@duckcodeailabs/dql-cli 1.12.11 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-CBGEoGmU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-CwAD3tXE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-CyqTuQe5.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-CnTbFVGT.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-BDPNVot1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DzAucwBW.js → HomePage-DiOnRhEG.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-DdVH-nz6.js → LineageDetailView-CfbSvlPJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-CgTScaGB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CSut-zvm.js → LineagePathBreadcrumb-D7ZA7k68.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-zg_1wW3M.js → MiniLineageGraph-GkD4y17x.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-9cDletl-.js → NewBlockModal-B9TfRjt7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-V6de8L4d.js → NewNotebookModal-BbO9NKUl.js} +2 -2
- package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bg-MjbC9.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DGuHB8kP.js → TrustBadge-vQQh8d0D.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-BDzY4MuQ.js → answer-to-notebook-DuqCcDDl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-IjlnAihE.js → arrow-left-CMe1kkOL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BI4cXgOY.js → arrow-right-DvB_DONr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-i6xhxu_I.js → book-open-text-CJ3NAvrs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-C6DE7Q6m.js → bot-CV8DYRrt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-DSEILnDs.js → chevron-up-HxU1l85K.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BoAorVSm.js → circle-x-BCgtha1W.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-CycymVj6.js → dagre.esm-GKp7qoUL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-ZwE5iHsX.js → external-link-C-PXokWV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Dnp2st8l.js → grip-vertical-B4EHbGXW.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-CTKe6Snr.js → link-2-BLx-goet.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-Ced8e_S1.js → list-tree-BRFpEmvV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-Cojc6867.js → maximize-2-CCd5uRIZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CBIAE0XH.js → minimize-2-CDwSCGlO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-po3bWSeL.js → panel-right-open-CunA1xO7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{pencil-Cb45c6WU.js → pencil-D_I14Wyk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-B9v1LTJ0.js → rotate-ccw-DOrfTZk8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-AfQvjt5R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CO4tfaDq.js → star-DDhv4e8M.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BSdIu2El.js → triangle-alert-2ZXx8wAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-BfrV8U-W.js → user-round-BA074kiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BgTxZNBc.js → wand-sparkles-CEYHLt9b.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow--2ycp0yy.js → workflow-CZtyrcR-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-LMCrpa9_.js → wrench-Ong23-wu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CeNgQwGm.js → x-CSo1M3tu.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +49 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1590 -323
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +12 -11
- package/dist/project-refresh-coordinator.d.ts +19 -0
- package/dist/project-refresh-coordinator.d.ts.map +1 -0
- package/dist/project-refresh-coordinator.js +134 -0
- package/dist/project-refresh-coordinator.js.map +1 -0
- package/dist/project-refresh-worker.d.ts +13 -0
- package/dist/project-refresh-worker.d.ts.map +1 -0
- package/dist/project-refresh-worker.js +58 -0
- package/dist/project-refresh-worker.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-CpL2kDCV.js +0 -5
- package/dist/assets/dql-notebook/assets/AiSidePanel-BCQB9rVF.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-Ba4Ve_Gd.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-Brg4fwn5.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-DHyDBChc.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-Cys4n_rq.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-QHqd_AM5.js +0 -1
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +0 -200
- package/dist/assets/dql-notebook/assets/ReadinessPage-BaGvjyfd.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +0 -83
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +0 -634
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-CkVFrrjk.js +0 -18
|
@@ -1,634 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-DzAucwBW.js","assets/TrustBadge-DGuHB8kP.js","assets/arrow-right-BI4cXgOY.js","assets/triangle-alert-BSdIu2El.js","assets/book-open-text-i6xhxu_I.js","assets/workflow--2ycp0yy.js","assets/react-CRB3T2We.js","assets/AnalyticsHome-Ba4Ve_Gd.js","assets/answer-to-notebook-BDzY4MuQ.js","assets/UnifiedAgentRunPanel-BlWAVEwO.js","assets/AgentAnswerCard-CpL2kDCV.js","assets/usePersistedAgentThreadId-CkVFrrjk.js","assets/AiBuildResult-D9t_4sQl.js","assets/user-round-BfrV8U-W.js","assets/rotate-ccw-B9v1LTJ0.js","assets/x-CeNgQwGm.js","assets/pencil-Cb45c6WU.js","assets/list-tree-Ced8e_S1.js","assets/wrench-LMCrpa9_.js","assets/chevron-up-DSEILnDs.js","assets/star-CO4tfaDq.js","assets/GlobalAiRail-Cys4n_rq.js","assets/AiSidePanel-BCQB9rVF.js","assets/minimize-2-CBIAE0XH.js","assets/maximize-2-Cojc6867.js","assets/NotebookEditor-EZ0pfWVs.js","assets/LineagePathBreadcrumb-CSut-zvm.js","assets/codemirror-DXt7RW72.js","assets/semantic-fields-B6ii0an0.js","assets/MiniLineageGraph-zg_1wW3M.js","assets/dagre.esm-CycymVj6.js","assets/dagre-BZV40eAE.css","assets/link-2-CTKe6Snr.js","assets/NewNotebookModal-V6de8L4d.js","assets/NewBlockModal-9cDletl-.js","assets/SetupOnboarding-Bg-MjbC9.js","assets/arrow-left-IjlnAihE.js","assets/BlockStudio-Brg4fwn5.js","assets/panel-right-open-po3bWSeL.js","assets/bot-C6DE7Q6m.js","assets/BusinessArtifactView-CnTbFVGT.js","assets/LineageDetailView-DdVH-nz6.js","assets/LineageDAG-QHqd_AM5.js","assets/HelpDocsPage-CL0vbSER.js","assets/GitPage-DHyDBChc.js","assets/external-link-ZwE5iHsX.js","assets/ReadinessPage-BaGvjyfd.js","assets/ai-build-bus-1BR770pY.js","assets/wand-sparkles-BgTxZNBc.js","assets/AgentLogPage-hzHqpD3-.js","assets/circle-x-BoAorVSm.js","assets/GovernedContextPage-DyKoDSZ2.js","assets/DbtFirstModelingPage-CQe2FUZq.js","assets/AppsView-CdAT9BOq.js","assets/grip-vertical-Dnp2st8l.js","assets/LineageDrawer-BvrVZNKY.js","assets/AiBuildDialog-BQRWoxp9.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Wd=Object.defineProperty;var Kd=(e,t,n)=>t in e?Wd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ee=(e,t,n)=>Kd(e,typeof t!="symbol"?t+"":t,n);import{r as La,a as Na,g as Ba}from"./react-CRB3T2We.js";function Vd(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var uo={exports:{}},An={};/**
|
|
3
|
-
* @license React
|
|
4
|
-
* react-jsx-runtime.production.min.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var ii;function Hd(){if(ii)return An;ii=1;var e=La(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(a,d,c){var f,p={},h=null,y=null;c!==void 0&&(h=""+c),d.key!==void 0&&(h=""+d.key),d.ref!==void 0&&(y=d.ref);for(f in d)r.call(d,f)&&!i.hasOwnProperty(f)&&(p[f]=d[f]);if(a&&a.defaultProps)for(f in d=a.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:a,key:h,ref:y,props:p,_owner:o.current}}return An.Fragment=n,An.jsx=l,An.jsxs=l,An}var ai;function Gd(){return ai||(ai=1,uo.exports=Hd()),uo.exports}var s=Gd(),pr={},li;function Jd(){if(li)return pr;li=1;var e=Na();return pr.createRoot=e.createRoot,pr.hydrateRoot=e.hydrateRoot,pr}var Qd=Jd(),u=La();const Ie=Ba(u),Fa=Vd({__proto__:null,default:Ie},[u]),fe={gray0:"#ffffff",gray50:"#f6f8fa",gray100:"#eaeef2",gray200:"#d0d7de",gray300:"#afb8c1",gray400:"#8c959f",gray600:"#57606a",gray900:"#24292f",gray950:"#1c2128",gray975:"#161b22",gray1000:"#0d1117",blue400:"#58a6ff",blue500:"#388bfd",blue600:"#0969da",blue700:"#0550ae",green500:"#56d364",green600:"#1f883d",red500:"#f85149",red600:"#cf222e",yellow500:"#e3b341",yellow600:"#9a6700"},me={1:"4px",2:"8px",3:"12px",4:"16px"},Nt={sm:"4px",md:"6px",lg:"8px"},ze={xs:"11px",sm:"12px",md:"14px"},ss={medium:"500",semibold:"600"},Wn={overlay:1e3,modal:1100,popover:1200,tooltip:1300},po={surfaceBase:fe.gray1000,surfaceRaised:fe.gray975,surfaceElevated:fe.gray950,surfaceOverlay:"rgba(0,0,0,0.7)",surfaceHover:fe.gray900,surfaceActive:"#1f2d3d",surfaceSunken:fe.gray1000,borderSubtle:"#21262d",borderDefault:"#30363d",borderStrong:"#484f58",borderFocus:fe.blue500,textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",textDisabled:"#32383f",textInverse:fe.gray1000,accent:fe.blue500,accentHover:fe.blue400,accentMuted:"rgba(56,139,253,0.15)",accentContrast:"#ffffff",success:fe.green500,warning:fe.yellow500,danger:fe.red500,info:fe.blue400,shadowSm:"0 1px 2px rgba(0,0,0,0.4)",shadowMd:"0 4px 10px rgba(0,0,0,0.45)",shadowLg:"0 12px 28px rgba(0,0,0,0.55)"},fr={surfaceBase:fe.gray0,surfaceRaised:fe.gray50,surfaceElevated:fe.gray0,surfaceOverlay:"rgba(0,0,0,0.4)",surfaceHover:fe.gray100,surfaceActive:"#dbeafe",surfaceSunken:fe.gray50,borderSubtle:fe.gray100,borderDefault:fe.gray200,borderStrong:fe.gray300,borderFocus:fe.blue600,textPrimary:"#1f2328",textSecondary:fe.gray600,textMuted:fe.gray400,textDisabled:fe.gray300,textInverse:fe.gray0,accent:fe.blue600,accentHover:fe.blue700,accentMuted:"rgba(9,105,218,0.12)",accentContrast:"#ffffff",success:fe.green600,warning:fe.yellow600,danger:fe.red600,info:fe.blue600,shadowSm:"0 1px 2px rgba(31,35,40,0.08)",shadowMd:"0 4px 10px rgba(31,35,40,0.1)",shadowLg:"0 12px 28px rgba(31,35,40,0.15)"},Yd={obsidian:po,paper:fr,white:fr,dark:po,light:fr,midnight:po,arctic:fr};function za(e){return`--dql-${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function ci(e){const t={};for(const[n,r]of Object.entries(e))t[za(n)]=r;return t}function le(e){return`var(${za(e)})`}const Xd=u.createContext(null);function Zd({theme:e,defaultTheme:t="dark",onThemeChange:n,applyGlobal:r=!1,children:o}){const[i,l]=u.useState(t),a=e??i,d=Yd[a],c=u.useCallback(h=>{e===void 0&&l(h),n==null||n(h)},[e,n]);u.useEffect(()=>{if(!r)return;const h=ci(d),y=document.documentElement;for(const[S,x]of Object.entries(h))y.style.setProperty(S,x);return y.setAttribute("data-theme",a),()=>{for(const S of Object.keys(h))y.style.removeProperty(S);y.removeAttribute("data-theme")}},[r,a,d]);const f=u.useMemo(()=>({theme:a,tokens:d,setTheme:c}),[a,d,c]),p=r?void 0:ci(d);return s.jsx(Xd.Provider,{value:f,children:s.jsx("div",{"data-theme":a,style:p,children:o})})}function se(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function di(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Vr(...e){return t=>{let n=!1;const r=e.map(o=>{const i=di(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():di(e[o],null)}}}}function je(...e){return u.useCallback(Vr(...e),e)}function eu(e,t){const n=u.createContext(t),r=i=>{const{children:l,...a}=i,d=u.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:d,children:l})};r.displayName=e+"Provider";function o(i){const l=u.useContext(n);if(l)return l;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Bt(e,t=[]){let n=[];function r(i,l){const a=u.createContext(l),d=n.length;n=[...n,l];const c=p=>{var w;const{scope:h,children:y,...S}=p,x=((w=h==null?void 0:h[e])==null?void 0:w[d])||a,b=u.useMemo(()=>S,Object.values(S));return s.jsx(x.Provider,{value:b,children:y})};c.displayName=i+"Provider";function f(p,h){var x;const y=((x=h==null?void 0:h[e])==null?void 0:x[d])||a,S=u.useContext(y);if(S)return S;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[c,f]}const o=()=>{const i=n.map(l=>u.createContext(l));return function(a){const d=(a==null?void 0:a[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[r,tu(o,...t)]}function tu(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const l=r.reduce((a,{useScope:d,scopeName:c})=>{const p=d(i)[`__scope${c}`];return{...a,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}var is=Na();const nu=Ba(is);function xn(e){const t=ru(e),n=u.forwardRef((r,o)=>{const{children:i,...l}=r,a=u.Children.toArray(i),d=a.find(su);if(d){const c=d.props.children,f=a.map(p=>p===d?u.Children.count(c)>1?u.Children.only(null):u.isValidElement(c)?c.props.children:null:p);return s.jsx(t,{...l,ref:o,children:u.isValidElement(c)?u.cloneElement(c,void 0,f):null})}return s.jsx(t,{...l,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function ru(e){const t=u.forwardRef((n,r)=>{const{children:o,...i}=n;if(u.isValidElement(o)){const l=au(o),a=iu(i,o.props);return o.type!==u.Fragment&&(a.ref=r?Vr(r,l):l),u.cloneElement(o,a)}return u.Children.count(o)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qa=Symbol("radix.slottable");function ou(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=qa,t}function su(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qa}function iu(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const d=i(...a);return o(...a),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function au(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],we=lu.reduce((e,t)=>{const n=xn(`Primitive.${t}`),r=u.forwardRef((o,i)=>{const{asChild:l,...a}=o,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ua(e,t){e&&is.flushSync(()=>e.dispatchEvent(t))}function Dt(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function cu(e,t=globalThis==null?void 0:globalThis.document){const n=Dt(e);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var du="DismissableLayer",qo="dismissableLayer.update",uu="dismissableLayer.pointerDownOutside",pu="dismissableLayer.focusOutside",ui,Wa=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Xn=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:l,onDismiss:a,...d}=e,c=u.useContext(Wa),[f,p]=u.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=u.useState({}),S=je(t,T=>p(T)),x=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),w=x.indexOf(b),C=f?x.indexOf(f):-1,E=c.layersWithOutsidePointerEventsDisabled.size>0,v=C>=w,j=mu(T=>{const g=T.target,$=[...c.branches].some(_=>_.contains(g));!v||$||(o==null||o(T),l==null||l(T),T.defaultPrevented||a==null||a())},h),O=gu(T=>{const g=T.target;[...c.branches].some(_=>_.contains(g))||(i==null||i(T),l==null||l(T),T.defaultPrevented||a==null||a())},h);return cu(T=>{C===c.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&a&&(T.preventDefault(),a()))},h),u.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(ui=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),pi(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=ui)}},[f,h,n,c]),u.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),pi())},[f,c]),u.useEffect(()=>{const T=()=>y({});return document.addEventListener(qo,T),()=>document.removeEventListener(qo,T)},[]),s.jsx(we.div,{...d,ref:S,style:{pointerEvents:E?v?"auto":"none":void 0,...e.style},onFocusCapture:se(e.onFocusCapture,O.onFocusCapture),onBlurCapture:se(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:se(e.onPointerDownCapture,j.onPointerDownCapture)})});Xn.displayName=du;var fu="DismissableLayerBranch",hu=u.forwardRef((e,t)=>{const n=u.useContext(Wa),r=u.useRef(null),o=je(t,r);return u.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(we.div,{...e,ref:o})});hu.displayName=fu;function mu(e,t=globalThis==null?void 0:globalThis.document){const n=Dt(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let d=function(){Ka(uu,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},l=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function gu(e,t=globalThis==null?void 0:globalThis.document){const n=Dt(e),r=u.useRef(!1);return u.useEffect(()=>{const o=i=>{i.target&&!r.current&&Ka(pu,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function pi(){const e=new CustomEvent(qo);document.dispatchEvent(e)}function Ka(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ua(o,i):o.dispatchEvent(i)}var Pt=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},yu=Fa[" useId ".trim().toString()]||(()=>{}),xu=0;function zn(e){const[t,n]=u.useState(yu());return Pt(()=>{n(r=>r??String(xu++))},[e]),t?`radix-${t}`:""}const bu=["top","right","bottom","left"],It=Math.min,Xe=Math.max,Dr=Math.round,hr=Math.floor,St=e=>({x:e,y:e}),vu={left:"right",right:"left",bottom:"top",top:"bottom"};function Uo(e,t,n){return Xe(e,It(t,n))}function Et(e,t){return typeof e=="function"?e(t):e}function Tt(e){return e.split("-")[0]}function wn(e){return e.split("-")[1]}function as(e){return e==="x"?"y":"x"}function ls(e){return e==="y"?"height":"width"}function vt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function cs(e){return as(vt(e))}function Su(e,t,n){n===void 0&&(n=!1);const r=wn(e),o=cs(e),i=ls(o);let l=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(l=Pr(l)),[l,Pr(l)]}function wu(e){const t=Pr(e);return[Wo(e),t,Wo(t)]}function Wo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const fi=["left","right"],hi=["right","left"],ku=["top","bottom"],ju=["bottom","top"];function Cu(e,t,n){switch(e){case"top":case"bottom":return n?t?hi:fi:t?fi:hi;case"left":case"right":return t?ku:ju;default:return[]}}function Eu(e,t,n,r){const o=wn(e);let i=Cu(Tt(e),n==="start",r);return o&&(i=i.map(l=>l+"-"+o),t&&(i=i.concat(i.map(Wo)))),i}function Pr(e){const t=Tt(e);return vu[t]+e.slice(t.length)}function Tu(e){return{top:0,right:0,bottom:0,left:0,...e}}function Va(e){return typeof e!="number"?Tu(e):{top:e,right:e,bottom:e,left:e}}function Ir(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function mi(e,t,n){let{reference:r,floating:o}=e;const i=vt(t),l=cs(t),a=ls(l),d=Tt(t),c=i==="y",f=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let y;switch(d){case"top":y={x:f,y:r.y-o.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:p};break;case"left":y={x:r.x-o.width,y:p};break;default:y={x:r.x,y:r.y}}switch(wn(t)){case"start":y[l]-=h*(n&&c?-1:1);break;case"end":y[l]+=h*(n&&c?-1:1);break}return y}async function Au(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:l,elements:a,strategy:d}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:h=!1,padding:y=0}=Et(t,e),S=Va(y),b=a[h?p==="floating"?"reference":"floating":p],w=Ir(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:d})),C=p==="floating"?{x:r,y:o,width:l.floating.width,height:l.floating.height}:l.reference,E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),v=await(i.isElement==null?void 0:i.isElement(E))?await(i.getScale==null?void 0:i.getScale(E))||{x:1,y:1}:{x:1,y:1},j=Ir(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:C,offsetParent:E,strategy:d}):C);return{top:(w.top-j.top+S.top)/v.y,bottom:(j.bottom-w.bottom+S.bottom)/v.y,left:(w.left-j.left+S.left)/v.x,right:(j.right-w.right+S.right)/v.x}}const Ru=50,_u=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:Au},d=await(l.isRTL==null?void 0:l.isRTL(t));let c=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=mi(c,r,d),h=r,y=0;const S={};for(let x=0;x<i.length;x++){const b=i[x];if(!b)continue;const{name:w,fn:C}=b,{x:E,y:v,data:j,reset:O}=await C({x:f,y:p,initialPlacement:r,placement:h,strategy:o,middlewareData:S,rects:c,platform:a,elements:{reference:e,floating:t}});f=E??f,p=v??p,S[w]={...S[w],...j},O&&y<Ru&&(y++,typeof O=="object"&&(O.placement&&(h=O.placement),O.rects&&(c=O.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):O.rects),{x:f,y:p}=mi(c,h,d)),x=-1)}return{x:f,y:p,placement:h,strategy:o,middlewareData:S}},Ou=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:l,elements:a,middlewareData:d}=t,{element:c,padding:f=0}=Et(e,t)||{};if(c==null)return{};const p=Va(f),h={x:n,y:r},y=cs(o),S=ls(y),x=await l.getDimensions(c),b=y==="y",w=b?"top":"left",C=b?"bottom":"right",E=b?"clientHeight":"clientWidth",v=i.reference[S]+i.reference[y]-h[y]-i.floating[S],j=h[y]-i.reference[y],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(c));let T=O?O[E]:0;(!T||!await(l.isElement==null?void 0:l.isElement(O)))&&(T=a.floating[E]||i.floating[S]);const g=v/2-j/2,$=T/2-x[S]/2-1,_=It(p[w],$),R=It(p[C],$),A=_,M=T-x[S]-R,B=T/2-x[S]/2+g,K=Uo(A,B,M),G=!d.arrow&&wn(o)!=null&&B!==K&&i.reference[S]/2-(B<A?_:R)-x[S]/2<0,V=G?B<A?B-A:B-M:0;return{[y]:h[y]+V,data:{[y]:K,centerOffset:B-K-V,...G&&{alignmentOffset:V}},reset:G}}}),$u=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:l,initialPlacement:a,platform:d,elements:c}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:x=!0,...b}=Et(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=Tt(o),C=vt(a),E=Tt(a)===a,v=await(d.isRTL==null?void 0:d.isRTL(c.floating)),j=h||(E||!x?[Pr(a)]:wu(a)),O=S!=="none";!h&&O&&j.push(...Eu(a,x,S,v));const T=[a,...j],g=await d.detectOverflow(t,b),$=[];let _=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&$.push(g[w]),p){const B=Su(o,l,v);$.push(g[B[0]],g[B[1]])}if(_=[..._,{placement:o,overflows:$}],!$.every(B=>B<=0)){var R,A;const B=(((R=i.flip)==null?void 0:R.index)||0)+1,K=T[B];if(K&&(!(p==="alignment"?C!==vt(K):!1)||_.every(I=>vt(I.placement)===C?I.overflows[0]>0:!0)))return{data:{index:B,overflows:_},reset:{placement:K}};let G=(A=_.filter(V=>V.overflows[0]<=0).sort((V,I)=>V.overflows[1]-I.overflows[1])[0])==null?void 0:A.placement;if(!G)switch(y){case"bestFit":{var M;const V=(M=_.filter(I=>{if(O){const D=vt(I.placement);return D===C||D==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(D=>D>0).reduce((D,Y)=>D+Y,0)]).sort((I,D)=>I[1]-D[1])[0])==null?void 0:M[0];V&&(G=V);break}case"initialPlacement":G=a;break}if(o!==G)return{reset:{placement:G}}}return{}}}};function gi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yi(e){return bu.some(t=>e[t]>=0)}const Du=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Et(e,t);switch(o){case"referenceHidden":{const l=await r.detectOverflow(t,{...i,elementContext:"reference"}),a=gi(l,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:yi(a)}}}case"escaped":{const l=await r.detectOverflow(t,{...i,altBoundary:!0}),a=gi(l,n.floating);return{data:{escapedOffsets:a,escaped:yi(a)}}}default:return{}}}}},Ha=new Set(["left","top"]);async function Pu(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),l=Tt(n),a=wn(n),d=vt(n)==="y",c=Ha.has(l)?-1:1,f=i&&d?-1:1,p=Et(t,e);let{mainAxis:h,crossAxis:y,alignmentAxis:S}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof S=="number"&&(y=a==="end"?S*-1:S),d?{x:y*f,y:h*c}:{x:h*c,y:y*f}}const Iu=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:l,middlewareData:a}=t,d=await Pu(t,e);return l===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:l}}}}},Mu=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:l=!0,crossAxis:a=!1,limiter:d={fn:w=>{let{x:C,y:E}=w;return{x:C,y:E}}},...c}=Et(e,t),f={x:n,y:r},p=await i.detectOverflow(t,c),h=vt(Tt(o)),y=as(h);let S=f[y],x=f[h];if(l){const w=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=S+p[w],v=S-p[C];S=Uo(E,S,v)}if(a){const w=h==="y"?"top":"left",C=h==="y"?"bottom":"right",E=x+p[w],v=x-p[C];x=Uo(E,x,v)}const b=d.fn({...t,[y]:S,[h]:x});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:l,[h]:a}}}}}},Lu=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:l}=t,{offset:a=0,mainAxis:d=!0,crossAxis:c=!0}=Et(e,t),f={x:n,y:r},p=vt(o),h=as(p);let y=f[h],S=f[p];const x=Et(a,t),b=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(d){const E=h==="y"?"height":"width",v=i.reference[h]-i.floating[E]+b.mainAxis,j=i.reference[h]+i.reference[E]-b.mainAxis;y<v?y=v:y>j&&(y=j)}if(c){var w,C;const E=h==="y"?"width":"height",v=Ha.has(Tt(o)),j=i.reference[p]-i.floating[E]+(v&&((w=l.offset)==null?void 0:w[p])||0)+(v?0:b.crossAxis),O=i.reference[p]+i.reference[E]+(v?0:((C=l.offset)==null?void 0:C[p])||0)-(v?b.crossAxis:0);S<j?S=j:S>O&&(S=O)}return{[h]:y,[p]:S}}}},Nu=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:l,elements:a}=t,{apply:d=()=>{},...c}=Et(e,t),f=await l.detectOverflow(t,c),p=Tt(o),h=wn(o),y=vt(o)==="y",{width:S,height:x}=i.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=h===(await(l.isRTL==null?void 0:l.isRTL(a.floating))?"start":"end")?"left":"right"):(w=p,b=h==="end"?"top":"bottom");const C=x-f.top-f.bottom,E=S-f.left-f.right,v=It(x-f[b],C),j=It(S-f[w],E),O=!t.middlewareData.shift;let T=v,g=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(g=E),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=C),O&&!h){const _=Xe(f.left,0),R=Xe(f.right,0),A=Xe(f.top,0),M=Xe(f.bottom,0);y?g=S-2*(_!==0||R!==0?_+R:Xe(f.left,f.right)):T=x-2*(A!==0||M!==0?A+M:Xe(f.top,f.bottom))}await d({...t,availableWidth:g,availableHeight:T});const $=await l.getDimensions(a.floating);return S!==$.width||x!==$.height?{reset:{rects:!0}}:{}}}};function Hr(){return typeof window<"u"}function kn(e){return Ga(e)?(e.nodeName||"").toLowerCase():"#document"}function Ze(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wt(e){var t;return(t=(Ga(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ga(e){return Hr()?e instanceof Node||e instanceof Ze(e).Node:!1}function ft(e){return Hr()?e instanceof Element||e instanceof Ze(e).Element:!1}function At(e){return Hr()?e instanceof HTMLElement||e instanceof Ze(e).HTMLElement:!1}function xi(e){return!Hr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ze(e).ShadowRoot}function Zn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ht(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Bu(e){return/^(table|td|th)$/.test(kn(e))}function Gr(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Fu=/transform|translate|scale|rotate|perspective|filter/,zu=/paint|layout|strict|content/,Kt=e=>!!e&&e!=="none";let fo;function ds(e){const t=ft(e)?ht(e):e;return Kt(t.transform)||Kt(t.translate)||Kt(t.scale)||Kt(t.rotate)||Kt(t.perspective)||!us()&&(Kt(t.backdropFilter)||Kt(t.filter))||Fu.test(t.willChange||"")||zu.test(t.contain||"")}function qu(e){let t=Mt(e);for(;At(t)&&!bn(t);){if(ds(t))return t;if(Gr(t))return null;t=Mt(t)}return null}function us(){return fo==null&&(fo=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fo}function bn(e){return/^(html|body|#document)$/.test(kn(e))}function ht(e){return Ze(e).getComputedStyle(e)}function Jr(e){return ft(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mt(e){if(kn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xi(e)&&e.host||wt(e);return xi(t)?t.host:t}function Ja(e){const t=Mt(e);return bn(t)?e.ownerDocument?e.ownerDocument.body:e.body:At(t)&&Zn(t)?t:Ja(t)}function Kn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ja(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),l=Ze(o);if(i){const a=Ko(l);return t.concat(l,l.visualViewport||[],Zn(o)?o:[],a&&n?Kn(a):[])}else return t.concat(o,Kn(o,[],n))}function Ko(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qa(e){const t=ht(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=At(e),i=o?e.offsetWidth:n,l=o?e.offsetHeight:r,a=Dr(n)!==i||Dr(r)!==l;return a&&(n=i,r=l),{width:n,height:r,$:a}}function ps(e){return ft(e)?e:e.contextElement}function mn(e){const t=ps(e);if(!At(t))return St(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Qa(t);let l=(i?Dr(n.width):n.width)/r,a=(i?Dr(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!a||!Number.isFinite(a))&&(a=1),{x:l,y:a}}const Uu=St(0);function Ya(e){const t=Ze(e);return!us()||!t.visualViewport?Uu:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wu(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ze(e)?!1:t}function Qt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ps(e);let l=St(1);t&&(r?ft(r)&&(l=mn(r)):l=mn(e));const a=Wu(i,n,r)?Ya(i):St(0);let d=(o.left+a.x)/l.x,c=(o.top+a.y)/l.y,f=o.width/l.x,p=o.height/l.y;if(i){const h=Ze(i),y=r&&ft(r)?Ze(r):r;let S=h,x=Ko(S);for(;x&&r&&y!==S;){const b=mn(x),w=x.getBoundingClientRect(),C=ht(x),E=w.left+(x.clientLeft+parseFloat(C.paddingLeft))*b.x,v=w.top+(x.clientTop+parseFloat(C.paddingTop))*b.y;d*=b.x,c*=b.y,f*=b.x,p*=b.y,d+=E,c+=v,S=Ze(x),x=Ko(S)}}return Ir({width:f,height:p,x:d,y:c})}function Qr(e,t){const n=Jr(e).scrollLeft;return t?t.left+n:Qt(wt(e)).left+n}function Xa(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Qr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ku(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",l=wt(r),a=t?Gr(t.floating):!1;if(r===l||a&&i)return n;let d={scrollLeft:0,scrollTop:0},c=St(1);const f=St(0),p=At(r);if((p||!p&&!i)&&((kn(r)!=="body"||Zn(l))&&(d=Jr(r)),p)){const y=Qt(r);c=mn(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const h=l&&!p&&!i?Xa(l,d):St(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-d.scrollLeft*c.x+f.x+h.x,y:n.y*c.y-d.scrollTop*c.y+f.y+h.y}}function Vu(e){return Array.from(e.getClientRects())}function Hu(e){const t=wt(e),n=Jr(e),r=e.ownerDocument.body,o=Xe(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Xe(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+Qr(e);const a=-n.scrollTop;return ht(r).direction==="rtl"&&(l+=Xe(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:l,y:a}}const bi=25;function Gu(e,t){const n=Ze(e),r=wt(e),o=n.visualViewport;let i=r.clientWidth,l=r.clientHeight,a=0,d=0;if(o){i=o.width,l=o.height;const f=us();(!f||f&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const c=Qr(r);if(c<=0){const f=r.ownerDocument,p=f.body,h=getComputedStyle(p),y=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,S=Math.abs(r.clientWidth-p.clientWidth-y);S<=bi&&(i-=S)}else c<=bi&&(i+=c);return{width:i,height:l,x:a,y:d}}function Ju(e,t){const n=Qt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=At(e)?mn(e):St(1),l=e.clientWidth*i.x,a=e.clientHeight*i.y,d=o*i.x,c=r*i.y;return{width:l,height:a,x:d,y:c}}function vi(e,t,n){let r;if(t==="viewport")r=Gu(e,n);else if(t==="document")r=Hu(wt(e));else if(ft(t))r=Ju(t,n);else{const o=Ya(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ir(r)}function Za(e,t){const n=Mt(e);return n===t||!ft(n)||bn(n)?!1:ht(n).position==="fixed"||Za(n,t)}function Qu(e,t){const n=t.get(e);if(n)return n;let r=Kn(e,[],!1).filter(a=>ft(a)&&kn(a)!=="body"),o=null;const i=ht(e).position==="fixed";let l=i?Mt(e):e;for(;ft(l)&&!bn(l);){const a=ht(l),d=ds(l);!d&&a.position==="fixed"&&(o=null),(i?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Zn(l)&&!d&&Za(e,l))?r=r.filter(f=>f!==l):o=a,l=Mt(l)}return t.set(e,r),r}function Yu(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const l=[...n==="clippingAncestors"?Gr(t)?[]:Qu(t,this._c):[].concat(n),r],a=vi(t,l[0],o);let d=a.top,c=a.right,f=a.bottom,p=a.left;for(let h=1;h<l.length;h++){const y=vi(t,l[h],o);d=Xe(y.top,d),c=It(y.right,c),f=It(y.bottom,f),p=Xe(y.left,p)}return{width:c-p,height:f-d,x:p,y:d}}function Xu(e){const{width:t,height:n}=Qa(e);return{width:t,height:n}}function Zu(e,t,n){const r=At(t),o=wt(t),i=n==="fixed",l=Qt(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const d=St(0);function c(){d.x=Qr(o)}if(r||!r&&!i)if((kn(t)!=="body"||Zn(o))&&(a=Jr(t)),r){const y=Qt(t,!0,i,t);d.x=y.x+t.clientLeft,d.y=y.y+t.clientTop}else o&&c();i&&!r&&o&&c();const f=o&&!r&&!i?Xa(o,a):St(0),p=l.left+a.scrollLeft-d.x-f.x,h=l.top+a.scrollTop-d.y-f.y;return{x:p,y:h,width:l.width,height:l.height}}function ho(e){return ht(e).position==="static"}function Si(e,t){if(!At(e)||ht(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wt(e)===n&&(n=n.ownerDocument.body),n}function el(e,t){const n=Ze(e);if(Gr(e))return n;if(!At(e)){let o=Mt(e);for(;o&&!bn(o);){if(ft(o)&&!ho(o))return o;o=Mt(o)}return n}let r=Si(e,t);for(;r&&Bu(r)&&ho(r);)r=Si(r,t);return r&&bn(r)&&ho(r)&&!ds(r)?n:r||qu(e)||n}const ep=async function(e){const t=this.getOffsetParent||el,n=this.getDimensions,r=await n(e.floating);return{reference:Zu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tp(e){return ht(e).direction==="rtl"}const np={convertOffsetParentRelativeRectToViewportRelativeRect:Ku,getDocumentElement:wt,getClippingRect:Yu,getOffsetParent:el,getElementRects:ep,getClientRects:Vu,getDimensions:Xu,getScale:mn,isElement:ft,isRTL:tp};function tl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rp(e,t){let n=null,r;const o=wt(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function l(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),i();const c=e.getBoundingClientRect(),{left:f,top:p,width:h,height:y}=c;if(a||t(),!h||!y)return;const S=hr(p),x=hr(o.clientWidth-(f+h)),b=hr(o.clientHeight-(p+y)),w=hr(f),E={rootMargin:-S+"px "+-x+"px "+-b+"px "+-w+"px",threshold:Xe(0,It(1,d))||1};let v=!0;function j(O){const T=O[0].intersectionRatio;if(T!==d){if(!v)return l();T?l(!1,T):r=setTimeout(()=>{l(!1,1e-7)},1e3)}T===1&&!tl(c,e.getBoundingClientRect())&&l(),v=!1}try{n=new IntersectionObserver(j,{...E,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,E)}n.observe(e)}return l(!0),i}function op(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,c=ps(e),f=o||i?[...c?Kn(c):[],...t?Kn(t):[]]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const p=c&&a?rp(c,n):null;let h=-1,y=null;l&&(y=new ResizeObserver(w=>{let[C]=w;C&&C.target===c&&y&&t&&(y.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(t)})),n()}),c&&!d&&y.observe(c),t&&y.observe(t));let S,x=d?Qt(e):null;d&&b();function b(){const w=Qt(e);x&&!tl(x,w)&&n(),x=w,S=requestAnimationFrame(b)}return n(),()=>{var w;f.forEach(C=>{o&&C.removeEventListener("scroll",n),i&&C.removeEventListener("resize",n)}),p==null||p(),(w=y)==null||w.disconnect(),y=null,d&&cancelAnimationFrame(S)}}const sp=Iu,ip=Mu,ap=$u,lp=Nu,cp=Du,wi=Ou,dp=Lu,up=(e,t,n)=>{const r=new Map,o={platform:np,...n},i={...o.platform,_c:r};return _u(e,t,{...o,platform:i})};var pp=typeof document<"u",fp=function(){},Ar=pp?u.useLayoutEffect:fp;function Mr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Mr(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Mr(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function nl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ki(e,t){const n=nl(e);return Math.round(t*n)/n}function mo(e){const t=u.useRef(e);return Ar(()=>{t.current=e}),t}function hp(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:l}={},transform:a=!0,whileElementsMounted:d,open:c}=e,[f,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,y]=u.useState(r);Mr(h,r)||y(r);const[S,x]=u.useState(null),[b,w]=u.useState(null),C=u.useCallback(I=>{I!==O.current&&(O.current=I,x(I))},[]),E=u.useCallback(I=>{I!==T.current&&(T.current=I,w(I))},[]),v=i||S,j=l||b,O=u.useRef(null),T=u.useRef(null),g=u.useRef(f),$=d!=null,_=mo(d),R=mo(o),A=mo(c),M=u.useCallback(()=>{if(!O.current||!T.current)return;const I={placement:t,strategy:n,middleware:h};R.current&&(I.platform=R.current),up(O.current,T.current,I).then(D=>{const Y={...D,isPositioned:A.current!==!1};B.current&&!Mr(g.current,Y)&&(g.current=Y,is.flushSync(()=>{p(Y)}))})},[h,t,n,R,A]);Ar(()=>{c===!1&&g.current.isPositioned&&(g.current.isPositioned=!1,p(I=>({...I,isPositioned:!1})))},[c]);const B=u.useRef(!1);Ar(()=>(B.current=!0,()=>{B.current=!1}),[]),Ar(()=>{if(v&&(O.current=v),j&&(T.current=j),v&&j){if(_.current)return _.current(v,j,M);M()}},[v,j,M,_,$]);const K=u.useMemo(()=>({reference:O,floating:T,setReference:C,setFloating:E}),[C,E]),G=u.useMemo(()=>({reference:v,floating:j}),[v,j]),V=u.useMemo(()=>{const I={position:n,left:0,top:0};if(!G.floating)return I;const D=ki(G.floating,f.x),Y=ki(G.floating,f.y);return a?{...I,transform:"translate("+D+"px, "+Y+"px)",...nl(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:Y}},[n,a,G.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:M,refs:K,elements:G,floatingStyles:V}),[f,M,K,G,V])}const mp=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?wi({element:r.current,padding:o}).fn(n):{}:r?wi({element:r,padding:o}).fn(n):{}}}},gp=(e,t)=>{const n=sp(e);return{name:n.name,fn:n.fn,options:[e,t]}},yp=(e,t)=>{const n=ip(e);return{name:n.name,fn:n.fn,options:[e,t]}},xp=(e,t)=>({fn:dp(e).fn,options:[e,t]}),bp=(e,t)=>{const n=ap(e);return{name:n.name,fn:n.fn,options:[e,t]}},vp=(e,t)=>{const n=lp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sp=(e,t)=>{const n=cp(e);return{name:n.name,fn:n.fn,options:[e,t]}},wp=(e,t)=>{const n=mp(e);return{name:n.name,fn:n.fn,options:[e,t]}};var kp="Arrow",rl=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(we.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});rl.displayName=kp;var jp=rl;function Cp(e){const[t,n]=u.useState(void 0);return Pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let l,a;if("borderBoxSize"in i){const d=i.borderBoxSize,c=Array.isArray(d)?d[0]:d;l=c.inlineSize,a=c.blockSize}else l=e.offsetWidth,a=e.offsetHeight;n({width:l,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var fs="Popper",[ol,jn]=Bt(fs),[Ep,sl]=ol(fs),il=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return s.jsx(Ep,{scope:t,anchor:r,onAnchorChange:o,children:n})};il.displayName=fs;var al="PopperAnchor",ll=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=sl(al,n),l=u.useRef(null),a=je(t,l),d=u.useRef(null);return u.useEffect(()=>{const c=d.current;d.current=(r==null?void 0:r.current)||l.current,c!==d.current&&i.onAnchorChange(d.current)}),r?null:s.jsx(we.div,{...o,ref:a})});ll.displayName=al;var hs="PopperContent",[Tp,Ap]=ol(hs),cl=u.forwardRef((e,t)=>{var ue,ie,ge,Oe,$e,Ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:l=0,arrowPadding:a=0,avoidCollisions:d=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:y="optimized",onPlaced:S,...x}=e,b=sl(hs,n),[w,C]=u.useState(null),E=je(t,xe=>C(xe)),[v,j]=u.useState(null),O=Cp(v),T=(O==null?void 0:O.width)??0,g=(O==null?void 0:O.height)??0,$=r+(i!=="center"?"-"+i:""),_=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},R=Array.isArray(c)?c:[c],A=R.length>0,M={padding:_,boundary:R.filter(_p),altBoundary:A},{refs:B,floatingStyles:K,placement:G,isPositioned:V,middlewareData:I}=hp({strategy:"fixed",placement:$,whileElementsMounted:(...xe)=>op(...xe,{animationFrame:y==="always"}),elements:{reference:b.anchor},middleware:[gp({mainAxis:o+g,alignmentAxis:l}),d&&yp({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?xp():void 0,...M}),d&&bp({...M}),vp({...M,apply:({elements:xe,rects:pe,availableWidth:Be,availableHeight:Ue})=>{const{width:De,height:Me}=pe.reference,et=xe.floating.style;et.setProperty("--radix-popper-available-width",`${Be}px`),et.setProperty("--radix-popper-available-height",`${Ue}px`),et.setProperty("--radix-popper-anchor-width",`${De}px`),et.setProperty("--radix-popper-anchor-height",`${Me}px`)}}),v&&wp({element:v,padding:a}),Op({arrowWidth:T,arrowHeight:g}),h&&Sp({strategy:"referenceHidden",...M})]}),[D,Y]=pl(G),U=Dt(S);Pt(()=>{V&&(U==null||U())},[V,U]);const te=(ue=I.arrow)==null?void 0:ue.x,Q=(ie=I.arrow)==null?void 0:ie.y,F=((ge=I.arrow)==null?void 0:ge.centerOffset)!==0,[ee,ce]=u.useState();return Pt(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:V?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Oe=I.transformOrigin)==null?void 0:Oe.x,($e=I.transformOrigin)==null?void 0:$e.y].join(" "),...((Ne=I.hide)==null?void 0:Ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(Tp,{scope:n,placedSide:D,onArrowChange:j,arrowX:te,arrowY:Q,shouldHideArrow:F,children:s.jsx(we.div,{"data-side":D,"data-align":Y,...x,ref:E,style:{...x.style,animation:V?void 0:"none"}})})})});cl.displayName=hs;var dl="PopperArrow",Rp={top:"bottom",right:"left",bottom:"top",left:"right"},ul=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Ap(dl,r),l=Rp[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx(jp,{...o,ref:n,style:{...o.style,display:"block"}})})});ul.displayName=dl;function _p(e){return e!==null}var Op=e=>({name:"transformOrigin",options:e,fn(t){var b,w,C;const{placement:n,rects:r,middlewareData:o}=t,l=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[c,f]=pl(n),p={start:"0%",center:"50%",end:"100%"}[f],h=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,y=(((C=o.arrow)==null?void 0:C.y)??0)+d/2;let S="",x="";return c==="bottom"?(S=l?p:`${h}px`,x=`${-d}px`):c==="top"?(S=l?p:`${h}px`,x=`${r.floating.height+d}px`):c==="right"?(S=`${-d}px`,x=l?p:`${y}px`):c==="left"&&(S=`${r.floating.width+d}px`,x=l?p:`${y}px`),{data:{x:S,y:x}}}});function pl(e){const[t,n="center"]=e.split("-");return[t,n]}var $p=il,Yr=ll,ms=cl,gs=ul,Dp="Portal",er=u.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=u.useState(!1);Pt(()=>i(!0),[]);const l=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return l?nu.createPortal(s.jsx(we.div,{...r,ref:t}),l):null});er.displayName=Dp;function Pp(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var it=e=>{const{present:t,children:n}=e,r=Ip(t),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),i=je(r.ref,Mp(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:i}):null};it.displayName="Presence";function Ip(e){const[t,n]=u.useState(),r=u.useRef(null),o=u.useRef(e),i=u.useRef("none"),l=e?"mounted":"unmounted",[a,d]=Pp(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const c=mr(r.current);i.current=a==="mounted"?c:"none"},[a]),Pt(()=>{const c=r.current,f=o.current;if(f!==e){const h=i.current,y=mr(c);e?d("MOUNT"):y==="none"||(c==null?void 0:c.display)==="none"?d("UNMOUNT"):d(f&&h!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Pt(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,p=y=>{const x=mr(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&x&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},h=y=>{y.target===t&&(i.current=mr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:u.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function mr(e){return(e==null?void 0:e.animationName)||"none"}function Mp(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Lp=Fa[" useInsertionEffect ".trim().toString()]||Pt;function ys({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,l]=Np({defaultProp:t,onChange:n}),a=e!==void 0,d=a?e:o;{const f=u.useRef(e!==void 0);u.useEffect(()=>{const p=f.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,r])}const c=u.useCallback(f=>{var p;if(a){const h=Bp(f)?f(e):f;h!==e&&((p=l.current)==null||p.call(l,h))}else i(f)},[a,e,i,l]);return[d,c]}function Np({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),o=u.useRef(n),i=u.useRef(t);return Lp(()=>{i.current=t},[t]),u.useEffect(()=>{var l;o.current!==n&&((l=i.current)==null||l.call(i,n),o.current=n)},[n,o]),[n,r,i]}function Bp(e){return typeof e=="function"}var Fp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),zp="VisuallyHidden",fl=u.forwardRef((e,t)=>s.jsx(we.span,{...e,ref:t,style:{...Fp,...e.style}}));fl.displayName=zp;var qp=fl,[Xr]=Bt("Tooltip",[jn]),Zr=jn(),hl="TooltipProvider",Up=700,Vo="tooltip.open",[Wp,xs]=Xr(hl),ml=e=>{const{__scopeTooltip:t,delayDuration:n=Up,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,l=u.useRef(!0),a=u.useRef(!1),d=u.useRef(0);return u.useEffect(()=>{const c=d.current;return()=>window.clearTimeout(c)},[]),s.jsx(Wp,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:u.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:i})};ml.displayName=hl;var Vn="Tooltip",[Kp,tr]=Xr(Vn),gl=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:l,delayDuration:a}=e,d=xs(Vn,e.__scopeTooltip),c=Zr(t),[f,p]=u.useState(null),h=zn(),y=u.useRef(0),S=l??d.disableHoverableContent,x=a??d.delayDuration,b=u.useRef(!1),[w,C]=ys({prop:r,defaultProp:o??!1,onChange:T=>{T?(d.onOpen(),document.dispatchEvent(new CustomEvent(Vo))):d.onClose(),i==null||i(T)},caller:Vn}),E=u.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),v=u.useCallback(()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,C(!0)},[C]),j=u.useCallback(()=>{window.clearTimeout(y.current),y.current=0,C(!1)},[C]),O=u.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,C(!0),y.current=0},x)},[x,C]);return u.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),s.jsx($p,{...c,children:s.jsx(Kp,{scope:t,contentId:h,open:w,stateAttribute:E,trigger:f,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{d.isOpenDelayedRef.current?O():v()},[d.isOpenDelayedRef,O,v]),onTriggerLeave:u.useCallback(()=>{S?j():(window.clearTimeout(y.current),y.current=0)},[j,S]),onOpen:v,onClose:j,disableHoverableContent:S,children:n})})};gl.displayName=Vn;var Ho="TooltipTrigger",yl=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=tr(Ho,n),i=xs(Ho,n),l=Zr(n),a=u.useRef(null),d=je(t,a,o.onTriggerChange),c=u.useRef(!1),f=u.useRef(!1),p=u.useCallback(()=>c.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),s.jsx(Yr,{asChild:!0,...l,children:s.jsx(we.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:se(e.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:se(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:se(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:se(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:se(e.onBlur,o.onClose),onClick:se(e.onClick,o.onClose)})})});yl.displayName=Ho;var bs="TooltipPortal",[Vp,Hp]=Xr(bs,{forceMount:void 0}),xl=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=tr(bs,t);return s.jsx(Vp,{scope:t,forceMount:n,children:s.jsx(it,{present:n||i.open,children:s.jsx(er,{asChild:!0,container:o,children:r})})})};xl.displayName=bs;var vn="TooltipContent",bl=u.forwardRef((e,t)=>{const n=Hp(vn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,l=tr(vn,e.__scopeTooltip);return s.jsx(it,{present:r||l.open,children:l.disableHoverableContent?s.jsx(vl,{side:o,...i,ref:t}):s.jsx(Gp,{side:o,...i,ref:t})})}),Gp=u.forwardRef((e,t)=>{const n=tr(vn,e.__scopeTooltip),r=xs(vn,e.__scopeTooltip),o=u.useRef(null),i=je(t,o),[l,a]=u.useState(null),{trigger:d,onClose:c}=n,f=o.current,{onPointerInTransitChange:p}=r,h=u.useCallback(()=>{a(null),p(!1)},[p]),y=u.useCallback((S,x)=>{const b=S.currentTarget,w={x:S.clientX,y:S.clientY},C=Zp(w,b.getBoundingClientRect()),E=ef(w,C),v=tf(x.getBoundingClientRect()),j=rf([...E,...v]);a(j),p(!0)},[p]);return u.useEffect(()=>()=>h(),[h]),u.useEffect(()=>{if(d&&f){const S=b=>y(b,f),x=b=>y(b,d);return d.addEventListener("pointerleave",S),f.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",S),f.removeEventListener("pointerleave",x)}}},[d,f,y,h]),u.useEffect(()=>{if(l){const S=x=>{const b=x.target,w={x:x.clientX,y:x.clientY},C=(d==null?void 0:d.contains(b))||(f==null?void 0:f.contains(b)),E=!nf(w,l);C?h():E&&(h(),c())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[d,f,l,c,h]),s.jsx(vl,{...e,ref:i})}),[Jp,Qp]=Xr(Vn,{isInside:!1}),Yp=ou("TooltipContent"),vl=u.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:l,...a}=e,d=tr(vn,n),c=Zr(n),{onClose:f}=d;return u.useEffect(()=>(document.addEventListener(Vo,f),()=>document.removeEventListener(Vo,f)),[f]),u.useEffect(()=>{if(d.trigger){const p=h=>{const y=h.target;y!=null&&y.contains(d.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,f]),s.jsx(Xn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:l,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:s.jsxs(ms,{"data-state":d.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(Yp,{children:r}),s.jsx(Jp,{scope:n,isInside:!0,children:s.jsx(qp,{id:d.contentId,role:"tooltip",children:o||r})})]})})});bl.displayName=vn;var Sl="TooltipArrow",Xp=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Zr(n);return Qp(Sl,n).isInside?null:s.jsx(gs,{...o,...r,ref:t})});Xp.displayName=Sl;function Zp(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function ef(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function tf(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function nf(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,l=t.length-1;i<t.length;l=i++){const a=t[i],d=t[l],c=a.x,f=a.y,p=d.x,h=d.y;f>r!=h>r&&n<(p-c)*(r-f)/(h-f)+c&&(o=!o)}return o}function rf(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),of(t)}function of(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],l=t[t.length-2];if((i.x-l.x)*(o.y-l.y)>=(i.y-l.y)*(o.x-l.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],l=n[n.length-2];if((i.x-l.x)*(o.y-l.y)>=(i.y-l.y)*(o.x-l.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var sf=ml,af=gl,lf=yl,cf=xl,df=bl;function wl({content:e,children:t,side:n="right",align:r="center",sideOffset:o=6,delayMs:i=200,container:l}){return s.jsxs(af,{delayDuration:i,children:[s.jsx(lf,{asChild:!0,children:t}),s.jsx(cf,{container:l,children:s.jsx(df,{side:n,align:r,sideOffset:o,style:{background:le("surfaceElevated"),color:le("textPrimary"),border:`1px solid ${le("borderDefault")}`,borderRadius:Nt.sm,padding:`${me[1]} ${me[2]}`,fontSize:ze.sm,boxShadow:le("shadowMd"),zIndex:Wn.tooltip,userSelect:"none"},children:e})})]})}const uf=sf;var go="focusScope.autoFocusOnMount",yo="focusScope.autoFocusOnUnmount",ji={bubbles:!1,cancelable:!0},pf="FocusScope",eo=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...l}=e,[a,d]=u.useState(null),c=Dt(o),f=Dt(i),p=u.useRef(null),h=je(t,x=>d(x)),y=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let x=function(E){if(y.paused||!a)return;const v=E.target;a.contains(v)?p.current=v:$t(p.current,{select:!0})},b=function(E){if(y.paused||!a)return;const v=E.relatedTarget;v!==null&&(a.contains(v)||$t(p.current,{select:!0}))},w=function(E){if(document.activeElement===document.body)for(const j of E)j.removedNodes.length>0&&$t(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",b);const C=new MutationObserver(w);return a&&C.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",b),C.disconnect()}}},[r,a,y.paused]),u.useEffect(()=>{if(a){Ei.add(y);const x=document.activeElement;if(!a.contains(x)){const w=new CustomEvent(go,ji);a.addEventListener(go,c),a.dispatchEvent(w),w.defaultPrevented||(ff(xf(kl(a)),{select:!0}),document.activeElement===x&&$t(a))}return()=>{a.removeEventListener(go,c),setTimeout(()=>{const w=new CustomEvent(yo,ji);a.addEventListener(yo,f),a.dispatchEvent(w),w.defaultPrevented||$t(x??document.body,{select:!0}),a.removeEventListener(yo,f),Ei.remove(y)},0)}}},[a,c,f,y]);const S=u.useCallback(x=>{if(!n&&!r||y.paused)return;const b=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,w=document.activeElement;if(b&&w){const C=x.currentTarget,[E,v]=hf(C);E&&v?!x.shiftKey&&w===v?(x.preventDefault(),n&&$t(E,{select:!0})):x.shiftKey&&w===E&&(x.preventDefault(),n&&$t(v,{select:!0})):w===C&&x.preventDefault()}},[n,r,y.paused]);return s.jsx(we.div,{tabIndex:-1,...l,ref:h,onKeyDown:S})});eo.displayName=pf;function ff(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($t(r,{select:t}),document.activeElement!==n)return}function hf(e){const t=kl(e),n=Ci(t,e),r=Ci(t.reverse(),e);return[n,r]}function kl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ci(e,t){for(const n of e)if(!mf(n,{upTo:t}))return n}function mf(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gf(e){return e instanceof HTMLInputElement&&"select"in e}function $t(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&gf(e)&&t&&e.select()}}var Ei=yf();function yf(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ti(e,t),e.unshift(t)},remove(t){var n;e=Ti(e,t),(n=e[0])==null||n.resume()}}}function Ti(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function xf(e){return e.filter(t=>t.tagName!=="A")}var xo=0;function vs(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ai()),document.body.insertAdjacentElement("beforeend",e[1]??Ai()),xo++,()=>{xo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),xo--}},[])}function Ai(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var xt=function(){return xt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},xt.apply(this,arguments)};function jl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function bf(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Rr="right-scroll-bar-position",_r="width-before-scroll-bar",vf="with-scroll-bars-hidden",Sf="--removed-body-scroll-bar-size";function bo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function wf(e,t){var n=u.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var kf=typeof window<"u"?u.useLayoutEffect:u.useEffect,Ri=new WeakMap;function jf(e,t){var n=wf(null,function(r){return e.forEach(function(o){return bo(o,r)})});return kf(function(){var r=Ri.get(n);if(r){var o=new Set(r),i=new Set(e),l=n.current;o.forEach(function(a){i.has(a)||bo(a,null)}),i.forEach(function(a){o.has(a)||bo(a,l)})}Ri.set(n,e)},[e]),n}function Cf(e){return e}function Ef(e,t){t===void 0&&(t=Cf);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var l=t(i,r);return n.push(l),function(){n=n.filter(function(a){return a!==l})}},assignSyncMedium:function(i){for(r=!0;n.length;){var l=n;n=[],l.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var l=[];if(n.length){var a=n;n=[],a.forEach(i),l=n}var d=function(){var f=l;l=[],f.forEach(i)},c=function(){return Promise.resolve().then(d)};c(),n={push:function(f){l.push(f),c()},filter:function(f){return l=l.filter(f),n}}}};return o}function Tf(e){e===void 0&&(e={});var t=Ef(null);return t.options=xt({async:!0,ssr:!1},e),t}var Cl=function(e){var t=e.sideCar,n=jl(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,xt({},n))};Cl.isSideCarExport=!0;function Af(e,t){return e.useMedium(t),Cl}var El=Tf(),vo=function(){},to=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:vo,onWheelCapture:vo,onTouchMoveCapture:vo}),o=r[0],i=r[1],l=e.forwardProps,a=e.children,d=e.className,c=e.removeScrollBar,f=e.enabled,p=e.shards,h=e.sideCar,y=e.noRelative,S=e.noIsolation,x=e.inert,b=e.allowPinchZoom,w=e.as,C=w===void 0?"div":w,E=e.gapMode,v=jl(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,O=jf([n,t]),T=xt(xt({},v),o);return u.createElement(u.Fragment,null,f&&u.createElement(j,{sideCar:El,removeScrollBar:c,shards:p,noRelative:y,noIsolation:S,inert:x,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:E}),l?u.cloneElement(u.Children.only(a),xt(xt({},T),{ref:O})):u.createElement(C,xt({},T,{className:d,ref:O}),a))});to.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};to.classNames={fullWidth:_r,zeroRight:Rr};var Rf=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function _f(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Rf();return t&&e.setAttribute("nonce",t),e}function Of(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $f(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Df=function(){var e=0,t=null;return{add:function(n){e==0&&(t=_f())&&(Of(t,n),$f(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Pf=function(){var e=Df();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Tl=function(){var e=Pf(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},If={left:0,top:0,right:0,gap:0},So=function(e){return parseInt(e||"",10)||0},Mf=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[So(n),So(r),So(o)]},Lf=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return If;var t=Mf(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Nf=Tl(),gn="data-scroll-locked",Bf=function(e,t,n,r){var o=e.left,i=e.top,l=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
11
|
-
.`.concat(vf,` {
|
|
12
|
-
overflow: hidden `).concat(r,`;
|
|
13
|
-
padding-right: `).concat(a,"px ").concat(r,`;
|
|
14
|
-
}
|
|
15
|
-
body[`).concat(gn,`] {
|
|
16
|
-
overflow: hidden `).concat(r,`;
|
|
17
|
-
overscroll-behavior: contain;
|
|
18
|
-
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
19
|
-
padding-left: `.concat(o,`px;
|
|
20
|
-
padding-top: `).concat(i,`px;
|
|
21
|
-
padding-right: `).concat(l,`px;
|
|
22
|
-
margin-left:0;
|
|
23
|
-
margin-top:0;
|
|
24
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
25
|
-
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.`).concat(Rr,` {
|
|
29
|
-
right: `).concat(a,"px ").concat(r,`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.`).concat(_r,` {
|
|
33
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.`).concat(Rr," .").concat(Rr,` {
|
|
37
|
-
right: 0 `).concat(r,`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.`).concat(_r," .").concat(_r,` {
|
|
41
|
-
margin-right: 0 `).concat(r,`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
body[`).concat(gn,`] {
|
|
45
|
-
`).concat(Sf,": ").concat(a,`px;
|
|
46
|
-
}
|
|
47
|
-
`)},_i=function(){var e=parseInt(document.body.getAttribute(gn)||"0",10);return isFinite(e)?e:0},Ff=function(){u.useEffect(function(){return document.body.setAttribute(gn,(_i()+1).toString()),function(){var e=_i()-1;e<=0?document.body.removeAttribute(gn):document.body.setAttribute(gn,e.toString())}},[])},zf=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Ff();var i=u.useMemo(function(){return Lf(o)},[o]);return u.createElement(Nf,{styles:Bf(i,!t,o,n?"":"!important")})},Go=!1;if(typeof window<"u")try{var gr=Object.defineProperty({},"passive",{get:function(){return Go=!0,!0}});window.addEventListener("test",gr,gr),window.removeEventListener("test",gr,gr)}catch{Go=!1}var sn=Go?{passive:!1}:!1,qf=function(e){return e.tagName==="TEXTAREA"},Al=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!qf(e)&&n[t]==="visible")},Uf=function(e){return Al(e,"overflowY")},Wf=function(e){return Al(e,"overflowX")},Oi=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Rl(e,r);if(o){var i=_l(e,r),l=i[1],a=i[2];if(l>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Kf=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Vf=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Rl=function(e,t){return e==="v"?Uf(t):Wf(t)},_l=function(e,t){return e==="v"?Kf(t):Vf(t)},Hf=function(e,t){return e==="h"&&t==="rtl"?-1:1},Gf=function(e,t,n,r,o){var i=Hf(e,window.getComputedStyle(t).direction),l=i*r,a=n.target,d=t.contains(a),c=!1,f=l>0,p=0,h=0;do{if(!a)break;var y=_l(e,a),S=y[0],x=y[1],b=y[2],w=x-b-i*S;(S||w)&&Rl(e,a)&&(p+=w,h+=S);var C=a.parentNode;a=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&a!==document.body||d&&(t.contains(a)||t===a));return(f&&Math.abs(p)<1||!f&&Math.abs(h)<1)&&(c=!0),c},yr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$i=function(e){return[e.deltaX,e.deltaY]},Di=function(e){return e&&"current"in e?e.current:e},Jf=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qf=function(e){return`
|
|
48
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
49
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
50
|
-
`)},Yf=0,an=[];function Xf(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(Yf++)[0],i=u.useState(Tl)[0],l=u.useRef(e);u.useEffect(function(){l.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=bf([e.lockRef.current],(e.shards||[]).map(Di),!0).filter(Boolean);return x.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=u.useCallback(function(x,b){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!l.current.allowPinchZoom;var w=yr(x),C=n.current,E="deltaX"in x?x.deltaX:C[0]-w[0],v="deltaY"in x?x.deltaY:C[1]-w[1],j,O=x.target,T=Math.abs(E)>Math.abs(v)?"h":"v";if("touches"in x&&T==="h"&&O.type==="range")return!1;var g=window.getSelection(),$=g&&g.anchorNode,_=$?$===O||$.contains(O):!1;if(_)return!1;var R=Oi(T,O);if(!R)return!0;if(R?j=T:(j=T==="v"?"h":"v",R=Oi(T,O)),!R)return!1;if(!r.current&&"changedTouches"in x&&(E||v)&&(r.current=j),!j)return!0;var A=r.current||j;return Gf(A,b,x,A==="h"?E:v)},[]),d=u.useCallback(function(x){var b=x;if(!(!an.length||an[an.length-1]!==i)){var w="deltaY"in b?$i(b):yr(b),C=t.current.filter(function(j){return j.name===b.type&&(j.target===b.target||b.target===j.shadowParent)&&Jf(j.delta,w)})[0];if(C&&C.should){b.cancelable&&b.preventDefault();return}if(!C){var E=(l.current.shards||[]).map(Di).filter(Boolean).filter(function(j){return j.contains(b.target)}),v=E.length>0?a(b,E[0]):!l.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),c=u.useCallback(function(x,b,w,C){var E={name:x,delta:b,target:w,should:C,shadowParent:Zf(w)};t.current.push(E),setTimeout(function(){t.current=t.current.filter(function(v){return v!==E})},1)},[]),f=u.useCallback(function(x){n.current=yr(x),r.current=void 0},[]),p=u.useCallback(function(x){c(x.type,$i(x),x.target,a(x,e.lockRef.current))},[]),h=u.useCallback(function(x){c(x.type,yr(x),x.target,a(x,e.lockRef.current))},[]);u.useEffect(function(){return an.push(i),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",d,sn),document.addEventListener("touchmove",d,sn),document.addEventListener("touchstart",f,sn),function(){an=an.filter(function(x){return x!==i}),document.removeEventListener("wheel",d,sn),document.removeEventListener("touchmove",d,sn),document.removeEventListener("touchstart",f,sn)}},[]);var y=e.removeScrollBar,S=e.inert;return u.createElement(u.Fragment,null,S?u.createElement(i,{styles:Qf(o)}):null,y?u.createElement(zf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zf(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const eh=Af(El,Xf);var no=u.forwardRef(function(e,t){return u.createElement(to,xt({},e,{ref:t,sideCar:eh}))});no.classNames=to.classNames;var th=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ln=new WeakMap,xr=new WeakMap,br={},wo=0,Ol=function(e){return e&&(e.host||Ol(e.parentNode))},nh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ol(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},rh=function(e,t,n,r){var o=nh(t,Array.isArray(e)?e:[e]);br[n]||(br[n]=new WeakMap);var i=br[n],l=[],a=new Set,d=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var f=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(h){if(a.has(h))f(h);else try{var y=h.getAttribute(r),S=y!==null&&y!=="false",x=(ln.get(h)||0)+1,b=(i.get(h)||0)+1;ln.set(h,x),i.set(h,b),l.push(h),x===1&&S&&xr.set(h,!0),b===1&&h.setAttribute(n,"true"),S||h.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",h,w)}})};return f(t),a.clear(),wo++,function(){l.forEach(function(p){var h=ln.get(p)-1,y=i.get(p)-1;ln.set(p,h),i.set(p,y),h||(xr.has(p)||p.removeAttribute(r),xr.delete(p)),y||p.removeAttribute(n)}),wo--,wo||(ln=new WeakMap,ln=new WeakMap,xr=new WeakMap,br={})}},Ss=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=th(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),rh(r,o,n,"aria-hidden")):function(){return null}},ro="Dialog",[$l]=Bt(ro),[oh,mt]=$l(ro),Dl=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:l=!0}=e,a=u.useRef(null),d=u.useRef(null),[c,f]=ys({prop:r,defaultProp:o??!1,onChange:i,caller:ro});return s.jsx(oh,{scope:t,triggerRef:a,contentRef:d,contentId:zn(),titleId:zn(),descriptionId:zn(),open:c,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:l,children:n})};Dl.displayName=ro;var Pl="DialogTrigger",sh=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mt(Pl,n),i=je(t,o.triggerRef);return s.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":js(o.open),...r,ref:i,onClick:se(e.onClick,o.onOpenToggle)})});sh.displayName=Pl;var ws="DialogPortal",[ih,Il]=$l(ws,{forceMount:void 0}),Ml=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=mt(ws,t);return s.jsx(ih,{scope:t,forceMount:n,children:u.Children.map(r,l=>s.jsx(it,{present:n||i.open,children:s.jsx(er,{asChild:!0,container:o,children:l})}))})};Ml.displayName=ws;var Lr="DialogOverlay",Ll=u.forwardRef((e,t)=>{const n=Il(Lr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=mt(Lr,e.__scopeDialog);return i.modal?s.jsx(it,{present:r||i.open,children:s.jsx(lh,{...o,ref:t})}):null});Ll.displayName=Lr;var ah=xn("DialogOverlay.RemoveScroll"),lh=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mt(Lr,n);return s.jsx(no,{as:ah,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(we.div,{"data-state":js(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Yt="DialogContent",Nl=u.forwardRef((e,t)=>{const n=Il(Yt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=mt(Yt,e.__scopeDialog);return s.jsx(it,{present:r||i.open,children:i.modal?s.jsx(ch,{...o,ref:t}):s.jsx(dh,{...o,ref:t})})});Nl.displayName=Yt;var ch=u.forwardRef((e,t)=>{const n=mt(Yt,e.__scopeDialog),r=u.useRef(null),o=je(t,n.contentRef,r);return u.useEffect(()=>{const i=r.current;if(i)return Ss(i)},[]),s.jsx(Bl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:se(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0;(l.button===2||a)&&i.preventDefault()}),onFocusOutside:se(e.onFocusOutside,i=>i.preventDefault())})}),dh=u.forwardRef((e,t)=>{const n=mt(Yt,e.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return s.jsx(Bl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var l,a;(l=e.onCloseAutoFocus)==null||l.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Bl=u.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...l}=e,a=mt(Yt,n),d=u.useRef(null),c=je(t,d);return vs(),s.jsxs(s.Fragment,{children:[s.jsx(eo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(Xn,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":js(a.open),...l,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(fh,{titleId:a.titleId}),s.jsx(mh,{contentRef:d,descriptionId:a.descriptionId})]})]})}),ks="DialogTitle",Fl=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mt(ks,n);return s.jsx(we.h2,{id:o.titleId,...r,ref:t})});Fl.displayName=ks;var zl="DialogDescription",uh=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mt(zl,n);return s.jsx(we.p,{id:o.descriptionId,...r,ref:t})});uh.displayName=zl;var ql="DialogClose",ph=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mt(ql,n);return s.jsx(we.button,{type:"button",...r,ref:t,onClick:se(e.onClick,()=>o.onOpenChange(!1))})});ph.displayName=ql;function js(e){return e?"open":"closed"}var Ul="DialogTitleWarning",[Bw,Wl]=eu(Ul,{contentName:Yt,titleName:ks,docsSlug:"dialog"}),fh=({titleId:e})=>{const t=Wl(Ul),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
51
|
-
|
|
52
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
53
|
-
|
|
54
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hh="DialogDescriptionWarning",mh=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wl(hh).contentName}}.`;return u.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},gh=Dl,yh=Ml,xh=Ll,bh=Nl,vh=Fl;function Kl(e){const t=e+"CollectionProvider",[n,r]=Bt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=x=>{const{scope:b,children:w}=x,C=Ie.useRef(null),E=Ie.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:E,collectionRef:C,children:w})};l.displayName=t;const a=e+"CollectionSlot",d=xn(a),c=Ie.forwardRef((x,b)=>{const{scope:w,children:C}=x,E=i(a,w),v=je(b,E.collectionRef);return s.jsx(d,{ref:v,children:C})});c.displayName=a;const f=e+"CollectionItemSlot",p="data-radix-collection-item",h=xn(f),y=Ie.forwardRef((x,b)=>{const{scope:w,children:C,...E}=x,v=Ie.useRef(null),j=je(b,v),O=i(f,w);return Ie.useEffect(()=>(O.itemMap.set(v,{ref:v,...E}),()=>void O.itemMap.delete(v))),s.jsx(h,{[p]:"",ref:j,children:C})});y.displayName=f;function S(x){const b=i(e+"CollectionConsumer",x);return Ie.useCallback(()=>{const C=b.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((O,T)=>E.indexOf(O.ref.current)-E.indexOf(T.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:l,Slot:c,ItemSlot:y},S,r]}var Sh=u.createContext(void 0);function wh(e){const t=u.useContext(Sh);return e||t||"ltr"}var ko="rovingFocusGroup.onEntryFocus",kh={bubbles:!1,cancelable:!0},nr="RovingFocusGroup",[Jo,Vl,jh]=Kl(nr),[Ch,Hl]=Bt(nr,[jh]),[Eh,Th]=Ch(nr),Gl=u.forwardRef((e,t)=>s.jsx(Jo.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Jo.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Ah,{...e,ref:t})})}));Gl.displayName=nr;var Ah=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...p}=e,h=u.useRef(null),y=je(t,h),S=wh(i),[x,b]=ys({prop:l,defaultProp:a??null,onChange:d,caller:nr}),[w,C]=u.useState(!1),E=Dt(c),v=Vl(n),j=u.useRef(!1),[O,T]=u.useState(0);return u.useEffect(()=>{const g=h.current;if(g)return g.addEventListener(ko,E),()=>g.removeEventListener(ko,E)},[E]),s.jsx(Eh,{scope:n,orientation:r,dir:S,loop:o,currentTabStopId:x,onItemFocus:u.useCallback(g=>b(g),[b]),onItemShiftTab:u.useCallback(()=>C(!0),[]),onFocusableItemAdd:u.useCallback(()=>T(g=>g+1),[]),onFocusableItemRemove:u.useCallback(()=>T(g=>g-1),[]),children:s.jsx(we.div,{tabIndex:w||O===0?-1:0,"data-orientation":r,...p,ref:y,style:{outline:"none",...e.style},onMouseDown:se(e.onMouseDown,()=>{j.current=!0}),onFocus:se(e.onFocus,g=>{const $=!j.current;if(g.target===g.currentTarget&&$&&!w){const _=new CustomEvent(ko,kh);if(g.currentTarget.dispatchEvent(_),!_.defaultPrevented){const R=v().filter(G=>G.focusable),A=R.find(G=>G.active),M=R.find(G=>G.id===x),K=[A,M,...R].filter(Boolean).map(G=>G.ref.current);Yl(K,f)}}j.current=!1}),onBlur:se(e.onBlur,()=>C(!1))})})}),Jl="RovingFocusGroupItem",Ql=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:l,...a}=e,d=zn(),c=i||d,f=Th(Jl,n),p=f.currentTabStopId===c,h=Vl(n),{onFocusableItemAdd:y,onFocusableItemRemove:S,currentTabStopId:x}=f;return u.useEffect(()=>{if(r)return y(),()=>S()},[r,y,S]),s.jsx(Jo.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:s.jsx(we.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:se(e.onMouseDown,b=>{r?f.onItemFocus(c):b.preventDefault()}),onFocus:se(e.onFocus,()=>f.onItemFocus(c)),onKeyDown:se(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){f.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=Oh(b,f.orientation,f.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let E=h().filter(v=>v.focusable).map(v=>v.ref.current);if(w==="last")E.reverse();else if(w==="prev"||w==="next"){w==="prev"&&E.reverse();const v=E.indexOf(b.currentTarget);E=f.loop?$h(E,v+1):E.slice(v+1)}setTimeout(()=>Yl(E))}}),children:typeof l=="function"?l({isCurrentTabStop:p,hasTabStop:x!=null}):l})})});Ql.displayName=Jl;var Rh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _h(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Oh(e,t,n){const r=_h(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Rh[r]}function Yl(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $h(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dh=Gl,Ph=Ql,Qo=["Enter"," "],Ih=["ArrowDown","PageUp","Home"],Xl=["ArrowUp","PageDown","End"],Mh=[...Ih,...Xl],Lh={ltr:[...Qo,"ArrowRight"],rtl:[...Qo,"ArrowLeft"]},Nh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},oo="Menu",[Hn,Bh,Fh]=Kl(oo),[en,Zl]=Bt(oo,[Fh,jn,Hl]),Cs=jn(),ec=Hl(),[Fw,tn]=en(oo),[zw,rr]=en(oo),zh="MenuAnchor",Es=u.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Cs(n);return s.jsx(Yr,{...o,...r,ref:t})});Es.displayName=zh;var Ts="MenuPortal",[qh,tc]=en(Ts,{forceMount:void 0}),nc=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=tn(Ts,t);return s.jsx(qh,{scope:t,forceMount:n,children:s.jsx(it,{present:n||i.open,children:s.jsx(er,{asChild:!0,container:o,children:r})})})};nc.displayName=Ts;var ot="MenuContent",[Uh,As]=en(ot),rc=u.forwardRef((e,t)=>{const n=tc(ot,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=tn(ot,e.__scopeMenu),l=rr(ot,e.__scopeMenu);return s.jsx(Hn.Provider,{scope:e.__scopeMenu,children:s.jsx(it,{present:r||i.open,children:s.jsx(Hn.Slot,{scope:e.__scopeMenu,children:l.modal?s.jsx(Wh,{...o,ref:t}):s.jsx(Kh,{...o,ref:t})})})})}),Wh=u.forwardRef((e,t)=>{const n=tn(ot,e.__scopeMenu),r=u.useRef(null),o=je(t,r);return u.useEffect(()=>{const i=r.current;if(i)return Ss(i)},[]),s.jsx(Rs,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:se(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Kh=u.forwardRef((e,t)=>{const n=tn(ot,e.__scopeMenu);return s.jsx(Rs,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Vh=xn("MenuContent.ScrollLock"),Rs=u.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:l,disableOutsidePointerEvents:a,onEntryFocus:d,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:h,onDismiss:y,disableOutsideScroll:S,...x}=e,b=tn(ot,n),w=rr(ot,n),C=Cs(n),E=ec(n),v=Bh(n),[j,O]=u.useState(null),T=u.useRef(null),g=je(t,T,b.onContentChange),$=u.useRef(0),_=u.useRef(""),R=u.useRef(0),A=u.useRef(null),M=u.useRef("right"),B=u.useRef(0),K=S?no:u.Fragment,G=S?{as:Vh,allowPinchZoom:!0}:void 0,V=D=>{var ue,ie;const Y=_.current+D,U=v().filter(ge=>!ge.disabled),te=document.activeElement,Q=(ue=U.find(ge=>ge.ref.current===te))==null?void 0:ue.textValue,F=U.map(ge=>ge.textValue),ee=om(F,Y,Q),ce=(ie=U.find(ge=>ge.textValue===ee))==null?void 0:ie.ref.current;(function ge(Oe){_.current=Oe,window.clearTimeout($.current),Oe!==""&&($.current=window.setTimeout(()=>ge(""),1e3))})(Y),ce&&setTimeout(()=>ce.focus())};u.useEffect(()=>()=>window.clearTimeout($.current),[]),vs();const I=u.useCallback(D=>{var U,te;return M.current===((U=A.current)==null?void 0:U.side)&&im(D,(te=A.current)==null?void 0:te.area)},[]);return s.jsx(Uh,{scope:n,searchRef:_,onItemEnter:u.useCallback(D=>{I(D)&&D.preventDefault()},[I]),onItemLeave:u.useCallback(D=>{var Y;I(D)||((Y=T.current)==null||Y.focus(),O(null))},[I]),onTriggerLeave:u.useCallback(D=>{I(D)&&D.preventDefault()},[I]),pointerGraceTimerRef:R,onPointerGraceIntentChange:u.useCallback(D=>{A.current=D},[]),children:s.jsx(K,{...G,children:s.jsx(eo,{asChild:!0,trapped:o,onMountAutoFocus:se(i,D=>{var Y;D.preventDefault(),(Y=T.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:s.jsx(Xn,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:h,onDismiss:y,children:s.jsx(Dh,{asChild:!0,...E,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:j,onCurrentTabStopIdChange:O,onEntryFocus:se(d,D=>{w.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(ms,{role:"menu","aria-orientation":"vertical","data-state":bc(b.open),"data-radix-menu-content":"",dir:w.dir,...C,...x,ref:g,style:{outline:"none",...x.style},onKeyDown:se(x.onKeyDown,D=>{const U=D.target.closest("[data-radix-menu-content]")===D.currentTarget,te=D.ctrlKey||D.altKey||D.metaKey,Q=D.key.length===1;U&&(D.key==="Tab"&&D.preventDefault(),!te&&Q&&V(D.key));const F=T.current;if(D.target!==F||!Mh.includes(D.key))return;D.preventDefault();const ce=v().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);Xl.includes(D.key)&&ce.reverse(),nm(ce)}),onBlur:se(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout($.current),_.current="")}),onPointerMove:se(e.onPointerMove,Gn(D=>{const Y=D.target,U=B.current!==D.clientX;if(D.currentTarget.contains(Y)&&U){const te=D.clientX>B.current?"right":"left";M.current=te,B.current=D.clientX}}))})})})})})})});rc.displayName=ot;var Hh="MenuGroup",_s=u.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(we.div,{role:"group",...r,ref:t})});_s.displayName=Hh;var Gh="MenuLabel",oc=u.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(we.div,{...r,ref:t})});oc.displayName=Gh;var Nr="MenuItem",Pi="menu.itemSelect",so=u.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=u.useRef(null),l=rr(Nr,e.__scopeMenu),a=As(Nr,e.__scopeMenu),d=je(t,i),c=u.useRef(!1),f=()=>{const p=i.current;if(!n&&p){const h=new CustomEvent(Pi,{bubbles:!0,cancelable:!0});p.addEventListener(Pi,y=>r==null?void 0:r(y),{once:!0}),Ua(p,h),h.defaultPrevented?c.current=!1:l.onClose()}};return s.jsx(sc,{...o,ref:d,disabled:n,onClick:se(e.onClick,f),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),c.current=!0},onPointerUp:se(e.onPointerUp,p=>{var h;c.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:se(e.onKeyDown,p=>{const h=a.searchRef.current!=="";n||h&&p.key===" "||Qo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});so.displayName=Nr;var sc=u.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,l=As(Nr,n),a=ec(n),d=u.useRef(null),c=je(t,d),[f,p]=u.useState(!1),[h,y]=u.useState("");return u.useEffect(()=>{const S=d.current;S&&y((S.textContent??"").trim())},[i.children]),s.jsx(Hn.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:s.jsx(Ph,{asChild:!0,...a,focusable:!r,children:s.jsx(we.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:se(e.onPointerMove,Gn(S=>{r?l.onItemLeave(S):(l.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:se(e.onPointerLeave,Gn(S=>l.onItemLeave(S))),onFocus:se(e.onFocus,()=>p(!0)),onBlur:se(e.onBlur,()=>p(!1))})})})}),Jh="MenuCheckboxItem",ic=u.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(uc,{scope:e.__scopeMenu,checked:n,children:s.jsx(so,{role:"menuitemcheckbox","aria-checked":Br(n)?"mixed":n,...o,ref:t,"data-state":$s(n),onSelect:se(o.onSelect,()=>r==null?void 0:r(Br(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ic.displayName=Jh;var ac="MenuRadioGroup",[Qh,Yh]=en(ac,{value:void 0,onValueChange:()=>{}}),lc=u.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=Dt(r);return s.jsx(Qh,{scope:e.__scopeMenu,value:n,onValueChange:i,children:s.jsx(_s,{...o,ref:t})})});lc.displayName=ac;var cc="MenuRadioItem",dc=u.forwardRef((e,t)=>{const{value:n,...r}=e,o=Yh(cc,e.__scopeMenu),i=n===o.value;return s.jsx(uc,{scope:e.__scopeMenu,checked:i,children:s.jsx(so,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":$s(i),onSelect:se(r.onSelect,()=>{var l;return(l=o.onValueChange)==null?void 0:l.call(o,n)},{checkForDefaultPrevented:!1})})})});dc.displayName=cc;var Os="MenuItemIndicator",[uc,Xh]=en(Os,{checked:!1}),pc=u.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=Xh(Os,n);return s.jsx(it,{present:r||Br(i.checked)||i.checked===!0,children:s.jsx(we.span,{...o,ref:t,"data-state":$s(i.checked)})})});pc.displayName=Os;var Zh="MenuSeparator",fc=u.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(we.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});fc.displayName=Zh;var em="MenuArrow",hc=u.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Cs(n);return s.jsx(gs,{...o,...r,ref:t})});hc.displayName=em;var tm="MenuSub",[qw,mc]=en(tm),Pn="MenuSubTrigger",gc=u.forwardRef((e,t)=>{const n=tn(Pn,e.__scopeMenu),r=rr(Pn,e.__scopeMenu),o=mc(Pn,e.__scopeMenu),i=As(Pn,e.__scopeMenu),l=u.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:d}=i,c={__scopeMenu:e.__scopeMenu},f=u.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return u.useEffect(()=>f,[f]),u.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),d(null)}},[a,d]),s.jsx(Es,{asChild:!0,...c,children:s.jsx(sc,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":bc(n.open),...e,ref:Vr(t,o.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:se(e.onPointerMove,Gn(p=>{i.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(i.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:se(e.onPointerLeave,Gn(p=>{var y,S;f();const h=(y=n.content)==null?void 0:y.getBoundingClientRect();if(h){const x=(S=n.content)==null?void 0:S.dataset.side,b=x==="right",w=b?-5:5,C=h[b?"left":"right"],E=h[b?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:C,y:h.top},{x:E,y:h.top},{x:E,y:h.bottom},{x:C,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:se(e.onKeyDown,p=>{var y;const h=i.searchRef.current!=="";e.disabled||h&&p.key===" "||Lh[r.dir].includes(p.key)&&(n.onOpenChange(!0),(y=n.content)==null||y.focus(),p.preventDefault())})})})});gc.displayName=Pn;var yc="MenuSubContent",xc=u.forwardRef((e,t)=>{const n=tc(ot,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=tn(ot,e.__scopeMenu),l=rr(ot,e.__scopeMenu),a=mc(yc,e.__scopeMenu),d=u.useRef(null),c=je(t,d);return s.jsx(Hn.Provider,{scope:e.__scopeMenu,children:s.jsx(it,{present:r||i.open,children:s.jsx(Hn.Slot,{scope:e.__scopeMenu,children:s.jsx(Rs,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var p;l.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:se(e.onFocusOutside,f=>{f.target!==a.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:se(e.onEscapeKeyDown,f=>{l.onClose(),f.preventDefault()}),onKeyDown:se(e.onKeyDown,f=>{var y;const p=f.currentTarget.contains(f.target),h=Nh[l.dir].includes(f.key);p&&h&&(i.onOpenChange(!1),(y=a.trigger)==null||y.focus(),f.preventDefault())})})})})})});xc.displayName=yc;function bc(e){return e?"open":"closed"}function Br(e){return e==="indeterminate"}function $s(e){return Br(e)?"indeterminate":e?"checked":"unchecked"}function nm(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function rm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function om(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let l=rm(e,Math.max(i,0));o.length===1&&(l=l.filter(c=>c!==n));const d=l.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function sm(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,l=t.length-1;i<t.length;l=i++){const a=t[i],d=t[l],c=a.x,f=a.y,p=d.x,h=d.y;f>r!=h>r&&n<(p-c)*(r-f)/(h-f)+c&&(o=!o)}return o}function im(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sm(n,t)}function Gn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var am=Es,lm=nc,cm=rc,dm=_s,um=oc,pm=so,fm=ic,hm=lc,mm=dc,gm=pc,ym=fc,xm=hc,bm=gc,vm=xc,vc="DropdownMenu",[Sm]=Bt(vc,[Zl]),Qe=Zl(),[Uw,Sc]=Sm(vc),wc="DropdownMenuTrigger",wm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=Sc(wc,n),l=Qe(n);return s.jsx(am,{asChild:!0,...l,children:s.jsx(we.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Vr(t,i.triggerRef),onPointerDown:se(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(i.onOpenToggle(),i.open||a.preventDefault())}),onKeyDown:se(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&i.onOpenToggle(),a.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});wm.displayName=wc;var km="DropdownMenuPortal",kc=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Qe(t);return s.jsx(lm,{...r,...n})};kc.displayName=km;var jc="DropdownMenuContent",Cc=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sc(jc,n),i=Qe(n),l=u.useRef(!1);return s.jsx(cm,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:se(e.onCloseAutoFocus,a=>{var d;l.current||(d=o.triggerRef.current)==null||d.focus(),l.current=!1,a.preventDefault()}),onInteractOutside:se(e.onInteractOutside,a=>{const d=a.detail.originalEvent,c=d.button===0&&d.ctrlKey===!0,f=d.button===2||c;(!o.modal||f)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Cc.displayName=jc;var jm="DropdownMenuGroup",Cm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(dm,{...o,...r,ref:t})});Cm.displayName=jm;var Em="DropdownMenuLabel",Ec=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(um,{...o,...r,ref:t})});Ec.displayName=Em;var Tm="DropdownMenuItem",Tc=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(pm,{...o,...r,ref:t})});Tc.displayName=Tm;var Am="DropdownMenuCheckboxItem",Rm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(fm,{...o,...r,ref:t})});Rm.displayName=Am;var _m="DropdownMenuRadioGroup",Om=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(hm,{...o,...r,ref:t})});Om.displayName=_m;var $m="DropdownMenuRadioItem",Dm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(mm,{...o,...r,ref:t})});Dm.displayName=$m;var Pm="DropdownMenuItemIndicator",Im=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(gm,{...o,...r,ref:t})});Im.displayName=Pm;var Mm="DropdownMenuSeparator",Ac=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(ym,{...o,...r,ref:t})});Ac.displayName=Mm;var Lm="DropdownMenuArrow",Nm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(xm,{...o,...r,ref:t})});Nm.displayName=Lm;var Bm="DropdownMenuSubTrigger",Fm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(bm,{...o,...r,ref:t})});Fm.displayName=Bm;var zm="DropdownMenuSubContent",qm=u.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qe(n);return s.jsx(vm,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qm.displayName=zm;var Um=kc,Wm=Cc,Km=Ec,Vm=Tc,Hm=Ac;const Gm=u.forwardRef(({container:e,style:t,sideOffset:n=4,...r},o)=>s.jsx(Um,{container:e,children:s.jsx(Wm,{ref:o,sideOffset:n,style:{minWidth:180,background:le("surfaceElevated"),color:le("textPrimary"),border:`1px solid ${le("borderDefault")}`,borderRadius:Nt.md,boxShadow:le("shadowMd"),padding:me[1],zIndex:Wn.popover,...t},...r})}));Gm.displayName="DropdownMenuContent";const Jm=u.forwardRef(({style:e,...t},n)=>s.jsx(Vm,{ref:n,style:{display:"flex",alignItems:"center",gap:me[2],padding:`${me[1]} ${me[2]}`,fontSize:ze.sm,borderRadius:Nt.sm,cursor:"default",outline:"none",userSelect:"none",...e},...t}));Jm.displayName="DropdownMenuItem";const Qm=u.forwardRef(({style:e,...t},n)=>s.jsx(Hm,{ref:n,style:{height:1,background:le("borderSubtle"),margin:`${me[1]} 0`,...e},...t}));Qm.displayName="DropdownMenuSeparator";const Ym=u.forwardRef(({style:e,...t},n)=>s.jsx(Km,{ref:n,style:{padding:`${me[1]} ${me[2]}`,fontSize:ze.xs,color:le("textMuted"),textTransform:"uppercase",letterSpacing:"0.04em",...e},...t}));Ym.displayName="DropdownMenuLabel";var Rc="Popover",[_c]=Bt(Rc,[jn]),io=jn(),[Ww,Ft]=_c(Rc),Oc="PopoverAnchor",Xm=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ft(Oc,n),i=io(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:a}=o;return u.useEffect(()=>(l(),()=>a()),[l,a]),s.jsx(Yr,{...i,...r,ref:t})});Xm.displayName=Oc;var $c="PopoverTrigger",Zm=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ft($c,n),i=io(n),l=je(t,o.triggerRef),a=s.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Lc(o.open),...r,ref:l,onClick:se(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:s.jsx(Yr,{asChild:!0,...i,children:a})});Zm.displayName=$c;var Ds="PopoverPortal",[eg,tg]=_c(Ds,{forceMount:void 0}),Dc=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ft(Ds,t);return s.jsx(eg,{scope:t,forceMount:n,children:s.jsx(it,{present:n||i.open,children:s.jsx(er,{asChild:!0,container:o,children:r})})})};Dc.displayName=Ds;var Sn="PopoverContent",Pc=u.forwardRef((e,t)=>{const n=tg(Sn,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ft(Sn,e.__scopePopover);return s.jsx(it,{present:r||i.open,children:i.modal?s.jsx(rg,{...o,ref:t}):s.jsx(og,{...o,ref:t})})});Pc.displayName=Sn;var ng=xn("PopoverContent.RemoveScroll"),rg=u.forwardRef((e,t)=>{const n=Ft(Sn,e.__scopePopover),r=u.useRef(null),o=je(t,r),i=u.useRef(!1);return u.useEffect(()=>{const l=r.current;if(l)return Ss(l)},[]),s.jsx(no,{as:ng,allowPinchZoom:!0,children:s.jsx(Ic,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,l=>{var a;l.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:se(e.onPointerDownOutside,l=>{const a=l.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,c=a.button===2||d;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:se(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),og=u.forwardRef((e,t)=>{const n=Ft(Sn,e.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return s.jsx(Ic,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var l,a;(l=e.onCloseAutoFocus)==null||l.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Ic=u.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:c,onInteractOutside:f,...p}=e,h=Ft(Sn,n),y=io(n);return vs(),s.jsx(eo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(Xn,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:s.jsx(ms,{"data-state":Lc(h.open),role:"dialog",id:h.contentId,...y,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Mc="PopoverClose",sg=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ft(Mc,n);return s.jsx(we.button,{type:"button",...r,ref:t,onClick:se(e.onClick,()=>o.onOpenChange(!1))})});sg.displayName=Mc;var ig="PopoverArrow",ag=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=io(n);return s.jsx(gs,{...o,...r,ref:t})});ag.displayName=ig;function Lc(e){return e?"open":"closed"}var lg=Dc,cg=Pc;const dg=u.forwardRef(({container:e,style:t,sideOffset:n=6,...r},o)=>s.jsx(lg,{container:e,children:s.jsx(cg,{ref:o,sideOffset:n,style:{background:le("surfaceElevated"),color:le("textPrimary"),border:`1px solid ${le("borderDefault")}`,borderRadius:Nt.md,boxShadow:le("shadowMd"),padding:me[3],zIndex:Wn.popover,minWidth:220,...t},...r})}));dg.displayName="PopoverContent";function Ps({icon:e,eyebrow:t,title:n,subtitle:r,status:o,actions:i,toolbar:l,bodyPadding:a=14,children:d}){return s.jsxs("div",{className:"panel-frame",children:[s.jsxs("div",{className:"panel-frame-header",children:[s.jsxs("div",{className:"panel-frame-heading",children:[e&&s.jsx("span",{className:"panel-frame-icon",children:e}),s.jsxs("div",{className:"panel-frame-title-col",children:[t&&s.jsx("div",{className:"panel-frame-eyebrow",children:t}),s.jsxs("div",{className:"panel-frame-title-row",children:[n&&s.jsx("h2",{className:"panel-frame-title",children:n}),o&&s.jsx("span",{className:"panel-frame-status",children:o})]}),r&&s.jsx("div",{className:"panel-frame-subtitle",children:r})]})]}),i&&s.jsx("div",{className:"panel-frame-actions",children:i})]}),l&&s.jsx("div",{className:"panel-frame-toolbar",children:l}),s.jsx("div",{className:"panel-frame-body",style:{padding:a},children:d})]})}function Nc({tone:e="neutral",icon:t,children:n,className:r="",...o}){return s.jsxs("span",{className:`status-pill tone-${e} ${r}`,...o,children:[t&&s.jsx("span",{className:"status-pill-icon",children:t}),n]})}function qn({icon:e,title:t,description:n,action:r}){return s.jsxs("div",{className:"panel-empty",children:[e&&s.jsx("span",{className:"panel-empty-icon",children:e}),t&&s.jsx("p",{className:"panel-empty-title",children:t}),n&&s.jsx("p",{className:"panel-empty-desc",children:n}),r]})}function Bc({left:e,right:t,children:n,className:r=""}){return s.jsxs("div",{className:`panel-toolbar ${r}`,children:[e&&s.jsx("div",{className:"panel-toolbar-left",children:e}),n&&s.jsx("div",{className:"panel-toolbar-center",children:n}),t&&s.jsx("div",{className:"panel-toolbar-right",children:t})]})}function ug({shortcut:e,children:t,style:n,...r}){return s.jsx("kbd",{...r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:18,height:18,padding:`0 ${me[1]}px`,borderRadius:Nt.sm,border:`1px solid ${le("borderSubtle")}`,background:le("surfaceRaised"),color:le("textSecondary"),fontFamily:"var(--dql-font-mono, monospace)",fontSize:ze.xs,fontWeight:ss.medium,lineHeight:1,whiteSpace:"nowrap",...n},children:e??t})}const Ii=e=>{let t;const n=new Set,r=(c,f)=>{const p=typeof c=="function"?c(t):c;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,h))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>d,subscribe:c=>(n.add(c),()=>n.delete(c))},d=t=e(r,o,a);return a},pg=(e=>e?Ii(e):Ii),fg=e=>e;function hg(e,t=fg){const n=Ie.useSyncExternalStore(e.subscribe,Ie.useCallback(()=>t(e.getState()),[e,t]),Ie.useCallback(()=>t(e.getInitialState()),[e,t]));return Ie.useDebugValue(n),n}const Mi=e=>{const t=pg(e),n=r=>hg(t,r);return Object.assign(n,t),n},mg=(e=>e?Mi(e):Mi),Li=e=>Symbol.iterator in e,Ni=e=>"entries"in e,Bi=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,i]of n)if(!r.has(o)||!Object.is(i,r.get(o)))return!1;return!0},gg=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),i=r.next();for(;!o.done&&!i.done;){if(!Object.is(o.value,i.value))return!1;o=n.next(),i=r.next()}return!!o.done&&!!i.done};function yg(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Li(e)&&Li(t)?Ni(e)&&Ni(t)?Bi(e,t):gg(e,t):Bi({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function xg(e){const t=Ie.useRef(void 0);return n=>{const r=e(n);return yg(t.current,r)?t.current:t.current=r}}const bg=/\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g;function Is(e,t){const n=new Map;for(const o of t)n.set(o.id,o.id),o.name&&n.set(o.name,o.id);const r=new Map;for(const o of e.dependencies??[])r.set(o.cellId,o);for(const o of e.content.matchAll(bg)){const i=o[1],l=n.get(i);l&&l!==e.id&&r.set(l,{cellId:l,output:i})}if(e.upstream){const o=n.get(e.upstream);o&&o!==e.id&&r.set(o,{cellId:o,output:e.upstream})}return[...r.values()]}function vg(e){const t=e.filter(c=>!["markdown","param","chat"].includes(c.type)),n=new Set(t.map(c=>c.id)),r=new Set(e.map(c=>c.id)),o=new Map(t.map(c=>[c.id,0])),i=new Map(t.map(c=>[c.id,[]])),l=[];for(const c of t)for(const f of Is(c,e)){if(!r.has(f.cellId)){l.push({cellId:c.id,dependency:f.cellId});continue}n.has(f.cellId)&&(i.get(f.cellId).push(c.id),o.set(c.id,(o.get(c.id)??0)+1))}const a=t.filter(c=>o.get(c.id)===0),d=[];for(;a.length>0;){const c=a.shift();d.push(c);for(const f of i.get(c.id)??[]){const p=(o.get(f)??0)-1;if(o.set(f,p),p===0){const h=t.find(y=>y.id===f);h&&a.push(h)}}}return{ordered:d,cycleCellIds:t.filter(c=>!d.some(f=>f.id===c.id)).map(c=>c.id),missing:l}}function Sg(e,t){const n=new Set,r=[e];for(;r.length>0;){const o=r.shift();for(const i of t)n.has(i.id)||i.id===e||Is(i,t).some(l=>l.cellId===o)&&(n.add(i.id),r.push(i.id))}return n}function wg(){var e;if(typeof window<"u")try{(e=window.localStorage)==null||e.removeItem("dql-app-mode")}catch{}return"studio"}function kg(){var t;if(typeof window>"u")return"paper";const e=(t=window.localStorage)==null?void 0:t.getItem("dql-theme");return e==="obsidian"||e==="paper"||e==="white"?e:e==="midnight"||e==="dark"?"obsidian":e==="arctic"?"white":"paper"}function jg(){if(typeof window>"u")return"apps";const e=new URLSearchParams(window.location.search);return e.has("domain")||e.has("domainSection")||e.has("modelArea")?"domains":"apps"}const Cg={mainView:jg(),agentLogRun:void 0,settingsTab:"overview",themeMode:kg(),appMode:wg(),sidebarPanel:null,sidebarOpen:!1,files:[],filesLoading:!1,activeFile:null,cells:[],notebookTitle:"",notebookMetadata:{},notebookDirty:!1,schemaTables:[],schemaLoading:!1,authoredDomains:[],semanticLayer:{available:!1,provider:null,metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[],domains:[],tags:[],favorites:[],recentlyUsed:[],loading:!1,lastSyncTime:null},devPanelOpen:!1,devPanelTab:"logs",queryLog:[],newNotebookModalOpen:!1,newBlockModalOpen:!1,newBlockModalDefaultType:"custom",autoSave:!0,executionCounter:0,savingFile:!1,lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null,lineageDrawerOpen:!1,lineageDrawerNodeId:null,dashboardMode:!1,activeBlockPath:null,blockStudioDraft:"",blockStudioDirty:!1,blockStudioPreview:null,blockStudioValidation:null,blockStudioMetadata:null,blockStudioCatalog:null,blockStudioCatalogLoading:!1,blockStudioImportOpen:!1,blockStudioDbtStatus:null,setupOpen:!1,inspectorOpen:!1,inspectorContext:null,apps:[],appsLoading:!1,activeAppId:null,activeDashboardId:null,activeAppExperience:"view",activeAppSection:"dashboards",activePersona:null,globalAi:{open:!1,audience:"stakeholder",context:{}}};function Yo(e){const t=new Set;return e.map(n=>{var o;let r=(o=n.id)==null?void 0:o.trim();if(!r||t.has(r))do r=nt();while(t.has(r));return t.add(r),r===n.id?n:{...n,id:r}})}function Eg(e,t){var n,r,o,i,l,a,d;switch(t.type){case"SET_MAIN_VIEW":return t.view==="imports"?{...e,mainView:"block_studio",sidebarPanel:"block_library",sidebarOpen:!0,blockStudioImportOpen:!0,lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null}:t.view==="home"?{...e,mainView:"home",sidebarPanel:null,sidebarOpen:!1,lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null,lineageDrawerOpen:!1,lineageDrawerNodeId:null,dashboardMode:!1}:{...e,mainView:t.view,lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null};case"OPEN_AGENT_LOG":return{...e,agentLogRun:t.run,mainView:"agent_log"};case"SET_SETTINGS_TAB":return{...e,settingsTab:t.tab};case"SET_THEME":{if(typeof document<"u"){const c=t.mode==="dark"||t.mode==="midnight"?"obsidian":t.mode==="light"?"paper":t.mode==="arctic"?"white":t.mode;document.documentElement.setAttribute("data-theme",c);try{(n=window.localStorage)==null||n.setItem("dql-theme",t.mode)}catch{}}return{...e,themeMode:t.mode}}case"SET_APP_MODE":{if(typeof window<"u")try{(r=window.localStorage)==null||r.removeItem("dql-app-mode")}catch{}return{...e,appMode:"studio"}}case"SET_SIDEBAR_PANEL":{if(t.panel==="lineage")return{...e,sidebarPanel:"lineage",sidebarOpen:!1,lineageFullscreen:!1,lineageFocusNodeId:e.mainView==="lineage_detail"?e.lineageFocusNodeId:null,lineageReturnTarget:null,mainView:"lineage"};const c=["connection","git","apps","readiness","skills","domains","settings"],f=t.panel!==null&&c.includes(t.panel);return{...e,sidebarPanel:t.panel,sidebarOpen:t.panel!==null&&!f,lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null,mainView:t.panel==="connection"?"connection":t.panel==="git"?"git":t.panel==="apps"?"apps":t.panel==="readiness"?"readiness":t.panel==="skills"?"skills":t.panel==="domains"?"domains":t.panel==="settings"?"connection":t.panel==="files"?"notebook":t.panel==="block_library"||((o=e.activeFile)==null?void 0:o.type)==="block"?"block_studio":"notebook"}}case"TOGGLE_SIDEBAR":return{...e,sidebarOpen:!e.sidebarOpen};case"SET_FILES":return{...e,files:t.files};case"SET_FILES_LOADING":return{...e,filesLoading:t.loading};case"OPEN_BUSINESS_ARTIFACT":return{...e,activeFile:t.file,cells:[],notebookTitle:t.file.name.replace(/\.(dqlnb|dql)$/i,""),notebookDirty:!1,mainView:"business_artifact",activeBlockPath:null,blockStudioDraft:"",blockStudioDirty:!1,blockStudioPreview:null,blockStudioValidation:null,blockStudioMetadata:null,dashboardMode:!1,lineageFullscreen:!1,lineageDrawerOpen:!1,lineageDrawerNodeId:null,lineageFocusNodeId:`${t.file.type}:${t.file.name.replace(/\.(dqlnb|dql)$/i,"")}`};case"OPEN_FILE":return{...e,activeFile:t.file,cells:Yo(t.cells),notebookTitle:t.title,notebookMetadata:t.metadata??{},notebookDirty:!1,mainView:t.file.type==="block"?"block_studio":"notebook",activeBlockPath:t.file.type==="block"?t.file.path:null,blockStudioDraft:t.file.type==="block"?e.blockStudioDraft:"",blockStudioDirty:!1,blockStudioPreview:t.file.type==="block"?e.blockStudioPreview:null,blockStudioValidation:t.file.type==="block"?e.blockStudioValidation:null,blockStudioMetadata:t.file.type==="block"?e.blockStudioMetadata:null,lineageFullscreen:!1,lineageFocusNodeId:null};case"OPEN_BLOCK_STUDIO":return{...e,activeFile:t.file,cells:[],notebookTitle:t.payload.metadata.name,notebookDirty:!1,mainView:"block_studio",dashboardMode:!1,activeBlockPath:t.payload.path,blockStudioDraft:t.payload.source,blockStudioDirty:!1,blockStudioPreview:null,blockStudioValidation:t.payload.validation,blockStudioMetadata:t.payload.metadata,blockStudioImportOpen:!1,lineageFullscreen:!1,lineageFocusNodeId:(i=t.payload.metadata)!=null&&i.name?`block:${t.payload.metadata.name}`:null};case"SET_CELLS":return{...e,cells:Yo(t.cells),notebookDirty:!0};case"UPDATE_NOTEBOOK_METADATA":{const c=e.notebookMetadata;let f=!1;for(const p of Object.keys(t.updates))if(c[p]!==t.updates[p]){f=!0;break}return f?{...e,notebookMetadata:{...c,...t.updates},notebookDirty:!0}:e}case"ADD_CELL":{const c=e.cells.some(h=>h.id===t.cell.id)?{...t.cell,id:nt()}:t.cell;if(!t.afterId)return{...e,cells:[...e.cells,c],notebookDirty:!0};const f=e.cells.findIndex(h=>h.id===t.afterId);if(f===-1)return{...e,cells:[...e.cells,c],notebookDirty:!0};const p=[...e.cells];return p.splice(f+1,0,c),{...e,cells:p,notebookDirty:!0}}case"UPDATE_CELL":{const c=t.updates.content!==void 0||t.updates.name!==void 0||t.updates.executionTarget!==void 0||t.updates.datasetRefs!==void 0||t.updates.dependencies!==void 0||t.updates.dqlParameterValues!==void 0||t.updates.blockBinding!==void 0,f=c?Sg(t.id,e.cells):new Set,p=e.cells.map(y=>{if(y.id===t.id){const S={...y,...t.updates};return c&&y.result&&t.updates.stale===void 0?{...S,stale:!0}:S}return f.has(y.id)&&y.result?{...y,stale:!0}:y}),h=t.updates.executionCount!==void 0?e.executionCounter+1:e.executionCounter;return{...e,cells:p,notebookDirty:!0,executionCounter:h}}case"DELETE_CELL":return{...e,cells:e.cells.filter(c=>c.id!==t.id),notebookDirty:!0};case"MOVE_CELL":{const c=e.cells.findIndex(p=>p.id===t.id);if(c===-1)return e;const f=[...e.cells];return t.direction==="up"&&c>0?[f[c-1],f[c]]=[f[c],f[c-1]]:t.direction==="down"&&c<f.length-1&&([f[c],f[c+1]]=[f[c+1],f[c]]),{...e,cells:f,notebookDirty:!0}}case"REORDER_CELL":{const{fromIndex:c,toIndex:f}=t;if(c===f||c<0||f<0||c>=e.cells.length||f>=e.cells.length)return e;const p=[...e.cells],[h]=p.splice(c,1);return p.splice(f,0,h),{...e,cells:p,notebookDirty:!0}}case"SET_SCHEMA":return{...e,schemaTables:t.tables};case"MERGE_SCHEMA_TABLES":{const c=new Map(e.schemaTables.map(f=>[f.path.toLowerCase(),f]));for(const f of t.tables){const p=f.path.toLowerCase(),h=c.get(p);c.set(p,h?{...h,...f,columns:f.columns.length>0?f.columns:h.columns,expanded:h.expanded}:f)}return{...e,schemaTables:Array.from(c.values())}}case"SET_SCHEMA_LOADING":return{...e,schemaLoading:t.loading};case"SET_AUTHORED_DOMAINS":return{...e,authoredDomains:t.domains};case"TOGGLE_SCHEMA_TABLE":return{...e,schemaTables:e.schemaTables.map(c=>c.name===t.tableName?{...c,expanded:!c.expanded}:c)};case"TOGGLE_DEV_PANEL":return{...e,devPanelOpen:!e.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...e,devPanelTab:t.tab};case"APPEND_QUERY_LOG":return{...e,queryLog:[...e.queryLog,t.entry]};case"OPEN_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!0};case"CLOSE_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!1};case"OPEN_NEW_BLOCK_MODAL":return{...e,newBlockModalOpen:!0,newBlockModalDefaultType:t.blockType??"custom"};case"START_NEW_BLOCK_WORKSPACE":return{...e,mainView:"block_studio",sidebarPanel:"block_library",sidebarOpen:!0,activeFile:null,activeBlockPath:null,blockStudioDraft:"",blockStudioDirty:!1,blockStudioPreview:null,blockStudioValidation:null,blockStudioMetadata:null,blockStudioImportOpen:!1,newBlockModalOpen:!1,newBlockModalDefaultType:t.blockType??"custom",notebookTitle:"Blocks"};case"CLOSE_NEW_BLOCK_MODAL":return{...e,newBlockModalOpen:!1};case"SET_AUTO_SAVE":return{...e,autoSave:t.enabled};case"SET_NOTEBOOK_DIRTY":return{...e,notebookDirty:t.dirty};case"SET_SAVING":return{...e,savingFile:t.saving};case"FILE_ADDED":return e.files.some(c=>c.path===t.file.path)?e:{...e,files:[...e.files,t.file]};case"FILE_REMOVED":{const c=e.files.filter(f=>f.path!==t.path);return((l=e.activeFile)==null?void 0:l.path)!==t.path?{...e,files:c}:{...e,files:c,activeFile:null,cells:[],notebookTitle:"",notebookMetadata:{},notebookDirty:!1}}case"SET_TABLE_COLUMNS":return{...e,schemaTables:e.schemaTables.map(c=>c.name===t.tableName?{...c,columns:t.columns}:c)};case"SET_PARAM_VALUE":return{...e,cells:e.cells.map(c=>c.id===t.id?{...c,paramValue:t.value}:c),notebookDirty:!0};case"SET_SEMANTIC_LAYER":return{...e,semanticLayer:{...t.layer,loading:!1}};case"SET_SEMANTIC_LOADING":return{...e,semanticLayer:{...e.semanticLayer,loading:t.loading}};case"SET_SEMANTIC_FAVORITES":return{...e,semanticLayer:{...e.semanticLayer,favorites:t.favorites}};case"ADD_SEMANTIC_RECENT":{const c=[t.name,...e.semanticLayer.recentlyUsed.filter(f=>f!==t.name)].slice(0,12);return{...e,semanticLayer:{...e.semanticLayer,recentlyUsed:c}}}case"SET_SEMANTIC_DOMAINS":return{...e,semanticLayer:{...e.semanticLayer,domains:t.domains,tags:t.tags,lastSyncTime:t.lastSyncTime??e.semanticLayer.lastSyncTime}};case"TOGGLE_LINEAGE_FULLSCREEN":return{...e,lineageFullscreen:!e.lineageFullscreen};case"SET_LINEAGE_FOCUS":return{...e,lineageFocusNodeId:t.nodeId};case"OPEN_LINEAGE_DETAIL":{const c=t.returnTo!==void 0?t.returnTo:e.mainView==="lineage_detail"?e.lineageReturnTarget:null;return{...e,mainView:"lineage_detail",lineageFullscreen:!1,lineageFocusNodeId:t.nodeId,lineageReturnTarget:c,lineageDrawerOpen:!1,lineageDrawerNodeId:null,dashboardMode:!1}}case"OPEN_LINEAGE_DRAWER":return{...e,lineageDrawerOpen:!0,lineageDrawerNodeId:t.nodeId};case"CLOSE_LINEAGE_DRAWER":return{...e,lineageDrawerOpen:!1,lineageDrawerNodeId:null};case"TOGGLE_DASHBOARD_MODE":return{...e,dashboardMode:!e.dashboardMode};case"SET_BLOCK_STUDIO_DRAFT":return{...e,blockStudioDraft:t.draft,blockStudioDirty:!0};case"SET_BLOCK_STUDIO_DIRTY":return{...e,blockStudioDirty:t.dirty};case"SET_BLOCK_STUDIO_PREVIEW":return{...e,blockStudioPreview:t.preview};case"SET_BLOCK_STUDIO_VALIDATION":return{...e,blockStudioValidation:t.validation};case"SET_BLOCK_STUDIO_METADATA":return{...e,blockStudioMetadata:t.metadata,notebookTitle:t.metadata.name,blockStudioDirty:!0};case"SET_BLOCK_STUDIO_CATALOG":return{...e,blockStudioCatalog:t.catalog};case"SET_BLOCK_STUDIO_CATALOG_LOADING":return{...e,blockStudioCatalogLoading:t.loading};case"OPEN_BLOCK_IMPORT":return{...e,mainView:"block_studio",sidebarPanel:"block_library",sidebarOpen:!0,blockStudioImportOpen:!0,lineageFullscreen:!1,lineageFocusNodeId:null};case"CLOSE_BLOCK_IMPORT":return{...e,blockStudioImportOpen:!1};case"SET_BLOCK_STUDIO_DBT_STATUS":return{...e,blockStudioDbtStatus:t.status};case"OPEN_SETUP":return{...e,setupOpen:!0};case"CLOSE_SETUP":return{...e,setupOpen:!1};case"OPEN_GLOBAL_AI":return{...e,globalAi:{open:!0,audience:t.audience??e.globalAi.audience,context:t.context??e.globalAi.context,autoRun:t.autoRun?{...t.autoRun,nonce:Date.now()}:e.globalAi.autoRun}};case"CLOSE_GLOBAL_AI":return{...e,globalAi:{...e.globalAi,open:!1}};case"TOGGLE_GLOBAL_AI":return{...e,globalAi:{...e.globalAi,open:!e.globalAi.open,audience:t.audience??e.globalAi.audience,context:t.context??e.globalAi.context}};case"SET_GLOBAL_AI_CONTEXT":return{...e,globalAi:{...e.globalAi,context:t.context,audience:t.audience??e.globalAi.audience}};case"TOGGLE_INSPECTOR":return{...e,inspectorOpen:!e.inspectorOpen};case"SET_INSPECTOR":return{...e,inspectorOpen:t.open,inspectorContext:t.context===void 0?e.inspectorContext:t.context};case"SET_INSPECTOR_CONTEXT":return{...e,inspectorContext:t.context,inspectorOpen:t.context!==null?!0:e.inspectorOpen};case"SET_APPS":return{...e,apps:t.apps};case"SET_APPS_LOADING":return{...e,appsLoading:t.loading};case"OPEN_APP":{const c=e.apps.find(h=>h.id===t.appId)??null,f=t.dashboardId!==void 0?t.dashboardId:((a=c==null?void 0:c.homepage)==null?void 0:a.type)==="dashboard"?c.homepage.id:((d=c==null?void 0:c.dashboards[0])==null?void 0:d.id)??null,p=e.activeAppId===t.appId;return{...e,mainView:"apps",activeAppId:t.appId,activeDashboardId:f,activeAppExperience:t.experience??(p?e.activeAppExperience:"view"),activeAppSection:t.section??(p?e.activeAppSection:"dashboards"),lineageReturnTarget:null}}case"OPEN_DASHBOARD":return{...e,activeDashboardId:t.dashboardId};case"SET_APP_WORKSPACE_STATE":return{...e,activeAppExperience:t.experience??e.activeAppExperience,activeAppSection:t.section??e.activeAppSection};case"SET_ACTIVE_PERSONA":return{...e,activePersona:t.persona};default:return e}}const Xo=mg((e,t)=>({...Cg,dispatch:n=>{const r=Eg(t(),n);e(r)}})),Tg=u.createContext(null);function Ag({children:e}){return Ie.useEffect(()=>{const t=n=>{if(n.key!=="dql-theme"||!n.newValue)return;const r=n.newValue;(r==="obsidian"||r==="paper"||r==="white"||r==="midnight"||r==="arctic"||r==="dark"||r==="light")&&Xo.getState().dispatch({type:"SET_THEME",mode:r})};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]),s.jsx(s.Fragment,{children:e})}function Se(){const e=Xo(xg(r=>{const{dispatch:o,...i}=r;return i})),t=Xo(r=>r.dispatch);return u.useContext(Tg)??{state:e,dispatch:t}}function nt(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Ms(e,t=""){const n={id:nt(),type:e,content:t,status:"idle"};return e==="param"&&(n.content="",n.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),e==="chart"&&(n.chartConfig={chart:"bar"}),e==="filter"&&(n.filterConfig={mode:"keep",groups:[{id:`g_${Math.random().toString(36).slice(2,8)}`,combinator:"and",rules:[]}]}),e==="pivot"&&(n.pivotConfig={rows:[],columns:[],values:[]}),e==="single_value"&&(n.singleValueConfig={aggregation:"count",format:"number"}),e==="table"&&(n.tableConfig={}),e==="chat"&&(n.chatConfig={history:[]}),n}const Rg="modulepreload",_g=function(e){return"/"+e},Fi={},Ce=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(c){return Promise.all(c.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),d=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));o=l(n.map(c=>{if(c=_g(c),c in Fi)return;Fi[c]=!0;const f=c.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const h=document.createElement("link");if(h.rel=f?"stylesheet":Rg,f||(h.as="script"),h.crossOrigin="",h.href=c,d&&h.setAttribute("nonce",d),document.head.appendChild(h),f)return new Promise((y,S)=>{h.addEventListener("load",y),h.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(l){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=l,window.dispatchEvent(a),!a.defaultPrevented)throw l}return o.then(l=>{for(const a of l||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})};/**
|
|
55
|
-
* @license lucide-react v0.563.0 - ISC
|
|
56
|
-
*
|
|
57
|
-
* This source code is licensed under the ISC license.
|
|
58
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
59
|
-
*/const Fc=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
|
60
|
-
* @license lucide-react v0.563.0 - ISC
|
|
61
|
-
*
|
|
62
|
-
* This source code is licensed under the ISC license.
|
|
63
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
64
|
-
*/const Og=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
65
|
-
* @license lucide-react v0.563.0 - ISC
|
|
66
|
-
*
|
|
67
|
-
* This source code is licensed under the ISC license.
|
|
68
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
69
|
-
*/const $g=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
|
|
70
|
-
* @license lucide-react v0.563.0 - ISC
|
|
71
|
-
*
|
|
72
|
-
* This source code is licensed under the ISC license.
|
|
73
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
74
|
-
*/const zi=e=>{const t=$g(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
75
|
-
* @license lucide-react v0.563.0 - ISC
|
|
76
|
-
*
|
|
77
|
-
* This source code is licensed under the ISC license.
|
|
78
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
79
|
-
*/var Dg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
80
|
-
* @license lucide-react v0.563.0 - ISC
|
|
81
|
-
*
|
|
82
|
-
* This source code is licensed under the ISC license.
|
|
83
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
84
|
-
*/const Pg=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
85
|
-
* @license lucide-react v0.563.0 - ISC
|
|
86
|
-
*
|
|
87
|
-
* This source code is licensed under the ISC license.
|
|
88
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
89
|
-
*/const Ig=u.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:l,...a},d)=>u.createElement("svg",{ref:d,...Dg,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Fc("lucide",o),...!i&&!Pg(a)&&{"aria-hidden":"true"},...a},[...l.map(([c,f])=>u.createElement(c,f)),...Array.isArray(i)?i:[i]]));/**
|
|
90
|
-
* @license lucide-react v0.563.0 - ISC
|
|
91
|
-
*
|
|
92
|
-
* This source code is licensed under the ISC license.
|
|
93
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
94
|
-
*/const X=(e,t)=>{const n=u.forwardRef(({className:r,...o},i)=>u.createElement(Ig,{ref:i,iconNode:t,className:Fc(`lucide-${Og(zi(e))}`,`lucide-${e}`,r),...o}));return n.displayName=zi(e),n};/**
|
|
95
|
-
* @license lucide-react v0.563.0 - ISC
|
|
96
|
-
*
|
|
97
|
-
* This source code is licensed under the ISC license.
|
|
98
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
99
|
-
*/const Mg=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Lg=X("arrow-down",Mg);/**
|
|
100
|
-
* @license lucide-react v0.563.0 - ISC
|
|
101
|
-
*
|
|
102
|
-
* This source code is licensed under the ISC license.
|
|
103
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
104
|
-
*/const Ng=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],Bg=X("arrow-right-left",Ng);/**
|
|
105
|
-
* @license lucide-react v0.563.0 - ISC
|
|
106
|
-
*
|
|
107
|
-
* This source code is licensed under the ISC license.
|
|
108
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
109
|
-
*/const Fg=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],zg=X("arrow-up",Fg);/**
|
|
110
|
-
* @license lucide-react v0.563.0 - ISC
|
|
111
|
-
*
|
|
112
|
-
* This source code is licensed under the ISC license.
|
|
113
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
114
|
-
*/const qg=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],Ls=X("blocks",qg);/**
|
|
115
|
-
* @license lucide-react v0.563.0 - ISC
|
|
116
|
-
*
|
|
117
|
-
* This source code is licensed under the ISC license.
|
|
118
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
119
|
-
*/const Ug=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],Wg=X("bookmark",Ug);/**
|
|
120
|
-
* @license lucide-react v0.563.0 - ISC
|
|
121
|
-
*
|
|
122
|
-
* This source code is licensed under the ISC license.
|
|
123
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
124
|
-
*/const Kg=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Vg=X("box",Kg);/**
|
|
125
|
-
* @license lucide-react v0.563.0 - ISC
|
|
126
|
-
*
|
|
127
|
-
* This source code is licensed under the ISC license.
|
|
128
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
129
|
-
*/const Hg=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Zo=X("boxes",Hg);/**
|
|
130
|
-
* @license lucide-react v0.563.0 - ISC
|
|
131
|
-
*
|
|
132
|
-
* This source code is licensed under the ISC license.
|
|
133
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
134
|
-
*/const Gg=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],Jg=X("briefcase",Gg);/**
|
|
135
|
-
* @license lucide-react v0.563.0 - ISC
|
|
136
|
-
*
|
|
137
|
-
* This source code is licensed under the ISC license.
|
|
138
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
139
|
-
*/const Qg=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Yg=X("check",Qg);/**
|
|
140
|
-
* @license lucide-react v0.563.0 - ISC
|
|
141
|
-
*
|
|
142
|
-
* This source code is licensed under the ISC license.
|
|
143
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
144
|
-
*/const Xg=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ns=X("chevron-down",Xg);/**
|
|
145
|
-
* @license lucide-react v0.563.0 - ISC
|
|
146
|
-
*
|
|
147
|
-
* This source code is licensed under the ISC license.
|
|
148
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
149
|
-
*/const Zg=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ao=X("chevron-right",Zg);/**
|
|
150
|
-
* @license lucide-react v0.563.0 - ISC
|
|
151
|
-
*
|
|
152
|
-
* This source code is licensed under the ISC license.
|
|
153
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
154
|
-
*/const ey=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ty=X("chevrons-left",ey);/**
|
|
155
|
-
* @license lucide-react v0.563.0 - ISC
|
|
156
|
-
*
|
|
157
|
-
* This source code is licensed under the ISC license.
|
|
158
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
159
|
-
*/const ny=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],ry=X("chevrons-right",ny);/**
|
|
160
|
-
* @license lucide-react v0.563.0 - ISC
|
|
161
|
-
*
|
|
162
|
-
* This source code is licensed under the ISC license.
|
|
163
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
164
|
-
*/const oy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],sy=X("circle-alert",oy);/**
|
|
165
|
-
* @license lucide-react v0.563.0 - ISC
|
|
166
|
-
*
|
|
167
|
-
* This source code is licensed under the ISC license.
|
|
168
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
169
|
-
*/const iy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],zc=X("circle-check",iy);/**
|
|
170
|
-
* @license lucide-react v0.563.0 - ISC
|
|
171
|
-
*
|
|
172
|
-
* This source code is licensed under the ISC license.
|
|
173
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
174
|
-
*/const ay=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ly=X("circle-question-mark",ay);/**
|
|
175
|
-
* @license lucide-react v0.563.0 - ISC
|
|
176
|
-
*
|
|
177
|
-
* This source code is licensed under the ISC license.
|
|
178
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
179
|
-
*/const cy=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dy=X("clock",cy);/**
|
|
180
|
-
* @license lucide-react v0.563.0 - ISC
|
|
181
|
-
*
|
|
182
|
-
* This source code is licensed under the ISC license.
|
|
183
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
184
|
-
*/const uy=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],py=X("command",uy);/**
|
|
185
|
-
* @license lucide-react v0.563.0 - ISC
|
|
186
|
-
*
|
|
187
|
-
* This source code is licensed under the ISC license.
|
|
188
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
189
|
-
*/const fy=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],or=X("database",fy);/**
|
|
190
|
-
* @license lucide-react v0.563.0 - ISC
|
|
191
|
-
*
|
|
192
|
-
* This source code is licensed under the ISC license.
|
|
193
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
194
|
-
*/const hy=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],qc=X("download",hy);/**
|
|
195
|
-
* @license lucide-react v0.563.0 - ISC
|
|
196
|
-
*
|
|
197
|
-
* This source code is licensed under the ISC license.
|
|
198
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
199
|
-
*/const my=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],gy=X("eye-off",my);/**
|
|
200
|
-
* @license lucide-react v0.563.0 - ISC
|
|
201
|
-
*
|
|
202
|
-
* This source code is licensed under the ISC license.
|
|
203
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
204
|
-
*/const yy=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],xy=X("eye",yy);/**
|
|
205
|
-
* @license lucide-react v0.563.0 - ISC
|
|
206
|
-
*
|
|
207
|
-
* This source code is licensed under the ISC license.
|
|
208
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
209
|
-
*/const by=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],vy=X("file-check",by);/**
|
|
210
|
-
* @license lucide-react v0.563.0 - ISC
|
|
211
|
-
*
|
|
212
|
-
* This source code is licensed under the ISC license.
|
|
213
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
214
|
-
*/const Sy=[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]],wy=X("file-pen",Sy);/**
|
|
215
|
-
* @license lucide-react v0.563.0 - ISC
|
|
216
|
-
*
|
|
217
|
-
* This source code is licensed under the ISC license.
|
|
218
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
219
|
-
*/const ky=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],Uc=X("file-plus",ky);/**
|
|
220
|
-
* @license lucide-react v0.563.0 - ISC
|
|
221
|
-
*
|
|
222
|
-
* This source code is licensed under the ISC license.
|
|
223
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
224
|
-
*/const jy=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],Cy=X("file-question-mark",jy);/**
|
|
225
|
-
* @license lucide-react v0.563.0 - ISC
|
|
226
|
-
*
|
|
227
|
-
* This source code is licensed under the ISC license.
|
|
228
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
229
|
-
*/const Ey=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Bs=X("file-text",Ey);/**
|
|
230
|
-
* @license lucide-react v0.563.0 - ISC
|
|
231
|
-
*
|
|
232
|
-
* This source code is licensed under the ISC license.
|
|
233
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
234
|
-
*/const Ty=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],Ay=X("file-x",Ty);/**
|
|
235
|
-
* @license lucide-react v0.563.0 - ISC
|
|
236
|
-
*
|
|
237
|
-
* This source code is licensed under the ISC license.
|
|
238
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
239
|
-
*/const Ry=[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]],_y=X("files",Ry);/**
|
|
240
|
-
* @license lucide-react v0.563.0 - ISC
|
|
241
|
-
*
|
|
242
|
-
* This source code is licensed under the ISC license.
|
|
243
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
244
|
-
*/const Oy=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Wc=X("folder-open",Oy);/**
|
|
245
|
-
* @license lucide-react v0.563.0 - ISC
|
|
246
|
-
*
|
|
247
|
-
* This source code is licensed under the ISC license.
|
|
248
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
249
|
-
*/const $y=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Un=X("folder",$y);/**
|
|
250
|
-
* @license lucide-react v0.563.0 - ISC
|
|
251
|
-
*
|
|
252
|
-
* This source code is licensed under the ISC license.
|
|
253
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
254
|
-
*/const Dy=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Py=X("funnel",Dy);/**
|
|
255
|
-
* @license lucide-react v0.563.0 - ISC
|
|
256
|
-
*
|
|
257
|
-
* This source code is licensed under the ISC license.
|
|
258
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
259
|
-
*/const Iy=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],My=X("gauge",Iy);/**
|
|
260
|
-
* @license lucide-react v0.563.0 - ISC
|
|
261
|
-
*
|
|
262
|
-
* This source code is licensed under the ISC license.
|
|
263
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
264
|
-
*/const Ly=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Cn=X("git-branch",Ly);/**
|
|
265
|
-
* @license lucide-react v0.563.0 - ISC
|
|
266
|
-
*
|
|
267
|
-
* This source code is licensed under the ISC license.
|
|
268
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
269
|
-
*/const Ny=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],By=X("git-commit-horizontal",Ny);/**
|
|
270
|
-
* @license lucide-react v0.563.0 - ISC
|
|
271
|
-
*
|
|
272
|
-
* This source code is licensed under the ISC license.
|
|
273
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
274
|
-
*/const Fy=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],zy=X("git-fork",Fy);/**
|
|
275
|
-
* @license lucide-react v0.563.0 - ISC
|
|
276
|
-
*
|
|
277
|
-
* This source code is licensed under the ISC license.
|
|
278
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
279
|
-
*/const qy=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Kc=X("layers",qy);/**
|
|
280
|
-
* @license lucide-react v0.563.0 - ISC
|
|
281
|
-
*
|
|
282
|
-
* This source code is licensed under the ISC license.
|
|
283
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
284
|
-
*/const Uy=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Wy=X("layout-dashboard",Uy);/**
|
|
285
|
-
* @license lucide-react v0.563.0 - ISC
|
|
286
|
-
*
|
|
287
|
-
* This source code is licensed under the ISC license.
|
|
288
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
289
|
-
*/const Ky=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Jt=X("loader-circle",Ky);/**
|
|
290
|
-
* @license lucide-react v0.563.0 - ISC
|
|
291
|
-
*
|
|
292
|
-
* This source code is licensed under the ISC license.
|
|
293
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
294
|
-
*/const Vy=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Hy=X("message-circle",Vy);/**
|
|
295
|
-
* @license lucide-react v0.563.0 - ISC
|
|
296
|
-
*
|
|
297
|
-
* This source code is licensed under the ISC license.
|
|
298
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
299
|
-
*/const Gy=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Jy=X("monitor",Gy);/**
|
|
300
|
-
* @license lucide-react v0.563.0 - ISC
|
|
301
|
-
*
|
|
302
|
-
* This source code is licensed under the ISC license.
|
|
303
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
304
|
-
*/const Qy=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Yy=X("network",Qy);/**
|
|
305
|
-
* @license lucide-react v0.563.0 - ISC
|
|
306
|
-
*
|
|
307
|
-
* This source code is licensed under the ISC license.
|
|
308
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
309
|
-
*/const Xy=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Zy=X("notebook-pen",Xy);/**
|
|
310
|
-
* @license lucide-react v0.563.0 - ISC
|
|
311
|
-
*
|
|
312
|
-
* This source code is licensed under the ISC license.
|
|
313
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
314
|
-
*/const ex=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],tx=X("package",ex);/**
|
|
315
|
-
* @license lucide-react v0.563.0 - ISC
|
|
316
|
-
*
|
|
317
|
-
* This source code is licensed under the ISC license.
|
|
318
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
319
|
-
*/const nx=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],rx=X("palette",nx);/**
|
|
320
|
-
* @license lucide-react v0.563.0 - ISC
|
|
321
|
-
*
|
|
322
|
-
* This source code is licensed under the ISC license.
|
|
323
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
324
|
-
*/const ox=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],sx=X("panel-left",ox);/**
|
|
325
|
-
* @license lucide-react v0.563.0 - ISC
|
|
326
|
-
*
|
|
327
|
-
* This source code is licensed under the ISC license.
|
|
328
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
329
|
-
*/const ix=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],ax=X("plug",ix);/**
|
|
330
|
-
* @license lucide-react v0.563.0 - ISC
|
|
331
|
-
*
|
|
332
|
-
* This source code is licensed under the ISC license.
|
|
333
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
334
|
-
*/const lx=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],cx=X("plus",lx);/**
|
|
335
|
-
* @license lucide-react v0.563.0 - ISC
|
|
336
|
-
*
|
|
337
|
-
* This source code is licensed under the ISC license.
|
|
338
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
339
|
-
*/const dx=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Fr=X("refresh-cw",dx);/**
|
|
340
|
-
* @license lucide-react v0.563.0 - ISC
|
|
341
|
-
*
|
|
342
|
-
* This source code is licensed under the ISC license.
|
|
343
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
344
|
-
*/const ux=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qi=X("search",ux);/**
|
|
345
|
-
* @license lucide-react v0.563.0 - ISC
|
|
346
|
-
*
|
|
347
|
-
* This source code is licensed under the ISC license.
|
|
348
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
349
|
-
*/const px=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],fx=X("settings-2",px);/**
|
|
350
|
-
* @license lucide-react v0.563.0 - ISC
|
|
351
|
-
*
|
|
352
|
-
* This source code is licensed under the ISC license.
|
|
353
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
354
|
-
*/const hx=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],mx=X("settings",hx);/**
|
|
355
|
-
* @license lucide-react v0.563.0 - ISC
|
|
356
|
-
*
|
|
357
|
-
* This source code is licensed under the ISC license.
|
|
358
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
359
|
-
*/const gx=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],yx=X("shield-alert",gx);/**
|
|
360
|
-
* @license lucide-react v0.563.0 - ISC
|
|
361
|
-
*
|
|
362
|
-
* This source code is licensed under the ISC license.
|
|
363
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
364
|
-
*/const xx=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],bx=X("shield-check",xx);/**
|
|
365
|
-
* @license lucide-react v0.563.0 - ISC
|
|
366
|
-
*
|
|
367
|
-
* This source code is licensed under the ISC license.
|
|
368
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
369
|
-
*/const vx=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],Sx=X("sigma",vx);/**
|
|
370
|
-
* @license lucide-react v0.563.0 - ISC
|
|
371
|
-
*
|
|
372
|
-
* This source code is licensed under the ISC license.
|
|
373
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
374
|
-
*/const wx=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Vc=X("sparkles",wx);/**
|
|
375
|
-
* @license lucide-react v0.563.0 - ISC
|
|
376
|
-
*
|
|
377
|
-
* This source code is licensed under the ISC license.
|
|
378
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
379
|
-
*/const kx=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],jx=X("square-dashed",kx);/**
|
|
380
|
-
* @license lucide-react v0.563.0 - ISC
|
|
381
|
-
*
|
|
382
|
-
* This source code is licensed under the ISC license.
|
|
383
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
384
|
-
*/const Cx=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Ex=X("tag",Cx);/**
|
|
385
|
-
* @license lucide-react v0.563.0 - ISC
|
|
386
|
-
*
|
|
387
|
-
* This source code is licensed under the ISC license.
|
|
388
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
389
|
-
*/const Tx=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ax=X("terminal",Tx);/**
|
|
390
|
-
* @license lucide-react v0.563.0 - ISC
|
|
391
|
-
*
|
|
392
|
-
* This source code is licensed under the ISC license.
|
|
393
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
394
|
-
*/const Rx=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Hc=X("trash-2",Rx);function _x(e,t){if(!t)return 1;const n=(e.label+" "+e.group+" "+(e.keywords||"")).toLowerCase(),r=t.toLowerCase();if(n.includes(r))return 100-n.indexOf(r);let o=0;for(const i of n)if(i===r[o]&&o++,o===r.length)return 10;return 0}function Ox(e,t){const n=e.mode??"both";return n==="both"||n===t}function $x({open:e,onClose:t}){const{state:n,dispatch:r}=Se(),[o,i]=u.useState(""),[l,a]=u.useState(0),d=u.useRef(null);u.useEffect(()=>{e&&(i(""),a(0))},[e]);const c=u.useMemo(()=>{const y=v=>r(v),S=()=>t(),x=v=>()=>{v(),S()},b=[["Files","files",_y],["Lineage","lineage",zy],["Git","git",Cn],["Block Library","block_library",Ls],["Apps","apps",Yy],["Connections","connection",ax]],w=[{mode:"obsidian",label:"Obsidian"},{mode:"paper",label:"Paper"},{mode:"white",label:"White"}],C=[];C.push({id:"sidebar.toggle",label:n.sidebarOpen?"Hide sidebar":"Show sidebar",group:"View",icon:sx,shortcut:"⌘B",mode:"studio",run:x(()=>y({type:"TOGGLE_SIDEBAR"}))},{id:"inspector.toggle",label:n.inspectorOpen?"Hide inspector":"Show inspector",group:"View",icon:n.inspectorOpen?gy:xy,shortcut:"⌘⇧I",mode:"studio",run:x(()=>y({type:"TOGGLE_INSPECTOR"}))},{id:"dashboard.toggle",label:n.dashboardMode?"Exit dashboard mode":"Enter dashboard mode",group:"View",icon:Wy,shortcut:"⌘D",run:x(()=>y({type:"TOGGLE_DASHBOARD_MODE"}))},{id:"dev.toggle",label:"Toggle dev panel",group:"View",icon:Ax,shortcut:"⌘J",mode:"studio",run:x(()=>y({type:"TOGGLE_DEV_PANEL"}))});for(const[v,j,O]of b)C.push({id:`panel.${j}`,label:`Go to ${v}`,group:"Navigate",icon:O,mode:"studio",run:x(()=>{y({type:"SET_SIDEBAR_PANEL",panel:j}),j!=="lineage"&&!n.sidebarOpen&&y({type:"TOGGLE_SIDEBAR"})})});C.push({id:"notebook.new",label:"New notebook…",group:"Create",icon:Uc,mode:"studio",run:x(()=>y({type:"OPEN_NEW_NOTEBOOK_MODAL"}))},{id:"block.new",label:"New block…",group:"Create",icon:jx,mode:"studio",run:x(()=>y({type:"OPEN_NEW_BLOCK_MODAL"}))});const E=n.themeMode==="dark"||n.themeMode==="midnight"?"obsidian":n.themeMode==="light"?"paper":n.themeMode==="arctic"?"white":n.themeMode;for(const v of w)v.mode!==E&&C.push({id:`theme.${v.mode}`,label:`Switch to ${v.label}`,group:"Theme",icon:rx,keywords:"appearance color",run:x(()=>y({type:"SET_THEME",mode:v.mode}))});return C},[n.sidebarOpen,n.inspectorOpen,n.themeMode,n.dashboardMode,n.appMode,n.sidebarPanel,r,t]),f=u.useMemo(()=>{const S=c.filter(x=>Ox(x,n.appMode)).map(x=>({a:x,s:_x(x,o)})).filter(x=>x.s>0);return S.sort((x,b)=>b.s-x.s),S.map(x=>x.a)},[c,o,n.appMode]);u.useEffect(()=>{a(0)},[o]),u.useEffect(()=>{var S;const y=(S=d.current)==null?void 0:S.querySelector(`[data-palette-idx="${l}"]`);y==null||y.scrollIntoView({block:"nearest"})},[l]);const p=y=>{var S;y.key==="ArrowDown"?(y.preventDefault(),a(x=>Math.min(f.length-1,x+1))):y.key==="ArrowUp"?(y.preventDefault(),a(x=>Math.max(0,x-1))):y.key==="Enter"&&(y.preventDefault(),(S=f[l])==null||S.run())};let h="";return s.jsx(gh,{open:e,onOpenChange:y=>!y&&t(),children:s.jsxs(yh,{children:[s.jsx(xh,{style:{position:"fixed",inset:0,background:le("surfaceOverlay"),zIndex:Wn.overlay}}),s.jsxs(bh,{"aria-label":"Command palette",style:{position:"fixed",top:"18vh",left:"50%",transform:"translateX(-50%)",width:"92vw",maxWidth:620,background:le("surfaceRaised"),color:le("textPrimary"),border:`1px solid ${le("borderDefault")}`,borderRadius:Nt.lg,boxShadow:le("shadowLg"),zIndex:Wn.modal,display:"flex",flexDirection:"column",overflow:"hidden"},onKeyDown:p,children:[s.jsx(vh,{style:{position:"absolute",left:-9999},children:"Command palette"}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:me[2],padding:`${me[3]}px ${me[4]}px`,borderBottom:`1px solid ${le("borderSubtle")}`},children:[s.jsx(py,{size:14,strokeWidth:1.75,color:le("textMuted")}),s.jsx("input",{autoFocus:!0,value:o,onChange:y=>i(y.target.value),placeholder:"Type a command…",style:{flex:1,border:"none",outline:"none",background:"transparent",color:le("textPrimary"),fontSize:ze.md}})]}),s.jsxs("div",{ref:d,style:{maxHeight:360,overflowY:"auto",padding:`${me[1]}px 0`},children:[f.length===0&&s.jsx("div",{style:{padding:me[4],fontSize:ze.sm,color:le("textMuted"),textAlign:"center"},children:"No matching commands"}),f.map((y,S)=>{const x=y.group!==h;h=y.group;const b=S===l,w=y.icon;return s.jsxs(Ie.Fragment,{children:[x&&s.jsx("div",{style:{padding:`${me[2]}px ${me[4]}px ${me[1]}px`},children:s.jsx(Nc,{tone:"neutral",children:y.group})}),s.jsxs("div",{"data-palette-idx":S,role:"option","aria-selected":b,onMouseEnter:()=>a(S),onMouseDown:C=>{C.preventDefault(),y.run()},style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:me[3],padding:`${me[2]}px ${me[4]}px`,fontSize:ze.sm,cursor:"pointer",background:b?le("surfaceHover"):"transparent",color:le("textPrimary")},children:[s.jsxs("span",{style:{display:"flex",alignItems:"center",gap:me[2],minWidth:0,flex:1},children:[w&&s.jsx(w,{size:14,strokeWidth:1.75}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.label})]}),y.shortcut&&s.jsx(ug,{shortcut:y.shortcut})]})]},y.id)})]})]})]})})}function es(e){const t=Rt(e);if(!t)return;const n=Mx(t.kind),r=Dx(t.source);if(!n||!r)return;const o=Hx(t.limit);return{kind:n,source:r,name:st(t.name),sourcePath:st(t.sourcePath),metrics:ts(t.metrics),dimensions:ts(t.dimensions),filters:Lx(t.filters),timeDimension:Nx(t.timeDimension),orderBy:Bx(t.orderBy),parameters:Fx(t.parameters),parameterValues:Wx(t.parameterValues),persistence:Kx(t.persistence),trustState:Vx(t.trustState),compiledSql:st(t.compiledSql),executionReceipt:Ix(t.executionReceipt),filterableColumns:Px(t.filterableColumns),...o===void 0?{}:{limit:o}}}function Dx(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function Px(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Rt(n),o=st(r==null?void 0:r.column),i=st(r==null?void 0:r.predicateTarget);return o&&i?[{column:o,predicateTarget:i}]:[]});return t.length>0?t:void 0}function Ix(e){const t=Rt(e);if(!t)return;const n=vr(t.sourceFingerprint),r=vr(t.compiledSqlFingerprint),o=vr(t.parameterFingerprint),i=vr(t.resultFingerprint);return n&&r&&o&&i?{sourceFingerprint:n,compiledSqlFingerprint:r,parameterFingerprint:o,resultFingerprint:i}:void 0}function vr(e){return typeof e=="string"&&/^[a-f0-9]{64}$/i.test(e.trim())?e.trim().toLowerCase():void 0}function Mx(e){return e==="certified_block"||e==="semantic_block"||e==="sql_block"?e:void 0}function Lx(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Rt(n);if(!r)return[];const o=st(r.dimension),i=st(r.operator);return!o||!i?[]:[{dimension:o,operator:i,values:ts(r.values)??[]}]});return t.length?t:void 0}function Nx(e){const t=Rt(e);if(!t)return;const n=st(t.name),r=st(t.granularity);return n&&r?{name:n,granularity:r}:void 0}function Bx(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Rt(n);if(!r)return[];const o=st(r.name),i=r.direction==="asc"||r.direction==="desc"?r.direction:void 0;return o&&i?[{name:o,direction:i}]:[]});return t.length?t:void 0}function Fx(e){if(!Array.isArray(e))return;const t=new Set,n=e.flatMap(r=>{const o=Rt(r),i=st(o==null?void 0:o.name),l=zx(o==null?void 0:o.type),a=qx(o==null?void 0:o.policy);if(!o||!i||!l||!a||t.has(i))return[];t.add(i);const d=Ux(o.binding);return[{name:i,type:l,required:o.required===!0,...o.default===void 0?{}:{default:o.default},policy:a,...d?{binding:d}:{}}]});return n.length?n:void 0}function zx(e){return e==="string"||e==="number"||e==="boolean"||e==="date"||e==="string[]"||e==="number[]"||e==="date[]"?e:void 0}function qx(e){return e==="dynamic"||e==="static"||e==="business"||e==="derived"||e==="optional"||e==="ambiguous_review_required"?e:void 0}function Ux(e){const t=Rt(e);if(!t)return;if(t.kind==="sql_value")return{kind:"sql_value"};if(t.kind==="limit")return{kind:"limit"};const n=st(t.field);if(t.kind==="semantic_filter"&&n&&(t.operator==="equals"||t.operator==="in"||t.operator==="gte"||t.operator==="lte"))return{kind:"semantic_filter",field:n,operator:t.operator}}function Wx(e){const t=Rt(e);if(!t)return;const n=Object.entries(t).filter(([r])=>r.trim().length>0);return n.length?Object.fromEntries(n):void 0}function Kx(e){return e==="transient"||e==="saved"?e:void 0}function Vx(e){return e==="certified"||e==="governed"||e==="review_required"?e:void 0}function Rt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function st(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function ts(e){if(!Array.isArray(e))return;const t=e.filter(n=>typeof n=="string"&&n.trim().length>0).map(n=>n.trim());return t.length?t:void 0}function Hx(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}const Gc="dql_token",Ui="dql.server-token.v1";function Gx(e){var r;return((r=new URLSearchParams(e.replace(/^#/,"")).get(Gc))==null?void 0:r.trim())||void 0}function Jx(e){const t=new URLSearchParams(e.replace(/^#/,""));t.delete(Gc);const n=t.toString();return n?`#${n}`:""}function Qx(){var e;if(!(typeof window>"u"))try{const t=Gx(window.location.hash);if(t){window.sessionStorage.setItem(Ui,t);const n=Jx(window.location.hash);return window.history.replaceState(window.history.state,"",`${window.location.pathname}${window.location.search}${n}`),t}return((e=window.sessionStorage.getItem(Ui))==null?void 0:e.trim())||void 0}catch{return}}const Wi=Qx();function In(e){const t=new Headers(e);return Wi&&t.set("Authorization",`Bearer ${Wi}`),t}const Yx={totals:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0},willGenerate:0,willSkip:0,domains:[],config:{businessLayers:[],excludeLayers:[],maxPerDomain:0,minScore:0,aiEnrichment:"auto"}};function Sr(){return{total:0,tracked:0,changed:0,untracked:0,ignored:0,paths:[]}}const Mn=window.location.origin;class rt extends Error{constructor(n){super(n.message);Ee(this,"status");Ee(this,"code");Ee(this,"recoverable");Ee(this,"details");Ee(this,"nextActions");Ee(this,"requestId");Ee(this,"snapshotId");this.name="DqlApiError",this.status=n.status,this.code=n.code,this.recoverable=n.recoverable,this.details=n.details,this.nextActions=n.nextActions,this.requestId=n.requestId,this.snapshotId=n.snapshotId}}function ns(e,t){const n=t.trim()||e.statusText||`HTTP ${e.status}`;if(!t.trim())return new rt({message:n,status:e.status});try{const r=JSON.parse(t),o=typeof(r==null?void 0:r.message)=="string"&&r.message.trim()?r.message:typeof(r==null?void 0:r.error)=="string"&&r.error.trim()?r.error:n;return new rt({message:o,status:e.status,code:typeof(r==null?void 0:r.code)=="string"?r.code:void 0,recoverable:typeof(r==null?void 0:r.recoverable)=="boolean"?r.recoverable:void 0,details:r==null?void 0:r.details,nextActions:Array.isArray(r==null?void 0:r.nextActions)?r.nextActions.filter(i=>typeof i=="string"):void 0,requestId:typeof(r==null?void 0:r.requestId)=="string"?r.requestId:void 0,snapshotId:typeof(r==null?void 0:r.snapshotId)=="string"?r.snapshotId:void 0})}catch{return new rt({message:n,status:e.status})}}const jo=new Map;async function k(e,t){if(((t==null?void 0:t.method)??"GET").toUpperCase()==="GET"&&!(t!=null&&t.signal)&&!(t!=null&&t.body)){const o=jo.get(e);if(o)return o;const i=Ki(e,t).finally(()=>{jo.delete(e)});return jo.set(e,i),i}return Ki(e,t)}async function Ki(e,t){var r;let n;try{const o=In(t==null?void 0:t.headers);o.has("Content-Type")||o.set("Content-Type","application/json"),n=await fetch(`${Mn}${e}`,{...t,headers:o})}catch(o){if((r=t==null?void 0:t.signal)!=null&&r.aborted)throw o;const i=o instanceof Error&&o.message?` ${o.message}`:"";throw new Error(`Unable to reach the local DQL notebook server. Check that it is still running, then retry.${i}`)}if(!n.ok){const o=await n.text().catch(()=>"");throw ns(n,o)}if(n.status!==204)return n.json()}async function Xx(e,t){if(!e.body)throw new Error("Agent run stream is not available in this browser.");const n=e.body.getReader(),r=new TextDecoder;let o="",i;const l=a=>{const d=a.split(/\r?\n/);let c="message";const f=[];for(const h of d)h.startsWith("event:")&&(c=h.slice(6).trim()),h.startsWith("data:")&&f.push(h.slice(5).trimStart());if(f.length===0)return;const p=JSON.parse(f.join(`
|
|
395
|
-
`));if(c==="agent-run-event")t({kind:"event",event:p});else if(c==="agent-run-answer-delta"){const h=typeof(p==null?void 0:p.delta)=="string"?p.delta:"";h&&t({kind:"answer-delta",delta:h})}else if(c==="agent-run-complete")i=p,t({kind:"complete",run:i});else if(c==="agent-run-error")throw new Error(typeof(p==null?void 0:p.error)=="string"?p.error:"Agent run failed.")};for(;;){const{value:a,done:d}=await n.read();if(a){o+=r.decode(a,{stream:!d});let c=o.search(/\r?\n\r?\n/);for(;c>=0;){const f=o.slice(0,c);o=o.slice(o[c]==="\r"?c+4:c+2),l(f),c=o.search(/\r?\n\r?\n/)}}if(d)break}if(o.trim()&&l(o),!i)throw new Error("Agent run stream ended before completion.");return i}function Gt(e){var r;const t=Array.isArray(e==null?void 0:e.columns)?e.columns.map(o=>typeof o=="string"?o:typeof(o==null?void 0:o.name)=="string"?o.name:String(o)):[],n=e!=null&&e.semanticRefs&&typeof e.semanticRefs=="object"?{metrics:Array.isArray(e.semanticRefs.metrics)?e.semanticRefs.metrics.map(String):[],dimensions:Array.isArray(e.semanticRefs.dimensions)?e.semanticRefs.dimensions.map(String):[]}:void 0;return{columns:t,rows:Array.isArray(e==null?void 0:e.rows)?e.rows:[],rowCount:(e==null?void 0:e.rowCount)??((r=e==null?void 0:e.rows)==null?void 0:r.length)??0,executionTime:(e==null?void 0:e.executionTime)??(e==null?void 0:e.executionTimeMs)??0,...n?{semanticRefs:n}:{}}}function jt(e){var n;const t=e!=null&&e.resultPreview&&typeof e.resultPreview=="object"?Gt(e.resultPreview):void 0;return{...e,domain:typeof(e==null?void 0:e.domain)=="string"&&e.domain.trim()?e.domain:void 0,owner:typeof(e==null?void 0:e.owner)=="string"&&e.owner.trim()?e.owner:void 0,warnings:Array.isArray(e==null?void 0:e.warnings)?e.warnings:[],dqlCandidateIds:Array.isArray(e==null?void 0:e.dqlCandidateIds)?e.dqlCandidateIds:[],dqlArtifact:es(e==null?void 0:e.dqlArtifact),dqlPromotionAction:lb((e==null?void 0:e.dqlPromotionAction)??((n=e==null?void 0:e.dqlPromotion)==null?void 0:n.recommendedAction)),dqlPromotion:Jc(e==null?void 0:e.dqlPromotion),researchPlan:Zx(e==null?void 0:e.researchPlan),reviewChecklist:ib(e==null?void 0:e.reviewChecklist,e),...t?{resultPreview:t}:{resultPreview:void 0}}}function Zx(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=t.evidence&&typeof t.evidence=="object"&&!Array.isArray(t.evidence)?t.evidence:{},r=t.preview&&typeof t.preview=="object"&&!Array.isArray(t.preview)?t.preview:{},o=t.promotion&&typeof t.promotion=="object"&&!Array.isArray(t.promotion)?t.promotion:{},i=t.sqlState==="generated"||t.sqlState==="reviewed"?t.sqlState:"missing",l=r.status==="ready"||r.status==="error"?r.status:"not_run",a=o.path==="review_context"||o.path==="run_preview"||o.path==="reuse_existing"||o.path==="create_dql_draft"||o.path==="open_certification"||o.path==="complete_review"?o.path:"needs_sql",d=typeof r.rowCount=="number"&&Number.isFinite(r.rowCount)?r.rowCount:void 0;return{sqlState:i,grain:typeof t.grain=="string"&&t.grain.trim()?t.grain:void 0,parameterPolicy:eb(t.parameterPolicy),allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters.map(String).filter(Boolean):[],evidence:{trustLabel:typeof n.trustLabel=="string"&&n.trustLabel.trim()?n.trustLabel:void 0,contextPackId:typeof n.contextPackId=="string"&&n.contextPackId.trim()?n.contextPackId:void 0,evidenceCount:be(n.evidenceCount),relationCount:be(n.relationCount),missingContextCount:be(n.missingContextCount)},preview:{status:l,...d===void 0?{}:{rowCount:d}},promotion:{path:a,duplicateDecision:typeof o.duplicateDecision=="string"&&o.duplicateDecision.trim()?o.duplicateDecision:void 0},reviewFocus:Array.isArray(t.reviewFocus)?t.reviewFocus.map(String).filter(Boolean):[],generatedAt:typeof t.generatedAt=="string"&&t.generatedAt.trim()?t.generatedAt:new Date(0).toISOString()}}function eb(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];const n=t,r=typeof n.name=="string"&&n.name.trim()?n.name:void 0,o=typeof n.policy=="string"&&n.policy.trim()?n.policy:void 0;return r&&o?[{name:r,policy:o}]:[]}):[]}function be(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function cn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function tb(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{totalReviewCount:be(t.totalReviewCount),openReviewCount:be(t.openReviewCount),terminalReviewCount:be(t.terminalReviewCount),draftCreatedCount:be(t.draftCreatedCount),certifiedCount:be(t.certifiedCount),completedCount:be(t.completedCount),rejectedCount:be(t.rejectedCount),draftCreationRate:cn(t.draftCreationRate),certifyConversionRate:cn(t.certifyConversionRate),medianOpenReviewAgeMs:cn(t.medianOpenReviewAgeMs),medianTimeToDraftMs:cn(t.medianTimeToDraftMs),medianTimeToCertificationMs:cn(t.medianTimeToCertificationMs),medianTimeToTerminalMs:cn(t.medianTimeToTerminalMs)}}function nb(e){const t=e&&typeof e=="object"?e:{},n=t.counts&&typeof t.counts=="object"?t.counts:{},r=t.health&&typeof t.health=="object"?t.health:{},o=t.search&&typeof t.search=="object"?t.search:{},i=t.updatedAt&&typeof t.updatedAt=="object"?t.updatedAt:{},l=t.limits&&typeof t.limits=="object"?t.limits:{};return{counts:{totalRuns:be(n.totalRuns),activeRuns:be(n.activeRuns),closedRuns:be(n.closedRuns),notebooks:be(n.notebooks),domains:be(n.domains),owners:be(n.owners),sourceLinkedRuns:be(n.sourceLinkedRuns)},health:{staleOpenRuns:be(r.staleOpenRuns),expiredOpenRuns:be(r.expiredOpenRuns),staleThresholdDays:be(r.staleThresholdDays)||7,expiredThresholdDays:be(r.expiredThresholdDays)||30,oldestOpenUpdatedAt:typeof r.oldestOpenUpdatedAt=="string"&&r.oldestOpenUpdatedAt.trim()?r.oldestOpenUpdatedAt:void 0,newestOpenUpdatedAt:typeof r.newestOpenUpdatedAt=="string"&&r.newestOpenUpdatedAt.trim()?r.newestOpenUpdatedAt:void 0},search:{indexed:o.indexed===!0,indexRows:be(o.indexRows),indexVersion:typeof o.indexVersion=="string"&&o.indexVersion.trim()?o.indexVersion:void 0,stale:o.stale===!0},updatedAt:{oldest:typeof i.oldest=="string"&&i.oldest.trim()?i.oldest:void 0,newest:typeof i.newest=="string"&&i.newest.trim()?i.newest:void 0},limits:{pageSize:be(l.pageSize)||25,maxPageSize:be(l.maxPageSize)||500,sourceCoverageLimit:be(l.sourceCoverageLimit)||1e4,seedCellLimit:be(l.seedCellLimit)||1e3},warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[]}}function rb(e){return e==="diagnose_change"||e==="driver_breakdown"||e==="segment_compare"||e==="entity_drilldown"||e==="anomaly_investigation"||e==="trust_gap_review"?e:"ad_hoc_analysis"}function ob(e){const t=typeof e=="string"?e:"";return(t.split(/[\\/]/).pop()??t).replace(/\.dqlnb$/i,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim()||"Untitled notebook"}function sb(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=r=>typeof t[r]=="number"&&Number.isFinite(t[r])?t[r]:0;return{fix_blockers:n("fix_blockers"),review_sql:n("review_sql"),review_context:n("review_context"),run_preview:n("run_preview"),reuse_existing:n("reuse_existing"),create_dql_draft:n("create_dql_draft"),open_certification:n("open_certification"),complete_review:n("complete_review"),continue_review:n("continue_review")}}function wr(e){return e==="fix_blockers"||e==="review_sql"||e==="review_context"||e==="run_preview"||e==="reuse_existing"||e==="create_dql_draft"||e==="open_certification"||e==="complete_review"||e==="continue_review"?e:void 0}function ib(e,t){var c,f;if(e&&typeof e=="object"&&Array.isArray(e.items))return{readyForDqlDraft:e.readyForDqlDraft===!0,readyForCertificationReview:e.readyForCertificationReview===!0,blockers:Array.isArray(e.blockers)?e.blockers.filter(p=>typeof p=="string"):[],warnings:Array.isArray(e.warnings)?e.warnings.filter(p=>typeof p=="string"):[],items:e.items.map(p=>({id:typeof p.id=="string"?p.id:"item",label:typeof p.label=="string"?p.label:"Review item",status:p.status==="passed"||p.status==="pending"||p.status==="warning"||p.status==="blocked"?p.status:"pending",detail:typeof p.detail=="string"?p.detail:""}))};const n=!!t.reviewedSql,r=n||!!t.generatedSql,o=((c=t.resultPreview)==null?void 0:c.rowCount)??((f=t.resultPreview)==null?void 0:f.rows.length)??0,i=!!(t.resultPreview&&(t.resultPreview.columns.length>0||o>0)),l=!!t.draftBlockPath,a=!!(t.contextPackId||t.evidence),d=t.dqlPromotionAction==="reuse_existing";return{readyForDqlDraft:!!(!d&&t.question&&n&&a&&t.status!=="error"),readyForCertificationReview:!!(!d&&t.question&&n&&a&&i&&l),blockers:t.status==="error"?[t.error??"Preview failed."]:[],warnings:i||d?[]:["Run a bounded preview before certification review."],items:[{id:"question",label:"Question",status:t.question?"passed":"blocked",detail:t.question?"Business question is captured.":"Add a business question."},{id:"sql",label:"Reviewed SQL",status:r||d?"passed":"blocked",detail:d&&!r?"Existing DQL should be reused; no new SQL is required.":r?"SQL is available.":"Add SQL before promotion."},{id:"evidence",label:"Evidence",status:a||d?"passed":"warning",detail:a?"Context evidence is saved.":d?"Reuse evidence is captured in the recommendation.":"Preview and save metadata context."},{id:"preview",label:"Preview",status:i||d?"passed":"pending",detail:i?"Preview result is available.":d?"Certified block reuse does not require a new raw SQL preview.":"Run a bounded preview."},{id:"dql_draft",label:"DQL draft",status:l||d?"passed":"pending",detail:l?`Draft saved at ${t.draftBlockPath}.`:d?"No new DQL draft is required.":"Create a DQL draft after review."}]}}function ab(e){var r,o,i,l;const t=e&&typeof e=="object"?e:{},n=t.routeDecision&&typeof t.routeDecision=="object"?{route:typeof t.routeDecision.route=="string"?t.routeDecision.route:void 0,intent:typeof t.routeDecision.intent=="string"?t.routeDecision.intent:void 0,reason:typeof t.routeDecision.reason=="string"?t.routeDecision.reason:void 0}:void 0;return{contextPackId:typeof t.contextPackId=="string"?t.contextPackId:"",trustLabel:typeof t.trustLabel=="string"?t.trustLabel:void 0,routeDecision:n,evidence:Array.isArray(t.evidence)?t.evidence.map(a=>({objectKey:typeof a.objectKey=="string"?a.objectKey:void 0,objectType:typeof a.objectType=="string"?a.objectType:void 0,name:typeof a.name=="string"?a.name:"Evidence",role:typeof a.role=="string"?a.role:void 0,reason:typeof a.reason=="string"?a.reason:""})):[],summaries:Array.isArray(t.summaries)?t.summaries.map(a=>({title:typeof a.title=="string"?a.title:"Context",detail:typeof a.detail=="string"?a.detail:"",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:void 0})):[],relations:Array.isArray(t.relations)?t.relations.map(a=>({relation:typeof a.relation=="string"?a.relation:"",name:typeof a.name=="string"?a.name:"Relation",source:typeof a.source=="string"?a.source:"",columns:Array.isArray(a.columns)?a.columns.map(String):[]})).filter(a=>a.relation||a.name):[],missingContext:Array.isArray(t.missingContext)?t.missingContext.map(a=>({kind:typeof a.kind=="string"?a.kind:"metadata",message:typeof a.message=="string"?a.message:"",severity:typeof a.severity=="string"?a.severity:"warning"})).filter(a=>a.message):[],warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[],topRejected:Array.isArray(t.topRejected)?t.topRejected.map(a=>({name:typeof a.name=="string"?a.name:"Rejected context",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:"",score:typeof a.score=="number"&&Number.isFinite(a.score)?a.score:void 0})).filter(a=>a.reason):[],counts:{objects:typeof((r=t.counts)==null?void 0:r.objects)=="number"?t.counts.objects:0,evidence:typeof((o=t.counts)==null?void 0:o.evidence)=="number"?t.counts.evidence:0,relations:typeof((i=t.counts)==null?void 0:i.relations)=="number"?t.counts.relations:0,warnings:typeof((l=t.counts)==null?void 0:l.warnings)=="number"?t.counts.warnings:0}}}function lb(e){return e==="reuse_existing"||e==="extend_existing"||e==="create_replacement"||e==="create_new"||e==="review_required"?e:void 0}function Jc(e){if(!(!e||typeof e!="object"))return{importId:typeof e.importId=="string"?e.importId:"",candidateIds:Array.isArray(e.candidateIds)?e.candidateIds.filter(t=>typeof t=="string"):[],draftBlockPath:typeof e.draftBlockPath=="string"?e.draftBlockPath:void 0,recommendedAction:typeof e.recommendedAction=="string"?e.recommendedAction:void 0,similarityMatches:Array.isArray(e.similarityMatches)?e.similarityMatches:[],candidates:Array.isArray(e.candidates)?e.candidates.map(t=>({...t,similarityMatches:Array.isArray(t.similarityMatches)?t.similarityMatches:[],parameterPolicy:Array.isArray(t.parameterPolicy)?t.parameterPolicy:[],allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters:[],warnings:Array.isArray(t.warnings)?t.warnings:[]})):[],createdAt:typeof e.createdAt=="string"?e.createdAt:""}}const N={async getDbtFirstModeling(){return k("/api/modeling/dbt-first")},async getDbtModelingNode(e){return k(`/api/modeling/dbt-first/nodes/${encodeURIComponent(e)}`)},async getDbtModelingNodes(e){return k("/api/modeling/dbt-first/nodes/batch",{method:"POST",body:JSON.stringify({uniqueIds:e})})},async getDbtModelInventory(e={}){const t=new URLSearchParams;return e.q&&t.set("q",e.q),e.domain&&t.set("domain",e.domain),e.cursor!==void 0&&t.set("cursor",String(e.cursor)),e.limit!==void 0&&t.set("limit",String(e.limit)),e.physicalOnly&&t.set("physicalOnly","true"),k(`/api/modeling/dbt-first/inventory?${t.toString()}`)},async getDomainWorkspaces(){return k("/api/domain-workspaces")},async getRelatedDomainProducts(e){return k(`/api/domain-workspaces/${encodeURIComponent(e)}/related-products`)},async getAllRelatedDomainProducts(){return k("/api/domain-workspaces/related-products")},async getDomainKnowledge(e){return k(`/api/domain-workspaces/${encodeURIComponent(e)}/knowledge`)},async previewModelingChange(e,t){return k("/api/modeling/dbt-first/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyModelingChange(e,t,n){return k("/api/modeling/dbt-first/apply",{method:"POST",body:JSON.stringify({change:e,fingerprint:t,expectedSnapshotId:n})})},async validateModelingRelationship(e,t){return(await k("/api/modeling/dbt-first/relationships/validate",{method:"POST",body:JSON.stringify({relationship:e,expectedSnapshotId:t})})).evidence},async previewDbtSourcePatch(e,t){return k("/api/modeling/dbt-first/dbt-source/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyDbtSourcePatch(e,t,n){return k("/api/modeling/dbt-first/dbt-source/apply",{method:"POST",body:JSON.stringify({change:e,expectedFingerprint:t,expectedSnapshotId:n})})},async getSettingsEnvStatus(){try{return await k("/api/settings/env-status")}catch{return{groups:[]}}},async getProposeReadiness(e){try{return await k("/api/propose",{method:"POST",body:JSON.stringify(e??{})})}catch{return{ready:!1,reason:"Unable to reach the propose engine. Is the local DQL server running?",summary:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0,proposalsRanked:0,draftsExisting:0,readyForReview:0,blockingTotal:0,warningTotal:0},plan:Yx,proposals:[]}}},async generateProposeDrafts(e){try{return await k("/api/propose/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ready:!1,reason:t instanceof Error?t.message:"Unable to reach the propose engine.",draftsWritten:0,draftsSkipped:0,proposals:[]}}},async proposePreview(e){return k(`/api/propose/preview?slug=${encodeURIComponent(e)}`)},async aiBuild(e){return k("/api/ai/build",{method:"POST",body:JSON.stringify(e)})},async createAgentRun(e){return(await k("/api/agent-runs",{method:"POST",body:JSON.stringify(e)})).run},async createAgentRunStream(e,t,n){let r;try{r=await fetch(`${Mn}/api/agent-runs?stream=1`,{method:"POST",headers:In({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:n})}catch(o){if(n!=null&&n.aborted)throw o;const i=o instanceof Error&&o.message?` ${o.message}`:"";throw new Error(`Unable to reach the local DQL notebook server. Check that it is still running, then retry.${i}`)}if(!r.ok){const o=await r.text().catch(()=>"");throw ns(r,o)}return Xx(r,t)},async listAgentRuns(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit));const n=t.toString()?`?${t.toString()}`:"";return k(`/api/agent-runs${n}`)},async getAgentRun(e){const t=await this.getAgentRunState(e);if(t.lifecycleState!=="terminal")throw new Error(`Agent run ${e} is still ${t.lifecycleState}.`);return t.run},async getAgentRunState(e){return k(`/api/agent-runs/${encodeURIComponent(e)}`)},async deriveAnalyticalRepair(e,t){return k(`/api/agent-runs/${encodeURIComponent(e)}/analytical-repair`,{method:"POST",body:JSON.stringify({repair:t})})},async repairAgentRunExecution(e,t){return k(`/api/agent-runs/${encodeURIComponent(e)}/repair-execution`,{method:"POST",body:JSON.stringify({threadId:t})})},async repairNotebookCellExecution(e,t,n){var o,i,l,a,d,c;const r=await k("/api/notebook/repair-execution",{method:"POST",body:JSON.stringify({cell:{id:e.id,type:e.type,source:e.content,title:e.name,config:e.chartConfig},error:t,failure:(o=e.execution)==null?void 0:o.error,attemptedSql:((i=e.execution)==null?void 0:i.compiledSql)??e.content,executionTarget:e.executionTarget,parameters:((l=e.blockBinding)==null?void 0:l.state)==="bound"?e.blockBinding.parameterValues:e.dqlParameterValues,executionContext:n})});if(n!=null&&n.runId&&typeof((a=r==null?void 0:r.executionContext)==null?void 0:a.runId)=="string"&&r.executionContext.runId!==n.runId)throw new rt({message:"The notebook server returned a repair for a different cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:r.executionContext}});return{ok:!0,source:String(r.source??e.content),repairedSql:String(r.repairedSql??""),repairMode:r.repairMode==="ai"?"ai":"deterministic",result:Gt(r.result),executionTarget:((d=r==null?void 0:r.executionTarget)==null?void 0:d.target)==="local"?{target:"local"}:((c=r==null?void 0:r.executionTarget)==null?void 0:c.target)==="connection"?{target:"connection",...typeof r.executionTarget.connectionName=="string"?{connectionName:r.executionTarget.connectionName}:{}}:void 0,compiledSql:typeof(r==null?void 0:r.compiledSql)=="string"?r.compiledSql:void 0,executedSql:typeof(r==null?void 0:r.executedSql)=="string"?r.executedSql:void 0,executionReceipt:r!=null&&r.executionReceipt&&typeof r.executionReceipt=="object"?r.executionReceipt:void 0}},async cancelAgentRun(e){return k(`/api/agent-runs/${encodeURIComponent(e)}/cancel`,{method:"POST"})},async listAgentThreads(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit)),e!=null&&e.archived&&t.set("archived","1");const n=t.toString()?`?${t.toString()}`:"";return k(`/api/agent/threads${n}`)},async createAgentThread(e={}){return(await k("/api/agent/threads",{method:"POST",body:JSON.stringify(e)})).thread},async getAgentThread(e){return k(`/api/agent/threads/${encodeURIComponent(e)}`)},async updateAgentThread(e,t){return k(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async archiveAgentThread(e){return k(`/api/agent/threads/${encodeURIComponent(e)}/archive`,{method:"POST"})},async deleteAgentThread(e){return k(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"DELETE"})},async requestCertification(e){return k("/api/agent-runs/request-certification",{method:"POST",body:JSON.stringify(e)})},async getIdentity(){return k("/api/identity")},async getProviderSettings(){try{return await k("/api/settings/providers")}catch{return{providers:[]}}},async getProviderCliStatus(){try{return await k("/api/settings/providers/cli-status")}catch{return{status:{}}}},async saveProviderSettings(e){return k("/api/settings/providers",{method:"POST",body:JSON.stringify(e)})},async startOAuth(e){return k(`/api/auth/${e}/start`,{method:"POST"})},async getOAuthStatus(e){return k(`/api/auth/${e}/status`)},async signOutOAuth(e){return k(`/api/auth/${e}/signout`,{method:"POST"})},async testProviderSettings(e,t){try{return await k("/api/settings/providers/test",{method:"POST",body:JSON.stringify({id:e,...t})})}catch(n){return{ok:!1,message:n instanceof Error?n.message:String(n)}}},async getRemoteMcpSettings(){try{return await k("/api/settings/mcp")}catch{return{settings:{path:"",entries:[],warnings:[]}}}},async saveRemoteMcpSettings(e){return k("/api/settings/mcp",{method:"POST",body:JSON.stringify({entries:e})})},async recordAgentCorrection(e){return k("/api/agent/learnings/correction",{method:"POST",body:JSON.stringify(e)})},async listAgentHints(e){const t=e?`?status=${encodeURIComponent(e)}`:"";return k(`/api/agent/hints${t}`)},async reviewAgentHint(e,t,n){return k(`/api/agent/hints/${encodeURIComponent(e)}/review`,{method:"POST",body:JSON.stringify({decision:t,...n?{note:n}:{}})})},async updateAgentHint(e,t){return k(`/api/agent/hints/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async transitionAgentHint(e,t){return k(`/api/agent/hints/${encodeURIComponent(e)}/lifecycle`,{method:"POST",body:JSON.stringify(t)})},async listAgentMemory(e){const t=e?`?scope=${encodeURIComponent(e)}`:"";try{return await k(`/api/agent/memory${t}`)}catch{return{memories:[]}}},async saveAgentMemory(e){return k("/api/agent/memory",{method:"POST",body:JSON.stringify(e)})},async deleteAgentMemory(e){return k(`/api/agent/memory?id=${encodeURIComponent(e)}`,{method:"DELETE"})},async ensureAgentMemoryFiles(){return k("/api/agent/memory/default-files",{method:"POST"})},async listNotebooks(){try{return await k("/api/notebooks")}catch{return[]}},async readNotebook(e){return k(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async deleteNotebook(e){return k(`/api/notebooks?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async createNotebook(e,t,n={}){return k("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:t,...n})})},async createBlock(e,t){return k("/api/blocks",{method:"POST",body:JSON.stringify({name:e,...t})})},async getBlockLibrary(){try{return await k("/api/blocks/library")}catch{return{blocks:[]}}},async getApps(){try{return await k("/api/apps")}catch{return{apps:[]}}},async updateBlockStatus(e,t){return k("/api/blocks/status",{method:"POST",body:JSON.stringify({path:e,newStatus:t})})},async getBlockHistory(e){try{return await k(`/api/blocks/history?path=${encodeURIComponent(e)}`)}catch{return{entries:[]}}},async runBlockTests(e,t){return k("/api/blocks/run-tests",{method:"POST",body:JSON.stringify({source:e,path:t})})},async getBlockStudioCatalog(e={}){const t=new URLSearchParams;e.includeSemantic===!1&&t.set("includeSemantic","false");const n=t.toString();return k(`/api/block-studio/catalog${n?`?${n}`:""}`)},async getBlockStudioDbtStatus(){return k("/api/block-studio/dbt-status")},async openBlockStudio(e){return k(`/api/block-studio/open?path=${encodeURIComponent(e)}`)},async getBlockBody(e){return k(`/api/blocks/body?path=${encodeURIComponent(e)}`)},async validateBlockStudio(e,t){return k("/api/block-studio/validate",{method:"POST",body:JSON.stringify({source:e,path:t})})},async runBlockStudio(e,t,n){return k("/api/block-studio/run",{method:"POST",body:JSON.stringify({source:e,path:t,parameters:n})})},async getCertifiedBlockParameters(e){return k(`/api/blocks/parameters?name=${encodeURIComponent(e)}`)},async invokeCertifiedBlock(e,t,n){var o,i,l,a,d,c;const r=await k("/api/blocks/invoke",{method:"POST",body:JSON.stringify({blockName:e,parameters:t,question:n})});return{parameters:Array.isArray(r==null?void 0:r.parameters)?r.parameters:[],result:{...Gt(r==null?void 0:r.result),...typeof((o=r==null?void 0:r.result)==null?void 0:o.sql)=="string"?{sql:r.result.sql}:{},...typeof((i=r==null?void 0:r.result)==null?void 0:i.blockName)=="string"?{blockName:r.result.blockName}:{},...typeof((l=r==null?void 0:r.result)==null?void 0:l.blockPath)=="string"?{blockPath:r.result.blockPath}:{},...(a=r==null?void 0:r.result)!=null&&a.chartConfig?{chartConfig:r.result.chartConfig}:{},...Array.isArray((d=r==null?void 0:r.result)==null?void 0:d.parameters)?{parameters:r.result.parameters}:{},...typeof((c=r==null?void 0:r.result)==null?void 0:c.auditId)=="string"?{auditId:r.result.auditId}:{}}}},async addDqlArtifactResultFilter(e,t,n,r,o){const i=await k("/api/dql/artifacts/add-filter",{method:"POST",body:JSON.stringify({artifact:e,resultColumns:t,column:n,value:r,executionTarget:o})}),l=es(i==null?void 0:i.artifact);if(!l)throw new Error("Adding the filter input returned an invalid artifact contract.");return{artifact:l,parameterName:String((i==null?void 0:i.parameterName)??n)}},async invokeDqlArtifact(e,t,n,r,o){var a,d,c,f,p,h;const i=await k("/api/dql/artifacts/execute",{method:"POST",body:JSON.stringify({artifact:e,parameters:t,question:n,blockName:r,executionTarget:o})}),l=es(i==null?void 0:i.artifact);if(!l)throw new Error("DQL artifact execution returned an invalid artifact contract.");return{artifact:l,parameters:l.parameters??[],result:{...Gt(i==null?void 0:i.result),...typeof((a=i==null?void 0:i.result)==null?void 0:a.sql)=="string"?{sql:i.result.sql}:{},...typeof((d=i==null?void 0:i.result)==null?void 0:d.blockName)=="string"?{blockName:i.result.blockName}:{},...typeof((c=i==null?void 0:i.result)==null?void 0:c.blockPath)=="string"?{blockPath:i.result.blockPath}:{},...(f=i==null?void 0:i.result)!=null&&f.chartConfig?{chartConfig:i.result.chartConfig}:{},...Array.isArray((p=i==null?void 0:i.result)==null?void 0:p.parameters)?{parameters:i.result.parameters}:{},...typeof((h=i==null?void 0:i.result)==null?void 0:h.auditId)=="string"?{auditId:i.result.auditId}:{}}}},async composeSemanticBlock(e){return k("/api/block-studio/compose-semantic",{method:"POST",body:JSON.stringify({question:e})})},async saveBlockStudio(e){return k("/api/block-studio/save",{method:"POST",body:JSON.stringify(e)})},async saveAgentBlockDraft(e){return k("/api/block-studio/agent-drafts",{method:"POST",body:JSON.stringify(e)})},async deleteBlockStudio(e){return k(`/api/block-studio/block?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async previewBlockStudioImport(e){return k("/api/block-studio/import/preview",{method:"POST",body:JSON.stringify(e)})},async listBlockStudioImports(){return k("/api/block-studio/imports")},async createBlockStudioImport(e){return k("/api/block-studio/imports",{method:"POST",body:JSON.stringify(e)})},async createDqlGenerationSession(e){return k("/api/block-studio/ai-imports",{method:"POST",body:JSON.stringify(e)})},async getDqlGenerationSession(e){return k(`/api/block-studio/ai-imports/${encodeURIComponent(e)}`)},async getBlockStudioImport(e){return k(`/api/block-studio/imports/${encodeURIComponent(e)}`)},async deleteBlockStudioImport(e){return k(`/api/block-studio/imports/${encodeURIComponent(e)}`,{method:"DELETE"})},async clearBlockStudioImports(){return k("/api/block-studio/imports",{method:"DELETE"})},async updateBlockStudioImportCandidate(e,t,n){return k(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async updateDqlGenerationCandidate(e,t,n){return k(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async matchSqlForBlockReuse(e,t){return k("/api/block-studio/match-sql",{method:"POST",body:JSON.stringify({sql:e,...t??{}})})},async previewDqlGenerationCandidate(e,t){return k(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/preview`,{method:"POST"})},async certifyDqlGenerationCandidate(e,t){return k(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/certify`,{method:"POST"})},async saveSelectedDqlGenerationCandidates(e,t){return k(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify(t)})},async runBlockStudioImportCandidate(e,t){return k(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/run`,{method:"POST"})},async saveBlockStudioImportCandidate(e,t){return k(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/save`,{method:"POST"})},async saveAllBlockStudioImportCandidates(e){return k(`/api/block-studio/imports/${encodeURIComponent(e)}/save-all`,{method:"POST"})},async assistBlockStudioImportCandidate(e,t,n){return k(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/ai-assist`,{method:"POST",body:JSON.stringify({action:n})})},async getSemanticLayerDiagnostics(){return k("/api/semantic-layer/diagnostics")},async reloadSemanticLayer(){return k("/api/semantic-layer/reload",{method:"POST"})},async certifyBlockStudio(e){const t=await fetch(`${Mn}/api/block-studio/certify`,{headers:In({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(e)}),n=await t.json().catch(()=>({ok:!1,error:t.statusText}));if(!t.ok&&t.status!==422)throw new Error(JSON.stringify(n));return n},async saveAsBlock(e){return k("/api/blocks/save-from-cell",{method:"POST",body:JSON.stringify(e)})},async getBlockTemplates(){try{return(await k("/api/blocks/templates")).templates}catch{return[]}},async listBlocks(e){try{return(await k("/api/notebooks")).filter(n=>n.type==="block"&&(!e||n.path.startsWith(`blocks/${e}/`)))}catch{return[]}},async saveNotebook(e,t){return k("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:t})})},async executeQuery(e,t,n,r){var i,l,a;const o=await k("/api/query",{method:"POST",body:JSON.stringify({sql:e,executionContext:n,executionTarget:r}),signal:t});if(n!=null&&n.runId&&typeof((i=o==null?void 0:o.executionContext)==null?void 0:i.runId)=="string"&&o.executionContext.runId!==n.runId)throw new rt({message:"The notebook server returned a result for a different cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:o.executionContext}});return{...Gt(o),executionTarget:((l=o==null?void 0:o.executionTarget)==null?void 0:l.target)==="local"?{target:"local"}:((a=o==null?void 0:o.executionTarget)==null?void 0:a.target)==="connection"?{target:"connection",...typeof o.executionTarget.connectionName=="string"?{connectionName:o.executionTarget.connectionName}:{}}:void 0,compiledSql:typeof(o==null?void 0:o.compiledSql)=="string"?o.compiledSql:void 0,executedSql:typeof(o==null?void 0:o.executedSql)=="string"?o.executedSql:void 0,targetBinding:o!=null&&o.targetBinding&&typeof o.targetBinding=="object"?o.targetBinding:void 0,executionReceipt:o!=null&&o.executionReceipt&&typeof o.executionReceipt=="object"?o.executionReceipt:void 0}},async previewGeneratedSql(e,t){try{const n=await k("/api/ai/sql-draft/preview",{method:"POST",body:JSON.stringify({sql:e}),signal:t});return{ok:!0,result:Gt(n.result)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async executeNotebookCell(e,t,n){var o,i,l,a,d,c;const r=await k("/api/notebook/execute",{method:"POST",body:JSON.stringify({cell:{id:e.id,type:e.type,source:e.content,title:e.name,config:e.chartConfig},executionTarget:e.executionTarget,parameters:((o=e.blockBinding)==null?void 0:o.state)==="bound"?e.blockBinding.parameterValues:e.dqlParameterValues,executionContext:n}),signal:t});if(n!=null&&n.runId&&typeof((i=r==null?void 0:r.executionContext)==null?void 0:i.runId)=="string"&&r.executionContext.runId!==n.runId)throw new rt({message:"The notebook server returned a result for a different semantic cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:r.executionContext}});return{cellType:String((r==null?void 0:r.cellType)??e.type),cellId:typeof((l=r==null?void 0:r.executionContext)==null?void 0:l.cellId)=="string"?r.executionContext.cellId:void 0,runId:typeof((a=r==null?void 0:r.executionContext)==null?void 0:a.runId)=="string"?r.executionContext.runId:void 0,title:typeof(r==null?void 0:r.title)=="string"?r.title:void 0,blockName:typeof(r==null?void 0:r.blockName)=="string"?r.blockName:void 0,blockPath:typeof(r==null?void 0:r.blockPath)=="string"?r.blockPath:void 0,chartConfig:r!=null&&r.chartConfig&&typeof r.chartConfig=="object"?r.chartConfig:void 0,tests:Array.isArray(r==null?void 0:r.tests)?r.tests:void 0,result:r!=null&&r.result?Gt(r.result):null,executionTarget:((d=r==null?void 0:r.executionTarget)==null?void 0:d.target)==="local"?{target:"local"}:((c=r==null?void 0:r.executionTarget)==null?void 0:c.target)==="connection"?{target:"connection",...typeof r.executionTarget.connectionName=="string"?{connectionName:r.executionTarget.connectionName}:{}}:void 0,engine:(r==null?void 0:r.engine)==="native"||(r==null?void 0:r.engine)==="metricflow-cli"||(r==null?void 0:r.engine)==="dbt-cloud"?r.engine:void 0,semanticTrace:r!=null&&r.semanticTrace&&typeof r.semanticTrace=="object"?r.semanticTrace:void 0,compiledSql:typeof(r==null?void 0:r.compiledSql)=="string"?r.compiledSql:void 0,executedSql:typeof(r==null?void 0:r.executedSql)=="string"?r.executedSql:void 0,targetBinding:r!=null&&r.targetBinding&&typeof r.targetBinding=="object"?r.targetBinding:void 0,executionReceipt:r!=null&&r.executionReceipt&&typeof r.executionReceipt=="object"?r.executionReceipt:void 0}},async getDatasets(){return k("/api/datasets")},async importDataset(e){if(e.file){const t=new FormData;t.set("file",e.file,e.file.name);for(const[r,o]of Object.entries(e))r==="file"||o===void 0||t.set(r,Array.isArray(o)?o.join(","):String(o));const n=await fetch(`${Mn}/api/datasets/import`,{method:"POST",headers:In(),body:t});if(!n.ok){const r=await n.text().catch(()=>"");throw ns(n,r)}return n.json()}return k("/api/datasets/import",{method:"POST",body:JSON.stringify(e)})},async refreshDataset(e){return k(`/api/datasets/${encodeURIComponent(e)}/refresh`,{method:"POST"})},async updateDatasetSchema(e,t){return k(`/api/datasets/${encodeURIComponent(e)}/schema`,{method:"POST",body:JSON.stringify({overrides:t})})},async renameDataset(e,t,n){return k(`/api/datasets/${encodeURIComponent(e)}/rename`,{method:"POST",body:JSON.stringify({name:t,alias:n})})},async pinDataset(e,t=!0){return k(`/api/datasets/${encodeURIComponent(e)}/pin`,{method:"POST",body:JSON.stringify({pinned:t})})},async removeDataset(e){await k(`/api/datasets/${encodeURIComponent(e)}`,{method:"DELETE"})},async stageDataset(e){return k("/api/datasets/stage",{method:"POST",body:JSON.stringify(e)})},async listNotebookResearch(e){var o,i,l,a,d,c,f,p,h,y,S,x,b,w,C,E,v,j,O,T;const t=new URLSearchParams;typeof e=="string"?e&&t.set("path",e):e&&(e.path&&t.set("path",e.path),e.sourceCellId&&t.set("sourceCellId",e.sourceCellId),e.domain&&t.set("domain",e.domain),e.owner&&t.set("owner",e.owner),e.intent&&t.set("intent",e.intent),e.search&&t.set("q",e.search),e.status&&t.set("status",e.status),e.reviewStatus&&t.set("reviewStatus",e.reviewStatus),e.promotionAction&&t.set("promotionAction",e.promotionAction),e.readiness&&t.set("readiness",e.readiness),e.age&&t.set("age",e.age),e.nextAction&&t.set("nextAction",e.nextAction),e.activeOnly&&t.set("activeOnly","true"),e.sort&&t.set("sort",e.sort),typeof e.limit=="number"&&t.set("limit",String(e.limit)),typeof e.offset=="number"&&t.set("offset",String(e.offset)));const n=t.toString()?`?${t.toString()}`:"",r=await k(`/api/notebook/research${n}`);return{runs:r.runs.map(jt),total:typeof r.total=="number"?r.total:r.runs.length,domains:Array.isArray(r.domains)?r.domains.map(g=>({domain:typeof g.domain=="string"&&g.domain.trim()?g.domain:"uncategorized",total:typeof g.total=="number"?g.total:0,draftReady:typeof g.draftReady=="number"?g.draftReady:0,certificationReady:typeof g.certificationReady=="number"?g.certificationReady:0,blocked:typeof g.blocked=="number"?g.blocked:0,staleOpen:typeof g.staleOpen=="number"?g.staleOpen:0,expiredOpen:typeof g.expiredOpen=="number"?g.expiredOpen:0,nextAction:wr(g.nextAction),nextActionCount:typeof g.nextActionCount=="number"&&Number.isFinite(g.nextActionCount)?Math.max(0,Math.floor(g.nextActionCount)):void 0})):[],owners:Array.isArray(r.owners)?r.owners.map(g=>({owner:typeof g.owner=="string"&&g.owner.trim()?g.owner:"unassigned",total:typeof g.total=="number"?g.total:0,draftReady:typeof g.draftReady=="number"?g.draftReady:0,certificationReady:typeof g.certificationReady=="number"?g.certificationReady:0,blocked:typeof g.blocked=="number"?g.blocked:0,staleOpen:typeof g.staleOpen=="number"?g.staleOpen:0,expiredOpen:typeof g.expiredOpen=="number"?g.expiredOpen:0,nextAction:wr(g.nextAction),nextActionCount:typeof g.nextActionCount=="number"&&Number.isFinite(g.nextActionCount)?Math.max(0,Math.floor(g.nextActionCount)):void 0})):[],intents:Array.isArray(r.intents)?r.intents.map(g=>({intent:rb(g.intent),total:typeof g.total=="number"?g.total:0,draftReady:typeof g.draftReady=="number"?g.draftReady:0,certificationReady:typeof g.certificationReady=="number"?g.certificationReady:0,blocked:typeof g.blocked=="number"?g.blocked:0,staleOpen:typeof g.staleOpen=="number"?g.staleOpen:0,expiredOpen:typeof g.expiredOpen=="number"?g.expiredOpen:0,nextAction:wr(g.nextAction),nextActionCount:typeof g.nextActionCount=="number"&&Number.isFinite(g.nextActionCount)?Math.max(0,Math.floor(g.nextActionCount)):void 0})):[],notebooks:Array.isArray(r.notebooks)?r.notebooks.map(g=>({path:typeof g.path=="string"&&g.path.trim()?g.path:"notebooks/untitled.dqlnb",title:typeof g.title=="string"&&g.title.trim()?g.title:ob(g.path),total:typeof g.total=="number"?g.total:0,draftReady:typeof g.draftReady=="number"?g.draftReady:0,certificationReady:typeof g.certificationReady=="number"?g.certificationReady:0,blocked:typeof g.blocked=="number"?g.blocked:0,staleOpen:typeof g.staleOpen=="number"?g.staleOpen:0,expiredOpen:typeof g.expiredOpen=="number"?g.expiredOpen:0,nextAction:wr(g.nextAction),nextActionCount:typeof g.nextActionCount=="number"&&Number.isFinite(g.nextActionCount)?Math.max(0,Math.floor(g.nextActionCount)):void 0})):[],counts:{total:typeof((o=r.counts)==null?void 0:o.total)=="number"?r.counts.total:r.runs.length,ready:typeof((i=r.counts)==null?void 0:i.ready)=="number"?r.counts.ready:0,needsReview:typeof((l=r.counts)==null?void 0:l.needsReview)=="number"?r.counts.needsReview:0,dqlDrafts:typeof((a=r.counts)==null?void 0:a.dqlDrafts)=="number"?r.counts.dqlDrafts:0,errors:typeof((d=r.counts)==null?void 0:d.errors)=="number"?r.counts.errors:0,reuseExisting:typeof((c=r.counts)==null?void 0:c.reuseExisting)=="number"?r.counts.reuseExisting:0,extendExisting:typeof((f=r.counts)==null?void 0:f.extendExisting)=="number"?r.counts.extendExisting:0,replacements:typeof((p=r.counts)==null?void 0:p.replacements)=="number"?r.counts.replacements:0,createNew:typeof((h=r.counts)==null?void 0:h.createNew)=="number"?r.counts.createNew:0,draftReady:typeof((y=r.counts)==null?void 0:y.draftReady)=="number"?r.counts.draftReady:0,certificationReady:typeof((S=r.counts)==null?void 0:S.certificationReady)=="number"?r.counts.certificationReady:0,blocked:typeof((x=r.counts)==null?void 0:x.blocked)=="number"?r.counts.blocked:0,staleOpen:typeof((b=r.counts)==null?void 0:b.staleOpen)=="number"?r.counts.staleOpen:0,expiredOpen:typeof((w=r.counts)==null?void 0:w.expiredOpen)=="number"?r.counts.expiredOpen:0,sourceLinked:typeof((C=r.counts)==null?void 0:C.sourceLinked)=="number"?r.counts.sourceLinked:0,nextActions:sb((E=r.counts)==null?void 0:E.nextActions)},groupCounts:{domains:typeof((v=r.groupCounts)==null?void 0:v.domains)=="number"&&Number.isFinite(r.groupCounts.domains)?Math.max(0,Math.floor(r.groupCounts.domains)):Array.isArray(r.domains)?r.domains.length:0,owners:typeof((j=r.groupCounts)==null?void 0:j.owners)=="number"&&Number.isFinite(r.groupCounts.owners)?Math.max(0,Math.floor(r.groupCounts.owners)):Array.isArray(r.owners)?r.owners.length:0,intents:typeof((O=r.groupCounts)==null?void 0:O.intents)=="number"&&Number.isFinite(r.groupCounts.intents)?Math.max(0,Math.floor(r.groupCounts.intents)):Array.isArray(r.intents)?r.intents.length:0,notebooks:typeof((T=r.groupCounts)==null?void 0:T.notebooks)=="number"&&Number.isFinite(r.groupCounts.notebooks)?Math.max(0,Math.floor(r.groupCounts.notebooks)):Array.isArray(r.notebooks)?r.notebooks.length:0},reviewMetrics:tb(r.reviewMetrics),limit:r.limit,offset:typeof r.offset=="number"?r.offset:0}},async getNotebookResearchDiagnostics(){const e=await k("/api/notebook/research/diagnostics");return nb(e)},async createNotebookResearch(e){const t=await k("/api/notebook/research",{method:"POST",body:JSON.stringify(e)});return jt(t.run)},async seedNotebookResearchFromCells(e){const t=await k("/api/notebook/research/seed-cells",{method:"POST",body:JSON.stringify(e)});return{created:Array.isArray(t.created)?t.created.map(jt):[],createdCount:typeof t.createdCount=="number"?t.createdCount:Array.isArray(t.created)?t.created.length:0,skippedCount:typeof t.skippedCount=="number"?t.skippedCount:0,limitApplied:t.limitApplied===!0}},async listNotebookResearchSourceCoverage(e){const t=await k("/api/notebook/research/source-coverage",{method:"POST",body:JSON.stringify({path:e.path,sourceCellIds:e.sourceCellIds,sourceCells:e.sourceCells,limit:e.limit})});return{runs:Array.isArray(t.runs)?t.runs.map(jt):[],requestedCount:typeof t.requestedCount=="number"?t.requestedCount:e.sourceCellIds.length,matchedCount:typeof t.matchedCount=="number"?t.matchedCount:Array.isArray(t.runs)?t.runs.length:0,limitApplied:t.limitApplied===!0}},async previewNotebookResearchContext(e){const t=await k("/api/notebook/research/context-preview",{method:"POST",body:JSON.stringify(e)});return ab(t)},async getNotebookResearch(e){const t=await k(`/api/notebook/research/${encodeURIComponent(e)}`);return jt(t.run)},async updateNotebookResearch(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)});return jt(n.run)},async runNotebookResearch(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t??{})});return jt(n.run)},async checkNotebookResearchReuse(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}/reuse-check`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:jt(n.run),promotion:Jc(n.promotion)??n.promotion}},async promoteNotebookResearchToDql(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}/promote-dql`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:jt(n.run)}},async getSchema(){try{const e=await fetch(`${Mn}/api/schema`,{headers:In()});if(e.ok)return await e.json();const t=await e.json().catch(()=>null);return t!=null&&t.error&&console.warn(`[dql] schema introspection failed: ${t.error}`),(t==null?void 0:t.fallback)??[]}catch(e){return console.warn("[dql] getSchema request failed",e),[]}},async getConnections(){try{return await k("/api/connections")}catch{return{default:"unknown",connections:{}}}},async previewDbtProfiles(e){return k("/api/connections/dbt-profiles/preview",{method:"POST",body:JSON.stringify({path:e})})},async saveConnections(e,t){return k("/api/connections",{method:"PUT",body:JSON.stringify({connections:e,defaultConnectionName:t})})},async previewConnectionMetadataScope(e,t={}){return k(`/api/connections/${encodeURIComponent(e)}/metadata-scope/preview`,{method:"POST",body:JSON.stringify(t)})},async discoverConnectionMetadataScopes(e){return k(`/api/connections/${encodeURIComponent(e)}/metadata-scope/discovery`,{method:"POST"})},async getConnectionMetadataScope(e){return k(`/api/connections/${encodeURIComponent(e)}/metadata-scope`)},async applyConnectionMetadataScope(e,t){return k(`/api/connections/${encodeURIComponent(e)}/metadata-scope`,{method:"PUT",body:JSON.stringify(t)})},async refreshConnectionMetadata(e){return k(`/api/connections/${encodeURIComponent(e)}/metadata-sync`,{method:"POST"})},async installConnector(e){return k("/api/connectors/install",{method:"POST",body:JSON.stringify({driver:e})})},async testConnection(){try{return await k("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(e){return{ok:!1,message:e.message??"Connection failed"}}},async getSemanticRuntimeSettings(){return k("/api/semantic-runtime")},async getMetricFlowInstallerStatus(){return k("/api/semantic-runtime/metricflow/installer")},async installMetricFlow(e){return k("/api/semantic-runtime/metricflow/install",{method:"POST",body:JSON.stringify(e?{adapter:e}:{})})},async testDbtCloudSemanticRuntime(e){try{return await k("/api/semantic-runtime/dbt-cloud/test",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:(t==null?void 0:t.message)??"dbt Cloud Semantic Layer test failed."}}},async applyDbtCloudSemanticRuntime(e){return k("/api/semantic-runtime/dbt-cloud/apply",{method:"POST",body:JSON.stringify(e)})},async setSemanticRuntimePreference(e){return k("/api/semantic-runtime/preference",{method:"POST",body:JSON.stringify({preference:e})})},async getSemanticLayer(){try{return await k("/api/semantic-layer")}catch{return{available:!1,provider:null,metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[],domains:[],tags:[],favorites:[],recentlyUsed:[],lastSyncTime:null}}},async getSemanticTree(){return(await k("/api/semantic-layer/tree")).tree},async getSemanticObject(e){return k(`/api/semantic-layer/object/${encodeURIComponent(e)}`)},async getSetupLaunch(){return k("/api/onboarding/launch")},async acknowledgeSetupLaunch(){return k("/api/onboarding/acknowledge",{method:"POST",body:"{}"})},async getOnboardingStatus(){return k("/api/onboarding/status")},async previewDbtOnboarding(e){return k("/api/onboarding/dbt/preview",{method:"POST",body:JSON.stringify(e)})},async applyDbtOnboarding(e){return k("/api/onboarding/dbt/apply",{method:"POST",body:JSON.stringify({...e,fingerprint:e.expectedFingerprint})})},async refreshDbtOnboarding(e={}){return k("/api/onboarding/refresh",{method:"POST",body:JSON.stringify(e)})},async getOnboardingJob(e){return k(`/api/onboarding/jobs/${encodeURIComponent(e)}`)},async cancelOnboardingJob(e){return k(`/api/onboarding/jobs/${encodeURIComponent(e)}`,{method:"DELETE"})},async discoverOnboardingDomains(e={}){return k("/api/onboarding/domains/discover",{method:"POST",body:JSON.stringify(e)})},async applyOnboardingDomains(e){return k("/api/onboarding/domains/apply",{method:"POST",body:JSON.stringify(e)})},async importSemanticLayer(e){return k("/api/semantic-layer/import",{method:"POST",body:JSON.stringify(e)})},async syncSemanticLayer(){return k("/api/semantic-layer/sync",{method:"POST",body:JSON.stringify({})})},async previewSemanticImport(e){return k("/api/semantic-layer/import-preview",{method:"POST",body:JSON.stringify(e)})},async previewSyncDiff(){return k("/api/semantic-layer/sync-preview",{method:"POST",body:JSON.stringify({})})},async searchSemanticLayer(e){const t=new URLSearchParams;e.query&&t.set("q",e.query),e.domain&&t.set("domain",e.domain),e.tag&&t.set("tag",e.tag),e.type&&t.set("type",e.type);try{return await k(`/api/semantic-layer/search?${t.toString()}`)}catch{return{metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[]}}},async getFavorites(){try{return(await k("/api/user-prefs/favorites")).favorites}catch{return[]}},async toggleFavorite(e){return(await k("/api/user-prefs/favorites",{method:"POST",body:JSON.stringify({name:e})})).favorites},async getRecentlyUsed(){try{return(await k("/api/user-prefs/recent")).recentlyUsed}catch{return[]}},async trackUsage(e){try{return(await k("/api/user-prefs/recent",{method:"POST",body:JSON.stringify({name:e})})).recentlyUsed}catch{return[]}},async getCompatibleDimensions(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));try{return(await k(`/api/semantic-layer/compatible-dims?${t.toString()}`)).dimensions}catch{return[]}},async getCompatibility(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));const n=await k(`/api/semantic-layer/compatible-dims?${t.toString()}`);return{dimensions:n.dimensions??[],engine:n.engine??"native",incompatible:n.incompatible??[],degraded:n.degraded??null}},async composeQuery(e,t,n){try{return await k("/api/semantic-query",{method:"POST",body:JSON.stringify({metrics:e,dimensions:t,timeDimension:n})})}catch(r){return{error:r.message??"Failed to compose query"}}},async previewSemanticBuilder(e){try{return await k("/api/semantic-builder/preview",{method:"POST",body:JSON.stringify(e)})}catch(t){return t instanceof rt?{error:t.message,code:t.code,details:t.details}:{error:t instanceof Error?t.message:"Failed to preview semantic block"}}},async saveSemanticBuilder(e){return k("/api/semantic-builder/save",{method:"POST",body:JSON.stringify(e)})},async createMetric(e){try{return await k("/api/semantic-layer/metric",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t.message??"Failed to create metric"}}},async describeTable(e){const t=new URLSearchParams({relation:e});try{return await k(`/api/describe-table?${t.toString()}`)}catch{return[]}},async fetchLineage(){try{return await k("/api/lineage")}catch{return{nodes:[],edges:[]}}},async searchLineage(e){try{return await k(`/api/lineage/search?q=${encodeURIComponent(e)}`)}catch{return{matches:[]}}},async queryLineage(e){var n;const t=new URLSearchParams;e.focus&&t.set("focus",e.focus),e.search&&t.set("search",e.search),(n=e.types)!=null&&n.length&&t.set("types",e.types.join(",")),e.domain&&t.set("domain",e.domain),e.upstreamDepth!==void 0&&t.set("upstreamDepth",String(e.upstreamDepth)),e.downstreamDepth!==void 0&&t.set("downstreamDepth",String(e.downstreamDepth));try{return await k(`/api/lineage/query?${t.toString()}`)}catch{return{graph:{nodes:[],edges:[]},matches:[]}}},async fetchLineageNode(e){try{return await k(`/api/lineage/node/${encodeURIComponent(e)}`)}catch{return null}},async fetchBusiness360(e){try{return await k(`/api/lineage/business-360/${encodeURIComponent(e)}`)}catch{return null}},async fetchBlockLineage(e){try{return await k(`/api/lineage/block/${encodeURIComponent(e)}`)}catch{return null}},async fetchImpactAnalysis(e){try{return await k(`/api/lineage/impact/${encodeURIComponent(e)}`)}catch{return null}},async fetchLineagePaths(e,t){try{const n=new URLSearchParams;t!=null&&t.maxDepth&&n.set("maxDepth",String(t.maxDepth)),t!=null&&t.maxPaths&&n.set("maxPaths",String(t.maxPaths));const r=n.toString(),o=`/api/lineage/paths/${encodeURIComponent(e)}${r?`?${r}`:""}`;return await k(o)}catch{return null}},async fetchGitStatus(){try{return await k("/api/git/status")}catch{return{inRepo:!1,branch:null,ahead:0,behind:0,changes:[]}}},async fetchGitLog(e=20){try{return await k(`/api/git/log?limit=${e}`)}catch{return{inRepo:!1,commits:[]}}},async fetchRunSnapshot(e){try{return await k(`/api/run-snapshot?path=${encodeURIComponent(e)}`)}catch{return{found:!1,snapshot:null}}},async saveRunSnapshot(e,t){await k("/api/run-snapshot",{method:"PUT",body:JSON.stringify({path:e,snapshot:t})})},async fetchGitDiff(e,t){try{const n=new URLSearchParams;e&&n.set("path",e),t&&n.set("staged","true");const r=n.toString();return await k(`/api/git/diff${r?`?${r}`:""}`)}catch{return{inRepo:!1,diff:"",before:null,after:null,diffReport:null}}},async fetchGitBranches(){try{return await k("/api/git/branches")}catch{return{inRepo:!1,current:null,branches:[]}}},async fetchGitRemote(){try{return await k("/api/git/remote")}catch{return{inRepo:!1,url:null,name:null}}},async fetchGitGovernedContext(){try{return await k("/api/git/governed-context")}catch{return{inRepo:!1,trackingReady:!1,legacyBroadIgnore:!1,domains:Sr(),skills:Sr(),artifacts:Sr(),learning:Sr()}}},async enableGitGovernedContextTracking(){try{return await k("/api/git/governed-context/enable",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitStage(e){try{return await k("/api/git/stage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitUnstage(e){try{return await k("/api/git/unstage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitDiscard(e){try{return await k("/api/git/discard",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCommit(e,t=!1){try{return await k("/api/git/commit",{method:"POST",body:JSON.stringify({message:e,stageAll:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitPush(){try{return await k("/api/git/push",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitPull(){try{return await k("/api/git/pull",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitCreateBranch(e,t=!0){try{return await k("/api/git/branch",{method:"POST",body:JSON.stringify({name:e,checkout:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitCreateReview(e){try{return await k("/api/git/review",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitOpenReview(e){try{return await k("/api/git/review/open",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCheckout(e){try{return await k("/api/git/checkout",{method:"POST",body:JSON.stringify({name:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async listApps(){try{const{apps:e}=await k("/api/apps");return e}catch{return[]}},async listAppsStrict(){const{apps:e}=await k("/api/apps");return e},async recommendAppBlocks(e){try{const{blocks:t}=await k("/api/apps/recommend-blocks",{method:"POST",body:JSON.stringify(e)});return t}catch{return[]}},async createApp(e){return k("/api/apps",{method:"POST",body:JSON.stringify(e)})},async generateApp(e){try{return await k("/api/apps/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async createAppAiBuild(e){try{return await k("/api/apps/ai-builds",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async getAppAiBuild(e){try{const{session:t}=await k(`/api/apps/ai-builds/${encodeURIComponent(e)}`);return t}catch{return null}},async proposeAppAiBuild(e){try{return await k("/api/apps/ai-builds/propose",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async commitAppAiBuild(e,t={}){try{return await k(`/api/apps/ai-builds/${encodeURIComponent(e)}/commit`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getApp(e){try{return await k(`/api/apps/${encodeURIComponent(e)}`)}catch{return null}},async attachAppNotebook(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/notebooks`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppNotebookCandidates(e){try{const{notebooks:t}=await k(`/api/apps/${encodeURIComponent(e)}/notebook-candidates`);return t}catch{return[]}},async createAppNotebook(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/notebooks/create`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async previewAppNotebook(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/notebooks/preview?path=${encodeURIComponent(t)}`)}catch{return null}},async runAppNotebook(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/notebooks/run`,{method:"POST",body:JSON.stringify({path:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppConversations(e){try{const{conversations:t}=await k(`/api/apps/${encodeURIComponent(e)}/conversations`);return t}catch{return[]}},async createAppConversation(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/conversations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppConversation(e,t){try{const{conversation:n}=await k(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`);return n}catch{return null}},async updateAppConversation(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async deleteAppConversation(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"DELETE"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppInvestigations(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{investigations:o}=await k(`/api/apps/${encodeURIComponent(e)}/investigations${r?`?${r}`:""}`);return o}catch{return[]}},async createAppInvestigation(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/investigations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppInvestigation(e,t){try{const{investigation:n}=await k(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}`);return n}catch{return null}},async runAppInvestigation(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async pinAppInvestigation(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/pin`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getDashboard(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`)}catch{return null}},async dashboardFilterOptions(e,t){try{const n=new URLSearchParams({block:e,column:t});return await k(`/api/dashboard/filter-options?${n.toString()}`)}catch{return null}},async getAppEditorCatalog(e,t){try{const n=new URLSearchParams;t!=null&&t.domain&&n.set("domain",t.domain),(t==null?void 0:t.certifiedOnly)===!1&&n.set("certifiedOnly","false");const r=n.toString();return await k(`/api/apps/${encodeURIComponent(e)}/editor/catalog${r?`?${r}`:""}`)}catch{return null}},async createAppDashboard(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async patchDashboardLayout(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/layout`,{method:"PATCH",body:JSON.stringify({layout:n})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async askApp(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/ask`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteApp(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/promote`,{method:"POST",body:JSON.stringify(t??{})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async recommendVisualization(e){try{return await k("/api/visualizations/recommend",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async recommendDashboardTile(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/tiles/recommend`,{method:"POST",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async createAiPin(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/ai-pins`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAiPins(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{pins:o}=await k(`/api/apps/${encodeURIComponent(e)}/ai-pins${r?`?${r}`:""}`);return o}catch{return[]}},async refreshAiPin(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/refresh`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteAiPin(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/promote`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async fetchScopedLineage(e){try{const t=new URLSearchParams;return e.domain&&t.set("domain",e.domain),e.appId&&t.set("appId",e.appId),e.dashboardId&&t.set("dashboardId",e.dashboardId),e.blockId&&t.set("blockId",e.blockId),await k(`/api/lineage/scope?${t.toString()}`)}catch{return null}},async runDashboard(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({variables:n??{}})})}catch{return null}},async getDashboardStory(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/story`,{method:"POST",body:JSON.stringify({runId:n})})}catch{return null}},async saveDashboard(e,t,n){try{return{ok:!!(await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})).ok}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getPersona(){try{const{persona:e}=await k("/api/persona");return e}catch{return null}},async setPersona(e,t){try{const{persona:n}=await k("/api/persona",{method:"POST",body:JSON.stringify({userId:e,appId:t})});return n}catch{return null}},async clearPersona(){try{await k("/api/persona",{method:"DELETE"})}catch{}},async getSkills(){return k("/api/skills")},async getSkillPathSettings(){return k("/api/skills/settings")},async updateSkillPath(e){return k("/api/skills/settings",{method:"PUT",body:JSON.stringify({path:e})})},async getSkillOptions(e=""){const t=e.trim()?`?q=${encodeURIComponent(e.trim())}`:"";return k(`/api/skills/options${t}`)},async createSkill(e){return k("/api/skills",{method:"POST",body:JSON.stringify({skill:e})})},async updateSkill(e,t){return k(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({skill:t})})},async getEmbeddingSettings(){return k("/api/settings/embeddings")},async saveEmbeddingSettings(e){return k("/api/settings/embeddings",{method:"PUT",body:JSON.stringify(e)})},async listEmbeddingModels(e){const t=e?`?endpoint=${encodeURIComponent(e)}`:"";return k(`/api/settings/embeddings/models${t}`)},async installEmbeddingModel(e,t){return k("/api/settings/embeddings/install",{method:"POST",body:JSON.stringify({model:e,endpoint:t})})},async testEmbeddingProvider(){return k("/api/settings/embeddings/test",{method:"POST"})},async reindexEmbeddings(){return k("/api/settings/embeddings/reindex",{method:"POST"})},async deleteSkill(e){return k(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"})},async getDomains(){try{return await k("/api/domains")}catch{return{domains:[]}}},async createDomain(e){return k("/api/domains",{method:"POST",body:JSON.stringify({domain:e})})},async updateDomain(e,t){return k(`/api/domains/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({domain:t})})},async deleteDomain(e){return k(`/api/domains/${encodeURIComponent(e)}`,{method:"DELETE"})},async startContextBootstrap(e={}){return k("/api/context-bootstrap",{method:"POST",body:JSON.stringify(e)})},async getContextBootstrap(e){return k(`/api/context-bootstrap/${encodeURIComponent(e)}`)},async getLatestContextBootstrap(){return(await k("/api/context-bootstrap/latest")).session??null},async saveContextBootstrapSelected(e,t){return k(`/api/context-bootstrap/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify({candidateIds:t})})}},cb={source_table:"#8a8d96",dbt_model:"#4a74c9",dbt_source:"#4a74c9",term:"#0a6b5e",block:"#b26b1f",business_view:"#c14545",metric:"#6b5dd3",dimension:"#0a6b5e",domain:"#7c5cff",chart:"#c14590",notebook:"#2e8b57",dashboard:"#2e8b57",app:"#2e8b57"},db={source_table:"TBL",dbt_model:"DBT",dbt_source:"SRC",term:"TERM",block:"BLK",business_view:"VIEW",metric:"MET",dimension:"DIM",domain:"DOM",chart:"CHT",notebook:"NB",dashboard:"DASH",app:"APP"},Qc={source_table:"Source Table",dbt_model:"dbt Model",dbt_source:"dbt Source",term:"Business Term",block:"DQL Block",business_view:"Business View",metric:"Metric",dimension:"Dimension",domain:"Domain",chart:"Chart",notebook:"Notebook",dashboard:"Dashboard",app:"App"},Kw={reads_from:"#8b949e",feeds_into:"#56d364",defines:"#39c5cf",composes:"#f2cc60",aggregates:"#388bfd",visualizes:"#f778ba",depends_on:"#ff7b72",contains:"#d2a8ff",crosses_domain:"#d2a8ff",certified_by:"#56d364"},Vw={reads_from:"reads from",feeds_into:"feeds into",defines:"defines",composes:"composes into",aggregates:"aggregates into",visualizes:"visualizes",depends_on:"dbt depends on",contains:"contains",crosses_domain:"crosses domain",certified_by:"certified by"},ub={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},Vi={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"},Hi=["source","transform","answer","consumption"],Hw=["term","business_view","block","metric","dimension","domain","source_table","dbt_source","dbt_model","chart","notebook","dashboard","app"],Gw=["source_table","dbt_source","dbt_model"],pb=["term","domain","business_view","metric","dimension","block"];[...pb];function fb(e){if(e.layer)return e.layer;switch(e.type){case"source_table":case"dbt_source":return"source";case"dbt_model":return"transform";case"term":case"block":case"business_view":case"metric":case"dimension":case"domain":return"answer";case"chart":case"notebook":case"dashboard":case"app":return"consumption";default:return"answer"}}function hb(){const{state:e,dispatch:t}=Se(),n=e.inspectorContext;return s.jsxs("aside",{"aria-label":"Inspector",style:{width:320,borderLeft:`1px solid ${le("borderSubtle")}`,background:le("surfaceBase"),color:le("textPrimary"),display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${me[3]}px ${me[4]}px`,borderBottom:`1px solid ${le("borderSubtle")}`},children:[s.jsx("div",{style:{fontSize:ze.sm,fontWeight:ss.semibold},children:n?mb(n):"Inspector"}),s.jsx("button",{onClick:()=>t({type:"SET_INSPECTOR",open:!1}),"aria-label":"Close inspector",style:{background:"transparent",border:"none",color:le("textMuted"),cursor:"pointer",fontSize:ze.md,padding:2,borderRadius:Nt.sm},children:"×"})]}),s.jsx("div",{style:{flex:1,overflow:"auto",padding:me[4]},children:n?s.jsx(gb,{context:n}):s.jsx(vb,{})})]})}function mb(e){switch(e.kind){case"cell":return"Cell";case"lineage-node":return"Lineage node";case"metric":return"Metric"}}function gb({context:e}){return e.kind==="cell"?s.jsx(yb,{cellId:e.cellId}):e.kind==="lineage-node"?s.jsx(xb,{nodeId:e.nodeId}):s.jsx(bb,{name:e.name})}function yb({cellId:e}){const{state:t}=Se(),n=t.cells.find(r=>r.id===e);return n?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:me[3],fontSize:ze.sm},children:[s.jsx(Te,{label:"Type",children:n.type}),s.jsx(Te,{label:"ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:n.id})}),s.jsxs(Te,{label:"Length",children:[n.content.length," chars"]}),n.status&&s.jsx(Te,{label:"Status",children:n.status})]}):s.jsx(zr,{children:"No matching cell in the active notebook."})}function xb({nodeId:e}){const[t,n]=u.useState(null),[r,o]=u.useState(!0);if(u.useEffect(()=>{let a=!1;return o(!0),N.fetchLineageNode(e).then(d=>{a||(n(d),o(!1))}).catch(()=>{a||o(!1)}),()=>{a=!0}},[e]),r)return s.jsx(zr,{children:"Loading node…"});if(!t||!t.node)return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:me[3]},children:[s.jsx(Te,{label:"Node ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:e})}),s.jsx(zr,{children:"No metadata available for this node."})]});const i=t.node,l=i.metadata??{};return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:me[3]},children:[s.jsx(Te,{label:"Name",children:i.name??e}),s.jsx(Te,{label:"Type",children:Qc[i.type]??i.type}),i.domain&&s.jsx(Te,{label:"Domain",children:i.domain}),i.owner&&s.jsx(Te,{label:"Owner",children:i.owner}),i.status&&s.jsx(Te,{label:"Status",children:i.status}),typeof l.termType=="string"&&s.jsx(Te,{label:"Term Type",children:l.termType}),typeof l.description=="string"&&s.jsx(Te,{label:"Description",children:l.description}),Array.isArray(l.identifiers)&&l.identifiers.length>0&&s.jsx(Te,{label:"Identifiers",children:l.identifiers.map(String).join(", ")}),Array.isArray(l.synonyms)&&l.synonyms.length>0&&s.jsx(Te,{label:"Synonyms",children:l.synonyms.map(String).join(", ")}),typeof l.businessOutcome=="string"&&s.jsx(Te,{label:"Business Outcome",children:l.businessOutcome}),i.layer&&s.jsx(Te,{label:"Layer",children:i.layer}),s.jsx(Te,{label:"Upstream",children:t.incoming.length}),s.jsx(Te,{label:"Downstream",children:t.outgoing.length}),(i.path||l.filePath)&&s.jsx(Te,{label:"Path",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)",fontSize:ze.xs},children:i.path??l.filePath})})]})}function bb({name:e}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:me[3]},children:[s.jsx(Te,{label:"Metric",children:e}),s.jsx(zr,{children:"Definition, dimensions, and governance surface will render here."})]})}function Te({label:e,children:t}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[s.jsx("div",{style:{fontSize:ze.xs,color:le("textMuted"),textTransform:"uppercase",letterSpacing:.5,fontWeight:ss.medium},children:e}),s.jsx("div",{style:{fontSize:ze.sm,color:le("textPrimary")},children:t})]})}function zr({children:e}){return s.jsx("div",{style:{fontSize:ze.sm,color:le("textSecondary"),lineHeight:1.5,background:le("surfaceSunken"),border:`1px solid ${le("borderSubtle")}`,borderRadius:Nt.md,padding:me[3]},children:e})}function vb(){return s.jsx("div",{style:{fontSize:ze.sm,color:le("textMuted"),lineHeight:1.5},children:"Select a cell, lineage node, or metric to inspect its details here."})}const Ln={appBg:"--color-bg-primary",sidebarBg:"--color-bg-secondary",activityBarBg:"--color-bg-sunken",headerBg:"--color-bg-toolbar",headerBorder:"--color-border-primary",cellBg:"--color-bg-card",cellBorder:"--color-border-subtle",cellBorderActive:"--color-accent-blue",cellBorderRunning:"--color-status-success",textPrimary:"--color-text-primary",textSecondary:"--color-text-secondary",textMuted:"--color-text-tertiary",editorBg:"--color-bg-surface",editorBorder:"--color-border-subtle",tableBorder:"--color-border-subtle",tableHeaderBg:"--color-bg-secondary",tableRowHover:"--color-bg-hover",accent:"--color-accent-blue",accentHover:"--color-accent-blue",success:"--color-status-success",error:"--color-status-error",warning:"--color-status-warning",btnBg:"--color-bg-tertiary",btnBorder:"--color-border-primary",btnHover:"--color-bg-hover",sidebarItemHover:"--color-bg-hover",sidebarItemActive:"--color-bg-active",scrollbarThumb:"--color-border-secondary",modalBg:"--color-bg-secondary",modalOverlay:"--color-bg-overlay",inputBg:"--color-bg-sunken",inputBorder:"--color-border-subtle",pillBg:"--color-bg-tertiary",font:"--font-ui",fontMono:"--font-mono",fontSerif:"--font-ui"},Gi={appBg:"#fbfaf7",sidebarBg:"#fbfaf7",activityBarBg:"#ffffff",headerBg:"#ffffff",headerBorder:"#e9e6e0",cellBg:"#ffffff",cellBorder:"#e9e6e0",cellBorderActive:"#6b5dd3",cellBorderRunning:"#2e8b57",textPrimary:"#1a1a1a",textSecondary:"#4a4a52",textMuted:"#8a8d96",editorBg:"#fbfaf7",editorBorder:"#e9e6e0",tableBorder:"#f0eee9",tableHeaderBg:"#faf9f7",tableRowHover:"#f3f0ea",accent:"#6b5dd3",accentHover:"#5c4fc2",success:"#2e8b57",error:"#c14545",warning:"#b26b1f",btnBg:"#ffffff",btnBorder:"#e9e6e0",btnHover:"#f3f0ea",sidebarItemHover:"#f3f0ea",sidebarItemActive:"#f3f0fb",scrollbarThumb:"#d9d5cc",modalBg:"#ffffff",modalOverlay:"rgba(26,26,26,0.40)",inputBg:"#fbfaf7",inputBorder:"#e9e6e0",pillBg:"#f3f0ea",font:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace",fontSerif:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"};function Ji(e){if(typeof document>"u")return Gi[e];const t=Ln[e];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||Gi[e]}function Sb(){return new Proxy({},{get(e,t){if(typeof t=="string"&&t in Ln)return Ji(t)},has(e,t){return typeof t=="string"&&t in Ln},ownKeys(){return Object.keys(Ln)},getOwnPropertyDescriptor(e,t){if(!(typeof t!="string"||!(t in Ln)))return{enumerable:!0,configurable:!0,value:Ji(t)}}})}const Vt=Sb(),qe={obsidian:Vt,paper:Vt,white:Vt,dark:Vt,light:Vt,midnight:Vt,arctic:Vt};function at(e,t="0 0 24 24"){return function({size:r=16,strokeWidth:o=1.75,...i}){return s.jsx("svg",{width:r,height:r,viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",...i,children:e})}}const wb=at(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1.5"})]}));at(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V5l8-3z"}),s.jsx("path",{d:"M9 12l2 2 4-4"})]}));const kb=at(s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"5",cy:"12",r:"2"}),s.jsx("circle",{cx:"19",cy:"5",r:"2"}),s.jsx("circle",{cx:"19",cy:"19",r:"2"}),s.jsx("path",{d:"M7 12l10-6M7 12l10 6"})]})),Jw=at(s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),s.jsx("path",{d:"M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5"}),s.jsx("path",{d:"M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6"})]}));at(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h8a8 8 0 010 16H4z"}),s.jsx("path",{d:"M16 20l4 4"})]}));at(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 3v18h18"}),s.jsx("path",{d:"M7 15l4-4 4 4 5-7"})]}));at(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 3v18"})]}));at(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M8 12h8M12 8v8"})]}));const Qw=at(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}),s.jsx("circle",{cx:"18",cy:"17",r:"2"})]}));at(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 5h18l-7 9v5l-4-2v-3L3 5z"})}));at(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h10l6 6v10H4z"}),s.jsx("path",{d:"M14 4v6h6"}),s.jsx("path",{d:"M8 14l3 3 5-5"})]}));at(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M21 12a8 8 0 01-11.5 7.2L4 21l1.8-5.5A8 8 0 1121 12z"})}));const Yc=44,Xc=188,Zc="dql-activitybar-expanded";function jb(){var e;if(typeof window>"u")return!1;try{return((e=window.localStorage)==null?void 0:e.getItem(Zc))==="1"}catch{return!1}}function Cb(e){var t;try{(t=window.localStorage)==null||t.setItem(Zc,e?"1":"0")}catch{}}function Qi({title:e,icon:t,active:n,expanded:r,onClick:o,t:i}){const[l,a]=u.useState(!1),d=s.jsxs("button",{"aria-label":e,onClick:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:r?Xc-12:Yc-8,height:32,display:"flex",alignItems:"center",justifyContent:r?"flex-start":"center",gap:10,padding:r?"0 10px":0,marginLeft:r?6:4,marginRight:r?6:4,background:n?i.accent+"1f":l?i.textPrimary+"0f":"transparent",border:"none",borderRadius:6,cursor:"pointer",color:n?i.accent:l?i.textPrimary:i.textSecondary,transition:"background 0.15s, color 0.15s",fontFamily:i.font,fontSize:13,fontWeight:n?500:400,textAlign:"left",overflow:"hidden",whiteSpace:"nowrap"},children:[s.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:18,height:18},children:t}),r&&s.jsx("span",{style:{flex:1,textOverflow:"ellipsis",overflow:"hidden"},children:e})]});return r?d:s.jsx(wl,{content:e,side:"right",children:d})}function Eb(){const{state:e,dispatch:t}=Se(),n=qe[e.themeMode],[r,o]=u.useState(jb);u.useEffect(()=>{Cb(r)},[r]);function i(d){if(d==="home"||d==="ask"||d==="modeling"){t({type:"SET_MAIN_VIEW",view:d});return}if(d==="lineage"){t({type:"SET_SIDEBAR_PANEL",panel:"lineage"});return}if(d==="connection"||d==="git"||d==="apps"||d==="readiness"||d==="skills"||d==="domains"||d==="settings"){t({type:"SET_SIDEBAR_PANEL",panel:d});return}e.sidebarPanel===d&&e.sidebarOpen?t({type:"TOGGLE_SIDEBAR"}):t({type:"SET_SIDEBAR_PANEL",panel:d})}const l=[{label:"Insights",items:[{key:"apps",title:"Apps",icon:s.jsx(tx,{size:16,strokeWidth:1.75}),active:e.mainView==="apps"},{key:"ask",title:"Ask",icon:s.jsx(Hy,{size:16,strokeWidth:1.75}),active:e.mainView==="ask"}]},{label:"Build",items:[{key:"files",title:"Notebooks",icon:s.jsx(Bs,{size:16,strokeWidth:1.75}),active:e.sidebarPanel==="files"&&e.sidebarOpen},{key:"block_library",title:"Blocks",icon:s.jsx(wb,{size:16}),active:e.sidebarPanel==="block_library"&&e.sidebarOpen},{key:"lineage",title:"Lineage",icon:s.jsx(kb,{size:16}),active:e.mainView==="lineage"||e.mainView==="lineage_detail"}]},{label:"Govern",items:[{key:"domains",title:"Domains",icon:s.jsx(Zo,{size:16,strokeWidth:1.75}),active:e.mainView==="domains"||e.mainView==="modeling"||e.mainView==="skills"},{key:"git",title:"Source control",icon:s.jsx(Cn,{size:16,strokeWidth:1.75}),active:e.mainView==="git"},{key:"settings",title:"Settings",icon:s.jsx(mx,{size:16,strokeWidth:1.75}),active:e.mainView==="settings"||e.mainView==="connection"}]}],a=[{key:"help",title:"Help",icon:s.jsx(ly,{size:16,strokeWidth:1.75}),active:e.mainView==="help",onClick:()=>t({type:"SET_MAIN_VIEW",view:"help"})}];return s.jsxs("div",{style:{width:r?Xc:Yc,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",paddingTop:6,paddingBottom:6,gap:2,userSelect:"none",transition:"width 0.18s ease",overflow:"hidden"},children:[s.jsx("div",{style:{display:"flex",justifyContent:r?"flex-end":"center",paddingLeft:r?6:0,paddingRight:r?6:0,marginBottom:4},children:s.jsx(wl,{content:r?"Collapse":"Expand",side:"right",children:s.jsx("button",{"aria-label":r?"Collapse sidebar rail":"Expand sidebar rail",onClick:()=>o(d=>!d),style:{width:28,height:26,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderRadius:5,cursor:"pointer",color:n.textMuted,padding:0},onMouseEnter:d=>{d.currentTarget.style.color=n.textPrimary,d.currentTarget.style.background=n.textPrimary+"0f"},onMouseLeave:d=>{d.currentTarget.style.color=n.textMuted,d.currentTarget.style.background="transparent"},children:r?s.jsx(ty,{size:14,strokeWidth:2}):s.jsx(ry,{size:14,strokeWidth:2})})})}),l.map((d,c)=>s.jsxs(Ie.Fragment,{children:[c>0?s.jsx("div",{style:{height:1,margin:r?"8px 10px 2px":"8px 12px",background:n.headerBorder}}):null,r?s.jsx("div",{style:{fontSize:10,fontWeight:600,color:n.textMuted,letterSpacing:"0.04em",padding:"4px 12px 2px"},children:d.label}):null,d.items.map(f=>s.jsx(Qi,{title:f.title,icon:f.icon,active:f.active,expanded:r,onClick:()=>i(f.key),t:n},f.key))]},d.label)),s.jsx("div",{style:{flex:1}}),a.map(d=>s.jsx(Qi,{title:d.title,icon:d.icon,active:d.active,expanded:r,onClick:d.onClick,t:n},d.key))]})}const Tb=2e4,Yw="application/dql-semantic-ref",Yi=new Map;let Jn=null;function Ab(e){N.trackUsage(e),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:e}}))}async function Xi(e,t){const n=`${e}:${t.toLowerCase()}`,r=Yi.get(n);if(r&&Date.now()<r.expiresAt)return r.items;const o=new URLSearchParams({kind:e,q:t,limit:"50"}),i=await fetch(`${window.location.origin}/api/editor/completions?${o.toString()}`);if(!i.ok)throw new Error(`Failed to load semantic completions: HTTP ${i.status}`);const l=await i.json(),a=Array.isArray(l.completions)?l.completions:[];return Yi.set(n,{items:a,expiresAt:Date.now()+Tb}),a}function ed(e,t,n){const r=n??e.state.selection.main.from;e.dispatch({changes:{from:r,to:n??e.state.selection.main.to,insert:t},selection:{anchor:r+t.length}}),e.focus()}function Xw(e){Jn=e}function Zw(e){Jn===e&&(Jn=null)}function Rb(e){return Jn?(ed(Jn,e),!0):!1}function e1(e,t,n){const r=n?e.posAtCoords(n)??e.state.selection.main.from:e.state.selection.main.from;ed(e,t,r)}function Zi(e,t,n){return{label:e.name,detail:e.type==="metric"?"@metric":"@dim",type:e.type==="metric"?"function":"variable",info:`${e.label}${e.description?`
|
|
396
|
-
${e.description}`:""}${e.sql?`
|
|
397
|
-
${e.sql}`:""}`,apply(r){const i=r.state.sliceDoc(n,n+1)===")"?e.name:`${e.name})`;r.dispatch({changes:{from:t,to:n,insert:i},selection:{anchor:t+i.length}}),Ab(e.name)}}}function _b(e){return{from:e,options:[{label:"@metric(",detail:"semantic metric",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@metric("},selection:{anchor:r+8}})}},{label:"@dim(",detail:"semantic dimension",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@dim("},selection:{anchor:r+5}})}}]}}const t1=async e=>{const{state:t,pos:n}=e,r=t.sliceDoc(Math.max(0,n-120),n),o=/@metric\(([^)]*)$/i.exec(r);if(o){const a=o[1].trim().toLowerCase(),d=n-o[1].length,c=await Xi("metric",a);return{from:d,options:c.map(f=>Zi(f,d,n)),validFor:/^[\w-]*$/}}const i=/@dim\(([^)]*)$/i.exec(r);if(i){const a=i[1].trim().toLowerCase(),d=n-i[1].length,c=await Xi("dimension",a);return{from:d,options:c.map(f=>Zi(f,d,n)),validFor:/^[\w-]*$/}}const l=/@([md][a-z_]*)?$/i.exec(r);return l?_b(n-l[0].length):(e.explicit,null)};function n1(e){if(!e)return null;try{const t=JSON.parse(e);return(t.type==="metric"||t.type==="dimension")&&t.name&&t.reference?{type:t.type,name:t.name,reference:t.reference}:null}catch{return null}}const Ob=6,$b=999,Db={xs:{height:22,fontSize:10.5,paddingX:7,gap:4,icon:11},sm:{height:26,fontSize:11.5,paddingX:9,gap:5,icon:12},md:{height:32,fontSize:12.5,paddingX:12,gap:6,icon:14},lg:{height:54,fontSize:12.5,paddingX:17,gap:7,icon:15}};function ke(e,t={}){const{variant:n="secondary",size:r="sm",active:o=!1,disabled:i=!1,pill:l=!1}=t,a=Db[r],d=n==="danger"?e.error:n==="success"?e.success:n==="accent"?e.accent:void 0,c={boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:a.gap,height:a.height,padding:`0 ${a.paddingX}px`,borderRadius:l?$b:Ob,fontSize:a.fontSize,fontWeight:n==="primary"?700:600,fontFamily:e.font,lineHeight:1,whiteSpace:"nowrap",cursor:i?"not-allowed":"pointer",opacity:i?.55:1,transition:"background 0.15s, border-color 0.15s, color 0.15s"};return n==="primary"?{...c,background:e.accent,border:`1px solid ${e.accent}`,color:"#ffffff"}:n==="ghost"?{...c,background:o?`${e.accent}14`:"transparent",border:"1px solid transparent",color:o?e.accent:e.textMuted,fontWeight:550}:d?{...c,background:o?`${d}22`:`${d}12`,border:`1px solid ${d}${o?"66":"33"}`,color:d}:{...c,background:o?`${e.accent}14`:e.btnBg,border:`1px solid ${o?e.accent:e.btnBorder}`,color:o?e.accent:e.textSecondary}}const Pb=new Set(["metric","measure","dimension","time_dimension"]);function lo(e){var r;if(typeof((r=e.meta)==null?void 0:r.reference)=="string"&&e.meta.reference.trim())return e.meta.reference;const t=`${e.kind}:`;if(e.id.startsWith(t))return e.id.slice(t.length);const n=e.id.lastIndexOf(":");return n>=0?e.id.slice(n+1):e.id}function rs(e){const t=lo(e);return e.kind==="metric"||e.kind==="measure"?`@metric(${t})`:`@dim(${t})`}function td(e){var r,o;const t=typeof((r=e.meta)==null?void 0:r.qualifiedName)=="string"?e.meta.qualifiedName.trim():"";return t||(typeof((o=e.meta)==null?void 0:o.localName)=="string"?e.meta.localName.trim():"")||lo(e)}function Fs(e,t){return!t||e.label.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||lo(e).toLowerCase().includes(t)||td(e).toLowerCase().includes(t)?!0:(e.children??[]).some(n=>Fs(n,t))}function nd(e){var r;const t=[],n=new Map;for(const o of e){const i=(((r=o.children)==null?void 0:r.length)??0)>0,l=i?`group:${o.label.toLowerCase()}`:`leaf:${rs(o).toLowerCase()}`,a=n.get(l);if(a){i&&a.children&&(a.children=a.children.concat(o.children??[]));continue}const d=o.children?{...o,children:[...o.children]}:o;n.set(l,d),t.push(d)}for(const o of t)o.children&&(o.children=nd(o.children));return t}const Co={metric:{Icon:My,tone:e=>e.accent},measure:{Icon:Sx,tone:e=>e.accent},dimension:{Icon:Ex,tone:e=>e.success},time_dimension:{Icon:dy,tone:e=>e.warning},entity:{Icon:Vg,tone:e=>e.textSecondary},segment:{Icon:Py,tone:e=>e.textMuted},hierarchy:{Icon:Cn,tone:e=>e.textMuted},pre_aggregation:{Icon:Kc,tone:e=>e.textMuted},cube:{Icon:Zo,tone:e=>e.textSecondary},semantic_model:{Icon:Zo,tone:e=>e.textSecondary},saved_query:{Icon:Wg,tone:e=>e.textMuted},provider:{Icon:Un,tone:e=>e.textMuted},domain:{Icon:Un,tone:e=>e.textMuted},group:{Icon:Un,tone:e=>e.textMuted}};function Ib(e){var t;if(e.kind==="group"){const n=typeof((t=e.meta)==null?void 0:t.objectKind)=="string"?e.meta.objectKind:"";return Co[n]??Co.group}return Co[e.kind]}function Mb({tree:e,themeMode:t,search:n="",onInsert:r,selectionMode:o=!1,selected:i=new Set,onToggleSelection:l,canSelect:a=()=>({allowed:!0})}){const d=qe[t],c=n.trim().toLowerCase(),f=nd(e.children??[]).filter(p=>Fs(p,c));return f.length===0?s.jsx("div",{style:{padding:"16px 12px",fontSize:11.5,color:d.textMuted,textAlign:"center"},children:c?"No matches.":"No semantic objects."}):s.jsx(s.Fragment,{children:f.map(p=>s.jsx(rd,{node:p,t:d,q:c,onInsert:r,depth:0,selectionMode:o,selected:i,onToggleSelection:l,canSelect:a},p.id))})}function rd({node:e,t,q:n,onInsert:r,depth:o,selectionMode:i,selected:l,onToggleSelection:a,canSelect:d}){var T;const c=(((T=e.children)==null?void 0:T.length)??0)>0,[f,p]=u.useState(o<1||!!n);u.useEffect(()=>{n&&p(!0)},[n]);const h=Pb.has(e.kind),y=Ib(e),S=y==null?void 0:y.Icon,x=10+o*13,b=e.kind==="metric"||e.kind==="measure"?"metric":e.kind==="dimension"||e.kind==="time_dimension"?"dimension":null,w=lo(e),C=td(e),E=w!==C?` · DQL ${w}`:"",v=b?`${b}:${w}`:"",j=b?d(b,w):{allowed:!1};if(!c)return s.jsx("div",{style:{display:"flex",alignItems:"center",width:"100%",minWidth:0,borderBottom:`1px solid ${t.cellBorder}`},children:s.jsxs("button",{type:"button",onClick:()=>{i&&b&&j.allowed?a==null||a(b,w):!i&&h&&r(rs(e))},disabled:i&&!!b&&!j.allowed,title:i&&b?j.allowed?`Select ${e.label} · dbt ${C}${E}`:j.reason||"Not compatible with the current selection":h?`Insert ${rs(e)} · dbt ${C}${E}`:e.label,style:{display:"flex",alignItems:"center",gap:7,flex:1,minWidth:0,boxSizing:"border-box",padding:`5px 6px 5px ${x+15}px`,border:"none",background:"transparent",cursor:i&&b?j.allowed?"pointer":"not-allowed":h?"pointer":"default",textAlign:"left",fontFamily:t.font,color:j.allowed||!b?t.textPrimary:t.textMuted,opacity:i&&b&&!j.allowed?.55:1},children:[i&&b&&s.jsx("input",{type:"checkbox",readOnly:!0,checked:l.has(v),disabled:!j.allowed,style:{accentColor:t.accent,margin:0,flexShrink:0}}),S&&s.jsx(S,{size:13,color:y.tone(t),style:{flexShrink:0}}),s.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:1,overflow:"hidden"},children:[s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11.5},children:e.label}),C!==e.label?s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:9.5,fontFamily:t.fontMono,color:t.textMuted},children:C}):null]})]})});const O=(e.children??[]).filter(g=>Fs(g,n));return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>p(g=>!g),style:{display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,boxSizing:"border-box",padding:`6px 10px 6px ${x}px`,border:"none",borderBottom:`1px solid ${t.cellBorder}`,background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:t.font,color:t.textPrimary},children:[f?s.jsx(Ns,{size:13,color:t.textMuted,style:{flexShrink:0}}):s.jsx(ao,{size:13,color:t.textMuted,style:{flexShrink:0}}),S&&s.jsx(S,{size:13,color:y.tone(t),style:{flexShrink:0}}),s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:600},children:e.label}),s.jsx("span",{style:{fontSize:10,color:t.textMuted,flexShrink:0},children:e.count??O.length})]}),f&&O.map(g=>s.jsx(rd,{node:g,t,q:n,onInsert:r,depth:o+1,selectionMode:i,selected:l,onToggleSelection:a,canSelect:d},g.id))]})}function bt(e){return(e==null?void 0:e.trim())??""}function nn(e){const t=new Map;for(const r of e){const o=bt(r.id);o&&!t.has(o)&&t.set(o,{...r,id:o})}const n=r=>{const o=[bt(r.name)||r.id],i=new Set([r.id]);let l=bt(r.parent);for(;l&&!i.has(l);){i.add(l);const a=t.get(l);if(!a)break;o.unshift(bt(a.name)||a.id),l=bt(a.parent)}return o.join(" / ")};return[...t.values()].map(r=>({value:r.id,label:n(r)})).sort((r,o)=>r.label.localeCompare(o.label))}function r1(e,t){const n=nn(t),r=bt(e??void 0);return!r||n.some(o=>o.value===r)?n:[{value:r,label:`${r} (missing Domain page)`,disabled:!0},...n]}function sr(e){return new Set(nn(e).map(t=>t.value))}function o1(e,t){const n=bt(void 0).toLowerCase();if(!n)return"";const r=t.find(o=>bt(o.id).toLowerCase()===n||bt(o.name).toLowerCase()===n);return bt(r==null?void 0:r.id)}function Lb(e,t){const n=sr(t),r=e.some(o=>{var i;return!n.has(((i=o.domain)==null?void 0:i.trim())??"")});return[...nn(t).map(o=>o.value),...r?["uncategorized"]:[]]}function Nb(e,t,n="",r=[]){const o=n.trim().toLowerCase(),i=sr(r);return Array.from(new Map(e.map(l=>[l.path,l])).values()).filter(l=>{var d;const a=((d=l.domain)==null?void 0:d.trim())??"";return t==="uncategorized"&&i.has(a)||t&&t!=="uncategorized"&&(!i.has(t)||a!==t)?!1:!o||l.name.toLowerCase().includes(o)||(l.description??"").toLowerCase().includes(o)})}var H;(function(e){e.Program="Program",e.Workbook="Workbook",e.Page="Page",e.Dashboard="Dashboard",e.ChartCall="ChartCall",e.FilterCall="FilterCall",e.VariableDecl="VariableDecl",e.ParamDecl="ParamDecl",e.ImportDecl="ImportDecl",e.UseDecl="UseDecl",e.LayoutBlock="LayoutBlock",e.LayoutRow="LayoutRow",e.Decorator="Decorator",e.SQLQuery="SQLQuery",e.NamedArg="NamedArg",e.StringLiteral="StringLiteral",e.NumberLiteral="NumberLiteral",e.BooleanLiteral="BooleanLiteral",e.ArrayLiteral="ArrayLiteral",e.Identifier="Identifier",e.BinaryExpr="BinaryExpr",e.IntervalExpr="IntervalExpr",e.FunctionCall="FunctionCall",e.TemplateString="TemplateString",e.BlockDecl="BlockDecl",e.DomainDecl="DomainDecl",e.TermDecl="TermDecl",e.BusinessViewDecl="BusinessViewDecl",e.BusinessViewInclude="BusinessViewInclude",e.BlockParams="BlockParams",e.BlockVisualization="BlockVisualization",e.BlockTest="BlockTest",e.Digest="Digest",e.Narrative="Narrative"})(H||(H={}));var fn;(function(e){e.Error="error",e.Warning="warning",e.Info="info"})(fn||(fn={}));class Bb{constructor(){Ee(this,"diagnostics",[])}report(t){this.diagnostics.push(t)}error(t,n,r){this.report({severity:fn.Error,message:t,span:n,hint:r})}warning(t,n,r){this.report({severity:fn.Warning,message:t,span:n,hint:r})}hasErrors(){return this.diagnostics.some(t=>t.severity===fn.Error)}getErrors(){return this.diagnostics.filter(t=>t.severity===fn.Error)}getAll(){return[...this.diagnostics]}clear(){this.diagnostics=[]}format(t){return this.diagnostics.map(n=>Fb(n,t)).join(`
|
|
398
|
-
|
|
399
|
-
`)}}function Fb(e,t){const{severity:n,message:r,span:o,hint:i}=e,a=t.split(`
|
|
400
|
-
`)[o.start.line-1]??"",d=String(o.start.line),c=" ".repeat(d.length),f=o.start.file?`${o.start.file}:`:"";let p=`${n}: ${r}
|
|
401
|
-
`;p+=` --> ${f}${o.start.line}:${o.start.column}
|
|
402
|
-
`,p+=`${c} |
|
|
403
|
-
`,p+=`${d} | ${a}
|
|
404
|
-
`;const h=o.start.column-1,y=Math.max(1,o.start.line===o.end.line?o.end.column-o.start.column:a.length-h);return p+=`${c} | ${" ".repeat(h)}${"^".repeat(y)}`,i&&(p+=`
|
|
405
|
-
${c} = hint: ${i}`),p}class zb extends Error{constructor(n,r){super(n);Ee(this,"diagnostics");this.diagnostics=r,this.name="DQLSyntaxError"}}var m;(function(e){e.StringLiteral="StringLiteral",e.NumberLiteral="NumberLiteral",e.BooleanLiteral="BooleanLiteral",e.Identifier="Identifier",e.DashboardKeyword="DashboardKeyword",e.WorkbookKeyword="WorkbookKeyword",e.PageKeyword="PageKeyword",e.LetKeyword="LetKeyword",e.ParamKeyword="ParamKeyword",e.ChartKeyword="ChartKeyword",e.FilterKeyword="FilterKeyword",e.IntervalKeyword="IntervalKeyword",e.ImportKeyword="ImportKeyword",e.FromKeyword="FromKeyword",e.UseKeyword="UseKeyword",e.LayoutKeyword="LayoutKeyword",e.RowKeyword="RowKeyword",e.BlockKeyword="BlockKeyword",e.TermKeyword="TermKeyword",e.TermsKeyword="TermsKeyword",e.BusinessViewKeyword="BusinessViewKeyword",e.IncludesKeyword="IncludesKeyword",e.DomainKeyword="DomainKeyword",e.TypeKeyword="TypeKeyword",e.DescriptionKeyword="DescriptionKeyword",e.TagsKeyword="TagsKeyword",e.OwnerKeyword="OwnerKeyword",e.QueryKeyword="QueryKeyword",e.VisualizationKeyword="VisualizationKeyword",e.TestsKeyword="TestsKeyword",e.ParamsKeyword="ParamsKeyword",e.AssertKeyword="AssertKeyword",e.VarKeyword="VarKeyword",e.DefaultKeyword="DefaultKeyword",e.MetricKeyword="MetricKeyword",e.MetricsKeyword="MetricsKeyword",e.DimensionsKeyword="DimensionsKeyword",e.DigestKeyword="DigestKeyword",e.NarrativeKeyword="NarrativeKeyword",e.ColonToken="ColonToken",e.TripleQuoteString="TripleQuoteString",e.GreaterThan="GreaterThan",e.LessThan="LessThan",e.GreaterThanOrEqual="GreaterThanOrEqual",e.LessThanOrEqual="LessThanOrEqual",e.DoubleEquals="DoubleEquals",e.NotEquals="NotEquals",e.InKeyword="InKeyword",e.SQLFragment="SQLFragment",e.AtSign="AtSign",e.LeftParen="LeftParen",e.RightParen="RightParen",e.LeftBrace="LeftBrace",e.RightBrace="RightBrace",e.LeftBracket="LeftBracket",e.RightBracket="RightBracket",e.Comma="Comma",e.Dot="Dot",e.Equals="Equals",e.Plus="Plus",e.Minus="Minus",e.Star="Star",e.Comment="Comment",e.Newline="Newline",e.EOF="EOF"})(m||(m={}));const qb={dashboard:m.DashboardKeyword,workbook:m.WorkbookKeyword,page:m.PageKeyword,let:m.LetKeyword,param:m.ParamKeyword,chart:m.ChartKeyword,filter:m.FilterKeyword,true:m.BooleanLiteral,false:m.BooleanLiteral,INTERVAL:m.IntervalKeyword,import:m.ImportKeyword,from:m.FromKeyword,use:m.UseKeyword,layout:m.LayoutKeyword,row:m.RowKeyword,block:m.BlockKeyword,term:m.TermKeyword,terms:m.TermsKeyword,business_view:m.BusinessViewKeyword,includes:m.IncludesKeyword,domain:m.DomainKeyword,type:m.TypeKeyword,description:m.DescriptionKeyword,tags:m.TagsKeyword,owner:m.OwnerKeyword,query:m.QueryKeyword,visualization:m.VisualizationKeyword,tests:m.TestsKeyword,params:m.ParamsKeyword,assert:m.AssertKeyword,var:m.VarKeyword,default:m.DefaultKeyword,IN:m.InKeyword,metric:m.MetricKeyword,metrics:m.MetricsKeyword,dimensions:m.DimensionsKeyword,digest:m.DigestKeyword,narrative:m.NarrativeKeyword};function Ub(e){return qb[e]??m.Identifier}const Eo=new Set(["line","bar","kpi","pie","donut","scatter","area","stacked-area","stacked_area","heatmap","table","metric","stacked-bar","stacked_bar","grouped-bar","grouped_bar","combo","histogram","funnel","treemap","tree-map","sankey","flow","sparkline","spark-line","spark","small_multiples","small-multiples","small_multiple","small-multiple","gauge","waterfall","boxplot","geo","forecast"]),Wb={"grouped-bar":"grouped_bar",grouped_bar:"grouped_bar","stacked-bar":"stacked_bar",stacked_bar:"stacked_bar","stacked-area":"area",stacked_area:"area",donut:"pie",forecast:"line","tree-map":"treemap",flow:"sankey","spark-line":"sparkline",spark:"sparkline","small-multiples":"small_multiples",small_multiple:"small_multiples","small-multiple":"small_multiples"};function Kb(e){return Wb[e]??e}const To=new Set(["dropdown","date_range","text","multi_select","range"]),Vb=new Set(["SELECT","WITH"]);class qr{constructor(t,n){Ee(this,"source");Ee(this,"pos",0);Ee(this,"line",1);Ee(this,"column",1);Ee(this,"file");this.source=t,this.file=n}tokenize(){const t=[];for(;!this.isAtEnd()&&(this.skipWhitespace(),!this.isAtEnd());){const n=this.nextToken();n.type!==m.Comment&&t.push(n)}return t.push(this.makeToken(m.EOF,"",this.location())),t}nextToken(){if(this.skipWhitespace(),this.isAtEnd())return this.makeToken(m.EOF,"",this.location());const t=this.location(),n=this.peek();return n==="/"&&this.peekNext()==="/"?this.readComment(t):n==='"'&&this.peekNext()==='"'&&this.source[this.pos+2]==='"'?this.readTripleQuoteString(t):n==='"'||n==="'"?this.readString(n,t):this.isDigit(n)||n==="-"&&this.isDigit(this.peekNext()??"")?this.readNumber(t):this.isAlpha(n)||n==="_"?this.readIdentifierOrKeyword(t):n===">"&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(m.GreaterThanOrEqual,">=",t)):n==="<"&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(m.LessThanOrEqual,"<=",t)):n==="="&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(m.DoubleEquals,"==",t)):n==="!"&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(m.NotEquals,"!=",t)):this.readPunctuation(t)}static scanSQLBoundary(t,n,r){let o=n,i=r;const l=t.length;for(;o<l;){const d=t[o];if(d==="'"||d==='"'){o=qr.skipStringInSQL(t,o);continue}if(d==="("){i++,o++;continue}if(d===")"){if(i===1)return{sql:t.substring(n,o).trim(),endOffset:o};i--,o++;continue}if(d===","&&i===1){let c=o+1;for(;c<l&&/\s/.test(t[c]);)c++;if(c<l&&/[a-zA-Z_]/.test(t[c])){let f=c;for(;f<l&&/[a-zA-Z0-9_]/.test(t[f]);)f++;let p=f;for(;p<l&&/\s/.test(t[p]);)p++;if(p<l&&t[p]==="="&&(p+1>=l||t[p+1]!=="="))return{sql:t.substring(n,o).trim(),endOffset:o}}}o++}return{sql:t.substring(n,o).trim(),endOffset:o}}static skipStringInSQL(t,n){const r=t[n];for(n++;n<t.length;){if(t[n]==="\\"){n+=2;continue}if(t[n]===r)return n++,n;n++}return n}readComment(t){let n="";for(;!this.isAtEnd()&&this.peek()!==`
|
|
406
|
-
`;)n+=this.advance();return this.makeToken(m.Comment,n,t)}readString(t,n){this.advance();let r="";for(;!this.isAtEnd()&&this.peek()!==t;)if(this.peek()==="\\"){this.advance();const o=this.advance();switch(o){case"n":r+=`
|
|
407
|
-
`;break;case"t":r+=" ";break;case"\\":r+="\\";break;case"'":r+="'";break;case'"':r+='"';break;default:r+=o}}else r+=this.advance();return this.isAtEnd()||this.advance(),this.makeToken(m.StringLiteral,r,n)}readNumber(t){let n="";for(this.peek()==="-"&&(n+=this.advance());!this.isAtEnd()&&this.isDigit(this.peek());)n+=this.advance();if(!this.isAtEnd()&&this.peek()==="."&&this.isDigit(this.peekNext()??""))for(n+=this.advance();!this.isAtEnd()&&this.isDigit(this.peek());)n+=this.advance();return this.makeToken(m.NumberLiteral,n,t)}readIdentifierOrKeyword(t){let n="";for(;!this.isAtEnd()&&(this.isAlphaNumeric(this.peek())||this.peek()==="_");)n+=this.advance();const r=Ub(n);return this.makeToken(r,n,t)}readPunctuation(t){const n=this.advance();switch(n){case"(":return this.makeToken(m.LeftParen,n,t);case")":return this.makeToken(m.RightParen,n,t);case"{":return this.makeToken(m.LeftBrace,n,t);case"}":return this.makeToken(m.RightBrace,n,t);case"[":return this.makeToken(m.LeftBracket,n,t);case"]":return this.makeToken(m.RightBracket,n,t);case",":return this.makeToken(m.Comma,n,t);case".":return this.makeToken(m.Dot,n,t);case"=":return this.makeToken(m.Equals,n,t);case"+":return this.makeToken(m.Plus,n,t);case"-":return this.makeToken(m.Minus,n,t);case"*":return this.makeToken(m.Star,n,t);case"@":return this.makeToken(m.AtSign,n,t);case":":return this.makeToken(m.ColonToken,n,t);case">":return this.makeToken(m.GreaterThan,n,t);case"<":return this.makeToken(m.LessThan,n,t);default:return this.makeToken(m.Identifier,n,t)}}skipWhitespace(){for(;!this.isAtEnd();){const t=this.peek();if(t===" "||t===" "||t==="\r"||t===`
|
|
408
|
-
`)this.advance();else break}}peek(){return this.source[this.pos]}peekNext(){return this.source[this.pos+1]}advance(){const t=this.source[this.pos];return this.pos++,t===`
|
|
409
|
-
`?(this.line++,this.column=1):this.column++,t}isAtEnd(){return this.pos>=this.source.length}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}isAlphaNumeric(t){return this.isAlpha(t)||this.isDigit(t)}readTripleQuoteString(t){this.advance(),this.advance(),this.advance(),!this.isAtEnd()&&this.peek()===`
|
|
410
|
-
`&&this.advance();let n="";for(;!this.isAtEnd();){if(this.peek()==='"'&&this.peekNext()==='"'&&this.source[this.pos+2]==='"')return this.advance(),this.advance(),this.advance(),n=n.replace(/\n\s*$/,""),this.makeToken(m.TripleQuoteString,n,t);n+=this.advance()}return this.makeToken(m.TripleQuoteString,n,t)}location(){return{line:this.line,column:this.column,offset:this.pos,file:this.file}}makeToken(t,n,r){return{type:t,value:n,span:{start:r,end:this.location()}}}}const Hb=new Set(["first_asked","last_asked","proposed_contract_id","proposed_domain","proposed_entity","source_question","source_block","source_dql_kind","source_dql_name","source_dql_path","source_dql_hash","source_dql_time_dimension","source_dql_granularity","followup_kind","context_pack_id","route_intent","time_dimension","granularity","draft_path"]),Gb=new Set(["upstream_refs","requested_filters","requested_dimensions","order_by","source_dql_metrics","source_dql_dimensions","source_dql_filters","source_dql_order_by","validation_warnings"]);function Jb(e){return Hb.has(e)}function Qb(e){return Gb.has(e)}class Yb{constructor(t,n){Ee(this,"tokens");Ee(this,"pos",0);Ee(this,"source");Ee(this,"file");Ee(this,"reporter");this.source=t,this.file=n,this.reporter=new Bb;const r=new qr(t,n);this.tokens=r.tokenize()}parse(){const t=this.currentSpan(),n=[];for(;!this.isAtEnd();){const r=this.pos;try{const o=this.parseStatement();o&&n.push(o)}catch{this.synchronize()}this.pos===r&&!this.isAtEnd()&&this.advance()}if(this.reporter.hasErrors())throw new zb(`Parse errors in ${this.file??"<input>"}`,this.reporter.getErrors());return{kind:H.Program,statements:n,span:this.makeSpan(t,this.currentSpan())}}parseStatement(){const t=this.parseDecoratorList();return this.check(m.WorkbookKeyword)?this.parseWorkbook(t):this.check(m.DashboardKeyword)?this.parseDashboard(t):this.check(m.DigestKeyword)?this.parseDigest(t):this.check(m.ChartKeyword)?this.parseChartCall(t):this.check(m.BlockKeyword)?this.parseBlockDecl(t):this.check(m.DomainKeyword)?this.parseDomainDecl(t):this.check(m.TermKeyword)?this.parseTermDecl(t):this.check(m.BusinessViewKeyword)?this.parseBusinessViewDecl(t):this.check(m.ImportKeyword)?(t.length>0&&this.error("Decorators cannot be applied to import statements."),this.parseImportDecl()):(this.check(m.EOF)||this.error(`Unexpected token '${this.current().value}'. Expected 'dashboard', 'digest', 'workbook', 'chart', 'domain', 'block', 'term', 'business_view', or 'import'.`),null)}parseFilterCall(){const t=this.currentSpan();this.expect(m.FilterKeyword),this.expect(m.Dot);const n=this.expect(m.Identifier);To.has(n.value)||this.reporter.error(`Unknown filter type '${n.value}'. Valid types: ${[...To].join(", ")}`,n.span,`Did you mean one of: ${[...To].join(", ")}?`),this.expect(m.LeftParen);let r;const i=this.current().value.toUpperCase();(i==="SELECT"||i==="WITH")&&(r=this.parseSQLQuery());const l=[];for(;(this.check(m.Comma)||!r&&(this.check(m.Identifier)||this.isKeywordUsableAsArgName(this.current().type)))&&(this.check(m.Comma)&&this.advance(),!this.check(m.RightParen));)l.push(this.parseNamedArg());return this.expect(m.RightParen),{kind:H.FilterCall,filterType:n.value,query:r,args:l,span:this.makeSpan(t,this.previousSpan())}}parseDashboard(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.DashboardKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);const o=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const i=this.parseDecoratorList();if(this.check(m.LetKeyword))i.length>0&&this.error("Decorators cannot be applied to variable declarations."),o.push(this.parseVariableDecl());else if(this.check(m.ParamKeyword))i.length>0&&this.error("Decorators cannot be applied to param declarations."),o.push(this.parseParamDecl());else if(this.check(m.ChartKeyword))o.push(this.parseChartCall(i));else if(this.check(m.FilterKeyword))i.length>0&&this.error("Decorators cannot be applied to filter declarations."),o.push(this.parseFilterCall());else if(this.check(m.UseKeyword))i.length>0&&this.error("Decorators cannot be applied to use declarations."),o.push(this.parseUseDecl());else if(this.check(m.LayoutKeyword))i.length>0&&this.error("Decorators cannot be applied to layout blocks."),o.push(this.parseLayoutBlock());else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside dashboard. Expected 'let', 'param', 'chart', 'filter', 'use', 'layout', or '}'.`),this.advance()}}return this.expect(m.RightBrace),{kind:H.Dashboard,title:r.value,decorators:t,body:o,span:this.makeSpan(n,this.previousSpan())}}parseDigest(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.DigestKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);const o=[];let i;for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const l=this.parseDecoratorList();if(this.check(m.NarrativeKeyword))l.length>0&&this.error("Decorators cannot be applied to narrative blocks."),i&&this.error("A digest can only contain one narrative block."),i=this.parseNarrative();else if(this.check(m.LetKeyword))l.length>0&&this.error("Decorators cannot be applied to variable declarations."),o.push(this.parseVariableDecl());else if(this.check(m.ParamKeyword))l.length>0&&this.error("Decorators cannot be applied to param declarations."),o.push(this.parseParamDecl());else if(this.check(m.ChartKeyword))o.push(this.parseChartCall(l));else if(this.check(m.FilterKeyword))l.length>0&&this.error("Decorators cannot be applied to filter declarations."),o.push(this.parseFilterCall());else if(this.check(m.UseKeyword))l.length>0&&this.error("Decorators cannot be applied to use declarations."),o.push(this.parseUseDecl());else if(this.check(m.LayoutKeyword))l.length>0&&this.error("Decorators cannot be applied to layout blocks."),o.push(this.parseLayoutBlock());else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside digest. Expected 'narrative', 'let', 'param', 'chart', 'filter', 'use', 'layout', or '}'.`),this.advance()}}return this.expect(m.RightBrace),{kind:H.Digest,title:r.value,decorators:t,narrative:i,body:o,span:this.makeSpan(n,this.previousSpan())}}parseNarrative(){const t=this.currentSpan();this.expect(m.NarrativeKeyword),this.expect(m.LeftBrace);const n=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();)n.push(this.parseNamedArg());return this.expect(m.RightBrace),{kind:H.Narrative,properties:n,span:this.makeSpan(t,this.previousSpan())}}parseChartCall(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.ChartKeyword),this.expect(m.Dot);const r=this.currentSpan();let i=this.expect(m.Identifier).value;for(;this.check(m.Minus);)this.advance(),i+=`-${this.expect(m.Identifier).value}`;const l=this.makeSpan(r,this.previousSpan());Eo.has(i)||this.reporter.error(`Unknown chart type '${i}'. Valid types: ${[...Eo].join(", ")}`,l,`Did you mean one of: ${[...Eo].join(", ")}?`);const a=Kb(i);this.expect(m.LeftParen);const d=this.parseSQLQuery(),c=[];for(;this.check(m.Comma)&&(this.advance(),!this.check(m.RightParen));)c.push(this.parseNamedArg());return this.expect(m.RightParen),{kind:H.ChartCall,chartType:a,query:d,args:c,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseSQLQuery(){const t=this.currentSpan(),r=this.current().span.start.offset,{sql:o,endOffset:i}=qr.scanSQLBoundary(this.source,r,1),l=this.extractInterpolations(o,t);for(;!this.isAtEnd()&&this.current().span.start.offset<i;)this.advance();const a=this.makeSpan(t,this.currentSpan());return{kind:H.SQLQuery,rawSQL:o,interpolations:l,span:a}}extractInterpolations(t,n){const r=[],o=/\$\{(\w+)\}|\{(\w+)\}/g;let i;for(;(i=o.exec(t))!==null;){const l=i[1]||i[2];l&&r.push({variableName:l,offsetInSQL:i.index,span:n})}return r}parseNamedArg(){const t=this.currentSpan(),n=this.current();n.type===m.Identifier||this.isKeywordUsableAsArgName(n.type)?this.advance():(this.error(`Expected argument name, got '${n.value}'.`),this.advance()),this.expect(m.Equals);const r=this.parseExpression();return{kind:H.NamedArg,name:n.value,value:r,span:this.makeSpan(t,this.previousSpan())}}isKeywordUsableAsArgName(t){return t===m.ParamKeyword||t===m.FromKeyword||t===m.LayoutKeyword||t===m.RowKeyword||t===m.UseKeyword||t===m.ImportKeyword||t===m.MetricKeyword||t===m.MetricsKeyword||t===m.TermsKeyword||t===m.IncludesKeyword}parseVariableDecl(){const t=this.currentSpan();this.expect(m.LetKeyword);const n=this.expect(m.Identifier);this.expect(m.Equals);const r=this.parseExpression();return{kind:H.VariableDecl,name:n.value,initializer:r,span:this.makeSpan(t,this.previousSpan())}}parseDecoratorList(){const t=[];for(;this.check(m.AtSign);)t.push(this.parseDecorator());return t}parseDecorator(){const t=this.currentSpan();this.expect(m.AtSign);const n=this.expect(m.Identifier),r=[];if(this.check(m.LeftParen)){if(this.advance(),!this.check(m.RightParen))for(r.push(this.parseExpression());this.check(m.Comma);)this.advance(),r.push(this.parseExpression());this.expect(m.RightParen)}return{kind:H.Decorator,name:n.value,arguments:r,span:this.makeSpan(t,this.previousSpan())}}parseExpression(){let t=this.parsePrimary();for(;this.check(m.Plus)||this.check(m.Minus);){const n=this.advance(),r=this.parsePrimary();t={kind:H.BinaryExpr,operator:n.value,left:t,right:r,span:this.makeSpan(t.span,r.span)}}return t}parsePrimary(){const t=this.current();if(this.check(m.StringLiteral))return this.advance(),{kind:H.StringLiteral,value:t.value,span:t.span};if(this.check(m.NumberLiteral))return this.advance(),{kind:H.NumberLiteral,value:Number(t.value),span:t.span};if(this.check(m.BooleanLiteral))return this.advance(),{kind:H.BooleanLiteral,value:t.value==="true",span:t.span};if(this.check(m.LeftBracket))return this.parseArrayLiteral();if(this.check(m.IntervalKeyword)){const n=this.currentSpan();this.advance();const r=this.expect(m.StringLiteral);return{kind:H.IntervalExpr,value:r.value,span:this.makeSpan(n,this.previousSpan())}}if(this.check(m.Identifier)){this.advance();const n=t.value;return this.check(m.LeftParen)?this.parseFunctionCall(n,t.span):{kind:H.Identifier,name:n,span:t.span}}if(this.check(m.Minus)){const n=this.currentSpan();this.advance();const r=this.expect(m.NumberLiteral);return{kind:H.NumberLiteral,value:-Number(r.value),span:this.makeSpan(n,r.span)}}return this.error(`Unexpected token '${t.value}'. Expected an expression.`),this.advance(),{kind:H.Identifier,name:"__error__",span:t.span}}parseArrayLiteral(){const t=this.currentSpan();this.expect(m.LeftBracket);const n=[];if(!this.check(m.RightBracket))for(n.push(this.parseExpression());this.check(m.Comma)&&(this.advance(),!this.check(m.RightBracket));)n.push(this.parseExpression());return this.expect(m.RightBracket),{kind:H.ArrayLiteral,elements:n,span:this.makeSpan(t,this.previousSpan())}}parseFunctionCall(t,n){this.expect(m.LeftParen);const r=[];if(!this.check(m.RightParen))for(r.push(this.parseExpression());this.check(m.Comma);)this.advance(),r.push(this.parseExpression());return this.expect(m.RightParen),{kind:H.FunctionCall,callee:t,arguments:r,span:this.makeSpan(n,this.previousSpan())}}current(){return this.tokens[this.pos]??this.tokens[this.tokens.length-1]}previous(){return this.tokens[this.pos-1]??this.tokens[0]}check(t){return this.current().type===t}advance(){const t=this.current();return this.isAtEnd()||this.pos++,t}skipBalancedBlock(){if(!this.check(m.LeftBrace))return;let t=0;for(;!this.isAtEnd();){if(this.check(m.LeftBrace)){t+=1,this.advance();continue}if(this.check(m.RightBrace)){if(t-=1,this.advance(),t<=0)return;continue}this.advance()}}expect(t){if(this.check(t))return this.advance();const n=this.current();return this.error(`Expected ${t} but found '${n.value}' (${n.type}).`),{type:t,value:"",span:n.span}}expectStringLike(){return this.check(m.StringLiteral)||this.check(m.TripleQuoteString)?this.advance():this.expect(m.StringLiteral)}isAtEnd(){return this.current().type===m.EOF}error(t){this.reporter.error(t,this.currentSpan())}currentSpan(){return this.current().span}previousSpan(){return this.previous().span}makeSpan(t,n){return{start:t.start,end:n.end}}parseDomainDecl(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.DomainKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);let o,i,l,a,d,c,f,p,h,y,S,x,b,w,C,E,v,j,O;for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.OwnerKeyword))this.advance(),this.expect(m.Equals),i=this.expect(m.StringLiteral).value;else if(this.check(m.DescriptionKeyword))this.advance(),this.expect(m.Equals),S=this.expectStringLike().value;else if(this.check(m.TagsKeyword))this.advance(),this.expect(m.Equals),h=this.parseStringArrayValues();else if(this.check(m.Identifier)&&(this.current().value==="id"||this.current().value==="parent"||this.current().value==="businessOwner"||this.current().value==="boundedContext"||this.current().value==="sourceSystems"||this.current().value==="primaryTerms"||this.current().value==="reviewCadence"||this.current().value==="businessOutcome"||this.current().value==="inScope"||this.current().value==="outOfScope"||this.current().value==="dbtGroups"||this.current().value==="dbtPaths"||this.current().value==="dbtTags"||this.current().value==="semanticDomains"||this.current().value==="semanticTags"||this.current().value==="exports")){const T=this.advance();this.expect(m.Equals),T.value==="id"?o=this.expect(m.StringLiteral).value:T.value==="parent"?l=this.expect(m.StringLiteral).value:T.value==="businessOwner"?a=this.expect(m.StringLiteral).value:T.value==="boundedContext"?d=this.expectStringLike().value:T.value==="sourceSystems"?c=this.parseStringArrayValues():T.value==="primaryTerms"?f=this.parseStringArrayValues():T.value==="reviewCadence"?p=this.expect(m.StringLiteral).value:T.value==="businessOutcome"?y=this.expect(m.StringLiteral).value:T.value==="inScope"?x=this.parseStringArrayValues():T.value==="outOfScope"?b=this.parseStringArrayValues():T.value==="dbtGroups"?w=this.parseStringArrayValues():T.value==="dbtPaths"?C=this.parseStringArrayValues():T.value==="dbtTags"?E=this.parseStringArrayValues():T.value==="semanticDomains"?v=this.parseStringArrayValues():T.value==="semanticTags"?j=this.parseStringArrayValues():T.value==="exports"&&(O=this.parseStringArrayValues())}else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside domain. Expected 'id', 'parent', 'owner', 'businessOwner', 'boundedContext', 'sourceSystems', 'primaryTerms', 'reviewCadence', 'tags', 'businessOutcome', 'description', or '}'.`),this.advance()}return this.expect(m.RightBrace),{kind:H.DomainDecl,name:r.value,id:o,parent:l,owner:i,businessOwner:a,boundedContext:d,sourceSystems:c,primaryTerms:f,reviewCadence:p,tags:h,businessOutcome:y,description:S,inScope:x,outOfScope:b,dbtGroups:w,dbtPaths:C,dbtTags:E,semanticDomains:v,semanticTags:j,exports:O,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseTermDecl(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.TermKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);let o,i,l,a,d,c,f,p,h,y,S,x,b,w,C;for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.DomainKeyword))this.advance(),this.expect(m.Equals),o=this.expect(m.StringLiteral).value;else if(this.check(m.TypeKeyword))this.advance(),this.expect(m.Equals),i=this.expect(m.StringLiteral).value;else if(this.check(m.DescriptionKeyword))this.advance(),this.expect(m.Equals),a=this.expectStringLike().value;else if(this.check(m.TagsKeyword))this.advance(),this.expect(m.Equals),d=this.parseStringArrayValues();else if(this.check(m.OwnerKeyword))this.advance(),this.expect(m.Equals),c=this.expect(m.StringLiteral).value;else if(this.check(m.Identifier)&&(this.current().value==="status"||this.current().value==="identifiers"||this.current().value==="synonyms"||this.current().value==="metricRefs"||this.current().value==="businessOutcome"||this.current().value==="businessOwner"||this.current().value==="decisionUse"||this.current().value==="reviewCadence"||this.current().value==="businessRules"||this.current().value==="caveats")){const E=this.advance();this.expect(m.Equals),E.value==="status"?l=this.expect(m.StringLiteral).value:E.value==="identifiers"?f=this.parseStringArrayValues():E.value==="synonyms"?p=this.parseStringArrayValues():E.value==="metricRefs"?h=this.parseStringArrayValues():E.value==="businessOutcome"?y=this.expect(m.StringLiteral).value:E.value==="businessOwner"?S=this.expect(m.StringLiteral).value:E.value==="decisionUse"?x=this.expect(m.StringLiteral).value:E.value==="reviewCadence"?b=this.expect(m.StringLiteral).value:E.value==="businessRules"?w=this.parseStringArrayValues():E.value==="caveats"&&(C=this.parseStringArrayValues())}else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside term. Expected 'domain', 'type', 'status', 'description', 'tags', 'owner', 'identifiers', 'synonyms', 'metricRefs', 'businessOutcome', 'businessOwner', 'decisionUse', 'reviewCadence', 'businessRules', 'caveats', or '}'.`),this.advance()}return this.expect(m.RightBrace),{kind:H.TermDecl,name:r.value,domain:o,termType:i,status:l,description:a,tags:d,owner:c,identifiers:f,synonyms:p,metricRefs:h,businessOutcome:y,businessOwner:S,decisionUse:x,reviewCadence:b,businessRules:w,caveats:C,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseBusinessViewDecl(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.BusinessViewKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);let o,i,l,a,d,c,f,p,h,y,S,x,b=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.DomainKeyword))this.advance(),this.expect(m.Equals),o=this.expect(m.StringLiteral).value;else if(this.check(m.DescriptionKeyword))this.advance(),this.expect(m.Equals),l=this.expectStringLike().value;else if(this.check(m.TagsKeyword))this.advance(),this.expect(m.Equals),a=this.parseStringArrayValues();else if(this.check(m.OwnerKeyword))this.advance(),this.expect(m.Equals),d=this.expect(m.StringLiteral).value;else if(this.check(m.TermsKeyword))this.advance(),this.expect(m.Equals),c=this.parseStringArrayValues();else if(this.check(m.IncludesKeyword))b=this.parseBusinessViewIncludes();else if(this.check(m.Identifier)&&(this.current().value==="status"||this.current().value==="businessOutcome"||this.current().value==="businessOwner"||this.current().value==="decisionUse"||this.current().value==="reviewCadence"||this.current().value==="businessRules"||this.current().value==="caveats")){const w=this.advance();this.expect(m.Equals),w.value==="status"?i=this.expect(m.StringLiteral).value:w.value==="businessOutcome"?f=this.expect(m.StringLiteral).value:w.value==="businessOwner"?p=this.expect(m.StringLiteral).value:w.value==="decisionUse"?h=this.expect(m.StringLiteral).value:w.value==="reviewCadence"?y=this.expect(m.StringLiteral).value:w.value==="businessRules"?S=this.parseStringArrayValues():w.value==="caveats"&&(x=this.parseStringArrayValues())}else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside business_view. Expected 'domain', 'status', 'description', 'tags', 'owner', 'terms', 'businessOutcome', 'businessOwner', 'decisionUse', 'reviewCadence', 'businessRules', 'caveats', 'includes', or '}'.`),this.advance()}return this.expect(m.RightBrace),{kind:H.BusinessViewDecl,name:r.value,domain:o,status:i,description:l,tags:a,owner:d,termRefs:c,businessOutcome:f,businessOwner:p,decisionUse:h,reviewCadence:y,businessRules:S,caveats:x,includes:b,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseBusinessViewIncludes(){this.expect(m.IncludesKeyword),this.expect(m.LeftBrace);const t=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan();if(this.check(m.BlockKeyword)){this.advance();const r=this.expect(m.StringLiteral);t.push({kind:H.BusinessViewInclude,refType:"block",name:r.value,span:this.makeSpan(n,this.previousSpan())})}else if(this.check(m.BusinessViewKeyword)){this.advance();const r=this.expect(m.StringLiteral);t.push({kind:H.BusinessViewInclude,refType:"business_view",name:r.value,span:this.makeSpan(n,this.previousSpan())})}else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside includes. Expected 'block', 'business_view', or '}'.`),this.advance()}}return this.expect(m.RightBrace),t}parseStringArrayValues(){const t=this.parseArrayLiteral();return t.kind!==H.ArrayLiteral?[]:t.elements.filter(n=>n.kind===H.StringLiteral).map(n=>n.value)}parseBlockDecl(t){var kt;const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.BlockKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);let o,i,l,a,d,c,f,p,h,y,S,x,b,w,C,E,v,j,O,T,g,$,_,R,A,M,B,K,G,V,I,D,Y,U,te,Q,F,ee,ce,ue,ie,ge,Oe,$e,Ne,xe,pe,Be,Ue,De,Me,et,gt,lt,tt,_t,qt,Ut,Wt,z,ne,ve,he,de;for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.DomainKeyword))this.advance(),this.expect(m.Equals),o=this.expect(m.StringLiteral).value;else if(this.check(m.TypeKeyword)){this.advance(),this.expect(m.Equals);const J=this.expect(m.StringLiteral).value;J==="semantic"||J==="custom"?i=J:(this.error(`Block type must be "semantic" or "custom", got "${J}". Use type = "semantic" for dbt metric blocks or type = "custom" for SQL blocks.`),i="custom")}else if(this.check(m.MetricKeyword))this.advance(),this.expect(m.Equals),l=this.expect(m.StringLiteral).value;else if(this.check(m.MetricsKeyword)){this.advance(),this.expect(m.Equals);const oe=this.parseArrayLiteral();oe.kind===H.ArrayLiteral&&(a=oe.elements.filter(J=>J.kind===H.StringLiteral).map(J=>J.value))}else if(this.check(m.DimensionsKeyword)){this.advance(),this.expect(m.Equals);const oe=this.parseArrayLiteral();oe.kind===H.ArrayLiteral&&(d=oe.elements.filter(J=>J.kind===H.StringLiteral).map(J=>J.value))}else if(this.check(m.DescriptionKeyword))this.advance(),this.expect(m.Equals),c=this.expectStringLike().value;else if(this.check(m.TagsKeyword)){this.advance(),this.expect(m.Equals);const oe=this.parseArrayLiteral();oe.kind===H.ArrayLiteral&&(f=oe.elements.filter(J=>J.kind===H.StringLiteral).map(J=>J.value))}else if(this.check(m.OwnerKeyword))this.advance(),this.expect(m.Equals),p=this.expect(m.StringLiteral).value;else if(this.check(m.TermsKeyword))this.advance(),this.expect(m.Equals),h=this.parseStringArrayValues();else if(this.check(m.Identifier)&&(this.current().value==="grain"||this.current().value==="pattern"||this.current().value==="entities"||this.current().value==="outputs"||this.current().value==="allowedFilters"||this.current().value==="sourceSystems"||this.current().value==="replacementFor")){const oe=this.advance();this.expect(m.Equals),oe.value==="pattern"?y=this.expect(m.StringLiteral).value:oe.value==="grain"?S=this.expect(m.StringLiteral).value:oe.value==="entities"?x=this.parseStringArrayValues():oe.value==="outputs"?b=this.parseStringArrayValues():oe.value==="allowedFilters"?w=this.parseStringArrayValues():oe.value==="sourceSystems"?v=this.parseStringArrayValues():oe.value==="replacementFor"&&(j=this.parseStringArrayValues())}else if(this.check(m.ParamsKeyword))O=this.parseBlockParams();else if(this.check(m.Identifier)&&this.current().value==="parameterPolicy")C=this.parseBlockParameterPolicy();else if(this.check(m.Identifier)&&this.current().value==="filterBindings")E=this.parseBlockFilterBindings();else if(this.check(m.QueryKeyword))if(this.advance(),this.check(m.LeftBrace))T=this.parseLegacyBlockQuerySection();else if(this.expect(m.Equals),this.check(m.TripleQuoteString)){const oe=this.advance(),J=this.extractInterpolations(oe.value,oe.span);T={kind:H.SQLQuery,rawSQL:oe.value,interpolations:J,span:oe.span}}else T=this.parseSQLQuery();else if(this.check(m.VisualizationKeyword))g=this.parseBlockVisualization();else if(this.check(m.TestsKeyword))$=this.parseBlockTests();else{if(this.check(m.RightBrace))break;if(this.check(m.Identifier)&&this.current().value==="status")this.advance(),this.expect(m.Equals),D=this.expect(m.StringLiteral).value;else if(this.check(m.Identifier)&&this.current().value==="datalex_contract")this.advance(),this.expect(m.Equals),Y=this.expect(m.StringLiteral).value;else if(this.check(m.Identifier)&&(this.current().value==="asked_times"||this.current().value==="limit"||this.current().value==="source_dql_limit")){const oe=this.advance();this.expect(m.Equals);const J=this.expect(m.NumberLiteral);oe.value==="asked_times"?U=Number(J.value):oe.value==="limit"?Ut=Number(J.value):he=Number(J.value)}else if(this.check(m.Identifier)&&Jb(this.current().value)){const oe=this.advance();this.expect(m.Equals);const J=this.expect(m.StringLiteral);switch(oe.value){case"first_asked":te=J.value;break;case"last_asked":Q=J.value;break;case"proposed_contract_id":F=J.value;break;case"proposed_domain":ee=J.value;break;case"proposed_entity":ce=J.value;break;case"source_question":ue=J.value;break;case"source_block":ie=J.value;break;case"source_dql_kind":ge=J.value;break;case"source_dql_name":Oe=J.value;break;case"source_dql_path":$e=J.value;break;case"source_dql_hash":Ne=J.value;break;case"source_dql_time_dimension":xe=J.value;break;case"source_dql_granularity":pe=J.value;break;case"followup_kind":Be=J.value;break;case"context_pack_id":Ue=J.value;break;case"route_intent":De=J.value;break;case"time_dimension":Me=J.value;break;case"granularity":et=J.value;break;case"draft_path":gt=J.value;break}}else if(this.check(m.Identifier)&&Qb(this.current().value)){const oe=this.advance();this.expect(m.Equals);const J=this.parseStringArrayValues();switch(oe.value){case"upstream_refs":lt=J;break;case"requested_filters":tt=J;break;case"requested_dimensions":_t=J;break;case"order_by":qt=J;break;case"source_dql_metrics":Wt=J;break;case"source_dql_dimensions":z=J;break;case"source_dql_filters":ne=J;break;case"source_dql_order_by":ve=J;break;case"validation_warnings":de=J;break}}else if(this.check(m.Identifier)&&(this.current().value==="llmContext"||this.current().value==="invariants"||this.current().value==="examples"||this.current().value==="businessOutcome"||this.current().value==="businessOwner"||this.current().value==="decisionUse"||this.current().value==="reviewCadence"||this.current().value==="businessRules"||this.current().value==="caveats")){const oe=this.advance();if(this.expect(m.Equals),oe.value==="llmContext")_=this.expect(m.StringLiteral).value;else if(oe.value==="invariants"){const J=this.parseArrayLiteral();J.kind===H.ArrayLiteral&&(R=J.elements.filter(Ae=>Ae.kind===H.StringLiteral).map(Ae=>Ae.value))}else if(oe.value==="examples"){this.expect(m.LeftBracket);const J=[];for(;!this.check(m.RightBracket)&&!this.isAtEnd();){this.expect(m.LeftBrace);let Ae,Tn;for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const rn=this.current();if(rn.type!==m.Identifier){this.error(`Expected 'question' or 'sql' in example entry, got '${rn.value}'.`),this.advance();continue}this.advance(),this.expect(m.Equals);const ir=this.expect(m.StringLiteral);rn.value==="question"?Ae=ir.value:rn.value==="sql"&&(Tn=ir.value),this.check(m.Comma)&&this.advance()}this.expect(m.RightBrace),Ae&&J.push(Tn?{question:Ae,sql:Tn}:{question:Ae}),this.check(m.Comma)&&this.advance()}this.expect(m.RightBracket),J.length>0&&(A=J)}else if(oe.value==="businessOutcome")M=this.expect(m.StringLiteral).value;else if(oe.value==="businessOwner")B=this.expect(m.StringLiteral).value;else if(oe.value==="decisionUse")K=this.expect(m.StringLiteral).value;else if(oe.value==="reviewCadence")G=this.expect(m.StringLiteral).value;else if(oe.value==="businessRules"){const J=this.parseArrayLiteral();J.kind===H.ArrayLiteral&&(V=J.elements.filter(Ae=>Ae.kind===H.StringLiteral).map(Ae=>Ae.value))}else if(oe.value==="caveats"){const J=this.parseArrayLiteral();J.kind===H.ArrayLiteral&&(I=J.elements.filter(Ae=>Ae.kind===H.StringLiteral).map(Ae=>Ae.value))}}else{if(this.check(m.Identifier)&&((kt=this.tokens[this.pos+1])==null?void 0:kt.type)===m.LeftBrace){const oe=this.current().value;this.error(`Unexpected nested section '${oe}' inside block. Unknown block sections are skipped during parse recovery.`),this.advance(),this.skipBalancedBlock();continue}this.error(`Unexpected token '${this.current().value}' inside block. Expected 'domain', 'type', 'status', 'datalex_contract', 'metric', 'metrics', 'dimensions', 'description', 'tags', 'owner', 'terms', 'pattern', 'grain', 'entities', 'outputs', 'allowedFilters', 'parameterPolicy', 'filterBindings', 'sourceSystems', 'replacementFor', 'params', 'query', 'visualization', 'tests', 'llmContext', 'invariants', 'examples', 'businessOutcome', 'businessOwner', 'decisionUse', 'reviewCadence', 'businessRules', 'caveats', Tier-2 draft metadata fields, or '}'.`),this.advance()}}return i||(i="custom",this.reporter.warning(`Block "${r.value}" is missing a type declaration. DQL treated it as type = "custom" for backward compatibility.`,r.span)),this.expect(m.RightBrace),{kind:H.BlockDecl,name:r.value,domain:o,blockType:i,metricRef:l,metricsRef:a,dimensionsRef:i==="semantic"?d:void 0,description:c,tags:f,owner:p,termRefs:h,pattern:y,grain:S,entities:x,outputs:b,dimensions:i==="semantic"?void 0:d,allowedFilters:w,parameterPolicy:C,filterBindings:E,sourceSystems:v,replacementFor:j,params:O,query:T,visualization:g,tests:$,decorators:t,llmContext:_,invariants:R,examples:A,businessOutcome:M,businessOwner:B,decisionUse:K,reviewCadence:G,businessRules:V,caveats:I,status:D,datalexContract:Y,askedTimes:U,firstAsked:te,lastAsked:Q,proposedContractId:F,proposedDomain:ee,proposedEntity:ce,sourceQuestion:ue,sourceBlock:ie,sourceDqlKind:ge,sourceDqlName:Oe,sourceDqlPath:$e,sourceDqlHash:Ne,sourceDqlTimeDimension:xe,sourceDqlGranularity:pe,followupKind:Be,contextPackId:Ue,routeIntent:De,timeDimension:Me,granularity:et,draftPath:gt,upstreamRefs:lt,requestedFilters:tt,requestedDimensions:_t,orderBy:qt,limit:Ut,sourceDqlMetrics:Wt,sourceDqlDimensions:z,sourceDqlFilters:ne,sourceDqlOrderBy:ve,sourceDqlLimit:he,validationWarnings:de,span:this.makeSpan(n,this.previousSpan())}}parseLegacyBlockQuerySection(){const t=this.currentSpan();this.expect(m.LeftBrace);let n;for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.Identifier)&&this.current().value==="sql")if(this.advance(),this.expect(m.Equals),this.check(m.TripleQuoteString)){const r=this.advance(),o=this.extractInterpolations(r.value,r.span);n={kind:H.SQLQuery,rawSQL:r.value,interpolations:o,span:r.span}}else n=this.parseSQLQuery();else this.check(m.Identifier)&&Vb.has(this.current().value.toUpperCase())?n=this.parseSQLQuery():(this.error(`Unexpected token '${this.current().value}' inside query section. Expected 'sql' or inline SQL.`),this.advance());return this.expect(m.RightBrace),n||this.reporter.error('Query section must contain sql = """...""" or inline SQL.',this.makeSpan(t,this.previousSpan())),n}parseBlockParams(){var r;const t=this.currentSpan();this.expect(m.ParamsKeyword),this.expect(m.LeftBrace);const n=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const o=this.currentSpan(),i=this.current();if(i.type===m.Identifier||this.isBlockFieldKeyword(i.type))this.advance();else{this.error(`Expected parameter name, got '${i.value}'.`),this.advance();continue}let l;if(this.check(m.ColonToken)){this.advance();let c=this.expect(m.Identifier).value;this.check(m.LeftBracket)&&((r=this.tokens[this.pos+1])==null?void 0:r.type)===m.RightBracket&&(this.advance(),this.advance(),c+="[]");const f=["string","number","boolean","date","string[]","number[]","date[]"];f.includes(c)?l=c:this.error(`Invalid block parameter type '${c}'. Valid types: ${f.join(", ")}`)}let a;this.check(m.Equals)&&(this.advance(),a=this.parseExpression()),n.push({name:i.value,paramType:l,initializer:a,span:this.makeSpan(o,this.previousSpan())})}return this.expect(m.RightBrace),{kind:H.BlockParams,params:n,span:this.makeSpan(t,this.previousSpan())}}parseBlockParameterPolicy(){const t=[];for(this.expect(m.Identifier),this.expect(m.LeftBrace);!this.check(m.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan(),r=this.current();if(r.type===m.Identifier||this.isBlockFieldKeyword(r.type))this.advance();else{this.error(`Expected parameter name inside parameterPolicy, got '${r.value}'.`),this.advance();continue}this.expect(m.Equals);const o=this.expectStringLike();t.push({name:r.value,policy:o.value,span:this.makeSpan(n,this.previousSpan())})}return this.expect(m.RightBrace),t}parseBlockFilterBindings(){const t=[];for(this.expect(m.Identifier),this.expect(m.LeftBrace);!this.check(m.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan(),r=this.current();if(r.type===m.Identifier||this.isBlockFieldKeyword(r.type))this.advance();else{this.error(`Expected business filter name inside filterBindings, got '${r.value}'.`),this.advance();continue}this.expect(m.Equals);const o=this.expectStringLike();t.push({filter:r.value,binding:o.value,span:this.makeSpan(n,this.previousSpan())})}return this.expect(m.RightBrace),t}parseBlockVisualization(){const t=this.currentSpan();this.expect(m.VisualizationKeyword),this.expect(m.LeftBrace);const n=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const r=this.currentSpan(),o=this.current();if(o.type===m.Identifier||this.isBlockFieldKeyword(o.type))this.advance();else{this.error(`Expected property name, got '${o.value}'.`),this.advance();continue}this.expect(m.Equals);const i=this.parseExpression();n.push({kind:H.NamedArg,name:o.value,value:i,span:this.makeSpan(r,this.previousSpan())})}return this.expect(m.RightBrace),{kind:H.BlockVisualization,properties:n,span:this.makeSpan(t,this.previousSpan())}}parseBlockTests(){this.currentSpan(),this.expect(m.TestsKeyword),this.expect(m.LeftBrace);const t=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.AssertKeyword)){const n=this.currentSpan();this.advance();const r=this.current();if(r.type===m.Identifier||this.isBlockFieldKeyword(r.type))this.advance();else{this.error(`Expected field name after 'assert', got '${r.value}'.`),this.advance();continue}let o;if(this.check(m.GreaterThan))this.advance(),o=">";else if(this.check(m.LessThan))this.advance(),o="<";else if(this.check(m.GreaterThanOrEqual))this.advance(),o=">=";else if(this.check(m.LessThanOrEqual))this.advance(),o="<=";else if(this.check(m.DoubleEquals))this.advance(),o="==";else if(this.check(m.NotEquals))this.advance(),o="!=";else if(this.check(m.InKeyword))this.advance(),o="IN";else{this.error(`Expected comparison operator (>, <, >=, <=, ==, !=, IN) after field name, got '${this.current().value}'.`),this.advance();continue}const i=this.parseExpression();t.push({kind:H.BlockTest,field:r.value,operator:o,expected:i,span:this.makeSpan(n,this.previousSpan())})}else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside tests. Expected 'assert' or '}'.`),this.advance()}return this.expect(m.RightBrace),t}isBlockFieldKeyword(t){return t===m.DomainKeyword||t===m.TypeKeyword||t===m.MetricKeyword||t===m.DescriptionKeyword||t===m.TagsKeyword||t===m.OwnerKeyword||t===m.TermsKeyword||t===m.ChartKeyword||t===m.QueryKeyword||t===m.DefaultKeyword||t===m.FromKeyword}parseWorkbook(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(m.WorkbookKeyword);const r=this.expect(m.StringLiteral);this.expect(m.LeftBrace);const o=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.PageKeyword))o.push(this.parsePage());else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside workbook. Expected 'page' or '}'.`),this.advance()}return this.expect(m.RightBrace),{kind:H.Workbook,title:r.value,decorators:t,pages:o,span:this.makeSpan(n,this.previousSpan())}}parsePage(){const t=this.currentSpan();this.expect(m.PageKeyword);const n=this.expect(m.StringLiteral);this.expect(m.LeftBrace);const r=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const o=this.parseDecoratorList();if(this.check(m.LetKeyword))o.length>0&&this.error("Decorators cannot be applied to variable declarations."),r.push(this.parseVariableDecl());else if(this.check(m.ParamKeyword))o.length>0&&this.error("Decorators cannot be applied to param declarations."),r.push(this.parseParamDecl());else if(this.check(m.ChartKeyword))r.push(this.parseChartCall(o));else if(this.check(m.FilterKeyword))o.length>0&&this.error("Decorators cannot be applied to filter declarations."),r.push(this.parseFilterCall());else if(this.check(m.UseKeyword))o.length>0&&this.error("Decorators cannot be applied to use declarations."),r.push(this.parseUseDecl());else if(this.check(m.LayoutKeyword))o.length>0&&this.error("Decorators cannot be applied to layout blocks."),r.push(this.parseLayoutBlock());else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside page. Expected 'let', 'param', 'chart', 'filter', 'use', 'layout', or '}'.`),this.advance()}}return this.expect(m.RightBrace),{kind:H.Page,title:n.value,body:r,span:this.makeSpan(t,this.previousSpan())}}parseParamDecl(){const t=this.currentSpan();this.expect(m.ParamKeyword);const n=this.expect(m.Identifier);let r="string";if(this.check(m.ColonToken)){this.advance();const i=this.expect(m.Identifier),l=["string","number","boolean","date"];l.includes(i.value)?r=i.value:this.reporter.error(`Invalid param type '${i.value}'. Valid types: ${l.join(", ")}`,i.span)}let o;return this.check(m.Equals)&&(this.advance(),o=this.parseExpression()),{kind:H.ParamDecl,name:n.value,paramType:r,defaultValue:o,span:this.makeSpan(t,this.previousSpan())}}parseImportDecl(){const t=this.currentSpan();this.expect(m.ImportKeyword),this.expect(m.LeftBrace);const n=[];if(!this.check(m.RightBrace))for(n.push(this.expect(m.Identifier).value);this.check(m.Comma)&&(this.advance(),!this.check(m.RightBrace));)n.push(this.expect(m.Identifier).value);this.expect(m.RightBrace),this.expect(m.FromKeyword);const r=this.expect(m.StringLiteral);return{kind:H.ImportDecl,names:n,path:r.value,span:this.makeSpan(t,this.previousSpan())}}parseUseDecl(){const t=this.currentSpan();this.expect(m.UseKeyword);let n;return this.check(m.Identifier)||this.check(m.StringLiteral)?n=this.advance():n=this.expect(m.Identifier),{kind:H.UseDecl,name:n.value,span:this.makeSpan(t,this.previousSpan())}}parseLayoutBlock(){const t=this.currentSpan();this.expect(m.LayoutKeyword);let n=12;if(this.check(m.LeftParen)){this.advance();const o=[];if(!this.check(m.RightParen))for(o.push(this.parseNamedArg());this.check(m.Comma)&&(this.advance(),!this.check(m.RightParen));)o.push(this.parseNamedArg());this.expect(m.RightParen);const i=o.find(l=>l.name==="columns");i&&i.value.kind===H.NumberLiteral&&(n=i.value.value)}this.expect(m.LeftBrace);const r=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();)if(this.check(m.RowKeyword))r.push(this.parseLayoutRow());else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside layout. Expected 'row' or '}'.`),this.advance()}return this.expect(m.RightBrace),{kind:H.LayoutBlock,columns:n,rows:r,span:this.makeSpan(t,this.previousSpan())}}parseLayoutRow(){const t=this.currentSpan();this.expect(m.RowKeyword),this.expect(m.LeftBrace);const n=[];for(;!this.check(m.RightBrace)&&!this.isAtEnd();){const r=this.parseDecoratorList();let o;if(this.check(m.ChartKeyword))o=this.parseChartCall(r);else if(this.check(m.FilterKeyword))r.length>0&&this.error("Decorators cannot be applied to filter declarations."),o=this.parseFilterCall();else{if(this.check(m.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside row. Expected 'chart', 'filter', or '}'.`),this.advance();continue}let i;if(this.check(m.Identifier)&&this.current().value==="span"){this.advance();const l=this.expect(m.NumberLiteral);i=Number(l.value)}n.push({node:o,span:i})}return this.expect(m.RightBrace),{kind:H.LayoutRow,items:n,span:this.makeSpan(t,this.previousSpan())}}synchronize(){for(;!this.isAtEnd();){const t=this.current();if(t.type===m.DashboardKeyword||t.type===m.WorkbookKeyword||t.type===m.ChartKeyword||t.type===m.FilterKeyword||t.type===m.ImportKeyword||t.type===m.BlockKeyword||t.type===m.TermKeyword||t.type===m.BusinessViewKeyword||t.type===m.AtSign||t.type===m.RightBrace)return;this.advance()}}}function Xb(e,t){return new Yb(e,t).parse()}function Zb(e,t={}){const n=Xb(e);return ev(n,t)}function ev(e,t={}){const n={indentUnit:t.indent??" "},r=e.statements.map(o=>tv(o,0,n)).join(`
|
|
411
|
-
|
|
412
|
-
`).trimEnd();return t.finalNewline===!1?r:`${r}
|
|
413
|
-
`}function L(e,t){return t.indentUnit.repeat(e)}function tv(e,t,n){switch(e.kind){case H.Dashboard:return nv(e,t,n);case H.ChartCall:return qs(e,t,n);case H.Workbook:return sv(e,t,n);case H.ImportDecl:return av(e,t,n);case H.DomainDecl:return hv(e,t,n);case H.BlockDecl:return fv(e,t,n);case H.TermDecl:return mv(e,t,n);case H.BusinessViewDecl:return gv(e,t,n);case H.Digest:return rv(e,t,n);default:return""}}function nv(e,t,n){const r=[];r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}dashboard ${W(e.title)} {`);for(const o of e.body)r.push(zs(o,t+1,n));return r.push(`${L(t,n)}}`),r.join(`
|
|
414
|
-
`)}function rv(e,t,n){const r=[];r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}digest ${W(e.title)} {`),e.narrative&&r.push(ov(e.narrative,t+1,n));for(const o of e.body)r.push(zs(o,t+1,n));return r.push(`${L(t,n)}}`),r.join(`
|
|
415
|
-
`)}function ov(e,t,n){const r=[];r.push(`${L(t,n)}narrative {`);for(const o of e.properties)r.push(`${L(t+1,n)}${Us(o)}`);return r.push(`${L(t,n)}}`),r.join(`
|
|
416
|
-
`)}function sv(e,t,n){const r=[];r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}workbook ${W(e.title)} {`);for(const o of e.pages)r.push(iv(o,t+1,n));return r.push(`${L(t,n)}}`),r.join(`
|
|
417
|
-
`)}function iv(e,t,n){const r=[];r.push(`${L(t,n)}page ${W(e.title)} {`);for(const o of e.body)r.push(zs(o,t+1,n));return r.push(`${L(t,n)}}`),r.join(`
|
|
418
|
-
`)}function zs(e,t,n){switch(e.kind){case H.VariableDecl:return cv(e,t,n);case H.ParamDecl:return dv(e,t,n);case H.ChartCall:return qs(e,t,n);case H.FilterCall:return od(e,t,n);case H.UseDecl:return lv(e,t,n);case H.LayoutBlock:return uv(e,t,n);default:return""}}function av(e,t,n){return`${L(t,n)}import { ${e.names.join(", ")} } from ${W(e.path)}`}function lv(e,t,n){const r=/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.name);return`${L(t,n)}use ${r?e.name:W(e.name)}`}function cv(e,t,n){return`${L(t,n)}let ${e.name} = ${pt(e.initializer)}`}function dv(e,t,n){const r=`: ${e.paramType}`,o=e.defaultValue?` = ${pt(e.defaultValue)}`:"";return`${L(t,n)}param ${e.name}${r}${o}`}function zt(e,t,n){return e.map(r=>{if(r.arguments.length===0)return`${L(t,n)}@${r.name}`;const o=r.arguments.map(i=>pt(i)).join(", ");return`${L(t,n)}@${r.name}(${o})`})}function qs(e,t,n){return sd(`chart.${e.chartType}`,e.decorators,e.query,e.args,t,n)}function od(e,t,n){return sd(`filter.${e.filterType}`,[],e.query,e.args,t,n)}function sd(e,t,n,r,o,i){const l=[];l.push(...zt(t,o,i)),l.push(`${L(o,i)}${e}(`);const a=[];n&&a.push(id(n,o+1,i));for(const d of r)a.push([`${L(o+1,i)}${Us(d)}`]);for(let d=0;d<a.length;d++){const c=d===a.length-1,f=a[d];for(let p=0;p<f.length;p++){const h=p===f.length-1;l.push(h&&!c?`${f[p]},`:f[p])}}return l.push(`${L(o,i)})`),l.join(`
|
|
419
|
-
`)}function uv(e,t,n){const r=[];r.push(`${L(t,n)}layout(columns = ${e.columns}) {`);for(const o of e.rows)r.push(pv(o,t+1,n));return r.push(`${L(t,n)}}`),r.join(`
|
|
420
|
-
`)}function pv(e,t,n){const r=[];r.push(`${L(t,n)}row {`);for(const o of e.items){const i=o.node.kind===H.ChartCall?qs(o.node,t+1,n):od(o.node,t+1,n);if(o.span==null){r.push(i);continue}const l=i.split(`
|
|
421
|
-
`);l[l.length-1]=`${l[l.length-1]} span ${o.span}`,r.push(l.join(`
|
|
422
|
-
`))}return r.push(`${L(t,n)}}`),r.join(`
|
|
423
|
-
`)}function fv(e,t,n){const r=[];if(r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}block ${W(e.name)} {`),e.domain&&r.push(`${L(t+1,n)}domain = ${W(e.domain)}`),e.blockType&&r.push(`${L(t+1,n)}type = ${W(e.blockType)}`),e.status&&r.push(`${L(t+1,n)}status = ${W(e.status)}`),e.description&&r.push(`${L(t+1,n)}description = ${W(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${L(t+1,n)}tags = [${e.tags.map(W).join(", ")}]`),e.owner&&r.push(`${L(t+1,n)}owner = ${W(e.owner)}`),e.termRefs&&e.termRefs.length>0&&r.push(`${L(t+1,n)}terms = [${e.termRefs.map(W).join(", ")}]`),e.pattern&&r.push(`${L(t+1,n)}pattern = ${W(e.pattern)}`),e.grain&&r.push(`${L(t+1,n)}grain = ${W(e.grain)}`),e.entities&&e.entities.length>0&&r.push(`${L(t+1,n)}entities = [${e.entities.map(W).join(", ")}]`),e.outputs&&e.outputs.length>0&&r.push(`${L(t+1,n)}outputs = [${e.outputs.map(W).join(", ")}]`),e.blockType!=="semantic"&&e.dimensions&&e.dimensions.length>0&&r.push(`${L(t+1,n)}dimensions = [${e.dimensions.map(W).join(", ")}]`),e.allowedFilters&&e.allowedFilters.length>0&&r.push(`${L(t+1,n)}allowedFilters = [${e.allowedFilters.map(W).join(", ")}]`),e.parameterPolicy&&e.parameterPolicy.length>0){r.push(`${L(t+1,n)}parameterPolicy {`);for(const o of e.parameterPolicy)r.push(`${L(t+2,n)}${o.name} = ${W(o.policy)}`);r.push(`${L(t+1,n)}}`)}if(e.filterBindings&&e.filterBindings.length>0){r.push(`${L(t+1,n)}filterBindings {`);for(const o of e.filterBindings)r.push(`${L(t+2,n)}${o.filter} = ${W(o.binding)}`);r.push(`${L(t+1,n)}}`)}if(e.sourceSystems&&e.sourceSystems.length>0&&r.push(`${L(t+1,n)}sourceSystems = [${e.sourceSystems.map(W).join(", ")}]`),e.replacementFor&&e.replacementFor.length>0&&r.push(`${L(t+1,n)}replacementFor = [${e.replacementFor.map(W).join(", ")}]`),e.llmContext&&r.push(`${L(t+1,n)}llmContext = ${W(e.llmContext)}`),e.businessOutcome&&r.push(`${L(t+1,n)}businessOutcome = ${W(e.businessOutcome)}`),e.businessOwner&&r.push(`${L(t+1,n)}businessOwner = ${W(e.businessOwner)}`),e.decisionUse&&r.push(`${L(t+1,n)}decisionUse = ${W(e.decisionUse)}`),e.reviewCadence&&r.push(`${L(t+1,n)}reviewCadence = ${W(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${L(t+1,n)}businessRules = [${e.businessRules.map(W).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${L(t+1,n)}caveats = [${e.caveats.map(W).join(", ")}]`),e.examples&&e.examples.length>0&&r.push(`${L(t+1,n)}examples = [${yv(e.examples)}]`),e.invariants&&e.invariants.length>0&&r.push(`${L(t+1,n)}invariants = [${e.invariants.map(W).join(", ")}]`),e.blockType==="semantic"){const o=e.metricsRef??(e.metricRef!==void 0?[e.metricRef]:[]);r.push(`${L(t+1,n)}metrics = [${o.map(W).join(", ")}]`),r.push(`${L(t+1,n)}dimensions = [${(e.dimensionsRef??[]).map(W).join(", ")}]`),e.timeDimension&&r.push(`${L(t+1,n)}time_dimension = ${W(e.timeDimension)}`),e.granularity&&r.push(`${L(t+1,n)}granularity = ${W(e.granularity)}`),e.requestedFilters&&e.requestedFilters.length>0&&r.push(`${L(t+1,n)}requested_filters = [${e.requestedFilters.map(W).join(", ")}]`),e.orderBy&&e.orderBy.length>0&&r.push(`${L(t+1,n)}order_by = [${e.orderBy.map(W).join(", ")}]`),e.limit!==void 0&&r.push(`${L(t+1,n)}limit = ${e.limit}`)}if(e.params){r.push(`${L(t+1,n)}params {`);for(const o of e.params.params){const i=o.paramType?`: ${o.paramType}`:"",l=o.initializer?` = ${pt(o.initializer)}`:"";r.push(`${L(t+2,n)}${o.name}${i}${l}`)}r.push(`${L(t+1,n)}}`)}if(e.query&&(r.push(`${L(t+1,n)}query = """`),r.push(...id(e.query,t+2,n)),r.push(`${L(t+1,n)}"""`)),e.visualization){r.push(`${L(t+1,n)}visualization {`);for(const o of e.visualization.properties)r.push(`${L(t+2,n)}${Us(o)}`);r.push(`${L(t+1,n)}}`)}if(e.tests&&e.tests.length>0){r.push(`${L(t+1,n)}tests {`);for(const o of e.tests)r.push(`${L(t+2,n)}assert ${o.field} ${o.operator} ${pt(o.expected)}`);r.push(`${L(t+1,n)}}`)}return r.push(`${L(t,n)}}`),r.join(`
|
|
424
|
-
`)}function hv(e,t,n){var o,i,l,a,d,c,f,p;const r=[];return r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}domain ${W(e.name)} {`),e.id&&r.push(`${L(t+1,n)}id = ${W(e.id)}`),e.parent&&r.push(`${L(t+1,n)}parent = ${W(e.parent)}`),e.owner&&r.push(`${L(t+1,n)}owner = ${W(e.owner)}`),e.businessOwner&&r.push(`${L(t+1,n)}businessOwner = ${W(e.businessOwner)}`),e.boundedContext&&r.push(`${L(t+1,n)}boundedContext = ${W(e.boundedContext)}`),e.sourceSystems&&e.sourceSystems.length>0&&r.push(`${L(t+1,n)}sourceSystems = [${e.sourceSystems.map(W).join(", ")}]`),e.primaryTerms&&e.primaryTerms.length>0&&r.push(`${L(t+1,n)}primaryTerms = [${e.primaryTerms.map(W).join(", ")}]`),e.reviewCadence&&r.push(`${L(t+1,n)}reviewCadence = ${W(e.reviewCadence)}`),e.tags&&e.tags.length>0&&r.push(`${L(t+1,n)}tags = [${e.tags.map(W).join(", ")}]`),e.businessOutcome&&r.push(`${L(t+1,n)}businessOutcome = ${W(e.businessOutcome)}`),e.description&&r.push(`${L(t+1,n)}description = ${W(e.description)}`),(o=e.inScope)!=null&&o.length&&r.push(`${L(t+1,n)}inScope = [${e.inScope.map(W).join(", ")}]`),(i=e.outOfScope)!=null&&i.length&&r.push(`${L(t+1,n)}outOfScope = [${e.outOfScope.map(W).join(", ")}]`),(l=e.dbtGroups)!=null&&l.length&&r.push(`${L(t+1,n)}dbtGroups = [${e.dbtGroups.map(W).join(", ")}]`),(a=e.dbtPaths)!=null&&a.length&&r.push(`${L(t+1,n)}dbtPaths = [${e.dbtPaths.map(W).join(", ")}]`),(d=e.dbtTags)!=null&&d.length&&r.push(`${L(t+1,n)}dbtTags = [${e.dbtTags.map(W).join(", ")}]`),(c=e.semanticDomains)!=null&&c.length&&r.push(`${L(t+1,n)}semanticDomains = [${e.semanticDomains.map(W).join(", ")}]`),(f=e.semanticTags)!=null&&f.length&&r.push(`${L(t+1,n)}semanticTags = [${e.semanticTags.map(W).join(", ")}]`),(p=e.exports)!=null&&p.length&&r.push(`${L(t+1,n)}exports = [${e.exports.map(W).join(", ")}]`),r.push(`${L(t,n)}}`),r.join(`
|
|
425
|
-
`)}function mv(e,t,n){const r=[];return r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}term ${W(e.name)} {`),e.domain&&r.push(`${L(t+1,n)}domain = ${W(e.domain)}`),e.termType&&r.push(`${L(t+1,n)}type = ${W(e.termType)}`),e.status&&r.push(`${L(t+1,n)}status = ${W(e.status)}`),e.description&&r.push(`${L(t+1,n)}description = ${W(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${L(t+1,n)}tags = [${e.tags.map(W).join(", ")}]`),e.owner&&r.push(`${L(t+1,n)}owner = ${W(e.owner)}`),e.identifiers&&e.identifiers.length>0&&r.push(`${L(t+1,n)}identifiers = [${e.identifiers.map(W).join(", ")}]`),e.synonyms&&e.synonyms.length>0&&r.push(`${L(t+1,n)}synonyms = [${e.synonyms.map(W).join(", ")}]`),e.businessOutcome&&r.push(`${L(t+1,n)}businessOutcome = ${W(e.businessOutcome)}`),e.businessOwner&&r.push(`${L(t+1,n)}businessOwner = ${W(e.businessOwner)}`),e.decisionUse&&r.push(`${L(t+1,n)}decisionUse = ${W(e.decisionUse)}`),e.reviewCadence&&r.push(`${L(t+1,n)}reviewCadence = ${W(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${L(t+1,n)}businessRules = [${e.businessRules.map(W).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${L(t+1,n)}caveats = [${e.caveats.map(W).join(", ")}]`),r.push(`${L(t,n)}}`),r.join(`
|
|
426
|
-
`)}function gv(e,t,n){const r=[];r.push(...zt(e.decorators,t,n)),r.push(`${L(t,n)}business_view ${W(e.name)} {`),e.domain&&r.push(`${L(t+1,n)}domain = ${W(e.domain)}`),e.status&&r.push(`${L(t+1,n)}status = ${W(e.status)}`),e.description&&r.push(`${L(t+1,n)}description = ${W(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${L(t+1,n)}tags = [${e.tags.map(W).join(", ")}]`),e.owner&&r.push(`${L(t+1,n)}owner = ${W(e.owner)}`),e.termRefs&&e.termRefs.length>0&&r.push(`${L(t+1,n)}terms = [${e.termRefs.map(W).join(", ")}]`),e.businessOutcome&&r.push(`${L(t+1,n)}businessOutcome = ${W(e.businessOutcome)}`),e.businessOwner&&r.push(`${L(t+1,n)}businessOwner = ${W(e.businessOwner)}`),e.decisionUse&&r.push(`${L(t+1,n)}decisionUse = ${W(e.decisionUse)}`),e.reviewCadence&&r.push(`${L(t+1,n)}reviewCadence = ${W(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${L(t+1,n)}businessRules = [${e.businessRules.map(W).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${L(t+1,n)}caveats = [${e.caveats.map(W).join(", ")}]`),r.push(`${L(t+1,n)}includes {`);for(const o of e.includes)r.push(`${L(t+2,n)}${o.refType} ${W(o.name)}`);return r.push(`${L(t+1,n)}}`),r.push(`${L(t,n)}}`),r.join(`
|
|
427
|
-
`)}function id(e,t,n){const r=e.rawSQL.replace(/^\n+|\s+$/g,"");if(!r.trim())return[`${L(t,n)}SELECT 1`];const o=r.split(`
|
|
428
|
-
`).map(d=>d.trimEnd()),i=o.slice(1).filter(d=>d.length>0),l=i.length?i:o.filter(d=>d.length>0),a=l.length?Math.min(...l.map(d=>d.match(/^[ \t]*/)[0].length)):0;return o.map(d=>{if(d.length===0)return"";const c=d.startsWith(" ".repeat(a))||d.startsWith(" ".repeat(a))?d.slice(a):d.trimStart();return`${L(t,n)}${c}`})}function Us(e){return`${e.name} = ${pt(e.value)}`}function yv(e){return e.map(t=>{const n=[`question = ${W(t.question)}`];return t.sql&&n.push(`sql = ${W(t.sql)}`),`{ ${n.join(", ")} }`}).join(", ")}function pt(e){switch(e.kind){case H.StringLiteral:return W(e.value);case H.NumberLiteral:return String(e.value);case H.BooleanLiteral:return e.value?"true":"false";case H.Identifier:return e.name;case H.ArrayLiteral:return`[${e.elements.map(t=>pt(t)).join(", ")}]`;case H.BinaryExpr:return`${pt(e.left)} ${e.operator} ${pt(e.right)}`;case H.IntervalExpr:return`INTERVAL ${W(e.value)}`;case H.FunctionCall:return`${e.callee}(${e.arguments.map(t=>pt(t)).join(", ")})`;case H.TemplateString:return W(e.parts.map(t=>typeof t=="string"?t:`{${pt(t)}}`).join(""));default:return""}}function W(e){return JSON.stringify(e)}function xv(e){var c,f,p,h,y,S,x,b;const t=Rn(e.metrics),n=Rn(e.dimensions??[]),r=Rn(e.requestedFilters??[]),o=Rn((e.orderBy??[]).map(w=>typeof w=="string"?w:`${w.name} ${w.direction}`)),i=vv(e.parameters??[]),l=[`block ${Pe(e.name)} {`,' type = "semantic"',` status = ${Pe(((c=e.status)==null?void 0:c.trim())||"draft")}`],a=bv(e.domain);a&&l.push(` domain = ${Pe(a)}`),(f=e.description)!=null&&f.trim()&&l.push(` description = ${Pe(e.description.trim())}`);const d=Rn(e.tags??[]);if(d.length>0&&l.push(` tags = [${d.map(Pe).join(", ")}]`),(p=e.owner)!=null&&p.trim()&&l.push(` owner = ${Pe(e.owner.trim())}`),l.push(` metrics = [${t.map(Pe).join(", ")}]`),l.push(` dimensions = [${n.map(Pe).join(", ")}]`),(h=e.timeDimension)!=null&&h.name.trim()&&(l.push(` time_dimension = ${Pe(e.timeDimension.name.trim())}`),e.timeDimension.granularity.trim()&&l.push(` granularity = ${Pe(e.timeDimension.granularity.trim())}`)),r.length>0&&l.push(` requested_filters = [${r.map(Pe).join(", ")}]`),o.length>0&&l.push(` order_by = [${o.map(Pe).join(", ")}]`),Sv(e.limit)&&l.push(` limit = ${Math.floor(e.limit)}`),i.length>0){l.push(" params {");for(const E of i){const v=(y=E.type)!=null&&y.trim()?`: ${E.type.trim()}`:"",j=E.default!==void 0?` = ${ad(E.default)}`:"";l.push(` ${E.name}${v}${j}`)}l.push(" }");const w=i.filter(E=>{var v;return(v=E.policy)==null?void 0:v.trim()});if(w.length>0){l.push(" parameterPolicy {");for(const E of w)l.push(` ${E.name} = ${Pe(E.policy.trim())}`);l.push(" }")}const C=i.filter(E=>{var v;return(v=E.binding)==null?void 0:v.trim()});if(C.length>0){l.push(" filterBindings {");for(const E of C)l.push(` ${E.name} = ${Pe(E.binding.trim())}`);l.push(" }")}}return(S=e.visualization)!=null&&S.chart.trim()&&(l.push(" visualization {"),l.push(` chart = ${Pe(e.visualization.chart.trim())}`),(x=e.visualization.x)!=null&&x.trim()&&l.push(` x = ${ea(e.visualization.x.trim())}`),(b=e.visualization.y)!=null&&b.trim()&&l.push(` y = ${ea(e.visualization.y.trim())}`),l.push(" }")),l.push("}"),Zb(`${l.join(`
|
|
429
|
-
`)}
|
|
430
|
-
`)}function bv(e){const t=e==null?void 0:e.trim();if(!(!t||t==="uncategorized"||t==="_uncategorized"))return t}function Rn(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function vv(e){const t=new Map;for(const n of e){const r=n.name.trim();!r||t.has(r)||t.set(r,{...n,name:r})}return[...t.values()]}function Sv(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ad(e){return Array.isArray(e)?`[${e.map(ad).join(", ")}]`:typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":Pe(String(e??""))}function Pe(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function ea(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)?e:Pe(e)}function wv(e,t){const n=Array.from(new Set(e.filter(Boolean))),r=Array.from(new Set(t.filter(Boolean))),i=([...n.slice(0,2),...r.slice(0,1)].join("_by_")||"semantic_query").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)||"semantic_query";return xv({name:i,status:"draft",metrics:n,dimensions:r}).trimEnd()}function kv(e,t){const n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),r=n.match(/^domains\/[^/]+\/blocks\/(.+)$/);if(r)return r[1];const o=`blocks/${t.replace(/^\/+|\/+$/g,"")}/`;return n.startsWith(o)?n.slice(o.length):n.startsWith("blocks/")?n.slice(7):n}function jv(e,t){var o;const n={path:"",folders:new Map,blocks:[]};for(const i of e){const l=((o=i.domain)==null?void 0:o.trim())||"uncategorized",d=kv(i.path,t||l).split("/").filter(Boolean),c=t?d.slice(0,-1):[l,...d.slice(0,-1)];let f=n;for(const p of c){const h=[f.path,p].filter(Boolean).join("/");let y=f.folders.get(p);y||(y={name:p,path:h,folders:new Map,blocks:[]},f.folders.set(p,y)),f=y}f.blocks.push(i)}const r=i=>[...Array.from(i.folders.values()).sort((l,a)=>l.name.localeCompare(a.name)).map(l=>({kind:"folder",name:l.name,path:l.path,children:r(l)})),...i.blocks.sort((l,a)=>l.name.localeCompare(a.name)).map(l=>({kind:"block",block:l}))];return r(n)}function Cv(e,t){const n={path:"",folders:new Map,files:[]};for(const o of e){const i=Ev(o,t);let l=n;for(const a of i){const d=[l.path,a].filter(Boolean).join("/");let c=l.folders.get(a);c||(c={name:a,path:d,folders:new Map,files:[]},l.folders.set(a,c)),l=c}l.files.push(o)}const r=o=>[...Array.from(o.folders.values()).sort((i,l)=>i.name.localeCompare(l.name)).map(i=>({kind:"folder",name:i.name,path:i.path,children:r(i)})),...o.files.sort((i,l)=>i.name.localeCompare(l.name)).map(i=>({kind:"file",file:i}))];return r(n)}function Ev(e,t){const n=e.path.replace(/\\/g,"/").split("/").filter(Boolean);if(n[0]==="domains"){const i=["notebooks","workbooks"],l=n.findIndex((a,d)=>d>0&&i.includes(a));if(l>0)return["Domains",...n.slice(1,l),...n.slice(l+1,-1)]}const r=n.findIndex(i=>i===t||i==="workbooks"||t==="business-views"),o=r>=0?n.slice(r+1,-1):n.slice(0,-1);return e.ownerDomain?["Domains",...e.ownerDomain.split(/[./]/).map(l=>l.trim()).filter(Boolean),...o]:["Project",...o]}function ld({id:e,ariaLabel:t,value:n,options:r,onChange:o,summary:i,t:l}){return s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${l.headerBorder}`,display:"grid",gap:5},children:[s.jsx("label",{htmlFor:e,style:{color:l.textMuted,fontSize:9,fontWeight:750,letterSpacing:".06em",textTransform:"uppercase"},children:"Domain"}),s.jsxs("select",{id:e,"aria-label":t,value:n,onChange:a=>o(a.target.value),style:{width:"100%",background:l.inputBg,border:`1px solid ${l.inputBorder}`,borderRadius:6,color:l.textPrimary,fontFamily:l.font,fontSize:12,padding:"7px 8px"},children:[s.jsx("option",{value:"",children:"All domains"}),r.map(a=>{const d=typeof a=="string"?{value:a,label:a}:a;return s.jsx("option",{value:d.value,children:d.label??d.value},d.value)})]}),i!==void 0?s.jsx("span",{style:{color:l.textMuted,fontSize:10},children:i}):null]})}function Tv(e,t){const n=sr(t),r=e.some(o=>o.type!=="notebook"?!1:![o.ownerDomain,...o.usesDomains??[]].map(l=>l==null?void 0:l.trim()).filter(l=>!!l).some(l=>n.has(l)));return[...nn(t).map(o=>o.value),...r?["uncategorized"]:[]]}function ta(e,t,n="",r=[]){const o=t.trim().toLowerCase(),i=sr(r);return Array.from(new Map(e.filter(l=>l.type==="notebook").map(l=>[l.path,l])).values()).filter(l=>{var c,f;const a=[l.ownerDomain,...l.usesDomains??[]].map(p=>p==null?void 0:p.trim()).filter(p=>!!p);return(!n||(n==="uncategorized"?!a.some(p=>i.has(p)):i.has(n)&&a.includes(n)))&&(!o||l.name.toLowerCase().includes(o)||l.path.toLowerCase().includes(o)||((c=l.ownerDomain)==null?void 0:c.toLowerCase().includes(o))||((f=l.usesDomains)==null?void 0:f.some(p=>p.toLowerCase().includes(o))))}).sort((l,a)=>l.name.localeCompare(a.name))}const Ao=25;function na(e){var t;return!!((t=e.relation)!=null&&t.trim())}function ra(e){return{name:e.relation,path:e.relation,columns:[],source:"database",objectType:e.resourceType==="source"?"dbt_source":"dbt_model",dbtUniqueId:e.uniqueId,dbtResourceType:e.resourceType,dbtSourcePath:e.sourcePath,governance:e.binding?{domain:e.binding.domain,owner:e.binding.owner,status:$v(e.binding.status)}:void 0}}function Av(e,t){const n=new Map(e.map(r=>[r.dbtUniqueId,r]));for(const r of t){const o=n.get(r.dbtUniqueId);n.set(r.dbtUniqueId,o?{...o,...r,columns:r.columns.length>0?r.columns:o.columns,expanded:o.expanded}:r)}return Array.from(n.values())}function Rv(e,t){const n=new Map(t.map(i=>[i.name.toLowerCase(),i])),r=e.columns.map(i=>{var l;return{name:i.name,type:i.type??((l=n.get(i.name.toLowerCase()))==null?void 0:l.type)??""}}),o=new Set(r.map(i=>i.name.toLowerCase()));for(const i of t)o.has(i.name.toLowerCase())||r.push(i);return r}function _v(e){return e.split(".").filter(Boolean).at(-1)??e}function Ov(e){const t=e.split(".").filter(Boolean);return t.length>1?t.slice(0,-1).join("."):""}function $v(e){if(e==="draft"||e==="review"||e==="certified"||e==="deprecated"||e==="pending_recertification")return e}function Dv({t:e,search:t,onInsert:n}){const{dispatch:r}=Se(),[o,i]=u.useState([]),[l,a]=u.useState(0),[d,c]=u.useState(null),[f,p]=u.useState(!0),[h,y]=u.useState(!1),[S,x]=u.useState(null),[b,w]=u.useState(new Set),[C,E]=u.useState(new Set),[v,j]=u.useState(new Set),[O,T]=u.useState({}),g=u.useRef(0),$=t.trim();u.useEffect(()=>{const A=++g.current,M=window.setTimeout(()=>{p(!0),x(null),N.getDbtModelInventory({q:$,limit:Ao,physicalOnly:!0}).then(B=>{if(A!==g.current)return;const K=B.items.filter(na).map(ra);i(K),a(B.total),c(B.nextCursor),w(new Set),E(new Set),T({}),r({type:"MERGE_SCHEMA_TABLES",tables:K})}).catch(B=>{A===g.current&&(i([]),a(0),c(null),x(B instanceof Error?B:new Error(String(B))))}).finally(()=>{A===g.current&&p(!1)})},180);return()=>window.clearTimeout(M)},[r,$]);const _=async()=>{if(d===null||h)return;const A=g.current;y(!0);try{const M=await N.getDbtModelInventory({q:$,cursor:d,limit:Ao,physicalOnly:!0});if(A!==g.current)return;const B=M.items.filter(na).map(ra);i(K=>Av(K,B)),a(M.total),c(M.nextCursor),r({type:"MERGE_SCHEMA_TABLES",tables:B})}catch(M){A===g.current&&x(M instanceof Error?M:new Error(String(M)))}finally{A===g.current&&y(!1)}},R=async A=>{const M=!b.has(A.dbtUniqueId);if(w(B=>{const K=new Set(B);return M?K.add(A.dbtUniqueId):K.delete(A.dbtUniqueId),K}),!(!M||C.has(A.dbtUniqueId)||v.has(A.dbtUniqueId))){j(B=>new Set(B).add(A.dbtUniqueId)),T(B=>{const K={...B};return delete K[A.dbtUniqueId],K});try{const B=await N.getDbtModelingNode(A.dbtUniqueId),G=B.columns.length===0||B.columns.some(D=>!D.type)?await N.describeTable(A.path):[],V=Rv(B,G),I={...A,columns:V};i(D=>D.map(Y=>Y.dbtUniqueId===A.dbtUniqueId?I:Y)),E(D=>new Set(D).add(A.dbtUniqueId)),r({type:"MERGE_SCHEMA_TABLES",tables:[I]})}catch(B){T(K=>({...K,[A.dbtUniqueId]:B instanceof Error?B.message:String(B)}))}finally{j(B=>{const K=new Set(B);return K.delete(A.dbtUniqueId),K})}}};return f?s.jsxs(pn,{t:e,children:[s.jsx(Jt,{size:13,className:"dql-spin"})," Loading dbt database objects…"]}):S?s.jsx(Pv,{error:S,t:e}):o.length===0?s.jsx(pn,{t:e,children:$?`No dbt models or sources match “${$}”.`:"No dbt database objects found. Compile the connected dbt project, then refresh this workspace."}):s.jsxs("div",{children:[s.jsxs("div",{style:{padding:"7px 10px",borderBottom:`1px solid ${e.cellBorder}`,color:e.textMuted,fontSize:10.5},children:["dbt scope · showing ",o.length.toLocaleString()," of ",l.toLocaleString()," object",l===1?"":"s"]}),o.map(A=>{const M=b.has(A.dbtUniqueId),B=v.has(A.dbtUniqueId),K=O[A.dbtUniqueId],G=_v(A.path),V=Ov(A.path);return s.jsxs("div",{children:[s.jsxs("div",{style:{...oa(e),alignItems:"flex-start"},children:[s.jsx("button",{type:"button",onClick:()=>void R(A),"aria-label":`${M?"Collapse":"Expand"} ${G}`,title:M?"Collapse columns":"Load columns",style:Iv(e),children:M?s.jsx(Ns,{size:13}):s.jsx(ao,{size:13})}),s.jsxs("button",{type:"button",onClick:()=>n(`SELECT * FROM ${A.path} LIMIT 100`),title:`Insert a bounded SELECT from ${A.path}`,style:{flex:1,minWidth:0,border:"none",background:"transparent",cursor:"pointer",color:e.textPrimary,textAlign:"left",display:"grid",gap:2,padding:0,fontFamily:e.font},children:[s.jsxs("span",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[s.jsx(or,{size:12.5,color:e.accent,style:{flexShrink:0}}),s.jsx("strong",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11.5,fontFamily:e.fontMono},children:G}),s.jsx("span",{style:{fontSize:8.5,color:e.textMuted,textTransform:"uppercase",letterSpacing:".04em",flexShrink:0},children:A.dbtResourceType}),C.has(A.dbtUniqueId)?s.jsx("span",{style:{fontSize:10,color:e.textMuted,flexShrink:0},children:A.columns.length}):null]}),V?s.jsx("span",{style:{paddingLeft:19,color:e.textMuted,fontSize:9.5,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V}):null]})]}),M?s.jsxs("div",{children:[B?s.jsxs(pn,{t:e,compact:!0,children:[s.jsx(Jt,{size:11,className:"dql-spin"})," Loading columns…"]}):null,!B&&K?s.jsx(pn,{t:e,compact:!0,children:"Columns unavailable. The relation can still be inserted and queried."}):null,!B&&!K&&C.has(A.dbtUniqueId)&&A.columns.length===0?s.jsx(pn,{t:e,compact:!0,children:"No columns are documented in dbt or visible from the selected connection."}):null,!B&&A.columns.map(I=>s.jsxs("button",{type:"button",onClick:()=>n(I.name),title:`Insert column ${I.name}`,style:{...oa(e),paddingLeft:34,gap:7},children:[s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,fontFamily:e.fontMono,color:e.textSecondary},children:I.name}),s.jsx("span",{style:{fontSize:9.5,color:e.textMuted,flexShrink:0,fontFamily:e.fontMono},children:I.type||"unknown"})]},I.name))]}):null]},A.dbtUniqueId)}),d!==null?s.jsx("button",{type:"button",onClick:()=>void _(),disabled:h,style:{width:"calc(100% - 20px)",margin:"9px 10px 11px",padding:"7px 9px",borderRadius:6,border:`1px solid ${e.btnBorder}`,background:e.btnBg,color:e.textSecondary,cursor:h?"wait":"pointer",fontSize:10.5,fontFamily:e.font},children:h?"Loading…":`Load ${Math.min(Ao,l-o.length).toLocaleString()} more`}):null,s.jsx("style",{children:".dql-spin { animation: dql-catalog-spin .8s linear infinite; } @keyframes dql-catalog-spin { to { transform: rotate(360deg); } }"})]})}function Pv({error:e,t}){const n=e instanceof rt?e:null,r=(n==null?void 0:n.code)==="DBT_FIRST_NOT_ENABLED"?"Connect and apply a dbt project in Settings to browse its database objects.":(n==null?void 0:n.code)==="DBT_MANIFEST_NOT_FOUND"?"The connected dbt manifest is missing. Run dbt parse or dbt build, then refresh.":"The dbt database catalog could not be loaded. Refresh after checking the dbt project setup.";return s.jsx(pn,{t,children:r})}function pn({t:e,compact:t=!1,children:n}){return s.jsx("div",{style:{padding:t?"6px 12px 6px 34px":"16px 12px",fontSize:t?10:11.5,color:e.textMuted,textAlign:t?"left":"center",display:"flex",alignItems:"center",justifyContent:t?"flex-start":"center",gap:6},children:n})}const oa=e=>({display:"flex",alignItems:"center",gap:7,width:"100%",minWidth:0,boxSizing:"border-box",padding:"7px 10px",border:"none",borderBottom:`1px solid ${e.cellBorder}`,background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:e.font,color:e.textPrimary}),Iv=e=>({border:"none",background:"transparent",cursor:"pointer",color:e.textMuted,display:"flex",padding:"1px 0 0",flexShrink:0}),Mv=[{collection:"metrics",kind:"metric",label:"Metrics"},{collection:"dimensions",kind:"dimension",label:"Dimensions"},{collection:"timeDimensions",kind:"time_dimension",label:"Time Dimensions"},{collection:"entities",kind:"entity",label:"Entities"},{collection:"measures",kind:"measure",label:"Underlying measures"}];function He(e){return String(e??"").trim()||"uncategorized"}function ut(e){const t=Array.isArray(e.semanticModelIds)?e.semanticModelIds.map(String).filter(Boolean):[];return t.length>0?Array.from(new Set(t)).sort((n,r)=>n.localeCompare(r)):e.cube?[String(e.cube)]:[]}function Lv(e,t){return String((t==="dimension"||t==="time_dimension")&&e.reference||e.name)}function Nv(e,t,n){const r=Lv(e,t),o=He(e.domain);return{id:`${t}:${r}`,label:String(e.label||e.name),kind:t,meta:{provider:n,domain:o,localName:String(e.name),reference:r,...e.canonicalId?{canonicalId:String(e.canonicalId)}:{},...e.qualifiedName?{qualifiedName:String(e.qualifiedName)}:{},...e.entityLink?{entityLink:String(e.entityLink)}:{},...e.table?{table:String(e.table)}:{},...e.cube?{cube:String(e.cube)}:{},...ut(e).length>0?{semanticModelIds:ut(e).join(",")}:{},...e.owner?{owner:String(e.owner)}:{},...Array.isArray(e.tags)&&e.tags.length>0?{tags:e.tags.join(",")}:{}}}}function Ct(e,t,n,r,o){if(r.length===0)return null;const i=r.map(l=>Nv(l,n,o)).sort((l,a)=>l.label.localeCompare(a.label)||l.id.localeCompare(a.id));return{id:e,label:t,kind:"group",count:i.length,meta:{provider:o,objectKind:n},children:i}}function hn(e){var t;return(t=e.children)!=null&&t.length?e.children.reduce((n,r)=>n+hn(r),0):1}function Bv(e){const t=e.provider??"dql",n=[...e.metrics,...e.measures,...e.dimensions,...e.timeDimensions,...e.entities,...e.hierarchies,...e.savedQueries];if(n.length===0&&e.semanticModels.length===0)return null;const r=new Map(e.semanticModels.map(c=>[c.name,c])),o=new Set(e.semanticModels.map(c=>c.name));for(const c of n)for(const f of ut(c))o.add(f);const i=c=>{const f=r.get(c);if(f)return He(f.domain);const p=n.find(h=>ut(h).includes(c));return He(p==null?void 0:p.domain)},l=new Set([...e.domains.map(He),...e.semanticModels.map(c=>He(c.domain)),...n.map(c=>He(c.domain))]),a=Array.from(l).sort((c,f)=>c.localeCompare(f)).flatMap(c=>{const p=Array.from(o).filter(v=>i(v)===c).sort((v,j)=>v.localeCompare(j)).flatMap(v=>{const j=r.get(v),O=Mv.flatMap(({collection:g,kind:$,label:_})=>{const R=e[g].filter(M=>{const B=ut(M);return B.length===1&&B[0]===v&&(g!=="dimensions"||!M.isTimeDimension)}),A=Ct(`group:${c}:${v}:${$}`,_,$,R,t);return A?[A]:[]});return O.length===0&&!j?[]:[{id:`semantic_model:${v}`,label:(j==null?void 0:j.label)||v,kind:"semantic_model",count:O.reduce((g,$)=>g+hn($),0),meta:{provider:t,domain:c,cube:v,...j!=null&&j.table?{table:j.table}:{},...j!=null&&j.owner?{owner:j.owner}:{}},children:O}]}),h=e.metrics.filter(v=>He(v.domain)===c&&ut(v).length>1),y=e.metrics.filter(v=>He(v.domain)===c&&ut(v).length===0),S=[Ct(`group:${c}:unassigned-dimensions`,"Dimensions","dimension",e.dimensions.filter(v=>He(v.domain)===c&&ut(v).length===0&&!v.isTimeDimension),t),Ct(`group:${c}:unassigned-time-dimensions`,"Time Dimensions","time_dimension",e.timeDimensions.filter(v=>He(v.domain)===c&&ut(v).length===0),t),Ct(`group:${c}:unassigned-measures`,"Underlying measures","measure",e.measures.filter(v=>He(v.domain)===c&&ut(v).length===0),t),Ct(`group:${c}:unassigned-entities`,"Entities","entity",e.entities.filter(v=>He(v.domain)===c&&ut(v).length===0),t)].filter(v=>!!v),x=[...p],b=Ct(`group:${c}:cross-model-metrics`,"Cross-model metrics","metric",h,t);b&&x.push(b);const w=Ct(`group:${c}:unassigned-metrics`,"Unassigned metrics","metric",y,t);w&&x.push(w),S.length>0&&x.push({id:`group:${c}:unassigned-objects`,label:"Unassigned objects",kind:"group",count:S.reduce((v,j)=>v+hn(j),0),meta:{provider:t,domain:c},children:S});const C=Ct(`group:${c}:hierarchies`,"Hierarchies","hierarchy",e.hierarchies.filter(v=>He(v.domain)===c),t);C&&x.push(C);const E=Ct(`group:${c}:saved-queries`,"Saved Queries","saved_query",e.savedQueries.filter(v=>He(v.domain)===c),t);return E&&x.push(E),x.length===0?[]:[{id:`domain:${t}:${c}`,label:c,kind:"domain",count:x.reduce((v,j)=>v+hn(j),0),meta:{provider:t,domain:c},children:x}]});if(a.length===0)return null;const d=a.flatMap(c=>c.label==="uncategorized"?c.children??[]:[c]);return{id:"root:semantic",label:"Semantic Layer",kind:"group",children:[{id:`provider:${t}`,label:t.toUpperCase(),kind:"provider",count:d.reduce((c,f)=>c+hn(f),0),meta:{provider:t},children:d}]}}function Fv(e,t,n,r){const o=i=>{var a,d;if(!((a=i.children)!=null&&a.length)){if(i.kind==="metric")return{...i};if(i.kind==="dimension"||i.kind==="time_dimension"){if(t===0||r!=="ready"||!n)return null;const c=String(((d=i.meta)==null?void 0:d.reference)||i.id.slice(i.id.indexOf(":")+1));return n.has(c)?{...i}:null}return null}const l=i.children.map(o).filter(c=>!!c);return l.length===0?null:{...i,count:l.reduce((c,f)=>c+hn(f),0),children:l}};return o(e)??{...e,children:[]}}const sa=[{id:"notebooks",label:"Notebooks",icon:Bs},{id:"semantic",label:"Semantic",icon:Kc},{id:"database",label:"Database",icon:or},{id:"blocks",label:"Blocks",icon:Ls}],zv={certified:"var(--status-success)",published:"var(--status-success)",deprecated:"var(--status-error)",draft:"var(--status-warning)",pending:"var(--status-warning)",review:"#4a74c9",in_review:"#4a74c9"};function qv({defaultTab:e,onOpenFile:t,tabs:n,onInsertText:r,onSemanticCompose:o,blockDomain:i="",onBlockDomainChange:l,onNewBlock:a,onDeleteBlock:d,blockLibraryRefreshKey:c=0,footer:f,footerStatus:p="ready",onCollapse:h}){var g;const{state:y,dispatch:S}=Se(),x=qe[y.themeMode],b=n?n.map($=>sa.find(_=>_.id===$)).filter($=>!!$):sa,[w,C]=u.useState(e??((g=b[0])==null?void 0:g.id)??"notebooks"),[E,v]=u.useState(""),[j,O]=u.useState("");u.useEffect(()=>{e&&C(e)},[e]);const T=r??($=>{Rb($)||S({type:"ADD_CELL",cell:Ms("sql",$)})});return s.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",minHeight:0,background:x.cellBg,fontFamily:x.font},children:[s.jsxs("div",{style:{display:"flex",gap:2,padding:"6px 6px 0",borderBottom:`1px solid ${x.headerBorder}`},children:[b.map(({id:$,label:_,icon:R})=>{const A=w===$;return s.jsxs("button",{type:"button",onClick:()=>C($),title:_,style:{flex:b.length>3?"1 1 auto":1,minWidth:0,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5,border:"none",borderBottom:`2px solid ${A?x.accent:"transparent"}`,background:"transparent",color:A?x.accent:x.textMuted,cursor:"pointer",fontSize:11,fontWeight:700,padding:"6px 3px 7px"},children:[s.jsx(R,{size:13,style:{flexShrink:0}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_})]},$)}),h?s.jsx("button",{type:"button",onClick:h,title:"Collapse explorer",style:{border:"none",background:"transparent",color:x.textMuted,cursor:"pointer",fontSize:13,padding:"0 6px",flexShrink:0},children:"‹"}):null]}),w==="notebooks"?s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${x.headerBorder}`,display:"flex",gap:6},children:[s.jsxs("div",{style:{position:"relative",flex:1},children:[s.jsx(qi,{size:12,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:x.textMuted}}),s.jsx("input",{value:E,onChange:$=>v($.target.value),placeholder:"Search notebooks…","aria-label":"Search notebooks",style:{width:"100%",boxSizing:"border-box",background:x.inputBg,border:`1px solid ${x.inputBorder}`,borderRadius:6,color:x.textPrimary,fontSize:12,fontFamily:x.font,padding:"6px 8px 6px 26px",outline:"none"}})]}),s.jsx("button",{type:"button",onClick:()=>S({type:"OPEN_NEW_NOTEBOOK_MODAL"}),title:"Create notebook","aria-label":"Create notebook",style:{width:28,height:28,flexShrink:0,borderRadius:7,border:`1px solid ${x.accent}55`,background:"var(--accent-dim)",color:x.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s.jsx(Zy,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}):s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${x.headerBorder}`,display:"flex",gap:6},children:[s.jsxs("div",{style:{position:"relative",flex:1},children:[s.jsx(qi,{size:12,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:x.textMuted}}),s.jsx("input",{value:E,onChange:$=>v($.target.value),placeholder:`Search ${w}…`,style:{width:"100%",boxSizing:"border-box",background:x.inputBg,border:`1px solid ${x.inputBorder}`,borderRadius:6,color:x.textPrimary,fontSize:12,fontFamily:x.font,padding:"6px 8px 6px 26px",outline:"none"}})]}),a?s.jsx("button",{type:"button",onClick:a,title:"New block",style:{width:28,height:28,flexShrink:0,borderRadius:6,border:`1px solid ${x.btnBorder}`,background:x.btnBg,color:x.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s.jsx(cx,{size:14,strokeWidth:2})}):null]}),s.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:[w==="notebooks"&&t&&s.jsx(Uv,{t:x,onOpenFile:t,search:E,domain:j,onDomainChange:O}),w==="semantic"&&s.jsx(Hv,{t:x,search:E,onInsert:T,notebookMode:!r||!!o,onSemanticCompose:o}),w==="database"&&s.jsx(Dv,{t:x,search:E,onInsert:T}),w==="blocks"&&s.jsx(Gv,{t:x,search:E,domain:i,onDomainChange:l,onDeleteBlock:d,refreshKey:c})]}),f?s.jsxs("div",{style:{padding:"9px 12px",borderTop:`1px solid ${x.headerBorder}`,fontSize:10.5,color:x.textMuted,display:"flex",alignItems:"center",gap:6,fontFamily:x.font},children:[s.jsx("span",{style:{width:6,height:6,borderRadius:999,background:p==="ready"?"var(--status-success)":"var(--status-warning)",flexShrink:0}}),s.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f})]}):null]})}const cd=(e,t=!1)=>({display:"flex",alignItems:"center",gap:7,width:"100%",minWidth:0,boxSizing:"border-box",padding:"6px 10px",border:"none",borderBottom:`1px solid ${e.cellBorder}`,background:t?`${e.accent}14`:"transparent",cursor:"pointer",textAlign:"left",fontFamily:e.font,color:e.textPrimary});function yn({text:e,t}){return s.jsx("div",{style:{padding:"16px 12px",fontSize:11.5,color:t.textMuted,textAlign:"center"},children:e})}function Uv({t:e,onOpenFile:t,search:n,domain:r,onDomainChange:o}){var O;const{state:i,dispatch:l}=Se(),[a,d]=u.useState(null),[c,f]=u.useState(!1),[p,h]=u.useState(null),y=Tv(i.files,i.authoredDomains),S=y.includes(r)?r:"",b=[...nn(i.authoredDomains).filter(T=>y.includes(T.value)),...y.includes("uncategorized")?[{value:"uncategorized",label:"Unassigned"}]:[]],w=ta(i.files,"",S,i.authoredDomains),C=ta(i.files,n,S,i.authoredDomains),E=Cv(C,"notebooks"),v=S==="uncategorized"?"unassigned":S||"all domains",j=async()=>{if(a){f(!0),h(null);try{const T=await N.deleteNotebook(a.path);if(!T.ok){h(T.error??"Could not delete this notebook.");return}l({type:"FILE_REMOVED",path:a.path}),d(null)}catch(T){h(T instanceof Error?T.message:String(T))}finally{f(!1)}}};return s.jsxs("div",{children:[s.jsx(ld,{id:"notebook-domain-filter",ariaLabel:"Notebook domain",value:S,options:b,onChange:o,summary:s.jsxs(s.Fragment,{children:[C.length," notebook",C.length===1?"":"s"," · ",v]}),t:e}),C.length===0?s.jsx(yn,{text:w.length===0?S?`No notebooks are related to ${v} yet.`:"No notebooks yet. Use the notebook icon above to create one.":`No ${v} notebooks match “${n.trim()}”.`,t:e}):s.jsx(dd,{nodes:E,activePath:(O=i.activeFile)==null?void 0:O.path,onOpenFile:t,onDelete:T=>{h(null),d(T)},t:e}),s.jsx("style",{children:`
|
|
431
|
-
.dql-nb-delete { opacity: 0; transition: opacity .12s, color .12s, background .12s, border-color .12s; }
|
|
432
|
-
.dql-nb-row:hover .dql-nb-delete { opacity: 1; }
|
|
433
|
-
.dql-nb-delete:hover { color: ${e.error} !important; background: ${e.error}12 !important; border-color: ${e.error}44 !important; }
|
|
434
|
-
.dql-nb-delete:focus-visible { opacity: 1; }
|
|
435
|
-
`}),a?s.jsx(Vv,{file:a,t:e,busy:c,error:p,onCancel:()=>{d(null),h(null)},onConfirm:()=>void j()}):null]})}function dd({nodes:e,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i=0}){return s.jsx(s.Fragment,{children:e.map(l=>l.kind==="folder"?s.jsx(Wv,{node:l,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i},`notebook-folder:${l.path}`):s.jsx(Kv,{file:l.file,active:t===l.file.path,onOpenFile:n,onDelete:r,t:o,depth:i},l.file.path))})}function Wv({node:e,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i}){const[l,a]=u.useState(!0);return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":l,title:e.path,style:{display:"flex",alignItems:"center",gap:5,width:"100%",boxSizing:"border-box",padding:`5px 8px 5px ${10+i*14}px`,border:"none",borderBottom:`1px solid ${o.cellBorder}`,background:"transparent",color:o.textMuted,cursor:"pointer",textAlign:"left",fontFamily:o.font,fontSize:11,fontWeight:i===0?700:600},children:[s.jsx(ao,{size:11,style:{transform:l?"rotate(90deg)":void 0,flexShrink:0}}),l?s.jsx(Wc,{size:13}):s.jsx(Un,{size:13}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]}),l?s.jsx(dd,{nodes:e.children,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i+1}):null]})}function Kv({file:e,active:t,onOpenFile:n,onDelete:r,t:o,depth:i}){return s.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},className:"dql-nb-row",children:[s.jsxs("button",{type:"button",onClick:()=>n(e),style:{...cd(o,t),paddingLeft:10+i*14,paddingRight:30},title:`${e.path}${e.ownerDomain?` · Owner domain: ${e.ownerDomain}`:""}`,children:[s.jsx(Bs,{size:13,color:o.textMuted,style:{flexShrink:0}}),s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12.5},children:e.name.replace(/\.dqln?$|\.ipynb$/i,"")})]}),s.jsx("button",{type:"button",className:"dql-nb-delete",onClick:l=>{l.stopPropagation(),r(e)},title:`Delete ${e.name}`,"aria-label":`Delete ${e.name}`,style:{position:"absolute",right:6,display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"1px solid transparent",background:"transparent",color:o.textMuted,cursor:"pointer",padding:0},children:s.jsx(Hc,{size:12})})]})}function Vv({file:e,t,busy:n,error:r,onCancel:o,onConfirm:i}){return s.jsx("div",{role:"dialog","aria-modal":"true","aria-label":`Delete ${e.name}`,onClick:o,style:{position:"fixed",inset:0,zIndex:60,background:"rgba(15,23,42,0.34)",display:"grid",placeItems:"center"},children:s.jsxs("div",{onClick:l=>l.stopPropagation(),style:{width:"min(420px, calc(100vw - 40px))",background:t.cellBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,padding:18,display:"grid",gap:10,boxShadow:"0 18px 60px rgba(15,23,42,0.22)"},children:[s.jsx("div",{style:{fontSize:14,fontWeight:700,color:t.textPrimary,fontFamily:t.font},children:"Delete this notebook?"}),s.jsxs("div",{style:{fontSize:12.5,color:t.textSecondary,fontFamily:t.font,lineHeight:1.5},children:[s.jsx("code",{style:{fontFamily:t.fontMono,fontSize:12},children:e.path})," will be removed from disk. Blocks and metrics it referenced are not affected."]}),r?s.jsx("div",{style:{fontSize:12,color:t.error,fontFamily:t.font},children:r}):null,s.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[s.jsx("button",{type:"button",onClick:o,disabled:n,style:ke(t,{variant:"secondary",size:"md",disabled:n}),children:"Cancel"}),s.jsx("button",{type:"button",onClick:i,disabled:n,style:ke(t,{variant:"danger",size:"md",disabled:n}),children:n?"Deleting…":"Delete notebook"})]})]})})}function Hv({t:e,search:t,onInsert:n,notebookMode:r,onSemanticCompose:o}){var Y;const{state:i,dispatch:l}=Se(),a=u.useMemo(()=>Bv(i.semanticLayer),[i.semanticLayer.provider,i.semanticLayer.metrics,i.semanticLayer.measures,i.semanticLayer.dimensions,i.semanticLayer.timeDimensions,i.semanticLayer.entities,i.semanticLayer.hierarchies,i.semanticLayer.semanticModels,i.semanticLayer.savedQueries]),d=i.semanticLayer.loading,[c,f]=u.useState(new Set),[p,h]=u.useState(new Set),[y,S]=u.useState(null),[x,b]=u.useState("idle"),[w,C]=u.useState(null),[E,v]=u.useState(!1),[j,O]=u.useState(null),[T,g]=u.useState(null),[$,_]=u.useState(),R=new Map(i.semanticLayer.metrics.map(U=>[U.name,U])),A=()=>{l({type:"SET_SETTINGS_TAB",tab:"project"}),l({type:"SET_MAIN_VIEW",view:"settings"})};u.useEffect(()=>{let U=!0;return N.getConnections().then(te=>{U&&_(te.default?{target:"connection",connectionName:te.default}:void 0)}).catch(()=>{U&&_(void 0)}),()=>{U=!1}},[]),u.useEffect(()=>{let U=!0;if(O(null),g(null),c.size===0){S(null),b("idle"),C(null),h(new Set);return}return S(null),b("loading"),C(null),N.getCompatibility(Array.from(c)).then(te=>{if(!U)return;const Q=new Set(te.dimensions.map(F=>F.reference??F.name));S(Q),b("ready"),C(te.engine),h(F=>new Set(Array.from(F).filter(ee=>Q.has(ee))))}).catch(te=>{U&&(S(new Set),b("error"),C(null),h(new Set),g(te instanceof rt?`${te.code?`${te.code}: `:""}${te.message}`:te instanceof Error?te.message:"Semantic compatibility could not be verified."))}),()=>{U=!1}},[Array.from(c).sort().join("|")]);const M=u.useMemo(()=>!a||!r?a:Fv(a,c.size,y,x),[a,r,c.size,y,x]),B=(U,te)=>{O(null),g(null),(U==="metric"?f:h)(F=>{const ee=new Set(F);return ee.has(te)?ee.delete(te):ee.add(te),ee})},K=(U,te)=>{var Q;if(U==="metric"){const F=(Q=R.get(te))==null?void 0:Q.execution;return F&&F.status!=="ready"?{allowed:!1,reason:F.reason||"This metric requires semantic runtime setup."}:{allowed:!0}}return c.size===0?{allowed:!1,reason:"Select a metric first."}:y?y.has(te)?{allowed:!0}:{allowed:!1,reason:"This dimension has no governed join path to every selected metric."}:{allowed:!1,reason:"Checking compatibility…"}},G=new Set([...Array.from(c).map(U=>`metric:${U}`),...Array.from(p).map(U=>`dimension:${U}`)]),V=c.size>0&&x==="ready"&&!E,I=async()=>{if(c.size!==0){v(!0),g(null);try{const U=await N.previewSemanticBuilder({metrics:Array.from(c),dimensions:Array.from(p),executionTarget:$,limit:50});if("error"in U){O(null),g(U.error);return}O({sql:U.sql,rows:U.result.rowCount??U.result.rows.length,executionTarget:$,engine:U.engine})}catch(U){O(null),g(U instanceof rt?`${U.code?`${U.code}: `:""}${U.message}`:U instanceof Error?U.message:"The governed semantic preview could not run.")}finally{v(!1)}}},D=()=>{if(!V)return;const U=Array.from(c),te=Array.from(p);if(o){o(U,te),f(new Set),h(new Set),O(null),g(null);return}const Q=wv(U,te),F=Ms("dql",Q);F.executionTarget=(j==null?void 0:j.executionTarget)??$,F.dqlArtifact={source:Q,kind:"semantic_block",metrics:U,dimensions:te,persistence:"transient",trustState:"governed",reviewState:"draft",routeEvidence:[{route:"semantic",authoringState:j?"previewed":"selected",compatibilityState:x,...w?{compatibilityEngine:w}:{},...j?{engine:j.engine,executionTarget:j.executionTarget,previewRows:j.rows}:{}}],...j?{sql:j.sql,compiledSql:j.sql}:{}},l({type:"ADD_CELL",cell:F}),f(new Set),h(new Set),O(null),g(null)};return d&&!a?s.jsx(yn,{text:"Loading semantic layer…",t:e}):!a||!M||(((Y=a.children)==null?void 0:Y.length)??0)===0?s.jsx(yn,{text:"No semantic layer imported yet.",t:e}):s.jsxs("div",{children:[r&&s.jsxs("div",{style:{display:"grid",gap:7,padding:8,borderBottom:`1px solid ${e.headerBorder}`,background:"var(--bg-1)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{flex:1,fontSize:10.5,color:e.textMuted},children:c.size===0?"Choose a business metric. Related dimensions appear next.":x==="loading"?"Checking governed dimensions…":x==="ready"?`${c.size>1?"Common governed dimensions":"Governed dimensions"} · ${(y==null?void 0:y.size)??0} available${w?` · ${w}`:""}`:`${c.size} metric${c.size===1?"":"s"} selected`}),s.jsx("button",{type:"button",onClick:()=>void I(),disabled:E||c.size===0,style:{border:`1px solid ${e.btnBorder}`,background:e.btnBg,color:e.textSecondary,borderRadius:5,padding:"4px 7px",fontSize:10,cursor:c.size?"pointer":"not-allowed",opacity:c.size?1:.5},children:E?"Running…":"Preview & run"}),s.jsx("button",{type:"button",onClick:D,disabled:!V,title:V?o?"Apply this governed selection to the Block Studio visual builder":j?"Add the previewed semantic query to the notebook":"Add the governed semantic selection now; preview is optional":"Select an executable metric and wait for governed compatibility",style:{border:"none",background:e.accent,color:"#fff",borderRadius:5,padding:"5px 7px",fontSize:10,fontWeight:700,cursor:V?"pointer":"not-allowed",opacity:V?1:.5},children:o?"Apply to block":"Add to cell"})]}),j&&s.jsxs("div",{style:{display:"grid",gap:4,padding:"6px 7px",borderRadius:6,border:"1px solid var(--status-success)",background:"var(--status-success-bg)",color:e.textSecondary,fontSize:10},children:[s.jsxs("span",{children:["Preview succeeded · ",j.rows," row",j.rows===1?"":"s"]}),s.jsx("code",{style:{display:"block",maxHeight:48,overflow:"hidden",whiteSpace:"pre-wrap",fontSize:9,color:e.textMuted},children:j.sql})]}),T&&s.jsxs("div",{role:"alert",style:{display:"flex",gap:7,alignItems:"center",padding:"6px 7px",borderRadius:6,border:`1px solid ${e.error}40`,background:`${e.error}10`,color:e.error,fontSize:10,lineHeight:1.35},children:[s.jsx("span",{style:{flex:1},children:T}),/semantic runtime|MetricFlow/i.test(T)?s.jsx("button",{type:"button",onClick:A,style:{border:"none",background:"transparent",color:e.accent,fontSize:9.5,fontWeight:700,cursor:"pointer",whiteSpace:"nowrap"},children:"Set up →"}):null]}),i.semanticLayer.metrics.some(U=>U.execution&&U.execution.status!=="ready")&&s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:9.5,color:e.textMuted},children:[s.jsx("span",{style:{flex:1},children:"Complex metrics are imported but need a full semantic runtime to execute."}),s.jsx("button",{type:"button",onClick:A,style:{border:"none",background:"transparent",color:e.accent,fontSize:9.5,fontWeight:700,cursor:"pointer",padding:0,whiteSpace:"nowrap"},children:"Set up runtime →"})]})]}),s.jsx(Mb,{tree:M,themeMode:i.themeMode,search:t,onInsert:n,selectionMode:r,selected:G,onToggleSelection:B,canSelect:K})]})}function Gv({t:e,search:t,domain:n,onDomainChange:r,onDeleteBlock:o,refreshKey:i}){const{state:l,dispatch:a}=Se(),[d,c]=u.useState([]),[f,p]=u.useState(!0),[h,y]=u.useState(new Set),S=l.files.filter(T=>T.type==="block").map(T=>T.path).sort().join("|");u.useEffect(()=>{let T=!0;return p(!0),N.getBlockLibrary().then(g=>{T&&c(g.blocks)}).finally(()=>{T&&p(!1)}),()=>{T=!1}},[S,i]);const x=Lb(d,l.authoredDomains),b=x.includes(n)?n:"",C=[...nn(l.authoredDomains).filter(T=>x.includes(T.value)),...x.includes("uncategorized")?[{value:"uncategorized",label:"Unassigned"}]:[]],E=Nb(d,b,t,l.authoredDomains),v=u.useMemo(()=>jv(E,b),[E,b]),j=b==="uncategorized"?"unassigned":b||"all domains",O=T=>{const g={name:T.path.split("/").pop()??T.name,path:T.path,type:"block",folder:"blocks"};l.files.some($=>$.path===T.path)||a({type:"FILE_ADDED",file:g}),N.openBlockStudio(T.path).then($=>a({type:"OPEN_BLOCK_STUDIO",file:g,payload:$}))};return f?s.jsx(yn,{text:"Loading blocks…",t:e}):d.length===0?s.jsx(yn,{text:"No blocks yet.",t:e}):s.jsxs("div",{children:[s.jsx(ld,{id:"block-domain-filter",ariaLabel:"Block domain",value:b,options:C,onChange:T=>r==null?void 0:r(T),summary:s.jsxs(s.Fragment,{children:[E.length," block",E.length===1?"":"s"," · ",j]}),t:e}),E.length===0?s.jsx(yn,{text:t?`No ${j} blocks match this search.`:b?`No blocks in ${b} yet.`:"No blocks yet.",t:e}):s.jsx(ud,{nodes:v,depth:0,expandAll:!!t.trim(),expandedFolders:h,onToggleFolder:T=>y(g=>{const $=new Set(g);return $.has(T)?$.delete(T):$.add(T),$}),onOpen:O,onDelete:o,t:e})]})}function ud({nodes:e,depth:t,expandAll:n,expandedFolders:r,onToggleFolder:o,onOpen:i,onDelete:l,t:a}){return s.jsx(s.Fragment,{children:e.map(d=>{if(d.kind==="block")return s.jsx(Jv,{block:d.block,depth:t,t:a,onOpen:()=>i(d.block),onDelete:l?()=>l(d.block):void 0},d.block.path);const c=n||r.has(d.path);return s.jsxs(Ie.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>o(d.path),title:d.path,style:{...cd(a),paddingLeft:10+t*16,borderBottom:"none",fontWeight:650},children:[c?s.jsx(Ns,{size:13,color:a.textMuted}):s.jsx(ao,{size:13,color:a.textMuted}),c?s.jsx(Wc,{size:14,color:a.accent}):s.jsx(Un,{size:14,color:a.textMuted}),s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:d.name}),s.jsx("span",{style:{fontSize:10,color:a.textMuted},children:pd(d.children)})]}),c?s.jsx(ud,{nodes:d.children,depth:t+1,expandAll:n,expandedFolders:r,onToggleFolder:o,onOpen:i,onDelete:l,t:a}):null]},`folder:${d.path}`)})})}function pd(e){return e.reduce((t,n)=>t+(n.kind==="block"?1:pd(n.children)),0)}function Jv({block:e,depth:t=0,t:n,onOpen:r,onDelete:o}){const i=String(e.status??"draft"),l=zv[i]??n.warning;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,width:"100%",boxSizing:"border-box",padding:`7px 8px 7px ${10+t*16}px`,border:"none",borderRadius:7,margin:"1px 0",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:n.font},children:[s.jsxs("button",{type:"button",onClick:r,title:e.description||`${e.name} — open`,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,border:"none",background:"transparent",padding:0,cursor:"pointer",textAlign:"left",fontFamily:n.font},children:[s.jsx(Ls,{size:14,color:n.textMuted,strokeWidth:1.75,style:{flexShrink:0}}),s.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[s.jsx("span",{style:{fontSize:12,fontWeight:600,color:n.textPrimary,fontFamily:n.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),s.jsx("span",{style:{fontSize:10.5,color:n.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.domain,i].filter(Boolean).join(" · ")})]})]}),s.jsx("span",{title:i,style:{flexShrink:0,width:7,height:7,borderRadius:999,background:l}}),o?s.jsx("button",{type:"button","aria-label":`Delete ${e.name}`,title:`Delete ${e.name}`,onClick:o,style:{width:24,height:24,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"none",borderRadius:6,background:"transparent",color:n.error,cursor:"pointer"},children:s.jsx(Hc,{size:13})}):null]})}const kr=(e,t)=>`https://cdn.simpleicons.org/${e}/${t}`,Qv={duckdb:[kr("duckdb","FFF000")],file:[kr("duckdb","FFF000")],snowflake:[kr("snowflake","29B5E8")],databricks:[kr("databricks","FF3621")]},Yv={duckdb:"#f4bc00",file:"#f4bc00",snowflake:"#29b5e8",databricks:"#ff3621"};function Xv({size:e,color:t}){return s.jsx("span",{"aria-hidden":!0,style:{width:e,height:e,borderRadius:3,background:t,flexShrink:0,display:"inline-block"}})}function Nn({driver:e,size:t=16,fallbackColor:n}){const r=Qv[e]??[],o=n??Yv[e]??"#888",[i,l]=u.useState(0);return r.length===0||i>=r.length?s.jsx(Xv,{size:t,color:o}):s.jsx("img",{src:r[i],alt:`${e} logo`,width:t,height:t,loading:"lazy",onError:()=>l(i+1),style:{flexShrink:0,display:"block",objectFit:"contain"}})}function Zv(e,t){return t.reindexRequired?{ok:!1,message:`Re-index did not complete — ${e.reason??"the catalog is still using a different embedding index"}.`}:e.upgraded?{ok:!0,message:`Catalog re-embedded with ${t.activeProviderId}.`}:{ok:!0,message:`No re-index needed — ${e.reason??"already current"}.`}}const jr="http://127.0.0.1:11434";function eS({t:e,onStatus:t}){const[n,r]=u.useState("hashed"),[o,i]=u.useState(jr),[l,a]=u.useState(""),[d,c]=u.useState(""),[f,p]=u.useState(!1),[h,y]=u.useState({ollama:[],openai:[]}),[S,x]=u.useState([]),[b,w]=u.useState(!1),[C,E]=u.useState({id:"",semantic:!1,reindexRequired:!1}),[v,j]=u.useState(null),[O,T]=u.useState(null),[g,$]=u.useState(null),_=u.useCallback(D=>{r(D.settings.provider),i(D.settings.endpoint||jr),a(D.settings.model),p(D.settings.apiKeySet),E({id:D.activeProviderId,semantic:D.semantic,reindexRequired:D.reindexRequired})},[]),R=u.useCallback(async D=>{try{const Y=await N.listEmbeddingModels(D);y(Y.catalog),x(Y.installed),w(Y.ollamaReachable)}catch{}},[]);u.useEffect(()=>{(async()=>{try{const D=await N.getEmbeddingSettings();_(D),await R(D.settings.endpoint||jr)}catch(D){T(D instanceof Error?D.message:String(D))}})()},[_,R]);const A=async(D,Y)=>{j(D),T(null),$(null);try{await Y()}catch(U){T(U instanceof Error?U.message:String(U))}finally{j(null)}},M=(D,Y)=>A("save",async()=>{const U=await N.saveEmbeddingSettings({provider:D,...D==="ollama"?{endpoint:o}:{},...Y?{model:Y}:{},...D==="openai"&&d?{apiKey:d}:{}});r(D),a(Y),d&&(p(!0),c("")),E({id:U.activeProviderId,semantic:U.semantic,reindexRequired:U.reindexRequired}),t==null||t(U.semantic?"Semantic embeddings enabled. Re-index to apply them to your catalog.":"Using the offline hashed embedder — retrieval stays lexical.")}),B=n==="openai"?h.openai:h.ollama,K={border:`1px solid ${e.headerBorder}`,borderRadius:10,padding:14,background:e.cellBg,marginTop:14},G={fontSize:11,fontWeight:700,color:e.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},V={height:30,padding:"0 9px",borderRadius:6,border:`1px solid ${e.btnBorder}`,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,width:"100%"},I=D=>({display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 11px",borderRadius:6,border:`1px solid ${D?e.accent:e.btnBorder}`,background:D?e.accent:e.btnBg,color:D?"#fff":e.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:e.font});return s.jsxs("div",{style:K,children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:13.5,fontWeight:700,color:e.textPrimary},children:"Embeddings"}),s.jsxs("div",{style:{fontSize:12,color:e.textSecondary,marginTop:4,lineHeight:1.5,maxWidth:620},children:["Decides whether a plain-English question can match a metric by ",s.jsx("em",{children:"meaning"}),' or only by shared words. The offline default is lexical — it cannot connect "drinks" to a ',s.jsx("code",{children:"beverage_revenue"})," metric."]})]}),s.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,padding:"4px 9px",borderRadius:999,fontSize:11,fontWeight:650,background:C.semantic?"var(--status-success-bg)":"var(--status-warning-bg)",color:C.semantic?"var(--status-success)":"var(--status-warning)",border:`1px solid ${C.semantic?"var(--status-success-border)":"var(--status-warning-border)"}`},children:[C.semantic?s.jsx(bx,{size:11}):s.jsx(yx,{size:11}),C.semantic?"Semantic":"Lexical only"]})]}),s.jsx("div",{style:{display:"flex",gap:6,marginTop:12,flexWrap:"wrap"},children:["hashed","ollama","openai"].map(D=>s.jsx("button",{type:"button",onClick:()=>{r(D),D==="hashed"&&M("hashed","")},style:{...I(n===D),textTransform:"capitalize"},children:D==="hashed"?"Offline (default)":D==="ollama"?"Ollama (local)":"OpenAI"},D))}),n==="ollama"&&s.jsxs("div",{style:{marginTop:12},children:[s.jsx("div",{style:G,children:"Ollama endpoint"}),s.jsxs("div",{style:{display:"flex",gap:6,marginTop:4,alignItems:"center"},children:[s.jsx("input",{value:o,onChange:D=>i(D.target.value),onBlur:()=>void R(o),style:V,placeholder:jr}),s.jsx("span",{style:{fontSize:11,whiteSpace:"nowrap",color:b?"var(--status-success)":e.textMuted},children:b?"reachable":"not reachable"})]}),!b&&s.jsx("div",{style:{fontSize:11.5,color:e.textMuted,marginTop:6,lineHeight:1.5},children:"Start Ollama first — nothing leaves your machine with the local option."})]}),n==="openai"&&s.jsxs("div",{style:{marginTop:12},children:[s.jsxs("div",{style:G,children:["API key ",f?"(stored — leave blank to keep)":""]}),s.jsx("input",{type:"password",value:d,onChange:D=>c(D.target.value),style:{...V,marginTop:4},placeholder:f?"••••••••":"sk-…"}),s.jsx("div",{style:{fontSize:11.5,color:e.textMuted,marginTop:6,lineHeight:1.5},children:"Catalog text (metric names, descriptions, business context) is sent to this endpoint to be embedded. Your answer-model key is never reused for this."})]}),n!=="hashed"&&s.jsxs("div",{style:{marginTop:14},children:[s.jsx("div",{style:G,children:"Model"}),s.jsx("div",{style:{display:"grid",gap:6,marginTop:6},children:B.map(D=>{const Y=n==="openai"||S.includes(D.model),U=l===D.model;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 11px",borderRadius:8,border:`1px solid ${U?e.accent:e.btnBorder}`,background:U?`${e.accent}0f`:e.appBg},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary,fontFamily:e.fontMono},children:D.model}),D.recommended&&s.jsx("span",{style:{fontSize:10,fontWeight:700,color:e.accent,background:`${e.accent}18`,borderRadius:999,padding:"1px 7px"},children:"Recommended"}),s.jsxs("span",{style:{fontSize:10.5,color:e.textMuted},children:[D.dimensions," dims · ",D.size]})]}),s.jsx("div",{style:{fontSize:11.5,color:e.textSecondary,marginTop:3,lineHeight:1.45},children:D.description})]}),Y?s.jsx("button",{type:"button",onClick:()=>void M(n,D.model),disabled:v!==null,style:I(U),children:U?s.jsxs(s.Fragment,{children:[s.jsx(Yg,{size:12})," In use"]}):"Use this"}):s.jsx("button",{type:"button",disabled:v!==null||!b,onClick:()=>void A(`install:${D.model}`,async()=>{await N.installEmbeddingModel(D.model,o),await R(o),await N.saveEmbeddingSettings({provider:"ollama",endpoint:o,model:D.model}),a(D.model);const te=await N.getEmbeddingSettings();_(te),t==null||t(`${D.model} installed and selected. Re-index to apply it.`)}),style:I(!0),children:v===`install:${D.model}`?s.jsxs(s.Fragment,{children:[s.jsx(Jt,{size:12,className:"dql-spin"})," Installing…"]}):s.jsxs(s.Fragment,{children:[s.jsx(qc,{size:12})," Install"]})})]},D.model)})})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,flexWrap:"wrap"},children:[s.jsxs("button",{type:"button",disabled:v!==null,onClick:()=>void A("test",async()=>{const D=await N.testEmbeddingProvider();t==null||t(`${D.providerId} responded in ${D.elapsedMs} ms (${D.dimensions} dims).`)}),style:I(),children:[v==="test"?s.jsx(Jt,{size:12,className:"dql-spin"}):null," Test"]}),s.jsxs("button",{type:"button",disabled:v!==null,onClick:()=>void A("reindex",async()=>{const D=await N.reindexEmbeddings(),Y=await N.getEmbeddingSettings();_(Y);const U=Zv(D,Y);$(U),t==null||t(U.message)}),style:I(C.reindexRequired),children:[v==="reindex"?s.jsx(Jt,{size:12,className:"dql-spin"}):s.jsx(Fr,{size:12}),v==="reindex"?"Re-indexing…":"Re-index catalog"]}),s.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.fontMono},children:["active: ",C.id||"—"]})]}),C.reindexRequired&&s.jsx("div",{style:{fontSize:11.5,color:"var(--status-warning)",marginTop:8,lineHeight:1.5},children:"The catalog still holds vectors from the previous embedder. Re-index to search with the new one — until then the vector lane keeps using the old index."}),v==="reindex"&&s.jsx("div",{role:"status",style:{fontSize:11.5,color:e.textSecondary,marginTop:8,lineHeight:1.5},children:"Rebuilding the local vector index. This page will update automatically when it finishes."}),g&&s.jsx("div",{role:g.ok?"status":"alert",style:{fontSize:11.5,color:g.ok?"var(--status-success)":"var(--status-error)",marginTop:8,lineHeight:1.5},children:g.message}),O&&s.jsx("div",{style:{fontSize:11.5,color:e.error,marginTop:8,lineHeight:1.5},children:O})]})}function tS({values:e,onChange:t,placeholder:n,style:r,ariaLabel:o,title:i,disabled:l}){const a=e.join(", "),[d,c]=u.useState(a),f=u.useRef(!1);return u.useEffect(()=>{f.current||c(a)},[a]),s.jsx("input",{type:"text",value:d,disabled:l,"aria-label":o,title:i,placeholder:n,style:r,onFocus:()=>{f.current=!0},onBlur:()=>{f.current=!1,c(ia(d).join(", "))},onChange:p=>{c(p.target.value),t(ia(p.target.value))}})}function ia(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function nS(e){var t;return((t=e.evaluation)==null?void 0:t.status)==="failed"?"Rerun checks & approve":"Run checks & approve"}function rS(e){var t,n,r,o;return(t=e.exclusions)!=null&&t.some(i=>i.reason==="superseded")?"Superseded — excluded":(n=e.exclusions)!=null&&n.some(i=>i.reason==="conflict")?"Conflict — excluded":(r=e.inspection)!=null&&r.state&&e.inspection.state!=="current"?`${e.inspection.state} — excluded`:((o=e.evaluation)==null?void 0:o.status)==="failed"?"Evaluation failed":e.status==="approved"?"Current & applied":e.status}function oS(e,t,n){const r=n.trim();return{...e,[t]:r||void 0}}async function sS(e,t){try{return await e()}finally{await t()}}const iS=["claude-code","codex","anthropic","openai","gemini","ollama","custom-openai"],aS=["claude-code","codex"],lS=["anthropic","openai","gemini","ollama","custom-openai"];function fd(e){switch(e){case"ollama":return"http://host.docker.internal:11434 or http://127.0.0.1:11434";case"anthropic":return"Base URL (optional) — e.g. https://api.anthropic.com or your gateway";case"gemini":return"Base URL (optional) — e.g. https://generativelanguage.googleapis.com/v1beta or your gateway";case"openai":return"Base URL (optional) — e.g. https://api.openai.com/v1 or your gateway";case"custom-openai":default:return"Base URL — e.g. https://your-gateway/v1"}}function Ro({includeMemory:e=!0,embedded:t=!1,section:n,editorMode:r="settings",onProviderConfigured:o}){const{state:i}=Se(),l=qe[i.themeMode],[a,d]=u.useState([]),[c,f]=u.useState([]),[p,h]=u.useState({}),[y,S]=u.useState({path:"",entries:[],warnings:[]}),[x,b]=u.useState([]),[w,C]=u.useState(!0),[E,v]=u.useState(null),j=async()=>{C(!0);try{const[g,$,_,R]=await Promise.all([N.getSettingsEnvStatus(),N.getProviderSettings(),N.getRemoteMcpSettings(),e?N.listAgentMemory():Promise.resolve({memories:[]})]);d(g.groups),f($.providers),S(_.settings),b(R.memories)}finally{C(!1)}};u.useEffect(()=>{j()},[]),u.useEffect(()=>{if(w)return;let g=!1;return N.getProviderCliStatus().then($=>{g||h($.status??{})}),()=>{g=!0}},[w]);const O=u.useMemo(()=>c.filter(g=>g.enabled&&g.configured).length,[c]),T=c.find(g=>g.active&&g.configured);return s.jsxs("div",{style:{padding:t?0:24,maxWidth:t?void 0:1180},children:[!n&&s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:18,fontWeight:700},children:"AI providers, memory & connections"}),s.jsxs("div",{style:{color:l.textSecondary,fontSize:13,marginTop:6,lineHeight:1.5,maxWidth:820},children:["Connect a model provider, manage the agent's learning & memory, and (optionally) attach MCP servers. Secrets stay under ",s.jsx("code",{children:".dql/"})," and are never returned raw."]})]}),s.jsx(hS,{configured:O,total:c.length||iS.length,activeLabel:T==null?void 0:T.label,t:l})]}),E&&s.jsx("div",{style:{marginTop:14,border:`1px solid ${l.headerBorder}`,borderRadius:8,padding:"10px 12px",fontSize:12,color:l.textSecondary,background:l.cellBg},children:E}),w?s.jsx("div",{style:{marginTop:24,color:l.textSecondary},children:"Loading settings..."}):s.jsxs(s.Fragment,{children:[n==="providers"&&s.jsxs(s.Fragment,{children:[s.jsx(uS,{providers:c,cliStatus:p,t:l,onSaved:g=>f(g),onStatus:v,editorMode:r,onProviderConfigured:o}),s.jsx(eS,{t:l,onStatus:v})]}),!n&&s.jsxs("section",{style:{marginTop:22},children:[s.jsx(dn,{title:"Model providers",detail:"Connect at least one AI provider — it powers governed answers, block suggestions, and research. Sign in with a Claude or ChatGPT subscription, or use an API key / local model.",t:l}),s.jsx(la,{title:"Use your subscription",detail:"No API key — sign in with the provider's CLI. DQL runs each request through it using your plan.",t:l}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:aS.map(g=>{const $=c.find(_=>_.id===g);return $?s.jsx(ua,{provider:$,cliStatus:p[g],t:l,onSaved:_=>f(_),onStatus:v},g):null})}),s.jsx(la,{title:"API key & local providers",detail:"Paste an API key (or set the env var), point at a gateway, or run a local model with Ollama.",t:l}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:lS.map(g=>{const $=c.find(_=>_.id===g);return $?s.jsx(ua,{provider:$,t:l,onSaved:_=>f(_),onStatus:v},g):null})})]}),(!n||n==="memory")&&e&&s.jsxs("section",{style:{marginTop:n?0:22},children:[s.jsx(dn,{title:"Agent learning & memory",detail:"Durable business context you add explicitly, plus a separate governed correction queue. Advisory context never overrides current certified metadata, dbt truth, or routing.",t:l}),s.jsx(fS,{memories:x,t:l,onChange:b,onStatus:v}),s.jsx(pS,{t:l,onStatus:v})]}),n==="advanced"&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx(dn,{title:"MCP servers and connectors",detail:"Remote MCP servers can be attached to OpenAI and Claude SDK chat. OpenAI hosted connectors are OpenAI-only.",t:l}),s.jsx(aa,{settings:y,t:l,onChange:S,onStatus:v})]}),s.jsxs("section",{style:{marginTop:22},children:[s.jsx(dn,{title:"Runtime status",detail:"Environment variables remain supported for Docker, CI, and shell-based setup.",t:l}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:a.map(g=>s.jsx(fa,{group:g,t:l},g.id))})]})]}),!n&&s.jsxs("details",{style:{marginTop:22,border:`1px solid ${l.headerBorder}`,borderRadius:10,background:l.cellBg,overflow:"hidden"},children:[s.jsxs("summary",{style:{cursor:"pointer",padding:"13px 16px",fontSize:13,fontWeight:650,listStyle:"none",color:l.textPrimary},children:["Advanced — MCP connections & runtime status",s.jsx("span",{style:{color:l.textMuted,fontWeight:400,marginLeft:8,fontSize:12},children:"optional for most users"})]}),s.jsxs("div",{style:{padding:"4px 16px 18px"},children:[s.jsxs("section",{style:{marginTop:14},children:[s.jsx(dn,{title:"MCP servers and connectors",detail:"Remote MCP servers can be attached to OpenAI and Claude SDK chat. OpenAI hosted connectors are OpenAI-only.",t:l}),s.jsx(aa,{settings:y,t:l,onChange:S,onStatus:v})]}),s.jsxs("section",{style:{marginTop:22},children:[s.jsx(dn,{title:"Runtime status",detail:"Environment variables remain supported for Docker, CI, and shell-based setup.",t:l}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:a.map(g=>s.jsx(fa,{group:g,t:l},g.id))})]})]})]})]})]})}function aa({settings:e,t,onChange:n,onStatus:r}){const[o,i]=u.useState(e.entries),[l,a]=u.useState("form"),[d,c]=u.useState(()=>On(e.entries)),[f,p]=u.useState(null),[h,y]=u.useState(!1);u.useEffect(()=>{i(e.entries),c(On(e.entries)),p(null)},[e]);const S=R=>{i(R),c(On(R)),p(null)},x=(R,A)=>{S(o.map((M,B)=>B===R?Zt({...M,...A}):M))},b=R=>{S(o.filter((A,M)=>M!==R))},w=()=>{S([...o,{kind:"server",name:"",url:"",enabled:!0,trusted:!1,providers:["openai","anthropic"]}])},C=()=>{S([...o,{kind:"connector",name:"",connectorId:"connector_googledrive",enabled:!0,trusted:!1,providers:["openai"]}])},E=R=>{R==="json"&&c(On(o)),p(null),a(R)},v=()=>{const R=yS(d);return i(R),c(On(R)),p(null),R},j=()=>{try{v()}catch(R){p(R instanceof Error?R.message:String(R))}},O=()=>{try{v(),a("form"),r("MCP JSON applied.")}catch(R){p(R instanceof Error?R.message:String(R))}},T=async()=>{y(!0);try{const R=l==="json"?v():o,A=await N.saveRemoteMcpSettings(R.map(B=>Zt(B)));n(A.settings);const M=A.settings.warnings.length?` ${A.settings.warnings.join(" ")}`:"";r(`MCP connections saved.${M}`)}catch(R){const A=R instanceof Error?R.message:String(R);l==="json"&&p(A),r(A)}finally{y(!1)}},g=o.filter(R=>R.enabled&&R.trusted).length,$=o.filter(R=>R.kind==="server").length,_=o.filter(R=>R.kind==="connector").length;return s.jsxs("section",{style:{border:`1px solid ${t.headerBorder}`,borderRadius:8,background:t.cellBg,padding:14},children:[s.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{style:{flex:1,minWidth:240},children:[s.jsxs("div",{style:{fontSize:12,color:t.textSecondary},children:[g," trusted connection",g===1?"":"s"," available to SDK providers"]}),s.jsxs("div",{style:{fontSize:11,color:t.textMuted,marginTop:3},children:[$," remote server",$===1?"":"s"," / ",_," OpenAI connector",_===1?"":"s"]}),e.path&&s.jsx("div",{style:{fontSize:11,color:t.textMuted,marginTop:3,fontFamily:t.fontMono},children:e.path})]}),s.jsxs("div",{style:{display:"flex",border:`1px solid ${t.headerBorder}`,borderRadius:6,overflow:"hidden"},children:[s.jsx("button",{type:"button",onClick:()=>E("form"),style:ha(t,l==="form"),children:"Form"}),s.jsx("button",{type:"button",onClick:()=>E("json"),style:ha(t,l==="json"),children:"JSON import"})]}),s.jsx("button",{type:"button",onClick:w,style:yt(t,!1),children:"Add MCP server"}),s.jsx("button",{type:"button",onClick:C,style:yt(t,!1),children:"Add OpenAI connector"}),s.jsx("button",{type:"button",onClick:T,disabled:h,style:yt(t,!0),children:"Save MCP"})]}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:10,marginTop:12},children:[s.jsx(_o,{title:"Remote MCP server",detail:"Use URL-based MCP servers with OpenAI and Claude. Mark trusted when the server is approved for model tool use.",badge:"OpenAI + Claude",t}),s.jsx(_o,{title:"OpenAI connector",detail:"Use OpenAI hosted connectors such as Google Drive. These are skipped for Claude because Anthropic does not use connector IDs.",badge:"OpenAI only",t}),s.jsx(_o,{title:"JSON import",detail:"Paste DQL JSON, OpenAI Responses tools, or Claude mcp_servers. DQL saves the normalized project config.",badge:"DQL normalized",t})]}),e.warnings.length>0&&s.jsx("div",{style:{marginTop:10,color:"#9a5a00",fontSize:12,lineHeight:1.4},children:e.warnings.join(" ")}),l==="json"?s.jsxs("div",{style:{marginTop:14},children:[s.jsxs("div",{style:{color:t.textSecondary,fontSize:12,lineHeight:1.45,marginBottom:8},children:["Paste DQL MCP JSON, OpenAI Responses ",s.jsx("code",{children:"tools"}),", or Claude ",s.jsx("code",{children:"mcp_servers"}),". Existing stored tokens are preserved when ",s.jsx("code",{children:"authorizationToken"})," is omitted and the same kind/name is kept."]}),s.jsx("textarea",{value:d,onChange:R=>{c(R.target.value),p(null)},spellCheck:!1,rows:18,style:{..._e(t),width:"100%",minHeight:360,resize:"vertical",fontFamily:t.fontMono,fontSize:12,lineHeight:1.45}}),f&&s.jsx("div",{style:{color:"#b42318",fontSize:12,marginTop:8},children:f}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[s.jsx("button",{type:"button",onClick:j,style:yt(t,!1),children:"Format JSON"}),s.jsx("button",{type:"button",onClick:O,style:yt(t,!1),children:"Apply to form"})]})]}):o.length===0?s.jsx("div",{style:{marginTop:14,color:t.textSecondary,fontSize:12},children:"No MCP connections configured."}):s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(340px, 1fr))",gap:12,marginTop:14},children:o.map((R,A)=>s.jsxs("div",{style:{border:`1px solid ${t.headerBorder}`,borderRadius:8,padding:12,background:t.appBg},children:[s.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[s.jsxs("select",{value:R.kind,onChange:M=>x(A,{kind:M.target.value==="connector"?"connector":"server",providers:M.target.value==="connector"?["openai"]:R.providers}),style:{..._e(t),width:116},children:[s.jsx("option",{value:"server",children:"Server"}),s.jsx("option",{value:"connector",children:"Connector"})]}),s.jsx("input",{value:R.name,onChange:M=>x(A,{name:M.target.value}),placeholder:"Name",style:{..._e(t),flex:1}}),s.jsx("button",{type:"button",onClick:()=>b(A),style:yt(t,!1),children:"Remove"})]}),s.jsxs("div",{style:{display:"grid",gap:8,marginTop:10},children:[R.kind==="connector"?s.jsx("input",{value:R.connectorId??"",onChange:M=>x(A,{connectorId:M.target.value}),placeholder:"connector_googledrive",style:_e(t)}):s.jsx("input",{value:R.url??"",onChange:M=>x(A,{url:M.target.value}),placeholder:"https://example.com/mcp or /sse",style:_e(t)}),s.jsx("input",{value:R.description??"",onChange:M=>x(A,{description:M.target.value}),placeholder:"Description shown to the model",style:_e(t)}),s.jsx("input",{value:R.authorizationTokenEnv??"",onChange:M=>x(A,{authorizationTokenEnv:M.target.value}),placeholder:"Authorization token env var",style:_e(t)}),s.jsx("input",{value:R.authorizationToken??"",onChange:M=>x(A,{authorizationToken:M.target.value}),type:"password",placeholder:R.hasAuthorizationToken?`Leave blank to keep ${R.authorizationTokenPreview??"stored token"}`:"Optional OAuth token",style:_e(t)}),s.jsx(tS,{values:R.allowedTools??[],onChange:M=>x(A,{allowedTools:M}),placeholder:"Allowed tools, comma separated",style:_e(t)})]}),s.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginTop:10},children:[s.jsxs("label",{style:_n(t),children:[s.jsx("input",{type:"checkbox",checked:R.enabled,onChange:M=>x(A,{enabled:M.target.checked})})," Enabled"]}),s.jsxs("label",{style:_n(t),children:[s.jsx("input",{type:"checkbox",checked:R.trusted,onChange:M=>x(A,{trusted:M.target.checked})})," Trusted"]}),s.jsxs("label",{style:_n(t),children:[s.jsx("input",{type:"checkbox",checked:!!R.deferLoading,onChange:M=>x(A,{deferLoading:M.target.checked})})," Defer tools"]}),s.jsxs("label",{style:_n(t),children:[s.jsx("input",{type:"checkbox",checked:(R.providers??[]).includes("openai"),onChange:M=>x(A,{providers:ga(R.providers,"openai",M.target.checked)})})," OpenAI"]}),s.jsxs("label",{style:_n(t),children:[s.jsx("input",{type:"checkbox",checked:(R.providers??[]).includes("anthropic"),disabled:R.kind==="connector",onChange:M=>x(A,{providers:ga(R.providers,"anthropic",M.target.checked)})})," Anthropic"]})]})]},`${R.kind}-${R.name||A}`))})]})}function _o({title:e,detail:t,badge:n,t:r}){return s.jsxs("div",{style:{border:`1px solid ${r.headerBorder}`,borderRadius:8,background:r.appBg,padding:10},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx("div",{style:{fontSize:12,fontWeight:700,color:r.textPrimary},children:e}),s.jsx("span",{style:{marginLeft:"auto",border:`1px solid ${r.accent}33`,borderRadius:999,padding:"2px 7px",color:r.accent,background:`${r.accent}12`,fontSize:10,fontWeight:800,whiteSpace:"nowrap"},children:n})]}),s.jsx("div",{style:{color:r.textSecondary,fontSize:11,lineHeight:1.45,marginTop:6},children:t})]})}function cS({status:e,command:t,loginCmd:n,t:r}){let o=r.textMuted,i=r.textMuted,l="Checking for the CLI…";if(e)if(!e.installed)o=r.warning,i=r.warning,l=s.jsxs(s.Fragment,{children:[s.jsx("code",{children:t})," CLI not found on this machine — install it, then sign in."]});else if(!e.loggedIn)o=r.warning,i=r.warning,l=s.jsxs(s.Fragment,{children:["Installed but not signed in — run ",s.jsxs("code",{children:[t," ",n]}),"."]});else{o=r.success,i=r.success;const a=[e.email,e.subscriptionType?`${e.subscriptionType} plan`:e.authMethod].filter(Boolean).join(" · ");l=s.jsxs(s.Fragment,{children:["Signed in",a?s.jsxs(s.Fragment,{children:[" — ",a]}):"",". Ready to use."]})}return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12,color:o},children:[s.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:i,flex:"0 0 auto"}}),s.jsx("span",{children:l})]})}function la({title:e,detail:t,t:n}){return s.jsxs("div",{style:{margin:"20px 0 10px"},children:[s.jsx("div",{style:{fontSize:12.5,fontWeight:750,color:n.textPrimary,letterSpacing:"-0.01em"},children:e}),s.jsx("div",{style:{fontSize:11.5,color:n.textSecondary,marginTop:2,lineHeight:1.45},children:t})]})}function hd(e){return e==="codex"?"codex":"claude"}function md({oauthProvider:e,label:t,model:n,setModel:r,cliStatus:o,command:i,loginCmd:l,t:a,onStatus:d,onConnected:c}){const[f,p]=u.useState(null),[h,y]=u.useState(!1),S=u.useRef(null),x=u.useRef(!0),b=e==="codex"?"ChatGPT":"Claude",w=u.useCallback(()=>{S.current!==null&&(window.clearInterval(S.current),S.current=null)},[]);u.useEffect(()=>(x.current=!0,N.getOAuthStatus(e).then(v=>{x.current&&p(v)}).catch(()=>{}),()=>{x.current=!1,w()}),[e,w]);const C=async()=>{y(!0);try{const v=await N.startOAuth(e);p(v),window.open(v.url,"_blank","noopener,noreferrer"),d(`Opened your browser to sign in to ${b}. Complete it there — this updates automatically.`);const j=Date.now();w(),S.current=window.setInterval(async()=>{const O=await N.getOAuthStatus(e).catch(()=>null);if(!x.current){w();return}O&&p(O),O!=null&&O.connected?(w(),y(!1),c(O.defaultModel)):Date.now()-j>300*1e3&&(w(),y(!1),d(`${b} sign-in timed out. Try again.`))},2500)}catch(v){y(!1),d(v instanceof Error?v.message:String(v))}},E=async()=>{y(!0),w();try{p(await N.signOutOAuth(e)),d(`Signed out of ${b}.`)}catch(v){d(v instanceof Error?v.message:String(v))}finally{y(!1)}};if(f!=null&&f.connected){const v=f.models.length>0?f.models:[f.defaultModel];return s.jsxs("div",{style:{display:"grid",gap:8},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12.5},children:[s.jsxs("span",{style:{color:"#16a34a",fontWeight:700},children:["✓ Signed in to ",b]}),f.email?s.jsxs("span",{style:{color:a.textSecondary},children:["as ",f.email]}):null]}),s.jsx("label",{style:{fontSize:11,color:a.textSecondary,fontWeight:600},children:"Model"}),s.jsx("select",{value:n||f.defaultModel,onChange:j=>r(j.target.value),style:_e(a),children:v.map(j=>s.jsx("option",{value:j,children:j},j))}),s.jsx("div",{children:s.jsx("button",{type:"button",onClick:E,disabled:h,style:yt(a,!1),children:"Sign out"})})]})}return s.jsxs("div",{style:{display:"grid",gap:8},children:[s.jsx("button",{type:"button",onClick:C,disabled:h,style:yt(a,!0),children:h||f!=null&&f.pending?`Waiting for ${b}…`:`Sign in with ${b}`}),s.jsxs("div",{style:{fontSize:12,color:a.textSecondary,lineHeight:1.5},children:["No API key needed — signs in with your ",b," subscription in the browser."]}),s.jsxs("details",{children:[s.jsx("summary",{style:{fontSize:11.5,color:a.textSecondary,cursor:"pointer"},children:"Prefer the CLI?"}),s.jsxs("div",{style:{marginTop:6,display:"grid",gap:6},children:[s.jsx(cS,{status:o,command:i,loginCmd:l,t:a}),s.jsxs("div",{style:{fontSize:11.5,color:a.textSecondary,lineHeight:1.5},children:["Or install the ",s.jsx("code",{children:i})," CLI and run ",s.jsxs("code",{children:[i," ",l]}),", then Enable + Save."]})]})]})]})}const Or=[{key:"claude",label:"Anthropic Claude",modes:{subscription:"claude-code",api:"anthropic"}},{key:"openai",label:"OpenAI",modes:{subscription:"codex",api:"openai"}},{key:"gemini",label:"Google Gemini",modes:{api:"gemini"}},{key:"ollama",label:"Ollama — local",modes:{local:"ollama"}},{key:"gateway",label:"Custom OpenAI-compatible",modes:{api:"custom-openai"}}],ca={subscription:{label:"Subscription",hint:"Sign in — no API key"},api:{label:"API key",hint:"Paste a key or use env var"},local:{label:"Local",hint:"Runs on this machine"}};function dS(e){if(!e)return"claude";const t=Or.find(n=>Object.values(n.modes).includes(e));return(t==null?void 0:t.key)??"claude"}function uS({providers:e,cliStatus:t,t:n,onSaved:r,onStatus:o,editorMode:i,onProviderConfigured:l}){var Q;const a=e.find(F=>F.active&&F.configured),[d,c]=u.useState(()=>dS(a==null?void 0:a.id)),f=Or.find(F=>F.key===d)??Or[0],p=Object.keys(f.modes),[h,y]=u.useState(()=>p.find(ee=>f.modes[ee]===(a==null?void 0:a.id))??p[0]),S=p.includes(h)?h:p[0],x=f.modes[S],b=e.find(F=>F.id===x),[w,C]=u.useState(""),[E,v]=u.useState((b==null?void 0:b.baseUrl)??""),[j,O]=u.useState((b==null?void 0:b.model)??""),[T,g]=u.useState((b==null?void 0:b.reasoningEffort)??"auto"),[$,_]=u.useState(!1),[R,A]=u.useState({state:"idle"}),[M,B]=u.useState({state:"idle"});u.useEffect(()=>{C(""),v((b==null?void 0:b.baseUrl)??""),O((b==null?void 0:b.model)??""),g((b==null?void 0:b.reasoningEffort)??"auto"),B({state:"idle"})},[x,b==null?void 0:b.baseUrl,b==null?void 0:b.model,b==null?void 0:b.reasoningEffort]);const K=async()=>{if(!a)return;A({state:"testing"});const F=Date.now(),ee=await N.testProviderSettings(a.id,{}),ce=ee.ok!==!1;A({state:"done",ok:ce,message:ee.message,seconds:((Date.now()-F)/1e3).toFixed(1)})},G=()=>{var F;return x==="custom-openai"&&!E.trim()?"Custom OpenAI-compatible providers require a Base URL.":x==="custom-openai"&&!j.trim()?"Custom OpenAI-compatible providers require a model.":S==="api"&&x!=="custom-openai"&&!w.trim()&&!(b!=null&&b.hasApiKey)?`Add an API key${(F=b==null?void 0:b.envVars)!=null&&F[0]?` or set ${b.envVars[0]}`:""}.`:S==="local"&&!E.trim()&&!j.trim()&&!(b!=null&&b.configured)?"Set an Ollama endpoint or model before testing.":null},V=async()=>{const F=G();if(F)return B({state:"done",ok:!1,message:F}),!1;B({state:"testing"});const ee=await N.testProviderSettings(x,{apiKey:w||void 0,baseUrl:E||void 0,model:j||void 0});return B({state:"done",ok:ee.ok,message:ee.message}),ee.ok},I=async()=>{_(!0);try{if(!await V()){o("Test failed. Your existing provider configuration was not changed.");return}const ee=await N.saveProviderSettings({id:x,enabled:!0,apiKey:w||void 0,baseUrl:E,model:j,reasoningEffort:T});r(ee.providers);const ce=ee.providers.find(ue=>ue.id===x);ce&&(l==null||l(ce)),o(`${f.label} passed its test and is now the active provider.`)}catch(F){o(F instanceof Error?F.message:String(F))}finally{_(!1)}},D=async F=>{const ee=j||F;O(ee);try{const ce=await N.saveProviderSettings({id:x,enabled:!0,model:ee});r(ce.providers);const ue=ce.providers.find(ie=>ie.id===x);ue&&(l==null||l(ue)),o(`${f.label} subscription configured and activated. Run Test to verify the next governed request.`)}catch(ce){o(ce instanceof Error?ce.message:String(ce))}},Y={fontSize:11,fontWeight:650,color:n.textSecondary},U={..._e(n),borderRadius:8},te=S==="subscription"?"Uses your existing plan through the provider’s sign-in — nothing billed per token.":S==="local"?"Everything runs on this machine — no data leaves your network.":"Keys stay in .dql/ and are never returned raw.";return s.jsxs("div",{style:{width:"min(680px, 100%)",display:"flex",flexDirection:"column",gap:16},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:17,fontWeight:700,color:n.textPrimary},children:"AI provider"}),s.jsxs("div",{style:{fontSize:12.5,color:n.textMuted,marginTop:3,lineHeight:1.5},children:["AI is optional. Without it, deterministic queries, dbt metadata, connections, and governed non-AI paths remain available. Keys stay in ",s.jsx("span",{style:{fontFamily:n.fontMono,fontSize:11.5},children:".dql/"})," and are never returned raw."]})]}),a?s.jsxs("div",{style:{border:"1px solid var(--status-success-border)",borderRadius:12,background:n.cellBg,padding:"16px 18px",display:"flex",alignItems:"center",gap:12},children:[s.jsx("span",{style:{width:36,height:36,borderRadius:9,background:"var(--status-success-bg)",color:"var(--status-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx(Vc,{size:17,strokeWidth:1.75})}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{fontSize:13,fontWeight:700,color:n.textPrimary},children:["Active · ",a.label,a.model?` — ${a.model}`:""]}),s.jsx("div",{style:{fontSize:11.5,color:R.state==="done"&&R.ok===!1?"var(--status-error)":"var(--status-success)",marginTop:2},children:R.state==="testing"?"Testing…":R.state==="done"?R.ok?`Test passed · ${R.seconds}s`:R.message||"Test failed":a.source==="env"?"Configured from environment — run Test to verify":"Configured — run Test to verify reachability"})]}),s.jsx("button",{type:"button",onClick:()=>void K(),disabled:R.state==="testing",style:{display:"inline-flex",alignItems:"center",gap:6,height:30,padding:"0 13px",borderRadius:8,border:`1px solid ${n.headerBorder}`,background:n.cellBg,color:n.textSecondary,fontSize:12,fontWeight:650,cursor:"pointer",fontFamily:n.font,flexShrink:0},children:R.state==="testing"?"Testing…":"Test"})]}):null,s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:12,background:n.cellBg,padding:18,display:"flex",flexDirection:"column",gap:14},children:[s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr",gap:12},children:s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:Y,children:"Provider"}),s.jsx("select",{value:f.key,onChange:F=>{c(F.target.value),y("subscription")},style:U,children:Or.map(F=>s.jsx("option",{value:F.key,children:F.label},F.key))})]})}),s.jsxs("div",{children:[s.jsx("span",{style:{...Y,display:"block",marginBottom:6},children:"How do you want to connect?"}),s.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:p.map(F=>{const ee=F===S;return s.jsxs("button",{type:"button",onClick:()=>y(F),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 13px",borderRadius:9,border:`1.5px solid ${ee?n.accent:n.headerBorder}`,background:ee?"var(--accent-dim)":n.cellBg,cursor:"pointer",fontFamily:n.font,textAlign:"left"},children:[s.jsx("span",{style:{width:13,height:13,borderRadius:999,border:`1.5px solid ${ee?n.accent:"var(--border-strong)"}`,background:ee?n.accent:n.cellBg,boxShadow:ee?`inset 0 0 0 2.5px ${n.cellBg}`:"none",flexShrink:0}}),s.jsxs("span",{style:{display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{fontSize:12,fontWeight:650,color:n.textPrimary},children:ca[F].label}),s.jsx("span",{style:{fontSize:10,color:n.textMuted},children:ca[F].hint})]})]},F)})})]}),S==="subscription"&&b?s.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,background:"var(--bg-1)",padding:"11px 13px"},children:s.jsx(md,{oauthProvider:hd(x),label:b.label,model:j,setModel:O,cliStatus:t[x],command:b.command,loginCmd:x==="claude-code"?"/login":"login",t:n,onStatus:o,onConnected:D})}):null,S==="api"?s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:8,alignItems:"end"},children:[s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:Y,children:"API key"}),s.jsx("input",{type:"password",value:w,onChange:F=>C(F.target.value),placeholder:b!=null&&b.hasApiKey?"Leave blank to keep existing key":"API key",style:{...U,fontFamily:n.fontMono}})]}),(Q=b==null?void 0:b.envVars)!=null&&Q[0]?s.jsxs("span",{style:{fontSize:10.5,color:n.textMuted,paddingBottom:9},children:["or set ",s.jsx("span",{style:{fontFamily:n.fontMono},children:b.envVars[0]})]}):null]}):null,S==="local"?s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:Y,children:"Host"}),s.jsx("input",{value:E,onChange:F=>v(F.target.value),placeholder:"http://localhost:11434",style:{...U,fontFamily:n.fontMono}})]}),s.jsx("div",{style:{display:"flex",alignItems:"flex-end",paddingBottom:2},children:s.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:b!=null&&b.enabled?"var(--status-success)":n.textMuted},children:[s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:b!=null&&b.enabled?"var(--status-success)":"var(--border-strong)"}}),b!=null&&b.enabled?"Ollama configured":"Point at your Ollama host"]})})]}):null,i==="setup"?s.jsxs("details",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:10},children:[s.jsx("summary",{style:{fontSize:11.5,fontWeight:650,color:n.textSecondary,cursor:"pointer"},children:"Advanced enterprise routing"}),s.jsx("div",{style:{display:"grid",gap:10,marginTop:10},children:s.jsx(da,{providerId:x,provider:b,mode:S,baseUrl:E,setBaseUrl:v,model:j,setModel:O,reasoningEffort:T,setReasoningEffort:g,t:n,input:U,fieldLabel:Y})})]}):s.jsx("div",{style:{display:"grid",gap:10},children:s.jsx(da,{providerId:x,provider:b,mode:S,baseUrl:E,setBaseUrl:v,model:j,setModel:O,reasoningEffort:T,setReasoningEffort:g,t:n,input:U,fieldLabel:Y})}),M.state!=="idle"?s.jsx("div",{role:M.ok===!1?"alert":"status",style:{fontSize:11.5,lineHeight:1.5,color:M.state==="testing"?n.textMuted:M.ok?"var(--status-success)":"var(--status-error)"},children:M.state==="testing"?"Testing these unsaved values through the governed runtime…":M.message}):null,s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:4,borderTop:"1px solid var(--border-subtle)"},children:[s.jsx("span",{style:{fontSize:10.5,color:n.textMuted,flex:1},children:te}),s.jsx("button",{type:"button",onClick:()=>void V(),disabled:$||M.state==="testing",style:{height:30,padding:"0 13px",borderRadius:8,border:`1px solid ${n.headerBorder}`,background:n.cellBg,color:n.textSecondary,fontSize:12,fontWeight:650,cursor:"pointer",fontFamily:n.font},children:M.state==="testing"?"Testing…":"Test unsaved values"}),s.jsx("button",{type:"button",onClick:()=>void I(),disabled:$,style:{height:30,padding:"0 15px",borderRadius:8,border:"none",background:n.accent,color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",fontFamily:n.font,boxShadow:"0 1px 4px rgba(107,93,211,0.25)",opacity:$?.7:1},children:$?"Testing…":"Test, save & activate"})]})]})]})}function da({providerId:e,provider:t,mode:n,baseUrl:r,setBaseUrl:o,model:i,setModel:l,reasoningEffort:a,setReasoningEffort:d,t:c,input:f,fieldLabel:p}){return s.jsxs(s.Fragment,{children:[n!=="subscription"&&n!=="local"?s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:p,children:e==="custom-openai"?"Base URL (required)":"Base URL (optional)"}),s.jsx("input",{value:r,onChange:h=>o(h.target.value),placeholder:fd(e),style:{...f,fontFamily:c.fontMono}})]}):null,s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:p,children:e==="custom-openai"?"Model (required)":"Model (optional)"}),s.jsx("input",{value:i,onChange:h=>l(h.target.value),placeholder:(t==null?void 0:t.model)||"Provider default",style:f})]}),t!=null&&t.supportsReasoningEffort&&n==="api"?s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:p,children:"Reasoning effort"}),s.jsxs("select",{value:a,onChange:h=>d(h.target.value),style:f,children:[s.jsx("option",{value:"auto",children:"Auto — pick per task (up to High)"}),s.jsx("option",{value:"low",children:"Low — fastest, cheapest"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High — deepest reasoning"})]})]}):null]})}function ua({provider:e,cliStatus:t,t:n,onSaved:r,onStatus:o}){const[i,l]=u.useState(e.enabled),[a,d]=u.useState(""),[c,f]=u.useState(e.baseUrl??""),[p,h]=u.useState(e.model??""),[y,S]=u.useState(e.reasoningEffort??"auto"),[x,b]=u.useState(!1),[w,C]=u.useState(!1),[E,v]=u.useState(null),j=e.authMode==="subscription_cli",O=e.id==="claude-code"?"/login":"login",T=e.supportsReasoningEffort===!0&&!j&&e.id!=="ollama";u.useEffect(()=>{l(e.enabled),f(e.baseUrl??""),h(e.model??""),S(e.reasoningEffort??"auto"),d(""),v(null)},[e.id,e.enabled,e.baseUrl,e.model,e.reasoningEffort]);const g=async()=>{b(!0);try{const R=await N.saveProviderSettings({id:e.id,enabled:i,apiKey:a||void 0,baseUrl:c,model:p,reasoningEffort:y});r(R.providers),o(`${e.label} settings saved.`)}catch(R){o(R instanceof Error?R.message:String(R))}finally{b(!1)}},$=async()=>{C(!0),v(null);const R=await N.testProviderSettings(e.id,{apiKey:a||void 0,baseUrl:c||void 0,model:p||void 0}),A=R.ok!==!1;v({ok:A,message:R.message||(A?`${e.label} is reachable.`:`${e.label} test failed.`)}),C(!1)},_=async R=>{const A=p||R;h(A),l(!0);try{const M=await N.saveProviderSettings({id:e.id,enabled:!0,model:A});r(M.providers),o(`${e.label} connected and activated.`)}catch(M){o(M instanceof Error?M.message:String(M))}};return s.jsxs("section",{style:{border:`1px solid ${n.headerBorder}`,borderRadius:8,background:n.cellBg,padding:14},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[s.jsxs("div",{style:{flex:1},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx("div",{style:{fontSize:14,fontWeight:700},children:e.label}),e.active?s.jsx("span",{style:gS(n),children:"Active"}):null]}),s.jsxs("div",{style:{fontSize:11,color:n.textSecondary,marginTop:3},children:[e.source==="local"?"Project local":e.source==="env"?"Environment":"Not configured",e.apiKeyPreview?` · ${e.apiKeyPreview}`:""]})]}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:n.textSecondary},children:[s.jsx("input",{type:"checkbox",checked:i,onChange:R=>l(R.target.checked)}),"Enabled"]})]}),s.jsxs("div",{style:{display:"grid",gap:8,marginTop:12},children:[j?s.jsx(md,{oauthProvider:hd(e.id),label:e.label,model:p,setModel:h,cliStatus:t,command:e.command,loginCmd:O,t:n,onStatus:o,onConnected:_}):s.jsxs(s.Fragment,{children:[e.id!=="ollama"&&s.jsx("input",{value:a,onChange:R=>d(R.target.value),type:"password",placeholder:e.hasApiKey?"Leave blank to keep existing key":"API key",style:_e(n)}),s.jsx("input",{value:c,onChange:R=>f(R.target.value),placeholder:fd(e.id),style:_e(n)})]}),!j&&s.jsx("input",{value:p,onChange:R=>h(R.target.value),placeholder:"Default model",style:_e(n)}),T&&s.jsxs("div",{style:{display:"grid",gap:4},children:[s.jsx("label",{style:{fontSize:11,color:n.textSecondary,fontWeight:600},children:"Reasoning effort"}),s.jsxs("select",{value:y,onChange:R=>S(R.target.value),style:_e(n),children:[s.jsx("option",{value:"auto",children:"Auto — pick per task (up to High)"}),s.jsx("option",{value:"low",children:"Low — fastest, cheapest"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High — deepest reasoning"})]}),s.jsx("div",{style:{fontSize:11,color:n.textSecondary,lineHeight:1.4},children:y==="auto"?"The agent spends more reasoning on SQL generation, gates, and repairs, and less on chat.":`Caps every request at ${y} reasoning.`})]})]}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[s.jsx("button",{type:"button",onClick:g,disabled:x||w,style:yt(n,!0),children:e.active?"Save active provider":"Save and use"}),s.jsx("button",{type:"button",onClick:$,disabled:x||w,style:yt(n,!1),children:w?"Testing…":"Test"})]}),E&&s.jsxs("div",{role:"status",style:{marginTop:10,display:"flex",alignItems:"flex-start",gap:7,fontSize:12,lineHeight:1.45,padding:"8px 10px",borderRadius:7,color:E.ok?n.success:n.error,background:`${E.ok?n.success:n.error}12`,border:`1px solid ${E.ok?n.success:n.error}40`},children:[s.jsx("span",{style:{flexShrink:0,fontWeight:700},children:E.ok?"✓":"✗"}),s.jsx("span",{children:E.message})]}),e.envVars.length>0&&s.jsxs("div",{style:{marginTop:10,color:n.textSecondary,fontSize:11,lineHeight:1.4},children:["Env: ",e.envVars.join(", ")]})]})}function Ke(e){var t;return e.lesson??{version:1,category:"semantic_rule",rule:e.guidance,intentExamples:(t=e.trace)!=null&&t.question?[e.trace.question]:[],avoid:[]}}function pa(e){return[...new Map(e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean).map(t=>[t.toLowerCase(),t])).values()].slice(0,8)}function pS({t:e,onStatus:t}){const[n,r]=u.useState([]),[o,i]=u.useState({candidate:0,approved:0,rejected:0,retired:0}),[l,a]=u.useState(null),[d,c]=u.useState(!1),[f,p]=u.useState({}),[h,y]=u.useState(null),S=u.useCallback(async()=>{try{const g=await N.listAgentHints();r(g.hints??[]),i(g.counts??{candidate:0,approved:0,rejected:0,retired:0})}catch{r([])}finally{c(!0)}},[]);u.useEffect(()=>{S()},[S]);const x=async(g,$)=>{var _;a(g.id),t(null);try{const R=(_=f[g.id])==null?void 0:_.trim(),A=await sS(()=>N.reviewAgentHint(g.id,$,R),S);A.ok?t($==="approved"?`Approved. DQL will apply "${g.title}" to matching questions.`:`Rejected. "${g.title}" will not be used.`):t(A.error??`Could not ${$==="approved"?"approve":"reject"} this correction.`)}catch(R){t(R instanceof Error?R.message:String(R))}finally{a(null)}},b=async(g,$,_)=>{var R;a(g.id),t(null);try{const A=await N.transitionAgentHint(g.id,{action:$,targetHintId:_,note:((R=f[g.id])==null?void 0:R.trim())||void 0});t(A.ok?$==="retire"?`Retired "${g.title}". It is excluded from future answers.`:$==="reopen"?`Reopened "${g.title}" as a candidate.`:`Resolved the conflict. "${g.title}" is authoritative.`:A.error??`Could not ${$} this hint.`),await S()}catch(A){t(A instanceof Error?A.message:String(A))}finally{a(null)}},w=async()=>{if(h){a(h.id),t(null);try{const g=await N.updateAgentHint(h.id,{title:h.title,guidance:h.guidance,lesson:{...Ke(h),rule:h.guidance},correctedSql:h.correctedSql,scope:h.scope});g.ok?(t(`Updated "${h.title}" and refreshed its current dependencies.`),y(null)):t(g.error??"Could not update this candidate."),await S()}catch(g){t(g instanceof Error?g.message:String(g))}finally{a(null)}}},C=async g=>{var $;if(!(($=g.trace)!=null&&$.question)||!g.correctedSql){t("This hint is missing the question or SQL required for an analyst certification request.");return}a(g.id);try{const _=await N.requestCertification({question:g.trace.question,generatedSql:g.correctedSql,domain:g.scope.domain,context:{source:"governed_hint_review",hintId:g.id,evaluationId:g.evaluationId,snapshotId:g.snapshotId}});t(_.ok?`Certification research requested for "${g.title}". Approval of a hint did not certify an asset.`:_.error??"Could not request certification.")}catch(_){t(_ instanceof Error?_.message:String(_))}finally{a(null)}},E=n.filter(g=>g.status==="candidate"),v=n.filter(g=>g.status==="approved"),j=n.filter(g=>g.status==="rejected"||g.status==="retired");if(!d)return null;const O=g=>{var $,_,R,A,M,B,K,G,V;return s.jsxs("details",{style:{fontSize:10.5,color:e.textMuted},children:[s.jsx("summary",{style:{cursor:"pointer"},children:"Evidence, provenance & exclusions"}),s.jsxs("div",{style:{display:"grid",gap:5,paddingTop:6},children:[($=g.trace)!=null&&$.question?s.jsxs("div",{children:[s.jsx("b",{children:"Question:"})," ",g.trace.question]}):null,(_=g.trace)!=null&&_.wrongAnswer?s.jsxs("div",{children:[s.jsx("b",{children:"Previous answer:"})," ",g.trace.wrongAnswer]}):null,(R=g.trace)!=null&&R.rationale?s.jsxs("div",{children:[s.jsx("b",{children:"Why the correction is right:"})," ",g.trace.rationale]}):null,s.jsxs("div",{children:[s.jsx("b",{children:"Snapshot:"})," ",g.snapshotId??"missing",(A=g.inspection)!=null&&A.currentSnapshotId?` · current ${g.inspection.currentSnapshotId}`:""]}),s.jsxs("div",{children:[s.jsx("b",{children:"Dependencies:"})," ",((M=g.dependencies)==null?void 0:M.map(I=>`${I.kind}:${I.id}@${I.fingerprint.slice(0,10)}`).join(", "))||"none recorded"]}),s.jsxs("div",{children:[s.jsx("b",{children:"Graph connections:"})," ",(B=g.graphEdges)!=null&&B.length?g.graphEdges.map(I=>`${I.kind.replace(/_/g," ")} → ${I.targetName}`).join(" · "):"none materialized"]}),(K=g.lifecycleErrors)==null?void 0:K.map(I=>s.jsxs("div",{style:{color:e.error},children:[s.jsxs("b",{children:[I.code,":"]})," ",I.message]},`${I.code}-${I.at}`)),g.evaluation?s.jsxs("div",{children:[s.jsxs("b",{children:["Evaluation ",g.evaluation.status,":"]}),g.evaluation.checks.map(I=>s.jsxs("div",{style:{color:I.passed?e.success:e.error},children:[I.passed?"✓":"✕"," ",I.name," — ",I.evidence]},I.name))]}):s.jsxs("div",{children:[s.jsx("b",{children:"Evaluation:"})," not run"]}),(G=g.inspection)==null?void 0:G.checks.map(I=>s.jsxs("div",{style:{color:I.passed?e.success:e.error},children:[I.passed?"✓":"✕"," live ",I.name," — ",I.evidence]},`live-${I.name}`)),(V=g.exclusions)==null?void 0:V.map((I,D)=>s.jsxs("div",{style:{color:e.error},children:[s.jsxs("b",{children:["Excluded: ",I.reason]})," — ",I.detail]},`${I.reason}-${D}`))]})]})},T=g=>{var A,M,B,K,G,V;const $=((A=g.exclusions)==null?void 0:A.filter(I=>I.reason==="conflict"&&I.relatedHintId))??[],_=(h==null?void 0:h.id)===g.id,R=g.status==="approved"&&((M=g.evaluation)==null?void 0:M.status)==="passed"&&((B=g.inspection)==null?void 0:B.state)==="current"&&(((K=g.exclusions)==null?void 0:K.length)??0)===0;return s.jsxs("div",{style:{border:`1px solid ${e.btnBorder}`,borderRadius:8,padding:"10px 12px",background:e.btnBg,display:"grid",gap:7},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8},children:[s.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:e.textPrimary},children:g.title}),s.jsx("span",{style:{fontSize:10,color:(G=g.exclusions)!=null&&G.length||((V=g.evaluation)==null?void 0:V.status)==="failed"?e.error:e.success},children:rS(g)})]}),_?s.jsxs(s.Fragment,{children:[s.jsx("input",{value:h.title,onChange:I=>y({...h,title:I.target.value}),placeholder:"Hint title",style:ke(e,{size:"sm"})}),s.jsx("textarea",{value:h.guidance,onChange:I=>y({...h,guidance:I.target.value}),placeholder:"Guidance for matching questions",rows:3,style:{...ke(e,{size:"sm"}),resize:"vertical"}}),s.jsxs("details",{style:{border:`1px solid ${e.cellBorder}`,borderRadius:7,padding:"7px 8px"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:10.5,color:e.textSecondary,fontWeight:650},children:"Structured lesson"}),s.jsxs("div",{style:{display:"grid",gap:7,paddingTop:7},children:[s.jsxs("select",{value:Ke(h).category,onChange:I=>y({...h,lesson:{...Ke(h),category:I.target.value}}),style:ke(e,{size:"sm"}),children:[s.jsx("option",{value:"semantic_rule",children:"Business definition"}),s.jsx("option",{value:"filter_rule",children:"Filter rule"}),s.jsx("option",{value:"join_rule",children:"Join rule"}),s.jsx("option",{value:"aggregation_rule",children:"Aggregation rule"}),s.jsx("option",{value:"grain_rule",children:"Grain rule"}),s.jsx("option",{value:"time_rule",children:"Time rule"}),s.jsx("option",{value:"relation_rule",children:"Table or column rule"}),s.jsx("option",{value:"dialect_rule",children:"SQL dialect rule"})]}),s.jsx("textarea",{value:Ke(h).intentExamples.join(`
|
|
436
|
-
`),onChange:I=>y({...h,lesson:{...Ke(h),intentExamples:I.target.value.split(/\r?\n/)}}),onBlur:()=>y({...h,lesson:{...Ke(h),intentExamples:pa(Ke(h).intentExamples.join(`
|
|
437
|
-
`))}}),placeholder:"Similar questions, one per line",rows:3,style:{...ke(e,{size:"sm"}),resize:"vertical"}}),s.jsx("textarea",{value:Ke(h).avoid.join(`
|
|
438
|
-
`),onChange:I=>y({...h,lesson:{...Ke(h),avoid:I.target.value.split(/\r?\n/)}}),onBlur:()=>y({...h,lesson:{...Ke(h),avoid:pa(Ke(h).avoid.join(`
|
|
439
|
-
`))}}),placeholder:"Known mistakes to avoid, one per line",rows:2,style:{...ke(e,{size:"sm"}),resize:"vertical"}}),s.jsx("input",{value:Ke(h).expectedOutcome??"",onChange:I=>y({...h,lesson:{...Ke(h),expectedOutcome:I.target.value||void 0}}),placeholder:"Expected outcome or result shape",style:ke(e,{size:"sm"})})]})]}),s.jsx("textarea",{value:h.correctedSql??"",onChange:I=>y({...h,correctedSql:I.target.value}),placeholder:"Read-only corrected SQL",rows:5,style:{...ke(e,{size:"sm"}),resize:"vertical",fontFamily:e.fontMono}}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:7},children:[["dbtModel","dbt model"],["metric","metric"],["domain","domain"],["dialect","dialect"],["term","business term"],["block","block"]].map(([I,D])=>s.jsxs("label",{style:{display:"grid",gap:3,fontSize:10,color:e.textMuted},children:[D,s.jsx("input",{value:h.scope[I]??"",onChange:Y=>y({...h,scope:oS(h.scope,I,Y.target.value)}),placeholder:`Optional ${D}`,style:ke(e,{size:"sm"})})]},I))}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void w(),style:ke(e,{variant:"primary",size:"sm",disabled:l===g.id}),children:"Save & recheck"}),s.jsx("button",{type:"button",onClick:()=>y(null),style:ke(e,{variant:"ghost",size:"sm"}),children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.5},children:g.guidance}),g.lesson?s.jsxs("div",{style:{display:"grid",gap:3,padding:"7px 8px",borderRadius:6,background:e.btnBg,fontSize:10.5,color:e.textMuted},children:[s.jsxs("div",{children:[s.jsx("b",{children:"Lesson type:"})," ",g.lesson.category.replace(/_/g," ")]}),g.lesson.intentExamples.length?s.jsxs("div",{children:[s.jsx("b",{children:"Similar questions:"})," ",g.lesson.intentExamples.join(" · ")]}):null,g.lesson.avoid.length?s.jsxs("div",{children:[s.jsx("b",{children:"Avoid:"})," ",g.lesson.avoid.join(" · ")]}):null,g.lesson.expectedOutcome?s.jsxs("div",{children:[s.jsx("b",{children:"Expected:"})," ",g.lesson.expectedOutcome]}):null]}):null,g.correctedSql?s.jsx("pre",{style:{margin:0,fontSize:10.5,fontFamily:e.fontMono,color:e.textMuted,whiteSpace:"pre-wrap",maxHeight:120,overflow:"auto"},children:g.correctedSql}):null,O(g),s.jsx("textarea",{value:f[g.id]??"",onChange:I=>p({...f,[g.id]:I.target.value}),placeholder:"Reviewer note or result assertion (required evidence when this surface cannot execute)",rows:2,style:{...ke(e,{size:"sm"}),resize:"vertical"}}),s.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[g.status==="candidate"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void x(g,"approved"),style:ke(e,{variant:"primary",size:"sm",disabled:l===g.id}),children:l===g.id?"Checking…":nS(g)}),s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>y({...g,lesson:Ke(g)}),style:ke(e,{size:"sm",disabled:l===g.id}),children:"Edit candidate"}),s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void x(g,"rejected"),style:ke(e,{variant:"danger",size:"sm",disabled:l===g.id}),children:"Reject"})]}):null,g.status==="approved"?s.jsxs(s.Fragment,{children:[R?s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void C(g),style:ke(e,{variant:"primary",size:"sm",disabled:l===g.id}),children:"Request certification"}):null,s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void b(g,"reopen"),style:ke(e,{size:"sm",disabled:l===g.id}),children:"Reopen & edit"}),s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void b(g,"retire"),style:ke(e,{variant:"danger",size:"sm",disabled:l===g.id}),children:"Retire"}),$.map(I=>s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void b(g,"supersede",I.relatedHintId),style:ke(e,{size:"sm",disabled:l===g.id}),children:"Keep this; supersede conflict"},I.relatedHintId))]}):null,g.status==="retired"?s.jsx("button",{type:"button",disabled:l===g.id,onClick:()=>void b(g,"reopen"),style:ke(e,{size:"sm",disabled:l===g.id}),children:"Reopen as candidate"}):null,s.jsx("span",{style:{fontSize:10.5,color:e.textMuted},children:[g.scope.dbtModel,g.scope.metric,g.scope.domain].filter(Boolean).join(" · ")||"project-wide"})]})]})]},g.id)};return s.jsxs("div",{style:{marginTop:18},children:[s.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[s.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Corrections awaiting review"}),s.jsxs("span",{style:{fontSize:11,color:e.textMuted},children:[o.candidate," pending · ",o.approved," approved",o.rejected?` · ${o.rejected} rejected`:"",o.retired?` · ${o.retired} retired`:""]})]}),E.length===0?s.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.5},children:"Nothing pending. A candidate appears only after you explicitly choose Teach DQL on an AI draft that you changed and ran successfully."}):s.jsx("div",{style:{display:"grid",gap:8},children:E.map(T)}),v.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{margin:"16px 0 8px",fontSize:12.5,fontWeight:650,color:e.textPrimary},children:"Approved learning"}),s.jsx("div",{style:{display:"grid",gap:8},children:v.map(T)})]}):null,j.length>0?s.jsxs("details",{style:{marginTop:16},children:[s.jsxs("summary",{style:{cursor:"pointer",fontSize:12,color:e.textSecondary},children:["Rejected & retired history (",j.length,")"]}),s.jsx("div",{style:{display:"grid",gap:8,marginTop:8},children:j.map(T)})]}):null]})}function fS({memories:e,t,onChange:n,onStatus:r}){const[o,i]=u.useState("project"),[l,a]=u.useState(""),[d,c]=u.useState(""),[f,p]=u.useState(""),h=async()=>{const _=await N.listAgentMemory();n(_.memories)},y=async _=>{await N.deleteAgentMemory(_),await h(),r("Memory deleted.")},[S,x]=u.useState(!1),[b,w]=u.useState("all"),[C,E]=u.useState(null),v=_=>_==="project"?{label:"project",bg:"var(--accent-dim)",color:t.accent}:_==="user"?{label:"just me",bg:`${t.textMuted}1f`,color:t.textMuted}:{label:_,bg:"var(--status-success-bg)",color:"var(--status-success)"},j=e.filter(_=>b==="all"?!0:b==="project"?_.scope==="project":_.scope==="user"),O=_=>{E(_.id),i(_.scope),a(_.title),c(_.content),p(_.tags.join(", ")),x(!0)},T=()=>{x(!1),E(null),a(""),c(""),p("")},g=async()=>{if(!d.trim())return;l.trim()||a(d.trim().slice(0,60));const _=l.trim()||d.trim().slice(0,60);await N.saveAgentMemory({scope:o,title:_,content:d,tags:f.split(",").map(R=>R.trim()).filter(Boolean),source:"settings-ui",confidence:.8,importance:o==="project"?.7:.5,enabled:!0}),C&&await N.deleteAgentMemory(C).catch(()=>{}),T(),await h(),r(C?"Memory updated.":"Memory saved.")},$=(_,R)=>s.jsx("button",{type:"button",onClick:()=>w(_),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:t.font,background:b===_?"var(--accent-dim)":"transparent",color:b===_?t.accent:t.textMuted},children:R},_);return s.jsxs("div",{style:{width:"min(640px, 100%)",display:"flex",flexDirection:"column",gap:14},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${t.headerBorder}`,borderRadius:7,background:t.cellBg},children:[$("all","All"),$("project","Project"),$("me","Just me")]}),s.jsx("div",{style:{flex:1}}),s.jsx("button",{type:"button",onClick:()=>S?T():x(!0),style:{display:"inline-flex",alignItems:"center",gap:6,height:30,padding:"0 13px",borderRadius:8,border:"none",background:t.accent,color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",fontFamily:t.font,boxShadow:"0 1px 4px rgba(107,93,211,0.25)"},children:"+ Add memory"})]}),S?s.jsxs("div",{style:{border:`1px solid ${t.accent}4d`,borderRadius:12,background:t.cellBg,padding:"15px 17px",display:"flex",flexDirection:"column",gap:10},children:[s.jsx("textarea",{rows:2,value:d,onChange:_=>c(_.target.value),placeholder:"e.g. Fiscal quarters start in February. 'Sales' means recognized revenue unless someone says bookings.",style:{..._e(t),borderRadius:8,resize:"vertical",lineHeight:1.55}}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[s.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:t.textSecondary},children:["Scope",s.jsxs("select",{value:o,onChange:_=>i(_.target.value),style:{..._e(t),width:"auto",borderRadius:7,padding:"5px 7px"},children:[s.jsx("option",{value:"project",children:"Project"}),s.jsx("option",{value:"user",children:"Just me"}),s.jsx("option",{value:"artifact",children:"Artifact note"}),s.jsx("option",{value:"notebook",children:"Notebook context"}),s.jsx("option",{value:"thread",children:"Thread summary"})]})]}),s.jsx("input",{value:f,onChange:_=>p(_.target.value),placeholder:"Tags (optional)",style:{..._e(t),width:160,borderRadius:7,padding:"5px 8px"}}),s.jsx("div",{style:{flex:1}}),s.jsx("button",{type:"button",onClick:T,style:{height:28,padding:"0 12px",borderRadius:7,border:`1px solid ${t.headerBorder}`,background:t.cellBg,color:t.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:t.font},children:"Cancel"}),s.jsx("button",{type:"button",onClick:()=>void g(),disabled:!d.trim(),style:{height:28,padding:"0 13px",borderRadius:7,border:"none",background:t.accent,color:"#fff",fontSize:11.5,fontWeight:650,cursor:"pointer",fontFamily:t.font,opacity:d.trim()?1:.6},children:C?"Update memory":"Save memory"})]})]}):null,s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:j.length===0?s.jsx("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:t.cellBg,padding:"13px 15px",fontSize:12,color:t.textSecondary,lineHeight:1.5},children:"No advisory memory yet. Add business context explicitly here. Edited SQL corrections use the separate governed review queue and are never promoted into memory automatically."}):j.slice(0,30).map(_=>{const R=!["settings-ui","manual",""].includes(_.source),A=v(_.scope),M=R?`Saved from ${_.source}${typeof _.confidence=="number"?` · ${Math.round(_.confidence*100)}% confidence`:""}`:`Added by hand${_.tags.length?` · ${_.tags.join(", ")}`:""}`;return s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:t.cellBg,padding:"13px 15px",display:"flex",gap:11,alignItems:"flex-start"},children:[s.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"2.5px 7px",borderRadius:5,marginTop:1,background:A.bg,color:A.color},children:A.label}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:12.5,color:t.textPrimary,lineHeight:1.55,whiteSpace:"pre-wrap"},children:_.content||_.title}),s.jsx("div",{style:{fontSize:10.5,color:t.textMuted,marginTop:4},children:M})]}),s.jsx("button",{type:"button",title:"Edit",onClick:()=>O(_),style:{flexShrink:0,width:25,height:25,borderRadius:6,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",color:t.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:11},children:"✎"}),s.jsx("button",{type:"button",title:"Stop using",onClick:()=>void y(_.id),style:{flexShrink:0,width:25,height:25,borderRadius:6,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",color:t.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:11},children:"🗑"})]},_.id)})}),s.jsx("div",{style:{display:"flex",gap:9,alignItems:"flex-start",border:"1px solid var(--border-subtle)",background:t.cellBg,borderRadius:10,padding:"11px 13px"},children:s.jsxs("span",{style:{fontSize:11.5,color:t.textMuted,lineHeight:1.55},children:["Entries added here are local advisory records under ",s.jsx("span",{style:{fontFamily:t.fontMono,fontSize:10.5},children:".dql/cache/"}),". Put shared agent guidance in Git under ",s.jsx("span",{style:{fontFamily:t.fontMono,fontSize:10.5},children:"skills/"})," or ",s.jsx("span",{style:{fontFamily:t.fontMono,fontSize:10.5},children:"domains/<domain>/skills/"}),". Advisory memory and skills never approve or certify a governed hint."]})})]})}function fa({group:e,t}){return s.jsxs("section",{style:{border:`1px solid ${t.headerBorder}`,borderRadius:8,background:t.cellBg,overflow:"hidden"},children:[s.jsxs("div",{style:{padding:"14px 14px 10px",borderBottom:`1px solid ${t.headerBorder}`},children:[s.jsx("div",{style:{fontSize:14,fontWeight:700},children:e.title}),s.jsx("div",{style:{color:t.textSecondary,fontSize:12,lineHeight:1.45,marginTop:4},children:e.description})]}),e.vars.map(n=>s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsx("code",{style:{fontSize:12,color:t.textPrimary},children:n.key}),s.jsx("div",{style:{color:t.textSecondary,fontSize:12,lineHeight:1.4,marginTop:4},children:n.description})]}),s.jsx(mS,{present:n.present})]},n.key))]})}function dn({title:e,detail:t,t:n}){return s.jsxs("div",{style:{marginBottom:10},children:[s.jsx("div",{style:{fontSize:14,fontWeight:700},children:e}),s.jsx("div",{style:{fontSize:12,color:n.textSecondary,marginTop:3},children:t})]})}function hS({configured:e,total:t,activeLabel:n,t:r}){return s.jsxs("div",{style:{border:`1px solid ${r.headerBorder}`,borderRadius:8,padding:"10px 12px",minWidth:160,textAlign:"right",background:r.cellBg},children:[s.jsxs("div",{style:{fontSize:20,fontWeight:700},children:[e,"/",t]}),s.jsx("div",{style:{fontSize:12,color:r.textSecondary},children:"providers configured"}),s.jsx("div",{style:{fontSize:11,color:n?r.accent:r.textMuted,marginTop:4},children:n?`${n} active`:"No active provider"})]})}function mS({present:e}){return s.jsx("span",{style:{alignSelf:"start",fontSize:11,fontWeight:700,borderRadius:999,padding:"3px 8px",color:e?"#12613a":"#7a4a00",background:e?"#d9f8e6":"#fff0cc",whiteSpace:"nowrap"},children:e?"Set":"Optional"})}function _e(e){return{minHeight:32,border:`1px solid ${e.headerBorder}`,borderRadius:6,background:e.appBg,color:e.textPrimary,padding:"7px 9px",fontSize:12,fontFamily:e.font}}function yt(e,t){return{height:30,border:`1px solid ${t?e.accent:e.headerBorder}`,background:t?`${e.accent}24`:e.appBg,color:t?e.accent:e.textPrimary,borderRadius:6,padding:"0 10px",cursor:"pointer",fontSize:12}}function ha(e,t){return{height:28,border:0,borderRight:`1px solid ${e.headerBorder}`,background:t?`${e.accent}18`:e.appBg,color:t?e.accent:e.textSecondary,padding:"0 10px",cursor:"pointer",fontSize:12,fontWeight:t?700:500}}function gS(e){return{border:`1px solid ${e.accent}44`,background:`${e.accent}16`,color:e.accent,borderRadius:999,padding:"2px 7px",fontSize:10,fontWeight:800,textTransform:"uppercase",letterSpacing:0}}function _n(e){return{display:"flex",alignItems:"center",gap:5,fontSize:12,color:e.textSecondary}}function On(e){const t=e.filter(r=>r.kind!=="connector").map(r=>ma({name:r.name,url:r.url,description:r.description,authorizationToken:r.authorizationToken,authorizationTokenEnv:r.authorizationTokenEnv,allowedTools:r.allowedTools,enabled:r.enabled,trusted:r.trusted,deferLoading:r.deferLoading,providers:Zt(r).providers})),n=e.filter(r=>r.kind==="connector").map(r=>ma({name:r.name,connectorId:r.connectorId,description:r.description,authorizationToken:r.authorizationToken,authorizationTokenEnv:r.authorizationTokenEnv,allowedTools:r.allowedTools,enabled:r.enabled,trusted:r.trusted,deferLoading:r.deferLoading,providers:["openai"]}));return JSON.stringify({version:1,servers:t,connectors:n},null,2)}function yS(e){let t;try{t=JSON.parse(e)}catch(r){throw new Error(`Invalid JSON: ${r instanceof Error?r.message:String(r)}`)}if(!Xt(t))throw new Error("MCP config must be a JSON object.");const n=[];return Array.isArray(t.servers)&&n.push(...t.servers.map((r,o)=>Ur(r,"server",`servers[${o}]`))),Array.isArray(t.connectors)&&n.push(...t.connectors.map((r,o)=>Ur(r,"connector",`connectors[${o}]`))),Array.isArray(t.tools)&&n.push(...xS(t.tools)),Array.isArray(t.mcp_servers)&&n.push(...bS(t.mcp_servers)),Xt(t.mcpServers)&&n.push(...vS(t.mcpServers)),n.map(Zt)}function xS(e){return e.flatMap((t,n)=>{if(!Xt(t)||t.type!=="mcp")return[];const r=Ge(t,["connectorId","connector_id"]),o=Ge(t,["authorization"]);return r?[Zt({kind:"connector",name:Ge(t,["name","server_label","serverLabel"])??r,connectorId:r,authorizationToken:o,allowedTools:Qn(t,["allowedTools","allowed_tools"]),enabled:!0,trusted:t.trusted===!0||t.require_approval==="never",providers:["openai"]})]:[Ur({...t,name:Ge(t,["name","server_label","serverLabel"]),url:Ge(t,["url","server_url","serverUrl"]),authorizationToken:o??Ws(t.headers),allowedTools:Qn(t,["allowedTools","allowed_tools"]),enabled:!0,trusted:t.trusted===!0||t.require_approval==="never",providers:["openai"]},"server",`tools[${n}]`)]})}function bS(e){return e.map((t,n)=>{const r=Ur(t,"server",`mcp_servers[${n}]`);return Zt({...r,authorizationToken:r.authorizationToken??(Xt(t)?Ge(t,["authorization_token"]):void 0),providers:["anthropic"]})})}function vS(e){return Object.entries(e).map(([t,n])=>{if(!Xt(n))throw new Error(`mcpServers.${t} must be an object.`);const r=Ge(n,["url","server_url","serverUrl"]);if(!r)throw new Error(`mcpServers.${t} is not a remote HTTP MCP server. App chat SDK config only supports URL-based MCP servers.`);return Zt({kind:"server",name:t,url:r,authorizationToken:Ws(n.headers),enabled:n.enabled!==!1,trusted:n.trusted===!0,allowedTools:Qn(n,["allowedTools","allowed_tools"]),providers:gd(n,["providers"])??["openai","anthropic"]})})}function Ur(e,t,n){if(!Xt(e))throw new Error(`${n} must be an object.`);const r=Ge(e,["name","server_label","serverLabel"]);if(!r)throw new Error(`${n} needs a name.`);const o=Ge(e,["url","server_url","serverUrl"]),i=Ge(e,["connectorId","connector_id"]);if(t==="server"&&!o)throw new Error(`${n} needs a url.`);if(t==="connector"&&!i)throw new Error(`${n} needs a connectorId.`);return{kind:t,name:r,url:o,connectorId:i,description:Ge(e,["description","server_description","serverDescription"]),authorizationToken:Ge(e,["authorizationToken","authorization","authorization_token"])??Ws(e.headers),authorizationTokenEnv:Ge(e,["authorizationTokenEnv","authorizationEnv","authorization_token_env"]),allowedTools:Qn(e,["allowedTools","allowed_tools"]),enabled:e.enabled!==!1,trusted:e.trusted===!0,deferLoading:e.deferLoading===!0||e.defer_loading===!0,providers:gd(e,["providers"])}}function ma(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>!(t==null||t===""||Array.isArray(t)&&t.length===0)))}function Xt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ge(e,t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Qn(e,t){for(const n of t){const r=e[n];if(Array.isArray(r)){const o=r.map(i=>typeof i=="string"?i.trim():"").filter(Boolean);return o.length?Array.from(new Set(o)):void 0}}}function gd(e,t){const n=Qn(e,t);if(!n)return;const r=n.filter(o=>o==="openai"||o==="anthropic");return r.length?r:void 0}function Ws(e){if(!Xt(e))return;const t=Ge(e,["Authorization","authorization"]);return(t==null?void 0:t.replace(/^Bearer\s+/i,"").trim())||void 0}function ga(e,t,n){const r=new Set(e??[]);return n?r.add(t):r.delete(t),Array.from(r)}function Zt(e){var n,r;const t=e.kind==="connector"?["openai"]:(n=e.providers)!=null&&n.length?e.providers:["openai","anthropic"];return{...e,providers:t,allowedTools:(r=e.allowedTools)==null?void 0:r.filter(Boolean)}}function Oo(e){if(!e)return null;if("job"in e&&e.job)return e.job;const t=e.id??("jobId"in e?e.jobId:void 0);return t?{id:t,kind:e.kind,status:e.status??"running",stage:e.stage,progress:e.progress,message:e.message,phases:e.phases,result:e.result,error:e.error}:null}const SS=e=>new Promise(t=>{window.setTimeout(t,e)});async function wS({jobId:e,loadStatus:t,onCompleted:n,onFailed:r,isCancelled:o=()=>!1,wait:i=SS,intervalMs:l=700}){for(;!o();){if(await i(l),o())return;const a=await t();if(o())return;const d=a.job;if(!d||d.id!==e)return;if(!(d.state==="queued"||d.state==="running")){d.state==="completed"?await n(a):d.state==="failed"&&await r(a);return}}}function kS(e){return/^(?:https?:\/\/|ssh:\/\/|git@|file:\/\/)/i.test(e.trim())}function jS(e){const t=e.trim();return t?kS(t)?{repoUrl:t}:{projectDir:t}:{}}const $o={auto:"Auto",native:"Native (DQL)","metricflow-cli":"Local MetricFlow","dbt-cloud":"dbt Cloud"};function CS({compact:e=!1,reapplyRequired:t=!1,onConfigured:n}){var _t,qt,Ut,Wt;const{state:r,dispatch:o}=Se(),i=qe[r.themeMode],[l,a]=u.useState(null),[d,c]=u.useState(!1),[f,p]=u.useState(""),[h,y]=u.useState(null),[S,x]=u.useState(null),[b,w]=u.useState("loading"),[C,E]=u.useState(null),[v,j]=u.useState(null),[O,T]=u.useState(""),[g,$]=u.useState(""),[_,R]=u.useState(""),[A,M]=u.useState(null),[B,K]=u.useState(null),[G,V]=u.useState(null),[I,D]=u.useState(""),[Y,U]=u.useState(!1),te=u.useCallback(async()=>{const z=await N.getSemanticRuntimeSettings();return j(z),T(z.dbtCloud.host??""),$(z.dbtCloud.environmentId??""),R(""),z},[]),Q=u.useCallback(async()=>{const z=await N.getMetricFlowInstallerStatus();return V(z),D(ne=>ne||z.recommendedAdapter||z.supportedAdapters[0]||""),z},[]),F=u.useCallback(async()=>{var de,kt,oe;const[z,ne]=await Promise.all([N.getOnboardingStatus(),N.getBlockStudioDbtStatus().catch(()=>null)]);a(z),x(z.preparation??null);const ve=((de=z.dbt)==null?void 0:de.configured)===!0||!!(ne!=null&&ne.configured&&ne.artifacts.manifest.exists);c(ve);const he=((kt=z.dbt)==null?void 0:kt.repoUrl)||((oe=z.dbt)==null?void 0:oe.projectDir)||(ne==null?void 0:ne.projectPath)||"";return p(ve?he:""),z},[]);u.useEffect(()=>{let z=!0;return F().catch(ne=>z&&E({ok:!1,text:ne instanceof Error?ne.message:String(ne)})).finally(()=>z&&w(null)),()=>{z=!1}},[F]),u.useEffect(()=>{let z=!0;return Promise.all([te(),Q()]).catch(ne=>{z&&K({ok:!1,text:ne instanceof Error?ne.message:String(ne)})}),()=>{z=!1}},[Q,te]),u.useEffect(()=>{const z=G==null?void 0:G.job;if(!z||z.state!=="queued"&&z.state!=="running")return;let ne=!1;return wS({jobId:z.id,loadStatus:Q,isCancelled:()=>ne,onCompleted:async ve=>{var de;await te();const he=await N.getSemanticLayer();ne||(o({type:"SET_SEMANTIC_LAYER",layer:he}),K({ok:!0,text:((de=ve.job)==null?void 0:de.message)||"Local MetricFlow is installed and ready."}))},onFailed:ve=>{var he,de;ne||K({ok:!1,text:((he=ve.job)==null?void 0:he.error)||((de=ve.job)==null?void 0:de.message)||"Local MetricFlow installation failed."})}}).catch(ve=>{ne||K({ok:!1,text:ve instanceof Error?ve.message:String(ve)})}),()=>{ne=!0}},[o,Q,te,(_t=G==null?void 0:G.job)==null?void 0:_t.id]),u.useEffect(()=>{if(!S||S.status!=="queued"&&S.status!=="running")return;let z=!0,ne;const ve=async()=>{try{const he=await N.getOnboardingJob(S.id);if(!z)return;const de=Oo(he);if(!de)return;x(de),de.status==="completed"?(await F(),z&&E({ok:!0,text:de.message||"dbt metadata and governed search indexes are ready."})):de.status==="failed"||de.status==="cancelled"?E({ok:!1,text:de.error||de.message||`dbt preparation ${de.status}.`}):ne=window.setTimeout(()=>void ve(),650)}catch(he){z&&E({ok:!1,text:he instanceof Error?he.message:String(he)})}};return ne=window.setTimeout(()=>void ve(),350),()=>{z=!1,ne!==void 0&&window.clearTimeout(ne)}},[F,S==null?void 0:S.id,S==null?void 0:S.status]);const ee=async()=>{w("preview"),E(null);try{const z=await N.previewDbtOnboarding(jS(f));y(z),E({ok:!0,text:`Preview ready: ${z.counts.models??0} models, ${z.counts.sources??0} sources, ${z.counts.metrics??0} metrics. Nothing has changed yet.`})}catch(z){y(null),E({ok:!1,text:z instanceof Error?z.message:String(z)})}finally{w(null)}},ce=async()=>{if(h){w("apply"),E(null);try{const z=await N.applyDbtOnboarding({...h.repoUrl?{repoUrl:h.repoUrl,branch:h.branch,subPath:h.subPath}:{projectDir:h.projectDir},manifestPath:h.manifestPath,profilesDir:h.profilesDir,expectedFingerprint:h.fingerprint}),ne=Oo(z);ne&&x(ne);const ve=await F();await Q();const he=ve.preparation??ne,de=`${h.counts.models??0} models · ${h.counts.sources??0} sources · ${h.counts.metrics??0} metrics`;E({ok:!0,text:(he==null?void 0:he.status)==="completed"?he.message||`Connected ${h.projectName||h.projectDir}. Governed search is ready.`:he?`Connected ${h.projectName||h.projectDir}. DQL is preparing ${de} for fast governed search in the background.`:`Applied ${h.projectName||h.projectDir}. ${de}.`}),n==null||n({name:h.projectName||"dbt project",path:h.projectDir,summary:de,readiness:(he==null?void 0:he.status)==="completed"?"ready":"preparing",readinessDetail:he==null?void 0:he.message}),y(null)}catch(z){E({ok:!1,text:z instanceof Error?z.message:String(z)})}finally{w(null)}}},ue=async()=>{w("refresh"),E(null);try{const z=await N.previewDbtOnboarding({}),ne=await N.refreshDbtOnboarding({expectedFingerprint:z.fingerprint}),ve=Oo(ne);ve&&x(ve);const de=(await F()).preparation??ve;E({ok:!0,text:(de==null?void 0:de.status)==="completed"?de.message||"dbt artifacts and governed search indexes are ready.":de?"dbt artifacts refreshed. Governed search indexes are updating in the background.":"dbt artifacts refreshed from the configured project."})}catch(z){E({ok:!1,text:z instanceof Error?z.message:String(z)})}finally{w(null)}},ie=()=>({preference:(v==null?void 0:v.preference)??"auto",dbtCloud:{host:O,environmentId:g,serviceToken:_}}),ge=async z=>{M("apply"),K(null);try{const ne=await N.setSemanticRuntimePreference(z);j(ne),K({ok:!0,text:`Preferred runtime set to ${$o[z]??z}.`})}catch(ne){K({ok:!1,text:ne instanceof Error?ne.message:String(ne)})}finally{M(null)}},Oe=async()=>{M("test"),K(null);try{const z=await N.testDbtCloudSemanticRuntime(ie());K({ok:z.ok,text:z.message||z.error||"dbt Cloud Semantic Layer test failed."})}finally{M(null)}},$e=async()=>{M("apply"),K(null);try{const z=await N.applyDbtCloudSemanticRuntime(ie());j(z),R(""),K({ok:!0,text:`${z.dbtCloud.testMessage||"dbt Cloud Semantic Layer tested."} Compilation is now bound to the active warehouse target.`})}catch(z){K({ok:!1,text:z instanceof Error?z.message:String(z)})}finally{M(null)}},Ne=async()=>{if(!I){K({ok:!1,text:"Choose the warehouse adapter used by this dbt project."});return}U(!0),K(null);try{const z=await N.installMetricFlow(I);V(ne=>ne?{...ne,job:z.job}:{job:z.job,recommendedAdapter:I,supportedAdapters:[I],projectConfigured:!0,semanticManifestFound:!1})}catch(z){K({ok:!1,text:z instanceof Error?z.message:String(z)})}finally{U(!1)}},xe=d,pe=(G==null?void 0:G.job)??null,Be=Y||(pe==null?void 0:pe.state)==="queued"||(pe==null?void 0:pe.state)==="running",Ue=(pe==null?void 0:pe.state)==="failed",De=(S==null?void 0:S.status)==="queued"||(S==null?void 0:S.status)==="running",Me=(S==null?void 0:S.status)==="failed"||(S==null?void 0:S.status)==="cancelled",et=t?"Reapply required after DQL update":Me?"dbt project needs attention":De?"Preparing governed search":xe?"dbt project ready":"dbt project missing",gt=t?"Review the prefilled project, choose Preview, then Reapply project.":(S==null?void 0:S.message)??(xe?((qt=l==null?void 0:l.dbt)==null?void 0:qt.repoUrl)||((Ut=l==null?void 0:l.dbt)==null?void 0:Ut.projectDir)||"Configured dbt project.":"Choose a local path or Git repository."),lt={width:"100%",boxSizing:"border-box",height:36,borderRadius:8,border:`1px solid ${i.inputBorder}`,background:i.inputBg,color:i.textPrimary,padding:"0 11px",fontFamily:i.fontMono,fontSize:12,outline:"none"},tt={height:32,padding:"0 13px",borderRadius:8,border:`1px solid ${i.headerBorder}`,background:i.cellBg,color:i.textSecondary,fontFamily:i.font,fontSize:12,fontWeight:650,cursor:b?"wait":"pointer",opacity:b?.7:1};return s.jsxs("div",{style:{width:"min(680px, 100%)",display:"flex",flexDirection:"column",gap:14},children:[e?null:s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:17,fontWeight:700,color:i.textPrimary},children:"Project & dbt"}),s.jsx("div",{style:{fontSize:12.5,color:i.textMuted,marginTop:3,lineHeight:1.5},children:"Preview a local project or Git repository before DQL replaces the active dbt configuration."})]}),s.jsxs("div",{style:{border:`1px solid ${t?"var(--status-warning-border)":Me?"var(--status-error-border)":De?"var(--status-info-border)":xe?"var(--status-success-border)":"var(--border-subtle)"}`,borderRadius:12,background:i.cellBg,padding:"14px 16px",display:"flex",gap:11,alignItems:"center"},children:[s.jsx("span",{style:{width:34,height:34,borderRadius:9,display:"inline-flex",alignItems:"center",justifyContent:"center",color:t?"var(--status-warning)":Me?"var(--status-error)":De?"var(--status-info)":xe?"var(--status-success)":"var(--status-warning)",background:t?"var(--status-warning-bg)":Me?"var(--status-error-bg)":De?"var(--status-info-bg)":xe?"var(--status-success-bg)":"var(--status-warning-bg)"},children:t?s.jsx(Fr,{size:17}):Me?s.jsx(sy,{size:17}):De?s.jsx(Jt,{className:"dql-dbt-preparing-icon",size:17}):xe?s.jsx(zc,{size:17}):s.jsx(Cn,{size:17})}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:13,fontWeight:700,color:i.textPrimary},children:et}),s.jsx("div",{style:{fontSize:11.5,color:Me?"var(--status-error)":i.textMuted,marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:gt}),De?s.jsx("div",{"aria-label":"dbt preparation progress",style:{width:"min(360px, 100%)",height:3,borderRadius:999,background:"var(--border-subtle)",marginTop:7,overflow:"hidden"},children:s.jsx("span",{style:{display:"block",width:`${Math.max(8,(S==null?void 0:S.progress)??8)}%`,height:"100%",borderRadius:999,background:i.accent,transition:"width 180ms ease"}})}):null]}),xe&&!t?s.jsxs("button",{type:"button",onClick:()=>void ue(),disabled:!!b,style:tt,children:[s.jsx(Fr,{size:12,style:{verticalAlign:-2,marginRight:6}}),b==="refresh"?"Refreshing…":"Refresh"]}):null]}),s.jsx("style",{children:"@keyframes dql-dbt-preparing-spin { to { transform: rotate(360deg); } } .dql-dbt-preparing-icon { animation: dql-dbt-preparing-spin 1s linear infinite; } @media (prefers-reduced-motion: reduce) { .dql-dbt-preparing-icon { animation: none; } }"}),s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:12,background:i.cellBg,padding:16,display:"grid",gap:10},children:[s.jsxs("label",{style:{display:"grid",gap:5},children:[s.jsx("span",{style:{fontSize:11,fontWeight:650,color:i.textSecondary},children:"Local dbt project path or Git repository URL"}),s.jsx("input",{value:f,onChange:z=>{p(z.target.value),y(null)},placeholder:". or https://github.com/org/analytics.git",style:lt})]}),h?s.jsxs("div",{style:{border:`1px solid ${i.headerBorder}`,borderRadius:8,padding:"10px 11px",color:i.textSecondary,fontSize:11.5,lineHeight:1.5},children:[s.jsx("strong",{style:{color:i.textPrimary},children:h.projectName||h.projectDir}),s.jsx("br",{}),h.counts.models??0," models · ",h.counts.sources??0," sources · ",h.counts.metrics??0," metrics",s.jsx("br",{}),s.jsx("span",{style:{fontFamily:i.fontMono},children:h.manifestPath})]}):null,C?s.jsx("div",{role:C.ok?"status":"alert",style:{fontSize:11.5,lineHeight:1.5,color:C.ok?"var(--status-success)":"var(--status-error)"},children:C.text}):null,s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void ee(),disabled:!!b,style:tt,children:b==="preview"?"Inspecting…":"Preview"}),h?s.jsx("button",{type:"button",onClick:()=>void ce(),disabled:!!b,style:{...tt,border:"none",background:i.accent,color:"#fff"},children:b==="apply"?"Applying…":t?"Reapply project":"Apply project"}):null]})]}),s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:12,background:i.cellBg,padding:16,display:"grid",gap:12},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:13,fontWeight:700,color:i.textPrimary},children:"Semantic execution adapters"}),s.jsx("div",{style:{fontSize:11.5,color:i.textMuted,marginTop:3,lineHeight:1.5},children:"Adapter code is included with DQL. Auto selects one ready adapter in priority order: dbt Cloud, local MetricFlow, then native for simple metrics. Once selected, an adapter failure is shown directly and never silently downgraded."}),v!=null&&v.dbtCloud.configured?s.jsxs("div",{style:{fontSize:10.5,color:v.dbtCloud.targetBindingState==="bound"&&v.dbtCloud.metricInventoryState==="complete"?"var(--status-success)":"var(--status-warning)",marginTop:6,lineHeight:1.5},children:["dbt Cloud target: ",v.dbtCloud.targetBindingState==="bound"?`bound · ${(Wt=v.dbtCloud.executionTargetFingerprint)==null?void 0:Wt.slice(0,12)}`:"reapply required before execution",s.jsx("br",{}),"Metric inventory: ",v.dbtCloud.metricInventoryState,v.dbtCloud.semanticCatalogFingerprint?` · ${v.dbtCloud.semanticCatalogFingerprint.slice(0,12)}`:" · reapply required"]}):null,s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10,flexWrap:"wrap"},children:[s.jsx("label",{style:{fontSize:11,fontWeight:700,color:i.textSecondary},children:"Preferred runtime"}),s.jsxs("select",{value:(v==null?void 0:v.preference)??"auto",onChange:z=>{ge(z.target.value)},disabled:A==="apply",style:{fontSize:11.5,padding:"4px 8px",borderRadius:7,border:"1px solid var(--border-subtle)",background:i.cellBg,color:i.textPrimary,fontFamily:i.font},children:[s.jsx("option",{value:"auto",children:"Auto (recommended)"}),s.jsx("option",{value:"dbt-cloud",children:"dbt Cloud"}),s.jsx("option",{value:"metricflow-cli",children:"Local MetricFlow"}),s.jsx("option",{value:"native",children:"Native (DQL)"})]}),v!=null&&v.runtime.active?s.jsxs("span",{style:{fontSize:10.5,color:i.textMuted},children:["Active: ",s.jsx("strong",{style:{color:i.textSecondary},children:$o[v.runtime.active]??v.runtime.active}),v.preference&&v.preference!=="auto"&&v.preference!==v.runtime.active?` (preferred ${$o[v.preference]??v.preference} is not ready)`:""]}):null]})]}),s.jsx("div",{style:{display:"grid",gap:7},children:((v==null?void 0:v.runtime.adapters)??[]).map(z=>s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,padding:"9px 10px",display:"grid",gap:z.id==="metricflow-cli"?10:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,marginTop:4,background:z.ready?"var(--status-success)":z.configured?"var(--status-warning)":"var(--text-muted)"}}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:700,color:i.textPrimary},children:z.label}),(v==null?void 0:v.runtime.active)===z.id?s.jsx("span",{style:{fontSize:9,fontWeight:700,color:i.accent},children:"ACTIVE"}):null]}),s.jsx("div",{style:{fontSize:10.5,color:i.textMuted,marginTop:2,lineHeight:1.4},children:z.detail})]}),s.jsx("span",{style:{fontSize:9.5,color:z.ready?"var(--status-success)":i.textMuted},children:z.ready?"Ready":z.configured?"Configured":"Setup required"})]}),z.id==="metricflow-cli"&&(!z.ready||pe)?s.jsxs("div",{style:{marginLeft:17,paddingTop:9,borderTop:"1px solid var(--border-subtle)",display:"grid",gap:8},children:[z.ready?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:10.5,color:i.textSecondary,lineHeight:1.45},children:["Install into an isolated ",s.jsx("code",{style:{fontFamily:i.fontMono},children:".dql/runtimes/metricflow"})," environment. DQL never uses sudo or changes system Python."]}),s.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("select",{"aria-label":"MetricFlow warehouse adapter",value:I,onChange:ne=>D(ne.target.value),disabled:Be,style:{...lt,width:160,height:32,fontFamily:i.font},children:((G==null?void 0:G.supportedAdapters)??[]).map(ne=>s.jsx("option",{value:ne,children:ne==="postgres"?"PostgreSQL":ne.charAt(0).toUpperCase()+ne.slice(1)},ne))}),s.jsxs("button",{type:"button",onClick:()=>void Ne(),disabled:!xe||Be||!I,style:{...tt,border:"none",background:i.accent,color:"#fff",opacity:!xe||Be||!I?.55:1,cursor:!xe||Be?"not-allowed":"pointer"},children:[Be?s.jsx(Jt,{className:"dql-dbt-preparing-icon",size:12,style:{verticalAlign:-2,marginRight:6}}):s.jsx(qc,{size:12,style:{verticalAlign:-2,marginRight:6}}),Be?"Installing…":"Install local MetricFlow"]})]}),xe?null:s.jsx("div",{style:{fontSize:9.5,color:i.textMuted},children:"Connect the dbt project first, then install its matching runtime."})]}),pe?s.jsxs("div",{style:{display:"grid",gap:6},children:[s.jsx("div",{role:Ue?"alert":"status",style:{fontSize:10.5,color:Ue?"var(--status-error)":pe.state==="completed"?"var(--status-success)":i.textSecondary,lineHeight:1.45},children:pe.message}),pe.state==="queued"||pe.state==="running"?s.jsx("div",{"aria-label":"MetricFlow installation progress",style:{height:3,borderRadius:999,background:"var(--border-subtle)",overflow:"hidden"},children:s.jsx("span",{style:{display:"block",height:"100%",width:`${Math.max(4,pe.progress)}%`,background:i.accent,transition:"width 180ms ease"}})}):null,pe.error||pe.logs.length>0?s.jsxs("details",{children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:9.5,color:i.textMuted},children:Ue?"View error and manual details":"View installation details"}),s.jsx("pre",{style:{margin:"7px 0 0",maxHeight:130,overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:i.fontMono,fontSize:9,lineHeight:1.45,color:Ue?"var(--status-error)":i.textMuted},children:[...pe.logs.slice(-30),...pe.error?[pe.error]:[]].join(`
|
|
440
|
-
`)})]}):null]}):null]}):null]},z.id))}),s.jsxs("details",{children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:11.5,fontWeight:700,color:i.textSecondary},children:"dbt Cloud Semantic Layer"}),s.jsxs("div",{style:{display:"grid",gap:9,marginTop:11},children:[s.jsxs("label",{style:{display:"grid",gap:5},children:[s.jsx("span",{style:{fontSize:10.5,fontWeight:650,color:i.textSecondary},children:"Host"}),s.jsx("input",{value:O,onChange:z=>T(z.target.value),placeholder:"semantic-layer.cloud.getdbt.com",style:lt})]}),s.jsxs("label",{style:{display:"grid",gap:5},children:[s.jsx("span",{style:{fontSize:10.5,fontWeight:650,color:i.textSecondary},children:"Environment ID"}),s.jsx("input",{value:g,onChange:z=>$(z.target.value),placeholder:"123456",style:lt})]}),s.jsxs("label",{style:{display:"grid",gap:5},children:[s.jsx("span",{style:{fontSize:10.5,fontWeight:650,color:i.textSecondary},children:"Service token"}),s.jsx("input",{type:"password",value:_,onChange:z=>R(z.target.value),placeholder:(v==null?void 0:v.dbtCloud.serviceTokenPreview)||"Semantic Layer service token",autoComplete:"off",style:lt}),s.jsx("span",{style:{fontSize:9.5,color:i.textMuted},children:"Requires Semantic Layer and Metadata permissions. Leave blank to preserve the stored token."})]}),B?s.jsx("div",{role:B.ok?"status":"alert",style:{fontSize:11,color:B.ok?"var(--status-success)":"var(--status-error)"},children:B.text}):null,s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void Oe(),disabled:!!A,style:tt,children:A==="test"?"Testing…":"Test draft"}),s.jsx("button",{type:"button",onClick:()=>void $e(),disabled:!!A,style:{...tt,border:"none",background:i.accent,color:"#fff"},children:A==="apply"?"Testing & binding…":"Test, bind & save"})]})]})]})]})]})}function Cr(e){return e.map(t=>`${t.catalogOrDatabase}: ${t.schemas.join(", ")}`).join(`
|
|
441
|
-
`)}function Do(e){const t=new Map;for(const n of e.split(/\r?\n/)){const r=n.indexOf(":");if(r<1)continue;const o=n.slice(0,r).trim(),i=n.slice(r+1).split(",").map(d=>d.trim()).filter(Boolean);if(!o||i.length===0)continue;const l=o.toLowerCase(),a=t.get(l)??{catalogOrDatabase:o,schemas:new Set};for(const d of i)a.schemas.add(d);t.set(l,a)}return Array.from(t.values()).map(n=>({catalogOrDatabase:n.catalogOrDatabase,schemas:Array.from(n.schemas)}))}function ES(e,t,n){return e.some(r=>r.catalogOrDatabase.toLowerCase()===t.toLowerCase()&&r.schemas.some(o=>o.toLowerCase()===n.toLowerCase()))}function TS(e,t,n,r){const o=new Map(e.map(a=>[a.catalogOrDatabase.toLowerCase(),{catalogOrDatabase:a.catalogOrDatabase,schemas:new Map(a.schemas.map(d=>[d.toLowerCase(),d]))}])),i=t.toLowerCase(),l=o.get(i)??{catalogOrDatabase:t,schemas:new Map};return r?l.schemas.set(n.toLowerCase(),n):l.schemas.delete(n.toLowerCase()),l.schemas.size>0?o.set(i,l):o.delete(i),Array.from(o.values()).map(a=>({catalogOrDatabase:a.catalogOrDatabase,schemas:Array.from(a.schemas.values())}))}function AS(e){return e.scopes.reduce((t,n)=>t+n.schemas.filter(r=>!r.inDbtProject).length,0)}const Po={duckdb:"DuckDB",file:"Local File / DuckDB",snowflake:"Snowflake",databricks:"Databricks"},$r={duckdb:"#f4bc00",file:"#f4bc00",snowflake:"#29b5e8",databricks:"#ff3621"},RS={duckdb:"In-process analytical database",file:"Local CSV / Parquet via DuckDB",snowflake:"Cloud data platform",databricks:"Lakehouse platform"},co=[{driver:"duckdb",label:"DuckDB",fields:[{key:"filepath",label:"DuckDB file path",type:"text",placeholder:"./local/dev.duckdb",required:!0}]},{driver:"snowflake",label:"Snowflake",fields:[{key:"account",label:"Account",type:"text",required:!0},{key:"warehouse",label:"Warehouse",type:"text",required:!0},{key:"database",label:"Database",type:"text",required:!0},{key:"schema",label:"Schema",type:"text",required:!0},{key:"username",label:"Username",type:"text",required:!0},{key:"authMethod",label:"Authentication",type:"select",options:[{value:"password",label:"Password"},{value:"mfa",label:"Password + MFA"},{value:"key_pair",label:"Key pair / private key"},{value:"external_browser",label:"SSO / external browser"},{value:"oauth",label:"OAuth token"},{value:"oauth_authorization_code",label:"OAuth authorization code"},{value:"oauth_client_credentials",label:"OAuth client credentials"},{value:"programmatic_access_token",label:"Programmatic access token"},{value:"workload_identity",label:"Workload identity"}]},{key:"password",label:"Password",type:"password"},{key:"token",label:"Token",type:"password",helpText:"OAuth, programmatic access token, or OIDC workload identity token."},{key:"privateKeyPath",label:"Private key file path",type:"text",placeholder:"~/.ssh/snowflake_key.p8"},{key:"privateKey",label:"Private key PEM",type:"textarea",helpText:"Paste PEM only when a key file cannot be referenced."},{key:"privateKeyPassphrase",label:"Private key passphrase",type:"password"},{key:"authenticator",label:"Authenticator override",type:"text",placeholder:"EXTERNALBROWSER, OAUTH, WORKLOAD_IDENTITY, or Okta URL"},{key:"role",label:"Role",type:"text"},{key:"accessUrl",label:"Access URL",type:"text"},{key:"application",label:"Application name",type:"text",placeholder:"DQL"},{key:"queryTag",label:"Query tag",type:"text",placeholder:"team=analytics;app=dql"},{key:"passcode",label:"MFA passcode",type:"password"},{key:"passcodeInPassword",label:"MFA passcode is appended to password",type:"checkbox"},{key:"clientRequestMFAToken",label:"Reuse cached MFA token",type:"checkbox"},{key:"clientStoreTemporaryCredential",label:"Cache SSO token locally",type:"checkbox"},{key:"clientSessionKeepAlive",label:"Keep session alive",type:"checkbox"},{key:"clientSessionKeepAliveHeartbeatFrequency",label:"Keep-alive heartbeat seconds",type:"number",placeholder:"3600"},{key:"credentialCacheDir",label:"Credential cache directory",type:"text"},{key:"browserActionTimeout",label:"Browser SSO timeout ms",type:"number",placeholder:"120000"},{key:"keepAlive",label:"Socket keep-alive",type:"checkbox"},{key:"timeout",label:"Connection timeout ms",type:"number",placeholder:"60000"},{key:"proxyHost",label:"Proxy host",type:"text"},{key:"proxyPort",label:"Proxy port",type:"number"},{key:"proxyProtocol",label:"Proxy protocol",type:"text",placeholder:"https"},{key:"proxyUser",label:"Proxy user",type:"text"},{key:"proxyPassword",label:"Proxy password",type:"password"},{key:"noProxy",label:"No proxy hosts",type:"text",placeholder:"*.amazonaws.com|*.internal"},{key:"oauthClientId",label:"OAuth client ID",type:"text"},{key:"oauthClientSecret",label:"OAuth client secret",type:"password"},{key:"oauthAuthorizationUrl",label:"OAuth authorization URL",type:"text"},{key:"oauthTokenRequestUrl",label:"OAuth token request URL",type:"text"},{key:"oauthScope",label:"OAuth scope",type:"text"},{key:"oauthRedirectUri",label:"OAuth redirect URI",type:"text"},{key:"workloadIdentityProvider",label:"Workload identity provider",type:"text",placeholder:"AWS, AZURE, GCP, or OIDC"},{key:"workloadIdentityAzureClientId",label:"Azure client ID",type:"text"}]},{driver:"databricks",label:"Databricks SQL",fields:[{key:"host",label:"Workspace URL",type:"text",required:!0,placeholder:"https://adb-123.cloud.databricks.com"},{key:"database",label:"Catalog / database",type:"text"},{key:"schema",label:"Schema",type:"text"},{key:"warehouse",label:"Warehouse ID",type:"text",helpText:"Use the SQL warehouse ID when you have it."},{key:"httpPath",label:"SQL warehouse ID or path",type:"text",placeholder:"/sql/1.0/warehouses/abc123",helpText:"Paste the warehouse ID or its JDBC/HTTP path."},{key:"authMethod",label:"Authentication",type:"select",options:[{value:"token",label:"Access token"},{value:"oauth",label:"OAuth bearer token"}]},{key:"token",label:"Bearer token",type:"password",required:!0,helpText:"Use an OAuth token for automation when possible, or a service-principal PAT."},{key:"waitTimeout",label:"Statement wait timeout",type:"text",placeholder:"50s"},{key:"byteLimit",label:"Inline byte limit",type:"number",placeholder:"25000000"}]}],Ks=Object.fromEntries(co.map(e=>[e.driver,e])),_S=[{name:"default",label:"Local DuckDB",description:"In-memory DuckDB — no configuration needed",config:{driver:"duckdb",filepath:":memory:"}},{name:"snowflake",label:"Snowflake",description:"Connect to your Snowflake data warehouse",config:{driver:"snowflake",account:"",warehouse:"",database:"",schema:"PUBLIC",username:"",password:""}},{name:"databricks",label:"Databricks SQL",description:"Connect to a Databricks SQL warehouse",config:{driver:"databricks",host:"",warehouse:"",schema:"default",token:""}}];function Bn(e){return e==="postgres"?"postgresql":e}function os(e){return{dbname:"database",dataset:"schema",access_url:"accessUrl",auth_method:"authMethod",auth_type:"authMethod",browser_action_timeout:"browserActionTimeout",byte_limit:"byteLimit",client_request_mfa_token:"clientRequestMFAToken",client_session_keep_alive:"clientSessionKeepAlive",client_session_keep_alive_heartbeat_frequency:"clientSessionKeepAliveHeartbeatFrequency",client_store_temporary_credential:"clientStoreTemporaryCredential",credential_cache_dir:"credentialCacheDir",http_path:"httpPath",keep_alive:"keepAlive",keyFile:"keyFilename",keyFileName:"keyFilename",no_proxy:"noProxy",oauth_authorization_url:"oauthAuthorizationUrl",oauth_client_id:"oauthClientId",oauth_client_secret:"oauthClientSecret",oauth_redirect_uri:"oauthRedirectUri",oauth_scope:"oauthScope",oauth_token_request_url:"oauthTokenRequestUrl",passcode_in_password:"passcodeInPassword",private_key:"privateKey",private_key_path:"privateKeyPath",private_key_passphrase:"privateKeyPassphrase",proxy_host:"proxyHost",proxy_password:"proxyPassword",proxy_port:"proxyPort",proxy_protocol:"proxyProtocol",proxy_user:"proxyUser",query_tag:"queryTag",path:"filepath",project:"projectId",server:"host",server_hostname:"host",user:"username",wait_timeout:"waitTimeout",workload_identity_azure_client_id:"workloadIdentityAzureClientId",workload_identity_provider:"workloadIdentityProvider"}[e]??e}function OS(e){return`${e.profileName}_${e.targetName}`.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"")||"dbt_profile"}function $S(e){const t={};return Object.entries(e.connection??{}).forEach(([n,r])=>{n!=="driver"&&r!==void 0&&r!==null&&(t[os(n)]=String(r))}),t}function DS(e){const n=e.indexOf("/.dbt/");return n>=0?`~${e.slice(n)}`:e.split("/").slice(-3).join("/")}function PS(e){const t=e.toLowerCase();return t.includes("password")||t.includes("token")||t.includes("passphrase")||t.includes("privatekey")||t.includes("serviceaccountjson")||t.includes("secretaccesskey")||t.includes("clientsecret")}function ya(e,t){return e.startsWith("Error")||e.toLowerCase().includes("failed")?t.error:e.toLowerCase().includes("testing")?t.warning:t.success}function Yn(e){const t=Bn(String((e==null?void 0:e.driver)??(e==null?void 0:e.type)??""));if(t!=="duckdb"&&t!=="file")return!1;const n=(e==null?void 0:e.filepath)??(e==null?void 0:e.path);return!n||n===":memory:"}function IS(e,t,n,r){const o=r!==null&&r===t,i=!!(t&&e[t]),l=e[n];return r===null||o||!i||t==="default"&&Yn(e.default)&&!Yn(l)?n:t}function MS(e){const t=Object.keys(e);return t.find(n=>!Yn(e[n]))??t[0]}function yd({variant:e="panel",onConfigured:t}={}){var ti,ni,ri,oi;const{state:n,dispatch:r}=Se(),o=qe[n.themeMode],i=e==="page",l=e==="setup",[a,d]=u.useState(null),[c,f]=u.useState(!1),[p,h]=u.useState(null),[y,S]=u.useState(null),[x,b]=u.useState(!1),[w,C]=u.useState(!1),[E,v]=u.useState(null),[j,O]=u.useState(null),[T,g]=u.useState(""),[$,_]=u.useState(!1),[R,A]=u.useState(null),[M,B]=u.useState([]),[K,G]=u.useState(!1),[V,I]=u.useState(null),[D,Y]=u.useState("dbt_relations"),[U,te]=u.useState(""),[Q,F]=u.useState(!1),[ee,ce]=u.useState(null),[ue,ie]=u.useState(null),[ge,Oe]=u.useState(!1),[$e,Ne]=u.useState(""),[xe,pe]=u.useState("duckdb"),[Be,Ue]=u.useState({}),[De,Me]=u.useState("duckdb"),[et,gt]=u.useState({}),lt=u.useRef(null);u.useEffect(()=>{N.getConnections().then(P=>{d(P),P.metadataScope&&(Y(P.metadataScope.mode),te(Cr(P.metadataScope.selectedScopes??P.metadataScope.scopes))),Object.values(P.connections).some(q=>!Yn(q))&&N.testConnection().then(h)})},[]),u.useEffect(()=>{if(!i)return;let P=!0;return Promise.all([N.getProviderSettings(),N.getOnboardingStatus(),N.getBlockStudioDbtStatus().catch(()=>null)]).then(([q,re,Z])=>{var ae;P&&(B(q.providers),G(((ae=re.dbt)==null?void 0:ae.configured)===!0||!!(Z!=null&&Z.configured&&Z.artifacts.manifest.exists)),I(re.preparation??null))}).catch(()=>{}),()=>{P=!1}},[i]),u.useEffect(()=>{if(!i||!V||V.status!=="queued"&&V.status!=="running")return;let P=!0,q;const re=async()=>{var Z,ae,ye;try{const Le=await N.getOnboardingStatus();if(!P)return;I(Le.preparation??null),G(((Z=Le.dbt)==null?void 0:Z.configured)===!0),(((ae=Le.preparation)==null?void 0:ae.status)==="queued"||((ye=Le.preparation)==null?void 0:ye.status)==="running")&&(q=window.setTimeout(()=>void re(),700))}catch{}};return q=window.setTimeout(()=>void re(),500),()=>{P=!1,q!==void 0&&window.clearTimeout(q)}},[V==null?void 0:V.id,V==null?void 0:V.status,i]),u.useEffect(()=>{var Z;if(!a)return;const P=a.default,q=P?(Z=a.connections)==null?void 0:Z[P]:void 0,re=q?`${P}::${JSON.stringify(q)}`:"::none";if(lt.current!==re)if(lt.current=re,q){Me(Bn(String(q.driver??q.type??"duckdb")));const ae={};Object.entries(q).forEach(([ye,Le])=>{ye!=="driver"&&ye!=="type"&&(ae[os(ye)]=String(Le??""))}),gt(ae)}else Me("duckdb"),gt({})},[a]);const tt=async()=>{if(!a||Object.keys(a.connections??{}).length===0){h({ok:!1,message:"Add or import a connection before testing."});return}f(!0),h(null);const P=await N.testConnection();h(P),P.ok&&(t==null||t(P.message)),f(!1)},_t=P=>{d(q=>q&&{...q,metadataScope:P.scope,metadataStatus:P.status}),Y(P.scope.mode),te(Cr(P.scope.selectedScopes??P.scope.scopes))},qt=async()=>{if(!(!(a!=null&&a.default)||!(p!=null&&p.ok))){Oe(!0),ce("Finding databases/catalogs and schemas visible to this connection…");try{const P=await N.discoverConnectionMetadataScopes(a.default);ie(P),ce(P.message)}catch(P){ie(null),ce(P instanceof Error?P.message:String(P))}finally{Oe(!1)}}},Ut=(P,q,re)=>{const Z=TS(Do(U),P,q,re);te(Cr(Z)),Y(((ue==null?void 0:ue.dbtScopes.length)??0)>0?"dbt_plus_selected":"selected_scopes")},Wt=async()=>{if(!(a!=null&&a.default))return;const P=Do(U);if(D==="selected_scopes"&&P.length===0){ce("Add at least one line such as ANALYTICS_PROD: SALES, FINANCE.");return}F(!0),ce("Synchronizing selected metadata into local SQLite…");try{const q=await N.applyConnectionMetadataScope(a.default,{mode:D,...D==="dbt_relations"?{}:{scopes:P}});_t(q),ce(`Ready · ${q.status.relationCount.toLocaleString()} relations · ${q.status.columnCount.toLocaleString()} columns · ${q.status.queryCount??0} metadata queries`)}catch(q){ce(q instanceof Error?q.message:String(q))}finally{F(!1)}},z=async()=>{if(a!=null&&a.default){F(!0),ce("Refreshing the applied metadata scope…");try{const P=await N.refreshConnectionMetadata(a.default);_t(P),ce(`Refreshed · ${P.status.relationCount.toLocaleString()} relations · ${P.status.columnCount.toLocaleString()} columns`)}catch(P){ce(P instanceof Error?P.message:String(P))}finally{F(!1)}}},ne=(P,q)=>{S(P),b(!1),Ne(P),pe(Bn((q==null?void 0:q.driver)??(q==null?void 0:q.type)??"duckdb"));const re={};Object.entries(q??{}).forEach(([Z,ae])=>{Z!=="driver"&&Z!=="type"&&(re[os(Z)]=String(ae??""))}),Ue(re)},ve=()=>{b(!0),S(null),Ne(""),pe("duckdb"),Ue({})},he=()=>{S(null),b(!1)},de=async P=>{O(P),v(null);try{const q=await N.installConnector(P);if(q.connectorStatus&&a)d({...a,connectorStatus:q.connectorStatus});else{const re=await N.getConnections();d(re)}v(q.ok?"Connector installed":`Error: ${q.error??"Install failed"}`)}catch(q){v(`Error: ${(q==null?void 0:q.message)??"Install failed"}`)}finally{O(null)}},kt=async P=>{if(!a)return!1;C(!0),v(null);const q=P.name.trim()||(P.previousName??"default"),re={driver:P.driver},Z=Ks[P.driver],ae=new Map(((Z==null?void 0:Z.fields)??[]).map(Fe=>[Fe.key,Fe]));Object.entries(P.fields).forEach(([Fe,We])=>{const dt=ae.get(Fe);if((dt==null?void 0:dt.type)==="checkbox"){We!==""&&(re[Fe]=We==="true");return}const ur=We.trim();ur&&((dt==null?void 0:dt.type)==="number"&&!isNaN(Number(ur))?re[Fe]=Number(ur):re[Fe]=ur)});const ye={...a.connections},Le=a.default,on={...a.connections};P.previousName&&P.previousName!==q&&delete on[P.previousName],on[q]=re;const Ud=IS(on,a.default,q,P.previousName);let si=!1;try{await N.saveConnections(on,Ud);const Fe=await N.getConnections();d(Fe),Fe.metadataScope&&(Y(Fe.metadataScope.mode),te(Cr(Fe.metadataScope.selectedScopes??Fe.metadataScope.scopes))),ie(null),v("Saved. Testing connection..."),S(null),b(!1);try{f(!0);const We=await N.testConnection();if(h(We),si=We.ok,We.ok)v("Test passed. Connection saved and activated."),t==null||t(We.message),setTimeout(()=>v(null),2e3);else{await N.saveConnections(ye,Le||void 0);const dt=await N.getConnections();d(dt),v(`Test failed. Previous connection preserved: ${We.message}`)}}catch(We){await N.saveConnections(ye,Le||void 0).catch(()=>{});const dt=await N.getConnections().catch(()=>null);dt&&d(dt),v(`Test failed. Previous connection preserved: ${We.message??"Connection failed"}`)}finally{f(!1)}}catch(Fe){await N.saveConnections(ye,Le||void 0).catch(()=>{});const We=await N.getConnections().catch(()=>null);We&&d(We),v(`Test or save failed. Previous connection preserved: ${Fe.message}`)}finally{C(!1)}return si},oe=P=>{const q=Bn(String(P.connection.driver??P.adapter??"duckdb")),re=$S(P);h(null),(i||l)&&(Me(q),gt(re)),b(!1),S(null),kt({name:OS(P),driver:q,fields:re,previousName:null})},J=async()=>{const P=T.trim();if(!P){A("Enter a profiles.yml file or folder path.");return}_(!0),A(null);try{const q=await N.previewDbtProfiles(P);d(re=>{if(!re)return re;const Z=new Map((re.dbtProfiles??[]).map(ae=>[ae.id,ae]));return q.dbtProfiles.forEach(ae=>Z.set(ae.id,ae)),{...re,dbtProfiles:[...Z.values()]}})}catch(q){A(q instanceof Error?q.message:"Could not read that profiles.yml path.")}finally{_(!1)}},Ae=()=>kt({name:$e,driver:xe,fields:Be,previousName:y}),Tn=()=>kt({name:(a==null?void 0:a.default)||"default",driver:De,fields:et,previousName:(a==null?void 0:a.default)||null}),rn=P=>{Me(P),gt({}),h(null)},ir=async P=>{if(!a)return;const q={...a.connections};delete q[P];const re=P===a.default?MS(q):a.default;C(!0);try{await N.saveConnections(q,re);const Z=await N.getConnections();d(Z),S(null)}finally{C(!1)}},Dd=async P=>{if(!a)return;const q=a.default;C(!0),v(null);try{await N.saveConnections(a.connections,P);const re=await N.getConnections();d(re),v("Default updated. Testing connection..."),f(!0);const Z=await N.testConnection();if(h(Z),Z.ok)v("Test passed. Default connection updated."),t==null||t(Z.message),setTimeout(()=>v(null),2e3);else{await N.saveConnections(a.connections,q||void 0);const ae=await N.getConnections();d(ae),v(`Test failed. Previous default preserved: ${Z.message}`)}}catch(re){await N.saveConnections(a.connections,q||void 0).catch(()=>{});const Z=await N.getConnections().catch(()=>null);Z&&d(Z),v(`Test or save failed. Previous default preserved: ${re.message}`)}finally{f(!1),C(!1)}},ar={fontSize:10,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",color:o.textMuted,fontFamily:o.font,marginBottom:6},lr={background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderRadius:7,padding:"10px 12px",marginBottom:10},cr=(a==null?void 0:a.connections)??{},Pd=(a==null?void 0:a.default)??"",Js=(a==null?void 0:a.dbtProfiles)??[],Qs=Object.fromEntries(((a==null?void 0:a.connectorStatus)??[]).map(P=>[P.driver,P])),Ys=Object.keys(cr).length,dr=Ys>0,Id=s.jsxs(s.Fragment,{children:[s.jsx("div",{style:ar,children:"Connections"}),a===null?s.jsx("div",{style:{fontSize:12,color:o.textMuted,fontFamily:o.font},children:"Loading…"}):Object.entries(cr).map(([P,q])=>{const re=(q==null?void 0:q.driver)??(q==null?void 0:q.type)??"unknown",Z=P===Pd,ae=$r[re]??o.accent;return y===P?s.jsx(xa,{t:o,editName:$e,setEditName:Ne,editDriver:xe,setEditDriver:pe,editFields:Be,setEditFields:Ue,onSave:Ae,onCancel:he,onDelete:()=>ir(P),saving:w,isNew:!1},P):s.jsxs("div",{style:{...lr,borderLeft:Z?`3px solid ${ae}`:`1px solid ${o.cellBorder}`},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[s.jsx(Nn,{driver:re,size:18,fallbackColor:ae}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:Po[re]??re}),s.jsx("span",{style:{fontSize:11,fontFamily:o.fontMono,color:o.textMuted},children:P}),Z&&(p==null?void 0:p.ok)&&s.jsx("span",{title:"Connected","aria-label":"Connected",style:{width:7,height:7,borderRadius:"50%",background:o.success,flexShrink:0,boxShadow:`0 0 0 2px ${o.success}25`}}),Z&&p&&!p.ok&&s.jsx("span",{title:p.message,"aria-label":"Disconnected",style:{width:7,height:7,borderRadius:"50%",background:o.error,flexShrink:0,boxShadow:`0 0 0 2px ${o.error}25`}}),Z&&s.jsx("span",{style:{fontSize:9,color:o.accent,fontFamily:o.font,fontWeight:600,letterSpacing:"0.05em"},children:"DEFAULT"}),s.jsx("div",{style:{flex:1}}),!Z&&s.jsx("button",{onClick:()=>Dd(P),disabled:w,style:{background:"transparent",border:`1px solid ${o.btnBorder}`,borderRadius:3,cursor:w?"not-allowed":"pointer",color:o.textMuted,fontSize:10,fontFamily:o.font,padding:"1px 6px",transition:"all 0.15s"},children:"Use"}),s.jsx("button",{onClick:()=>ne(P,q),style:{background:"transparent",border:`1px solid ${o.btnBorder}`,borderRadius:3,cursor:"pointer",color:o.textMuted,fontSize:10,fontFamily:o.font,padding:"1px 6px",transition:"all 0.15s"},children:"Edit"})]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:Object.entries(q??{}).filter(([ye])=>ye!=="driver"&&ye!=="type").map(([ye,Le])=>s.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[s.jsx("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono,minWidth:70,flexShrink:0},children:ye}),s.jsx("span",{style:{fontSize:11,color:o.textSecondary,fontFamily:o.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:PS(ye)?"••••••••":String(Le)})]},ye))})]},P)}),a!==null&&Ys===0&&s.jsx("div",{style:{...lr,color:o.textMuted,fontSize:12,fontFamily:o.font,lineHeight:1.45},children:"No saved connections yet. Import a dbt profile target or add one manually."})]}),Xs=s.jsxs("div",{style:{...lr,marginBottom:12},children:[s.jsx("div",{style:{fontSize:12,fontWeight:650,color:o.textPrimary,fontFamily:o.font},children:"Import dbt profiles.yml"}),s.jsx("div",{style:{marginTop:3,fontSize:10.5,color:o.textMuted,lineHeight:1.45,fontFamily:o.font},children:"Load a profiles.yml, profiles.yaml, profile.yml, or profile.yaml file. DuckDB, Snowflake, and Databricks targets are supported."}),s.jsxs("div",{style:{display:"flex",gap:7,marginTop:9},children:[s.jsx("input",{"aria-label":"dbt profile file or folder path",value:T,onChange:P=>g(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),J())},placeholder:"~/.dbt/profiles.yml or /path/to/profile.yaml",style:{flex:1,minWidth:0,border:`1px solid ${o.inputBorder}`,borderRadius:6,background:o.inputBg,color:o.textPrimary,padding:"7px 9px",fontSize:11.5,fontFamily:o.fontMono,outline:"none"}}),s.jsx("button",{type:"button",onClick:()=>void J(),disabled:$,style:{border:`1px solid ${o.btnBorder}`,borderRadius:6,background:o.btnBg,color:o.textSecondary,padding:"0 11px",fontSize:11,fontWeight:650,fontFamily:o.font,cursor:$?"wait":"pointer"},children:$?"Reading…":"Find profiles"})]}),R?s.jsx("div",{role:"alert",style:{marginTop:6,color:o.error,fontSize:10.5,fontFamily:o.font},children:R}):null]}),Zs=s.jsx(s.Fragment,{children:!x&&!y&&Js.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...ar,marginTop:8},children:"dbt profiles"}),s.jsx("div",{style:{display:"grid",gap:8,marginBottom:12},children:Js.map(P=>{var ye;const q=Bn(String(P.connection.driver??P.adapter)),re=$r[q]??o.accent,Z=P.missingFields.length===0,ae=((ye=a==null?void 0:a.activeConnection)==null?void 0:ye.source)==="dbt_profile"&&a.activeConnection.profileId===P.id;return s.jsxs("div",{style:{...lr,marginBottom:0,display:"flex",alignItems:"center",gap:10},children:[s.jsx(Nn,{driver:q,size:18,fallbackColor:re}),s.jsxs("div",{style:{minWidth:0,flex:1},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[s.jsx("span",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:P.profileName}),s.jsx("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono},children:P.targetName})]}),s.jsxs("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[Po[q]??P.adapter," from ",DS(P.path)]}),s.jsx("div",{style:{fontSize:10,color:Z?o.success:o.warning,fontFamily:o.font,marginTop:2},children:Z?ae?"Active runtime connection · import to save":"Ready to import and test":`Imports now · needs ${P.missingFields.join(", ")}`})]}),s.jsx("button",{onClick:()=>oe(P),disabled:w,title:P.warnings.join(" ")||void 0,style:{background:o.btnBg,border:`1px solid ${o.btnBorder}`,borderRadius:4,cursor:w?"wait":"pointer",color:o.textSecondary,fontSize:11,fontFamily:o.font,padding:"4px 8px",flexShrink:0},children:"Import & test"})]},P.id)})})]})}),Md=s.jsx(s.Fragment,{children:!x&&!y&&Object.keys(cr).length===0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...ar,marginTop:8},children:"Quick Connect"}),s.jsx("div",{style:{display:"grid",gap:6,marginBottom:12},children:_S.map(P=>s.jsxs("button",{onClick:async()=>{C(!0);try{const q={...cr,[P.name]:P.config};await N.saveConnections(q,P.name);const re=await N.getConnections();d(re),f(!0);const Z=await N.testConnection();h(Z),f(!1)}finally{C(!1)}},disabled:w,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderRadius:7,cursor:w?"not-allowed":"pointer",textAlign:"left",transition:"border-color 0.15s"},children:[s.jsx(Nn,{driver:P.config.driver,size:18}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:P.label}),s.jsx("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:P.description})]})]},P.name))})]})}),Ld=s.jsx(s.Fragment,{children:x?s.jsx(xa,{t:o,editName:$e,setEditName:Ne,editDriver:xe,setEditDriver:pe,editFields:Be,setEditFields:Ue,onSave:Ae,onCancel:he,saving:w,isNew:!0}):s.jsxs("button",{onClick:ve,style:{width:"100%",padding:"7px 0",borderRadius:6,border:`1px dashed ${o.cellBorder}`,background:"transparent",color:o.textSecondary,fontSize:12,fontFamily:o.font,fontWeight:500,cursor:"pointer",marginBottom:12,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[s.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"Add Connection"]})}),Nd=s.jsx(s.Fragment,{children:E&&s.jsx("div",{style:{fontSize:11,fontFamily:o.font,padding:"4px 10px",borderRadius:4,marginBottom:8,color:ya(E,o),background:`${ya(E,o)}12`},children:E})}),Bd=s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:tt,disabled:c||!dr,style:{width:"100%",padding:"7px 0",borderRadius:6,border:`1px solid ${o.btnBorder}`,background:o.btnBg,color:o.textSecondary,fontSize:12,fontFamily:o.font,fontWeight:500,cursor:c||!dr?"not-allowed":"pointer",marginBottom:8,opacity:c||!dr?.7:1,transition:"all 0.15s"},children:c?"Testing...":dr?"Test Connection":"Add connection to test"}),p&&s.jsxs("div",{style:{fontSize:12,fontFamily:o.font,color:p.ok?o.success:o.error,background:p.ok?`${o.success}12`:`${o.error}12`,border:`1px solid ${p.ok?o.success:o.error}40`,borderRadius:6,padding:"7px 10px",marginBottom:12},children:[p.ok?"✓ ":"✗ ",p.message]})]}),Fd=s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...ar,marginTop:4},children:"Catalog"}),s.jsx("div",{className:i?"dql-connection-catalog-grid":void 0,style:{display:"grid",gridTemplateColumns:i?"repeat(auto-fit, minmax(180px, 1fr))":"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginBottom:12},children:co.map(({driver:P,label:q})=>{const re=$r[P]??o.accent,Z=RS[P]??"",ae=Qs[P],ye=(ae==null?void 0:ae.installed)??!0,Le=(ae==null?void 0:ae.builtIn)??!1,on=j===P;return s.jsxs("div",{style:{background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderRadius:8,padding:"10px 12px",display:"flex",flexDirection:"column",gap:4,minHeight:76,position:"relative",transition:"border-color 0.15s"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx(Nn,{driver:P,size:18,fallbackColor:re}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:q})]}),s.jsx("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font,lineHeight:1.35},children:Z}),s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginTop:"auto"},children:[s.jsx("span",{style:{fontSize:9,fontFamily:o.font,fontWeight:600,color:ye?o.success:o.warning,letterSpacing:"0.05em",textTransform:"uppercase"},children:Le?"Built in":ye?"Installed":"Install required"}),!ye&&s.jsx("button",{onClick:()=>de(P),disabled:!!j,title:ae==null?void 0:ae.installCommand,style:{border:`1px solid ${o.btnBorder}`,background:o.btnBg,color:o.textSecondary,borderRadius:4,padding:"2px 7px",fontSize:10,fontFamily:o.font,cursor:j?"not-allowed":"pointer",whiteSpace:"nowrap"},children:on?"Installing...":"Install"})]}),s.jsx("code",{style:{fontSize:9,color:o.textMuted,fontFamily:o.fontMono},children:P})]},P)})})]}),ct=!!(a&&Object.values(a.connections??{}).some(P=>!Yn(P))),Re=a==null?void 0:a.metadataStatus,zd=Do(U),qd=ct?s.jsxs("div",{style:{maxWidth:640,border:`1px solid ${o.cellBorder}`,borderRadius:12,background:o.cellBg,padding:"16px 18px",display:"flex",flexDirection:"column",gap:12},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:14,fontWeight:700,color:o.textPrimary,fontFamily:o.font},children:"Metadata scope"}),s.jsx("div",{style:{fontSize:11.5,color:o.textMuted,marginTop:3,lineHeight:1.5,fontFamily:o.font},children:"DQL synchronizes this authorized scope into local SQLite. Warm Ask, Notebook, and Block Studio searches use that index instead of scanning the warehouse."})]}),s.jsxs("div",{style:{border:`1px solid ${o.cellBorder}`,borderRadius:9,padding:"11px 12px",background:o.editorBg,display:"flex",flexDirection:"column",gap:9},children:[s.jsxs("div",{style:{fontSize:11.5,lineHeight:1.5,color:o.textSecondary,fontFamily:o.font},children:[s.jsx("strong",{style:{color:o.textPrimary},children:"Only add schemas outside the configured dbt project."})," ","Relations already present in the current dbt manifest are indexed automatically and should not be selected again."]}),s.jsx("div",{children:s.jsx("button",{type:"button",onClick:()=>void qt(),disabled:ge||Q||!(p!=null&&p.ok),style:{height:31,padding:"0 12px",borderRadius:8,border:`1px solid ${o.cellBorder}`,background:o.cellBg,color:o.textSecondary,fontSize:11.5,fontWeight:650,cursor:ge||Q||!(p!=null&&p.ok)?"not-allowed":"pointer",opacity:p!=null&&p.ok?1:.55,fontFamily:o.font},children:ge?"Finding available schemas…":"Find available databases & schemas"})}),ue?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{fontSize:10.5,color:o.textMuted,fontFamily:o.font},children:[ue.dbtScopes.reduce((P,q)=>P+q.schemas.length,0).toLocaleString()," dbt-covered schema(s)"," · ",AS(ue).toLocaleString()," additional schema(s) available"," · ",ue.queryCount.toLocaleString()," discovery query(s)"]}),ue.scopes.map(P=>s.jsxs("div",{style:{borderTop:`1px solid ${o.cellBorder}`,paddingTop:7},children:[s.jsx("div",{style:{fontSize:10.5,fontWeight:700,color:o.textPrimary,fontFamily:o.fontMono,marginBottom:5},children:P.catalogOrDatabase}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:5},children:P.schemas.map(q=>{const re=ES(zd,P.catalogOrDatabase,q.name);return s.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:7,fontSize:11,lineHeight:1.35,color:q.inDbtProject?o.textMuted:o.textSecondary,fontFamily:o.font,cursor:q.inDbtProject?"default":"pointer"},children:[s.jsx("input",{type:"checkbox",checked:q.inDbtProject||re,disabled:q.inDbtProject||Q,onChange:Z=>Ut(P.catalogOrDatabase,q.name,Z.target.checked),style:{marginTop:1}}),s.jsxs("span",{children:[s.jsx("span",{style:{fontFamily:o.fontMono},children:q.name}),q.inDbtProject?` · in dbt (${q.dbtRelationCount} relation${q.dbtRelationCount===1?"":"s"}), included automatically`:" · outside dbt, select only if reporting needs it"]})]},`${P.catalogOrDatabase}.${q.name}`)})})]},P.catalogOrDatabase)),ue.truncated?s.jsx("div",{style:{fontSize:10.5,color:"var(--status-warning)",fontFamily:o.font},children:"Discovery reached its safety limit. Narrow the connection role or enter another known database/schema manually."}):null]}):null]}),s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontFamily:o.font},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:o.textSecondary},children:"Index mode"}),s.jsxs("select",{value:D,onChange:P=>Y(P.target.value),disabled:Q,style:{height:34,borderRadius:7,border:`1px solid ${o.cellBorder}`,background:o.cellBg,color:o.textPrimary,padding:"0 10px",fontFamily:o.font},children:[s.jsx("option",{value:"dbt_relations",children:"Use exact dbt project relations (recommended)"}),s.jsx("option",{value:"dbt_plus_selected",children:"dbt relations plus selected schemas"}),s.jsx("option",{value:"selected_scopes",children:"Selected databases/catalogs and schemas"})]})]}),D!=="dbt_relations"?s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontFamily:o.font},children:[s.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:o.textSecondary},children:"Databases/catalogs and schemas"}),s.jsx("textarea",{value:U,onChange:P=>te(P.target.value),disabled:Q,placeholder:`ANALYTICS_PROD: SALES, FINANCE
|
|
442
|
-
REFERENCE_DATA: SHARED`,rows:4,style:{resize:"vertical",borderRadius:7,border:`1px solid ${o.cellBorder}`,background:o.cellBg,color:o.textPrimary,padding:"8px 10px",fontFamily:o.fontMono,fontSize:11.5,lineHeight:1.5}}),s.jsx("span",{style:{fontSize:10.5,color:o.textMuted},children:"Only additional schemas outside dbt belong here. Discovery is explicit and setup-only; Ask AI never scans the warehouse for available schemas."})]}):null,Re?s.jsxs("div",{style:{fontSize:11.5,color:Re.state==="ready"?"var(--status-success)":"var(--status-warning)",fontFamily:o.font},children:[Re.state==="ready"?"Ready":Re.state==="stale"?"Refresh required":"Not synchronized"," · ",Re.relationCount.toLocaleString()," relations"," · ",Re.columnCount.toLocaleString()," columns",Re.capturedAt?` · ${new Date(Re.capturedAt).toLocaleString()}`:""]}):null,Re!=null&&Re.observedTarget?s.jsx("div",{style:{fontSize:10.5,color:o.textMuted,fontFamily:o.fontMono},children:[Re.observedTarget.accountOrWorkspace,Re.observedTarget.role,Re.observedTarget.warehouse,Re.observedTarget.defaultCatalogOrDatabase,Re.observedTarget.defaultSchema].filter(Boolean).join(" · ")}):null,ee?s.jsx("div",{style:{fontSize:11.5,color:ee.toLowerCase().includes("failed")||ee.toLowerCase().includes("error")?"var(--status-error)":o.textSecondary,fontFamily:o.font},children:ee}):null,s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void Wt(),disabled:Q||!(p!=null&&p.ok),style:{height:32,padding:"0 13px",borderRadius:8,border:"none",background:o.accent,color:"var(--accent-fg)",fontSize:12,fontWeight:700,cursor:Q||!(p!=null&&p.ok)?"not-allowed":"pointer",opacity:Q||!(p!=null&&p.ok)?.55:1,fontFamily:o.font},children:Q?"Synchronizing…":"Apply and synchronize"}),s.jsx("button",{type:"button",onClick:()=>void z(),disabled:Q||(Re==null?void 0:Re.state)==="missing",style:{height:32,padding:"0 13px",borderRadius:8,border:`1px solid ${o.cellBorder}`,background:o.cellBg,color:o.textSecondary,fontSize:12,fontWeight:650,cursor:Q?"not-allowed":"pointer",fontFamily:o.font},children:"Refresh metadata"})]}),p!=null&&p.ok?null:s.jsx("div",{style:{fontSize:10.5,color:o.textMuted,fontFamily:o.font},children:"Test the active connection before applying its metadata scope."})]}):null,ei=s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:17,fontWeight:700,color:o.textPrimary,fontFamily:o.font},children:"Database connection"}),s.jsx("div",{style:{fontSize:12.5,color:o.textMuted,marginTop:3,lineHeight:1.5,fontFamily:o.font},children:"Import a dbt profile or configure the warehouse directly. The candidate is tested before it replaces the active connection."})]}),s.jsxs("div",{style:{border:`1px solid ${p!=null&&p.ok?"var(--status-success-border)":"var(--border-subtle)"}`,borderRadius:12,background:o.cellBg,padding:"16px 18px",display:"flex",alignItems:"center",gap:12,maxWidth:640},children:[s.jsx("span",{style:{width:36,height:36,borderRadius:9,background:ct?"var(--status-success-bg)":"var(--status-warning-bg)",color:ct?"var(--status-success)":"var(--status-warning)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx(or,{size:17,strokeWidth:1.75})}),s.jsxs("div",{style:{flex:1,minWidth:0,fontFamily:o.font},children:[s.jsxs("div",{style:{fontSize:13,fontWeight:700,color:o.textPrimary},children:[Po[String(((ni=(ti=a==null?void 0:a.connections)==null?void 0:ti[(a==null?void 0:a.default)??""])==null?void 0:ni.driver)??"")]??((oi=(ri=a==null?void 0:a.connections)==null?void 0:ri[(a==null?void 0:a.default)??""])==null?void 0:oi.driver)??"No connection yet",ct?" · configured":""]}),s.jsx("div",{style:{fontSize:11.5,marginTop:2,color:c?o.textMuted:p?p.ok?"var(--status-success)":"var(--status-error)":o.textMuted},children:c?"Testing…":p?p.ok?`Test passed · ${p.message}`:`Test failed · ${p.message}`:ct?"Configured — run Test connection to verify.":"Add a connection below to get started."})]}),s.jsx("button",{type:"button",onClick:()=>void tt(),disabled:c||!ct,style:{display:"inline-flex",alignItems:"center",gap:6,height:30,padding:"0 13px",borderRadius:8,border:`1px solid ${o.cellBorder}`,background:o.cellBg,color:o.textSecondary,fontSize:12,fontWeight:650,cursor:ct?"pointer":"not-allowed",fontFamily:o.font,flexShrink:0,opacity:ct?1:.55},children:c?"Testing…":"Test connection"})]}),s.jsxs("div",{style:{maxWidth:640},children:[Xs,Zs]}),s.jsx(FS,{t:o,driver:De,fields:et,onDriverChange:rn,onFieldsChange:gt,onSave:()=>void Tn(),saving:w,saveMessage:E,connectorStatus:Qs[De],installing:j===De,onInstall:()=>void de(De)}),qd]});if(l)return ei;if(i){const P=n.settingsTab,q=M.some(Z=>Z.configured&&Z.enabled),re=(Z,ae,ye,Le)=>s.jsxs("button",{type:"button",onClick:ye,style:{display:"flex",alignItems:"center",gap:9,padding:"8px 10px",borderRadius:7,border:"none",cursor:"pointer",textAlign:"left",fontSize:12.5,fontWeight:600,fontFamily:o.font,width:"100%",background:Z?"var(--accent-dim)":"transparent",color:Z?o.accent:o.textSecondary},children:[s.jsx("span",{style:{flex:1},children:ae}),Le]},ae);return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:NS}),s.jsxs("div",{style:{display:"flex",gap:0,alignItems:"stretch",minHeight:0},children:[s.jsxs("nav",{"aria-label":"Settings sections",style:{width:"clamp(190px, 17vw, 240px)",flexShrink:0,borderRight:`1px solid ${o.cellBorder}`,padding:"10px 10px 10px 0",display:"flex",flexDirection:"column",gap:2,alignSelf:"flex-start",position:"sticky",top:0},children:[re(P==="overview","Overview",()=>r({type:"SET_SETTINGS_TAB",tab:"overview"})),re(P==="project","Project & dbt",()=>r({type:"SET_SETTINGS_TAB",tab:"project"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:(V==null?void 0:V.status)==="failed"?"var(--status-error)":(V==null?void 0:V.status)==="running"||(V==null?void 0:V.status)==="queued"?"var(--status-info)":K?"var(--status-success)":"var(--status-warning)"},title:(V==null?void 0:V.status)==="failed"?"Needs attention":(V==null?void 0:V.status)==="running"||(V==null?void 0:V.status)==="queued"?"Preparing":K?"Ready":"Missing"})),re(P==="database","Database",()=>r({type:"SET_SETTINGS_TAB",tab:"database"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:ct?"var(--status-success)":"var(--status-warning)"},title:ct?"Configured":"Missing"})),re(P==="ai","AI provider",()=>r({type:"SET_SETTINGS_TAB",tab:"ai"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:q?"var(--status-success)":"var(--status-warning)"},title:q?"Configured":"Optional · missing"})),re(P==="memory","Agent memory",()=>r({type:"SET_SETTINGS_TAB",tab:"memory"})),s.jsx("div",{style:{height:1,background:o.cellBorder,margin:"10px 10px 10px 0"}}),re(P==="advanced","Advanced",()=>r({type:"SET_SETTINGS_TAB",tab:"advanced"}),s.jsx("span",{style:{fontSize:10,color:o.textMuted},children:"Advanced"}))]}),s.jsx("div",{style:{flex:1,minWidth:0,padding:"0 0 24px 20px"},children:P==="overview"?s.jsx(LS,{dbtConfigured:K,dbtPreparation:V,databaseConfigured:ct,databaseTest:p,providers:M}):P==="project"?s.jsx(CS,{onConfigured:()=>{G(!0),N.getOnboardingStatus().then(Z=>I(Z.preparation??null)).catch(()=>{})}}):P==="advanced"?s.jsx(Ro,{embedded:!0,section:"advanced"}):P==="database"?ei:P==="ai"?s.jsx(Ro,{embedded:!0,section:"providers",onProviderConfigured:Z=>B(ae=>ae.map(ye=>ye.id===Z.id?Z:{...ye,active:!1}))}):s.jsx(Ro,{embedded:!0,section:"memory"})})]})]})}return s.jsxs(Ps,{title:"Connections",bodyPadding:12,children:[Id,Xs,Zs,Md,Ld,Nd,Bd,Fd]})}function LS({dbtConfigured:e,dbtPreparation:t,databaseConfigured:n,databaseTest:r,providers:o}){const{state:i,dispatch:l}=Se(),a=qe[i.themeMode],d=o.find(p=>p.active&&p.configured)??o.find(p=>p.enabled&&p.configured),c=[{title:"Project & dbt",detail:(t==null?void 0:t.message)??(e?"Project configuration, dbt artifacts, and governed search indexes are ready.":"Choose a local dbt project or Git repository."),state:(t==null?void 0:t.status)==="failed"||(t==null?void 0:t.status)==="cancelled"?"failed":(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="queued"?"preparing":e?"configured":"missing",tab:"project",icon:s.jsx(Cn,{size:18})},{title:"Database",detail:r!=null&&r.ok||r?r.message:n?"Credentials are configured. Run Test to verify reachability.":"Import a dbt profile or enter warehouse credentials.",state:r?r.ok?"passed":"failed":n?"configured":"missing",tab:"database",icon:s.jsx(or,{size:18})},{title:"AI provider",detail:d?`${d.label}${d.model?` · ${d.model}`:""}. Run Test to verify reachability.`:"Optional. Deterministic and non-AI workflows remain available.",state:d?"configured":"missing",tab:"ai",icon:s.jsx(Vc,{size:18}),optional:!0}],f={missing:"Missing",configured:"Configured",preparing:"Preparing",passed:"Test passed",failed:"Test failed"};return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18,maxWidth:820},children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:20,fontWeight:750,color:a.textPrimary},children:"Settings overview"}),s.jsx("div",{style:{fontSize:12.5,color:a.textMuted,marginTop:4,lineHeight:1.5},children:"One place for project, data, AI, memory, and advanced runtime configuration."})]}),s.jsxs("button",{type:"button",onClick:()=>l({type:"OPEN_SETUP"}),style:{display:"inline-flex",alignItems:"center",gap:7,height:34,padding:"0 15px",borderRadius:8,border:"none",background:a.accent,color:"#fff",fontSize:12,fontWeight:700,cursor:"pointer",fontFamily:a.font,whiteSpace:"nowrap"},children:[s.jsx(fx,{size:14})," Guided Setup"]})]}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:12},children:c.map(p=>{const h=p.state==="configured"||p.state==="passed",y=p.state==="preparing",S=p.state==="failed",x=S?"var(--status-error)":y?"var(--status-info)":h?"var(--status-success)":"var(--status-warning)",b=S?"var(--status-error-bg)":y?"var(--status-info-bg)":h?"var(--status-success-bg)":"var(--status-warning-bg)";return s.jsxs("button",{type:"button",onClick:()=>l({type:"SET_SETTINGS_TAB",tab:p.tab}),style:{border:"1px solid var(--border-subtle)",borderRadius:12,background:a.cellBg,padding:16,textAlign:"left",cursor:"pointer",fontFamily:a.font,minHeight:158,display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{width:36,height:36,borderRadius:9,display:"inline-flex",alignItems:"center",justifyContent:"center",color:x,background:b},children:h?s.jsx(zc,{size:18}):p.icon}),s.jsx("span",{style:{fontSize:13.5,fontWeight:700,color:a.textPrimary,marginTop:12},children:p.title}),s.jsxs("span",{style:{fontSize:11,fontWeight:700,color:x,marginTop:4},children:[f[p.state],p.optional?" · optional":""]}),s.jsx("span",{style:{fontSize:11.5,color:a.textMuted,lineHeight:1.45,marginTop:7},children:p.detail})]},p.title)})}),d?null:s.jsx("div",{style:{border:"1px solid var(--status-info-border)",background:"var(--status-info-bg)",color:a.textSecondary,borderRadius:10,padding:"11px 13px",fontSize:11.5,lineHeight:1.5},children:"Limited-AI mode is active: SQL execution, dbt metadata, lineage, deterministic helpers, and other non-AI paths continue to work. Configure a provider when you want governed Ask and AI-assisted authoring."})]})}const NS=`
|
|
443
|
-
.dql-connection-page-stack {
|
|
444
|
-
display: grid;
|
|
445
|
-
gap: 16px;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.dql-connection-page-grid {
|
|
449
|
-
display: grid;
|
|
450
|
-
grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
|
|
451
|
-
gap: 16px;
|
|
452
|
-
align-items: start;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
@media (max-width: 920px) {
|
|
456
|
-
.dql-connection-page-grid {
|
|
457
|
-
grid-template-columns: minmax(0, 1fr);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
@keyframes dql-connector-shimmer {
|
|
462
|
-
0% { opacity: 1; }
|
|
463
|
-
50% { opacity: 0.45; }
|
|
464
|
-
100% { opacity: 1; }
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
.dql-connector-installing {
|
|
468
|
-
animation: dql-connector-shimmer 1.4s ease-in-out infinite;
|
|
469
|
-
}
|
|
470
|
-
`;function xa({t:e,editName:t,setEditName:n,editDriver:r,setEditDriver:o,editFields:i,setEditFields:l,onSave:a,onCancel:d,onDelete:c,saving:f,isNew:p}){const h=Ks[r],y=(h==null?void 0:h.fields)??[],S={background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:4,color:e.textPrimary,fontSize:11,fontFamily:e.fontMono,padding:"4px 8px",outline:"none",width:"100%"},x={fontSize:9,fontWeight:600,color:e.textMuted,fontFamily:e.font,letterSpacing:"0.05em",textTransform:"uppercase",marginBottom:2};return s.jsxs("div",{style:{background:e.cellBg,border:`1px solid ${e.accent}40`,borderRadius:7,padding:"10px 12px",marginBottom:10},children:[s.jsx("div",{style:{fontSize:11,fontWeight:600,color:e.accent,fontFamily:e.font,marginBottom:8},children:p?"New Connection":"Edit Connection"}),s.jsxs("div",{style:{marginBottom:6},children:[s.jsx("div",{style:x,children:"Name"}),s.jsx("input",{style:S,value:t,onChange:b=>n(b.target.value),placeholder:"e.g. production"})]}),s.jsxs("div",{style:{marginBottom:6},children:[s.jsx("div",{style:x,children:"Driver"}),s.jsx("select",{style:{...S,fontFamily:e.font},value:r,onChange:b=>{o(b.target.value),l({})},children:co.map(b=>s.jsx("option",{value:b.driver,children:b.label},b.driver))})]}),y.map(b=>s.jsxs("div",{style:{marginBottom:6},children:[s.jsxs("div",{style:x,children:[b.label,b.required?" *":""]}),b.type==="select"?s.jsxs("select",{style:{...S,fontFamily:e.font},value:i[b.key]??"",onChange:w=>l({...i,[b.key]:w.target.value}),children:[s.jsx("option",{value:"",children:"Default"}),(b.options??[]).map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))]}):b.type==="checkbox"?s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textSecondary,fontFamily:e.font},children:[s.jsx("input",{type:"checkbox",checked:i[b.key]==="true",onChange:w=>l({...i,[b.key]:w.target.checked?"true":"false"})}),"Enabled"]}):b.type==="textarea"?s.jsx("textarea",{style:{...S,minHeight:72,resize:"vertical"},value:i[b.key]??"",placeholder:b.placeholder??"",onChange:w=>l({...i,[b.key]:w.target.value})}):s.jsx("input",{style:S,type:b.type==="password"?"password":b.type==="number"?"number":"text",value:i[b.key]??"",placeholder:b.placeholder??"",onChange:w=>l({...i,[b.key]:w.target.value})}),b.helpText&&s.jsx("div",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font,marginTop:3,lineHeight:1.35},children:b.helpText})]},b.key)),s.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[s.jsx("button",{onClick:a,disabled:f,style:{flex:1,padding:"5px 0",borderRadius:5,border:"none",background:e.accent,color:"#fff",fontSize:11,fontFamily:e.font,fontWeight:600,cursor:f?"not-allowed":"pointer",opacity:f?.6:1},children:f?"Saving…":"Save"}),s.jsx("button",{onClick:d,style:{padding:"5px 12px",borderRadius:5,border:`1px solid ${e.btnBorder}`,background:"transparent",color:e.textSecondary,fontSize:11,fontFamily:e.font,cursor:"pointer"},children:"Cancel"}),c&&!p&&s.jsx("button",{onClick:c,style:{padding:"5px 12px",borderRadius:5,border:`1px solid ${e.error}40`,background:"transparent",color:e.error,fontSize:11,fontFamily:e.font,cursor:"pointer"},children:"Delete"})]})]})}function BS(e,t){if(e==="duckdb")return["filepath"];if(e==="databricks")return["host","httpPath","database","schema","authMethod","token"];if(e!=="snowflake")return[];const n=["account","warehouse","database","schema","username","authMethod"];switch(t.authMethod||"password"){case"key_pair":return[...n,"privateKeyPath","privateKey","privateKeyPassphrase"];case"external_browser":return n;case"oauth":case"programmatic_access_token":return[...n,"token"];case"oauth_authorization_code":return[...n,"oauthClientId","oauthClientSecret"];case"oauth_client_credentials":return[...n,"oauthClientId","oauthClientSecret","oauthTokenRequestUrl"];case"workload_identity":return[...n,"workloadIdentityProvider","token"];case"mfa":return[...n,"password","passcode"];default:return[...n,"password"]}}const ba=new Set(["filepath","httpPath","accessUrl"]);function FS({t:e,driver:t,fields:n,onDriverChange:r,onFieldsChange:o,onSave:i,saving:l,saveMessage:a,connectorStatus:d,installing:c,onInstall:f}){const[p,h]=u.useState(!1),y=Ks[t],S=(y==null?void 0:y.fields)??[],x=BS(t,n),b=new Set(x),w=S.filter(v=>b.has(v.key)),C=S.filter(v=>!b.has(v.key)),E=(v,j)=>o({...n,[v]:j});return s.jsxs("div",{style:{border:`1px solid ${e.cellBorder}`,borderRadius:12,background:e.cellBg,padding:18,display:"flex",flexDirection:"column",gap:13,maxWidth:640},children:[s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4,maxWidth:280},children:[s.jsx("span",{style:{fontSize:11,fontWeight:650,color:e.textSecondary,fontFamily:e.font},children:"Warehouse"}),s.jsx("select",{value:t,onChange:v=>r(v.target.value),style:{border:`1px solid ${e.cellBorder}`,background:e.cellBg,borderRadius:8,padding:"8px 9px",fontSize:12.5,fontFamily:e.font,color:e.textPrimary,outline:"none"},children:co.map(({driver:v,label:j})=>s.jsx("option",{value:v,children:j},v))})]}),s.jsx(zS,{t:e,driver:t,label:(y==null?void 0:y.label)??t,status:d,installing:c,onInstall:f}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:w.map(v=>s.jsx(va,{t:e,field:v,value:n[v.key]??"",onChange:j=>E(v.key,j),fullWidth:ba.has(v.key)},v.key))}),C.length>0&&s.jsxs("details",{open:p,onToggle:v=>h(v.target.open),style:{borderTop:`1px solid ${e.headerBorder}`,paddingTop:12},children:[s.jsxs("summary",{style:{cursor:"pointer",listStyle:"none",display:"flex",alignItems:"center",gap:7,fontSize:11.5,fontWeight:650,color:e.textSecondary,fontFamily:e.font},children:[s.jsx("span",{style:{color:e.textMuted,fontSize:10,transform:p?"rotate(90deg)":"none",transition:"transform 0.15s",display:"inline-block"},children:"▶"}),"Advanced options",s.jsxs("span",{style:{fontWeight:400,color:e.textMuted,fontSize:10.5},children:[C.length," more"]})]}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12},children:C.map(v=>s.jsx(va,{t:e,field:v,value:n[v.key]??"",onChange:j=>E(v.key,j),fullWidth:ba.has(v.key)||v.type==="textarea"},v.key))})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,paddingTop:4,borderTop:`1px solid ${e.headerBorder}`},children:[s.jsx("span",{style:{fontSize:10.5,color:e.textMuted,flex:1,fontFamily:e.font},children:a??"Changes apply after a successful test."}),s.jsx("button",{type:"button",onClick:i,disabled:l,style:{height:30,padding:"0 15px",borderRadius:8,border:"none",background:e.accent,color:"#fff",fontSize:12,fontWeight:650,cursor:l?"not-allowed":"pointer",fontFamily:e.font,boxShadow:"0 1px 4px rgba(107,93,211,0.25)",opacity:l?.7:1},children:l?"Saving…":"Save connection"})]})]})}function zS({t:e,driver:t,label:n,status:r,installing:o,onInstall:i}){const l=(r==null?void 0:r.builtIn)??!0,a=(r==null?void 0:r.installed)??!0,d=!a&&!l,c=o||d?e.warning:e.success,f=o||d?"var(--status-warning-bg)":"var(--status-success-bg)",p=o||d?"var(--status-warning-border)":"var(--status-success-border)",h=o?"Installing connector package…":l?"Built in — no installation needed":a?"Connector installed and ready":"Connector package required before you can connect";return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,border:`1px solid ${p}`,borderRadius:9,background:f,padding:"10px 12px"},children:[s.jsx(Nn,{driver:t,size:18,fallbackColor:$r[t]??e.accent}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{fontSize:12,fontWeight:650,color:e.textPrimary,fontFamily:e.font},children:[n," connector"]}),s.jsx("div",{className:o?"dql-connector-installing":void 0,style:{fontSize:11,color:c,fontFamily:e.font,marginTop:1},children:h})]}),d||o?s.jsx("button",{type:"button",onClick:i,disabled:o,title:r==null?void 0:r.installCommand,style:{flexShrink:0,height:28,padding:"0 12px",borderRadius:8,border:`1px solid ${e.accent}`,background:"var(--accent-dim)",color:e.accent,fontSize:11.5,fontWeight:650,cursor:o?"not-allowed":"pointer",fontFamily:e.font,opacity:o?.75:1},children:o?"Installing…":"Install connector"}):s.jsxs("span",{style:{flexShrink:0,display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:650,color:c,fontFamily:e.font},children:[s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})}),l?"Ready":"Installed"]})]})}function va({t:e,field:t,value:n,onChange:r,fullWidth:o}){const[i,l]=u.useState(!1),d={border:`1px solid ${i?e.accent:e.cellBorder}`,background:e.cellBg,borderRadius:8,padding:"8px 10px",fontSize:12,fontFamily:e.fontMono,color:e.textPrimary,outline:"none",width:"100%",boxSizing:"border-box"},c={display:"flex",flexDirection:"column",gap:4,gridColumn:o?"1 / -1":void 0},f=s.jsxs("span",{style:{fontSize:11,fontWeight:650,color:e.textSecondary,fontFamily:e.font},children:[t.label,t.required?" *":""]});return t.type==="checkbox"?s.jsxs("label",{style:{...c,flexDirection:"row",alignItems:"center",gap:8},children:[s.jsx("input",{type:"checkbox",checked:n==="true",onChange:p=>r(p.target.checked?"true":"false")}),f]}):s.jsxs("label",{style:c,children:[f,t.type==="select"?s.jsxs("select",{value:n,onChange:p=>r(p.target.value),onFocus:()=>l(!0),onBlur:()=>l(!1),style:{...d,fontFamily:e.font,fontSize:12.5,padding:"8px 9px"},children:[s.jsx("option",{value:"",children:"Default"}),(t.options??[]).map(p=>s.jsx("option",{value:p.value,children:p.label},p.value))]}):t.type==="textarea"?s.jsx("textarea",{value:n,placeholder:t.placeholder??"",onChange:p=>r(p.target.value),onFocus:()=>l(!0),onBlur:()=>l(!1),style:{...d,minHeight:72,resize:"vertical"}}):s.jsx("input",{type:t.type==="password"?"password":t.type==="number"?"number":"text",value:n,placeholder:t.placeholder??"",onChange:p=>r(p.target.value),onFocus:()=>l(!0),onBlur:()=>l(!1),style:d}),t.helpText&&s.jsx("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font,lineHeight:1.35},children:t.helpText})]})}const qS=Object.freeze(Object.defineProperty({__proto__:null,ConnectionPanel:yd},Symbol.toStringTag,{value:"Module"}));function US({type:e}){const t=cb[e]??"#8b949e";return s.jsx("span",{style:{color:t,fontSize:10,fontWeight:700,textTransform:"uppercase",minWidth:34},title:Qc[e]??e,children:db[e]??e.slice(0,4).toUpperCase()})}function WS({value:e,onChange:t,placeholder:n,t:r}){return s.jsx("input",{value:e,onChange:o=>t(o.target.value),placeholder:n,style:{width:"100%",padding:"7px 9px",borderRadius:6,border:`1px solid ${r.headerBorder}`,background:r.sidebarBg,color:r.textPrimary,fontSize:12,outline:"none"}})}function xd({node:e,t,onClick:n,secondary:r}){return s.jsxs("button",{onClick:n,style:{width:"100%",textAlign:"left",background:"transparent",border:"none",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:t.textPrimary},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[s.jsx(US,{type:e.type}),s.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},title:e.name,children:e.name})]}),(r||e.domain)&&s.jsx("div",{style:{marginLeft:40,marginTop:2,color:t.textMuted,fontSize:11},children:r??e.domain})]})}const KS=30,Io=200;function Ye(e){const t=e.metadata??{},n=[];return e.domain&&n.push(e.domain),e.type==="term"&&typeof t.termType=="string"&&n.push(t.termType),e.owner&&n.push(e.owner),e.status&&n.push(e.status),e.type==="business_view"&&typeof t.description=="string"&&n.push(t.description),n.length>0?n.join(" · "):void 0}function Mo({Icon:e,label:t,value:n,detail:r,t:o}){return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${o.headerBorder}`,borderRadius:6,padding:"7px 9px",background:o.inputBg,minWidth:0},title:r,children:[s.jsx(e,{size:14,strokeWidth:1.8,color:o.accent,style:{flexShrink:0}}),s.jsx("div",{style:{color:o.textMuted,fontSize:10,fontWeight:800,textTransform:"uppercase",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:t}),s.jsx("div",{style:{marginLeft:"auto",color:o.textPrimary,fontSize:15,fontWeight:800,lineHeight:1,flexShrink:0},children:n})]})}function Ve({title:e,nodes:t,t:n,onSelect:r,secondaryFor:o}){const i=t.length>KS,[l,a]=u.useState(!i),[d,c]=u.useState(Io);if(t.length===0)return null;const f=l?Math.min(d,t.length):0,p=Math.max(0,t.length-f);return s.jsxs("div",{style:{padding:"8px 0",borderTop:`1px solid ${n.headerBorder}`},children:[s.jsxs("button",{onClick:()=>a(h=>!h),"aria-expanded":l,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"0 8px 6px",color:n.textMuted,fontSize:11,fontWeight:700,textTransform:"uppercase",background:"transparent",border:"none",cursor:"pointer",textAlign:"left"},children:[s.jsx("span",{style:{display:"inline-block",width:10},children:l?"▾":"▸"}),s.jsx("span",{children:e}),s.jsx("span",{style:{marginLeft:"auto",fontWeight:500},children:t.length})]}),l&&t.slice(0,f).map(h=>s.jsx(xd,{node:h,t:n,onClick:()=>r(h),secondary:o==null?void 0:o(h)},h.id)),l&&p>0&&s.jsxs("button",{onClick:()=>c(h=>h+Io),style:{width:"100%",margin:"4px 0 0",padding:"6px 8px",background:"transparent",border:"none",color:n.textMuted,fontSize:11,cursor:"pointer",textAlign:"left"},children:["Show ",Math.min(Io,p)," more (",p," hidden)"]})]})}function VS({variant:e="sidebar"}){const{state:t,dispatch:n}=Se(),r=qe[t.themeMode],o=e==="page",[i,l]=u.useState(()=>typeof window<"u"?window.innerWidth<700:!1),[a,d]=u.useState(!0),[c,f]=u.useState([]),[p,h]=u.useState([]),[y,S]=u.useState(""),[x,b]=u.useState([]),w=u.useCallback(async()=>{d(!0);const g=await N.fetchLineage();f(g.nodes??[]),h(g.edges??[]),d(!1)},[]);u.useEffect(()=>{w()},[w]),u.useEffect(()=>{if(!o)return;const g=()=>l(window.innerWidth<700);return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[o]),u.useEffect(()=>{let g=!1;if(y.trim().length<2){b([]);return}return N.searchLineage(y.trim()).then($=>{g||b($.matches??[])}),()=>{g=!0}},[y]);const C=u.useCallback(g=>{n({type:"OPEN_LINEAGE_DETAIL",nodeId:g.id})},[n]),[E,v]=u.useState("type"),j=u.useMemo(()=>({terms:c.filter(g=>g.type==="term"),businessViews:c.filter(g=>g.type==="business_view"),dashboards:c.filter(g=>g.type==="dashboard"),notebooks:c.filter(g=>g.type==="notebook"),apps:c.filter(g=>g.type==="app"),charts:c.filter(g=>g.type==="chart"),blocks:c.filter(g=>g.type==="block"),metrics:c.filter(g=>g.type==="metric"),dimensions:c.filter(g=>g.type==="dimension"),dbtModels:c.filter(g=>g.type==="dbt_model"),dbtSources:c.filter(g=>g.type==="dbt_source"),tables:c.filter(g=>g.type==="source_table"),domains:c.filter(g=>g.type==="domain")}),[c]),O=u.useMemo(()=>({businessNodes:j.terms.length+j.businessViews.length,businessEdges:p.filter(g=>g.type==="defines"||g.type==="composes").length,technicalNodes:j.tables.length+j.dbtSources.length+j.dbtModels.length+j.metrics.length+j.dimensions.length+j.blocks.length,consumptionNodes:j.charts.length+j.notebooks.length+j.dashboards.length+j.apps.length}),[p,j]),T=u.useMemo(()=>{const g={source:[],transform:[],answer:[],consumption:[]};for(const $ of c){const _=fb($);g[_].push($)}return g},[c]);return a?s.jsx("div",{style:{padding:16,color:r.textMuted,fontSize:12},children:"Loading lineage..."}):c.length===0?s.jsx("div",{style:{height:"100%",background:o?r.sidebarBg:"transparent",border:o?`1px solid ${r.headerBorder}`:"none",borderRadius:o?8:0},children:s.jsx(qn,{title:"No lineage data",description:"Run `dql compile` or add notebooks/blocks first."})}):s.jsxs("div",{style:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",background:o?r.sidebarBg:"transparent",border:o?`1px solid ${r.headerBorder}`:"none",borderRadius:o?8:0,overflow:"hidden"},children:[s.jsx("div",{style:{padding:"10px 12px 8px",borderBottom:`1px solid ${r.headerBorder}`},children:s.jsx(WS,{value:y,onChange:S,placeholder:"Search lineage...",t:r})}),s.jsxs("div",{style:{flex:1,overflow:"auto"},children:[y.trim().length>=2&&x.length>0&&s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${r.headerBorder}`},children:[s.jsx("div",{style:{color:r.textMuted,fontSize:11,fontWeight:700,textTransform:"uppercase",marginBottom:6},children:"Search Results"}),x.slice(0,8).map(g=>s.jsx(xd,{node:g.node,t:r,onClick:()=>C(g.node),secondary:g.node.domain},g.node.id))]}),s.jsxs("div",{style:{padding:"8px 12px",display:"grid",gridTemplateColumns:o&&!i?"repeat(3, minmax(0, 1fr))":"1fr",gap:6,borderBottom:`1px solid ${r.headerBorder}`},children:[s.jsx(Mo,{Icon:Jg,label:"Business",value:O.businessNodes,detail:`${j.terms.length} terms · ${j.businessViews.length} views · ${O.businessEdges} edges`,t:r}),s.jsx(Mo,{Icon:or,label:"Technical",value:O.technicalNodes,detail:`${j.tables.length} tables · ${j.dbtModels.length+j.dbtSources.length} dbt · ${j.blocks.length} blocks`,t:r}),s.jsx(Mo,{Icon:Jy,label:"Consumption",value:O.consumptionNodes,detail:`${j.dashboards.length} dashboards · ${j.notebooks.length} notebooks · ${j.apps.length} apps`,t:r})]}),s.jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:7,flexWrap:"wrap",borderBottom:`1px solid ${r.headerBorder}`},children:[Hi.map(g=>{const $=T[g].length;return $===0?null:s.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,color:r.textMuted},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:2,background:ub[g],display:"inline-block"}}),Vi[g],": ",$]},g)}),s.jsx("span",{style:{flex:1}}),s.jsxs("div",{style:{display:"flex",borderRadius:4,border:`1px solid ${r.headerBorder}`,overflow:"hidden"},children:[s.jsx("button",{onClick:()=>v("type"),style:{padding:"2px 6px",fontSize:9,fontWeight:700,border:"none",cursor:"pointer",background:E==="type"?`${r.headerBorder}`:"transparent",color:E==="type"?r.textPrimary:r.textMuted},children:"Type"}),s.jsx("button",{onClick:()=>v("layer"),style:{padding:"2px 6px",fontSize:9,fontWeight:700,border:"none",cursor:"pointer",borderLeft:`1px solid ${r.headerBorder}`,background:E==="layer"?`${r.headerBorder}`:"transparent",color:E==="layer"?r.textPrimary:r.textMuted},children:"Layer"})]})]}),E==="type"?s.jsxs(s.Fragment,{children:[s.jsx(Ve,{title:"Business Terms",nodes:j.terms,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Business Views",nodes:j.businessViews,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"DQL Blocks",nodes:j.blocks,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Metrics",nodes:j.metrics,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Dimensions",nodes:j.dimensions,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Dashboards",nodes:j.dashboards,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Notebooks",nodes:j.notebooks,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Apps",nodes:j.apps,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Charts",nodes:j.charts,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"dbt Models",nodes:j.dbtModels,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"dbt Sources",nodes:j.dbtSources,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Source Tables",nodes:j.tables,t:r,onSelect:C,secondaryFor:Ye}),s.jsx(Ve,{title:"Business Domains",nodes:j.domains,t:r,onSelect:C,secondaryFor:Ye})]}):s.jsx(s.Fragment,{children:Hi.map(g=>s.jsx(Ve,{title:Vi[g],nodes:T[g],t:r,onSelect:C},g))})]})]})}function HS({diff:e,diffReport:t,activeFilePath:n,diffPath:r,onScopeToFile:o,onClearScope:i,t:l}){const a=t!==null&&!t.identical,d=e.trim()!=="";return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{display:"flex",gap:6,fontSize:11},children:[s.jsx("button",{onClick:i,style:wa(r==null,l),children:"All"}),n&&s.jsx("button",{onClick:o,style:wa(r===n,l),children:"Active file"}),r&&s.jsx("span",{style:{color:l.textMuted,fontSize:10,alignSelf:"center",fontFamily:l.fontMono},children:r})]}),a&&s.jsx(GS,{report:t,t:l}),!a&&d&&s.jsx(YS,{diff:e,t:l}),!a&&!d&&s.jsx("div",{style:{color:l.textMuted},children:t&&t.identical?"No semantic changes.":"No unstaged changes."})]})}function GS({report:e,t}){return s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.changes.map((n,r)=>s.jsx(JS,{change:n,t},r))})}function JS({change:e,t}){const{marker:n,color:r,label:o}=XS(e),i="fields"in e?e.fields:null;return s.jsxs("div",{style:{border:`1px solid ${t.editorBorder}`,borderRadius:6,padding:"6px 10px",background:t.editorBg},children:[s.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[s.jsx("span",{style:{color:r,fontFamily:t.fontMono,fontWeight:700,width:14},children:n}),s.jsx("span",{style:{color:t.textPrimary,fontSize:12,fontFamily:t.fontMono},children:o})]}),i&&i.length>0&&s.jsx("div",{style:{marginTop:4,display:"flex",flexDirection:"column",gap:2},children:i.map((l,a)=>s.jsx(QS,{field:l,t},a))})]})}function QS({field:e,t}){return s.jsxs("div",{style:{fontSize:11,fontFamily:t.fontMono,color:t.textPrimary,paddingLeft:22},children:[s.jsx("span",{style:{color:t.accent},children:e.path}),s.jsx("span",{style:{color:t.textMuted},children:": "}),s.jsx("span",{style:{color:t.error,textDecoration:"line-through"},children:Sa(e.before)}),s.jsx("span",{style:{color:t.textMuted},children:" → "}),s.jsx("span",{style:{color:t.success},children:Sa(e.after)})]})}function YS({diff:e,t}){return s.jsx("pre",{style:{fontFamily:t.fontMono,fontSize:11,margin:0,padding:8,background:t.editorBg,border:`1px solid ${t.editorBorder}`,borderRadius:6,overflow:"auto",whiteSpace:"pre",color:t.textPrimary},children:e.split(`
|
|
471
|
-
`).map((n,r)=>s.jsx("div",{style:{color:ZS(n,t)},children:n||" "},r))})}function XS(e){const t={marker:"+",color:"#3cb371"},n={marker:"-",color:"#e06060"},r={marker:"~",color:"#d4a24c"};switch(e.kind){case"block-added":return{...t,label:`block "${e.name}"`};case"block-removed":return{...n,label:`block "${e.name}"`};case"block-changed":return{...r,label:`block "${e.name}"`};case"dashboard-added":return{...t,label:`dashboard "${e.title}"`};case"dashboard-removed":return{...n,label:`dashboard "${e.title}"`};case"dashboard-changed":return{...r,label:`dashboard "${e.title}"`};case"workbook-added":return{...t,label:`workbook "${e.title}"`};case"workbook-removed":return{...n,label:`workbook "${e.title}"`};case"workbook-changed":return{...r,label:`workbook "${e.title}"`};case"cell-added":return{...t,label:`cell ${Lo(e.id,e.name)} [${e.cellType}]`};case"cell-removed":return{...n,label:`cell ${Lo(e.id,e.name)} [${e.cellType}]`};case"cell-changed":return{...r,label:`cell ${Lo(e.id,e.name)}`};case"notebook-changed":return{...r,label:"notebook"}}}function Lo(e,t){return t?`"${t}" (${e.slice(0,8)})`:e.slice(0,8)}function Sa(e,t=60){if(e==null)return"∅";const n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}…`:n}function wa(e,t){return{background:e?t.btnHover:"transparent",color:e?t.textPrimary:t.textMuted,border:`1px solid ${t.headerBorder}`,padding:"2px 8px",borderRadius:4,fontSize:11,cursor:"pointer"}}function ZS(e,t){return e.startsWith("+++")||e.startsWith("---")?t.textMuted:e.startsWith("+")?t.success:e.startsWith("-")?t.error:e.startsWith("@@")?t.accent:t.textPrimary}const e0=2e3,t0={modified:{label:"Modified",color:e=>e.warning,Icon:wy},added:{label:"Added",color:e=>e.success,Icon:Uc},deleted:{label:"Deleted",color:e=>e.error,Icon:Ay},renamed:{label:"Renamed",color:e=>e.accent,Icon:Bg},untracked:{label:"Untracked",color:e=>e.textMuted,Icon:Cy}},ka=["modified","added","renamed","deleted","untracked"];function n0(e){const t=e.trim();return t==="??"?"untracked":t.startsWith("R")?"renamed":t.includes("D")?"deleted":t.includes("A")?"added":"modified"}function r0(){var O;const{state:e}=Se(),t=qe[e.themeMode],[n,r]=u.useState("status"),[o,i]=u.useState(null),[l,a]=u.useState(null),[d,c]=u.useState(""),[f,p]=u.useState(null),[h,y]=u.useState(null),[S,x]=u.useState(!1),[b,w]=u.useState(!1),C=u.useCallback(async()=>{x(!0),w(!0);try{if(n==="status")i(await N.fetchGitStatus());else if(n==="log")a(await N.fetchGitLog(30));else{const T=await N.fetchGitDiff(h??void 0);c(T.diff),p(T.diffReport)}}finally{x(!1),window.setTimeout(()=>w(!1),400)}},[n,h]);u.useEffect(()=>{C()},[C]),u.useEffect(()=>{if(n!=="status")return;const T=window.setInterval(()=>{N.fetchGitStatus().then(g=>{i($=>o0($,g)?$:g)})},e0);return()=>window.clearInterval(T)},[n]);const E=((O=e.activeFile)==null?void 0:O.path)??null,v=s.jsxs("button",{onClick:()=>void C(),title:"Refresh","aria-label":"Refresh",style:{background:"transparent",border:`1px solid ${t.btnBorder}`,cursor:"pointer",color:t.textMuted,padding:"3px 6px",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center"},children:[s.jsx(Fr,{size:12,strokeWidth:1.75,style:{animation:b?"dql-spin 0.6s linear":void 0}}),s.jsx("style",{children:"@keyframes dql-spin { to { transform: rotate(360deg); } }"})]}),j=s.jsxs(Bc,{children:[s.jsx(No,{t,active:n==="status",onClick:()=>r("status"),children:"Status"}),s.jsx(No,{t,active:n==="log",onClick:()=>r("log"),children:"History"}),s.jsx(No,{t,active:n==="diff",onClick:()=>r("diff"),children:"Diff"})]});return s.jsxs(Ps,{title:"Git",actions:v,toolbar:j,bodyPadding:12,children:[S&&!o&&!l&&s.jsx(qn,{title:"Loading…"}),n==="status"&&o&&s.jsx(s0,{status:o,t}),n==="log"&&l&&s.jsx(d0,{log:l,t}),n==="diff"&&s.jsx(HS,{diff:d,diffReport:f,activeFilePath:E,diffPath:h,onScopeToFile:()=>y(E),onClearScope:()=>y(null),t})]})}function o0(e,t){if(!e||e.inRepo!==t.inRepo||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind||e.changes.length!==t.changes.length)return!1;const n=e.changes.map(o=>`${o.path}\0${o.status}`).sort(),r=t.changes.map(o=>`${o.path}\0${o.status}`).sort();for(let o=0;o<n.length;o++)if(n[o]!==r[o])return!1;return!0}function s0({status:e,t}){const n=u.useMemo(()=>{const r={modified:[],added:[],deleted:[],renamed:[],untracked:[]};for(const o of e.changes)r[n0(o.status)].push(o);for(const o of ka)r[o].sort((i,l)=>i.path.localeCompare(l.path));return r},[e.changes]);return e.inRepo?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[s.jsx(i0,{status:e,t}),e.changes.length===0?s.jsx(a0,{t}):ka.map(r=>{const o=n[r];return o.length===0?null:s.jsx(l0,{group:r,items:o,t},r)})]}):s.jsx(bd,{t})}function i0({status:e,t}){const n=e.ahead??0,r=e.behind??0;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderLeft:`3px solid ${t.accent}`,borderRadius:7},children:[s.jsx(Cn,{size:16,strokeWidth:1.75,color:t.accent}),s.jsx("span",{style:{fontSize:13,fontWeight:600,color:t.textPrimary,fontFamily:t.fontMono},children:e.branch??"detached"}),s.jsx("div",{style:{flex:1}}),n>0&&s.jsxs("span",{title:`${n} commit(s) ahead of upstream`,style:Bo(t.success,t),children:[s.jsx(zg,{size:11,strokeWidth:2})," ",n]}),r>0&&s.jsxs("span",{title:`${r} commit(s) behind upstream`,style:Bo(t.warning,t),children:[s.jsx(Lg,{size:11,strokeWidth:2})," ",r]}),n===0&&r===0&&s.jsx("span",{style:{...Bo(t.textMuted,t),opacity:.7},children:"up to date"})]})}function a0({t:e}){return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"14px 12px",background:e.cellBg,border:`1px solid ${e.cellBorder}`,borderRadius:7,color:e.textMuted,fontSize:12,fontFamily:e.font},children:[s.jsx(vy,{size:14,strokeWidth:1.75,color:e.success}),"Working tree clean"]})}function bd({t:e}){return s.jsx("div",{style:{padding:"14px 12px",background:e.cellBg,border:`1px solid ${e.cellBorder}`,borderRadius:7,color:e.textMuted,fontSize:12,fontFamily:e.font},children:"Not a git repository"})}function l0({group:e,items:t,t:n}){const r=t0[e],o=r.color(n),i=r.Icon;return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6,fontSize:10,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",color:n.textMuted,fontFamily:n.font},children:[s.jsx(i,{size:11,strokeWidth:1.75}),s.jsx("span",{children:r.label}),s.jsx("span",{style:{marginLeft:2,padding:"0 5px",borderRadius:8,background:`${o}1a`,color:o,fontWeight:700,fontSize:9,letterSpacing:"0.04em"},children:t.length})]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",background:n.cellBg,border:`1px solid ${n.cellBorder}`,borderRadius:7,overflow:"hidden"},children:t.map((l,a)=>s.jsx(c0,{change:l,t:n,color:o,divider:a<t.length-1},l.path))})]})}function c0({change:e,t,color:n,divider:r}){const o=e.status.trim()||"??";return s.jsxs("div",{title:e.path,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderBottom:r?`1px solid ${t.cellBorder}`:"none",fontFamily:t.fontMono,fontSize:11},children:[s.jsx("span",{style:{width:22,textAlign:"center",flexShrink:0,color:n,fontWeight:700,fontSize:10,letterSpacing:"0.02em"},children:o}),s.jsx("span",{style:{color:t.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.path})]})}function d0({log:e,t}){return e.inRepo?e.commits.length===0?s.jsx("div",{style:{padding:"14px 12px",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:7,color:t.textMuted,fontSize:12,fontFamily:t.font},children:"No commits yet"}):s.jsx("div",{style:{display:"flex",flexDirection:"column",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:7,overflow:"hidden"},children:e.commits.map((n,r)=>s.jsxs("div",{style:{display:"flex",gap:10,padding:"8px 12px",borderBottom:r<e.commits.length-1?`1px solid ${t.cellBorder}`:"none"},children:[s.jsx(By,{size:13,strokeWidth:1.75,color:t.accent,style:{flexShrink:0,marginTop:2}}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{color:t.textPrimary,fontSize:12,fontFamily:t.font,fontWeight:500,lineHeight:1.35,wordBreak:"break-word"},children:n.subject}),s.jsxs("div",{style:{color:t.textMuted,fontSize:10,marginTop:3,display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontFamily:t.fontMono,color:t.accent},children:n.hash.slice(0,7)}),s.jsx("span",{children:"·"}),s.jsx("span",{style:{fontFamily:t.font},children:n.author}),s.jsx("span",{children:"·"}),s.jsx("span",{style:{fontFamily:t.fontMono},children:n.date})]})]})]},n.hash))}):s.jsx(bd,{t})}function No({active:e,onClick:t,children:n,t:r}){return s.jsx("button",{onClick:t,style:{background:e?r.btnHover:"transparent",color:e?r.textPrimary:r.textMuted,border:"none",padding:"4px 12px",borderRadius:4,fontSize:11,fontWeight:600,letterSpacing:"0.02em",cursor:"pointer",fontFamily:r.font,transition:"background 0.15s, color 0.15s"},children:n})}function Bo(e,t){return{display:"inline-flex",alignItems:"center",gap:3,padding:"1px 7px",fontSize:10,fontWeight:600,letterSpacing:"0.02em",borderRadius:10,background:`${e}1a`,color:e,fontFamily:t.font}}function u0(e){const{state:t,dispatch:n}=Se(),r=qe[t.themeMode],[o,i]=u.useState([]),[l,a]=u.useState(!0),[d,c]=u.useState(""),[f,p]=u.useState(""),[h,y]=u.useState(new Set),S=()=>{a(!0),N.listApps().then(g=>i(g)).finally(()=>a(!1))};u.useEffect(()=>{S()},[]);const x=sr(t.authoredDomains),b=nn(t.authoredDomains),w=o.some(g=>{var $;return!x.has((($=g.domain)==null?void 0:$.trim())??"")}),C=o.filter(g=>{var _;const $=d.toLowerCase();return!($&&!g.name.toLowerCase().includes($)&&!(g.description??"").toLowerCase().includes($)||f==="uncategorized"&&x.has(((_=g.domain)==null?void 0:_.trim())??"")||f&&f!=="uncategorized"&&(!x.has(f)||g.domain!==f))}),E=g=>{y($=>{const _=new Set($);return _.has(g)?_.delete(g):_.add(g),_})},v=(g,$)=>{n({type:"OPEN_APP",appId:g.id,dashboardId:$})},j={background:r.inputBg,border:`1px solid ${r.inputBorder}`,borderRadius:4,color:r.textPrimary,fontSize:11,fontFamily:r.font,padding:"4px 6px",outline:"none"},O=s.jsx("button",{onClick:S,style:{background:"transparent",border:`1px solid ${r.cellBorder}`,borderRadius:4,color:r.textSecondary,cursor:"pointer",fontSize:10,fontFamily:r.font,padding:"3px 8px"},children:"Refresh"}),T=s.jsxs(Bc,{children:[s.jsx("input",{value:d,onChange:g=>c(g.target.value),placeholder:"Search apps...",style:{...j,flex:1,minWidth:100}}),s.jsxs("select",{value:f,onChange:g=>p(g.target.value),style:j,children:[s.jsx("option",{value:"",children:"All domains"}),b.map(g=>s.jsx("option",{value:g.value,children:g.label},g.value)),w?s.jsx("option",{value:"uncategorized",children:"Unassigned"}):null]})]});return s.jsx(Ps,{title:"Apps",status:s.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font},children:C.length}),actions:O,toolbar:T,bodyPadding:0,children:l?s.jsx(qn,{title:"Loading apps…"}):C.length===0?o.length===0?s.jsx(qn,{title:"No apps yet",description:s.jsxs(s.Fragment,{children:["Create one from the CLI:",s.jsx("br",{}),s.jsx("code",{style:{display:"inline-block",marginTop:6,padding:"2px 6px",background:r.inputBg,borderRadius:3,fontSize:10},children:"dql app new <name> --domain <domain>"})]})}):s.jsx(qn,{title:"No matches",description:"No apps match your filters."}):C.map(g=>{const $=h.has(g.id);return s.jsxs("div",{style:{borderBottom:`1px solid ${r.cellBorder}`},children:[s.jsxs("button",{onClick:()=>E(g.id),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",cursor:"pointer",padding:"10px 12px",transition:"background 0.1s"},onMouseEnter:_=>{_.currentTarget.style.background=`${r.accent}0a`},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[s.jsx("span",{style:{fontSize:10,color:r.textMuted,fontFamily:r.font,width:10},children:$?"▾":"▸"}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:r.textPrimary,fontFamily:r.font},children:g.name}),s.jsx(Nc,{tone:"accent",children:g.domain})]}),g.description&&s.jsx("div",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font,lineHeight:1.3,marginBottom:4,marginLeft:16},children:g.description}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10,color:r.textMuted,fontFamily:r.font,marginLeft:16},children:[g.owners[0]&&s.jsxs("span",{children:["by ",g.owners[0]]}),s.jsxs("span",{children:[g.dashboards.length," dashboard",g.dashboards.length===1?"":"s"]}),s.jsxs("span",{children:[g.members," member",g.members===1?"":"s"]})]})]}),$&&s.jsxs("div",{style:{padding:"4px 0 10px 28px",background:`${r.accent}04`},children:[g.dashboards.length===0&&s.jsx("div",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font,padding:"4px 0"},children:"(empty app scaffold)"}),g.dashboards.map(_=>s.jsx("button",{onClick:()=>v(g,_.id),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",padding:"3px 12px",cursor:"pointer",fontSize:11,color:r.textSecondary,fontFamily:r.font},children:_.title},_.id))]})]},g.id)})})}const p0={files:"Build",block_library:"Build",lineage:"Lineage",connection:"Connection",git:"Git",apps:"Apps"};function f0({onOpenFile:e}){const{state:t,dispatch:n}=Se(),r=qe[t.themeMode],[o,i]=u.useState(!1),[l,a]=u.useState(340),[d,c]=u.useState(!1),[f,p]=u.useState(""),h=u.useRef(l),y=t.sidebarPanel,S=y==="files"||y==="block_library",x=t.semanticLayer.loading?"Loading semantic metrics…":`${t.semanticLayer.provider?`${t.semanticLayer.provider} synced`:"dbt synced"} · ${t.schemaTables.length} table${t.schemaTables.length===1?"":"s"} · ${t.semanticLayer.metrics.length.toLocaleString()} metric${t.semanticLayer.metrics.length===1?"":"s"}`;u.useEffect(()=>{if(!S)return;let w=!0;return n({type:"SET_SEMANTIC_LOADING",loading:!0}),N.getSemanticLayer().then(C=>{w&&n({type:"SET_SEMANTIC_LAYER",layer:C})}).catch(()=>{}).finally(()=>{w&&n({type:"SET_SEMANTIC_LOADING",loading:!1})}),()=>{w=!1}},[S,n]);const b=w=>{w.preventDefault();const C=w.clientX,E=h.current;c(!0);const v=O=>{const T=Math.min(560,Math.max(180,E+(O.clientX-C)));h.current=T,a(T)},j=()=>{c(!1),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",v),window.addEventListener("mouseup",j)};return s.jsxs("div",{style:{width:l,flexShrink:0,background:r.sidebarBg,borderRight:`1px solid ${r.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"},children:[s.jsxs("div",{style:{height:36,flexShrink:0,display:S?"none":"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px 0 14px",borderBottom:`1px solid ${r.headerBorder}`},children:[s.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:r.textSecondary,fontFamily:r.font},children:p0[y??""]??""}),s.jsx("button",{title:"Collapse sidebar",onClick:()=>n({type:"TOGGLE_SIDEBAR"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:o?r.textPrimary:r.textMuted,padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,transition:"color 0.15s",display:"flex",alignItems:"center"},children:"‹"})]}),s.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[S&&s.jsx(qv,{defaultTab:y==="block_library"?"blocks":"notebooks",tabs:["notebooks","semantic","database","blocks"],onOpenFile:e,blockDomain:f,onBlockDomainChange:p,onNewBlock:()=>n({type:"OPEN_NEW_BLOCK_MODAL"}),onCollapse:()=>n({type:"TOGGLE_SIDEBAR"}),footer:x,footerStatus:t.semanticLayer.loading?"loading":"ready"}),y==="lineage"&&s.jsx(VS,{}),y==="connection"&&s.jsx(yd,{}),y==="git"&&s.jsx(r0,{}),y==="apps"&&s.jsx(u0,{onOpenFile:e})]}),s.jsx("div",{onMouseDown:b,title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",background:d?r.accent:"transparent",zIndex:10,transition:d?"none":"background 0.15s"},onMouseEnter:w=>{d||(w.currentTarget.style.background=`${r.accent}40`)},onMouseLeave:w=>{d||(w.currentTarget.style.background="transparent")}})]})}const vd=2;function h0(e,t={}){const n=t.version??vd,r=JSON.parse(e),{dqlnbVersion:o,...i}=r,l={dqlnbVersion:n,...i};return JSON.stringify(l,m0(),2)+`
|
|
472
|
-
`}function m0(){return function(t,n){if(n===null||typeof n!="object"||Array.isArray(n))return n;const r=n,o=Object.keys(r);o.sort((l,a)=>{const d=ja[l],c=ja[a];return d!==void 0&&c!==void 0?d-c:d!==void 0?-1:c!==void 0?1:l<a?-1:l>a?1:0});const i={};for(const l of o)i[l]=r[l];return i}}const ja={dqlnbVersion:0,version:1,title:2,metadata:3,cells:4,id:10,type:11,name:12,content:13};function g0(e){try{const t=e.match(/workbook\s+"([^"]+)"/i),n=t?t[1]:"Untitled Workbook",r=[],o=/page\s+"([^"]+)"\s*\{([\s\S]*?)\}/gi;let i;for(;(i=o.exec(e))!==null;){const l=i[1],a=i[2].trim();r.push({id:nt(),type:"markdown",content:`# ${l}`,status:"idle"}),a&&r.push({id:nt(),type:"dql",name:l.toLowerCase().replace(/\s+/g,"_"),content:a,status:"idle"})}return r.length===0&&r.push({id:nt(),type:"dql",content:e.trim(),status:"idle"}),{title:n,cells:r}}catch(t){return console.warn("parse-workbook: falling back after error",t),{title:"Untitled Workbook",cells:[{id:nt(),type:"dql",content:e.trim(),status:"idle"}]}}}const y0=new Set(["id","type","content","source","name","title","paramConfig","paramValue","chartConfig","filterConfig","pivotConfig","singleValueConfig","tableConfig","chatConfig","upstream","blockBinding","dqlParameterValues","dqlArtifact","correctionProvenance","executionTarget","datasetRefs","dependencies","annotations","mixedSourcePlan","kernel"]);function x0(e){var t;try{const n=JSON.parse(e),r=n.title||((t=n.metadata)==null?void 0:t.title)||"Untitled",o=Yo((n.cells||[]).map(a=>{const d=Object.fromEntries(Object.entries(a).filter(([c])=>!y0.has(c)));return{id:a.id||nt(),type:a.type||"sql",content:a.content??a.source??"",name:a.name||a.title,status:"idle",...a.paramConfig?{paramConfig:a.paramConfig}:{},...a.paramValue!==void 0?{paramValue:a.paramValue}:{},...a.chartConfig?{chartConfig:a.chartConfig}:{},...a.filterConfig?{filterConfig:a.filterConfig}:{},...a.pivotConfig?{pivotConfig:a.pivotConfig}:{},...a.singleValueConfig?{singleValueConfig:a.singleValueConfig}:{},...a.tableConfig?{tableConfig:a.tableConfig}:{},...a.chatConfig?{chatConfig:a.chatConfig}:{},...a.upstream?{upstream:a.upstream}:{},...a.blockBinding?{blockBinding:a.blockBinding}:{},...a.dqlParameterValues?{dqlParameterValues:a.dqlParameterValues}:{},...a.dqlArtifact?{dqlArtifact:a.dqlArtifact}:{},...a.correctionProvenance?{correctionProvenance:a.correctionProvenance}:{},...a.executionTarget?{executionTarget:a.executionTarget}:{},...a.datasetRefs?{datasetRefs:a.datasetRefs}:{},...a.dependencies?{dependencies:a.dependencies}:{},...a.annotations?{annotations:a.annotations}:{},...a.mixedSourcePlan?{mixedSourcePlan:a.mixedSourcePlan}:{},...a.kernel?{kernel:a.kernel}:{},...Object.keys(d).length>0?{preservedFields:d}:{}}})),{title:i,...l}=n.metadata??{};return{title:r,cells:o,metadata:l}}catch(n){return console.warn("parse-workbook: falling back after error",n),{title:"Untitled",cells:[{id:nt(),type:"sql",content:e,status:"idle"}]}}}function b0(e,t,n){const r={dqlnbVersion:vd,version:1,title:e,metadata:{...n,modifiedAt:new Date().toISOString(),...n!=null&&n.createdAt?{}:{createdAt:new Date().toISOString()}},cells:t.map(o=>({...o.preservedFields??{},id:o.id,type:o.type,content:o.content,...o.name?{name:o.name}:{},...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{},...o.chartConfig?{chartConfig:o.chartConfig}:{},...o.filterConfig?{filterConfig:o.filterConfig}:{},...o.pivotConfig?{pivotConfig:o.pivotConfig}:{},...o.singleValueConfig?{singleValueConfig:o.singleValueConfig}:{},...o.tableConfig?{tableConfig:o.tableConfig}:{},...o.chatConfig?{chatConfig:o.chatConfig}:{},...o.upstream?{upstream:o.upstream}:{},...o.blockBinding?{blockBinding:o.blockBinding}:{},...o.dqlParameterValues?{dqlParameterValues:o.dqlParameterValues}:{},...o.dqlArtifact?{dqlArtifact:o.dqlArtifact}:{},...o.correctionProvenance?{correctionProvenance:o.correctionProvenance}:{},...o.executionTarget?{executionTarget:o.executionTarget}:{},...o.datasetRefs?{datasetRefs:o.datasetRefs}:{},...o.dependencies?{dependencies:o.dependencies}:{},...o.annotations?{annotations:o.annotations}:{},...o.mixedSourcePlan?{mixedSourcePlan:o.mixedSourcePlan}:{},...o.kernel?{kernel:o.kernel}:{}}))};return h0(JSON.stringify(r))}function v0(e,t){return e.endsWith(".dql")?g0(t):x0(t)}const Sd=/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g;function s1(e){const t=new Set;for(const n of e.matchAll(Sd))t.add(n[1]);return[...t]}function S0(e,t){if(!t.columns.length||!t.rows.length)return`${e} AS (SELECT 1 WHERE 1=0)`;const n=t.columns,o=t.rows.slice(0,5e3).map(l=>`(${n.map(d=>{const c=l[d];return c==null?"NULL":typeof c=="number"?String(c):typeof c=="boolean"?c?"TRUE":"FALSE":`'${String(c).replace(/'/g,"''")}'`}).join(", ")})`).join(`,
|
|
473
|
-
`),i=n.map(l=>`"${l.replace(/"/g,'""')}"`).join(", ");return`${e} AS (
|
|
474
|
-
SELECT * FROM (VALUES
|
|
475
|
-
${o}
|
|
476
|
-
) AS _t(${i})
|
|
477
|
-
)`}function w0(e,t){if(t==="number"){const n=Number(e);return isNaN(n)?`'${e.replace(/'/g,"''")}'`:String(n)}return`'${e.replace(/'/g,"''")}'`}function k0(e,t){var c;const n=[...e.matchAll(Sd)];if(n.length===0)return{sql:e,substituted:[],unresolved:[],ambiguous:[]};const r=new Map;for(const f of t){const p=[f.id,(c=f.name)==null?void 0:c.trim()].filter(h=>!!h);for(const h of p)r.set(h,[...r.get(h)??[],f])}const o=[],i=[],l=[],a=[];let d=e;for(const f of n){const p=f[1],h=r.get(p)??[];if(h.length===0){i.push(p);continue}if(h.length>1){l.push(p);continue}const y=h[0];if(y.type==="param"){const S=y.paramConfig,x=y.paramValue??(S==null?void 0:S.defaultValue)??"",b=(S==null?void 0:S.paramType)??"text";d=d.replace(f[0],w0(x,b)),o.push(p);continue}if(!y.result||y.error||y.stale){i.push(p);continue}a.push(S0(p,y.result)),d=d.replace(f[0],`"${p}"`),o.push(p)}if(a.length>0){const f=d.trimStart();/^WITH\s+/i.test(f)?d=d.replace(/^(\s*WITH\s+)/i,`$1${a.join(`,
|
|
478
|
-
`)},
|
|
479
|
-
`):d=`WITH ${a.join(`,
|
|
480
|
-
`)}
|
|
481
|
-
${d}`}return{sql:d,substituted:Array.from(new Set(o)),unresolved:Array.from(new Set(i)),ambiguous:Array.from(new Set(l))}}function wd(e){const t=i=>{var l;return((l=e.match(new RegExp(`\\b${i}\\s*=\\s*"([^"]*)"`,"i")))==null?void 0:l[1])??""},n=i=>{const l=e.match(new RegExp(`\\b${i}\\s*=\\s*\\[([\\s\\S]*?)\\]`,"i"));return((l==null?void 0:l[1].match(/"([^"]*)"/g))??[]).map(a=>a.slice(1,-1)).filter(Boolean)},r=n("metrics"),o=t("metric");return{metrics:r.length>0?r:o?[o]:[],dimensions:n("dimensions"),requestedFilters:n("requested_filters"),timeDimension:t("time_dimension"),granularity:t("granularity")}}function i1(e,t){let n=e.replace(/\n\s*metrics\s*=\s*\[[\s\S]*?\]/i,"").replace(/\n\s*metric\s*=\s*"[^"]*"/i,"");const r=Array.from(new Set(t.filter(Boolean)));return Hs(n,` metrics = [${r.map(o=>`"${Lt(o)}"`).join(", ")}]`)}function kd(e,t,n){const r=Array.from(new Set(n.filter(Boolean))),o=`${t} = [${r.map(l=>`"${Lt(l)}"`).join(", ")}]`,i=new RegExp(`\\b${t}\\s*=\\s*\\[[\\s\\S]*?\\]`,"i");return i.test(e)?e.replace(i,o):Hs(e,` ${o}`)}function jd(e){const t=Ea(e,"parameterPolicy"),n=Ea(e,"filterBindings"),r=new Set(Array.from(e.matchAll(/\$\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}/g)).map(l=>l[1])),o=/\btype\s*=\s*"semantic"/i.test(e);return Vs(e,"params").split(/\r?\n/).flatMap(l=>{const a=l.trim();if(!a||a.startsWith("//")||a.startsWith("#"))return[];const d=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*(string|number|boolean|date)(\[\])?)?\s*(?:=\s*(.+))?$/.exec(a);if(!d)return[];const c=d[1],f=d[4]===void 0?void 0:Rd(d[4]),p=d[2]?`${d[2]}${d[3]??""}`:j0(_d(f),c),h=n.get(c),y=r.has(c)?{kind:"sql_value"}:c==="top_n"||c==="limit"?{kind:"limit"}:o&&h?{kind:"semantic_filter",field:h,operator:c.endsWith("_set")?"in":"equals"}:void 0;return[{name:c,type:p,required:d[4]===void 0,...d[4]===void 0?{}:{default:f},policy:E0(t.get(c)),...y?{binding:y}:{}}]})}function j0(e,t=""){const n=e.trim(),r=t.toLowerCase();if(n.includes(",")){const o=n.split(",").map(i=>i.trim()).filter(Boolean);return o.length>0&&o.every(i=>Ca(i))?"date[]":o.length>0&&o.every(i=>Wr(i))?"number[]":"string[]"}return n==="true"||n==="false"?"boolean":Ca(n)?"date":Wr(n)?"number":/\b(date|from|start|end|until)\b|(?:^|_)(date|at)(?:_|$)/.test(r)?"date":/(?:^|_)(top_n|limit|count|rank|number)(?:_|$)|_n$/.test(r)?"number":/(?:_set|_list|_ids|_values)$/.test(r)?"string[]":"string"}function Cd(e){return e.default===void 0?"":_d(e.default)}function a1(e){if(/^\s*block\s+"/i.test(e))return e;const t=e.trim();return`block "notebook_query" {
|
|
482
|
-
status = "draft"
|
|
483
|
-
domain = "uncategorized"
|
|
484
|
-
type = "custom"
|
|
485
|
-
description = "Notebook analysis"
|
|
486
|
-
|
|
487
|
-
query = """
|
|
488
|
-
${t?t.split(/\r?\n/).map(r=>` ${r}`).join(`
|
|
489
|
-
`):" -- Write query"}
|
|
490
|
-
"""
|
|
491
|
-
}
|
|
492
|
-
`}function l1(e,t){const n=Ad(t.name);if(!n)return e;const r=jd(e).filter(o=>o.name!==t.previousName&&o.name!==n).map(o=>({name:o.name,type:o.type,required:o.required,defaultText:Cd(o),policy:o.policy}));return r.push({name:n,type:t.type,required:t.required,defaultText:t.defaultText??"",policy:t.policy}),Ed(e,r)}function c1(e,t){const n=jd(e).filter(r=>r.name!==t).map(r=>({name:r.name,type:r.type,required:r.required,defaultText:Cd(r),policy:r.policy}));return Ed(e,n)}function d1(e,t,n){const r=Ad(t),o=n.trim();if(!r||!o)return e;const l=Vs(e,"filterBindings").split(/\r?\n/).filter(a=>a.trim()&&!new RegExp(`^${r}\\s*=`).test(a.trim()));return l.push(`${r} = "${Lt(o)}"`),Kr(e,"filterBindings",l.join(`
|
|
493
|
-
`))}function Ed(e,t){const n=t.map(i=>{const l=`${i.name}: ${i.type}`;return i.required?l:`${l} = ${Td(i.defaultText,i.type)}`}).join(`
|
|
494
|
-
`),r=t.map(i=>`${i.name} = "${i.policy}"`).join(`
|
|
495
|
-
`);let o=Kr(e,"params",n);return o=Kr(o,"parameterPolicy",r),o}function Td(e,t){const n=e.trim();if(t==="boolean")return n==="true"?"true":"false";if(t==="number")return Wr(n)?String(Number(n)):"0";if(t.endsWith("[]")){const r=t.slice(0,-2);return`[${n.split(",").map(i=>i.trim()).filter(Boolean).map(i=>Td(i,r)).join(", ")}]`}return`"${Lt(n)}"`}function Ad(e){const t=e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return/^[a-z_][a-z0-9_]*$/.test(t)?t:""}function Wr(e){return e!==""&&Number.isFinite(Number(e))}function Ca(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)}function Vs(e,t){const n=new RegExp(`\\b${t}\\s*\\{`,"i").exec(e);if(!n||n.index===void 0)return"";const r=e.indexOf("{",n.index);let o=0;for(let i=r;i<e.length;i+=1)if(e[i]==="{"&&(o+=1),e[i]==="}"&&(o-=1,o===0))return e.slice(r+1,i).trim();return""}function Ea(e,t){const n=new Map;for(const r of Vs(e,t).split(/\r?\n/)){const o=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*"([^"]*)"\s*$/.exec(r);o&&n.set(o[1],o[2])}return n}function Rd(e){const t=e.trim();return t==="true"?!0:t==="false"?!1:Wr(t)?Number(t):t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t.startsWith("[")&&t.endsWith("]")?C0(t.slice(1,-1)).map(Rd):t}function C0(e){const t=[];let n=!1,r="";for(let o=0;o<e.length;o+=1){const i=e[o];i==='"'&&e[o-1]!=="\\"&&(n=!n),i===","&&!n?(r.trim()&&t.push(r.trim()),r=""):r+=i}return r.trim()&&t.push(r.trim()),t}function _d(e){return Array.isArray(e)?e.join(", "):String(e??"")}function E0(e){return e==="static"||e==="business"||e==="derived"||e==="optional"||e==="ambiguous_review_required"?e:"dynamic"}function T0(e,t){const n=new Set(wd(e).requestedFilters),r=Array.from(new Set(t.filter(Boolean)));let o=kd(e,"requested_filters",r);return o=Fo(o,"params",n,r,i=>`${i}: string`),o=Fo(o,"parameterPolicy",n,r,i=>`${i} = "dynamic"`),o=Fo(o,"filterBindings",n,r,i=>`${i} = "${Lt(i)}"`),o}function Fo(e,t,n,r,o){const a=[...D0(e,t).split(/\r?\n/).filter(d=>{var f;const c=(f=d.trim().match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::|=)/))==null?void 0:f[1];return!c||!n.has(c)}).filter(d=>d.trim()),...r.map(o)].join(`
|
|
496
|
-
`);return Kr(e,t,a)}function Ta(e,t,n){const r=Lt(n),o=new RegExp(`(\\b${t}\\s*=\\s*)"[^"]*"`,"i");return o.test(e)?e.replace(o,`$1"${r}"`):Hs(e,` ${t} = "${r}"`)}function u1(e,t){const n=new Set(t.filter(Boolean)),r=wd(e);let o=kd(e,"dimensions",r.dimensions.filter(i=>n.has(i)));return o=T0(o,r.requestedFilters.filter(i=>n.has(i))),r.timeDimension&&!n.has(r.timeDimension)&&(o=Ta(o,"time_dimension",""),o=Ta(o,"granularity","")),o}function Lt(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function Hs(e,t){return/visualization\s*\{/i.test(e)?e.replace(/\n\s*visualization\s*\{/i,`
|
|
497
|
-
${t}
|
|
498
|
-
|
|
499
|
-
visualization {`):e.replace(/\n\}\s*$/,`
|
|
500
|
-
${t}
|
|
501
|
-
}
|
|
502
|
-
`)}function A0(e){var i;const t=e.match(/visualization\s*\{([^}]+)\}/is);if(!t)return;const n=t[1],r=l=>{var a;return(a=n.match(new RegExp(`\\b${l}\\s*=\\s*["']?([\\w-]+)["']?`,"i")))==null?void 0:a[1]},o=r("chart");if(o)return{chart:o,x:r("x"),y:r("y"),color:r("color"),title:(i=n.match(/\btitle\s*=\s*"([^"]+)"/i))==null?void 0:i[1]}}function R0(e){const t=e.trim();if(!t)return null;const n=t.match(/query\s*=\s*"""([\s\S]*?)"""/i);if(n)return n[1].trim()||null;const r=t.match(/"""([\s\S]*?)"""/);if(r)return r[1].trim()||null;if(/^\s*(dashboard|workbook)\s+"/i.test(t))return null;const o=t.match(/\b(SELECT|WITH|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|SHOW|DESCRIBE|EXPLAIN)\b([\s\S]*)/i);if(o){let i=o[0];const l=i.search(/\b(visualization|tests|block)\s*\{/i);return l>0&&(i=i.slice(0,l)),i=_0(i),i.trim()||null}return null}function _0(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==="("){t++;continue}if(r===")"){t>0&&t--;continue}if(r==="'"||r==='"'){for(n++;n<e.length&&e[n]!==r;)e[n]==="\\"&&n++,n++;continue}if(r===","&&t===0){let o=n+1;for(;o<e.length&&/\s/.test(e[o]);)o++;if(o<e.length&&/[a-zA-Z_]/.test(e[o])){for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let i=o;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="="&&e[i+1]!=="=")return e.slice(0,n)}}}return e}function p1(e){const t=Gs(e);return t?{name:t.name,domain:t.domain,owner:t.owner,description:t.description,blockType:t.blockType,status:t.status,tags:t.tags,llmContext:t.llmContext}:null}function O0(e,t,n){const r=n.replace(/"/g,'\\"'),o=new RegExp(`(\\b${t}\\s*=\\s*)"[^"]*"`,"i");return o.test(e)?e.replace(o,`$1"${r}"`):En(e,` ${t} = "${r}"`)}function $0(e,t){const n=t.replace(/"/g,'\\"');return/^\s*block\s+"/i.test(e)?e.replace(/^(\s*block\s+)"[^"]+"/i,`$1"${n}"`):e}function f1(e,t){const n=t.map(o=>`"${o.replace(/"/g,'\\"')}"`).join(", "),r=/(\btags\s*=\s*)\[[^\]]*\]/i;return r.test(e)?e.replace(r,`$1[${n}]`):En(e,` tags = [${n}]`)}function h1(e,t,n){const r=Array.from(new Set(n.map(l=>l.trim()).filter(Boolean))),o=`${t} = [${r.map(l=>`"${Lt(l)}"`).join(", ")}]`,i=new RegExp(`(\\b${t}\\s*=\\s*)\\[[\\s\\S]*?\\]`,"i");return i.test(e)?e.replace(i,`$1[${r.map(l=>`"${Lt(l)}"`).join(", ")}]`):En(e,` ${o}`)}function m1(e,t){const n=/visualization\s*\{[\s\S]*?\n\s*\}/i;if(!n.test(e)){const r=I0(t);return En(e,` ${r.replace(/\n/g,`
|
|
503
|
-
`)}`,!0)}return e.replace(n,r=>{let o=r;for(const[i,l]of Object.entries(t)){if(l==null||l==="")continue;const a=String(l).replace(/"/g,'\\"'),d=new RegExp(`(\\b${i}\\s*=\\s*)"[^"]*"`,"i");d.test(o)?o=o.replace(d,`$1"${a}"`):o=o.replace(/\n(\s*)\}$/,`
|
|
504
|
-
$1 ${i} = "${a}"
|
|
505
|
-
$1}`)}return o})}function D0(e,t){var r;const n=e.match(new RegExp(`\\b${t}\\s*\\{([\\s\\S]*?)\\n\\s*\\}`,"i"));return((r=n==null?void 0:n[1])==null?void 0:r.split(/\r?\n/).map(o=>o.replace(/^\s{4}/,"")).join(`
|
|
506
|
-
`).trim())??""}function Kr(e,t,n){const r=n.trim(),o=r?` ${t} {
|
|
507
|
-
${r.split(/\r?\n/).map(l=>` ${l.trimEnd()}`).join(`
|
|
508
|
-
`)}
|
|
509
|
-
}`:"",i=new RegExp(`\\n\\s*${t}\\s*\\{[\\s\\S]*?\\n\\s*\\}`,"i");return i.test(e)?e.replace(i,o?`
|
|
510
|
-
${o}`:""):o?/\n\s*visualization\s*\{/i.test(e)?e.replace(/\n\s*visualization\s*\{/i,`
|
|
511
|
-
${o}
|
|
512
|
-
|
|
513
|
-
visualization {`):En(e,o,!0):e}function g1(e,t){return e==="metric"?`@metric(${t})`:`@dim(${t})`}function y1(e,t){const n=Gs(e);if(!n||n.blockType!=="custom")return`${e.trimEnd()}
|
|
514
|
-
${t}
|
|
515
|
-
`;const r=n.query.trimEnd(),o=r?`${r}
|
|
516
|
-
${t}`:t;return P0(e,o)}function P0(e,t){if(!Gs(e))return e;const r=O0(e,"type","custom"),o=` query = """
|
|
517
|
-
${t.trimEnd()}
|
|
518
|
-
"""`,i=/\n\s*query\s*=\s*"""[\s\S]*?"""/i;return i.test(r)?r.replace(i,`
|
|
519
|
-
${o}`):En(r,o,!0)}function Gs(e){var i,l;if(!/^\s*block\s+"/i.test(e.trim()))return null;const t=a=>{var d;return((d=e.match(new RegExp(`\\b${a}\\s*=\\s*"([^"]*)"`,"i")))==null?void 0:d[1])??""},n=((i=e.match(/^\s*block\s+"([^"]+)"/i))==null?void 0:i[1])??"",r=e.match(/\btags\s*=\s*\[([^\]]*)\]/i),o=e.match(/query\s*=\s*"""([\s\S]*?)"""/i);return{name:n,domain:t("domain"),owner:t("owner"),description:t("description"),llmContext:t("llmContext"),status:t("status")||"draft",blockType:(t("type")||"custom").toLowerCase()==="semantic"?"semantic":"custom",tags:r?(r[1].match(/"([^"]*)"/g)??[]).map(a=>a.slice(1,-1)):[],metric:t("metric"),metrics:$n(e,"metrics"),dimensions:$n(e,"dimensions"),requestedFilters:$n(e,"requested_filters"),sourceDqlKind:t("source_dql_kind"),sourceDqlName:t("source_dql_name"),sourceDqlPath:t("source_dql_path"),sourceDqlHash:t("source_dql_hash"),sourceDqlMetrics:$n(e,"source_dql_metrics"),sourceDqlDimensions:$n(e,"source_dql_dimensions"),timeDimension:t("time_dimension"),granularity:t("granularity"),query:((l=o==null?void 0:o[1])==null?void 0:l.trim())??"",visualization:Aa(e,"visualization"),tests:Aa(e,"tests")}}function $n(e,t){const n=e.match(new RegExp(`\\b${t}\\s*=\\s*\\[([\\s\\S]*?)\\]`,"i"));return n?(n[1].match(/"([^"]*)"/g)??[]).map(r=>r.slice(1,-1)).filter(Boolean):[]}function Aa(e,t){const n=new RegExp(`\\b${t}\\s*\\{`,"i").exec(e);if(!n||n.index==null)return"";let r=0,o=-1;for(let i=n.index;i<e.length;i++){const l=e[i];if(l==="{")r===0&&(o=i),r++;else if(l==="}"&&(r--,r===0&&o>=0))return e.slice(n.index,i+1).trim()}return""}function I0(e){const t=[];return t.push("visualization {"),t.push(` chart = "${e.chart??"table"}"`),e.x&&t.push(` x = ${e.x}`),e.y&&t.push(` y = ${e.y}`),e.color&&t.push(` color = ${e.color}`),e.title&&t.push(` title = "${M0(e.title)}"`),t.push("}"),t.join(`
|
|
520
|
-
`)}function M0(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function En(e,t,n=!1){const r=e.trimEnd();if(!/^\s*block\s+"/i.test(r))return`${r}
|
|
521
|
-
${t}
|
|
522
|
-
`;const o=n?`
|
|
523
|
-
|
|
524
|
-
${t}
|
|
525
|
-
`:`
|
|
526
|
-
${t}`;return r.replace(/\n\}\s*$/,`${o}
|
|
527
|
-
}`)}function Ra(e,t){return t.filter(n=>n.datasetId&&(n.objectType==="dataset"||n.objectType==="staged_dataset")).filter(n=>Od(n.name).test(e)).map(n=>({id:n.datasetId,alias:n.name,role:n.objectType==="staged_dataset"?"staged":"source",fingerprint:n.fileFingerprint}))}function L0(e,t){return t.filter(n=>n.source==="database").filter(n=>Od(n.name).test(e)).map(n=>n.name)}function x1(e,t){const n=[];for(const r of e)for(const o of t){const i=N0(r,o.name,o.flags??[]);i.score>0&&n.push({warehouseKey:r,localKey:o.name,...i})}return n.sort((r,o)=>o.score-r.score||r.warehouseKey.localeCompare(o.warehouseKey)).slice(0,12)}function b1(e){const t=e.warehouseRows.map(o=>o[e.warehouseKey]).filter(o=>o!=null);if(t.length===0||!e.localSampledRows||e.localDistinctCount===void 0)return"unknown";const n=new Set(t.map(F0)).size===t.length,r=e.localDistinctCount>=e.localSampledRows;return n&&r?"one_to_one":n?"one_to_many":r?"many_to_one":"many_to_many"}function v1(e){const t=new Set(e.staged.columns??[]),r=[" warehouse.*",...(e.local.columns??[]).filter(i=>i!==e.localKey).map(i=>{const l=t.has(i)?`local_${i}`:i;return` local_data.${un(i)} AS ${un(l)}`})];return{id:`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,type:"sql",name:`${e.local.alias}_${e.staged.alias}_analysis`,content:["-- Local research join: governed warehouse snapshot plus local dataset","-- Review required: verify join cardinality and freshness before sharing","SELECT",r.join(`,
|
|
528
|
-
`),`FROM ${un(e.staged.alias)} AS warehouse`,`${e.joinType.toUpperCase()} JOIN ${un(e.local.alias)} AS local_data`,` ON warehouse.${un(e.warehouseKey)} = local_data.${un(e.localKey)}`,"LIMIT 1000"].join(`
|
|
529
|
-
`),status:"idle",executionTarget:{target:"local"},datasetRefs:[{id:e.staged.id,alias:e.staged.alias,role:"staged",fingerprint:e.staged.fileFingerprint},{id:e.local.id,alias:e.local.alias,role:"source",fingerprint:e.local.fileFingerprint}],dependencies:[{cellId:e.sourceCell.id}],annotations:[{id:`note_${Date.now()}_join`,body:`Combined ${e.staged.alias} (${e.staged.refreshedAt}) with ${e.local.alias} (${e.local.refreshedAt}) using ${e.warehouseKey} = ${e.localKey}. Review required.`,createdAt:new Date().toISOString(),author:"DQL"}]}}function N0(e,t,n){const r=e.toLowerCase(),o=t.toLowerCase();if(r===o)return{score:100,reason:"Same column name"};const i=_a(r),l=_a(o);return i===l?{score:90,reason:"Same normalized name"}:(i.endsWith(l)||l.endsWith(i))&&(i.endsWith("id")||l.endsWith("id"))?{score:n.includes("identifier")?78:70,reason:"Related identifier names"}:Oa(r).filter(d=>Oa(o).includes(d)).length>0&&(r.includes("id")||o.includes("id"))?{score:n.includes("identifier")?62:55,reason:"Shared entity identifier"}:{score:0,reason:""}}function _a(e){return e.replace(/[^a-z0-9]/g,"").replace(/identifier$/,"id")}function Oa(e){return e.split(/[^a-z0-9]+/).filter(t=>t.length>1)}function Od(e){return new RegExp(`(?:^|[^a-zA-Z0-9_])(?:["\`])?${B0(e)}(?:["\`])?(?=$|[^a-zA-Z0-9_])`,"i")}function un(e){return`"${e.replace(/"/g,'""')}"`}function B0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F0(e){return typeof e=="string"?e:JSON.stringify(e)}const Ht=new Map,Ot=new Map;function zo(e){const t=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`;return`cellrun_${e}_${t}`}function z0(e){if(e.type==="markdown"||e.type==="param")return null;if(e.type==="sql")return e.content.trim()||null;const t=e.content.trim();return t?R0(t):null}function q0(e){if(!e||typeof e!="object")return;const t=e;return{...typeof t.chart=="string"?{chart:t.chart}:{},...typeof t.x=="string"?{x:t.x}:{},...typeof t.y=="string"?{y:t.y}:{},...typeof t.color=="string"?{color:t.color}:{},...typeof t.title=="string"?{title:t.title}:{}}}function Fn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function U0(e){const t=Fn(e);if((t==null?void 0:t.target)==="local")return{target:"local"};if((t==null?void 0:t.target)==="connection")return{target:"connection",...typeof t.connectionName=="string"?{connectionName:t.connectionName}:{}}}function Dn(e,t,n){return new rt({status:400,code:e,message:t,recoverable:!0,details:{phase:"preflight",...n}})}function Er(e){const t=e.error instanceof rt?e.error:void 0,n=Fn(t==null?void 0:t.details),r=Fn(n==null?void 0:n.semanticTrace);return{version:1,runId:e.runId,cellId:e.cell.id,route:e.route,status:e.status??"error",startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,executionTarget:e.cell.executionTarget??U0(n==null?void 0:n.executionTarget),compiledSql:e.attemptedSql,semanticTrace:r,targetBinding:Fn(n==null?void 0:n.targetBinding),executionReceipt:Fn(n==null?void 0:n.executionReceipt),error:{code:t==null?void 0:t.code,phase:typeof(n==null?void 0:n.phase)=="string"?n.phase:"execution",message:e.message,details:t==null?void 0:t.details}}}function Tr(e,t){return e.map(n=>n.id!==t.cellId?n:t.status==="success"?{...n,status:"success",result:t.result,error:void 0,execution:t.execution,executionCount:(n.executionCount??0)+1,stale:!1}:t.status==="error"||t.status==="blocked"||t.status==="cancelled"?{...n,status:t.status==="cancelled"?"idle":"error",result:void 0,error:t.status==="cancelled"?void 0:t.error,execution:t.execution,executionCount:(n.executionCount??0)+1,stale:!1}:n)}function $d(){const{state:e,dispatch:t}=Se(),n=u.useRef(e);n.current=e;const r=u.useCallback(async(a,d)=>{var g,$,_,R;const c=n.current,f=d??c.cells,p=f.find(A=>A.id===a);if(!p)return{cellId:a,status:"skipped"};const h=p.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",y=p.type==="dql"?null:z0(p);if(p.type!=="dql"&&!y)return{cellId:a,status:"skipped"};const S=Ht.get(a);S&&S.controller.abort();const x=zo(a),b=new Date().toISOString(),w=Date.now(),C=new AbortController,E={controller:C,runId:x,startedAt:b,route:h,executionTarget:p.executionTarget};Ht.set(a,E),Ot.set(a,x);const v=()=>{var A;return((A=Ht.get(a))==null?void 0:A.runId)===x&&Ot.get(a)===x},j=(p.executionCount??0)+1;let O=y??void 0;t({type:"UPDATE_CELL",id:a,updates:{status:"running",error:void 0,result:void 0,execution:void 0,fromSnapshot:!1}});const T=(A,M,B="error")=>{const K=new Date().toISOString(),G=Er({cell:p,runId:x,route:h,startedAt:b,completedAt:K,durationMs:Date.now()-w,message:A,error:M,status:B,attemptedSql:O});return v()&&(t({type:"UPDATE_CELL",id:a,updates:{status:B==="cancelled"?"idle":"error",error:B==="cancelled"?void 0:A,result:void 0,execution:G,executionCount:j,stale:!1}}),t({type:"APPEND_QUERY_LOG",entry:{id:nt(),cellName:p.name??p.id,rows:0,time:G.durationMs,ts:new Date,...B==="cancelled"?{}:{error:A}}})),{cellId:a,runId:x,status:B,error:B==="cancelled"?void 0:A,execution:G}};try{if(p.type==="dql"){const ie=await N.executeNotebookCell(p,C.signal,{notebookPath:(g=c.activeFile)==null?void 0:g.path,cellId:p.id,cellName:p.name,source:h,runId:x});if(!ie.result)throw new Error("DQL cell produced no executable result.");if(!v())return{cellId:a,runId:x,status:"cancelled"};const ge=new Date().toISOString(),Oe=Date.now()-w,$e={...ie.result,executionTime:ie.result.executionTime??Oe,rowCount:ie.result.rowCount??ie.result.rows.length},Ne=q0(ie.chartConfig)??A0(p.content),xe={version:1,runId:x,cellId:a,route:h,status:"success",startedAt:b,completedAt:ge,durationMs:Oe,executionTarget:ie.executionTarget??p.executionTarget,engine:ie.engine,compiledSql:ie.compiledSql,executedSql:ie.executedSql,semanticTrace:ie.semanticTrace,targetBinding:ie.targetBinding,executionReceipt:ie.executionReceipt};return t({type:"UPDATE_CELL",id:a,updates:{status:"success",result:$e,error:void 0,execution:xe,executionTarget:ie.executionTarget??p.executionTarget,...Ne?{chartConfig:Ne}:{},executionCount:j,stale:!1}}),t({type:"APPEND_QUERY_LOG",entry:{id:nt(),cellName:ie.blockName??p.name??p.id,rows:$e.rowCount??$e.rows.length,time:$e.executionTime??Oe,ts:new Date}}),setTimeout(()=>{Ot.get(a)===x&&(t({type:"UPDATE_CELL",id:a,updates:{status:"idle"}}),Ot.delete(a))},2e3),{cellId:a,runId:x,status:"success",result:$e,execution:xe}}const A=Ra(y,c.schemaTables),M=L0(y,c.schemaTables);if(A.length>0&&M.length>0){const ie=[`Mixed-source query detected: ${M.join(", ")} runs in the warehouse, while ${A.map(ge=>ge.alias??ge.id).join(", ")} is local data.`,"Direct cross-engine joins are not executed. Run the warehouse-only extraction first, then choose Combine with local data on its result."].join(" ");return T(ie,Dn("CROSS_ENGINE_JOIN_REQUIRED",ie,{warehouseTables:M,datasets:A.map(ge=>ge.alias??ge.id)}))}const B=A.length>0?{target:"local"}:p.executionTarget;A.length>0&&(($=p.executionTarget)==null?void 0:$.target)!=="local"&&t({type:"UPDATE_CELL",id:a,updates:{executionTarget:B,datasetRefs:A}});const K=k0(y,f);if(K.ambiguous.length>0){const ie=`Ambiguous notebook dependency: ${K.ambiguous.join(", ")} matches more than one cell. Rename the duplicate cells or reference a stable cell ID.`;return T(ie,Dn("AMBIGUOUS_NOTEBOOK_DEPENDENCY",ie,{ambiguousReferences:K.ambiguous}))}if(K.unresolved.length>0){const ie=`Notebook dependency result is unavailable: ${K.unresolved.join(", ")}. Run or repair the upstream cell before retrying this cell.`;return T(ie,Dn("UPSTREAM_RESULT_UNAVAILABLE",ie,{unresolvedReferences:K.unresolved}))}O=K.sql;const G=await N.executeQuery(K.sql,C.signal,{notebookPath:(_=c.activeFile)==null?void 0:_.path,cellId:p.id,cellName:p.name,source:h,runId:x},B);if(!v())return{cellId:a,runId:x,status:"cancelled"};const V=new Date().toISOString(),I=Date.now()-w,{executionTarget:D,compiledSql:Y,executedSql:U,targetBinding:te,executionReceipt:Q,...F}=G,ee={...F,executionTime:F.executionTime??I,rowCount:F.rowCount??F.rows.length},ce=(B==null?void 0:B.target)==="local"?Ra(K.sql,c.schemaTables):p.datasetRefs,ue={version:1,runId:x,cellId:a,route:h,status:"success",startedAt:b,completedAt:V,durationMs:I,executionTarget:D??B,compiledSql:Y??K.sql,executedSql:U??K.sql,targetBinding:te,executionReceipt:Q};return t({type:"UPDATE_CELL",id:a,updates:{status:"success",result:ee,error:void 0,execution:ue,executionCount:j,stale:!1,datasetRefs:ce,executionTarget:D??B}}),t({type:"APPEND_QUERY_LOG",entry:{id:nt(),cellName:p.name??p.id,rows:ee.rowCount??ee.rows.length,time:ee.executionTime??I,ts:new Date}}),setTimeout(()=>{Ot.get(a)===x&&(t({type:"UPDATE_CELL",id:a,updates:{status:"idle"}}),Ot.delete(a))},2e3),{cellId:a,runId:x,status:"success",result:ee,execution:ue}}catch(A){if(C.signal.aborted||!v())return T("Cell execution was cancelled.",A,"cancelled");const M=A instanceof Error?A.message:String(A);return T(M,A)}finally{((R=Ht.get(a))==null?void 0:R.runId)===x&&Ht.delete(a)}},[t]),o=u.useCallback(async()=>{const a=n.current.cells,d=vg(a);let c=a.map(h=>({...h}));const f=new Map,p=new Map;for(const h of d.missing)p.set(h.cellId,[...p.get(h.cellId)??[],h.dependency]);for(const h of d.cycleCellIds){const y=c.find(E=>E.id===h);if(!y)continue;const S=zo(h),x=new Date().toISOString(),b="Dependency cycle detected. Update the cell dependencies before running all.",w=Er({cell:y,runId:S,route:y.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",startedAt:x,completedAt:x,durationMs:0,message:b,error:Dn("DEPENDENCY_CYCLE",b,{cycleCellIds:d.cycleCellIds}),status:"blocked"}),C={cellId:h,runId:S,status:"blocked",error:b,execution:w};f.set(h,C),c=Tr(c,C),t({type:"UPDATE_CELL",id:h,updates:{status:"error",error:b,result:void 0,execution:w,executionCount:(y.executionCount??0)+1,stale:!1}})}for(const h of d.ordered){const y=c.find(w=>w.id===h.id)??h,S=p.get(y.id)??[],x=Is(y,c).filter(w=>{const C=f.get(w.cellId);return C&&C.status!=="success"});if(S.length>0||x.length>0){const w=[...S,...x.map(T=>{var g;return((g=c.find($=>$.id===T.cellId))==null?void 0:g.name)??T.cellId})],C=zo(y.id),E=new Date().toISOString(),v=`Not executed because ${w.join(", ")} did not produce a valid upstream result.`,j=Er({cell:y,runId:C,route:y.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",startedAt:E,completedAt:E,durationMs:0,message:v,error:Dn("UPSTREAM_EXECUTION_FAILED",v,{blockedBy:w}),status:"blocked"}),O={cellId:y.id,runId:C,status:"blocked",error:v,execution:j};f.set(y.id,O),c=Tr(c,O),t({type:"UPDATE_CELL",id:y.id,updates:{status:"error",error:v,result:void 0,execution:j,executionCount:(y.executionCount??0)+1,stale:!1}});continue}const b=await r(y.id,c);f.set(y.id,b),c=Tr(c,b)}},[t,r]),i=u.useCallback(async a=>{if(!a)return;const d=`{{${a}}}`;let c=n.current.cells.map(f=>({...f}));for(const f of c){if(f.type==="markdown"||f.type==="param"||!f.content.includes(d))continue;const p=await r(f.id,c);c=Tr(c,p)}},[r]),l=u.useCallback(a=>{const d=Ht.get(a);if(!d)return;d.controller.abort(),Ht.delete(a),Ot.get(a)===d.runId&&Ot.delete(a);const c=new Date().toISOString(),f=n.current.cells.find(p=>p.id===a);t({type:"UPDATE_CELL",id:a,updates:{status:"idle",error:void 0,result:void 0,...f?{execution:Er({cell:f,runId:d.runId,route:d.route,startedAt:d.startedAt,completedAt:c,durationMs:Date.parse(c)-Date.parse(d.startedAt),message:"Cell execution was cancelled.",status:"cancelled"}),executionCount:(f.executionCount??0)+1}:{}}})},[t]);return{executeCell:r,executeAll:o,executeDependents:i,cancelCell:l}}function Je(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function W0(e){return typeof e=="number"?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(2):""}function K0(e){const t=e.split(`
|
|
530
|
-
`),n=[];let r=!1,o=!1;for(const i of t){const l=i;if(l.startsWith("```")){o&&(n.push("</ul>"),o=!1),r?(n.push("</code></pre>"),r=!1):(n.push("<pre><code>"),r=!0);continue}if(r){n.push(Je(l));continue}if(l.startsWith("### ")){o&&(n.push("</ul>"),o=!1),n.push(`<h3>${Je(l.slice(4))}</h3>`);continue}if(l.startsWith("## ")){o&&(n.push("</ul>"),o=!1),n.push(`<h2>${Je(l.slice(3))}</h2>`);continue}if(l.startsWith("# ")){o&&(n.push("</ul>"),o=!1),n.push(`<h1>${Je(l.slice(2))}</h1>`);continue}if(l.startsWith("> ")){o&&(n.push("</ul>"),o=!1),n.push(`<blockquote><p>${Je(l.slice(2))}</p></blockquote>`);continue}if(l.startsWith("- ")||l.startsWith("* ")){o||(n.push("<ul>"),o=!0),n.push(`<li>${$a(l.slice(2))}</li>`);continue}if(o&&(n.push("</ul>"),o=!1),l.trim()===""){n.push("<br>");continue}n.push(`<p>${$a(l)}</p>`)}return o&&n.push("</ul>"),r&&n.push("</code></pre>"),n.join(`
|
|
531
|
-
`)}function $a(e){return Je(e).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>")}function V0(e){const{columns:t,rows:n}=e,r=n.slice(0,200),o=n.length>200,i=t.map(a=>`<th>${Je(a)}</th>`).join(""),l=r.map(a=>`<tr>${t.map(c=>{const f=a[c],p=typeof f=="number",h=f==null?"—":String(f);return`<td${p?' class="num"':""}>${Je(h)}</td>`}).join("")}</tr>`).join("");return`
|
|
532
|
-
<div class="table-wrap">
|
|
533
|
-
<table>
|
|
534
|
-
<thead><tr>${i}</tr></thead>
|
|
535
|
-
<tbody>${l}</tbody>
|
|
536
|
-
</table>
|
|
537
|
-
${o?`<p class="truncated">Showing first 200 of ${n.length.toLocaleString()} rows</p>`:""}
|
|
538
|
-
</div>`}function H0(e){const{columns:t,rows:n}=e;if(t.length<2||n.length===0)return null;const r=t.find(i=>typeof n[0][i]=="number"),o=t.find(i=>i!==r);return!r||!o?null:{labelCol:o,valueCol:r}}function G0(e){const t=H0(e);if(!t)return null;const n=e.rows.slice(0,20).map(f=>({label:String(f[t.labelCol]??""),value:Number(f[t.valueCol]??0)})),r=Math.max(...n.map(f=>f.value),1),o=28,i=6,l=140,a=440,d=n.length*(o+i)+40,c=n.map((f,p)=>{const h=p*(o+i)+20,y=Math.max(f.value/r*a,2);return`
|
|
539
|
-
<text x="${l-6}" y="${h+o/2+4}" text-anchor="end" font-size="11" fill="#8b949e">${Je(f.label.slice(0,20))}</text>
|
|
540
|
-
<rect x="${l}" y="${h}" width="${y}" height="${o}" rx="3" fill="#388bfd" />
|
|
541
|
-
<text x="${l+y+5}" y="${h+o/2+4}" font-size="11" fill="#e6edf3">${W0(f.value)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${l+a+80}" height="${d}" style="max-width:100%">${c}</svg>`}function J0(e,t){const n=t.map(r=>{if(r.type==="markdown")return`<section class="cell md-cell">${K0(r.content)}</section>`;const o=r.name?`<div class="cell-header"><span class="cell-type">${r.type.toUpperCase()}</span><span class="cell-name">${Je(r.name)}</span></div>`:`<div class="cell-header"><span class="cell-type">${r.type.toUpperCase()}</span></div>`,i=`<pre class="cell-code"><code>${Je(r.content)}</code></pre>`;let l="";if(r.result&&r.result.rows.length>0){const a=G0(r.result),d=V0(r.result);l=`<div class="cell-output">${`<div class="output-meta">${r.result.rows.length.toLocaleString()} rows${r.result.executionTime?` · ${r.result.executionTime}ms`:""}</div>`}${a??""}${a?"":d}</div>`}else r.error&&(l=`<div class="cell-error">⚠ ${Je(r.error)}</div>`);return`<section class="cell sql-cell">${o}${i}${l}</section>`}).join(`
|
|
542
|
-
`);return`<!DOCTYPE html>
|
|
543
|
-
<html lang="en">
|
|
544
|
-
<head>
|
|
545
|
-
<meta charset="UTF-8">
|
|
546
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
547
|
-
<title>${Je(e)}</title>
|
|
548
|
-
<style>
|
|
549
|
-
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
550
|
-
body {
|
|
551
|
-
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
552
|
-
background: #0d1117; color: #e6edf3;
|
|
553
|
-
line-height: 1.6; padding: 0;
|
|
554
|
-
}
|
|
555
|
-
.page-header {
|
|
556
|
-
background: #161b22; border-bottom: 1px solid #21262d;
|
|
557
|
-
padding: 16px 32px; display: flex; align-items: center; gap: 12px;
|
|
558
|
-
}
|
|
559
|
-
.logo {
|
|
560
|
-
width: 28px; height: 28px; border-radius: 6px;
|
|
561
|
-
background: linear-gradient(135deg, #388bfd, #1f6feb);
|
|
562
|
-
display: flex; align-items: center; justify-content: center;
|
|
563
|
-
font-size: 10px; font-weight: 700; color: #fff;
|
|
564
|
-
font-family: monospace; letter-spacing: -0.5px; flex-shrink: 0;
|
|
565
|
-
}
|
|
566
|
-
.page-title { font-size: 18px; font-weight: 600; color: #e6edf3; }
|
|
567
|
-
.page-meta { font-size: 12px; color: #8b949e; margin-left: auto; }
|
|
568
|
-
.content { max-width: 900px; margin: 0 auto; padding: 32px 24px; display: flex; flex-direction: column; gap: 24px; }
|
|
569
|
-
.cell { border-radius: 8px; overflow: hidden; }
|
|
570
|
-
.md-cell { padding: 4px 0; }
|
|
571
|
-
.md-cell h1 { font-size: 26px; font-weight: 700; color: #e6edf3; margin: 0 0 12px; }
|
|
572
|
-
.md-cell h2 { font-size: 20px; font-weight: 600; color: #e6edf3; margin: 20px 0 10px; }
|
|
573
|
-
.md-cell h3 { font-size: 16px; font-weight: 600; color: #e6edf3; margin: 16px 0 8px; }
|
|
574
|
-
.md-cell p { color: #c9d1d9; margin-bottom: 8px; }
|
|
575
|
-
.md-cell ul { padding-left: 20px; color: #c9d1d9; margin-bottom: 8px; }
|
|
576
|
-
.md-cell code { background: #21262d; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
|
|
577
|
-
.md-cell pre { background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 14px; overflow-x: auto; margin-bottom: 8px; }
|
|
578
|
-
.md-cell pre code { background: none; padding: 0; }
|
|
579
|
-
.md-cell blockquote { border-left: 3px solid #388bfd; padding-left: 14px; color: #8b949e; }
|
|
580
|
-
.sql-cell { background: #161b22; border: 1px solid #30363d; }
|
|
581
|
-
.cell-header { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid #21262d; background: #1c2128; }
|
|
582
|
-
.cell-type { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; color: #8b949e; background: #21262d; padding: 2px 6px; border-radius: 4px; font-family: monospace; }
|
|
583
|
-
.cell-name { font-size: 12px; color: #388bfd; font-family: monospace; }
|
|
584
|
-
.cell-code { background: #0d1117; padding: 14px; font-size: 12px; font-family: 'JetBrains Mono', monospace; color: #c9d1d9; overflow-x: auto; border-bottom: 1px solid #21262d; line-height: 1.55; white-space: pre; }
|
|
585
|
-
.cell-output { padding: 14px; }
|
|
586
|
-
.output-meta { font-size: 11px; color: #8b949e; margin-bottom: 10px; }
|
|
587
|
-
.table-wrap { overflow-x: auto; }
|
|
588
|
-
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
589
|
-
th { background: #1c2128; color: #8b949e; font-weight: 600; text-align: left; padding: 7px 12px; border-bottom: 1px solid #30363d; white-space: nowrap; }
|
|
590
|
-
td { padding: 6px 12px; border-bottom: 1px solid #21262d; color: #e6edf3; }
|
|
591
|
-
td.num { text-align: right; font-family: monospace; }
|
|
592
|
-
tr:last-child td { border-bottom: none; }
|
|
593
|
-
.truncated { font-size: 11px; color: #8b949e; margin-top: 8px; }
|
|
594
|
-
.cell-error { padding: 12px 14px; background: #3d1a1a; border-top: 1px solid #f85149; color: #f85149; font-size: 13px; }
|
|
595
|
-
.exported-by { text-align: center; color: #484f58; font-size: 11px; padding: 40px 0 24px; }
|
|
596
|
-
</style>
|
|
597
|
-
</head>
|
|
598
|
-
<body>
|
|
599
|
-
<div class="page-header">
|
|
600
|
-
<div class="logo">DQL</div>
|
|
601
|
-
<span class="page-title">${Je(e)}</span>
|
|
602
|
-
<span class="page-meta">Exported ${new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}</span>
|
|
603
|
-
</div>
|
|
604
|
-
<div class="content">
|
|
605
|
-
${n}
|
|
606
|
-
</div>
|
|
607
|
-
<p class="exported-by">Built with DQL Workbench</p>
|
|
608
|
-
</body>
|
|
609
|
-
</html>`}function Q0(e,t){const n=J0(e,t),r=new Blob([n],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function Y0({t:e}){return s.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #5b8cff 0%, #7c5cff 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function X0(){var te;const{state:e,dispatch:t}=Se(),n=qe[e.themeMode],{executeAll:r}=$d(),[o,i]=u.useState(!1),[l,a]=u.useState(""),[d,c]=u.useState(!1),[f,p]=u.useState(!1),[h,y]=u.useState(!1),[S,x]=u.useState(!1),[b,w]=u.useState(!1),C=u.useRef(null),[E,v]=u.useState(!1),[j,O]=u.useState(!1),T=u.useRef(null),g=u.useRef(null),$=e.mainView==="block_studio"?e.blockStudioDirty:e.notebookDirty,_=e.mainView==="notebook",R=e.mainView==="notebook"||e.mainView==="block_studio",A=R&&!!e.activeFile,M={home:"Home",business_artifact:((te=e.activeFile)==null?void 0:te.name.replace(/\.(dqlnb|dql)$/i,""))??"Business Definition",lineage:"Lineage",lineage_detail:"Lineage",connection:"Settings",apps:"Apps",git:"Source control",settings:"Settings",imports:"Import SQL",domains:"Domains",modeling:"Domains"},B=R?e.activeFile?e.notebookTitle||"Untitled":e.mainView==="block_studio"?"Blocks":"Notebooks":M[e.mainView]??"DQL Workbench";u.useEffect(()=>{o&&g.current&&(g.current.focus(),g.current.select())},[o]),u.useEffect(()=>{if(!j)return;function Q(F){T.current&&!T.current.contains(F.target)&&O(!1)}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[j]);const K=()=>{a(e.notebookTitle),i(!0)},G=()=>{i(!1),l.trim()&&l!==e.notebookTitle&&(e.mainView==="block_studio"&&e.blockStudioMetadata?(t({type:"SET_BLOCK_STUDIO_METADATA",metadata:{...e.blockStudioMetadata,name:l.trim()}}),t({type:"SET_BLOCK_STUDIO_DRAFT",draft:$0(e.blockStudioDraft,l.trim())})):t({type:"SET_NOTEBOOK_DIRTY",dirty:!0}))},V=u.useCallback(async()=>{var Q;if(e.activeFile){t({type:"SET_SAVING",saving:!0});try{if(e.mainView==="block_studio"){if(!e.blockStudioMetadata)return;const F=await N.saveBlockStudio({path:e.activeBlockPath,source:e.blockStudioDraft,metadata:{name:e.blockStudioMetadata.name,domain:e.blockStudioMetadata.domain,folderPath:e.blockStudioMetadata.folderPath,description:e.blockStudioMetadata.description,owner:e.blockStudioMetadata.owner,tags:e.blockStudioMetadata.tags}});t({type:"OPEN_BLOCK_STUDIO",file:{name:`${F.metadata.name}.dql`,path:F.path,type:"block",folder:"blocks"},payload:F}),e.files.some(ee=>ee.path===F.path)||t({type:"FILE_ADDED",file:{name:`${F.metadata.name}.dql`,path:F.path,type:"block",folder:"blocks"}})}else{const F=e.activeFile.type==="block"?((Q=e.cells[0])==null?void 0:Q.content)??"":b0(e.notebookTitle,e.cells,e.notebookMetadata);await N.saveNotebook(e.activeFile.path,F),t({type:"SET_NOTEBOOK_DIRTY",dirty:!1})}c(!0),setTimeout(()=>c(!1),2e3)}catch(F){console.error("Save failed:",F)}finally{t({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.activeBlockPath,e.blockStudioDraft,e.blockStudioMetadata,e.files,e.mainView,e.notebookTitle,e.notebookMetadata,e.cells,t]);u.useEffect(()=>{const Q=F=>{(F.metaKey||F.ctrlKey)&&F.key==="s"&&(F.preventDefault(),V())};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[V]),u.useEffect(()=>{if(!e.autoSave||!$||!e.activeFile||e.mainView==="block_studio")return;const Q=setTimeout(()=>{V()},750);return()=>clearTimeout(Q)},[e.autoSave,$,e.activeFile,e.cells,e.blockStudioDraft,V]);const I=[{mode:"obsidian",label:"Obsidian",glyph:"●",swatch:"#0d0e11"},{mode:"paper",label:"Paper",glyph:"☼",swatch:"#f7f4ed"},{mode:"white",label:"White",glyph:"○",swatch:"#ffffff"}],D=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode,Y=I.find(Q=>Q.mode===D)??I[0];u.useEffect(()=>{if(!b)return;const Q=ee=>{C.current&&!C.current.contains(ee.target)&&w(!1)},F=ee=>{ee.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",Q),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",Q),document.removeEventListener("keydown",F)}},[b]);const U={height:28,padding:"0 10px",borderRadius:6,border:`1px solid ${n.btnBorder}`,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s",whiteSpace:"nowrap"};return s.jsxs("div",{style:{height:48,flexShrink:0,background:n.headerBg,borderBottom:`1px solid ${n.headerBorder}`,display:"flex",alignItems:"center",padding:"0 12px",gap:8,userSelect:"none"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[s.jsx(Y0,{t:n}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile&&R&&s.jsx("span",{style:{fontSize:10,fontWeight:600,color:e.activeFile.type==="block"?"#e3b341":n.accent,background:`${e.activeFile.type==="block"?"#e3b341":n.accent}18`,borderRadius:4,padding:"2px 6px",fontFamily:n.font,textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:e.activeFile.type}),e.activeFile&&R?o?s.jsx("input",{ref:g,value:l,onChange:Q=>a(Q.target.value),onBlur:G,onKeyDown:Q=>{Q.key==="Enter"&&G(),Q.key==="Escape"&&i(!1)},style:{background:"transparent",border:`1px solid ${n.cellBorderActive}`,borderRadius:4,color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,padding:"2px 6px",outline:"none",minWidth:120,maxWidth:320}}):s.jsxs("span",{onClick:K,title:"Click to rename",style:{color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,cursor:"text",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"2px 4px",borderRadius:4,border:"1px solid transparent"},children:[B,$&&s.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):s.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:B||"DQL Workbench"})]}),s.jsx("div",{style:{flex:1}}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.appMode==="studio"&&A&&e.mainView!=="block_studio"&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:_?r:void 0,disabled:!e.activeFile||!_,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{...U,height:30,padding:"0 14px",borderRadius:999,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:!e.activeFile||!_?.4:f?.9:1,boxShadow:"0 1px 2px rgba(107,93,211,0.25)",gap:6},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run all"]})}),s.jsxs("div",{ref:C,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>w(Q=>!Q),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),title:`Theme: ${Y.label}`,"aria-haspopup":"true","aria-expanded":b,style:{...U,background:S||b?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 10px",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{width:12,height:12,borderRadius:3,background:Y.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,letterSpacing:"0.04em"},children:Y.label}),s.jsx("span",{style:{fontSize:8,color:n.textMuted},children:"▾"})]}),b&&s.jsx("div",{role:"menu",style:{position:"absolute",top:"100%",right:0,marginTop:4,minWidth:160,background:n.headerBg,border:`1px solid ${n.headerBorder}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.32)",padding:4,zIndex:1e3,display:"flex",flexDirection:"column",gap:1},children:I.map(Q=>{const F=Q.mode===D;return s.jsxs("button",{role:"menuitemradio","aria-checked":F,onClick:()=>{t({type:"SET_THEME",mode:Q.mode}),w(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",background:F?n.btnHover:"transparent",color:n.textPrimary,cursor:"pointer",borderRadius:4,fontSize:12,fontFamily:n.font,textAlign:"left"},onMouseEnter:ee=>{F||(ee.currentTarget.style.background=n.btnHover)},onMouseLeave:ee=>{F||(ee.currentTarget.style.background="transparent")},children:[s.jsx("span",{style:{width:14,height:14,borderRadius:3,background:Q.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{flex:1},children:Q.label}),F&&s.jsx("span",{style:{color:n.accent,fontSize:11},children:"✓"})]},Q.mode)})})]}),e.appMode==="studio"&&A&&e.mainView!=="block_studio"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:V,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),title:"Save (Cmd+S)",style:{...U,background:h&&e.activeFile?n.btnHover:n.btnBg,color:d?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?s.jsxs(s.Fragment,{children:[s.jsx(ew,{}),"Saving…"]}):d?s.jsx(s.Fragment,{children:"✓ Saved"}):s.jsx(s.Fragment,{children:"Save"})}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),A&&e.mainView!=="block_studio"&&s.jsxs("div",{ref:T,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>{e.activeFile&&O(Q=>!Q)},disabled:!e.activeFile,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),title:"Share / export",style:{...U,height:30,padding:"0 14px",borderRadius:999,background:(E||j)&&e.activeFile?"#2a2a30":"#1a1a1a",color:"#ffffff",border:"1px solid #1a1a1a",opacity:e.activeFile?1:.4,gap:6},children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M5.5 10.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Zm0-3a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75ZM3 3.75A1.75 1.75 0 0 1 4.75 2h6.586c.464 0 .909.184 1.237.513l1.914 1.914c.329.328.513.773.513 1.237v6.586A1.75 1.75 0 0 1 13.25 14h-8.5A1.75 1.75 0 0 1 3 12.25Z"})}),"Share",s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1,opacity:.7},children:s.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),j&&s.jsx("div",{style:{position:"absolute",top:32,right:0,zIndex:200,background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,minWidth:160,display:"flex",flexDirection:"column",gap:2},children:s.jsx(Z0,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{Q0(e.notebookTitle||"dashboard",e.cells),O(!1)}})})]})]})]})}function Z0({label:e,description:t,t:n,onClick:r}){const[o,i]=u.useState(!1);return s.jsxs("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.btnHover:"transparent",border:"none",borderRadius:5,cursor:"pointer",padding:"6px 10px",textAlign:"left",display:"flex",flexDirection:"column",gap:1,transition:"background 0.12s"},children:[s.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),s.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:t})]})}function ew(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[s.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),s.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function tw(e){return e.toTimeString().slice(0,8)}function nw(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function rw(){const{state:e,dispatch:t}=Se(),n=qe[e.themeMode],[r,o]=u.useState(!1),i=e.queryLog.filter(a=>a.error),l=a=>t({type:"SET_DEV_PANEL_TAB",tab:a});return s.jsxs("div",{style:{height:e.devPanelOpen?180:0,flexShrink:0,background:n.sidebarBg,borderTop:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden",transition:"height 0.2s ease",position:"relative"},children:[e.devPanelOpen&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{height:32,flexShrink:0,display:"flex",alignItems:"center",borderBottom:`1px solid ${n.headerBorder}`,padding:"0 8px",gap:2},children:[["logs","errors"].map(a=>s.jsx(ow,{label:a==="errors"?`Errors${i.length>0?` (${i.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>l(a),t:n},a)),s.jsx("div",{style:{flex:1}}),s.jsx("button",{onClick:()=>t({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),s.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?s.jsx(Da,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>s.jsx(Pa,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(i.length===0?s.jsx(Da,{t:n,message:"No errors."}):[...i].reverse().map(a=>s.jsx(Pa,{entry:a,t:n},a.id)))]})]}),s.jsxs("button",{onClick:()=>t({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),title:e.devPanelOpen?"Close panel":"Open dev panel",style:{position:"absolute",bottom:e.devPanelOpen?4:-28,right:8,height:22,padding:"0 8px",borderRadius:"4px 4px 0 0",borderTop:`1px solid ${n.headerBorder}`,borderLeft:`1px solid ${n.headerBorder}`,borderRight:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:`1px solid ${n.headerBorder}`,background:r?n.btnHover:n.sidebarBg,color:n.textMuted,cursor:"pointer",fontSize:11,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, bottom 0.2s ease",zIndex:10},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function ow({label:e,active:t,onClick:n,t:r}){const[o,i]=u.useState(!1);return s.jsx("button",{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:t?`2px solid ${r.accent}`:"2px solid transparent",cursor:"pointer",color:t?r.textPrimary:o?r.textSecondary:r.textMuted,fontSize:12,fontFamily:r.font,fontWeight:t?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function Da({t:e,message:t}){return s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:t})}function Pa({entry:e,t}){return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:t.fontMono,color:e.error?t.error:t.textSecondary,borderLeft:e.error?`2px solid ${t.error}`:"2px solid transparent"},children:[s.jsx("span",{style:{color:t.textMuted,flexShrink:0},children:tw(e.ts)}),s.jsx("span",{style:{flexShrink:0,color:t.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?s.jsx("span",{style:{color:t.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{style:{color:t.textMuted},children:[e.rows.toLocaleString()," rows"]}),s.jsx("span",{style:{color:t.textMuted},children:nw(e.time)})]})]})}function sw(){const{state:e,dispatch:t}=Se(),{executeAll:n}=$d();u.useEffect(()=>{const r=o=>{const i=o.metaKey||o.ctrlKey;if(i&&o.key==="b"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_SIDEBAR"});return}if(i&&o.shiftKey&&o.key==="Enter"){o.preventDefault(),e.activeFile&&n();return}if(i&&o.key==="j"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_DEV_PANEL"});return}if(i&&o.key==="d"&&!o.shiftKey){o.preventDefault(),e.activeFile&&t({type:"TOGGLE_DASHBOARD_MODE"});return}if(o.key==="Escape"){if(e.dashboardMode){t({type:"TOGGLE_DASHBOARD_MODE"});return}if(e.newNotebookModalOpen){t({type:"CLOSE_NEW_NOTEBOOK_MODAL"});return}if(e.newBlockModalOpen){t({type:"CLOSE_NEW_BLOCK_MODAL"});return}}};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,n,e.activeFile,e.newNotebookModalOpen,e.newBlockModalOpen,e.dashboardMode])}const iw=600;function aw(e,t){const n=t.filter(r=>r.result||r.error||(r.executionCount??0)>0).map(r=>{var o;return{cellId:r.id,status:r.status,result:r.result,error:r.error,executionCount:r.executionCount,executedAt:((o=r.execution)==null?void 0:o.completedAt)??new Date().toISOString(),execution:r.execution}});return{version:1,notebookPath:e,capturedAt:new Date().toISOString(),cells:n}}function Ia(e){return e.map(t=>{var n,r;return`${t.id}:${((n=t.execution)==null?void 0:n.runId)??""}:${t.executionCount??0}:${((r=t.result)==null?void 0:r.rowCount)??-1}:${t.error??""}`}).join("|")}function lw(){var o;const{state:e}=Se(),t=u.useRef(null),n=u.useRef(""),r=u.useRef(null);u.useEffect(()=>{var a;const i=((a=e.activeFile)==null?void 0:a.path)??null;if(!i)return;if(i!==r.current){r.current=i,n.current=Ia(e.cells);return}const l=Ia(e.cells);return l!==n.current&&(n.current=l,t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{const d=aw(i,e.cells);N.saveRunSnapshot(i,d).catch(()=>{})},iw)),()=>{t.current&&(clearTimeout(t.current),t.current=null)}},[e.cells,(o=e.activeFile)==null?void 0:o.path])}const cw=u.lazy(()=>Ce(()=>import("./HomePage-DzAucwBW.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.HomePage}))),dw=u.lazy(()=>Ce(()=>import("./AnalyticsHome-Ba4Ve_Gd.js"),__vite__mapDeps([7,8,9,10,11,1,12,13,3,14,15,16,17,18,2,19,20,6])).then(e=>({default:e.AnalyticsHome}))),uw=u.lazy(()=>Ce(()=>import("./GlobalAiRail-Cys4n_rq.js"),__vite__mapDeps([21,9,10,11,1,12,13,3,14,15,16,17,18,2,19,22,23,24,6])).then(e=>({default:e.GlobalAiRail}))),pw=u.lazy(()=>Ce(()=>import("./NotebookEditor-EZ0pfWVs.js"),__vite__mapDeps([25,4,2,5,26,27,28,11,9,10,1,12,13,3,14,15,16,17,18,19,8,29,30,6,31,32,22,23,24])).then(e=>({default:e.NotebookEditor}))),fw=u.lazy(()=>Ce(()=>import("./NewNotebookModal-V6de8L4d.js"),__vite__mapDeps([33,4,15,6])).then(e=>({default:e.NewNotebookModal}))),hw=u.lazy(()=>Ce(()=>import("./NewBlockModal-9cDletl-.js"),__vite__mapDeps([34,6])).then(e=>({default:e.NewBlockModal}))),mw=u.lazy(()=>Ce(()=>import("./SetupOnboarding-Bg-MjbC9.js"),__vite__mapDeps([35,36,2,6])).then(e=>({default:e.SetupOnboarding}))),gw=u.lazy(()=>Ce(()=>import("./BlockStudio-Brg4fwn5.js"),__vite__mapDeps([37,26,27,11,29,30,6,31,9,10,1,12,13,3,14,15,16,17,18,2,19,22,23,24,38,39])).then(e=>({default:e.BlockStudio}))),yw=u.lazy(()=>Ce(()=>import("./BusinessArtifactView-CnTbFVGT.js"),__vite__mapDeps([40,29,30,6,31])).then(e=>({default:e.BusinessArtifactView}))),xw=u.lazy(()=>Ce(()=>import("./LineageDetailView-DdVH-nz6.js"),__vite__mapDeps([41,29,30,6,31,42,36,17])).then(e=>({default:e.LineageDetailView}))),bw=u.lazy(()=>Ce(()=>import("./LineageDAG-QHqd_AM5.js"),__vite__mapDeps([42,30,6,31])).then(e=>({default:e.LineageDAG}))),vw=u.lazy(()=>Ce(()=>import("./HelpDocsPage-CL0vbSER.js"),__vite__mapDeps([43,6])).then(e=>({default:e.HelpDocsPage}))),Sw=u.lazy(()=>Ce(()=>Promise.resolve().then(()=>qS),void 0).then(e=>({default:e.ConnectionPanel}))),ww=u.lazy(()=>Ce(()=>import("./GitPage-DHyDBChc.js"),__vite__mapDeps([44,45,15,6])).then(e=>({default:e.GitPage}))),kw=u.lazy(()=>Ce(()=>import("./ReadinessPage-BaGvjyfd.js"),__vite__mapDeps([46,1,47,48,13,3,2,6])).then(e=>({default:e.ReadinessPage}))),jw=u.lazy(()=>Ce(()=>import("./AgentLogPage-hzHqpD3-.js"),__vite__mapDeps([49,36,18,50,6])).then(e=>({default:e.AgentLogPage}))),Cw=u.lazy(()=>Ce(()=>import("./GovernedContextPage-DyKoDSZ2.js").then(e=>e.G),__vite__mapDeps([51,3,13,19,16,15])).then(e=>({default:e.GovernedContextPage}))),Ew=u.lazy(()=>Ce(()=>import("./DbtFirstModelingPage-CQe2FUZq.js"),__vite__mapDeps([52,51,3,13,19,16,15,30,6,31,32,24,38,50,14])).then(e=>({default:e.DbtFirstModelingPage}))),Tw=u.lazy(()=>Ce(()=>import("./AppsView-CdAT9BOq.js"),__vite__mapDeps([53,22,23,24,15,11,28,48,39,54,3,36,5,16,20,4,6])).then(e=>({default:e.AppsView}))),Aw=u.lazy(()=>Ce(()=>import("./LineageDrawer-BvrVZNKY.js"),__vite__mapDeps([55,29,30,6,31,38,15,23,14,54,45])).then(e=>({default:e.LineageDrawer}))),Rw=u.lazy(()=>Ce(()=>import("./AiBuildDialog-BQRWoxp9.js"),__vite__mapDeps([56,47,12,13,3,14,15,6])).then(e=>({default:e.AiBuildDialog})));function _w(){const{state:e,dispatch:t}=Se(),n=qe[e.themeMode],r=u.useRef({}),o=e.mainView==="block_studio"||e.mainView==="imports",[i,l]=u.useState(!1),[a,d]=u.useState(null),[c,f]=u.useState(!1);u.useEffect(()=>{let y=!0;return N.getSetupLaunch().then(S=>{y&&(d(S),S.shouldOpen&&t({type:"OPEN_SETUP"}))}).catch(()=>{}).finally(()=>{y&&f(!0)}),()=>{y=!1}},[t]),sw(),lw(),u.useEffect(()=>{const y=S=>{(S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"&&!S.shiftKey&&(S.preventDefault(),l(x=>!x)),(S.metaKey||S.ctrlKey)&&S.shiftKey&&S.key.toLowerCase()==="i"&&(S.preventDefault(),t({type:"TOGGLE_INSPECTOR"}))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t]);const p=u.useCallback(async y=>{try{if(y.type==="term"||y.type==="business_view"){e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"}),t({type:"OPEN_BUSINESS_ARTIFACT",file:y});return}if(y.type==="block"){const v=await N.openBlockStudio(y.path);t({type:"OPEN_BLOCK_STUDIO",file:y,payload:v});return}const{content:S}=await N.readNotebook(y.path),{title:x,cells:b,metadata:w}=v0(y.path,S),C=y.path.endsWith(".dqlnb")?await N.fetchRunSnapshot(y.path):null;let E=b;if(C!=null&&C.found&&C.snapshot){const v=new Map(C.snapshot.cells.map(j=>[j.cellId,j]));E=b.map(j=>{const O=v.get(j.id);return O?{...j,status:O.status??j.status,result:O.result??j.result,error:O.error??j.error,executionCount:O.executionCount??j.executionCount,execution:O.execution??j.execution,fromSnapshot:O.result!=null}:j})}t({type:"OPEN_FILE",file:y,cells:E,title:x,metadata:w}),e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(S){if(console.error("Failed to open file:",S),y.type==="block")try{const{content:x}=await N.readNotebook(y.path);t({type:"OPEN_BLOCK_STUDIO",file:y,payload:{path:y.path,source:x,companionPath:null,metadata:{name:y.name.replace(/\.dql$/i,""),path:y.path,domain:y.path.split("/").slice(1,-1).join("/")||"uncategorized",description:"",owner:"",tags:[]},validation:{valid:!1,diagnostics:[{severity:"warning",message:"Opened block without studio metadata. Save once to normalize it."}],semanticRefs:{metrics:[],dimensions:[],segments:[]}}}});return}catch(x){console.error("Failed to open block fallback:",x)}else t({type:"OPEN_FILE",file:y,cells:[Ms("sql")],title:y.name})}},[t,e.sidebarPanel]);u.useCallback(y=>{const S=r.current[y];S&&S.scrollIntoView({behavior:"smooth",block:"start"})},[]);const h=u.useCallback((y,S)=>{S?r.current[y]=S:delete r.current[y]},[]);return s.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[s.jsx(X0,{}),s.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.appMode==="studio"&&s.jsx(Eb,{}),e.appMode==="studio"&&e.sidebarOpen&&!o&&s.jsx(f0,{onOpenFile:p}),s.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:s.jsx(u.Suspense,{fallback:s.jsx(Ow,{t:n}),children:e.mainView==="home"?s.jsx(cw,{}):e.mainView==="ask"?s.jsx(dw,{}):e.mainView==="business_artifact"?s.jsx(yw,{}):e.mainView==="lineage"?s.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:s.jsx(bw,{})}):e.mainView==="lineage_detail"?s.jsx(xw,{}):e.mainView==="help"?s.jsx(vw,{}):e.mainView==="connection"||e.mainView==="settings"?s.jsx($w,{children:s.jsx(Sw,{variant:"page"})}):e.mainView==="git"?s.jsx(ww,{}):e.mainView==="readiness"?s.jsx(kw,{}):e.mainView==="skills"?s.jsx(Cw,{initialTab:"skills"}):e.mainView==="domains"||e.mainView==="modeling"?s.jsx(Ew,{}):e.mainView==="apps"?s.jsx(Tw,{}):e.mainView==="agent_log"?s.jsx(Dw,{title:"Agent steps",description:"What the agent did to answer this question, and where the time went — route, tools, checks, and per-step timing.",children:s.jsx(jw,{})}):s.jsx(s.Fragment,{children:e.mainView==="imports"||e.mainView==="block_studio"?s.jsx(gw,{},"block-editor"):s.jsxs(s.Fragment,{children:[s.jsx(pw,{onOpenFile:p,registerCellRef:h}),e.appMode==="studio"&&s.jsx(rw,{})]})})})}),e.appMode==="studio"&&e.lineageDrawerOpen&&!e.lineageFullscreen&&!e.dashboardMode&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(Aw,{})}),e.appMode==="studio"&&e.inspectorOpen&&!e.lineageFullscreen&&!e.lineageDrawerOpen&&!e.dashboardMode&&s.jsx(hb,{}),e.globalAi.open&&e.mainView==="apps"&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(uw,{})})]}),e.newNotebookModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(fw,{onFileOpened:p})}),e.newBlockModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(hw,{onFileOpened:p})}),s.jsx($x,{open:i,onClose:()=>l(!1)}),s.jsx(u.Suspense,{fallback:null,children:s.jsx(Rw,{})}),e.setupOpen&&s.jsx(u.Suspense,{fallback:s.jsx(Ma,{t:n}),children:s.jsx(mw,{launch:a!=null&&a.shouldOpen?a:void 0,onAcknowledged:()=>d(y=>y&&{...y,shouldOpen:!1,reason:null})})}),!c&&s.jsx(Ma,{t:n})]})}function Ow({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{flex:1,minWidth:0,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Loading workspace…"]})})}function Ma({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{position:"fixed",inset:0,zIndex:1100,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Checking workspace setup…"]})})}function $w({children:e}){return s.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto"},children:s.jsx("div",{style:{maxWidth:1120,margin:"0 auto",padding:"18px 28px 32px"},children:e})})}function Dw({title:e,description:t,children:n}){return s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden"},children:[s.jsxs("div",{style:{padding:"18px 24px 12px",borderBottom:"1px solid rgba(127, 127, 127, 0.16)"},children:[s.jsx("div",{style:{fontSize:22,fontWeight:700},children:e}),s.jsx("div",{style:{fontSize:13,opacity:.72,marginTop:6,maxWidth:760,lineHeight:1.5},children:t})]}),s.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:n})]})}function Pw(){const{state:e,dispatch:t}=Se(),n=u.useRef(null),r=u.useRef(null);u.useEffect(()=>{var o;n.current=((o=e.activeFile)==null?void 0:o.path)??null},[e.activeFile]),u.useEffect(()=>{if(typeof EventSource>"u")return;const o=()=>{const i=new EventSource(`${window.location.origin}/api/watch`);r.current=i,i.addEventListener("change",l=>{try{const a=JSON.parse(l.data);(a.type==="file-added"||a.type==="file-deleted")&&(N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),N.getDomains().then(({domains:d})=>{t({type:"SET_AUTHORED_DOMAINS",domains:d})})),a.type==="file-changed"&&(N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),N.getDomains().then(({domains:d})=>{t({type:"SET_AUTHORED_DOMAINS",domains:d})})),a.type==="semantic-reload"&&(t({type:"SET_SEMANTIC_LOADING",loading:!0}),N.getSemanticLayer().then(d=>{t({type:"SET_SEMANTIC_LAYER",layer:d})}))}catch{}}),i.addEventListener("error",()=>{i.close(),setTimeout(o,5e3)})};return o(),()=>{var i;(i=r.current)==null||i.close(),r.current=null}},[t])}function Iw(){const{state:e,dispatch:t}=Se(),n=qe[e.themeMode];u.useEffect(()=>{const o="dql-global-styles";let i=document.getElementById(o);i||(i=document.createElement("style"),i.id=o,document.head.appendChild(i)),i.textContent=`
|
|
610
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
611
|
-
body {
|
|
612
|
-
font-family: var(--font-ui, ${n.font});
|
|
613
|
-
overflow: hidden;
|
|
614
|
-
background: var(--color-bg-primary);
|
|
615
|
-
color: var(--color-text-primary);
|
|
616
|
-
}
|
|
617
|
-
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
618
|
-
::-webkit-scrollbar-track { background: transparent; }
|
|
619
|
-
::-webkit-scrollbar-thumb {
|
|
620
|
-
background: var(--color-border-secondary);
|
|
621
|
-
border-radius: 3px;
|
|
622
|
-
}
|
|
623
|
-
::-webkit-scrollbar-thumb:hover {
|
|
624
|
-
background: var(--color-text-tertiary);
|
|
625
|
-
}
|
|
626
|
-
::selection {
|
|
627
|
-
background: color-mix(in srgb, var(--color-accent-blue) 25%, transparent);
|
|
628
|
-
color: var(--color-text-primary);
|
|
629
|
-
}
|
|
630
|
-
.dql-meta-pill:hover {
|
|
631
|
-
background: var(--dql-pill-hover-bg) !important;
|
|
632
|
-
border-color: var(--dql-pill-hover-border) !important;
|
|
633
|
-
}
|
|
634
|
-
`},[n]),u.useEffect(()=>{const o=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode;document.documentElement.setAttribute("data-theme",o)},[e.themeMode]);const r=u.useRef(!1);return u.useEffect(()=>{t({type:"SET_FILES_LOADING",loading:!0}),N.listNotebooks().then(o=>{t({type:"SET_FILES",files:o}),t({type:"SET_FILES_LOADING",loading:!1}),r.current=!0}),N.getDomains().then(({domains:o})=>{t({type:"SET_AUTHORED_DOMAINS",domains:o})})},[t]),Pw(),s.jsx(Zd,{theme:e.themeMode,applyGlobal:!0,children:s.jsx(uf,{delayDuration:200,skipDelayDuration:400,children:s.jsx(_w,{})})})}function Mw(){return s.jsx(Ag,{children:s.jsx(Iw,{})})}Qd.createRoot(document.getElementById("root")).render(s.jsx(Mw,{}));export{Ro as $,a1 as A,Ls as B,ly as C,or as D,$d as E,Bs as F,Cn as G,nt as H,v1 as I,tS as J,sr as K,Jt as L,nn as M,Yy as N,wb as O,cx as P,Jw as Q,Ie as R,Vc as S,Hc as T,Qw as U,n1 as V,Yw as W,Wc as X,Fr as Y,CS as Z,yd as _,N as a,Zo as a0,r1 as a1,p1 as a2,qv as a3,g1 as a4,y1 as a5,O0 as a6,$0 as a7,f1 as a8,i1 as a9,Py as aA,dy as aB,ld as aC,gy as aD,qc as aE,v0 as aF,sy as aG,Ce as aH,Wy as aI,o1 as aJ,xy as aK,yx as aL,wy as aM,es as aN,d1 as aO,Nc as aP,kd as aa,h1 as ab,P0 as ac,D0 as ad,u1 as ae,Ta as af,m1 as ag,Kr as ah,xv as ai,qi as aj,e1 as ak,t1 as al,Zw as am,Xw as an,Qc as ao,Vw as ap,Hw as aq,Gw as ar,pb as as,fb as at,Kw as au,Hi as av,Hy as aw,Lg as ax,zg as ay,By as az,ke as b,X as c,Ns as d,ao as e,zc as f,Yg as g,bx as h,R0 as i,s as j,s1 as k,cb as l,Ms as m,db as n,b1 as o,jd as p,c1 as q,u as r,x1 as s,qe as t,Se as u,Cd as v,T0 as w,wd as x,j0 as y,l1 as z};
|