@duckcodeailabs/dql-cli 1.13.2 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +25 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +1037 -175
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/{AgentLogPage-BlUE3qsX.js → AgentLogPage-B3ugEb3H.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-O88iK6UW.js → AiBuildDialog-BK_TDNcM.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D-6G4Sh3.js → AiBuildResult-Cob_Lj05.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiSidePanel-MRSGtQDV.js → AiSidePanel-CzIgxmP9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AnalyticsHome-CcRVO6zN.js → AnalyticsHome-C2vJ2fxY.js} +1 -1
- package/dist/assets/dql-notebook/assets/AppsView-DEWQ0sHT.js +5588 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-CaDNTKMM.js +55 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-itEIUrYy.js → BusinessArtifactView-zwUOtddi.js} +1 -1
- package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-CbAqOpNc.js → DbtFirstModelingPage-BlnhTMu3.js} +4 -4
- package/dist/assets/dql-notebook/assets/{GitPage-BxOqRYu2.js → GitPage-Coevr9NJ.js} +3 -3
- package/dist/assets/dql-notebook/assets/{GlobalAiRail-Tfkx76CI.js → GlobalAiRail-BTZS11x5.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GovernedContextPage-CeaDbepP.js → GovernedContextPage-CjyyM_ne.js} +3 -3
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-D1lAryYv.js → HelpDocsPage-C1UeP85v.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-GB6se6xW.js → HomePage-zGPFIvOY.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDAG-zCyN-hdg.js → LineageDAG-DbXnQWu3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDetailView-Cg0TgG2Y.js → LineageDetailView-Ch1Db01I.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-DwMcenDf.js → LineageDrawer-DLxqJO6D.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-DUZx3ksU.js → LineagePathBreadcrumb-B2tNdkr_.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-DT_ycl6s.js → MiniLineageGraph-0gY-ZwCy.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-qdhzeJPF.js → NewBlockModal-DKVkXD20.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-BnaDzs1A.js → NewNotebookModal-BUIByvYT.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NotebookEditor-CouPFzdo.js → NotebookEditor-D2fIUxjE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{ReadinessPage-DB_KbH9Y.js → ReadinessPage-Ci4LyNiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-CamQq_N2.js → SetupOnboarding-BF7ai_0t.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SkillsPage--mYkOAK2.js → SkillsPage-BgYrgirJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{TrustBadge-ClEYiYeA.js → TrustBadge-Bob1Laiq.js} +1 -1
- package/dist/assets/dql-notebook/assets/{UnifiedAgentRunPanel-DBfsmXes.js → UnifiedAgentRunPanel-IxDUKSG8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-Cg3UyGwh.js → answer-to-notebook-Dk42N0pU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-DnYPGqlr.js → arrow-left-DKuuTw9l.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-Ct_YGrmU.js → arrow-right-TH8_ufKG.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-DULlwbj6.js → book-open-text-B-dcHHn0.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-ByYxoiS9.js → circle-x-BOc2KCZQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-BjYSO53F.js → dagre.esm-CPT_vn5p.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-DprWh9Yf.js → external-link-DtOfpYc6.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-CrEEYkXN.js → grip-vertical-B8joDDH9.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-DJRMz64S.js +635 -0
- package/dist/assets/dql-notebook/assets/{link-2-BkW-rkEC.js → link-2-DMZPHawg.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-BipBLmIE.js → list-tree-Dw0qlxPK.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-BhXsglrO.js → minimize-2-DUiSrPS3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-BoCSilYB.js → panel-right-open-BrrFrRZQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{play-mdoZawPu.js → play-Ced0HT9g.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-ELiDRUmj.js → rotate-ccw-D_9U9o7X.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-DVNRLfeU.js → semantic-fields-BlDOaonV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{sliders-horizontal-GeUzpmKz.js → sliders-horizontal-BDt6KRGR.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-D63O81Wp.js → star-CxUbF_BW.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BWrCxQVE.js → triangle-alert-COWnsSdh.js} +1 -1
- package/dist/assets/dql-notebook/assets/{upload-CI-ldXhC.js → upload-DSFC2kJX.js} +1 -1
- package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-Cv7Yq2hK.js → usePersistedAgentThreadId-DYdx896E.js} +1 -1
- package/dist/assets/dql-notebook/assets/{user-round-Do21aFGo.js → user-round-Bfu7fosn.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-DT7u7F_x.js → wand-sparkles-DSpG0c0j.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-DHh2mMbn.js → workflow-B1_pj9gq.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-7tYr_GKb.js → wrench-CvfM03KZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CcYceFMz.js → x-B4coLiOl.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/local-runtime.d.ts +47 -19
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1015 -566
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AppsView-BTkGC-wl.js +0 -5588
- package/dist/assets/dql-notebook/assets/BlockStudio-BrTNaDpb.js +0 -55
- package/dist/assets/dql-notebook/assets/index-9w93YPF9.js +0 -635
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-zGPFIvOY.js","assets/TrustBadge-Bob1Laiq.js","assets/arrow-right-TH8_ufKG.js","assets/triangle-alert-COWnsSdh.js","assets/book-open-text-B-dcHHn0.js","assets/workflow-B1_pj9gq.js","assets/react-CRB3T2We.js","assets/AnalyticsHome-C2vJ2fxY.js","assets/answer-to-notebook-Dk42N0pU.js","assets/UnifiedAgentRunPanel-IxDUKSG8.js","assets/usePersistedAgentThreadId-DYdx896E.js","assets/AiBuildResult-Cob_Lj05.js","assets/user-round-Bfu7fosn.js","assets/rotate-ccw-D_9U9o7X.js","assets/wrench-CvfM03KZ.js","assets/x-B4coLiOl.js","assets/list-tree-Dw0qlxPK.js","assets/minimize-2-DUiSrPS3.js","assets/star-CxUbF_BW.js","assets/GlobalAiRail-BTZS11x5.js","assets/AiSidePanel-CzIgxmP9.js","assets/NotebookEditor-D2fIUxjE.js","assets/LineagePathBreadcrumb-B2tNdkr_.js","assets/codemirror-DXt7RW72.js","assets/semantic-fields-BlDOaonV.js","assets/MiniLineageGraph-0gY-ZwCy.js","assets/dagre.esm-CPT_vn5p.js","assets/dagre-BZV40eAE.css","assets/link-2-DMZPHawg.js","assets/upload-DSFC2kJX.js","assets/NewNotebookModal-BUIByvYT.js","assets/NewBlockModal-DKVkXD20.js","assets/SetupOnboarding-BF7ai_0t.js","assets/arrow-left-DKuuTw9l.js","assets/BlockStudio-CaDNTKMM.js","assets/play-Ced0HT9g.js","assets/panel-right-open-BrrFrRZQ.js","assets/BusinessArtifactView-zwUOtddi.js","assets/LineageDetailView-Ch1Db01I.js","assets/LineageDAG-DbXnQWu3.js","assets/HelpDocsPage-C1UeP85v.js","assets/GitPage-Coevr9NJ.js","assets/external-link-DtOfpYc6.js","assets/ReadinessPage-Ci4LyNiQ.js","assets/ai-build-bus-1BR770pY.js","assets/wand-sparkles-DSpG0c0j.js","assets/AgentLogPage-B3ugEb3H.js","assets/circle-x-BOc2KCZQ.js","assets/GovernedContextPage-CjyyM_ne.js","assets/SkillsPage-BgYrgirJ.js","assets/DbtFirstModelingPage-BlnhTMu3.js","assets/sliders-horizontal-BDt6KRGR.js","assets/AppsView-DEWQ0sHT.js","assets/grip-vertical-B8joDDH9.js","assets/LineageDrawer-DLxqJO6D.js","assets/AiBuildDialog-BK_TDNcM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Sf=Object.defineProperty;var Ja=e=>{throw TypeError(e)};var wf=(e,t,n)=>t in e?Sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>wf(e,typeof t!="symbol"?t+"":t,n),Ps=(e,t,n)=>t.has(e)||Ja("Cannot "+n);var R=(e,t,n)=>(Ps(e,t,"read from private field"),n?n.call(e):t.get(e)),le=(e,t,n)=>t.has(e)?Ja("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Z=(e,t,n,r)=>(Ps(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),fe=(e,t,n)=>(Ps(e,t,"access private method"),n);var Ro=(e,t,n,r)=>({set _(o){Z(e,t,o,n)},get _(){return R(e,t,r)}});import{r as Ql,a as Jl,g as Yl}from"./react-CRB3T2We.js";function kf(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 c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).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 Is={exports:{}},Mr={};/**
|
|
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 Ya;function Cf(){if(Ya)return Mr;Ya=1;var e=Ql(),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 c(a,l,u){var h,d={},f=null,m=null;u!==void 0&&(f=""+u),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(m=l.ref);for(h in l)r.call(l,h)&&!i.hasOwnProperty(h)&&(d[h]=l[h]);if(a&&a.defaultProps)for(h in l=a.defaultProps,l)d[h]===void 0&&(d[h]=l[h]);return{$$typeof:t,type:a,key:f,ref:m,props:d,_owner:o.current}}return Mr.Fragment=n,Mr.jsx=c,Mr.jsxs=c,Mr}var Xa;function jf(){return Xa||(Xa=1,Is.exports=Cf()),Is.exports}var s=jf(),Oo={},Za;function Ef(){if(Za)return Oo;Za=1;var e=Jl();return Oo.createRoot=e.createRoot,Oo.hydrateRoot=e.hydrateRoot,Oo}var Tf=Ef(),p=Ql();const qe=Yl(p),Xl=kf({__proto__:null,default:qe},[p]);var ho=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},In,an,pr,Bl,Af=(Bl=class extends ho{constructor(){super();le(this,In);le(this,an);le(this,pr);Z(this,pr,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){R(this,an)||this.setEventListener(R(this,pr))}onUnsubscribe(){var t;this.hasListeners()||((t=R(this,an))==null||t.call(this),Z(this,an,void 0))}setEventListener(t){var n;Z(this,pr,t),(n=R(this,an))==null||n.call(this),Z(this,an,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){R(this,In)!==t&&(Z(this,In,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof R(this,In)=="boolean"?R(this,In):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},In=new WeakMap,an=new WeakMap,pr=new WeakMap,Bl),Ui=new Af,Rf={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},cn,qi,Fl,Of=(Fl=class{constructor(){le(this,cn,Rf);le(this,qi,!1)}setTimeoutProvider(e){Z(this,cn,e)}setTimeout(e,t){return R(this,cn).setTimeout(e,t)}clearTimeout(e){R(this,cn).clearTimeout(e)}setInterval(e,t){return R(this,cn).setInterval(e,t)}clearInterval(e){R(this,cn).clearInterval(e)}},cn=new WeakMap,qi=new WeakMap,Fl),_n=new Of;function _f(e){setTimeout(e,0)}var Pf=typeof window>"u"||"Deno"in globalThis;function at(){}function If(e,t){return typeof e=="function"?e(t):e}function ui(e){return typeof e=="number"&&e>=0&&e!==1/0}function Zl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function mn(e,t){return typeof e=="function"?e(t):e}function ft(e,t){return typeof e=="function"?e(t):e}function ec(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:c,stale:a}=e;if(c){if(r){if(t.queryHash!==Wi(c,t.options))return!1}else if(!jr(t.queryKey,c))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function tc(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Xr(t.options.mutationKey)!==Xr(i))return!1}else if(!jr(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function Wi(e,t){return((t==null?void 0:t.queryKeyHashFn)||Xr)(e)}function Xr(e){return JSON.stringify(e,(t,n)=>fi(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function jr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){for(let r=0;r<t.length;r++)if(!jr(e[r],t[r]))return!1;return!0}const n=Object.keys(t);for(const r of n)if(!jr(e[r],t[r]))return!1;return!0}return!1}var Df=Object.prototype.hasOwnProperty;function ed(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=nc(e)&&nc(t);if(!r&&!(fi(e)&&fi(t)))return t;const i=(r?e:Object.keys(e)).length,c=r?t:Object.keys(t),a=c.length,l=r?new Array(a):{};let u=0;for(let h=0;h<a;h++){const d=r?h:c[h],f=e[d],m=t[d];if(f===m){l[d]=f,(r?h<i:Df.call(e,d))&&u++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const S=ed(f,m,n+1);l[d]=S,S===f&&u++}return i===a&&u===i?e:l}function pi(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function nc(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function fi(e){if(!rc(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!rc(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function rc(e){return Object.prototype.toString.call(e)==="[object Object]"}function $f(e){return new Promise(t=>{_n.setTimeout(t,e)})}function hi(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?ed(e,t):t}function Mf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ki=Symbol();function td(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Ki?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function nd(e,t){return typeof e=="function"?e(...t):!!e}function Nf(e,t,n){let r=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??(o=t()),r||(r=!0,o.aborted?n():o.addEventListener("abort",n,{once:!0})),o)}),e}var Zr=(()=>{let e=()=>Pf;return{isServer(){return e()},setIsServer(t){e=t}}})();function mi(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}var Bf=_f;function Ff(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Bf;const i=a=>{t?e.push(a):o(()=>{n(a)})},c=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||c()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Ue=Ff(),fr,ln,hr,zl,zf=(zl=class extends ho{constructor(){super();le(this,fr,!0);le(this,ln);le(this,hr);Z(this,hr,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){R(this,ln)||this.setEventListener(R(this,hr))}onUnsubscribe(){var t;this.hasListeners()||((t=R(this,ln))==null||t.call(this),Z(this,ln,void 0))}setEventListener(t){var n;Z(this,hr,t),(n=R(this,ln))==null||n.call(this),Z(this,ln,t(this.setOnline.bind(this)))}setOnline(t){R(this,fr)!==t&&(Z(this,fr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return R(this,fr)}},fr=new WeakMap,ln=new WeakMap,hr=new WeakMap,zl),es=new zf;function qf(e){return Math.min(1e3*2**e,3e4)}function rd(e){return(e??"online")==="online"?es.isOnline():!0}var gi=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function od(e){let t=!1,n=0,r;const o=mi(),i=()=>o.status!=="pending",c=v=>{var b;if(!i()){const w=new gi(v);f(w),(b=e.onCancel)==null||b.call(e,w)}},a=()=>{t=!0},l=()=>{t=!1},u=()=>Ui.isFocused()&&(e.networkMode==="always"||es.isOnline())&&e.canRun(),h=()=>rd(e.networkMode)&&e.canRun(),d=v=>{i()||(r==null||r(),o.resolve(v))},f=v=>{i()||(r==null||r(),o.reject(v))},m=()=>new Promise(v=>{var b;r=w=>{(i()||u())&&v(w)},(b=e.onPause)==null||b.call(e)}).then(()=>{var v;r=void 0,i()||(v=e.onContinue)==null||v.call(e)}),S=()=>{if(i())return;let v;const b=n===0?e.initialPromise:void 0;try{v=b??e.fn()}catch(w){v=Promise.reject(w)}Promise.resolve(v).then(d).catch(w=>{var P;if(i())return;const j=e.retry??(Zr.isServer()?0:3),C=e.retryDelay??qf,x=typeof C=="function"?C(n,w):C,E=j===!0||typeof j=="number"&&n<j||typeof j=="function"&&j(n,w);if(t||!E){f(w);return}n++,(P=e.onFail)==null||P.call(e,n,w),$f(x).then(()=>u()?void 0:m()).then(()=>{t?f(w):S()})})};return{promise:o,status:()=>o.status,cancel:c,continue:()=>(r==null||r(),o),cancelRetry:a,continueRetry:l,canStart:h,start:()=>(h()?S():m().then(S),o)}}var Dn,ql,sd=(ql=class{constructor(){le(this,Dn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ui(this.gcTime)&&Z(this,Dn,_n.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zr.isServer()?1/0:300*1e3))}clearGcTimeout(){R(this,Dn)!==void 0&&(_n.clearTimeout(R(this,Dn)),Z(this,Dn,void 0))}},Dn=new WeakMap,ql);function Uf(e){return{onFetch:(t,n)=>{var h,d,f,m,S;const r=t.options,o=(f=(d=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],c=((S=t.state.data)==null?void 0:S.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const u=async()=>{let v=!1;const b=C=>{Nf(C,()=>t.signal,()=>v=!0)},w=td(t.options,t.fetchOptions),j=async(C,x,E)=>{if(v)return Promise.reject(t.signal.reason);if(x==null&&C.pages.length)return Promise.resolve(C);const A=(()=>{const O={client:t.client,queryKey:t.queryKey,pageParam:x,direction:E?"backward":"forward",meta:t.options.meta};return b(O),O})(),g=await w(A),{maxPages:I}=t.options,T=E?Lf:Mf;return{pages:T(C.pages,g,I),pageParams:T(C.pageParams,x,I)}};if(o&&i.length){const C=o==="backward",x=C?Wf:oc,E={pages:i,pageParams:c},P=x(r,E);a=await j(E,P,C)}else{const C=e??i.length;do{const x=l===0?c[0]??r.initialPageParam:oc(r,a);if(l>0&&x==null)break;a=await j(a,x),l++}while(l<C)}return a};t.options.persister?t.fetchFn=()=>{var v,b;return(b=(v=t.options).persister)==null?void 0:b.call(v,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function oc(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Wf(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var mr,$n,gr,yt,Mn,Le,co,Ln,pt,id,Vt,Ul,Kf=(Ul=class extends sd{constructor(t){super();le(this,pt);le(this,mr);le(this,$n);le(this,gr);le(this,yt);le(this,Mn);le(this,Le);le(this,co);le(this,Ln);Z(this,Ln,!1),Z(this,co,t.defaultOptions),this.setOptions(t.options),this.observers=[],Z(this,Mn,t.client),Z(this,yt,R(this,Mn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Z(this,$n,ic(this.options)),this.state=t.state??R(this,$n),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return R(this,mr)}get promise(){var t;return(t=R(this,Le))==null?void 0:t.promise}setOptions(t){if(this.options={...R(this,co),...t},t!=null&&t._type&&Z(this,mr,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ic(this.options);n.data!==void 0&&(this.setState(sc(n.data,n.dataUpdatedAt)),Z(this,$n,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&R(this,yt).remove(this)}setData(t,n){const r=hi(this.state.data,t,this.options);return fe(this,pt,Vt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){fe(this,pt,Vt).call(this,{type:"setState",state:t})}cancel(t){var r,o;const n=(r=R(this,Le))==null?void 0:r.promise;return(o=R(this,Le))==null||o.cancel(t),n?n.then(at).catch(at):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return R(this,$n)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ft(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ki||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>mn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Zl(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=R(this,Le))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=R(this,Le))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),R(this,yt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(R(this,Le)&&(R(this,Ln)||fe(this,pt,id).call(this)?R(this,Le).cancel({revert:!0}):R(this,Le).cancelRetry()),this.scheduleGc()),R(this,yt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||fe(this,pt,Vt).call(this,{type:"invalidate"})}async fetch(t,n){var u,h,d,f,m,S,v,b,w,j,C;if(this.state.fetchStatus!=="idle"&&((u=R(this,Le))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(R(this,Le))return R(this,Le).continueRetry(),R(this,Le).promise}if(t&&this.setOptions(t),!this.options.queryFn){const x=this.observers.find(E=>E.options.queryFn);x&&this.setOptions(x.options)}const r=new AbortController,o=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(Z(this,Ln,!0),r.signal)})},i=()=>{const x=td(this.options,n),P=(()=>{const A={client:R(this,Mn),queryKey:this.queryKey,meta:this.meta};return o(A),A})();return Z(this,Ln,!1),this.options.persister?this.options.persister(x,P,this):x(P)},a=(()=>{const x={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:R(this,Mn),state:this.state,fetchFn:i};return o(x),x})(),l=R(this,mr)==="infinite"?Uf(this.options.pages):this.options.behavior;l==null||l.onFetch(a,this),Z(this,gr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=a.fetchOptions)==null?void 0:h.meta))&&fe(this,pt,Vt).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),Z(this,Le,od({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:x=>{x instanceof gi&&x.revert&&this.setState({...R(this,gr),fetchStatus:"idle"}),r.abort()},onFail:(x,E)=>{fe(this,pt,Vt).call(this,{type:"failed",failureCount:x,error:E})},onPause:()=>{fe(this,pt,Vt).call(this,{type:"pause"})},onContinue:()=>{fe(this,pt,Vt).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const x=await R(this,Le).start();if(x===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(x),(m=(f=R(this,yt).config).onSuccess)==null||m.call(f,x,this),(v=(S=R(this,yt).config).onSettled)==null||v.call(S,x,this.state.error,this),x}catch(x){if(x instanceof gi){if(x.silent)return R(this,Le).promise;if(x.revert){if(this.state.data===void 0)throw x;return this.state.data}}throw fe(this,pt,Vt).call(this,{type:"error",error:x}),(w=(b=R(this,yt).config).onError)==null||w.call(b,x,this),(C=(j=R(this,yt).config).onSettled)==null||C.call(j,this.state.data,x,this),x}finally{this.scheduleGc()}}},mr=new WeakMap,$n=new WeakMap,gr=new WeakMap,yt=new WeakMap,Mn=new WeakMap,Le=new WeakMap,co=new WeakMap,Ln=new WeakMap,pt=new WeakSet,id=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Vt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ad(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...sc(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Z(this,gr,t.manual?o:void 0),o;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ue.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),R(this,yt).notify({query:this,type:"updated",action:t})})},Ul);function ad(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:rd(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function sc(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ic(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var it,he,lo,Xe,Nn,yr,Ht,dn,uo,br,xr,Bn,Fn,un,vr,Se,qr,yi,bi,xi,vi,Si,wi,ki,cd,Wl,Vf=(Wl=class extends ho{constructor(t,n){super();le(this,Se);le(this,it);le(this,he);le(this,lo);le(this,Xe);le(this,Nn);le(this,yr);le(this,Ht);le(this,dn);le(this,uo);le(this,br);le(this,xr);le(this,Bn);le(this,Fn);le(this,un);le(this,vr,new Set);this.options=n,Z(this,it,t),Z(this,dn,null),Z(this,Ht,mi()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(R(this,he).addObserver(this),ac(R(this,he),this.options)?fe(this,Se,qr).call(this):this.updateResult(),fe(this,Se,vi).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ci(R(this,he),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ci(R(this,he),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,fe(this,Se,Si).call(this),fe(this,Se,wi).call(this),R(this,he).removeObserver(this)}setOptions(t){const n=this.options,r=R(this,he);if(this.options=R(this,it).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ft(this.options.enabled,R(this,he))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");fe(this,Se,ki).call(this),R(this,he).setOptions(this.options),n._defaulted&&!pi(this.options,n)&&R(this,it).getQueryCache().notify({type:"observerOptionsUpdated",query:R(this,he),observer:this});const o=this.hasListeners();o&&cc(R(this,he),r,this.options,n)&&fe(this,Se,qr).call(this),this.updateResult(),o&&(R(this,he)!==r||ft(this.options.enabled,R(this,he))!==ft(n.enabled,R(this,he))||mn(this.options.staleTime,R(this,he))!==mn(n.staleTime,R(this,he)))&&fe(this,Se,yi).call(this);const i=fe(this,Se,bi).call(this);o&&(R(this,he)!==r||ft(this.options.enabled,R(this,he))!==ft(n.enabled,R(this,he))||i!==R(this,un))&&fe(this,Se,xi).call(this,i)}getOptimisticResult(t){const n=R(this,it).getQueryCache().build(R(this,it),t),r=this.createResult(n,t);return Gf(this,r)&&(Z(this,Xe,r),Z(this,yr,this.options),Z(this,Nn,R(this,he).state)),r}getCurrentResult(){return R(this,Xe)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&R(this,Ht).status==="pending"&&R(this,Ht).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){R(this,vr).add(t)}getCurrentQuery(){return R(this,he)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=R(this,it).defaultQueryOptions(t),r=R(this,it).getQueryCache().build(R(this,it),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return fe(this,Se,qr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),R(this,Xe)))}createResult(t,n){var I;const r=R(this,he),o=this.options,i=R(this,Xe),c=R(this,Nn),a=R(this,yr),u=t!==r?t.state:R(this,lo),{state:h}=t;let d={...h},f=!1,m;if(n._optimisticResults){const T=this.hasListeners(),O=!T&&ac(t,n),_=T&&cc(t,r,n,o);(O||_)&&(d={...d,...ad(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:S,errorUpdatedAt:v,status:b}=d;m=d.data;let w=!1;if(n.placeholderData!==void 0&&m===void 0&&b==="pending"){let T;i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(T=i.data,w=!0):T=typeof n.placeholderData=="function"?n.placeholderData((I=R(this,xr))==null?void 0:I.state.data,R(this,xr)):n.placeholderData,T!==void 0&&(b="success",m=hi(i==null?void 0:i.data,T,n),f=!0)}if(n.select&&m!==void 0&&!w)if(i&&m===(c==null?void 0:c.data)&&n.select===R(this,uo))m=R(this,br);else try{Z(this,uo,n.select),m=n.select(m),m=hi(i==null?void 0:i.data,m,n),Z(this,br,m),Z(this,dn,null)}catch(T){Z(this,dn,T)}R(this,dn)&&(S=R(this,dn),m=R(this,br),v=Date.now(),b="error");const j=d.fetchStatus==="fetching",C=b==="pending",x=b==="error",E=C&&j,P=m!==void 0,g={status:b,fetchStatus:d.fetchStatus,isPending:C,isSuccess:b==="success",isError:x,isInitialLoading:E,isLoading:E,data:m,dataUpdatedAt:d.dataUpdatedAt,error:S,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:j,isRefetching:j&&!C,isLoadingError:x&&!P,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:x&&P,isStale:Vi(t,n),refetch:this.refetch,promise:R(this,Ht),isEnabled:ft(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const T=g.data!==void 0,O=g.status==="error"&&!T,_=G=>{O?G.reject(g.error):T&&G.resolve(g.data)},M=()=>{const G=Z(this,Ht,g.promise=mi());_(G)},q=R(this,Ht);switch(q.status){case"pending":t.queryHash===r.queryHash&&_(q);break;case"fulfilled":(O||g.data!==q.value)&&M();break;case"rejected":(!O||g.error!==q.reason)&&M();break}}return g}updateResult(){const t=R(this,Xe),n=this.createResult(R(this,he),this.options);if(Z(this,Nn,R(this,he).state),Z(this,yr,this.options),R(this,Nn).data!==void 0&&Z(this,xr,R(this,he)),pi(n,t))return;Z(this,Xe,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,i=typeof o=="function"?o():o;if(i==="all"||!i&&!R(this,vr).size)return!0;const c=new Set(i??R(this,vr));return this.options.throwOnError&&c.add("error"),Object.keys(R(this,Xe)).some(a=>{const l=a;return R(this,Xe)[l]!==t[l]&&c.has(l)})};fe(this,Se,cd).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&fe(this,Se,vi).call(this)}},it=new WeakMap,he=new WeakMap,lo=new WeakMap,Xe=new WeakMap,Nn=new WeakMap,yr=new WeakMap,Ht=new WeakMap,dn=new WeakMap,uo=new WeakMap,br=new WeakMap,xr=new WeakMap,Bn=new WeakMap,Fn=new WeakMap,un=new WeakMap,vr=new WeakMap,Se=new WeakSet,qr=function(t){fe(this,Se,ki).call(this);let n=R(this,he).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(at)),n},yi=function(){fe(this,Se,Si).call(this);const t=mn(this.options.staleTime,R(this,he));if(Zr.isServer()||R(this,Xe).isStale||!ui(t))return;const r=Zl(R(this,Xe).dataUpdatedAt,t)+1;Z(this,Bn,_n.setTimeout(()=>{R(this,Xe).isStale||this.updateResult()},r))},bi=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(R(this,he)):this.options.refetchInterval)??!1},xi=function(t){fe(this,Se,wi).call(this),Z(this,un,t),!(Zr.isServer()||ft(this.options.enabled,R(this,he))===!1||!ui(R(this,un))||R(this,un)===0)&&Z(this,Fn,_n.setInterval(()=>{(this.options.refetchIntervalInBackground||Ui.isFocused())&&fe(this,Se,qr).call(this)},R(this,un)))},vi=function(){fe(this,Se,yi).call(this),fe(this,Se,xi).call(this,fe(this,Se,bi).call(this))},Si=function(){R(this,Bn)!==void 0&&(_n.clearTimeout(R(this,Bn)),Z(this,Bn,void 0))},wi=function(){R(this,Fn)!==void 0&&(_n.clearInterval(R(this,Fn)),Z(this,Fn,void 0))},ki=function(){const t=R(this,it).getQueryCache().build(R(this,it),this.options);if(t===R(this,he))return;const n=R(this,he);Z(this,he,t),Z(this,lo,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},cd=function(t){Ue.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(R(this,Xe))}),R(this,it).getQueryCache().notify({query:R(this,he),type:"observerResultsUpdated"})})},Wl);function Hf(e,t){return ft(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&ft(t.retryOnMount,e)===!1)}function ac(e,t){return Hf(e,t)||e.state.data!==void 0&&Ci(e,t,t.refetchOnMount)}function Ci(e,t,n){if(ft(t.enabled,e)!==!1&&mn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Vi(e,t)}return!1}function cc(e,t,n,r){return(e!==t||ft(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Vi(e,n)}function Vi(e,t){return ft(t.enabled,e)!==!1&&e.isStaleByTime(mn(t.staleTime,e))}function Gf(e,t){return!pi(e.getCurrentResult(),t)}var po,$t,He,zn,Mt,rn,Kl,Qf=(Kl=class extends sd{constructor(t){super();le(this,Mt);le(this,po);le(this,$t);le(this,He);le(this,zn);Z(this,po,t.client),this.mutationId=t.mutationId,Z(this,He,t.mutationCache),Z(this,$t,[]),this.state=t.state||Jf(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){R(this,$t).includes(t)||(R(this,$t).push(t),this.clearGcTimeout(),R(this,He).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Z(this,$t,R(this,$t).filter(n=>n!==t)),this.scheduleGc(),R(this,He).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){R(this,$t).length||(this.state.status==="pending"?this.scheduleGc():R(this,He).remove(this))}continue(){var t;return((t=R(this,zn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var c,a,l,u,h,d,f,m,S,v,b,w,j,C,x,E,P,A;const n=()=>{fe(this,Mt,rn).call(this,{type:"continue"})},r={client:R(this,po),meta:this.options.meta,mutationKey:this.options.mutationKey};Z(this,zn,od({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(g,I)=>{fe(this,Mt,rn).call(this,{type:"failed",failureCount:g,error:I})},onPause:()=>{fe(this,Mt,rn).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>R(this,He).canRun(this)}));const o=this.state.status==="pending",i=!R(this,zn).canStart();try{if(o)n();else{fe(this,Mt,rn).call(this,{type:"pending",variables:t,isPaused:i}),R(this,He).config.onMutate&&await R(this,He).config.onMutate(t,this,r);const I=await((a=(c=this.options).onMutate)==null?void 0:a.call(c,t,r));I!==this.state.context&&fe(this,Mt,rn).call(this,{type:"pending",context:I,variables:t,isPaused:i})}const g=await R(this,zn).start();return await((u=(l=R(this,He).config).onSuccess)==null?void 0:u.call(l,g,t,this.state.context,this,r)),await((d=(h=this.options).onSuccess)==null?void 0:d.call(h,g,t,this.state.context,r)),await((m=(f=R(this,He).config).onSettled)==null?void 0:m.call(f,g,null,this.state.variables,this.state.context,this,r)),await((v=(S=this.options).onSettled)==null?void 0:v.call(S,g,null,t,this.state.context,r)),fe(this,Mt,rn).call(this,{type:"success",data:g}),g}catch(g){try{await((w=(b=R(this,He).config).onError)==null?void 0:w.call(b,g,t,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((C=(j=this.options).onError)==null?void 0:C.call(j,g,t,this.state.context,r))}catch(I){Promise.reject(I)}try{await((E=(x=R(this,He).config).onSettled)==null?void 0:E.call(x,void 0,g,this.state.variables,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((A=(P=this.options).onSettled)==null?void 0:A.call(P,void 0,g,t,this.state.context,r))}catch(I){Promise.reject(I)}throw fe(this,Mt,rn).call(this,{type:"error",error:g}),g}finally{R(this,He).runNext(this)}}},po=new WeakMap,$t=new WeakMap,He=new WeakMap,zn=new WeakMap,Mt=new WeakSet,rn=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ue.batch(()=>{R(this,$t).forEach(r=>{r.onMutationUpdate(t)}),R(this,He).notify({mutation:this,type:"updated",action:t})})},Kl);function Jf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Gt,Rt,fo,Vl,Yf=(Vl=class extends ho{constructor(t={}){super();le(this,Gt);le(this,Rt);le(this,fo);this.config=t,Z(this,Gt,new Set),Z(this,Rt,new Map),Z(this,fo,0)}build(t,n,r){const o=new Qf({client:t,mutationCache:this,mutationId:++Ro(this,fo)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){R(this,Gt).add(t);const n=_o(t);if(typeof n=="string"){const r=R(this,Rt).get(n);r?r.push(t):R(this,Rt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(R(this,Gt).delete(t)){const n=_o(t);if(typeof n=="string"){const r=R(this,Rt).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&R(this,Rt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=_o(t);if(typeof n=="string"){const r=R(this,Rt).get(n),o=r==null?void 0:r.find(i=>i.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=_o(t);if(typeof n=="string"){const o=(r=R(this,Rt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ue.batch(()=>{R(this,Gt).forEach(t=>{this.notify({type:"removed",mutation:t})}),R(this,Gt).clear(),R(this,Rt).clear()})}getAll(){return Array.from(R(this,Gt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>tc(n,r))}findAll(t={}){return this.getAll().filter(n=>tc(t,n))}notify(t){Ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ue.batch(()=>Promise.all(t.map(n=>n.continue().catch(at))))}},Gt=new WeakMap,Rt=new WeakMap,fo=new WeakMap,Vl);function _o(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Lt,Hl,Xf=(Hl=class extends ho{constructor(t={}){super();le(this,Lt);this.config=t,Z(this,Lt,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??Wi(o,n);let c=this.get(i);return c||(c=new Kf({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(c)),c}add(t){R(this,Lt).has(t.queryHash)||(R(this,Lt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=R(this,Lt).get(t.queryHash);n&&(t.destroy(),n===t&&R(this,Lt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ue.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return R(this,Lt).get(t)}getAll(){return[...R(this,Lt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ec(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ec(t,r)):n}notify(t){Ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ue.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ue.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Lt=new WeakMap,Hl),Ae,pn,fn,Sr,wr,hn,kr,Cr,Gl,Zf=(Gl=class{constructor(e={}){le(this,Ae);le(this,pn);le(this,fn);le(this,Sr);le(this,wr);le(this,hn);le(this,kr);le(this,Cr);Z(this,Ae,e.queryCache||new Xf),Z(this,pn,e.mutationCache||new Yf),Z(this,fn,e.defaultOptions||{}),Z(this,Sr,new Map),Z(this,wr,new Map),Z(this,hn,0)}mount(){Ro(this,hn)._++,R(this,hn)===1&&(Z(this,kr,Ui.subscribe(async e=>{e&&(await this.resumePausedMutations(),R(this,Ae).onFocus())})),Z(this,Cr,es.subscribe(async e=>{e&&(await this.resumePausedMutations(),R(this,Ae).onOnline())})))}unmount(){var e,t;Ro(this,hn)._--,R(this,hn)===0&&((e=R(this,kr))==null||e.call(this),Z(this,kr,void 0),(t=R(this,Cr))==null||t.call(this),Z(this,Cr,void 0))}isFetching(e){return R(this,Ae).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return R(this,pn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=R(this,Ae).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=R(this,Ae).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(mn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return R(this,Ae).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=R(this,Ae).get(r.queryHash),i=o==null?void 0:o.state.data,c=If(t,i);if(c!==void 0)return R(this,Ae).build(this,r).setData(c,{...n,manual:!0})}setQueriesData(e,t,n){return Ue.batch(()=>R(this,Ae).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=R(this,Ae).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=R(this,Ae);Ue.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=R(this,Ae);return Ue.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ue.batch(()=>R(this,Ae).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(at).catch(at)}invalidateQueries(e,t={}){return Ue.batch(()=>(R(this,Ae).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ue.batch(()=>R(this,Ae).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(at)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(at)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=R(this,Ae).build(this,t);return n.isStaleByTime(mn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(at).catch(at)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(at).catch(at)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return es.isOnline()?R(this,pn).resumePausedMutations():Promise.resolve()}getQueryCache(){return R(this,Ae)}getMutationCache(){return R(this,pn)}getDefaultOptions(){return R(this,fn)}setDefaultOptions(e){Z(this,fn,e)}setQueryDefaults(e,t){R(this,Sr).set(Xr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...R(this,Sr).values()],n={};return t.forEach(r=>{jr(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){R(this,wr).set(Xr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...R(this,wr).values()],n={};return t.forEach(r=>{jr(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...R(this,fn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Wi(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ki&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...R(this,fn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){R(this,Ae).clear(),R(this,pn).clear()}},Ae=new WeakMap,pn=new WeakMap,fn=new WeakMap,Sr=new WeakMap,wr=new WeakMap,hn=new WeakMap,kr=new WeakMap,Cr=new WeakMap,Gl),ld=p.createContext(void 0),Hi=e=>{const t=p.useContext(ld);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},eh=({client:e,children:t})=>(p.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(ld.Provider,{value:e,children:t})),dd=p.createContext(!1),th=()=>p.useContext(dd);dd.Provider;function nh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var rh=p.createContext(nh()),oh=()=>p.useContext(rh),sh=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?nd(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ih=e=>{p.useEffect(()=>{e.clearReset()},[e])},ah=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||nd(n,[e.error,r])),ch=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},lh=(e,t)=>e.isLoading&&e.isFetching&&!t,dh=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,lc=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uh(e,t,n){var m,S,v,b;const r=th(),o=oh(),i=Hi(),c=i.defaultQueryOptions(e);(S=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||S.call(m,c);const a=i.getQueryCache().get(c.queryHash),l=e.subscribed!==!1;c._optimisticResults=r?"isRestoring":l?"optimistic":void 0,ch(c),sh(c,o,a),ih(o);const u=!i.getQueryCache().get(c.queryHash),[h]=p.useState(()=>new t(i,c)),d=h.getOptimisticResult(c),f=!r&&l;if(p.useSyncExternalStore(p.useCallback(w=>{const j=f?h.subscribe(Ue.batchCalls(w)):at;return h.updateResult(),j},[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),p.useEffect(()=>{h.setOptions(c)},[c,h]),dh(c,d))throw lc(c,h,o);if(ah({result:d,errorResetBoundary:o,throwOnError:c.throwOnError,query:a,suspense:c.suspense}))throw d.error;if((b=(v=i.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||b.call(v,c,d),c.experimental_prefetchInRender&&!Zr.isServer()&&lh(d,r)){const w=u?lc(c,h,o):a==null?void 0:a.promise;w==null||w.catch(at).finally(()=>{h.updateResult()})}return c.notifyOnChangeProps?d:h.trackResult(d)}function ji(e,t){return uh(e,Vf)}const ye={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"},be={1:"4px",2:"8px",3:"12px",4:"16px"},Sn={sm:"4px",md:"6px",lg:"8px"},Ze={xs:"11px",sm:"12px",md:"14px"},Gi={medium:"500",semibold:"600"},eo={overlay:1e3,modal:1100,popover:1200,tooltip:1300},Ds={surfaceBase:ye.gray1000,surfaceRaised:ye.gray975,surfaceElevated:ye.gray950,surfaceOverlay:"rgba(0,0,0,0.7)",surfaceHover:ye.gray900,surfaceActive:"#1f2d3d",surfaceSunken:ye.gray1000,borderSubtle:"#21262d",borderDefault:"#30363d",borderStrong:"#484f58",borderFocus:ye.blue500,textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",textDisabled:"#32383f",textInverse:ye.gray1000,accent:ye.blue500,accentHover:ye.blue400,accentMuted:"rgba(56,139,253,0.15)",accentContrast:"#ffffff",success:ye.green500,warning:ye.yellow500,danger:ye.red500,info:ye.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)"},Po={surfaceBase:ye.gray0,surfaceRaised:ye.gray50,surfaceElevated:ye.gray0,surfaceOverlay:"rgba(0,0,0,0.4)",surfaceHover:ye.gray100,surfaceActive:"#dbeafe",surfaceSunken:ye.gray50,borderSubtle:ye.gray100,borderDefault:ye.gray200,borderStrong:ye.gray300,borderFocus:ye.blue600,textPrimary:"#1f2328",textSecondary:ye.gray600,textMuted:ye.gray400,textDisabled:ye.gray300,textInverse:ye.gray0,accent:ye.blue600,accentHover:ye.blue700,accentMuted:"rgba(9,105,218,0.12)",accentContrast:"#ffffff",success:ye.green600,warning:ye.yellow600,danger:ye.red600,info:ye.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)"},ph={obsidian:Ds,paper:Po,white:Po,dark:Ds,light:Po,midnight:Ds,arctic:Po};function ud(e){return`--dql-${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function dc(e){const t={};for(const[n,r]of Object.entries(e))t[ud(n)]=r;return t}function pe(e){return`var(${ud(e)})`}const fh=p.createContext(null);function hh({theme:e,defaultTheme:t="dark",onThemeChange:n,applyGlobal:r=!1,children:o}){const[i,c]=p.useState(t),a=e??i,l=ph[a],u=p.useCallback(f=>{e===void 0&&c(f),n==null||n(f)},[e,n]);p.useEffect(()=>{if(!r)return;const f=dc(l),m=document.documentElement;for(const[S,v]of Object.entries(f))m.style.setProperty(S,v);return m.setAttribute("data-theme",a),()=>{for(const S of Object.keys(f))m.style.removeProperty(S);m.removeAttribute("data-theme")}},[r,a,l]);const h=p.useMemo(()=>({theme:a,tokens:l,setTheme:u}),[a,l,u]),d=r?void 0:dc(l);return s.jsx(fh.Provider,{value:h,children:s.jsx("div",{"data-theme":a,style:d,children:o})})}function de(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 uc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hs(...e){return t=>{let n=!1;const r=e.map(o=>{const i=uc(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():uc(e[o],null)}}}}function Oe(...e){return p.useCallback(hs(...e),e)}function mh(e,t){const n=p.createContext(t),r=i=>{const{children:c,...a}=i,l=p.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:l,children:c})};r.displayName=e+"Provider";function o(i){const c=p.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function wn(e,t=[]){let n=[];function r(i,c){const a=p.createContext(c),l=n.length;n=[...n,c];const u=d=>{var w;const{scope:f,children:m,...S}=d,v=((w=f==null?void 0:f[e])==null?void 0:w[l])||a,b=p.useMemo(()=>S,Object.values(S));return s.jsx(v.Provider,{value:b,children:m})};u.displayName=i+"Provider";function h(d,f){var v;const m=((v=f==null?void 0:f[e])==null?void 0:v[l])||a,S=p.useContext(m);if(S)return S;if(c!==void 0)return c;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,h]}const o=()=>{const i=n.map(c=>p.createContext(c));return function(a){const l=(a==null?void 0:a[e])||i;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,gh(o,...t)]}function gh(...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 c=r.reduce((a,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...a,...d}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var Qi=Jl();const yh=Yl(Qi);function Er(e){const t=bh(e),n=p.forwardRef((r,o)=>{const{children:i,...c}=r,a=p.Children.toArray(i),l=a.find(vh);if(l){const u=l.props.children,h=a.map(d=>d===l?p.Children.count(u)>1?p.Children.only(null):p.isValidElement(u)?u.props.children:null:d);return s.jsx(t,{...c,ref:o,children:p.isValidElement(u)?p.cloneElement(u,void 0,h):null})}return s.jsx(t,{...c,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function bh(e){const t=p.forwardRef((n,r)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const c=wh(o),a=Sh(i,o.props);return o.type!==p.Fragment&&(a.ref=r?hs(r,c):c),p.cloneElement(o,a)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pd=Symbol("radix.slottable");function xh(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=pd,t}function vh(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pd}function Sh(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 l=i(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function wh(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 kh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=kh.reduce((e,t)=>{const n=Er(`Primitive.${t}`),r=p.forwardRef((o,i)=>{const{asChild:c,...a}=o,l=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function fd(e,t){e&&Qi.flushSync(()=>e.dispatchEvent(t))}function gn(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ch(e,t=globalThis==null?void 0:globalThis.document){const n=gn(e);p.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 jh="DismissableLayer",Ei="dismissableLayer.update",Eh="dismissableLayer.pointerDownOutside",Th="dismissableLayer.focusOutside",pc,hd=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:c,onDismiss:a,...l}=e,u=p.useContext(hd),[h,d]=p.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),S=Oe(t,A=>d(A)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=v.indexOf(b),j=h?v.indexOf(h):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,x=j>=w,E=Oh(A=>{const g=A.target,I=[...u.branches].some(T=>T.contains(g));!x||I||(o==null||o(A),c==null||c(A),A.defaultPrevented||a==null||a())},f),P=_h(A=>{const g=A.target;[...u.branches].some(T=>T.contains(g))||(i==null||i(A),c==null||c(A),A.defaultPrevented||a==null||a())},f);return Ch(A=>{j===u.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&a&&(A.preventDefault(),a()))},f),p.useEffect(()=>{if(h)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(pc=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),fc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=pc)}},[h,f,n,u]),p.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),fc())},[h,u]),p.useEffect(()=>{const A=()=>m({});return document.addEventListener(Ei,A),()=>document.removeEventListener(Ei,A)},[]),s.jsx(Te.div,{...l,ref:S,style:{pointerEvents:C?x?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,P.onFocusCapture),onBlurCapture:de(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,E.onPointerDownCapture)})});mo.displayName=jh;var Ah="DismissableLayerBranch",Rh=p.forwardRef((e,t)=>{const n=p.useContext(hd),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Te.div,{...e,ref:o})});Rh.displayName=Ah;function Oh(e,t=globalThis==null?void 0:globalThis.document){const n=gn(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){md(Eh,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function _h(e,t=globalThis==null?void 0:globalThis.document){const n=gn(e),r=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!r.current&&md(Th,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 fc(){const e=new CustomEvent(Ei);document.dispatchEvent(e)}function md(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?fd(o,i):o.dispatchEvent(i)}var yn=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Ph=Xl[" useId ".trim().toString()]||(()=>{}),Ih=0;function Qr(e){const[t,n]=p.useState(Ph());return yn(()=>{n(r=>r??String(Ih++))},[e]),t?`radix-${t}`:""}const Dh=["top","right","bottom","left"],bn=Math.min,ht=Math.max,ts=Math.round,Io=Math.floor,qt=e=>({x:e,y:e}),$h={left:"right",right:"left",bottom:"top",top:"bottom"};function Ti(e,t,n){return ht(e,bn(t,n))}function Qt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function Or(e){return e.split("-")[1]}function Ji(e){return e==="x"?"y":"x"}function Yi(e){return e==="y"?"height":"width"}function zt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Xi(e){return Ji(zt(e))}function Mh(e,t,n){n===void 0&&(n=!1);const r=Or(e),o=Xi(e),i=Yi(o);let c=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(c=ns(c)),[c,ns(c)]}function Lh(e){const t=ns(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const hc=["left","right"],mc=["right","left"],Nh=["top","bottom"],Bh=["bottom","top"];function Fh(e,t,n){switch(e){case"top":case"bottom":return n?t?mc:hc:t?hc:mc;case"left":case"right":return t?Nh:Bh;default:return[]}}function zh(e,t,n,r){const o=Or(e);let i=Fh(Jt(e),n==="start",r);return o&&(i=i.map(c=>c+"-"+o),t&&(i=i.concat(i.map(Ai)))),i}function ns(e){const t=Jt(e);return $h[t]+e.slice(t.length)}function qh(e){return{top:0,right:0,bottom:0,left:0,...e}}function gd(e){return typeof e!="number"?qh(e):{top:e,right:e,bottom:e,left:e}}function rs(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 gc(e,t,n){let{reference:r,floating:o}=e;const i=zt(t),c=Xi(t),a=Yi(c),l=Jt(t),u=i==="y",h=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[a]/2-o[a]/2;let m;switch(l){case"top":m={x:h,y:r.y-o.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-o.width,y:d};break;default:m={x:r.x,y:r.y}}switch(Or(t)){case"start":m[c]-=f*(n&&u?-1:1);break;case"end":m[c]+=f*(n&&u?-1:1);break}return m}async function Uh(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:c,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:f=!1,padding:m=0}=Qt(t,e),S=gd(m),b=a[f?d==="floating"?"reference":"floating":d],w=rs(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:u,rootBoundary:h,strategy:l})),j=d==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),x=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},E=rs(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:j,offsetParent:C,strategy:l}):j);return{top:(w.top-E.top+S.top)/x.y,bottom:(E.bottom-w.bottom+S.bottom)/x.y,left:(w.left-E.left+S.left)/x.x,right:(E.right-w.right+S.right)/x.x}}const Wh=50,Kh=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=n,a=c.detectOverflow?c:{...c,detectOverflow:Uh},l=await(c.isRTL==null?void 0:c.isRTL(t));let u=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:h,y:d}=gc(u,r,l),f=r,m=0;const S={};for(let v=0;v<i.length;v++){const b=i[v];if(!b)continue;const{name:w,fn:j}=b,{x:C,y:x,data:E,reset:P}=await j({x:h,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:S,rects:u,platform:a,elements:{reference:e,floating:t}});h=C??h,d=x??d,S[w]={...S[w],...E},P&&m<Wh&&(m++,typeof P=="object"&&(P.placement&&(f=P.placement),P.rects&&(u=P.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):P.rects),{x:h,y:d}=gc(u,f,l)),v=-1)}return{x:h,y:d,placement:f,strategy:o,middlewareData:S}},Vh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:c,elements:a,middlewareData:l}=t,{element:u,padding:h=0}=Qt(e,t)||{};if(u==null)return{};const d=gd(h),f={x:n,y:r},m=Xi(o),S=Yi(m),v=await c.getDimensions(u),b=m==="y",w=b?"top":"left",j=b?"bottom":"right",C=b?"clientHeight":"clientWidth",x=i.reference[S]+i.reference[m]-f[m]-i.floating[S],E=f[m]-i.reference[m],P=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let A=P?P[C]:0;(!A||!await(c.isElement==null?void 0:c.isElement(P)))&&(A=a.floating[C]||i.floating[S]);const g=x/2-E/2,I=A/2-v[S]/2-1,T=bn(d[w],I),O=bn(d[j],I),_=T,M=A-v[S]-O,q=A/2-v[S]/2+g,G=Ti(_,q,M),J=!l.arrow&&Or(o)!=null&&q!==G&&i.reference[S]/2-(q<_?T:O)-v[S]/2<0,H=J?q<_?q-_:q-M:0;return{[m]:f[m]+H,data:{[m]:G,centerOffset:q-G-H,...J&&{alignmentOffset:H}},reset:J}}}),Hh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:c,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:v=!0,...b}=Qt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=Jt(o),j=zt(a),C=Jt(a)===a,x=await(l.isRTL==null?void 0:l.isRTL(u.floating)),E=f||(C||!v?[ns(a)]:Lh(a)),P=S!=="none";!f&&P&&E.push(...zh(a,v,S,x));const A=[a,...E],g=await l.detectOverflow(t,b),I=[];let T=((r=i.flip)==null?void 0:r.overflows)||[];if(h&&I.push(g[w]),d){const q=Mh(o,c,x);I.push(g[q[0]],g[q[1]])}if(T=[...T,{placement:o,overflows:I}],!I.every(q=>q<=0)){var O,_;const q=(((O=i.flip)==null?void 0:O.index)||0)+1,G=A[q];if(G&&(!(d==="alignment"?j!==zt(G):!1)||T.every(L=>zt(L.placement)===j?L.overflows[0]>0:!0)))return{data:{index:q,overflows:T},reset:{placement:G}};let J=(_=T.filter(H=>H.overflows[0]<=0).sort((H,L)=>H.overflows[1]-L.overflows[1])[0])==null?void 0:_.placement;if(!J)switch(m){case"bestFit":{var M;const H=(M=T.filter(L=>{if(P){const $=zt(L.placement);return $===j||$==="y"}return!0}).map(L=>[L.placement,L.overflows.filter($=>$>0).reduce(($,X)=>$+X,0)]).sort((L,$)=>L[1]-$[1])[0])==null?void 0:M[0];H&&(J=H);break}case"initialPlacement":J=a;break}if(o!==J)return{reset:{placement:J}}}return{}}}};function yc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bc(e){return Dh.some(t=>e[t]>=0)}const Gh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Qt(e,t);switch(o){case"referenceHidden":{const c=await r.detectOverflow(t,{...i,elementContext:"reference"}),a=yc(c,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:bc(a)}}}case"escaped":{const c=await r.detectOverflow(t,{...i,altBoundary:!0}),a=yc(c,n.floating);return{data:{escapedOffsets:a,escaped:bc(a)}}}default:return{}}}}},yd=new Set(["left","top"]);async function Qh(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Jt(n),a=Or(n),l=zt(n)==="y",u=yd.has(c)?-1:1,h=i&&l?-1:1,d=Qt(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:S}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof S=="number"&&(m=a==="end"?S*-1:S),l?{x:m*h,y:f*u}:{x:f*u,y:m*h}}const Jh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:c,middlewareData:a}=t,l=await Qh(t,e);return c===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:c}}}}},Yh=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:c=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:j,y:C}=w;return{x:j,y:C}}},...u}=Qt(e,t),h={x:n,y:r},d=await i.detectOverflow(t,u),f=zt(Jt(o)),m=Ji(f);let S=h[m],v=h[f];if(c){const w=m==="y"?"top":"left",j=m==="y"?"bottom":"right",C=S+d[w],x=S-d[j];S=Ti(C,S,x)}if(a){const w=f==="y"?"top":"left",j=f==="y"?"bottom":"right",C=v+d[w],x=v-d[j];v=Ti(C,v,x)}const b=l.fn({...t,[m]:S,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[m]:c,[f]:a}}}}}},Xh=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:c}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=Qt(e,t),h={x:n,y:r},d=zt(o),f=Ji(d);let m=h[f],S=h[d];const v=Qt(a,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const C=f==="y"?"height":"width",x=i.reference[f]-i.floating[C]+b.mainAxis,E=i.reference[f]+i.reference[C]-b.mainAxis;m<x?m=x:m>E&&(m=E)}if(u){var w,j;const C=f==="y"?"width":"height",x=yd.has(Jt(o)),E=i.reference[d]-i.floating[C]+(x&&((w=c.offset)==null?void 0:w[d])||0)+(x?0:b.crossAxis),P=i.reference[d]+i.reference[C]+(x?0:((j=c.offset)==null?void 0:j[d])||0)-(x?b.crossAxis:0);S<E?S=E:S>P&&(S=P)}return{[f]:m,[d]:S}}}},Zh=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:c,elements:a}=t,{apply:l=()=>{},...u}=Qt(e,t),h=await c.detectOverflow(t,u),d=Jt(o),f=Or(o),m=zt(o)==="y",{width:S,height:v}=i.floating;let b,w;d==="top"||d==="bottom"?(b=d,w=f===(await(c.isRTL==null?void 0:c.isRTL(a.floating))?"start":"end")?"left":"right"):(w=d,b=f==="end"?"top":"bottom");const j=v-h.top-h.bottom,C=S-h.left-h.right,x=bn(v-h[b],j),E=bn(S-h[w],C),P=!t.middlewareData.shift;let A=x,g=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(g=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(A=j),P&&!f){const T=ht(h.left,0),O=ht(h.right,0),_=ht(h.top,0),M=ht(h.bottom,0);m?g=S-2*(T!==0||O!==0?T+O:ht(h.left,h.right)):A=v-2*(_!==0||M!==0?_+M:ht(h.top,h.bottom))}await l({...t,availableWidth:g,availableHeight:A});const I=await c.getDimensions(a.floating);return S!==I.width||v!==I.height?{reset:{rects:!0}}:{}}}};function ms(){return typeof window<"u"}function _r(e){return bd(e)?(e.nodeName||"").toLowerCase():"#document"}function mt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ut(e){var t;return(t=(bd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bd(e){return ms()?e instanceof Node||e instanceof mt(e).Node:!1}function _t(e){return ms()?e instanceof Element||e instanceof mt(e).Element:!1}function Yt(e){return ms()?e instanceof HTMLElement||e instanceof mt(e).HTMLElement:!1}function xc(e){return!ms()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof mt(e).ShadowRoot}function go(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Pt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function em(e){return/^(table|td|th)$/.test(_r(e))}function gs(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tm=/transform|translate|scale|rotate|perspective|filter/,nm=/paint|layout|strict|content/,An=e=>!!e&&e!=="none";let $s;function Zi(e){const t=_t(e)?Pt(e):e;return An(t.transform)||An(t.translate)||An(t.scale)||An(t.rotate)||An(t.perspective)||!ea()&&(An(t.backdropFilter)||An(t.filter))||tm.test(t.willChange||"")||nm.test(t.contain||"")}function rm(e){let t=xn(e);for(;Yt(t)&&!Tr(t);){if(Zi(t))return t;if(gs(t))return null;t=xn(t)}return null}function ea(){return $s==null&&($s=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),$s}function Tr(e){return/^(html|body|#document)$/.test(_r(e))}function Pt(e){return mt(e).getComputedStyle(e)}function ys(e){return _t(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xn(e){if(_r(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xc(e)&&e.host||Ut(e);return xc(t)?t.host:t}function xd(e){const t=xn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Yt(t)&&go(t)?t:xd(t)}function to(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=mt(o);if(i){const a=Ri(c);return t.concat(c,c.visualViewport||[],go(o)?o:[],a&&n?to(a):[])}else return t.concat(o,to(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=Pt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Yt(e),i=o?e.offsetWidth:n,c=o?e.offsetHeight:r,a=ts(n)!==i||ts(r)!==c;return a&&(n=i,r=c),{width:n,height:r,$:a}}function ta(e){return _t(e)?e:e.contextElement}function lr(e){const t=ta(e);if(!Yt(t))return qt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=vd(t);let c=(i?ts(n.width):n.width)/r,a=(i?ts(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!a||!Number.isFinite(a))&&(a=1),{x:c,y:a}}const om=qt(0);function Sd(e){const t=mt(e);return!ea()||!t.visualViewport?om:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==mt(e)?!1:t}function Un(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ta(e);let c=qt(1);t&&(r?_t(r)&&(c=lr(r)):c=lr(e));const a=sm(i,n,r)?Sd(i):qt(0);let l=(o.left+a.x)/c.x,u=(o.top+a.y)/c.y,h=o.width/c.x,d=o.height/c.y;if(i){const f=mt(i),m=r&&_t(r)?mt(r):r;let S=f,v=Ri(S);for(;v&&r&&m!==S;){const b=lr(v),w=v.getBoundingClientRect(),j=Pt(v),C=w.left+(v.clientLeft+parseFloat(j.paddingLeft))*b.x,x=w.top+(v.clientTop+parseFloat(j.paddingTop))*b.y;l*=b.x,u*=b.y,h*=b.x,d*=b.y,l+=C,u+=x,S=mt(v),v=Ri(S)}}return rs({width:h,height:d,x:l,y:u})}function bs(e,t){const n=ys(e).scrollLeft;return t?t.left+n:Un(Ut(e)).left+n}function wd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-bs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function im(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=Ut(r),a=t?gs(t.floating):!1;if(r===c||a&&i)return n;let l={scrollLeft:0,scrollTop:0},u=qt(1);const h=qt(0),d=Yt(r);if((d||!d&&!i)&&((_r(r)!=="body"||go(c))&&(l=ys(r)),d)){const m=Un(r);u=lr(r),h.x=m.x+r.clientLeft,h.y=m.y+r.clientTop}const f=c&&!d&&!i?wd(c,l):qt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+h.x+f.x,y:n.y*u.y-l.scrollTop*u.y+h.y+f.y}}function am(e){return Array.from(e.getClientRects())}function cm(e){const t=Ut(e),n=ys(e),r=e.ownerDocument.body,o=ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+bs(e);const a=-n.scrollTop;return Pt(r).direction==="rtl"&&(c+=ht(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:c,y:a}}const vc=25;function lm(e,t){const n=mt(e),r=Ut(e),o=n.visualViewport;let i=r.clientWidth,c=r.clientHeight,a=0,l=0;if(o){i=o.width,c=o.height;const h=ea();(!h||h&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=bs(r);if(u<=0){const h=r.ownerDocument,d=h.body,f=getComputedStyle(d),m=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,S=Math.abs(r.clientWidth-d.clientWidth-m);S<=vc&&(i-=S)}else u<=vc&&(i+=u);return{width:i,height:c,x:a,y:l}}function dm(e,t){const n=Un(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Yt(e)?lr(e):qt(1),c=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,u=r*i.y;return{width:c,height:a,x:l,y:u}}function Sc(e,t,n){let r;if(t==="viewport")r=lm(e,n);else if(t==="document")r=cm(Ut(e));else if(_t(t))r=dm(t,n);else{const o=Sd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function kd(e,t){const n=xn(e);return n===t||!_t(n)||Tr(n)?!1:Pt(n).position==="fixed"||kd(n,t)}function um(e,t){const n=t.get(e);if(n)return n;let r=to(e,[],!1).filter(a=>_t(a)&&_r(a)!=="body"),o=null;const i=Pt(e).position==="fixed";let c=i?xn(e):e;for(;_t(c)&&!Tr(c);){const a=Pt(c),l=Zi(c);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||go(c)&&!l&&kd(e,c))?r=r.filter(h=>h!==c):o=a,c=xn(c)}return t.set(e,r),r}function pm(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const c=[...n==="clippingAncestors"?gs(t)?[]:um(t,this._c):[].concat(n),r],a=Sc(t,c[0],o);let l=a.top,u=a.right,h=a.bottom,d=a.left;for(let f=1;f<c.length;f++){const m=Sc(t,c[f],o);l=ht(m.top,l),u=bn(m.right,u),h=bn(m.bottom,h),d=ht(m.left,d)}return{width:u-d,height:h-l,x:d,y:l}}function fm(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function hm(e,t,n){const r=Yt(t),o=Ut(t),i=n==="fixed",c=Un(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=qt(0);function u(){l.x=bs(o)}if(r||!r&&!i)if((_r(t)!=="body"||go(o))&&(a=ys(t)),r){const m=Un(t,!0,i,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else o&&u();i&&!r&&o&&u();const h=o&&!r&&!i?wd(o,a):qt(0),d=c.left+a.scrollLeft-l.x-h.x,f=c.top+a.scrollTop-l.y-h.y;return{x:d,y:f,width:c.width,height:c.height}}function Ms(e){return Pt(e).position==="static"}function wc(e,t){if(!Yt(e)||Pt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ut(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){const n=mt(e);if(gs(e))return n;if(!Yt(e)){let o=xn(e);for(;o&&!Tr(o);){if(_t(o)&&!Ms(o))return o;o=xn(o)}return n}let r=wc(e,t);for(;r&&em(r)&&Ms(r);)r=wc(r,t);return r&&Tr(r)&&Ms(r)&&!Zi(r)?n:r||rm(e)||n}const mm=async function(e){const t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:hm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gm(e){return Pt(e).direction==="rtl"}const ym={convertOffsetParentRelativeRectToViewportRelativeRect:im,getDocumentElement:Ut,getClippingRect:pm,getOffsetParent:Cd,getElementRects:mm,getClientRects:am,getDimensions:fm,getScale:lr,isElement:_t,isRTL:gm};function jd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bm(e,t){let n=null,r;const o=Ut(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function c(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:h,top:d,width:f,height:m}=u;if(a||t(),!f||!m)return;const S=Io(d),v=Io(o.clientWidth-(h+f)),b=Io(o.clientHeight-(d+m)),w=Io(h),C={rootMargin:-S+"px "+-v+"px "+-b+"px "+-w+"px",threshold:ht(0,bn(1,l))||1};let x=!0;function E(P){const A=P[0].intersectionRatio;if(A!==l){if(!x)return c();A?c(!1,A):r=setTimeout(()=>{c(!1,1e-7)},1e3)}A===1&&!jd(u,e.getBoundingClientRect())&&c(),x=!1}try{n=new IntersectionObserver(E,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,C)}n.observe(e)}return c(!0),i}function xm(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ta(e),h=o||i?[...u?to(u):[],...t?to(t):[]]:[];h.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const d=u&&a?bm(u,n):null;let f=-1,m=null;c&&(m=new ResizeObserver(w=>{let[j]=w;j&&j.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var C;(C=m)==null||C.observe(t)})),n()}),u&&!l&&m.observe(u),t&&m.observe(t));let S,v=l?Un(e):null;l&&b();function b(){const w=Un(e);v&&!jd(v,w)&&n(),v=w,S=requestAnimationFrame(b)}return n(),()=>{var w;h.forEach(j=>{o&&j.removeEventListener("scroll",n),i&&j.removeEventListener("resize",n)}),d==null||d(),(w=m)==null||w.disconnect(),m=null,l&&cancelAnimationFrame(S)}}const vm=Jh,Sm=Yh,wm=Hh,km=Zh,Cm=Gh,kc=Vh,jm=Xh,Em=(e,t,n)=>{const r=new Map,o={platform:ym,...n},i={...o.platform,_c:r};return Kh(e,t,{...o,platform:i})};var Tm=typeof document<"u",Am=function(){},Go=Tm?p.useLayoutEffect:Am;function os(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(!os(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)&&!os(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Ed(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cc(e,t){const n=Ed(e);return Math.round(t*n)/n}function Ls(e){const t=p.useRef(e);return Go(()=>{t.current=e}),t}function Rm(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:c}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[h,d]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=p.useState(r);os(f,r)||m(r);const[S,v]=p.useState(null),[b,w]=p.useState(null),j=p.useCallback(L=>{L!==P.current&&(P.current=L,v(L))},[]),C=p.useCallback(L=>{L!==A.current&&(A.current=L,w(L))},[]),x=i||S,E=c||b,P=p.useRef(null),A=p.useRef(null),g=p.useRef(h),I=l!=null,T=Ls(l),O=Ls(o),_=Ls(u),M=p.useCallback(()=>{if(!P.current||!A.current)return;const L={placement:t,strategy:n,middleware:f};O.current&&(L.platform=O.current),Em(P.current,A.current,L).then($=>{const X={...$,isPositioned:_.current!==!1};q.current&&!os(g.current,X)&&(g.current=X,Qi.flushSync(()=>{d(X)}))})},[f,t,n,O,_]);Go(()=>{u===!1&&g.current.isPositioned&&(g.current.isPositioned=!1,d(L=>({...L,isPositioned:!1})))},[u]);const q=p.useRef(!1);Go(()=>(q.current=!0,()=>{q.current=!1}),[]),Go(()=>{if(x&&(P.current=x),E&&(A.current=E),x&&E){if(T.current)return T.current(x,E,M);M()}},[x,E,M,T,I]);const G=p.useMemo(()=>({reference:P,floating:A,setReference:j,setFloating:C}),[j,C]),J=p.useMemo(()=>({reference:x,floating:E}),[x,E]),H=p.useMemo(()=>{const L={position:n,left:0,top:0};if(!J.floating)return L;const $=Cc(J.floating,h.x),X=Cc(J.floating,h.y);return a?{...L,transform:"translate("+$+"px, "+X+"px)",...Ed(J.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:X}},[n,a,J.floating,h.x,h.y]);return p.useMemo(()=>({...h,update:M,refs:G,elements:J,floatingStyles:H}),[h,M,G,J,H])}const Om=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?kc({element:r.current,padding:o}).fn(n):{}:r?kc({element:r,padding:o}).fn(n):{}}}},_m=(e,t)=>{const n=vm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pm=(e,t)=>{const n=Sm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Im=(e,t)=>({fn:jm(e).fn,options:[e,t]}),Dm=(e,t)=>{const n=wm(e);return{name:n.name,fn:n.fn,options:[e,t]}},$m=(e,t)=>{const n=km(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mm=(e,t)=>{const n=Cm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lm=(e,t)=>{const n=Om(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Nm="Arrow",Td=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Te.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"})})});Td.displayName=Nm;var Bm=Td;function Fm(e){const[t,n]=p.useState(void 0);return yn(()=>{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 c,a;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;c=u.inlineSize,a=u.blockSize}else c=e.offsetWidth,a=e.offsetHeight;n({width:c,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[Ad,Pr]=wn(na),[zm,Rd]=Ad(na),Od=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return s.jsx(zm,{scope:t,anchor:r,onAnchorChange:o,children:n})};Od.displayName=na;var _d="PopperAnchor",Pd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Rd(_d,n),c=p.useRef(null),a=Oe(t,c),l=p.useRef(null);return p.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||c.current,u!==l.current&&i.onAnchorChange(l.current)}),r?null:s.jsx(Te.div,{...o,ref:a})});Pd.displayName=_d;var ra="PopperContent",[qm,Um]=Ad(ra),Id=p.forwardRef((e,t)=>{var ce,ke,xe,De,We,Be;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:c=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:h=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:S,...v}=e,b=Rd(ra,n),[w,j]=p.useState(null),C=Oe(t,Ee=>j(Ee)),[x,E]=p.useState(null),P=Fm(x),A=(P==null?void 0:P.width)??0,g=(P==null?void 0:P.height)??0,I=r+(i!=="center"?"-"+i:""),T=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},O=Array.isArray(u)?u:[u],_=O.length>0,M={padding:T,boundary:O.filter(Km),altBoundary:_},{refs:q,floatingStyles:G,placement:J,isPositioned:H,middlewareData:L}=Rm({strategy:"fixed",placement:I,whileElementsMounted:(...Ee)=>xm(...Ee,{animationFrame:m==="always"}),elements:{reference:b.anchor},middleware:[_m({mainAxis:o+g,alignmentAxis:c}),l&&Pm({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Im():void 0,...M}),l&&Dm({...M}),$m({...M,apply:({elements:Ee,rects:ge,availableWidth:Je,availableHeight:tt})=>{const{width:Fe,height:Ke}=ge.reference,gt=Ee.floating.style;gt.setProperty("--radix-popper-available-width",`${Je}px`),gt.setProperty("--radix-popper-available-height",`${tt}px`),gt.setProperty("--radix-popper-anchor-width",`${Fe}px`),gt.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),x&&Lm({element:x,padding:a}),Vm({arrowWidth:A,arrowHeight:g}),f&&Mm({strategy:"referenceHidden",...M})]}),[$,X]=Md(J),W=gn(S);yn(()=>{H&&(W==null||W())},[H,W]);const te=(ce=L.arrow)==null?void 0:ce.x,F=(ke=L.arrow)==null?void 0:ke.y,K=((xe=L.arrow)==null?void 0:xe.centerOffset)!==0,[oe,ee]=p.useState();return yn(()=>{w&&ee(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:H?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(De=L.transformOrigin)==null?void 0:De.x,(We=L.transformOrigin)==null?void 0:We.y].join(" "),...((Be=L.hide)==null?void 0:Be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(qm,{scope:n,placedSide:$,onArrowChange:E,arrowX:te,arrowY:F,shouldHideArrow:K,children:s.jsx(Te.div,{"data-side":$,"data-align":X,...v,ref:C,style:{...v.style,animation:H?void 0:"none"}})})})});Id.displayName=ra;var Dd="PopperArrow",Wm={top:"bottom",right:"left",bottom:"top",left:"right"},$d=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Um(Dd,r),c=Wm[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[c]: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(Bm,{...o,ref:n,style:{...o.style,display:"block"}})})});$d.displayName=Dd;function Km(e){return e!==null}var Vm=e=>({name:"transformOrigin",options:e,fn(t){var b,w,j;const{placement:n,rects:r,middlewareData:o}=t,c=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=c?0:e.arrowWidth,l=c?0:e.arrowHeight,[u,h]=Md(n),d={start:"0%",center:"50%",end:"100%"}[h],f=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,m=(((j=o.arrow)==null?void 0:j.y)??0)+l/2;let S="",v="";return u==="bottom"?(S=c?d:`${f}px`,v=`${-l}px`):u==="top"?(S=c?d:`${f}px`,v=`${r.floating.height+l}px`):u==="right"?(S=`${-l}px`,v=c?d:`${m}px`):u==="left"&&(S=`${r.floating.width+l}px`,v=c?d:`${m}px`),{data:{x:S,y:v}}}});function Md(e){const[t,n="center"]=e.split("-");return[t,n]}var Hm=Od,xs=Pd,oa=Id,sa=$d,Gm="Portal",yo=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=p.useState(!1);yn(()=>i(!0),[]);const c=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return c?yh.createPortal(s.jsx(Te.div,{...r,ref:t}),c):null});yo.displayName=Gm;function Qm(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var wt=e=>{const{present:t,children:n}=e,r=Jm(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=Oe(r.ref,Ym(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:i}):null};wt.displayName="Presence";function Jm(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),c=e?"mounted":"unmounted",[a,l]=Qm(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=Do(r.current);i.current=a==="mounted"?u:"none"},[a]),yn(()=>{const u=r.current,h=o.current;if(h!==e){const f=i.current,m=Do(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(h&&f!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),yn(()=>{if(t){let u;const h=t.ownerDocument.defaultView??window,d=m=>{const v=Do(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(l("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=m=>{m.target===t&&(i.current=Do(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{h.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Do(e){return(e==null?void 0:e.animationName)||"none"}function Ym(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 Xm=Xl[" useInsertionEffect ".trim().toString()]||yn;function ia({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,c]=Zm({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const h=p.useRef(e!==void 0);p.useEffect(()=>{const d=h.current;d!==a&&console.warn(`${r} is changing from ${d?"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.`),h.current=a},[a,r])}const u=p.useCallback(h=>{var d;if(a){const f=eg(h)?h(e):h;f!==e&&((d=c.current)==null||d.call(c,f))}else i(h)},[a,e,i,c]);return[l,u]}function Zm({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return Xm(()=>{i.current=t},[t]),p.useEffect(()=>{var c;o.current!==n&&((c=i.current)==null||c.call(i,n),o.current=n)},[n,o]),[n,r,i]}function eg(e){return typeof e=="function"}var tg=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"}),ng="VisuallyHidden",Ld=p.forwardRef((e,t)=>s.jsx(Te.span,{...e,ref:t,style:{...tg,...e.style}}));Ld.displayName=ng;var rg=Ld,[vs]=wn("Tooltip",[Pr]),Ss=Pr(),Nd="TooltipProvider",og=700,Oi="tooltip.open",[sg,aa]=vs(Nd),Bd=e=>{const{__scopeTooltip:t,delayDuration:n=og,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,c=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),s.jsx(sg,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),c.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(u=>{a.current=u},[]),disableHoverableContent:o,children:i})};Bd.displayName=Nd;var no="Tooltip",[ig,bo]=vs(no),Fd=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:c,delayDuration:a}=e,l=aa(no,e.__scopeTooltip),u=Ss(t),[h,d]=p.useState(null),f=Qr(),m=p.useRef(0),S=c??l.disableHoverableContent,v=a??l.delayDuration,b=p.useRef(!1),[w,j]=ia({prop:r,defaultProp:o??!1,onChange:A=>{A?(l.onOpen(),document.dispatchEvent(new CustomEvent(Oi))):l.onClose(),i==null||i(A)},caller:no}),C=p.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),x=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,j(!0)},[j]),E=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j(!1)},[j]),P=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,j(!0),m.current=0},v)},[v,j]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(Hm,{...u,children:s.jsx(ig,{scope:t,contentId:f,open:w,stateAttribute:C,trigger:h,onTriggerChange:d,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?P():x()},[l.isOpenDelayedRef,P,x]),onTriggerLeave:p.useCallback(()=>{S?E():(window.clearTimeout(m.current),m.current=0)},[E,S]),onOpen:x,onClose:E,disableHoverableContent:S,children:n})})};Fd.displayName=no;var _i="TooltipTrigger",zd=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=bo(_i,n),i=aa(_i,n),c=Ss(n),a=p.useRef(null),l=Oe(t,a,o.onTriggerChange),u=p.useRef(!1),h=p.useRef(!1),d=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),s.jsx(xs,{asChild:!0,...c,children:s.jsx(Te.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:de(e.onPointerMove,f=>{f.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:de(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:de(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:de(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:de(e.onBlur,o.onClose),onClick:de(e.onClick,o.onClose)})})});zd.displayName=_i;var ca="TooltipPortal",[ag,cg]=vs(ca,{forceMount:void 0}),qd=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=bo(ca,t);return s.jsx(ag,{scope:t,forceMount:n,children:s.jsx(wt,{present:n||i.open,children:s.jsx(yo,{asChild:!0,container:o,children:r})})})};qd.displayName=ca;var Ar="TooltipContent",Ud=p.forwardRef((e,t)=>{const n=cg(Ar,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,c=bo(Ar,e.__scopeTooltip);return s.jsx(wt,{present:r||c.open,children:c.disableHoverableContent?s.jsx(Wd,{side:o,...i,ref:t}):s.jsx(lg,{side:o,...i,ref:t})})}),lg=p.forwardRef((e,t)=>{const n=bo(Ar,e.__scopeTooltip),r=aa(Ar,e.__scopeTooltip),o=p.useRef(null),i=Oe(t,o),[c,a]=p.useState(null),{trigger:l,onClose:u}=n,h=o.current,{onPointerInTransitChange:d}=r,f=p.useCallback(()=>{a(null),d(!1)},[d]),m=p.useCallback((S,v)=>{const b=S.currentTarget,w={x:S.clientX,y:S.clientY},j=hg(w,b.getBoundingClientRect()),C=mg(w,j),x=gg(v.getBoundingClientRect()),E=bg([...C,...x]);a(E),d(!0)},[d]);return p.useEffect(()=>()=>f(),[f]),p.useEffect(()=>{if(l&&h){const S=b=>m(b,h),v=b=>m(b,l);return l.addEventListener("pointerleave",S),h.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",S),h.removeEventListener("pointerleave",v)}}},[l,h,m,f]),p.useEffect(()=>{if(c){const S=v=>{const b=v.target,w={x:v.clientX,y:v.clientY},j=(l==null?void 0:l.contains(b))||(h==null?void 0:h.contains(b)),C=!yg(w,c);j?f():C&&(f(),u())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[l,h,c,u,f]),s.jsx(Wd,{...e,ref:i})}),[dg,ug]=vs(no,{isInside:!1}),pg=xh("TooltipContent"),Wd=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:c,...a}=e,l=bo(Ar,n),u=Ss(n),{onClose:h}=l;return p.useEffect(()=>(document.addEventListener(Oi,h),()=>document.removeEventListener(Oi,h)),[h]),p.useEffect(()=>{if(l.trigger){const d=f=>{const m=f.target;m!=null&&m.contains(l.trigger)&&h()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,h]),s.jsx(mo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:d=>d.preventDefault(),onDismiss:h,children:s.jsxs(oa,{"data-state":l.stateAttribute,...u,...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(pg,{children:r}),s.jsx(dg,{scope:n,isInside:!0,children:s.jsx(rg,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ud.displayName=Ar;var Kd="TooltipArrow",fg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ss(n);return ug(Kd,n).isInside?null:s.jsx(sa,{...o,...r,ref:t})});fg.displayName=Kd;function hg(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 mg(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 gg(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 yg(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,c=t.length-1;i<t.length;c=i++){const a=t[i],l=t[c],u=a.x,h=a.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-u)*(r-h)/(f-h)+u&&(o=!o)}return o}function bg(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),xg(t)}function xg(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],c=t[t.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.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],c=n[n.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.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 vg=Bd,Sg=Fd,wg=zd,kg=qd,Cg=Ud;function Vd({content:e,children:t,side:n="right",align:r="center",sideOffset:o=6,delayMs:i=200,container:c}){return s.jsxs(Sg,{delayDuration:i,children:[s.jsx(wg,{asChild:!0,children:t}),s.jsx(kg,{container:c,children:s.jsx(Cg,{side:n,align:r,sideOffset:o,style:{background:pe("surfaceElevated"),color:pe("textPrimary"),border:`1px solid ${pe("borderDefault")}`,borderRadius:Sn.sm,padding:`${be[1]} ${be[2]}`,fontSize:Ze.sm,boxShadow:pe("shadowMd"),zIndex:eo.tooltip,userSelect:"none"},children:e})})]})}const jg=vg;var Ns="focusScope.autoFocusOnMount",Bs="focusScope.autoFocusOnUnmount",jc={bubbles:!1,cancelable:!0},Eg="FocusScope",ws=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...c}=e,[a,l]=p.useState(null),u=gn(o),h=gn(i),d=p.useRef(null),f=Oe(t,v=>l(v)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let v=function(C){if(m.paused||!a)return;const x=C.target;a.contains(x)?d.current=x:on(d.current,{select:!0})},b=function(C){if(m.paused||!a)return;const x=C.relatedTarget;x!==null&&(a.contains(x)||on(d.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const E of C)E.removedNodes.length>0&&on(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",b);const j=new MutationObserver(w);return a&&j.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),j.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){Tc.add(m);const v=document.activeElement;if(!a.contains(v)){const w=new CustomEvent(Ns,jc);a.addEventListener(Ns,u),a.dispatchEvent(w),w.defaultPrevented||(Tg(Pg(Hd(a)),{select:!0}),document.activeElement===v&&on(a))}return()=>{a.removeEventListener(Ns,u),setTimeout(()=>{const w=new CustomEvent(Bs,jc);a.addEventListener(Bs,h),a.dispatchEvent(w),w.defaultPrevented||on(v??document.body,{select:!0}),a.removeEventListener(Bs,h),Tc.remove(m)},0)}}},[a,u,h,m]);const S=p.useCallback(v=>{if(!n&&!r||m.paused)return;const b=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,w=document.activeElement;if(b&&w){const j=v.currentTarget,[C,x]=Ag(j);C&&x?!v.shiftKey&&w===x?(v.preventDefault(),n&&on(C,{select:!0})):v.shiftKey&&w===C&&(v.preventDefault(),n&&on(x,{select:!0})):w===j&&v.preventDefault()}},[n,r,m.paused]);return s.jsx(Te.div,{tabIndex:-1,...c,ref:f,onKeyDown:S})});ws.displayName=Eg;function Tg(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(on(r,{select:t}),document.activeElement!==n)return}function Ag(e){const t=Hd(e),n=Ec(t,e),r=Ec(t.reverse(),e);return[n,r]}function Hd(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 Ec(e,t){for(const n of e)if(!Rg(n,{upTo:t}))return n}function Rg(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 Og(e){return e instanceof HTMLInputElement&&"select"in e}function on(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Og(e)&&t&&e.select()}}var Tc=_g();function _g(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ac(e,t),e.unshift(t)},remove(t){var n;e=Ac(e,t),(n=e[0])==null||n.resume()}}}function Ac(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Pg(e){return e.filter(t=>t.tagName!=="A")}var Fs=0;function la(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Rc()),document.body.insertAdjacentElement("beforeend",e[1]??Rc()),Fs++,()=>{Fs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Fs--}},[])}function Rc(){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 Bt=function(){return Bt=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},Bt.apply(this,arguments)};function Gd(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 Ig(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 Qo="right-scroll-bar-position",Jo="width-before-scroll-bar",Dg="with-scroll-bars-hidden",$g="--removed-body-scroll-bar-size";function zs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Mg(e,t){var n=p.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 Lg=typeof window<"u"?p.useLayoutEffect:p.useEffect,Oc=new WeakMap;function Ng(e,t){var n=Mg(null,function(r){return e.forEach(function(o){return zs(o,r)})});return Lg(function(){var r=Oc.get(n);if(r){var o=new Set(r),i=new Set(e),c=n.current;o.forEach(function(a){i.has(a)||zs(a,null)}),i.forEach(function(a){o.has(a)||zs(a,c)})}Oc.set(n,e)},[e]),n}function Bg(e){return e}function Fg(e,t){t===void 0&&(t=Bg);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 c=t(i,r);return n.push(c),function(){n=n.filter(function(a){return a!==c})}},assignSyncMedium:function(i){for(r=!0;n.length;){var c=n;n=[],c.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var c=[];if(n.length){var a=n;n=[],a.forEach(i),c=n}var l=function(){var h=c;c=[],h.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(h){c.push(h),u()},filter:function(h){return c=c.filter(h),n}}}};return o}function zg(e){e===void 0&&(e={});var t=Fg(null);return t.options=Bt({async:!0,ssr:!1},e),t}var Qd=function(e){var t=e.sideCar,n=Gd(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 p.createElement(r,Bt({},n))};Qd.isSideCarExport=!0;function qg(e,t){return e.useMedium(t),Qd}var Jd=zg(),qs=function(){},ks=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:qs,onWheelCapture:qs,onTouchMoveCapture:qs}),o=r[0],i=r[1],c=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,h=e.enabled,d=e.shards,f=e.sideCar,m=e.noRelative,S=e.noIsolation,v=e.inert,b=e.allowPinchZoom,w=e.as,j=w===void 0?"div":w,C=e.gapMode,x=Gd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=f,P=Ng([n,t]),A=Bt(Bt({},x),o);return p.createElement(p.Fragment,null,h&&p.createElement(E,{sideCar:Jd,removeScrollBar:u,shards:d,noRelative:m,noIsolation:S,inert:v,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:C}),c?p.cloneElement(p.Children.only(a),Bt(Bt({},A),{ref:P})):p.createElement(j,Bt({},A,{className:l,ref:P}),a))});ks.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ks.classNames={fullWidth:Jo,zeroRight:Qo};var Ug=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wg(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ug();return t&&e.setAttribute("nonce",t),e}function Kg(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vg(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Hg=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Wg())&&(Kg(t,n),Vg(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Gg=function(){var e=Hg();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Yd=function(){var e=Gg(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Qg={left:0,top:0,right:0,gap:0},Us=function(e){return parseInt(e||"",10)||0},Jg=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[Us(n),Us(r),Us(o)]},Yg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Qg;var t=Jg(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])}},Xg=Yd(),dr="data-scroll-locked",Zg=function(e,t,n,r){var o=e.left,i=e.top,c=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
11
|
+
.`.concat(Dg,` {
|
|
12
|
+
overflow: hidden `).concat(r,`;
|
|
13
|
+
padding-right: `).concat(a,"px ").concat(r,`;
|
|
14
|
+
}
|
|
15
|
+
body[`).concat(dr,`] {
|
|
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(c,`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(Qo,` {
|
|
29
|
+
right: `).concat(a,"px ").concat(r,`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.`).concat(Jo,` {
|
|
33
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.`).concat(Qo," .").concat(Qo,` {
|
|
37
|
+
right: 0 `).concat(r,`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.`).concat(Jo," .").concat(Jo,` {
|
|
41
|
+
margin-right: 0 `).concat(r,`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
body[`).concat(dr,`] {
|
|
45
|
+
`).concat($g,": ").concat(a,`px;
|
|
46
|
+
}
|
|
47
|
+
`)},_c=function(){var e=parseInt(document.body.getAttribute(dr)||"0",10);return isFinite(e)?e:0},ey=function(){p.useEffect(function(){return document.body.setAttribute(dr,(_c()+1).toString()),function(){var e=_c()-1;e<=0?document.body.removeAttribute(dr):document.body.setAttribute(dr,e.toString())}},[])},ty=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;ey();var i=p.useMemo(function(){return Yg(o)},[o]);return p.createElement(Xg,{styles:Zg(i,!t,o,n?"":"!important")})},Pi=!1;if(typeof window<"u")try{var $o=Object.defineProperty({},"passive",{get:function(){return Pi=!0,!0}});window.addEventListener("test",$o,$o),window.removeEventListener("test",$o,$o)}catch{Pi=!1}var Zn=Pi?{passive:!1}:!1,ny=function(e){return e.tagName==="TEXTAREA"},Xd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ny(e)&&n[t]==="visible")},ry=function(e){return Xd(e,"overflowY")},oy=function(e){return Xd(e,"overflowX")},Pc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Zd(e,r);if(o){var i=eu(e,r),c=i[1],a=i[2];if(c>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},sy=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},iy=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Zd=function(e,t){return e==="v"?ry(t):oy(t)},eu=function(e,t){return e==="v"?sy(t):iy(t)},ay=function(e,t){return e==="h"&&t==="rtl"?-1:1},cy=function(e,t,n,r,o){var i=ay(e,window.getComputedStyle(t).direction),c=i*r,a=n.target,l=t.contains(a),u=!1,h=c>0,d=0,f=0;do{if(!a)break;var m=eu(e,a),S=m[0],v=m[1],b=m[2],w=v-b-i*S;(S||w)&&Zd(e,a)&&(d+=w,f+=S);var j=a.parentNode;a=j&&j.nodeType===Node.DOCUMENT_FRAGMENT_NODE?j.host:j}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(h&&Math.abs(d)<1||!h&&Math.abs(f)<1)&&(u=!0),u},Mo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ic=function(e){return[e.deltaX,e.deltaY]},Dc=function(e){return e&&"current"in e?e.current:e},ly=function(e,t){return e[0]===t[0]&&e[1]===t[1]},dy=function(e){return`
|
|
48
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
49
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
50
|
+
`)},uy=0,er=[];function py(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(uy++)[0],i=p.useState(Yd)[0],c=p.useRef(e);p.useEffect(function(){c.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=Ig([e.lockRef.current],(e.shards||[]).map(Dc),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!c.current.allowPinchZoom;var w=Mo(v),j=n.current,C="deltaX"in v?v.deltaX:j[0]-w[0],x="deltaY"in v?v.deltaY:j[1]-w[1],E,P=v.target,A=Math.abs(C)>Math.abs(x)?"h":"v";if("touches"in v&&A==="h"&&P.type==="range")return!1;var g=window.getSelection(),I=g&&g.anchorNode,T=I?I===P||I.contains(P):!1;if(T)return!1;var O=Pc(A,P);if(!O)return!0;if(O?E=A:(E=A==="v"?"h":"v",O=Pc(A,P)),!O)return!1;if(!r.current&&"changedTouches"in v&&(C||x)&&(r.current=E),!E)return!0;var _=r.current||E;return cy(_,b,v,_==="h"?C:x)},[]),l=p.useCallback(function(v){var b=v;if(!(!er.length||er[er.length-1]!==i)){var w="deltaY"in b?Ic(b):Mo(b),j=t.current.filter(function(E){return E.name===b.type&&(E.target===b.target||b.target===E.shadowParent)&&ly(E.delta,w)})[0];if(j&&j.should){b.cancelable&&b.preventDefault();return}if(!j){var C=(c.current.shards||[]).map(Dc).filter(Boolean).filter(function(E){return E.contains(b.target)}),x=C.length>0?a(b,C[0]):!c.current.noIsolation;x&&b.cancelable&&b.preventDefault()}}},[]),u=p.useCallback(function(v,b,w,j){var C={name:v,delta:b,target:w,should:j,shadowParent:fy(w)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(x){return x!==C})},1)},[]),h=p.useCallback(function(v){n.current=Mo(v),r.current=void 0},[]),d=p.useCallback(function(v){u(v.type,Ic(v),v.target,a(v,e.lockRef.current))},[]),f=p.useCallback(function(v){u(v.type,Mo(v),v.target,a(v,e.lockRef.current))},[]);p.useEffect(function(){return er.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Zn),document.addEventListener("touchmove",l,Zn),document.addEventListener("touchstart",h,Zn),function(){er=er.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,Zn),document.removeEventListener("touchmove",l,Zn),document.removeEventListener("touchstart",h,Zn)}},[]);var m=e.removeScrollBar,S=e.inert;return p.createElement(p.Fragment,null,S?p.createElement(i,{styles:dy(o)}):null,m?p.createElement(ty,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fy(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const hy=qg(Jd,py);var Cs=p.forwardRef(function(e,t){return p.createElement(ks,Bt({},e,{ref:t,sideCar:hy}))});Cs.classNames=ks.classNames;var my=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},tr=new WeakMap,Lo=new WeakMap,No={},Ws=0,tu=function(e){return e&&(e.host||tu(e.parentNode))},gy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=tu(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})},yy=function(e,t,n,r){var o=gy(t,Array.isArray(e)?e:[e]);No[n]||(No[n]=new WeakMap);var i=No[n],c=[],a=new Set,l=new Set(o),u=function(d){!d||a.has(d)||(a.add(d),u(d.parentNode))};o.forEach(u);var h=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))h(f);else try{var m=f.getAttribute(r),S=m!==null&&m!=="false",v=(tr.get(f)||0)+1,b=(i.get(f)||0)+1;tr.set(f,v),i.set(f,b),c.push(f),v===1&&S&&Lo.set(f,!0),b===1&&f.setAttribute(n,"true"),S||f.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return h(t),a.clear(),Ws++,function(){c.forEach(function(d){var f=tr.get(d)-1,m=i.get(d)-1;tr.set(d,f),i.set(d,m),f||(Lo.has(d)||d.removeAttribute(r),Lo.delete(d)),m||d.removeAttribute(n)}),Ws--,Ws||(tr=new WeakMap,tr=new WeakMap,Lo=new WeakMap,No={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=my(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),yy(r,o,n,"aria-hidden")):function(){return null}},js="Dialog",[nu]=wn(js),[by,It]=nu(js),ru=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:c=!0}=e,a=p.useRef(null),l=p.useRef(null),[u,h]=ia({prop:r,defaultProp:o??!1,onChange:i,caller:js});return s.jsx(by,{scope:t,triggerRef:a,contentRef:l,contentId:Qr(),titleId:Qr(),descriptionId:Qr(),open:u,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(d=>!d),[h]),modal:c,children:n})};ru.displayName=js;var ou="DialogTrigger",xy=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=It(ou,n),i=Oe(t,o.triggerRef);return s.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":fa(o.open),...r,ref:i,onClick:de(e.onClick,o.onOpenToggle)})});xy.displayName=ou;var ua="DialogPortal",[vy,su]=nu(ua,{forceMount:void 0}),iu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=It(ua,t);return s.jsx(vy,{scope:t,forceMount:n,children:p.Children.map(r,c=>s.jsx(wt,{present:n||i.open,children:s.jsx(yo,{asChild:!0,container:o,children:c})}))})};iu.displayName=ua;var ss="DialogOverlay",au=p.forwardRef((e,t)=>{const n=su(ss,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=It(ss,e.__scopeDialog);return i.modal?s.jsx(wt,{present:r||i.open,children:s.jsx(wy,{...o,ref:t})}):null});au.displayName=ss;var Sy=Er("DialogOverlay.RemoveScroll"),wy=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=It(ss,n);return s.jsx(Cs,{as:Sy,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Te.div,{"data-state":fa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Wn="DialogContent",cu=p.forwardRef((e,t)=>{const n=su(Wn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=It(Wn,e.__scopeDialog);return s.jsx(wt,{present:r||i.open,children:i.modal?s.jsx(ky,{...o,ref:t}):s.jsx(Cy,{...o,ref:t})})});cu.displayName=Wn;var ky=p.forwardRef((e,t)=>{const n=It(Wn,e.__scopeDialog),r=p.useRef(null),o=Oe(t,n.contentRef,r);return p.useEffect(()=>{const i=r.current;if(i)return da(i)},[]),s.jsx(lu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,i=>{var c;i.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,i=>{const c=i.detail.originalEvent,a=c.button===0&&c.ctrlKey===!0;(c.button===2||a)&&i.preventDefault()}),onFocusOutside:de(e.onFocusOutside,i=>i.preventDefault())})}),Cy=p.forwardRef((e,t)=>{const n=It(Wn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(lu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var c,a;(c=e.onCloseAutoFocus)==null||c.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 l,u;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),lu=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...c}=e,a=It(Wn,n),l=p.useRef(null),u=Oe(t,l);return la(),s.jsxs(s.Fragment,{children:[s.jsx(ws,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(mo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":fa(a.open),...c,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Ty,{titleId:a.titleId}),s.jsx(Ry,{contentRef:l,descriptionId:a.descriptionId})]})]})}),pa="DialogTitle",du=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=It(pa,n);return s.jsx(Te.h2,{id:o.titleId,...r,ref:t})});du.displayName=pa;var uu="DialogDescription",jy=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=It(uu,n);return s.jsx(Te.p,{id:o.descriptionId,...r,ref:t})});jy.displayName=uu;var pu="DialogClose",Ey=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=It(pu,n);return s.jsx(Te.button,{type:"button",...r,ref:t,onClick:de(e.onClick,()=>o.onOpenChange(!1))})});Ey.displayName=pu;function fa(e){return e?"open":"closed"}var fu="DialogTitleWarning",[pj,hu]=mh(fu,{contentName:Wn,titleName:pa,docsSlug:"dialog"}),Ty=({titleId:e})=>{const t=hu(fu),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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ay="DialogDescriptionWarning",Ry=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hu(Ay).contentName}}.`;return p.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},Oy=ru,_y=iu,Py=au,Iy=cu,Dy=du;function mu(e){const t=e+"CollectionProvider",[n,r]=wn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=v=>{const{scope:b,children:w}=v,j=qe.useRef(null),C=qe.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:C,collectionRef:j,children:w})};c.displayName=t;const a=e+"CollectionSlot",l=Er(a),u=qe.forwardRef((v,b)=>{const{scope:w,children:j}=v,C=i(a,w),x=Oe(b,C.collectionRef);return s.jsx(l,{ref:x,children:j})});u.displayName=a;const h=e+"CollectionItemSlot",d="data-radix-collection-item",f=Er(h),m=qe.forwardRef((v,b)=>{const{scope:w,children:j,...C}=v,x=qe.useRef(null),E=Oe(b,x),P=i(h,w);return qe.useEffect(()=>(P.itemMap.set(x,{ref:x,...C}),()=>void P.itemMap.delete(x))),s.jsx(f,{[d]:"",ref:E,children:j})});m.displayName=h;function S(v){const b=i(e+"CollectionConsumer",v);return qe.useCallback(()=>{const j=b.collectionRef.current;if(!j)return[];const C=Array.from(j.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((P,A)=>C.indexOf(P.ref.current)-C.indexOf(A.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:c,Slot:u,ItemSlot:m},S,r]}var $y=p.createContext(void 0);function My(e){const t=p.useContext($y);return e||t||"ltr"}var Ks="rovingFocusGroup.onEntryFocus",Ly={bubbles:!1,cancelable:!0},xo="RovingFocusGroup",[Ii,gu,Ny]=mu(xo),[By,yu]=wn(xo,[Ny]),[Fy,zy]=By(xo),bu=p.forwardRef((e,t)=>s.jsx(Ii.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Ii.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(qy,{...e,ref:t})})}));bu.displayName=xo;var qy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:c,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:h=!1,...d}=e,f=p.useRef(null),m=Oe(t,f),S=My(i),[v,b]=ia({prop:c,defaultProp:a??null,onChange:l,caller:xo}),[w,j]=p.useState(!1),C=gn(u),x=gu(n),E=p.useRef(!1),[P,A]=p.useState(0);return p.useEffect(()=>{const g=f.current;if(g)return g.addEventListener(Ks,C),()=>g.removeEventListener(Ks,C)},[C]),s.jsx(Fy,{scope:n,orientation:r,dir:S,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(g=>b(g),[b]),onItemShiftTab:p.useCallback(()=>j(!0),[]),onFocusableItemAdd:p.useCallback(()=>A(g=>g+1),[]),onFocusableItemRemove:p.useCallback(()=>A(g=>g-1),[]),children:s.jsx(Te.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{E.current=!0}),onFocus:de(e.onFocus,g=>{const I=!E.current;if(g.target===g.currentTarget&&I&&!w){const T=new CustomEvent(Ks,Ly);if(g.currentTarget.dispatchEvent(T),!T.defaultPrevented){const O=x().filter(J=>J.focusable),_=O.find(J=>J.active),M=O.find(J=>J.id===v),G=[_,M,...O].filter(Boolean).map(J=>J.ref.current);Su(G,h)}}E.current=!1}),onBlur:de(e.onBlur,()=>j(!1))})})}),xu="RovingFocusGroupItem",vu=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:c,...a}=e,l=Qr(),u=i||l,h=zy(xu,n),d=h.currentTabStopId===u,f=gu(n),{onFocusableItemAdd:m,onFocusableItemRemove:S,currentTabStopId:v}=h;return p.useEffect(()=>{if(r)return m(),()=>S()},[r,m,S]),s.jsx(Ii.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Te.span,{tabIndex:d?0:-1,"data-orientation":h.orientation,...a,ref:t,onMouseDown:de(e.onMouseDown,b=>{r?h.onItemFocus(u):b.preventDefault()}),onFocus:de(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:de(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){h.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=Ky(b,h.orientation,h.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let C=f().filter(x=>x.focusable).map(x=>x.ref.current);if(w==="last")C.reverse();else if(w==="prev"||w==="next"){w==="prev"&&C.reverse();const x=C.indexOf(b.currentTarget);C=h.loop?Vy(C,x+1):C.slice(x+1)}setTimeout(()=>Su(C))}}),children:typeof c=="function"?c({isCurrentTabStop:d,hasTabStop:v!=null}):c})})});vu.displayName=xu;var Uy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Wy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ky(e,t,n){const r=Wy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Uy[r]}function Su(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Vy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hy=bu,Gy=vu,Di=["Enter"," "],Qy=["ArrowDown","PageUp","Home"],wu=["ArrowUp","PageDown","End"],Jy=[...Qy,...wu],Yy={ltr:[...Di,"ArrowRight"],rtl:[...Di,"ArrowLeft"]},Xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Es="Menu",[ro,Zy,eb]=mu(Es),[Hn,ku]=wn(Es,[eb,Pr,yu]),ha=Pr(),Cu=yu(),[fj,Gn]=Hn(Es),[hj,vo]=Hn(Es),tb="MenuAnchor",ma=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ha(n);return s.jsx(xs,{...o,...r,ref:t})});ma.displayName=tb;var ga="MenuPortal",[nb,ju]=Hn(ga,{forceMount:void 0}),Eu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Gn(ga,t);return s.jsx(nb,{scope:t,forceMount:n,children:s.jsx(wt,{present:n||i.open,children:s.jsx(yo,{asChild:!0,container:o,children:r})})})};Eu.displayName=ga;var vt="MenuContent",[rb,ya]=Hn(vt),Tu=p.forwardRef((e,t)=>{const n=ju(vt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Gn(vt,e.__scopeMenu),c=vo(vt,e.__scopeMenu);return s.jsx(ro.Provider,{scope:e.__scopeMenu,children:s.jsx(wt,{present:r||i.open,children:s.jsx(ro.Slot,{scope:e.__scopeMenu,children:c.modal?s.jsx(ob,{...o,ref:t}):s.jsx(sb,{...o,ref:t})})})})}),ob=p.forwardRef((e,t)=>{const n=Gn(vt,e.__scopeMenu),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const i=r.current;if(i)return da(i)},[]),s.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:de(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),sb=p.forwardRef((e,t)=>{const n=Gn(vt,e.__scopeMenu);return s.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ib=Er("MenuContent.ScrollLock"),ba=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:c,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:m,disableOutsideScroll:S,...v}=e,b=Gn(vt,n),w=vo(vt,n),j=ha(n),C=Cu(n),x=Zy(n),[E,P]=p.useState(null),A=p.useRef(null),g=Oe(t,A,b.onContentChange),I=p.useRef(0),T=p.useRef(""),O=p.useRef(0),_=p.useRef(null),M=p.useRef("right"),q=p.useRef(0),G=S?Cs:p.Fragment,J=S?{as:ib,allowPinchZoom:!0}:void 0,H=$=>{var ce,ke;const X=T.current+$,W=x().filter(xe=>!xe.disabled),te=document.activeElement,F=(ce=W.find(xe=>xe.ref.current===te))==null?void 0:ce.textValue,K=W.map(xe=>xe.textValue),oe=bb(K,X,F),ee=(ke=W.find(xe=>xe.textValue===oe))==null?void 0:ke.ref.current;(function xe(De){T.current=De,window.clearTimeout(I.current),De!==""&&(I.current=window.setTimeout(()=>xe(""),1e3))})(X),ee&&setTimeout(()=>ee.focus())};p.useEffect(()=>()=>window.clearTimeout(I.current),[]),la();const L=p.useCallback($=>{var W,te;return M.current===((W=_.current)==null?void 0:W.side)&&vb($,(te=_.current)==null?void 0:te.area)},[]);return s.jsx(rb,{scope:n,searchRef:T,onItemEnter:p.useCallback($=>{L($)&&$.preventDefault()},[L]),onItemLeave:p.useCallback($=>{var X;L($)||((X=A.current)==null||X.focus(),P(null))},[L]),onTriggerLeave:p.useCallback($=>{L($)&&$.preventDefault()},[L]),pointerGraceTimerRef:O,onPointerGraceIntentChange:p.useCallback($=>{_.current=$},[]),children:s.jsx(G,{...J,children:s.jsx(ws,{asChild:!0,trapped:o,onMountAutoFocus:de(i,$=>{var X;$.preventDefault(),(X=A.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:s.jsx(mo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:m,children:s.jsx(Hy,{asChild:!0,...C,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:P,onEntryFocus:de(l,$=>{w.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(oa,{role:"menu","aria-orientation":"vertical","data-state":Uu(b.open),"data-radix-menu-content":"",dir:w.dir,...j,...v,ref:g,style:{outline:"none",...v.style},onKeyDown:de(v.onKeyDown,$=>{const W=$.target.closest("[data-radix-menu-content]")===$.currentTarget,te=$.ctrlKey||$.altKey||$.metaKey,F=$.key.length===1;W&&($.key==="Tab"&&$.preventDefault(),!te&&F&&H($.key));const K=A.current;if($.target!==K||!Jy.includes($.key))return;$.preventDefault();const ee=x().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);wu.includes($.key)&&ee.reverse(),gb(ee)}),onBlur:de(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(I.current),T.current="")}),onPointerMove:de(e.onPointerMove,oo($=>{const X=$.target,W=q.current!==$.clientX;if($.currentTarget.contains(X)&&W){const te=$.clientX>q.current?"right":"left";M.current=te,q.current=$.clientX}}))})})})})})})});Tu.displayName=vt;var ab="MenuGroup",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Te.div,{role:"group",...r,ref:t})});xa.displayName=ab;var cb="MenuLabel",Au=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Te.div,{...r,ref:t})});Au.displayName=cb;var is="MenuItem",$c="menu.itemSelect",Ts=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=p.useRef(null),c=vo(is,e.__scopeMenu),a=ya(is,e.__scopeMenu),l=Oe(t,i),u=p.useRef(!1),h=()=>{const d=i.current;if(!n&&d){const f=new CustomEvent($c,{bubbles:!0,cancelable:!0});d.addEventListener($c,m=>r==null?void 0:r(m),{once:!0}),fd(d,f),f.defaultPrevented?u.current=!1:c.onClose()}};return s.jsx(Ru,{...o,ref:l,disabled:n,onClick:de(e.onClick,h),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),u.current=!0},onPointerUp:de(e.onPointerUp,d=>{var f;u.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:de(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||Di.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Ts.displayName=is;var Ru=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,c=ya(is,n),a=Cu(n),l=p.useRef(null),u=Oe(t,l),[h,d]=p.useState(!1),[f,m]=p.useState("");return p.useEffect(()=>{const S=l.current;S&&m((S.textContent??"").trim())},[i.children]),s.jsx(ro.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:s.jsx(Gy,{asChild:!0,...a,focusable:!r,children:s.jsx(Te.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:u,onPointerMove:de(e.onPointerMove,oo(S=>{r?c.onItemLeave(S):(c.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:de(e.onPointerLeave,oo(S=>c.onItemLeave(S))),onFocus:de(e.onFocus,()=>d(!0)),onBlur:de(e.onBlur,()=>d(!1))})})})}),lb="MenuCheckboxItem",Ou=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx($u,{scope:e.__scopeMenu,checked:n,children:s.jsx(Ts,{role:"menuitemcheckbox","aria-checked":as(n)?"mixed":n,...o,ref:t,"data-state":Sa(n),onSelect:de(o.onSelect,()=>r==null?void 0:r(as(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ou.displayName=lb;var _u="MenuRadioGroup",[db,ub]=Hn(_u,{value:void 0,onValueChange:()=>{}}),Pu=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=gn(r);return s.jsx(db,{scope:e.__scopeMenu,value:n,onValueChange:i,children:s.jsx(xa,{...o,ref:t})})});Pu.displayName=_u;var Iu="MenuRadioItem",Du=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=ub(Iu,e.__scopeMenu),i=n===o.value;return s.jsx($u,{scope:e.__scopeMenu,checked:i,children:s.jsx(Ts,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":Sa(i),onSelect:de(r.onSelect,()=>{var c;return(c=o.onValueChange)==null?void 0:c.call(o,n)},{checkForDefaultPrevented:!1})})})});Du.displayName=Iu;var va="MenuItemIndicator",[$u,pb]=Hn(va,{checked:!1}),Mu=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=pb(va,n);return s.jsx(wt,{present:r||as(i.checked)||i.checked===!0,children:s.jsx(Te.span,{...o,ref:t,"data-state":Sa(i.checked)})})});Mu.displayName=va;var fb="MenuSeparator",Lu=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Te.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Lu.displayName=fb;var hb="MenuArrow",Nu=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ha(n);return s.jsx(sa,{...o,...r,ref:t})});Nu.displayName=hb;var mb="MenuSub",[mj,Bu]=Hn(mb),Ur="MenuSubTrigger",Fu=p.forwardRef((e,t)=>{const n=Gn(Ur,e.__scopeMenu),r=vo(Ur,e.__scopeMenu),o=Bu(Ur,e.__scopeMenu),i=ya(Ur,e.__scopeMenu),c=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=i,u={__scopeMenu:e.__scopeMenu},h=p.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return p.useEffect(()=>h,[h]),p.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),s.jsx(ma,{asChild:!0,...u,children:s.jsx(Ru,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Uu(n.open),...e,ref:hs(t,o.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:de(e.onPointerMove,oo(d=>{i.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(i.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:de(e.onPointerLeave,oo(d=>{var m,S;h();const f=(m=n.content)==null?void 0:m.getBoundingClientRect();if(f){const v=(S=n.content)==null?void 0:S.dataset.side,b=v==="right",w=b?-5:5,j=f[b?"left":"right"],C=f[b?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+w,y:d.clientY},{x:j,y:f.top},{x:C,y:f.top},{x:C,y:f.bottom},{x:j,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:de(e.onKeyDown,d=>{var m;const f=i.searchRef.current!=="";e.disabled||f&&d.key===" "||Yy[r.dir].includes(d.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),d.preventDefault())})})})});Fu.displayName=Ur;var zu="MenuSubContent",qu=p.forwardRef((e,t)=>{const n=ju(vt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Gn(vt,e.__scopeMenu),c=vo(vt,e.__scopeMenu),a=Bu(zu,e.__scopeMenu),l=p.useRef(null),u=Oe(t,l);return s.jsx(ro.Provider,{scope:e.__scopeMenu,children:s.jsx(wt,{present:r||i.open,children:s.jsx(ro.Slot,{scope:e.__scopeMenu,children:s.jsx(ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var d;c.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:de(e.onFocusOutside,h=>{h.target!==a.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:de(e.onEscapeKeyDown,h=>{c.onClose(),h.preventDefault()}),onKeyDown:de(e.onKeyDown,h=>{var m;const d=h.currentTarget.contains(h.target),f=Xy[c.dir].includes(h.key);d&&f&&(i.onOpenChange(!1),(m=a.trigger)==null||m.focus(),h.preventDefault())})})})})})});qu.displayName=zu;function Uu(e){return e?"open":"closed"}function as(e){return e==="indeterminate"}function Sa(e){return as(e)?"indeterminate":e?"checked":"unchecked"}function gb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function yb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bb(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let c=yb(e,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==n));const l=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function xb(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,c=t.length-1;i<t.length;c=i++){const a=t[i],l=t[c],u=a.x,h=a.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-u)*(r-h)/(f-h)+u&&(o=!o)}return o}function vb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return xb(n,t)}function oo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Sb=ma,wb=Eu,kb=Tu,Cb=xa,jb=Au,Eb=Ts,Tb=Ou,Ab=Pu,Rb=Du,Ob=Mu,_b=Lu,Pb=Nu,Ib=Fu,Db=qu,Wu="DropdownMenu",[$b]=wn(Wu,[ku]),dt=ku(),[gj,Ku]=$b(Wu),Vu="DropdownMenuTrigger",Mb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=Ku(Vu,n),c=dt(n);return s.jsx(Sb,{asChild:!0,...c,children:s.jsx(Te.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:hs(t,i.triggerRef),onPointerDown:de(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(i.onOpenToggle(),i.open||a.preventDefault())}),onKeyDown:de(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&i.onOpenToggle(),a.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Mb.displayName=Vu;var Lb="DropdownMenuPortal",Hu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=dt(t);return s.jsx(wb,{...r,...n})};Hu.displayName=Lb;var Gu="DropdownMenuContent",Qu=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ku(Gu,n),i=dt(n),c=p.useRef(!1);return s.jsx(kb,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{var l;c.current||(l=o.triggerRef.current)==null||l.focus(),c.current=!1,a.preventDefault()}),onInteractOutside:de(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,h=l.button===2||u;(!o.modal||h)&&(c.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)"}})});Qu.displayName=Gu;var Nb="DropdownMenuGroup",Bb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Cb,{...o,...r,ref:t})});Bb.displayName=Nb;var Fb="DropdownMenuLabel",Ju=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(jb,{...o,...r,ref:t})});Ju.displayName=Fb;var zb="DropdownMenuItem",Yu=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Eb,{...o,...r,ref:t})});Yu.displayName=zb;var qb="DropdownMenuCheckboxItem",Ub=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Tb,{...o,...r,ref:t})});Ub.displayName=qb;var Wb="DropdownMenuRadioGroup",Kb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Ab,{...o,...r,ref:t})});Kb.displayName=Wb;var Vb="DropdownMenuRadioItem",Hb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Rb,{...o,...r,ref:t})});Hb.displayName=Vb;var Gb="DropdownMenuItemIndicator",Qb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Ob,{...o,...r,ref:t})});Qb.displayName=Gb;var Jb="DropdownMenuSeparator",Xu=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(_b,{...o,...r,ref:t})});Xu.displayName=Jb;var Yb="DropdownMenuArrow",Xb=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Pb,{...o,...r,ref:t})});Xb.displayName=Yb;var Zb="DropdownMenuSubTrigger",ex=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Ib,{...o,...r,ref:t})});ex.displayName=Zb;var tx="DropdownMenuSubContent",nx=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=dt(n);return s.jsx(Db,{...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)"}})});nx.displayName=tx;var rx=Hu,ox=Qu,sx=Ju,ix=Yu,ax=Xu;const cx=p.forwardRef(({container:e,style:t,sideOffset:n=4,...r},o)=>s.jsx(rx,{container:e,children:s.jsx(ox,{ref:o,sideOffset:n,style:{minWidth:180,background:pe("surfaceElevated"),color:pe("textPrimary"),border:`1px solid ${pe("borderDefault")}`,borderRadius:Sn.md,boxShadow:pe("shadowMd"),padding:be[1],zIndex:eo.popover,...t},...r})}));cx.displayName="DropdownMenuContent";const lx=p.forwardRef(({style:e,...t},n)=>s.jsx(ix,{ref:n,style:{display:"flex",alignItems:"center",gap:be[2],padding:`${be[1]} ${be[2]}`,fontSize:Ze.sm,borderRadius:Sn.sm,cursor:"default",outline:"none",userSelect:"none",...e},...t}));lx.displayName="DropdownMenuItem";const dx=p.forwardRef(({style:e,...t},n)=>s.jsx(ax,{ref:n,style:{height:1,background:pe("borderSubtle"),margin:`${be[1]} 0`,...e},...t}));dx.displayName="DropdownMenuSeparator";const ux=p.forwardRef(({style:e,...t},n)=>s.jsx(sx,{ref:n,style:{padding:`${be[1]} ${be[2]}`,fontSize:Ze.xs,color:pe("textMuted"),textTransform:"uppercase",letterSpacing:"0.04em",...e},...t}));ux.displayName="DropdownMenuLabel";var Zu="Popover",[ep]=wn(Zu,[Pr]),As=Pr(),[yj,kn]=ep(Zu),tp="PopoverAnchor",px=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kn(tp,n),i=As(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:a}=o;return p.useEffect(()=>(c(),()=>a()),[c,a]),s.jsx(xs,{...i,...r,ref:t})});px.displayName=tp;var np="PopoverTrigger",fx=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kn(np,n),i=As(n),c=Oe(t,o.triggerRef),a=s.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ap(o.open),...r,ref:c,onClick:de(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:s.jsx(xs,{asChild:!0,...i,children:a})});fx.displayName=np;var wa="PopoverPortal",[hx,mx]=ep(wa,{forceMount:void 0}),rp=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=kn(wa,t);return s.jsx(hx,{scope:t,forceMount:n,children:s.jsx(wt,{present:n||i.open,children:s.jsx(yo,{asChild:!0,container:o,children:r})})})};rp.displayName=wa;var Rr="PopoverContent",op=p.forwardRef((e,t)=>{const n=mx(Rr,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=kn(Rr,e.__scopePopover);return s.jsx(wt,{present:r||i.open,children:i.modal?s.jsx(yx,{...o,ref:t}):s.jsx(bx,{...o,ref:t})})});op.displayName=Rr;var gx=Er("PopoverContent.RemoveScroll"),yx=p.forwardRef((e,t)=>{const n=kn(Rr,e.__scopePopover),r=p.useRef(null),o=Oe(t,r),i=p.useRef(!1);return p.useEffect(()=>{const c=r.current;if(c)return da(c)},[]),s.jsx(Cs,{as:gx,allowPinchZoom:!0,children:s.jsx(sp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,c=>{var a;c.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,c=>{const a=c.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:de(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),bx=p.forwardRef((e,t)=>{const n=kn(Rr,e.__scopePopover),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(sp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var c,a;(c=e.onCloseAutoFocus)==null||c.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 l,u;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),sp=p.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:h,...d}=e,f=kn(Rr,n),m=As(n);return la(),s.jsx(ws,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(mo,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:h,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:s.jsx(oa,{"data-state":ap(f.open),role:"dialog",id:f.contentId,...m,...d,ref:t,style:{...d.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)"}})})})}),ip="PopoverClose",xx=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kn(ip,n);return s.jsx(Te.button,{type:"button",...r,ref:t,onClick:de(e.onClick,()=>o.onOpenChange(!1))})});xx.displayName=ip;var vx="PopoverArrow",Sx=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=As(n);return s.jsx(sa,{...o,...r,ref:t})});Sx.displayName=vx;function ap(e){return e?"open":"closed"}var wx=rp,kx=op;const Cx=p.forwardRef(({container:e,style:t,sideOffset:n=6,...r},o)=>s.jsx(wx,{container:e,children:s.jsx(kx,{ref:o,sideOffset:n,style:{background:pe("surfaceElevated"),color:pe("textPrimary"),border:`1px solid ${pe("borderDefault")}`,borderRadius:Sn.md,boxShadow:pe("shadowMd"),padding:be[3],zIndex:eo.popover,minWidth:220,...t},...r})}));Cx.displayName="PopoverContent";function ka({icon:e,eyebrow:t,title:n,subtitle:r,status:o,actions:i,toolbar:c,bodyPadding:a=14,children:l}){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})]}),c&&s.jsx("div",{className:"panel-frame-toolbar",children:c}),s.jsx("div",{className:"panel-frame-body",style:{padding:a},children:l})]})}function cp({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 Jr({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 lp({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 jx({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 ${be[1]}px`,borderRadius:Sn.sm,border:`1px solid ${pe("borderSubtle")}`,background:pe("surfaceRaised"),color:pe("textSecondary"),fontFamily:"var(--dql-font-mono, monospace)",fontSize:Ze.xs,fontWeight:Gi.medium,lineHeight:1,whiteSpace:"nowrap",...n},children:e??t})}const Mc=e=>{let t;const n=new Set,r=(u,h)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const f=t;t=h??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,f))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(r,o,a);return a},Ex=(e=>e?Mc(e):Mc),Tx=e=>e;function Ax(e,t=Tx){const n=qe.useSyncExternalStore(e.subscribe,qe.useCallback(()=>t(e.getState()),[e,t]),qe.useCallback(()=>t(e.getInitialState()),[e,t]));return qe.useDebugValue(n),n}const Lc=e=>{const t=Ex(e),n=r=>Ax(t,r);return Object.assign(n,t),n},Rx=(e=>e?Lc(e):Lc),Nc=e=>Symbol.iterator in e,Bc=e=>"entries"in e,Fc=(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},Ox=(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 _x(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:Nc(e)&&Nc(t)?Bc(e)&&Bc(t)?Fc(e,t):Ox(e,t):Fc({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Ir(e){const t=qe.useRef(void 0);return n=>{const r=e(n);return _x(t.current,r)?t.current:t.current=r}}const Px=/\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g;function Ca(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(Px)){const i=o[1],c=n.get(i);c&&c!==e.id&&r.set(c,{cellId:c,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 Ix(e){const t=e.filter(u=>!["markdown","param","chat"].includes(u.type)),n=new Set(t.map(u=>u.id)),r=new Set(e.map(u=>u.id)),o=new Map(t.map(u=>[u.id,0])),i=new Map(t.map(u=>[u.id,[]])),c=[];for(const u of t)for(const h of Ca(u,e)){if(!r.has(h.cellId)){c.push({cellId:u.id,dependency:h.cellId});continue}n.has(h.cellId)&&(i.get(h.cellId).push(u.id),o.set(u.id,(o.get(u.id)??0)+1))}const a=t.filter(u=>o.get(u.id)===0),l=[];for(;a.length>0;){const u=a.shift();l.push(u);for(const h of i.get(u.id)??[]){const d=(o.get(h)??0)-1;if(o.set(h,d),d===0){const f=t.find(m=>m.id===h);f&&a.push(f)}}}return{ordered:l,cycleCellIds:t.filter(u=>!l.some(h=>h.id===u.id)).map(u=>u.id),missing:c}}function Dx(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||Ca(i,t).some(c=>c.cellId===o)&&(n.add(i.id),r.push(i.id))}return n}function $x(){var e;if(typeof window<"u")try{(e=window.localStorage)==null||e.removeItem("dql-app-mode")}catch{}return"studio"}function Mx(){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 Lx(){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 Nx={mainView:Lx(),agentLogRun:void 0,settingsTab:"overview",themeMode:Mx(),appMode:$x(),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,blockStudioLastRun:null,blockStudioValidation:null,blockStudioMetadata:null,blockStudioCatalog:null,blockStudioCatalogLoading:!1,blockStudioImportOpen:!1,blockStudioDbtStatus:null,setupOpen:!1,inspectorOpen:!1,inspectorContext:null,apps:[],appsLoading:!1,activeAppId:null,activeAppDraftId:null,activeDashboardId:null,activeAppExperience:"view",activeAppSection:"dashboards",activePersona:null,globalAi:{open:!1,audience:"stakeholder",context:{}}};function $i(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=bt();while(t.has(r));return t.add(r),r===n.id?n:{...n,id:r}})}function Bx(e,t){var n,r,o,i,c,a,l,u,h;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,...t.view==="notebook"&&((n=e.activeFile)==null?void 0:n.type)==="block"?{activeFile:null,cells:[],notebookTitle:"",notebookMetadata:{},notebookDirty:!1,dashboardMode:!1}:{},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 d=t.mode==="dark"||t.mode==="midnight"?"obsidian":t.mode==="light"?"paper":t.mode==="arctic"?"white":t.mode;document.documentElement.setAttribute("data-theme",d);try{(r=window.localStorage)==null||r.setItem("dql-theme",t.mode)}catch{}}return{...e,themeMode:t.mode}}case"SET_APP_MODE":{if(typeof window<"u")try{(o=window.localStorage)==null||o.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 d=["connection","git","apps","readiness","skills","domains","settings"],f=t.panel!==null&&d.includes(t.panel),m=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"||((i=e.activeFile)==null?void 0:i.type)==="block"?"block_studio":"notebook";return{...e,sidebarPanel:t.panel,sidebarOpen:t.panel!==null&&!f,...m==="notebook"&&((c=e.activeFile)==null?void 0:c.type)==="block"?{activeFile:null,cells:[],notebookTitle:"",notebookMetadata:{},notebookDirty:!1,dashboardMode:!1}:{},lineageFullscreen:!1,lineageFocusNodeId:null,lineageReturnTarget:null,mainView:m}}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,blockStudioLastRun: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:$i(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,blockStudioLastRun:t.file.type==="block"?e.blockStudioLastRun: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,blockStudioLastRun:t.payload.lastRun??null,blockStudioValidation:t.payload.validation,blockStudioMetadata:t.payload.metadata,blockStudioImportOpen:!1,lineageFullscreen:!1,lineageFocusNodeId:(a=t.payload.metadata)!=null&&a.name?`block:${t.payload.metadata.name}`:null};case"BLOCK_CERTIFICATION_ACCEPTED":return{...e,blockStudioDraft:t.source,blockStudioDirty:!1,blockStudioPreview:null,blockStudioLastRun:null,blockStudioMetadata:e.blockStudioMetadata?{...e.blockStudioMetadata,reviewStatus:"draft"}:null};case"RECONCILE_BLOCK_CERTIFICATION":{const d=t.newPath??t.payload.path,f={name:`${t.payload.metadata.name}.dql`,path:d,type:"block",folder:"blocks",isNew:!1},m=t.outcome==="certified"?new Set([t.draftPath,t.oldPath].filter(j=>j!==d&&j.includes("/_drafts/"))):new Set,S=e.files.filter(j=>!m.has(j.path)),v=S.findIndex(j=>j.path===d),b=v>=0?S.map((j,C)=>C===v?{...j,...f}:j):[...S,f];return e.mainView==="block_studio"&&!e.blockStudioDirty&&(!e.activeBlockPath||[t.oldPath,t.draftPath,d].includes(e.activeBlockPath))?{...e,files:b,activeFile:f,activeBlockPath:d,notebookTitle:t.payload.metadata.name,blockStudioDraft:t.payload.source,blockStudioDirty:!1,blockStudioPreview:null,blockStudioLastRun:t.payload.lastRun??null,blockStudioValidation:t.payload.validation,blockStudioMetadata:t.payload.metadata,lineageFocusNodeId:`block:${t.payload.metadata.name}`}:{...e,files:b}}case"SET_CELLS":return{...e,cells:$i(t.cells),notebookDirty:!0};case"UPDATE_NOTEBOOK_METADATA":{const d=e.notebookMetadata;let f=!1;for(const m of Object.keys(t.updates))if(d[m]!==t.updates[m]){f=!0;break}return f?{...e,notebookMetadata:{...d,...t.updates},notebookDirty:!0}:e}case"ADD_CELL":{const d=e.cells.some(S=>S.id===t.cell.id)?{...t.cell,id:bt()}:t.cell;if(!t.afterId)return{...e,cells:[...e.cells,d],notebookDirty:!0};const f=e.cells.findIndex(S=>S.id===t.afterId);if(f===-1)return{...e,cells:[...e.cells,d],notebookDirty:!0};const m=[...e.cells];return m.splice(f+1,0,d),{...e,cells:m,notebookDirty:!0}}case"UPDATE_CELL":{const d=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=d?Dx(t.id,e.cells):new Set,m=e.cells.map(v=>{if(v.id===t.id){const b={...v,...t.updates};return d&&v.result&&t.updates.stale===void 0?{...b,stale:!0}:b}return f.has(v.id)&&v.result?{...v,stale:!0}:v}),S=t.updates.executionCount!==void 0?e.executionCounter+1:e.executionCounter;return{...e,cells:m,notebookDirty:!0,executionCounter:S}}case"DELETE_CELL":return{...e,cells:e.cells.filter(d=>d.id!==t.id),notebookDirty:!0};case"MOVE_CELL":{const d=e.cells.findIndex(m=>m.id===t.id);if(d===-1)return e;const f=[...e.cells];return t.direction==="up"&&d>0?[f[d-1],f[d]]=[f[d],f[d-1]]:t.direction==="down"&&d<f.length-1&&([f[d],f[d+1]]=[f[d+1],f[d]]),{...e,cells:f,notebookDirty:!0}}case"REORDER_CELL":{const{fromIndex:d,toIndex:f}=t;if(d===f||d<0||f<0||d>=e.cells.length||f>=e.cells.length)return e;const m=[...e.cells],[S]=m.splice(d,1);return m.splice(f,0,S),{...e,cells:m,notebookDirty:!0}}case"SET_SCHEMA":return{...e,schemaTables:t.tables};case"MERGE_SCHEMA_TABLES":{const d=new Map(e.schemaTables.map(f=>[f.path.toLowerCase(),f]));for(const f of t.tables){const m=f.path.toLowerCase(),S=d.get(m);d.set(m,S?{...S,...f,columns:f.columns.length>0?f.columns:S.columns,expanded:S.expanded}:f)}return{...e,schemaTables:Array.from(d.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(d=>d.name===t.tableName?{...d,expanded:!d.expanded}:d)};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,blockStudioLastRun: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(d=>d.path===t.file.path)?e:{...e,files:[...e.files,t.file]};case"FILE_REMOVED":{const d=e.files.filter(f=>f.path!==t.path);return((l=e.activeFile)==null?void 0:l.path)!==t.path?{...e,files:d}:{...e,files:d,activeFile:null,cells:[],notebookTitle:"",notebookMetadata:{},notebookDirty:!1}}case"SET_TABLE_COLUMNS":return{...e,schemaTables:e.schemaTables.map(d=>d.name===t.tableName?{...d,columns:t.columns}:d)};case"SET_PARAM_VALUE":return{...e,cells:e.cells.map(d=>d.id===t.id?{...d,paramValue:t.value}:d),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 d=[t.name,...e.semanticLayer.recentlyUsed.filter(f=>f!==t.name)].slice(0,12);return{...e,semanticLayer:{...e.semanticLayer,recentlyUsed:d}}}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 d=t.returnTo!==void 0?t.returnTo:e.mainView==="lineage_detail"?e.lineageReturnTarget:null;return{...e,mainView:"lineage_detail",lineageFullscreen:!1,lineageFocusNodeId:t.nodeId,lineageReturnTarget:d,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,blockStudioLastRun:t.preview?{rowCount:t.preview.result.rowCount??t.preview.result.rows.length,executionTime:t.preview.result.executionTime,columns:t.preview.result.columns,ranAt:new Date().toISOString()}:e.blockStudioLastRun};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 d=e.apps.find(S=>S.id===t.appId)??null,f=t.dashboardId!==void 0?t.dashboardId:((u=d==null?void 0:d.homepage)==null?void 0:u.type)==="dashboard"?d.homepage.id:((h=d==null?void 0:d.dashboards[0])==null?void 0:h.id)??null,m=e.activeAppId===t.appId;return{...e,mainView:"apps",activeAppId:t.appId,activeAppDraftId:null,activeDashboardId:f,activeAppExperience:t.experience??(m?e.activeAppExperience:"view"),activeAppSection:t.section??(m?e.activeAppSection:"dashboards"),lineageReturnTarget:null}}case"OPEN_APP_DRAFT":return{...e,mainView:"apps",activeAppId:t.appId??null,activeAppDraftId:t.draftId,activeDashboardId:t.dashboardId??null,activeAppExperience:"build",activeAppSection:"dashboards",lineageReturnTarget:null};case"CLOSE_APP":return{...e,activeAppId:null,activeAppDraftId:null,activeDashboardId:null,activeAppExperience:"view",activeAppSection:"dashboards"};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 Ge=Rx((e,t)=>({...Nx,dispatch:n=>{const r=Bx(t(),n);e(r)}})),Pn=Ge,Fx=p.createContext(null);function zx({children:e}){return qe.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")&&Ge.getState().dispatch({type:"SET_THEME",mode:r})};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]),s.jsx(s.Fragment,{children:e})}function et(){const e=Ge(Ir(r=>{const{dispatch:o,...i}=r;return i})),t=Ge(r=>r.dispatch);return p.useContext(Fx)??{state:e,dispatch:t}}function Cn(){return Ge(e=>e.dispatch)}function bt(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function ja(e,t=""){const n={id:bt(),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 qx="modulepreload",Ux=function(e){return"/"+e},zc={},_e=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(h=>Promise.resolve(h).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));o=c(n.map(u=>{if(u=Ux(u),u in zc)return;zc[u]=!0;const h=u.endsWith(".css"),d=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const f=document.createElement("link");if(f.rel=h?"stylesheet":qx,h||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),h)return new Promise((m,S)=>{f.addEventListener("load",m),f.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(c){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=c,window.dispatchEvent(a),!a.defaultPrevented)throw c}return o.then(c=>{for(const a of c||[])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 dp=(...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 Wx=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 Kx=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 qc=e=>{const t=Kx(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 Vx={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 Hx=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 Gx=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:c,...a},l)=>p.createElement("svg",{ref:l,...Vx,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:dp("lucide",o),...!i&&!Hx(a)&&{"aria-hidden":"true"},...a},[...c.map(([u,h])=>p.createElement(u,h)),...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 ne=(e,t)=>{const n=p.forwardRef(({className:r,...o},i)=>p.createElement(Gx,{ref:i,iconNode:t,className:dp(`lucide-${Wx(qc(e))}`,`lucide-${e}`,r),...o}));return n.displayName=qc(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 Qx=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Jx=ne("arrow-down",Qx);/**
|
|
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 Yx=[["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"}]],Xx=ne("arrow-right-left",Yx);/**
|
|
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 Zx=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ev=ne("arrow-up",Zx);/**
|
|
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 tv=[["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"}]],Ea=ne("blocks",tv);/**
|
|
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 nv=[["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"}]],rv=ne("bookmark",nv);/**
|
|
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 ov=[["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"}]],sv=ne("box",ov);/**
|
|
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 iv=[["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"}]],Mi=ne("boxes",iv);/**
|
|
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 av=[["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"}]],cv=ne("briefcase",av);/**
|
|
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 lv=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],dv=ne("check",lv);/**
|
|
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 uv=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ta=ne("chevron-down",uv);/**
|
|
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 pv=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rs=ne("chevron-right",pv);/**
|
|
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 fv=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],hv=ne("chevrons-left",fv);/**
|
|
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 mv=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],gv=ne("chevrons-right",mv);/**
|
|
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 yv=[["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"}]],bv=ne("circle-alert",yv);/**
|
|
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 xv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],up=ne("circle-check",xv);/**
|
|
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 vv=[["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"}]],Sv=ne("circle-question-mark",vv);/**
|
|
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 wv=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],kv=ne("clock",wv);/**
|
|
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 Cv=[["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"}]],jv=ne("command",Cv);/**
|
|
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 Ev=[["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"}]],So=ne("database",Ev);/**
|
|
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 Tv=[["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"}]],pp=ne("download",Tv);/**
|
|
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 Av=[["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"}]],Rv=ne("eye-off",Av);/**
|
|
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 Ov=[["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"}]],_v=ne("eye",Ov);/**
|
|
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 Pv=[["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"}]],Iv=ne("file-check",Pv);/**
|
|
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 Dv=[["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"}]],$v=ne("file-pen",Dv);/**
|
|
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 Mv=[["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"}]],fp=ne("file-plus",Mv);/**
|
|
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 Lv=[["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"}]],Nv=ne("file-question-mark",Lv);/**
|
|
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 Bv=[["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"}]],Aa=ne("file-text",Bv);/**
|
|
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 Fv=[["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"}]],zv=ne("file-x",Fv);/**
|
|
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 qv=[["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"}]],Uv=ne("files",qv);/**
|
|
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 Wv=[["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"}]],hp=ne("folder-open",Wv);/**
|
|
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 Kv=[["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"}]],Yr=ne("folder",Kv);/**
|
|
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 Vv=[["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"}]],Hv=ne("funnel",Vv);/**
|
|
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 Gv=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Qv=ne("gauge",Gv);/**
|
|
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 Jv=[["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"}]],Dr=ne("git-branch",Jv);/**
|
|
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 Yv=[["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"}]],Xv=ne("git-commit-horizontal",Yv);/**
|
|
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 Zv=[["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"}]],eS=ne("git-fork",Zv);/**
|
|
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 tS=[["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"}]],mp=ne("layers",tS);/**
|
|
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 nS=[["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"}]],rS=ne("layout-dashboard",nS);/**
|
|
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 oS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],qn=ne("loader-circle",oS);/**
|
|
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 sS=[["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"}]],iS=ne("message-circle",sS);/**
|
|
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 aS=[["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"}]],cS=ne("monitor",aS);/**
|
|
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 lS=[["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"}]],dS=ne("network",lS);/**
|
|
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 uS=[["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"}]],pS=ne("notebook-pen",uS);/**
|
|
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 fS=[["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"}]],hS=ne("package",fS);/**
|
|
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 mS=[["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"}]],gS=ne("palette",mS);/**
|
|
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 yS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],bS=ne("panel-left",yS);/**
|
|
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 xS=[["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"}]],vS=ne("plug",xS);/**
|
|
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 SS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],wS=ne("plus",SS);/**
|
|
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 kS=[["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"}]],cs=ne("refresh-cw",kS);/**
|
|
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 CS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Uc=ne("search",CS);/**
|
|
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 jS=[["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"}]],ES=ne("settings-2",jS);/**
|
|
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 TS=[["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"}]],AS=ne("settings",TS);/**
|
|
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 RS=[["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"}]],OS=ne("shield-alert",RS);/**
|
|
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 _S=[["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"}]],PS=ne("shield-check",_S);/**
|
|
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 IS=[["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"}]],DS=ne("sigma",IS);/**
|
|
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 $S=[["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"}]],gp=ne("sparkles",$S);/**
|
|
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 MS=[["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"}]],LS=ne("square-dashed",MS);/**
|
|
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 NS=[["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"}]],BS=ne("tag",NS);/**
|
|
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 FS=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],zS=ne("terminal",FS);/**
|
|
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 qS=[["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"}]],yp=ne("trash-2",qS);function US(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 WS(e,t){const n=e.mode??"both";return n==="both"||n===t}function KS({open:e,onClose:t}){const{state:n,dispatch:r}=et(),[o,i]=p.useState(""),[c,a]=p.useState(0),l=p.useRef(null);p.useEffect(()=>{e&&(i(""),a(0))},[e]);const u=p.useMemo(()=>{const m=x=>r(x),S=()=>t(),v=x=>()=>{x(),S()},b=[["Files","files",Uv],["Lineage","lineage",eS],["Git","git",Dr],["Block Library","block_library",Ea],["Apps","apps",dS],["Connections","connection",vS]],w=[{mode:"obsidian",label:"Obsidian"},{mode:"paper",label:"Paper"},{mode:"white",label:"White"}],j=[];j.push({id:"sidebar.toggle",label:n.sidebarOpen?"Hide sidebar":"Show sidebar",group:"View",icon:bS,shortcut:"⌘B",mode:"studio",run:v(()=>m({type:"TOGGLE_SIDEBAR"}))},{id:"inspector.toggle",label:n.inspectorOpen?"Hide inspector":"Show inspector",group:"View",icon:n.inspectorOpen?Rv:_v,shortcut:"⌘⇧I",mode:"studio",run:v(()=>m({type:"TOGGLE_INSPECTOR"}))},{id:"dashboard.toggle",label:n.dashboardMode?"Exit dashboard mode":"Enter dashboard mode",group:"View",icon:rS,shortcut:"⌘D",run:v(()=>m({type:"TOGGLE_DASHBOARD_MODE"}))},{id:"dev.toggle",label:"Toggle dev panel",group:"View",icon:zS,shortcut:"⌘J",mode:"studio",run:v(()=>m({type:"TOGGLE_DEV_PANEL"}))});for(const[x,E,P]of b)j.push({id:`panel.${E}`,label:`Go to ${x}`,group:"Navigate",icon:P,mode:"studio",run:v(()=>{m({type:"SET_SIDEBAR_PANEL",panel:E}),E!=="lineage"&&!n.sidebarOpen&&m({type:"TOGGLE_SIDEBAR"})})});j.push({id:"notebook.new",label:"New notebook…",group:"Create",icon:fp,mode:"studio",run:v(()=>m({type:"OPEN_NEW_NOTEBOOK_MODAL"}))},{id:"block.new",label:"New block…",group:"Create",icon:LS,mode:"studio",run:v(()=>m({type:"OPEN_NEW_BLOCK_MODAL"}))});const C=n.themeMode==="dark"||n.themeMode==="midnight"?"obsidian":n.themeMode==="light"?"paper":n.themeMode==="arctic"?"white":n.themeMode;for(const x of w)x.mode!==C&&j.push({id:`theme.${x.mode}`,label:`Switch to ${x.label}`,group:"Theme",icon:gS,keywords:"appearance color",run:v(()=>m({type:"SET_THEME",mode:x.mode}))});return j},[n.sidebarOpen,n.inspectorOpen,n.themeMode,n.dashboardMode,n.appMode,n.sidebarPanel,r,t]),h=p.useMemo(()=>{const S=u.filter(v=>WS(v,n.appMode)).map(v=>({a:v,s:US(v,o)})).filter(v=>v.s>0);return S.sort((v,b)=>b.s-v.s),S.map(v=>v.a)},[u,o,n.appMode]);p.useEffect(()=>{a(0)},[o]),p.useEffect(()=>{var S;const m=(S=l.current)==null?void 0:S.querySelector(`[data-palette-idx="${c}"]`);m==null||m.scrollIntoView({block:"nearest"})},[c]);const d=m=>{var S;m.key==="ArrowDown"?(m.preventDefault(),a(v=>Math.min(h.length-1,v+1))):m.key==="ArrowUp"?(m.preventDefault(),a(v=>Math.max(0,v-1))):m.key==="Enter"&&(m.preventDefault(),(S=h[c])==null||S.run())};let f="";return s.jsx(Oy,{open:e,onOpenChange:m=>!m&&t(),children:s.jsxs(_y,{children:[s.jsx(Py,{style:{position:"fixed",inset:0,background:pe("surfaceOverlay"),zIndex:eo.overlay}}),s.jsxs(Iy,{"aria-label":"Command palette",style:{position:"fixed",top:"18vh",left:"50%",transform:"translateX(-50%)",width:"92vw",maxWidth:620,background:pe("surfaceRaised"),color:pe("textPrimary"),border:`1px solid ${pe("borderDefault")}`,borderRadius:Sn.lg,boxShadow:pe("shadowLg"),zIndex:eo.modal,display:"flex",flexDirection:"column",overflow:"hidden"},onKeyDown:d,children:[s.jsx(Dy,{style:{position:"absolute",left:-9999},children:"Command palette"}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:be[2],padding:`${be[3]}px ${be[4]}px`,borderBottom:`1px solid ${pe("borderSubtle")}`},children:[s.jsx(jv,{size:14,strokeWidth:1.75,color:pe("textMuted")}),s.jsx("input",{autoFocus:!0,value:o,onChange:m=>i(m.target.value),placeholder:"Type a command…",style:{flex:1,border:"none",outline:"none",background:"transparent",color:pe("textPrimary"),fontSize:Ze.md}})]}),s.jsxs("div",{ref:l,style:{maxHeight:360,overflowY:"auto",padding:`${be[1]}px 0`},children:[h.length===0&&s.jsx("div",{style:{padding:be[4],fontSize:Ze.sm,color:pe("textMuted"),textAlign:"center"},children:"No matching commands"}),h.map((m,S)=>{const v=m.group!==f;f=m.group;const b=S===c,w=m.icon;return s.jsxs(qe.Fragment,{children:[v&&s.jsx("div",{style:{padding:`${be[2]}px ${be[4]}px ${be[1]}px`},children:s.jsx(cp,{tone:"neutral",children:m.group})}),s.jsxs("div",{"data-palette-idx":S,role:"option","aria-selected":b,onMouseEnter:()=>a(S),onMouseDown:j=>{j.preventDefault(),m.run()},style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:be[3],padding:`${be[2]}px ${be[4]}px`,fontSize:Ze.sm,cursor:"pointer",background:b?pe("surfaceHover"):"transparent",color:pe("textPrimary")},children:[s.jsxs("span",{style:{display:"flex",alignItems:"center",gap:be[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:m.label})]}),m.shortcut&&s.jsx(jx,{shortcut:m.shortcut})]})]},m.id)})]})]})]})})}function Li(e){const t=Xt(e);if(!t)return;const n=QS(t.kind),r=VS(t.source);if(!n||!r)return;const o=iw(t.limit);return{kind:n,source:r,name:St(t.name),sourcePath:St(t.sourcePath),metrics:Ni(t.metrics),dimensions:Ni(t.dimensions),filters:JS(t.filters),timeDimension:YS(t.timeDimension),orderBy:XS(t.orderBy),parameters:ZS(t.parameters),parameterValues:rw(t.parameterValues),persistence:ow(t.persistence),trustState:sw(t.trustState),compiledSql:St(t.compiledSql),executionReceipt:GS(t.executionReceipt),filterableColumns:HS(t.filterableColumns),...o===void 0?{}:{limit:o}}}function VS(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function HS(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Xt(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 GS(e){const t=Xt(e);if(!t)return;const n=Bo(t.sourceFingerprint),r=Bo(t.compiledSqlFingerprint),o=Bo(t.parameterFingerprint),i=Bo(t.resultFingerprint);return n&&r&&o&&i?{sourceFingerprint:n,compiledSqlFingerprint:r,parameterFingerprint:o,resultFingerprint:i}:void 0}function Bo(e){return typeof e=="string"&&/^[a-f0-9]{64}$/i.test(e.trim())?e.trim().toLowerCase():void 0}function QS(e){return e==="certified_block"||e==="semantic_block"||e==="sql_block"?e:void 0}function JS(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Xt(n);if(!r)return[];const o=St(r.dimension),i=St(r.operator);return!o||!i?[]:[{dimension:o,operator:i,values:Ni(r.values)??[]}]});return t.length?t:void 0}function YS(e){const t=Xt(e);if(!t)return;const n=St(t.name),r=St(t.granularity);return n&&r?{name:n,granularity:r}:void 0}function XS(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Xt(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 ZS(e){if(!Array.isArray(e))return;const t=new Set,n=e.flatMap(r=>{const o=Xt(r),i=St(o==null?void 0:o.name),c=ew(o==null?void 0:o.type),a=tw(o==null?void 0:o.policy);if(!o||!i||!c||!a||t.has(i))return[];t.add(i);const l=nw(o.binding);return[{name:i,type:c,required:o.required===!0,...o.default===void 0?{}:{default:o.default},policy:a,...l?{binding:l}:{}}]});return n.length?n:void 0}function ew(e){return e==="string"||e==="number"||e==="boolean"||e==="date"||e==="string[]"||e==="number[]"||e==="date[]"?e:void 0}function tw(e){return e==="dynamic"||e==="static"||e==="business"||e==="derived"||e==="optional"||e==="ambiguous_review_required"?e:void 0}function nw(e){const t=Xt(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 rw(e){const t=Xt(e);if(!t)return;const n=Object.entries(t).filter(([r])=>r.trim().length>0);return n.length?Object.fromEntries(n):void 0}function ow(e){return e==="transient"||e==="saved"?e:void 0}function sw(e){return e==="certified"||e==="governed"||e==="review_required"?e:void 0}function Xt(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 Ni(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 iw(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}const bp="dql_token",Wc="dql.server-token.v1";function aw(e){var r;return((r=new URLSearchParams(e.replace(/^#/,"")).get(bp))==null?void 0:r.trim())||void 0}function cw(e){const t=new URLSearchParams(e.replace(/^#/,""));t.delete(bp);const n=t.toString();return n?`#${n}`:""}function lw(){var e;if(!(typeof window>"u"))try{const t=aw(window.location.hash);if(t){window.sessionStorage.setItem(Wc,t);const n=cw(window.location.hash);return window.history.replaceState(window.history.state,"",`${window.location.pathname}${window.location.search}${n}`),t}return((e=window.sessionStorage.getItem(Wc))==null?void 0:e.trim())||void 0}catch{return}}const Kc=lw();function ir(e){const t=new Headers(e);return Kc&&t.set("Authorization",`Bearer ${Kc}`),t}async function xp(e,t,n){const r=await fetch(e,{headers:ir({Accept:"text/event-stream"}),credentials:"same-origin",cache:"no-store",signal:n});if(!r.ok)throw new Error(`Event stream failed with HTTP ${r.status}.`);if(!r.body)throw new Error("Event stream response did not include a body.");const o=r.body.getReader(),i=new TextDecoder;let c="",a="message",l=[];const u=()=>{l.length>0&&t({event:a,data:l.join(`
|
|
395
|
+
`)}),a="message",l=[]};for(;!n.aborted;){const h=await o.read();c+=i.decode(h.value,{stream:!h.done});const d=c.split(/\r?\n/);c=d.pop()??"";for(const f of d)if(f==="")u();else if(!f.startsWith(":")){const m=f.indexOf(":"),S=m<0?f:f.slice(0,m),v=m<0?"":f.slice(m+1).replace(/^ /,"");S==="event"&&(a=v||"message"),S==="data"&&l.push(v)}if(h.done){u();return}}}const dw={totals:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0},willGenerate:0,willSkip:0,domains:[],config:{businessLayers:[],excludeLayers:[],maxPerDomain:0,minScore:0,aiEnrichment:"auto"}};function Fo(){return{total:0,tracked:0,changed:0,untracked:0,ignored:0,paths:[]}}const Wr=window.location.origin;class xt extends Error{constructor(n){super(n.message);Pe(this,"status");Pe(this,"code");Pe(this,"recoverable");Pe(this,"details");Pe(this,"nextActions");Pe(this,"requestId");Pe(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 Bi(e,t){const n=t.trim()||e.statusText||`HTTP ${e.status}`;if(!t.trim())return new xt({message:n,status:e.status});try{const r=JSON.parse(t),o=Array.isArray(r==null?void 0:r.errors)?r.errors.filter(c=>typeof c=="string"&&c.trim().length>0):[],i=typeof(r==null?void 0:r.friendlyMessage)=="string"&&r.friendlyMessage.trim()?r.friendlyMessage: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:o.length>0?`${o.slice(0,3).join(" ")}${o.length>3?` ${o.length-3} more blockers.`:""}`:n;return new xt({message:i,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)??(typeof(r==null?void 0:r.error)=="string"&&r.error.trim()&&r.error!==i?{technicalDetails:r.error}:o.length>0?{errors:o,draft:r==null?void 0:r.draft}:void 0),nextActions:Array.isArray(r==null?void 0:r.nextActions)?r.nextActions.filter(c=>typeof c=="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 xt({message:n,status:e.status})}}const Vs=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=Vs.get(e);if(o)return o;const i=Vc(e,t).finally(()=>{Vs.delete(e)});return Vs.set(e,i),i}return Vc(e,t)}async function Vc(e,t){var r;let n;try{const o=ir(t==null?void 0:t.headers);o.has("Content-Type")||o.set("Content-Type","application/json"),n=await fetch(`${Wr}${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 Bi(n,o)}if(n.status!==204)return n.json()}async function uw(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 c=a=>{const l=a.split(/\r?\n/);let u="message";const h=[];for(const f of l)f.startsWith("event:")&&(u=f.slice(6).trim()),f.startsWith("data:")&&h.push(f.slice(5).trimStart());if(h.length===0)return;const d=JSON.parse(h.join(`
|
|
396
|
+
`));if(u==="agent-run-event")t({kind:"event",event:d});else if(u==="agent-run-answer-delta"){const f=typeof(d==null?void 0:d.delta)=="string"?d.delta:"";f&&t({kind:"answer-delta",delta:f})}else if(u==="agent-run-complete")i=d,t({kind:"complete",run:i});else if(u==="agent-run-error")throw new Error(typeof(d==null?void 0:d.error)=="string"?d.error:"Agent run failed.")};for(;;){const{value:a,done:l}=await n.read();if(a){o+=r.decode(a,{stream:!l});let u=o.search(/\r?\n\r?\n/);for(;u>=0;){const h=o.slice(0,u);o=o.slice(o[u]==="\r"?u+4:u+2),c(h),u=o.search(/\r?\n\r?\n/)}}if(l)break}if(o.trim()&&c(o),!i)throw new Error("Agent run stream ended before completion.");return i}function sn(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 Wt(e){var n;const t=e!=null&&e.resultPreview&&typeof e.resultPreview=="object"?sn(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:Li(e==null?void 0:e.dqlArtifact),dqlPromotionAction:Sw((e==null?void 0:e.dqlPromotionAction)??((n=e==null?void 0:e.dqlPromotion)==null?void 0:n.recommendedAction)),dqlPromotion:vp(e==null?void 0:e.dqlPromotion),researchPlan:pw(e==null?void 0:e.researchPlan),reviewChecklist:xw(e==null?void 0:e.reviewChecklist,e),...t?{resultPreview:t}:{resultPreview:void 0}}}function pw(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",c=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",l=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:fw(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:Ce(n.evidenceCount),relationCount:Ce(n.relationCount),missingContextCount:Ce(n.missingContextCount)},preview:{status:c,...l===void 0?{}:{rowCount:l}},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 fw(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 Ce(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function nr(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function hw(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{totalReviewCount:Ce(t.totalReviewCount),openReviewCount:Ce(t.openReviewCount),terminalReviewCount:Ce(t.terminalReviewCount),draftCreatedCount:Ce(t.draftCreatedCount),certifiedCount:Ce(t.certifiedCount),completedCount:Ce(t.completedCount),rejectedCount:Ce(t.rejectedCount),draftCreationRate:nr(t.draftCreationRate),certifyConversionRate:nr(t.certifyConversionRate),medianOpenReviewAgeMs:nr(t.medianOpenReviewAgeMs),medianTimeToDraftMs:nr(t.medianTimeToDraftMs),medianTimeToCertificationMs:nr(t.medianTimeToCertificationMs),medianTimeToTerminalMs:nr(t.medianTimeToTerminalMs)}}function mw(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:{},c=t.limits&&typeof t.limits=="object"?t.limits:{};return{counts:{totalRuns:Ce(n.totalRuns),activeRuns:Ce(n.activeRuns),closedRuns:Ce(n.closedRuns),notebooks:Ce(n.notebooks),domains:Ce(n.domains),owners:Ce(n.owners),sourceLinkedRuns:Ce(n.sourceLinkedRuns)},health:{staleOpenRuns:Ce(r.staleOpenRuns),expiredOpenRuns:Ce(r.expiredOpenRuns),staleThresholdDays:Ce(r.staleThresholdDays)||7,expiredThresholdDays:Ce(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:Ce(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:Ce(c.pageSize)||25,maxPageSize:Ce(c.maxPageSize)||500,sourceCoverageLimit:Ce(c.sourceCoverageLimit)||1e4,seedCellLimit:Ce(c.seedCellLimit)||1e3},warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[]}}function gw(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 yw(e){const t=typeof e=="string"?e:"";return(t.split(/[\\/]/).pop()??t).replace(/\.dqlnb$/i,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim()||"Untitled notebook"}function bw(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 zo(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 xw(e,t){var u,h;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(d=>typeof d=="string"):[],warnings:Array.isArray(e.warnings)?e.warnings.filter(d=>typeof d=="string"):[],items:e.items.map(d=>({id:typeof d.id=="string"?d.id:"item",label:typeof d.label=="string"?d.label:"Review item",status:d.status==="passed"||d.status==="pending"||d.status==="warning"||d.status==="blocked"?d.status:"pending",detail:typeof d.detail=="string"?d.detail:""}))};const n=!!t.reviewedSql,r=n||!!t.generatedSql,o=((u=t.resultPreview)==null?void 0:u.rowCount)??((h=t.resultPreview)==null?void 0:h.rows.length)??0,i=!!(t.resultPreview&&(t.resultPreview.columns.length>0||o>0)),c=!!t.draftBlockPath,a=!!(t.contextPackId||t.evidence),l=t.dqlPromotionAction==="reuse_existing";return{readyForDqlDraft:!!(!l&&t.question&&n&&a&&t.status!=="error"),readyForCertificationReview:!!(!l&&t.question&&n&&a&&i&&c),blockers:t.status==="error"?[t.error??"Preview failed."]:[],warnings:i||l?[]:["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||l?"passed":"blocked",detail:l&&!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||l?"passed":"warning",detail:a?"Context evidence is saved.":l?"Reuse evidence is captured in the recommendation.":"Preview and save metadata context."},{id:"preview",label:"Preview",status:i||l?"passed":"pending",detail:i?"Preview result is available.":l?"Certified block reuse does not require a new raw SQL preview.":"Run a bounded preview."},{id:"dql_draft",label:"DQL draft",status:c||l?"passed":"pending",detail:c?`Draft saved at ${t.draftBlockPath}.`:l?"No new DQL draft is required.":"Create a DQL draft after review."}]}}function vw(e){var r,o,i,c;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((c=t.counts)==null?void 0:c.warnings)=="number"?t.counts.warnings:0}}}function Sw(e){return e==="reuse_existing"||e==="extend_existing"||e==="create_replacement"||e==="create_new"||e==="review_required"?e:void 0}function vp(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:""}}function Hc(e){return{id:e.sourceId,sourceId:e.sourceId,qualifiedIdentity:e.qualifiedIdentity,sourceRevision:e.sourceRevision,snapshotId:e.snapshotId,lifecycle:e.lifecycle,trust:e.trust,name:e.name,domain:e.domain??"Unassigned",status:e.lifecycle,owner:e.owner??null,tags:e.tags,path:e.executionRef,fingerprint:e.sourceRevision,lastModified:"",description:e.description??"",chartType:e.capabilities.chartType,filterIds:e.capabilities.filters,dimensionIds:e.capabilities.dimensions,capabilities:e.capabilities,eligibility:e.eligibility,score:e.score??0,reasons:e.reasons}}const B={async listOperations(e=50){return k(`/api/operations?limit=${Math.max(1,Math.min(100,Math.floor(e)))}`)},async cancelOperation(e){return k(`/api/operations/${encodeURIComponent(e)}`,{method:"DELETE"})},async requestBlockStudioCertification(e){return k("/api/block-studio/certifications",{method:"POST",headers:{"Idempotency-Key":e.idempotencyKey},body:JSON.stringify({source:e.source,path:e.path,metadata:e.metadata,expectedSourceFingerprint:e.expectedSourceFingerprint,clientRevision:e.clientRevision})})},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 createContextProposal(e){return(await k("/api/context-proposals",{method:"POST",body:JSON.stringify(e)})).proposal},async getContextProposal(e){return(await k(`/api/context-proposals/${encodeURIComponent(e)}`)).proposal},async repreviewContextProposal(e,t,n){return(await k(`/api/context-proposals/${encodeURIComponent(e)}/repreview`,{method:"POST",body:JSON.stringify({selectedOperationIds:t,rebase:(n==null?void 0:n.rebase)===!0})})).proposal},async commitContextProposal(e,t,n){return k(`/api/context-proposals/${encodeURIComponent(e)}/commit`,{method:"POST",body:JSON.stringify({expectedProposalHash:t,idempotencyKey:n})})},async createModelingImport(e){return(await k("/api/modeling/dbt-first/imports",{method:"POST",body:JSON.stringify({source:e})})).session},async previewModelingImport(e,t){return k(`/api/modeling/dbt-first/imports/${encodeURIComponent(e)}/preview`,{method:"POST",body:JSON.stringify(t)})},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:dw,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(`${Wr}/api/agent-runs?stream=1`,{method:"POST",headers:ir({"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 Bi(r,o)}return uw(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,c,a,l,u;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:((c=e.blockBinding)==null?void 0:c.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 xt({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:sn(r.result),executionTarget:((l=r==null?void 0:r.executionTarget)==null?void 0:l.target)==="local"?{target:"local"}:((u=r==null?void 0:r.executionTarget)==null?void 0:u.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,n){return k("/api/block-studio/validate",{method:"POST",body:JSON.stringify({source:e,path:t}),signal:n})},async runBlockStudio(e,t,n){return k("/api/block-studio/run",{method:"POST",body:JSON.stringify({source:e,path:t,parameters:n})})},async repairAndRunBlockStudio(e,t,n={},r){const o=await k("/api/block-studio/repair-and-run",{method:"POST",body:JSON.stringify({cell:{id:"block-studio-draft",type:"dql",source:e,title:r||"Block Studio draft"},error:t,attemptedSql:e,parameters:n})}),i=String(o.repairedSql??"");return{source:String(o.source??e),repairedSql:i,repairMode:o.repairMode==="ai"?"ai":"deterministic",preview:{sql:i,result:sn(o.result)}}},async getCertifiedBlockParameters(e){return k(`/api/blocks/parameters?name=${encodeURIComponent(e)}`)},async invokeCertifiedBlock(e,t,n){var o,i,c,a,l,u;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:{...sn(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((c=r==null?void 0:r.result)==null?void 0:c.blockPath)=="string"?{blockPath:r.result.blockPath}:{},...(a=r==null?void 0:r.result)!=null&&a.chartConfig?{chartConfig:r.result.chartConfig}:{},...Array.isArray((l=r==null?void 0:r.result)==null?void 0:l.parameters)?{parameters:r.result.parameters}:{},...typeof((u=r==null?void 0:r.result)==null?void 0:u.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})}),c=Li(i==null?void 0:i.artifact);if(!c)throw new Error("Adding the filter input returned an invalid artifact contract.");return{artifact:c,parameterName:String((i==null?void 0:i.parameterName)??n)}},async invokeDqlArtifact(e,t,n,r,o){var a,l,u,h,d,f;const i=await k("/api/dql/artifacts/execute",{method:"POST",body:JSON.stringify({artifact:e,parameters:t,question:n,blockName:r,executionTarget:o})}),c=Li(i==null?void 0:i.artifact);if(!c)throw new Error("DQL artifact execution returned an invalid artifact contract.");return{artifact:c,parameters:c.parameters??[],result:{...sn(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((l=i==null?void 0:i.result)==null?void 0:l.blockName)=="string"?{blockName:i.result.blockName}:{},...typeof((u=i==null?void 0:i.result)==null?void 0:u.blockPath)=="string"?{blockPath:i.result.blockPath}:{},...(h=i==null?void 0:i.result)!=null&&h.chartConfig?{chartConfig:i.result.chartConfig}:{},...Array.isArray((d=i==null?void 0:i.result)==null?void 0:d.parameters)?{parameters:i.result.parameters}:{},...typeof((f=i==null?void 0:i.result)==null?void 0:f.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 assessBlockStudioCertification(e){return k("/api/block-studio/certification-check",{method:"POST",body:JSON.stringify({source:e})})},async certifyBlockStudio(e){const t=await fetch(`${Wr}/api/block-studio/certify`,{headers:ir({"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,c,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 xt({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{...sn(o),executionTarget:((c=o==null?void 0:o.executionTarget)==null?void 0:c.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:sn(n.result)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async executeNotebookCell(e,t,n){var o,i,c,a,l,u;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 xt({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((c=r==null?void 0:r.executionContext)==null?void 0:c.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?sn(r.result):null,executionTarget:((l=r==null?void 0:r.executionTarget)==null?void 0:l.target)==="local"?{target:"local"}:((u=r==null?void 0:r.executionTarget)==null?void 0:u.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(`${Wr}/api/datasets/import`,{method:"POST",headers:ir(),body:t});if(!n.ok){const r=await n.text().catch(()=>"");throw Bi(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,c,a,l,u,h,d,f,m,S,v,b,w,j,C,x,E,P,A;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(Wt),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:zo(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:zo(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:gw(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:zo(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:yw(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:zo(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((c=r.counts)==null?void 0:c.needsReview)=="number"?r.counts.needsReview:0,dqlDrafts:typeof((a=r.counts)==null?void 0:a.dqlDrafts)=="number"?r.counts.dqlDrafts:0,errors:typeof((l=r.counts)==null?void 0:l.errors)=="number"?r.counts.errors:0,reuseExisting:typeof((u=r.counts)==null?void 0:u.reuseExisting)=="number"?r.counts.reuseExisting:0,extendExisting:typeof((h=r.counts)==null?void 0:h.extendExisting)=="number"?r.counts.extendExisting:0,replacements:typeof((d=r.counts)==null?void 0:d.replacements)=="number"?r.counts.replacements:0,createNew:typeof((f=r.counts)==null?void 0:f.createNew)=="number"?r.counts.createNew:0,draftReady:typeof((m=r.counts)==null?void 0:m.draftReady)=="number"?r.counts.draftReady:0,certificationReady:typeof((S=r.counts)==null?void 0:S.certificationReady)=="number"?r.counts.certificationReady:0,blocked:typeof((v=r.counts)==null?void 0:v.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((j=r.counts)==null?void 0:j.sourceLinked)=="number"?r.counts.sourceLinked:0,nextActions:bw((C=r.counts)==null?void 0:C.nextActions)},groupCounts:{domains:typeof((x=r.groupCounts)==null?void 0:x.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((E=r.groupCounts)==null?void 0:E.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((P=r.groupCounts)==null?void 0:P.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((A=r.groupCounts)==null?void 0:A.notebooks)=="number"&&Number.isFinite(r.groupCounts.notebooks)?Math.max(0,Math.floor(r.groupCounts.notebooks)):Array.isArray(r.notebooks)?r.notebooks.length:0},reviewMetrics:hw(r.reviewMetrics),limit:r.limit,offset:typeof r.offset=="number"?r.offset:0}},async getNotebookResearchDiagnostics(){const e=await k("/api/notebook/research/diagnostics");return mw(e)},async createNotebookResearch(e){const t=await k("/api/notebook/research",{method:"POST",body:JSON.stringify(e)});return Wt(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(Wt):[],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(Wt):[],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 vw(t)},async getNotebookResearch(e){const t=await k(`/api/notebook/research/${encodeURIComponent(e)}`);return Wt(t.run)},async updateNotebookResearch(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)});return Wt(n.run)},async runNotebookResearch(e,t){const n=await k(`/api/notebook/research/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t??{})});return Wt(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:Wt(n.run),promotion:vp(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:Wt(n.run)}},async getSchema(){try{const e=await fetch(`${Wr}/api/schema`,{headers:ir()});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 xt?{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:Fo(),skills:Fo(),artifacts:Fo(),learning:Fo()}}},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,t){const{blocks:n}=await k("/api/apps/recommend-blocks",{method:"POST",body:JSON.stringify(e),signal:t});return n},async listAppSourceCandidates(e,t={},n){var i;const r=new URLSearchParams;(i=t.query)!=null&&i.trim()&&r.set("q",t.query.trim()),t.cursor&&r.set("cursor",t.cursor),r.set("limit",String(t.limit??50));for(const c of t.lifecycles??[])r.append("lifecycle",c);for(const c of t.domains??[])r.append("domain",c);t.includeDeprecated&&r.set("includeDeprecated","true");const o=await k(`/api/app-builds/${encodeURIComponent(e)}/source-candidates?${r.toString()}`,{signal:n});return{...o,items:o.items.map(Hc)}},async resolveAppSourceCandidates(e,t){const n=await k(`/api/app-builds/${encodeURIComponent(e)}/source-candidates`,{method:"POST",body:JSON.stringify({sourceIds:t})});return{...n,items:n.items.map(Hc)}},async createApp(e){return k("/api/apps",{method:"POST",body:JSON.stringify(e)})},async createAppBuild(e){return k("/api/app-builds",{method:"POST",body:JSON.stringify(e)})},async listAppBuilds(){return k("/api/app-builds")},async proposeAppBuildChanges(e,t){return k(`/api/app-builds/${encodeURIComponent(e)}/ai-proposals`,{method:"POST",body:JSON.stringify(t)})},async reviseAppBuildProposal(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}/ai-proposals/${encodeURIComponent(t)}/revisions`,{method:"POST",body:JSON.stringify(n)})},async generateAppBuildGap(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}/ai-proposals/${encodeURIComponent(t)}/gaps`,{method:"POST",body:JSON.stringify(n)})},async patchAppBuild(e,t,n,r){return k(`/api/app-builds/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({expectedRevision:t,expectedProposalHash:r,operations:n})})},async composeAppBuild(e,t){return k(`/api/app-builds/${encodeURIComponent(e)}/compose`,{method:"POST",body:JSON.stringify(t)})},async addAskResultToAppBuild(e,t){return k(`/api/app-builds/${encodeURIComponent(e)}/ask-results`,{method:"POST",body:JSON.stringify(t)})},async preflightAppBuild(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}/preflight`,{method:"POST",body:JSON.stringify({expectedRevision:t,proposalHash:n})})},async publishAppBuild(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}/publish-to-project`,{method:"POST",body:JSON.stringify({expectedRevision:t,proposalHash:n})})},async deleteAppBuild(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}`,{method:"DELETE",body:JSON.stringify({expectedRevision:t,proposalHash:n})})},async commitAppBuild(e,t,n){return this.publishAppBuild(e,t,n)},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 proposeAppAiBuildInBackground(e){return k("/api/apps/ai-builds/propose-background",{method:"POST",body:JSON.stringify(e)})},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 deleteApp(e,t){return k(`/api/apps/${encodeURIComponent(e)}`,{method:"DELETE",body:JSON.stringify({expectedFingerprint:t})})},async restoreApp(e){return k(`/api/app-recoveries/${encodeURIComponent(e)}/restore`,{method:"POST",body:"{}"})},async renameApp(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},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 publishAppToProject(e,t){try{return await k(`/api/apps/${encodeURIComponent(e)}/publish-to-project`,{method:"POST",body:JSON.stringify(t??{})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteApp(e,t){return B.publishAppToProject(e,t)},async approveAppSemanticTiles(e,t,n){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/approve-semantic`,{method:"POST",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},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 runAppBuildPreview(e,t,n){return k(`/api/app-builds/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({variables:n??{}})})},async retryDashboardTile(e,t,n,r){try{return await k(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({variables:r??{},tileId: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})})}},ww={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"},kw={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"},Sp={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"},bj={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"},xj={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"},Cw={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},Gc={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"},Qc=["source","transform","answer","consumption"],vj=["term","business_view","block","metric","dimension","domain","source_table","dbt_source","dbt_model","chart","notebook","dashboard","app"],Sj=["source_table","dbt_source","dbt_model"],jw=["term","domain","business_view","metric","dimension","block"];[...jw];function Ew(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 Tw(){const{state:e,dispatch:t}=et(),n=e.inspectorContext;return s.jsxs("aside",{"aria-label":"Inspector",style:{width:320,borderLeft:`1px solid ${pe("borderSubtle")}`,background:pe("surfaceBase"),color:pe("textPrimary"),display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${be[3]}px ${be[4]}px`,borderBottom:`1px solid ${pe("borderSubtle")}`},children:[s.jsx("div",{style:{fontSize:Ze.sm,fontWeight:Gi.semibold},children:n?Aw(n):"Inspector"}),s.jsx("button",{onClick:()=>t({type:"SET_INSPECTOR",open:!1}),"aria-label":"Close inspector",style:{background:"transparent",border:"none",color:pe("textMuted"),cursor:"pointer",fontSize:Ze.md,padding:2,borderRadius:Sn.sm},children:"×"})]}),s.jsx("div",{style:{flex:1,overflow:"auto",padding:be[4]},children:n?s.jsx(Rw,{context:n}):s.jsx(Iw,{})})]})}function Aw(e){switch(e.kind){case"cell":return"Cell";case"lineage-node":return"Lineage node";case"metric":return"Metric"}}function Rw({context:e}){return e.kind==="cell"?s.jsx(Ow,{cellId:e.cellId}):e.kind==="lineage-node"?s.jsx(_w,{nodeId:e.nodeId}):s.jsx(Pw,{name:e.name})}function Ow({cellId:e}){const{state:t}=et(),n=t.cells.find(r=>r.id===e);return n?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:be[3],fontSize:Ze.sm},children:[s.jsx(Ie,{label:"Type",children:n.type}),s.jsx(Ie,{label:"ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:n.id})}),s.jsxs(Ie,{label:"Length",children:[n.content.length," chars"]}),n.status&&s.jsx(Ie,{label:"Status",children:n.status})]}):s.jsx(ls,{children:"No matching cell in the active notebook."})}function _w({nodeId:e}){const[t,n]=p.useState(null),[r,o]=p.useState(!0);if(p.useEffect(()=>{let a=!1;return o(!0),B.fetchLineageNode(e).then(l=>{a||(n(l),o(!1))}).catch(()=>{a||o(!1)}),()=>{a=!0}},[e]),r)return s.jsx(ls,{children:"Loading node…"});if(!t||!t.node)return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:be[3]},children:[s.jsx(Ie,{label:"Node ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:e})}),s.jsx(ls,{children:"No metadata available for this node."})]});const i=t.node,c=i.metadata??{};return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:be[3]},children:[s.jsx(Ie,{label:"Name",children:i.name??e}),s.jsx(Ie,{label:"Type",children:Sp[i.type]??i.type}),i.domain&&s.jsx(Ie,{label:"Domain",children:i.domain}),i.owner&&s.jsx(Ie,{label:"Owner",children:i.owner}),i.status&&s.jsx(Ie,{label:"Status",children:i.status}),typeof c.termType=="string"&&s.jsx(Ie,{label:"Term Type",children:c.termType}),typeof c.description=="string"&&s.jsx(Ie,{label:"Description",children:c.description}),Array.isArray(c.identifiers)&&c.identifiers.length>0&&s.jsx(Ie,{label:"Identifiers",children:c.identifiers.map(String).join(", ")}),Array.isArray(c.synonyms)&&c.synonyms.length>0&&s.jsx(Ie,{label:"Synonyms",children:c.synonyms.map(String).join(", ")}),typeof c.businessOutcome=="string"&&s.jsx(Ie,{label:"Business Outcome",children:c.businessOutcome}),i.layer&&s.jsx(Ie,{label:"Layer",children:i.layer}),s.jsx(Ie,{label:"Upstream",children:t.incoming.length}),s.jsx(Ie,{label:"Downstream",children:t.outgoing.length}),(i.path||c.filePath)&&s.jsx(Ie,{label:"Path",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)",fontSize:Ze.xs},children:i.path??c.filePath})})]})}function Pw({name:e}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:be[3]},children:[s.jsx(Ie,{label:"Metric",children:e}),s.jsx(ls,{children:"Definition, dimensions, and governance surface will render here."})]})}function Ie({label:e,children:t}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[s.jsx("div",{style:{fontSize:Ze.xs,color:pe("textMuted"),textTransform:"uppercase",letterSpacing:.5,fontWeight:Gi.medium},children:e}),s.jsx("div",{style:{fontSize:Ze.sm,color:pe("textPrimary")},children:t})]})}function ls({children:e}){return s.jsx("div",{style:{fontSize:Ze.sm,color:pe("textSecondary"),lineHeight:1.5,background:pe("surfaceSunken"),border:`1px solid ${pe("borderSubtle")}`,borderRadius:Sn.md,padding:be[3]},children:e})}function Iw(){return s.jsx("div",{style:{fontSize:Ze.sm,color:pe("textMuted"),lineHeight:1.5},children:"Select a cell, lineage node, or metric to inspect its details here."})}const Kr={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"},Jc={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 Yc(e){if(typeof document>"u")return Jc[e];const t=Kr[e];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||Jc[e]}function Dw(){return new Proxy({},{get(e,t){if(typeof t=="string"&&t in Kr)return Yc(t)},has(e,t){return typeof t=="string"&&t in Kr},ownKeys(){return Object.keys(Kr)},getOwnPropertyDescriptor(e,t){if(!(typeof t!="string"||!(t in Kr)))return{enumerable:!0,configurable:!0,value:Yc(t)}}})}const Rn=Dw(),Qe={obsidian:Rn,paper:Rn,white:Rn,dark:Rn,light:Rn,midnight:Rn,arctic:Rn};function kt(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 $w=kt(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"})]}));kt(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 Mw=kt(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"})]})),wj=kt(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"})]}));kt(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h8a8 8 0 010 16H4z"}),s.jsx("path",{d:"M16 20l4 4"})]}));kt(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 3v18h18"}),s.jsx("path",{d:"M7 15l4-4 4 4 5-7"})]}));kt(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"})]}));kt(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 kj=kt(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}),s.jsx("circle",{cx:"18",cy:"17",r:"2"})]}));kt(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 5h18l-7 9v5l-4-2v-3L3 5z"})}));kt(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"})]}));kt(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 wp=44,kp=188,Cp="dql-activitybar-expanded";function Lw(){var e;if(typeof window>"u")return!1;try{return((e=window.localStorage)==null?void 0:e.getItem(Cp))==="1"}catch{return!1}}function Nw(e){var t;try{(t=window.localStorage)==null||t.setItem(Cp,e?"1":"0")}catch{}}function Xc({title:e,icon:t,active:n,expanded:r,onClick:o,t:i}){const[c,a]=p.useState(!1),l=s.jsxs("button",{"aria-label":e,onClick:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:r?kp-12:wp-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":c?i.textPrimary+"0f":"transparent",border:"none",borderRadius:6,cursor:"pointer",color:n?i.accent:c?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?l:s.jsx(Vd,{content:e,side:"right",children:l})}function Bw(){const e=Ge(Ir(l=>({mainView:l.mainView,sidebarOpen:l.sidebarOpen,sidebarPanel:l.sidebarPanel,themeMode:l.themeMode}))),t=Cn(),n=Qe[e.themeMode],[r,o]=p.useState(Lw);p.useEffect(()=>{Nw(r)},[r]);function i(l){if(l==="home"||l==="ask"||l==="modeling"){t({type:"SET_MAIN_VIEW",view:l});return}if(l==="lineage"){t({type:"SET_SIDEBAR_PANEL",panel:"lineage"});return}if(l==="connection"||l==="git"||l==="apps"||l==="readiness"||l==="skills"||l==="domains"||l==="settings"){t({type:"SET_SIDEBAR_PANEL",panel:l});return}e.sidebarPanel===l&&e.sidebarOpen?t({type:"TOGGLE_SIDEBAR"}):t({type:"SET_SIDEBAR_PANEL",panel:l})}const c=[{label:"Insights",items:[{key:"apps",title:"Apps",icon:s.jsx(hS,{size:16,strokeWidth:1.75}),active:e.mainView==="apps"},{key:"ask",title:"Ask",icon:s.jsx(iS,{size:16,strokeWidth:1.75}),active:e.mainView==="ask"}]},{label:"Build",items:[{key:"files",title:"Notebooks",icon:s.jsx(Aa,{size:16,strokeWidth:1.75}),active:e.sidebarPanel==="files"&&e.sidebarOpen},{key:"block_library",title:"Blocks",icon:s.jsx($w,{size:16}),active:e.sidebarPanel==="block_library"&&e.sidebarOpen},{key:"lineage",title:"Lineage",icon:s.jsx(Mw,{size:16}),active:e.mainView==="lineage"||e.mainView==="lineage_detail"}]},{label:"Govern",items:[{key:"domains",title:"Modeling",icon:s.jsx(Mi,{size:16,strokeWidth:1.75}),active:e.mainView==="domains"||e.mainView==="modeling"||e.mainView==="skills"},{key:"git",title:"Source control",icon:s.jsx(Dr,{size:16,strokeWidth:1.75}),active:e.mainView==="git"},{key:"settings",title:"Settings",icon:s.jsx(AS,{size:16,strokeWidth:1.75}),active:e.mainView==="settings"||e.mainView==="connection"}]}],a=[{key:"help",title:"Help",icon:s.jsx(Sv,{size:16,strokeWidth:1.75}),active:e.mainView==="help",onClick:()=>t({type:"SET_MAIN_VIEW",view:"help"})}];return s.jsxs("div",{style:{width:r?kp:wp,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(Vd,{content:r?"Collapse":"Expand",side:"right",children:s.jsx("button",{"aria-label":r?"Collapse sidebar rail":"Expand sidebar rail",onClick:()=>o(l=>!l),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:l=>{l.currentTarget.style.color=n.textPrimary,l.currentTarget.style.background=n.textPrimary+"0f"},onMouseLeave:l=>{l.currentTarget.style.color=n.textMuted,l.currentTarget.style.background="transparent"},children:r?s.jsx(hv,{size:14,strokeWidth:2}):s.jsx(gv,{size:14,strokeWidth:2})})})}),c.map((l,u)=>s.jsxs(qe.Fragment,{children:[u>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:l.label}):null,l.items.map(h=>s.jsx(Xc,{title:h.title,icon:h.icon,active:h.active,expanded:r,onClick:()=>i(h.key),t:n},h.key))]},l.label)),s.jsx("div",{style:{flex:1}}),a.map(l=>s.jsx(Xc,{title:l.title,icon:l.icon,active:l.active,expanded:r,onClick:l.onClick,t:n},l.key))]})}const Fw=2e4,Cj="application/dql-semantic-ref",Zc=new Map;let so=null;function zw(e){B.trackUsage(e),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:e}}))}async function el(e,t){const n=`${e}:${t.toLowerCase()}`,r=Zc.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 c=await i.json(),a=Array.isArray(c.completions)?c.completions:[];return Zc.set(n,{items:a,expiresAt:Date.now()+Fw}),a}function jp(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 jj(e){so=e}function Ej(e){so===e&&(so=null)}function qw(e){return so?(jp(so,e),!0):!1}function Tj(e,t,n){const r=n?e.posAtCoords(n)??e.state.selection.main.from:e.state.selection.main.from;jp(e,t,r)}function tl(e,t,n){return{label:e.name,detail:e.type==="metric"?"@metric":"@dim",type:e.type==="metric"?"function":"variable",info:`${e.label}${e.description?`
|
|
397
|
+
${e.description}`:""}${e.sql?`
|
|
398
|
+
${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}}),zw(e.name)}}}function Uw(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 Aj=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(),l=n-o[1].length,u=await el("metric",a);return{from:l,options:u.map(h=>tl(h,l,n)),validFor:/^[\w-]*$/}}const i=/@dim\(([^)]*)$/i.exec(r);if(i){const a=i[1].trim().toLowerCase(),l=n-i[1].length,u=await el("dimension",a);return{from:l,options:u.map(h=>tl(h,l,n)),validFor:/^[\w-]*$/}}const c=/@([md][a-z_]*)?$/i.exec(r);return c?Uw(n-c[0].length):(e.explicit,null)};function Rj(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 Ww=6,Kw=999,Vw={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 Re(e,t={}){const{variant:n="secondary",size:r="sm",active:o=!1,disabled:i=!1,pill:c=!1}=t,a=Vw[r],l=n==="danger"?e.error:n==="success"?e.success:n==="accent"?e.accent:void 0,u={boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:a.gap,height:a.height,padding:`0 ${a.paddingX}px`,borderRadius:c?Kw:Ww,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"?{...u,background:e.accent,border:`1px solid ${e.accent}`,color:"#ffffff"}:n==="ghost"?{...u,background:o?`${e.accent}14`:"transparent",border:"1px solid transparent",color:o?e.accent:e.textMuted,fontWeight:550}:l?{...u,background:o?`${l}22`:`${l}12`,border:`1px solid ${l}${o?"66":"33"}`,color:l}:{...u,background:o?`${e.accent}14`:e.btnBg,border:`1px solid ${o?e.accent:e.btnBorder}`,color:o?e.accent:e.textSecondary}}const Hw=new Set(["metric","measure","dimension","time_dimension"]);function Os(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 Fi(e){const t=Os(e);return e.kind==="metric"||e.kind==="measure"?`@metric(${t})`:`@dim(${t})`}function Ep(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():"")||Os(e)}function Ra(e,t){return!t||e.label.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||Os(e).toLowerCase().includes(t)||Ep(e).toLowerCase().includes(t)?!0:(e.children??[]).some(n=>Ra(n,t))}function Tp(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,c=i?`group:${o.label.toLowerCase()}`:`leaf:${Fi(o).toLowerCase()}`,a=n.get(c);if(a){i&&a.children&&(a.children=a.children.concat(o.children??[]));continue}const l=o.children?{...o,children:[...o.children]}:o;n.set(c,l),t.push(l)}for(const o of t)o.children&&(o.children=Tp(o.children));return t}const Hs={metric:{Icon:Qv,tone:e=>e.accent},measure:{Icon:DS,tone:e=>e.accent},dimension:{Icon:BS,tone:e=>e.success},time_dimension:{Icon:kv,tone:e=>e.warning},entity:{Icon:sv,tone:e=>e.textSecondary},segment:{Icon:Hv,tone:e=>e.textMuted},hierarchy:{Icon:Dr,tone:e=>e.textMuted},pre_aggregation:{Icon:mp,tone:e=>e.textMuted},cube:{Icon:Mi,tone:e=>e.textSecondary},semantic_model:{Icon:Mi,tone:e=>e.textSecondary},saved_query:{Icon:rv,tone:e=>e.textMuted},provider:{Icon:Yr,tone:e=>e.textMuted},domain:{Icon:Yr,tone:e=>e.textMuted},group:{Icon:Yr,tone:e=>e.textMuted}};function Gw(e){var t;if(e.kind==="group"){const n=typeof((t=e.meta)==null?void 0:t.objectKind)=="string"?e.meta.objectKind:"";return Hs[n]??Hs.group}return Hs[e.kind]}function Qw({tree:e,themeMode:t,search:n="",onInsert:r,selectionMode:o=!1,selected:i=new Set,onToggleSelection:c,canSelect:a=()=>({allowed:!0})}){const l=Qe[t],u=n.trim().toLowerCase(),h=Tp(e.children??[]).filter(d=>Ra(d,u));return h.length===0?s.jsx("div",{style:{padding:"16px 12px",fontSize:11.5,color:l.textMuted,textAlign:"center"},children:u?"No matches.":"No semantic objects."}):s.jsx(s.Fragment,{children:h.map(d=>s.jsx(Ap,{node:d,t:l,q:u,onInsert:r,depth:0,selectionMode:o,selected:i,onToggleSelection:c,canSelect:a},d.id))})}function Ap({node:e,t,q:n,onInsert:r,depth:o,selectionMode:i,selected:c,onToggleSelection:a,canSelect:l}){var A;const u=(((A=e.children)==null?void 0:A.length)??0)>0,[h,d]=p.useState(o<1||!!n);p.useEffect(()=>{n&&d(!0)},[n]);const f=Hw.has(e.kind),m=Gw(e),S=m==null?void 0:m.Icon,v=10+o*13,b=e.kind==="metric"||e.kind==="measure"?"metric":e.kind==="dimension"||e.kind==="time_dimension"?"dimension":null,w=Os(e),j=Ep(e),C=w!==j?` · DQL ${w}`:"",x=b?`${b}:${w}`:"",E=b?l(b,w):{allowed:!1};if(!u)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&&E.allowed?a==null||a(b,w):!i&&f&&r(Fi(e))},disabled:i&&!!b&&!E.allowed,title:i&&b?E.allowed?`Select ${e.label} · dbt ${j}${C}`:E.reason||"Not compatible with the current selection":f?`Insert ${Fi(e)} · dbt ${j}${C}`:e.label,style:{display:"flex",alignItems:"center",gap:7,flex:1,minWidth:0,boxSizing:"border-box",padding:`5px 6px 5px ${v+15}px`,border:"none",background:"transparent",cursor:i&&b?E.allowed?"pointer":"not-allowed":f?"pointer":"default",textAlign:"left",fontFamily:t.font,color:E.allowed||!b?t.textPrimary:t.textMuted,opacity:i&&b&&!E.allowed?.55:1},children:[i&&b&&s.jsx("input",{type:"checkbox",readOnly:!0,checked:c.has(x),disabled:!E.allowed,style:{accentColor:t.accent,margin:0,flexShrink:0}}),S&&s.jsx(S,{size:13,color:m.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}),j!==e.label?s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:9.5,fontFamily:t.fontMono,color:t.textMuted},children:j}):null]})]})});const P=(e.children??[]).filter(g=>Ra(g,n));return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>d(g=>!g),style:{display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,boxSizing:"border-box",padding:`6px 10px 6px ${v}px`,border:"none",borderBottom:`1px solid ${t.cellBorder}`,background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:t.font,color:t.textPrimary},children:[h?s.jsx(Ta,{size:13,color:t.textMuted,style:{flexShrink:0}}):s.jsx(Rs,{size:13,color:t.textMuted,style:{flexShrink:0}}),S&&s.jsx(S,{size:13,color:m.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??P.length})]}),h&&P.map(g=>s.jsx(Ap,{node:g,t,q:n,onInsert:r,depth:o+1,selectionMode:i,selected:c,onToggleSelection:a,canSelect:l},g.id))]})}function Ft(e){return(e==null?void 0:e.trim())??""}function Qn(e){const t=new Map;for(const r of e){const o=Ft(r.id);o&&!t.has(o)&&t.set(o,{...r,id:o})}const n=r=>{const o=[Ft(r.name)||r.id],i=new Set([r.id]);let c=Ft(r.parent);for(;c&&!i.has(c);){i.add(c);const a=t.get(c);if(!a)break;o.unshift(Ft(a.name)||a.id),c=Ft(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 Oj(e,t){const n=Qn(t),r=Ft(e??void 0);return!r||n.some(o=>o.value===r)?n:[{value:r,label:`${r} (missing Domain page)`,disabled:!0},...n]}function wo(e){return new Set(Qn(e).map(t=>t.value))}function _j(e,t){const n=Ft(e??void 0).toLowerCase();if(!n)return"";const r=t.find(o=>Ft(o.id).toLowerCase()===n||Ft(o.name).toLowerCase()===n);return Ft(r==null?void 0:r.id)}function Jw(e,t){const n=wo(t),r=e.some(o=>{var i;return!n.has(((i=o.domain)==null?void 0:i.trim())??"")});return[...Qn(t).map(o=>o.value),...r?["uncategorized"]:[]]}function Yw(e,t,n="",r=[]){const o=n.trim().toLowerCase(),i=wo(r);return Array.from(new Map(e.map(c=>[c.path,c])).values()).filter(c=>{var l;const a=((l=c.domain)==null?void 0:l.trim())??"";return t==="uncategorized"&&i.has(a)||t&&t!=="uncategorized"&&(!i.has(t)||a!==t)?!1:!o||c.name.toLowerCase().includes(o)||(c.description??"").toLowerCase().includes(o)})}var Q;(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"})(Q||(Q={}));var ar;(function(e){e.Error="error",e.Warning="warning",e.Info="info"})(ar||(ar={}));class Xw{constructor(){Pe(this,"diagnostics",[])}report(t){this.diagnostics.push(t)}error(t,n,r){this.report({severity:ar.Error,message:t,span:n,hint:r})}warning(t,n,r){this.report({severity:ar.Warning,message:t,span:n,hint:r})}hasErrors(){return this.diagnostics.some(t=>t.severity===ar.Error)}getErrors(){return this.diagnostics.filter(t=>t.severity===ar.Error)}getAll(){return[...this.diagnostics]}clear(){this.diagnostics=[]}format(t){return this.diagnostics.map(n=>Zw(n,t)).join(`
|
|
399
|
+
|
|
400
|
+
`)}}function Zw(e,t){const{severity:n,message:r,span:o,hint:i}=e,a=t.split(`
|
|
401
|
+
`)[o.start.line-1]??"",l=String(o.start.line),u=" ".repeat(l.length),h=o.start.file?`${o.start.file}:`:"";let d=`${n}: ${r}
|
|
402
|
+
`;d+=` --> ${h}${o.start.line}:${o.start.column}
|
|
403
|
+
`,d+=`${u} |
|
|
404
|
+
`,d+=`${l} | ${a}
|
|
405
|
+
`;const f=o.start.column-1,m=Math.max(1,o.start.line===o.end.line?o.end.column-o.start.column:a.length-f);return d+=`${u} | ${" ".repeat(f)}${"^".repeat(m)}`,i&&(d+=`
|
|
406
|
+
${u} = hint: ${i}`),d}class e0 extends Error{constructor(n,r){super(n);Pe(this,"diagnostics");this.diagnostics=r,this.name="DQLSyntaxError"}}var y;(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"})(y||(y={}));const t0={dashboard:y.DashboardKeyword,workbook:y.WorkbookKeyword,page:y.PageKeyword,let:y.LetKeyword,param:y.ParamKeyword,chart:y.ChartKeyword,filter:y.FilterKeyword,true:y.BooleanLiteral,false:y.BooleanLiteral,INTERVAL:y.IntervalKeyword,import:y.ImportKeyword,from:y.FromKeyword,use:y.UseKeyword,layout:y.LayoutKeyword,row:y.RowKeyword,block:y.BlockKeyword,term:y.TermKeyword,terms:y.TermsKeyword,business_view:y.BusinessViewKeyword,includes:y.IncludesKeyword,domain:y.DomainKeyword,type:y.TypeKeyword,description:y.DescriptionKeyword,tags:y.TagsKeyword,owner:y.OwnerKeyword,query:y.QueryKeyword,visualization:y.VisualizationKeyword,tests:y.TestsKeyword,params:y.ParamsKeyword,assert:y.AssertKeyword,var:y.VarKeyword,default:y.DefaultKeyword,IN:y.InKeyword,metric:y.MetricKeyword,metrics:y.MetricsKeyword,dimensions:y.DimensionsKeyword,digest:y.DigestKeyword,narrative:y.NarrativeKeyword};function n0(e){return t0[e]??y.Identifier}const Gs=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"]),r0={"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 o0(e){return r0[e]??e}const Qs=new Set(["dropdown","date_range","text","multi_select","range"]),s0=new Set(["SELECT","WITH"]);class ds{constructor(t,n){Pe(this,"source");Pe(this,"pos",0);Pe(this,"line",1);Pe(this,"column",1);Pe(this,"file");this.source=t,this.file=n}tokenize(){const t=[];for(;!this.isAtEnd()&&(this.skipWhitespace(),!this.isAtEnd());){const n=this.nextToken();n.type!==y.Comment&&t.push(n)}return t.push(this.makeToken(y.EOF,"",this.location())),t}nextToken(){if(this.skipWhitespace(),this.isAtEnd())return this.makeToken(y.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(y.GreaterThanOrEqual,">=",t)):n==="<"&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(y.LessThanOrEqual,"<=",t)):n==="="&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(y.DoubleEquals,"==",t)):n==="!"&&this.peekNext()==="="?(this.advance(),this.advance(),this.makeToken(y.NotEquals,"!=",t)):this.readPunctuation(t)}static scanSQLBoundary(t,n,r){let o=n,i=r;const c=t.length;for(;o<c;){const l=t[o];if(l==="'"||l==='"'){o=ds.skipStringInSQL(t,o);continue}if(l==="("){i++,o++;continue}if(l===")"){if(i===1)return{sql:t.substring(n,o).trim(),endOffset:o};i--,o++;continue}if(l===","&&i===1){let u=o+1;for(;u<c&&/\s/.test(t[u]);)u++;if(u<c&&/[a-zA-Z_]/.test(t[u])){let h=u;for(;h<c&&/[a-zA-Z0-9_]/.test(t[h]);)h++;let d=h;for(;d<c&&/\s/.test(t[d]);)d++;if(d<c&&t[d]==="="&&(d+1>=c||t[d+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()!==`
|
|
407
|
+
`;)n+=this.advance();return this.makeToken(y.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+=`
|
|
408
|
+
`;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(y.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(y.NumberLiteral,n,t)}readIdentifierOrKeyword(t){let n="";for(;!this.isAtEnd()&&(this.isAlphaNumeric(this.peek())||this.peek()==="_");)n+=this.advance();const r=n0(n);return this.makeToken(r,n,t)}readPunctuation(t){const n=this.advance();switch(n){case"(":return this.makeToken(y.LeftParen,n,t);case")":return this.makeToken(y.RightParen,n,t);case"{":return this.makeToken(y.LeftBrace,n,t);case"}":return this.makeToken(y.RightBrace,n,t);case"[":return this.makeToken(y.LeftBracket,n,t);case"]":return this.makeToken(y.RightBracket,n,t);case",":return this.makeToken(y.Comma,n,t);case".":return this.makeToken(y.Dot,n,t);case"=":return this.makeToken(y.Equals,n,t);case"+":return this.makeToken(y.Plus,n,t);case"-":return this.makeToken(y.Minus,n,t);case"*":return this.makeToken(y.Star,n,t);case"@":return this.makeToken(y.AtSign,n,t);case":":return this.makeToken(y.ColonToken,n,t);case">":return this.makeToken(y.GreaterThan,n,t);case"<":return this.makeToken(y.LessThan,n,t);default:return this.makeToken(y.Identifier,n,t)}}skipWhitespace(){for(;!this.isAtEnd();){const t=this.peek();if(t===" "||t===" "||t==="\r"||t===`
|
|
409
|
+
`)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===`
|
|
410
|
+
`?(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()===`
|
|
411
|
+
`&&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(y.TripleQuoteString,n,t);n+=this.advance()}return this.makeToken(y.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 i0=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"]),a0=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 c0(e){return i0.has(e)}function l0(e){return a0.has(e)}class d0{constructor(t,n){Pe(this,"tokens");Pe(this,"pos",0);Pe(this,"source");Pe(this,"file");Pe(this,"reporter");this.source=t,this.file=n,this.reporter=new Xw;const r=new ds(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 e0(`Parse errors in ${this.file??"<input>"}`,this.reporter.getErrors());return{kind:Q.Program,statements:n,span:this.makeSpan(t,this.currentSpan())}}parseStatement(){const t=this.parseDecoratorList();return this.check(y.WorkbookKeyword)?this.parseWorkbook(t):this.check(y.DashboardKeyword)?this.parseDashboard(t):this.check(y.DigestKeyword)?this.parseDigest(t):this.check(y.ChartKeyword)?this.parseChartCall(t):this.check(y.BlockKeyword)?this.parseBlockDecl(t):this.check(y.DomainKeyword)?this.parseDomainDecl(t):this.check(y.TermKeyword)?this.parseTermDecl(t):this.check(y.BusinessViewKeyword)?this.parseBusinessViewDecl(t):this.check(y.ImportKeyword)?(t.length>0&&this.error("Decorators cannot be applied to import statements."),this.parseImportDecl()):(this.check(y.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(y.FilterKeyword),this.expect(y.Dot);const n=this.expect(y.Identifier);Qs.has(n.value)||this.reporter.error(`Unknown filter type '${n.value}'. Valid types: ${[...Qs].join(", ")}`,n.span,`Did you mean one of: ${[...Qs].join(", ")}?`),this.expect(y.LeftParen);let r;const i=this.current().value.toUpperCase();(i==="SELECT"||i==="WITH")&&(r=this.parseSQLQuery());const c=[];for(;(this.check(y.Comma)||!r&&(this.check(y.Identifier)||this.isKeywordUsableAsArgName(this.current().type)))&&(this.check(y.Comma)&&this.advance(),!this.check(y.RightParen));)c.push(this.parseNamedArg());return this.expect(y.RightParen),{kind:Q.FilterCall,filterType:n.value,query:r,args:c,span:this.makeSpan(t,this.previousSpan())}}parseDashboard(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.DashboardKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);const o=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const i=this.parseDecoratorList();if(this.check(y.LetKeyword))i.length>0&&this.error("Decorators cannot be applied to variable declarations."),o.push(this.parseVariableDecl());else if(this.check(y.ParamKeyword))i.length>0&&this.error("Decorators cannot be applied to param declarations."),o.push(this.parseParamDecl());else if(this.check(y.ChartKeyword))o.push(this.parseChartCall(i));else if(this.check(y.FilterKeyword))i.length>0&&this.error("Decorators cannot be applied to filter declarations."),o.push(this.parseFilterCall());else if(this.check(y.UseKeyword))i.length>0&&this.error("Decorators cannot be applied to use declarations."),o.push(this.parseUseDecl());else if(this.check(y.LayoutKeyword))i.length>0&&this.error("Decorators cannot be applied to layout blocks."),o.push(this.parseLayoutBlock());else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside dashboard. Expected 'let', 'param', 'chart', 'filter', 'use', 'layout', or '}'.`),this.advance()}}return this.expect(y.RightBrace),{kind:Q.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(y.DigestKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);const o=[];let i;for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const c=this.parseDecoratorList();if(this.check(y.NarrativeKeyword))c.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(y.LetKeyword))c.length>0&&this.error("Decorators cannot be applied to variable declarations."),o.push(this.parseVariableDecl());else if(this.check(y.ParamKeyword))c.length>0&&this.error("Decorators cannot be applied to param declarations."),o.push(this.parseParamDecl());else if(this.check(y.ChartKeyword))o.push(this.parseChartCall(c));else if(this.check(y.FilterKeyword))c.length>0&&this.error("Decorators cannot be applied to filter declarations."),o.push(this.parseFilterCall());else if(this.check(y.UseKeyword))c.length>0&&this.error("Decorators cannot be applied to use declarations."),o.push(this.parseUseDecl());else if(this.check(y.LayoutKeyword))c.length>0&&this.error("Decorators cannot be applied to layout blocks."),o.push(this.parseLayoutBlock());else{if(this.check(y.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(y.RightBrace),{kind:Q.Digest,title:r.value,decorators:t,narrative:i,body:o,span:this.makeSpan(n,this.previousSpan())}}parseNarrative(){const t=this.currentSpan();this.expect(y.NarrativeKeyword),this.expect(y.LeftBrace);const n=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();)n.push(this.parseNamedArg());return this.expect(y.RightBrace),{kind:Q.Narrative,properties:n,span:this.makeSpan(t,this.previousSpan())}}parseChartCall(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.ChartKeyword),this.expect(y.Dot);const r=this.currentSpan();let i=this.expect(y.Identifier).value;for(;this.check(y.Minus);)this.advance(),i+=`-${this.expect(y.Identifier).value}`;const c=this.makeSpan(r,this.previousSpan());Gs.has(i)||this.reporter.error(`Unknown chart type '${i}'. Valid types: ${[...Gs].join(", ")}`,c,`Did you mean one of: ${[...Gs].join(", ")}?`);const a=o0(i);this.expect(y.LeftParen);const l=this.parseSQLQuery(),u=[];for(;this.check(y.Comma)&&(this.advance(),!this.check(y.RightParen));)u.push(this.parseNamedArg());return this.expect(y.RightParen),{kind:Q.ChartCall,chartType:a,query:l,args:u,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseSQLQuery(){const t=this.currentSpan(),r=this.current().span.start.offset,{sql:o,endOffset:i}=ds.scanSQLBoundary(this.source,r,1),c=this.extractInterpolations(o,t);for(;!this.isAtEnd()&&this.current().span.start.offset<i;)this.advance();const a=this.makeSpan(t,this.currentSpan());return{kind:Q.SQLQuery,rawSQL:o,interpolations:c,span:a}}extractInterpolations(t,n){const r=[],o=/\$\{(\w+)\}|\{(\w+)\}/g;let i;for(;(i=o.exec(t))!==null;){const c=i[1]||i[2];c&&r.push({variableName:c,offsetInSQL:i.index,span:n})}return r}parseNamedArg(){const t=this.currentSpan(),n=this.current();n.type===y.Identifier||this.isKeywordUsableAsArgName(n.type)?this.advance():(this.error(`Expected argument name, got '${n.value}'.`),this.advance()),this.expect(y.Equals);const r=this.parseExpression();return{kind:Q.NamedArg,name:n.value,value:r,span:this.makeSpan(t,this.previousSpan())}}isKeywordUsableAsArgName(t){return t===y.ParamKeyword||t===y.FromKeyword||t===y.LayoutKeyword||t===y.RowKeyword||t===y.UseKeyword||t===y.ImportKeyword||t===y.MetricKeyword||t===y.MetricsKeyword||t===y.TermsKeyword||t===y.IncludesKeyword}parseVariableDecl(){const t=this.currentSpan();this.expect(y.LetKeyword);const n=this.expect(y.Identifier);this.expect(y.Equals);const r=this.parseExpression();return{kind:Q.VariableDecl,name:n.value,initializer:r,span:this.makeSpan(t,this.previousSpan())}}parseDecoratorList(){const t=[];for(;this.check(y.AtSign);)t.push(this.parseDecorator());return t}parseDecorator(){const t=this.currentSpan();this.expect(y.AtSign);const n=this.expect(y.Identifier),r=[];if(this.check(y.LeftParen)){if(this.advance(),!this.check(y.RightParen))for(r.push(this.parseExpression());this.check(y.Comma);)this.advance(),r.push(this.parseExpression());this.expect(y.RightParen)}return{kind:Q.Decorator,name:n.value,arguments:r,span:this.makeSpan(t,this.previousSpan())}}parseExpression(){let t=this.parsePrimary();for(;this.check(y.Plus)||this.check(y.Minus);){const n=this.advance(),r=this.parsePrimary();t={kind:Q.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(y.StringLiteral))return this.advance(),{kind:Q.StringLiteral,value:t.value,span:t.span};if(this.check(y.NumberLiteral))return this.advance(),{kind:Q.NumberLiteral,value:Number(t.value),span:t.span};if(this.check(y.BooleanLiteral))return this.advance(),{kind:Q.BooleanLiteral,value:t.value==="true",span:t.span};if(this.check(y.LeftBracket))return this.parseArrayLiteral();if(this.check(y.IntervalKeyword)){const n=this.currentSpan();this.advance();const r=this.expect(y.StringLiteral);return{kind:Q.IntervalExpr,value:r.value,span:this.makeSpan(n,this.previousSpan())}}if(this.check(y.Identifier)){this.advance();const n=t.value;return this.check(y.LeftParen)?this.parseFunctionCall(n,t.span):{kind:Q.Identifier,name:n,span:t.span}}if(this.check(y.Minus)){const n=this.currentSpan();this.advance();const r=this.expect(y.NumberLiteral);return{kind:Q.NumberLiteral,value:-Number(r.value),span:this.makeSpan(n,r.span)}}return this.error(`Unexpected token '${t.value}'. Expected an expression.`),this.advance(),{kind:Q.Identifier,name:"__error__",span:t.span}}parseArrayLiteral(){const t=this.currentSpan();this.expect(y.LeftBracket);const n=[];if(!this.check(y.RightBracket))for(n.push(this.parseExpression());this.check(y.Comma)&&(this.advance(),!this.check(y.RightBracket));)n.push(this.parseExpression());return this.expect(y.RightBracket),{kind:Q.ArrayLiteral,elements:n,span:this.makeSpan(t,this.previousSpan())}}parseFunctionCall(t,n){this.expect(y.LeftParen);const r=[];if(!this.check(y.RightParen))for(r.push(this.parseExpression());this.check(y.Comma);)this.advance(),r.push(this.parseExpression());return this.expect(y.RightParen),{kind:Q.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(y.LeftBrace))return;let t=0;for(;!this.isAtEnd();){if(this.check(y.LeftBrace)){t+=1,this.advance();continue}if(this.check(y.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(y.StringLiteral)||this.check(y.TripleQuoteString)?this.advance():this.expect(y.StringLiteral)}isAtEnd(){return this.current().type===y.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(y.DomainKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);let o,i,c,a,l,u,h,d,f,m,S,v,b,w,j,C,x,E,P;for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.OwnerKeyword))this.advance(),this.expect(y.Equals),i=this.expect(y.StringLiteral).value;else if(this.check(y.DescriptionKeyword))this.advance(),this.expect(y.Equals),S=this.expectStringLike().value;else if(this.check(y.TagsKeyword))this.advance(),this.expect(y.Equals),f=this.parseStringArrayValues();else if(this.check(y.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 A=this.advance();this.expect(y.Equals),A.value==="id"?o=this.expect(y.StringLiteral).value:A.value==="parent"?c=this.expect(y.StringLiteral).value:A.value==="businessOwner"?a=this.expect(y.StringLiteral).value:A.value==="boundedContext"?l=this.expectStringLike().value:A.value==="sourceSystems"?u=this.parseStringArrayValues():A.value==="primaryTerms"?h=this.parseStringArrayValues():A.value==="reviewCadence"?d=this.expect(y.StringLiteral).value:A.value==="businessOutcome"?m=this.expect(y.StringLiteral).value:A.value==="inScope"?v=this.parseStringArrayValues():A.value==="outOfScope"?b=this.parseStringArrayValues():A.value==="dbtGroups"?w=this.parseStringArrayValues():A.value==="dbtPaths"?j=this.parseStringArrayValues():A.value==="dbtTags"?C=this.parseStringArrayValues():A.value==="semanticDomains"?x=this.parseStringArrayValues():A.value==="semanticTags"?E=this.parseStringArrayValues():A.value==="exports"&&(P=this.parseStringArrayValues())}else{if(this.check(y.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(y.RightBrace),{kind:Q.DomainDecl,name:r.value,id:o,parent:c,owner:i,businessOwner:a,boundedContext:l,sourceSystems:u,primaryTerms:h,reviewCadence:d,tags:f,businessOutcome:m,description:S,inScope:v,outOfScope:b,dbtGroups:w,dbtPaths:j,dbtTags:C,semanticDomains:x,semanticTags:E,exports:P,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseTermDecl(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.TermKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);let o,i,c,a,l,u,h,d,f,m,S,v,b,w,j;for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.DomainKeyword))this.advance(),this.expect(y.Equals),o=this.expect(y.StringLiteral).value;else if(this.check(y.TypeKeyword))this.advance(),this.expect(y.Equals),i=this.expect(y.StringLiteral).value;else if(this.check(y.DescriptionKeyword))this.advance(),this.expect(y.Equals),a=this.expectStringLike().value;else if(this.check(y.TagsKeyword))this.advance(),this.expect(y.Equals),l=this.parseStringArrayValues();else if(this.check(y.OwnerKeyword))this.advance(),this.expect(y.Equals),u=this.expect(y.StringLiteral).value;else if(this.check(y.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 C=this.advance();this.expect(y.Equals),C.value==="status"?c=this.expect(y.StringLiteral).value:C.value==="identifiers"?h=this.parseStringArrayValues():C.value==="synonyms"?d=this.parseStringArrayValues():C.value==="metricRefs"?f=this.parseStringArrayValues():C.value==="businessOutcome"?m=this.expect(y.StringLiteral).value:C.value==="businessOwner"?S=this.expect(y.StringLiteral).value:C.value==="decisionUse"?v=this.expect(y.StringLiteral).value:C.value==="reviewCadence"?b=this.expect(y.StringLiteral).value:C.value==="businessRules"?w=this.parseStringArrayValues():C.value==="caveats"&&(j=this.parseStringArrayValues())}else{if(this.check(y.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(y.RightBrace),{kind:Q.TermDecl,name:r.value,domain:o,termType:i,status:c,description:a,tags:l,owner:u,identifiers:h,synonyms:d,metricRefs:f,businessOutcome:m,businessOwner:S,decisionUse:v,reviewCadence:b,businessRules:w,caveats:j,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseBusinessViewDecl(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.BusinessViewKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);let o,i,c,a,l,u,h,d,f,m,S,v,b=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.DomainKeyword))this.advance(),this.expect(y.Equals),o=this.expect(y.StringLiteral).value;else if(this.check(y.DescriptionKeyword))this.advance(),this.expect(y.Equals),c=this.expectStringLike().value;else if(this.check(y.TagsKeyword))this.advance(),this.expect(y.Equals),a=this.parseStringArrayValues();else if(this.check(y.OwnerKeyword))this.advance(),this.expect(y.Equals),l=this.expect(y.StringLiteral).value;else if(this.check(y.TermsKeyword))this.advance(),this.expect(y.Equals),u=this.parseStringArrayValues();else if(this.check(y.IncludesKeyword))b=this.parseBusinessViewIncludes();else if(this.check(y.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(y.Equals),w.value==="status"?i=this.expect(y.StringLiteral).value:w.value==="businessOutcome"?h=this.expect(y.StringLiteral).value:w.value==="businessOwner"?d=this.expect(y.StringLiteral).value:w.value==="decisionUse"?f=this.expect(y.StringLiteral).value:w.value==="reviewCadence"?m=this.expect(y.StringLiteral).value:w.value==="businessRules"?S=this.parseStringArrayValues():w.value==="caveats"&&(v=this.parseStringArrayValues())}else{if(this.check(y.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(y.RightBrace),{kind:Q.BusinessViewDecl,name:r.value,domain:o,status:i,description:c,tags:a,owner:l,termRefs:u,businessOutcome:h,businessOwner:d,decisionUse:f,reviewCadence:m,businessRules:S,caveats:v,includes:b,decorators:t,span:this.makeSpan(n,this.previousSpan())}}parseBusinessViewIncludes(){this.expect(y.IncludesKeyword),this.expect(y.LeftBrace);const t=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan();if(this.check(y.BlockKeyword)){this.advance();const r=this.expect(y.StringLiteral);t.push({kind:Q.BusinessViewInclude,refType:"block",name:r.value,span:this.makeSpan(n,this.previousSpan())})}else if(this.check(y.BusinessViewKeyword)){this.advance();const r=this.expect(y.StringLiteral);t.push({kind:Q.BusinessViewInclude,refType:"business_view",name:r.value,span:this.makeSpan(n,this.previousSpan())})}else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside includes. Expected 'block', 'business_view', or '}'.`),this.advance()}}return this.expect(y.RightBrace),t}parseStringArrayValues(){const t=this.parseArrayLiteral();return t.kind!==Q.ArrayLiteral?[]:t.elements.filter(n=>n.kind===Q.StringLiteral).map(n=>n.value)}parseBlockDecl(t){var tn;const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.BlockKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);let o,i,c,a,l,u,h,d,f,m,S,v,b,w,j,C,x,E,P,A,g,I,T,O,_,M,q,G,J,H,L,$,X,W,te,F,K,oe,ee,ce,ke,xe,De,We,Be,Ee,ge,Je,tt,Fe,Ke,gt,Dt,Ct,jt,Zt,en,En,Tn,U,se,je,ve,me;for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.DomainKeyword))this.advance(),this.expect(y.Equals),o=this.expect(y.StringLiteral).value;else if(this.check(y.TypeKeyword)){this.advance(),this.expect(y.Equals);const Y=this.expect(y.StringLiteral).value;Y==="semantic"||Y==="custom"?i=Y:(this.error(`Block type must be "semantic" or "custom", got "${Y}". Use type = "semantic" for dbt metric blocks or type = "custom" for SQL blocks.`),i="custom")}else if(this.check(y.MetricKeyword))this.advance(),this.expect(y.Equals),c=this.expect(y.StringLiteral).value;else if(this.check(y.MetricsKeyword)){this.advance(),this.expect(y.Equals);const ie=this.parseArrayLiteral();ie.kind===Q.ArrayLiteral&&(a=ie.elements.filter(Y=>Y.kind===Q.StringLiteral).map(Y=>Y.value))}else if(this.check(y.DimensionsKeyword)){this.advance(),this.expect(y.Equals);const ie=this.parseArrayLiteral();ie.kind===Q.ArrayLiteral&&(l=ie.elements.filter(Y=>Y.kind===Q.StringLiteral).map(Y=>Y.value))}else if(this.check(y.DescriptionKeyword))this.advance(),this.expect(y.Equals),u=this.expectStringLike().value;else if(this.check(y.TagsKeyword)){this.advance(),this.expect(y.Equals);const ie=this.parseArrayLiteral();ie.kind===Q.ArrayLiteral&&(h=ie.elements.filter(Y=>Y.kind===Q.StringLiteral).map(Y=>Y.value))}else if(this.check(y.OwnerKeyword))this.advance(),this.expect(y.Equals),d=this.expect(y.StringLiteral).value;else if(this.check(y.TermsKeyword))this.advance(),this.expect(y.Equals),f=this.parseStringArrayValues();else if(this.check(y.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 ie=this.advance();this.expect(y.Equals),ie.value==="pattern"?m=this.expect(y.StringLiteral).value:ie.value==="grain"?S=this.expect(y.StringLiteral).value:ie.value==="entities"?v=this.parseStringArrayValues():ie.value==="outputs"?b=this.parseStringArrayValues():ie.value==="allowedFilters"?w=this.parseStringArrayValues():ie.value==="sourceSystems"?x=this.parseStringArrayValues():ie.value==="replacementFor"&&(E=this.parseStringArrayValues())}else if(this.check(y.ParamsKeyword))P=this.parseBlockParams();else if(this.check(y.Identifier)&&this.current().value==="parameterPolicy")j=this.parseBlockParameterPolicy();else if(this.check(y.Identifier)&&this.current().value==="filterBindings")C=this.parseBlockFilterBindings();else if(this.check(y.QueryKeyword))if(this.advance(),this.check(y.LeftBrace))A=this.parseLegacyBlockQuerySection();else if(this.expect(y.Equals),this.check(y.TripleQuoteString)){const ie=this.advance(),Y=this.extractInterpolations(ie.value,ie.span);A={kind:Q.SQLQuery,rawSQL:ie.value,interpolations:Y,span:ie.span}}else A=this.parseSQLQuery();else if(this.check(y.VisualizationKeyword))g=this.parseBlockVisualization();else if(this.check(y.TestsKeyword))I=this.parseBlockTests();else{if(this.check(y.RightBrace))break;if(this.check(y.Identifier)&&this.current().value==="status")this.advance(),this.expect(y.Equals),$=this.expect(y.StringLiteral).value;else if(this.check(y.Identifier)&&this.current().value==="datalex_contract")this.advance(),this.expect(y.Equals),X=this.expect(y.StringLiteral).value;else if(this.check(y.Identifier)&&(this.current().value==="asked_times"||this.current().value==="limit"||this.current().value==="source_dql_limit")){const ie=this.advance();this.expect(y.Equals);const Y=this.expect(y.NumberLiteral);ie.value==="asked_times"?W=Number(Y.value):ie.value==="limit"?En=Number(Y.value):ve=Number(Y.value)}else if(this.check(y.Identifier)&&c0(this.current().value)){const ie=this.advance();this.expect(y.Equals);const Y=this.expect(y.StringLiteral);switch(ie.value){case"first_asked":te=Y.value;break;case"last_asked":F=Y.value;break;case"proposed_contract_id":K=Y.value;break;case"proposed_domain":oe=Y.value;break;case"proposed_entity":ee=Y.value;break;case"source_question":ce=Y.value;break;case"source_block":ke=Y.value;break;case"source_dql_kind":xe=Y.value;break;case"source_dql_name":De=Y.value;break;case"source_dql_path":We=Y.value;break;case"source_dql_hash":Be=Y.value;break;case"source_dql_time_dimension":Ee=Y.value;break;case"source_dql_granularity":ge=Y.value;break;case"followup_kind":Je=Y.value;break;case"context_pack_id":tt=Y.value;break;case"route_intent":Fe=Y.value;break;case"time_dimension":Ke=Y.value;break;case"granularity":gt=Y.value;break;case"draft_path":Dt=Y.value;break}}else if(this.check(y.Identifier)&&l0(this.current().value)){const ie=this.advance();this.expect(y.Equals);const Y=this.parseStringArrayValues();switch(ie.value){case"upstream_refs":Ct=Y;break;case"requested_filters":jt=Y;break;case"requested_dimensions":Zt=Y;break;case"order_by":en=Y;break;case"source_dql_metrics":Tn=Y;break;case"source_dql_dimensions":U=Y;break;case"source_dql_filters":se=Y;break;case"source_dql_order_by":je=Y;break;case"validation_warnings":me=Y;break}}else if(this.check(y.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 ie=this.advance();if(this.expect(y.Equals),ie.value==="llmContext")T=this.expect(y.StringLiteral).value;else if(ie.value==="invariants"){const Y=this.parseArrayLiteral();Y.kind===Q.ArrayLiteral&&(O=Y.elements.filter($e=>$e.kind===Q.StringLiteral).map($e=>$e.value))}else if(ie.value==="examples"){this.expect(y.LeftBracket);const Y=[];for(;!this.check(y.RightBracket)&&!this.isAtEnd();){this.expect(y.LeftBrace);let $e,Jn;for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const Yn=this.current();if(Yn.type!==y.Identifier){this.error(`Expected 'question' or 'sql' in example entry, got '${Yn.value}'.`),this.advance();continue}this.advance(),this.expect(y.Equals);const ko=this.expect(y.StringLiteral);Yn.value==="question"?$e=ko.value:Yn.value==="sql"&&(Jn=ko.value),this.check(y.Comma)&&this.advance()}this.expect(y.RightBrace),$e&&Y.push(Jn?{question:$e,sql:Jn}:{question:$e}),this.check(y.Comma)&&this.advance()}this.expect(y.RightBracket),Y.length>0&&(_=Y)}else if(ie.value==="businessOutcome")M=this.expect(y.StringLiteral).value;else if(ie.value==="businessOwner")q=this.expect(y.StringLiteral).value;else if(ie.value==="decisionUse")G=this.expect(y.StringLiteral).value;else if(ie.value==="reviewCadence")J=this.expect(y.StringLiteral).value;else if(ie.value==="businessRules"){const Y=this.parseArrayLiteral();Y.kind===Q.ArrayLiteral&&(H=Y.elements.filter($e=>$e.kind===Q.StringLiteral).map($e=>$e.value))}else if(ie.value==="caveats"){const Y=this.parseArrayLiteral();Y.kind===Q.ArrayLiteral&&(L=Y.elements.filter($e=>$e.kind===Q.StringLiteral).map($e=>$e.value))}}else{if(this.check(y.Identifier)&&((tn=this.tokens[this.pos+1])==null?void 0:tn.type)===y.LeftBrace){const ie=this.current().value;this.error(`Unexpected nested section '${ie}' 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(y.RightBrace),{kind:Q.BlockDecl,name:r.value,domain:o,blockType:i,metricRef:c,metricsRef:a,dimensionsRef:i==="semantic"?l:void 0,description:u,tags:h,owner:d,termRefs:f,pattern:m,grain:S,entities:v,outputs:b,dimensions:i==="semantic"?void 0:l,allowedFilters:w,parameterPolicy:j,filterBindings:C,sourceSystems:x,replacementFor:E,params:P,query:A,visualization:g,tests:I,decorators:t,llmContext:T,invariants:O,examples:_,businessOutcome:M,businessOwner:q,decisionUse:G,reviewCadence:J,businessRules:H,caveats:L,status:$,datalexContract:X,askedTimes:W,firstAsked:te,lastAsked:F,proposedContractId:K,proposedDomain:oe,proposedEntity:ee,sourceQuestion:ce,sourceBlock:ke,sourceDqlKind:xe,sourceDqlName:De,sourceDqlPath:We,sourceDqlHash:Be,sourceDqlTimeDimension:Ee,sourceDqlGranularity:ge,followupKind:Je,contextPackId:tt,routeIntent:Fe,timeDimension:Ke,granularity:gt,draftPath:Dt,upstreamRefs:Ct,requestedFilters:jt,requestedDimensions:Zt,orderBy:en,limit:En,sourceDqlMetrics:Tn,sourceDqlDimensions:U,sourceDqlFilters:se,sourceDqlOrderBy:je,sourceDqlLimit:ve,validationWarnings:me,span:this.makeSpan(n,this.previousSpan())}}parseLegacyBlockQuerySection(){const t=this.currentSpan();this.expect(y.LeftBrace);let n;for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.Identifier)&&this.current().value==="sql")if(this.advance(),this.expect(y.Equals),this.check(y.TripleQuoteString)){const r=this.advance(),o=this.extractInterpolations(r.value,r.span);n={kind:Q.SQLQuery,rawSQL:r.value,interpolations:o,span:r.span}}else n=this.parseSQLQuery();else this.check(y.Identifier)&&s0.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(y.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(y.ParamsKeyword),this.expect(y.LeftBrace);const n=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const o=this.currentSpan(),i=this.current();if(i.type===y.Identifier||this.isBlockFieldKeyword(i.type))this.advance();else{this.error(`Expected parameter name, got '${i.value}'.`),this.advance();continue}let c;if(this.check(y.ColonToken)){this.advance();let u=this.expect(y.Identifier).value;this.check(y.LeftBracket)&&((r=this.tokens[this.pos+1])==null?void 0:r.type)===y.RightBracket&&(this.advance(),this.advance(),u+="[]");const h=["string","number","boolean","date","string[]","number[]","date[]"];h.includes(u)?c=u:this.error(`Invalid block parameter type '${u}'. Valid types: ${h.join(", ")}`)}let a;this.check(y.Equals)&&(this.advance(),a=this.parseExpression()),n.push({name:i.value,paramType:c,initializer:a,span:this.makeSpan(o,this.previousSpan())})}return this.expect(y.RightBrace),{kind:Q.BlockParams,params:n,span:this.makeSpan(t,this.previousSpan())}}parseBlockParameterPolicy(){const t=[];for(this.expect(y.Identifier),this.expect(y.LeftBrace);!this.check(y.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan(),r=this.current();if(r.type===y.Identifier||this.isBlockFieldKeyword(r.type))this.advance();else{this.error(`Expected parameter name inside parameterPolicy, got '${r.value}'.`),this.advance();continue}this.expect(y.Equals);const o=this.expectStringLike();t.push({name:r.value,policy:o.value,span:this.makeSpan(n,this.previousSpan())})}return this.expect(y.RightBrace),t}parseBlockFilterBindings(){const t=[];for(this.expect(y.Identifier),this.expect(y.LeftBrace);!this.check(y.RightBrace)&&!this.isAtEnd();){const n=this.currentSpan(),r=this.current();if(r.type===y.Identifier||this.isBlockFieldKeyword(r.type))this.advance();else{this.error(`Expected business filter name inside filterBindings, got '${r.value}'.`),this.advance();continue}this.expect(y.Equals);const o=this.expectStringLike();t.push({filter:r.value,binding:o.value,span:this.makeSpan(n,this.previousSpan())})}return this.expect(y.RightBrace),t}parseBlockVisualization(){const t=this.currentSpan();this.expect(y.VisualizationKeyword),this.expect(y.LeftBrace);const n=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const r=this.currentSpan(),o=this.current();if(o.type===y.Identifier||this.isBlockFieldKeyword(o.type))this.advance();else{this.error(`Expected property name, got '${o.value}'.`),this.advance();continue}this.expect(y.Equals);const i=this.parseExpression();n.push({kind:Q.NamedArg,name:o.value,value:i,span:this.makeSpan(r,this.previousSpan())})}return this.expect(y.RightBrace),{kind:Q.BlockVisualization,properties:n,span:this.makeSpan(t,this.previousSpan())}}parseBlockTests(){this.currentSpan(),this.expect(y.TestsKeyword),this.expect(y.LeftBrace);const t=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.AssertKeyword)){const n=this.currentSpan();this.advance();const r=this.current();if(r.type===y.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(y.GreaterThan))this.advance(),o=">";else if(this.check(y.LessThan))this.advance(),o="<";else if(this.check(y.GreaterThanOrEqual))this.advance(),o=">=";else if(this.check(y.LessThanOrEqual))this.advance(),o="<=";else if(this.check(y.DoubleEquals))this.advance(),o="==";else if(this.check(y.NotEquals))this.advance(),o="!=";else if(this.check(y.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:Q.BlockTest,field:r.value,operator:o,expected:i,span:this.makeSpan(n,this.previousSpan())})}else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside tests. Expected 'assert' or '}'.`),this.advance()}return this.expect(y.RightBrace),t}isBlockFieldKeyword(t){return t===y.DomainKeyword||t===y.TypeKeyword||t===y.MetricKeyword||t===y.DescriptionKeyword||t===y.TagsKeyword||t===y.OwnerKeyword||t===y.TermsKeyword||t===y.ChartKeyword||t===y.QueryKeyword||t===y.DefaultKeyword||t===y.FromKeyword}parseWorkbook(t){const n=t.length>0?t[0].span:this.currentSpan();this.expect(y.WorkbookKeyword);const r=this.expect(y.StringLiteral);this.expect(y.LeftBrace);const o=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.PageKeyword))o.push(this.parsePage());else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside workbook. Expected 'page' or '}'.`),this.advance()}return this.expect(y.RightBrace),{kind:Q.Workbook,title:r.value,decorators:t,pages:o,span:this.makeSpan(n,this.previousSpan())}}parsePage(){const t=this.currentSpan();this.expect(y.PageKeyword);const n=this.expect(y.StringLiteral);this.expect(y.LeftBrace);const r=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const o=this.parseDecoratorList();if(this.check(y.LetKeyword))o.length>0&&this.error("Decorators cannot be applied to variable declarations."),r.push(this.parseVariableDecl());else if(this.check(y.ParamKeyword))o.length>0&&this.error("Decorators cannot be applied to param declarations."),r.push(this.parseParamDecl());else if(this.check(y.ChartKeyword))r.push(this.parseChartCall(o));else if(this.check(y.FilterKeyword))o.length>0&&this.error("Decorators cannot be applied to filter declarations."),r.push(this.parseFilterCall());else if(this.check(y.UseKeyword))o.length>0&&this.error("Decorators cannot be applied to use declarations."),r.push(this.parseUseDecl());else if(this.check(y.LayoutKeyword))o.length>0&&this.error("Decorators cannot be applied to layout blocks."),r.push(this.parseLayoutBlock());else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside page. Expected 'let', 'param', 'chart', 'filter', 'use', 'layout', or '}'.`),this.advance()}}return this.expect(y.RightBrace),{kind:Q.Page,title:n.value,body:r,span:this.makeSpan(t,this.previousSpan())}}parseParamDecl(){const t=this.currentSpan();this.expect(y.ParamKeyword);const n=this.expect(y.Identifier);let r="string";if(this.check(y.ColonToken)){this.advance();const i=this.expect(y.Identifier),c=["string","number","boolean","date"];c.includes(i.value)?r=i.value:this.reporter.error(`Invalid param type '${i.value}'. Valid types: ${c.join(", ")}`,i.span)}let o;return this.check(y.Equals)&&(this.advance(),o=this.parseExpression()),{kind:Q.ParamDecl,name:n.value,paramType:r,defaultValue:o,span:this.makeSpan(t,this.previousSpan())}}parseImportDecl(){const t=this.currentSpan();this.expect(y.ImportKeyword),this.expect(y.LeftBrace);const n=[];if(!this.check(y.RightBrace))for(n.push(this.expect(y.Identifier).value);this.check(y.Comma)&&(this.advance(),!this.check(y.RightBrace));)n.push(this.expect(y.Identifier).value);this.expect(y.RightBrace),this.expect(y.FromKeyword);const r=this.expect(y.StringLiteral);return{kind:Q.ImportDecl,names:n,path:r.value,span:this.makeSpan(t,this.previousSpan())}}parseUseDecl(){const t=this.currentSpan();this.expect(y.UseKeyword);let n;return this.check(y.Identifier)||this.check(y.StringLiteral)?n=this.advance():n=this.expect(y.Identifier),{kind:Q.UseDecl,name:n.value,span:this.makeSpan(t,this.previousSpan())}}parseLayoutBlock(){const t=this.currentSpan();this.expect(y.LayoutKeyword);let n=12;if(this.check(y.LeftParen)){this.advance();const o=[];if(!this.check(y.RightParen))for(o.push(this.parseNamedArg());this.check(y.Comma)&&(this.advance(),!this.check(y.RightParen));)o.push(this.parseNamedArg());this.expect(y.RightParen);const i=o.find(c=>c.name==="columns");i&&i.value.kind===Q.NumberLiteral&&(n=i.value.value)}this.expect(y.LeftBrace);const r=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();)if(this.check(y.RowKeyword))r.push(this.parseLayoutRow());else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside layout. Expected 'row' or '}'.`),this.advance()}return this.expect(y.RightBrace),{kind:Q.LayoutBlock,columns:n,rows:r,span:this.makeSpan(t,this.previousSpan())}}parseLayoutRow(){const t=this.currentSpan();this.expect(y.RowKeyword),this.expect(y.LeftBrace);const n=[];for(;!this.check(y.RightBrace)&&!this.isAtEnd();){const r=this.parseDecoratorList();let o;if(this.check(y.ChartKeyword))o=this.parseChartCall(r);else if(this.check(y.FilterKeyword))r.length>0&&this.error("Decorators cannot be applied to filter declarations."),o=this.parseFilterCall();else{if(this.check(y.RightBrace))break;this.error(`Unexpected token '${this.current().value}' inside row. Expected 'chart', 'filter', or '}'.`),this.advance();continue}let i;if(this.check(y.Identifier)&&this.current().value==="span"){this.advance();const c=this.expect(y.NumberLiteral);i=Number(c.value)}n.push({node:o,span:i})}return this.expect(y.RightBrace),{kind:Q.LayoutRow,items:n,span:this.makeSpan(t,this.previousSpan())}}synchronize(){for(;!this.isAtEnd();){const t=this.current();if(t.type===y.DashboardKeyword||t.type===y.WorkbookKeyword||t.type===y.ChartKeyword||t.type===y.FilterKeyword||t.type===y.ImportKeyword||t.type===y.BlockKeyword||t.type===y.TermKeyword||t.type===y.BusinessViewKeyword||t.type===y.AtSign||t.type===y.RightBrace)return;this.advance()}}}function u0(e,t){return new d0(e,t).parse()}function p0(e,t={}){const n=u0(e);return f0(n,t)}function f0(e,t={}){const n={indentUnit:t.indent??" "},r=e.statements.map(o=>h0(o,0,n)).join(`
|
|
412
|
+
|
|
413
|
+
`).trimEnd();return t.finalNewline===!1?r:`${r}
|
|
414
|
+
`}function N(e,t){return t.indentUnit.repeat(e)}function h0(e,t,n){switch(e.kind){case Q.Dashboard:return m0(e,t,n);case Q.ChartCall:return _a(e,t,n);case Q.Workbook:return b0(e,t,n);case Q.ImportDecl:return v0(e,t,n);case Q.DomainDecl:return T0(e,t,n);case Q.BlockDecl:return E0(e,t,n);case Q.TermDecl:return A0(e,t,n);case Q.BusinessViewDecl:return R0(e,t,n);case Q.Digest:return g0(e,t,n);default:return""}}function m0(e,t,n){const r=[];r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}dashboard ${V(e.title)} {`);for(const o of e.body)r.push(Oa(o,t+1,n));return r.push(`${N(t,n)}}`),r.join(`
|
|
415
|
+
`)}function g0(e,t,n){const r=[];r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}digest ${V(e.title)} {`),e.narrative&&r.push(y0(e.narrative,t+1,n));for(const o of e.body)r.push(Oa(o,t+1,n));return r.push(`${N(t,n)}}`),r.join(`
|
|
416
|
+
`)}function y0(e,t,n){const r=[];r.push(`${N(t,n)}narrative {`);for(const o of e.properties)r.push(`${N(t+1,n)}${Pa(o)}`);return r.push(`${N(t,n)}}`),r.join(`
|
|
417
|
+
`)}function b0(e,t,n){const r=[];r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}workbook ${V(e.title)} {`);for(const o of e.pages)r.push(x0(o,t+1,n));return r.push(`${N(t,n)}}`),r.join(`
|
|
418
|
+
`)}function x0(e,t,n){const r=[];r.push(`${N(t,n)}page ${V(e.title)} {`);for(const o of e.body)r.push(Oa(o,t+1,n));return r.push(`${N(t,n)}}`),r.join(`
|
|
419
|
+
`)}function Oa(e,t,n){switch(e.kind){case Q.VariableDecl:return w0(e,t,n);case Q.ParamDecl:return k0(e,t,n);case Q.ChartCall:return _a(e,t,n);case Q.FilterCall:return Rp(e,t,n);case Q.UseDecl:return S0(e,t,n);case Q.LayoutBlock:return C0(e,t,n);default:return""}}function v0(e,t,n){return`${N(t,n)}import { ${e.names.join(", ")} } from ${V(e.path)}`}function S0(e,t,n){const r=/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.name);return`${N(t,n)}use ${r?e.name:V(e.name)}`}function w0(e,t,n){return`${N(t,n)}let ${e.name} = ${Ot(e.initializer)}`}function k0(e,t,n){const r=`: ${e.paramType}`,o=e.defaultValue?` = ${Ot(e.defaultValue)}`:"";return`${N(t,n)}param ${e.name}${r}${o}`}function jn(e,t,n){return e.map(r=>{if(r.arguments.length===0)return`${N(t,n)}@${r.name}`;const o=r.arguments.map(i=>Ot(i)).join(", ");return`${N(t,n)}@${r.name}(${o})`})}function _a(e,t,n){return Op(`chart.${e.chartType}`,e.decorators,e.query,e.args,t,n)}function Rp(e,t,n){return Op(`filter.${e.filterType}`,[],e.query,e.args,t,n)}function Op(e,t,n,r,o,i){const c=[];c.push(...jn(t,o,i)),c.push(`${N(o,i)}${e}(`);const a=[];n&&a.push(_p(n,o+1,i));for(const l of r)a.push([`${N(o+1,i)}${Pa(l)}`]);for(let l=0;l<a.length;l++){const u=l===a.length-1,h=a[l];for(let d=0;d<h.length;d++){const f=d===h.length-1;c.push(f&&!u?`${h[d]},`:h[d])}}return c.push(`${N(o,i)})`),c.join(`
|
|
420
|
+
`)}function C0(e,t,n){const r=[];r.push(`${N(t,n)}layout(columns = ${e.columns}) {`);for(const o of e.rows)r.push(j0(o,t+1,n));return r.push(`${N(t,n)}}`),r.join(`
|
|
421
|
+
`)}function j0(e,t,n){const r=[];r.push(`${N(t,n)}row {`);for(const o of e.items){const i=o.node.kind===Q.ChartCall?_a(o.node,t+1,n):Rp(o.node,t+1,n);if(o.span==null){r.push(i);continue}const c=i.split(`
|
|
422
|
+
`);c[c.length-1]=`${c[c.length-1]} span ${o.span}`,r.push(c.join(`
|
|
423
|
+
`))}return r.push(`${N(t,n)}}`),r.join(`
|
|
424
|
+
`)}function E0(e,t,n){const r=[];if(r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}block ${V(e.name)} {`),e.domain&&r.push(`${N(t+1,n)}domain = ${V(e.domain)}`),e.blockType&&r.push(`${N(t+1,n)}type = ${V(e.blockType)}`),e.status&&r.push(`${N(t+1,n)}status = ${V(e.status)}`),e.description&&r.push(`${N(t+1,n)}description = ${V(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${N(t+1,n)}tags = [${e.tags.map(V).join(", ")}]`),e.owner&&r.push(`${N(t+1,n)}owner = ${V(e.owner)}`),e.termRefs&&e.termRefs.length>0&&r.push(`${N(t+1,n)}terms = [${e.termRefs.map(V).join(", ")}]`),e.pattern&&r.push(`${N(t+1,n)}pattern = ${V(e.pattern)}`),e.grain&&r.push(`${N(t+1,n)}grain = ${V(e.grain)}`),e.entities&&e.entities.length>0&&r.push(`${N(t+1,n)}entities = [${e.entities.map(V).join(", ")}]`),e.outputs&&e.outputs.length>0&&r.push(`${N(t+1,n)}outputs = [${e.outputs.map(V).join(", ")}]`),e.blockType!=="semantic"&&e.dimensions&&e.dimensions.length>0&&r.push(`${N(t+1,n)}dimensions = [${e.dimensions.map(V).join(", ")}]`),e.allowedFilters&&e.allowedFilters.length>0&&r.push(`${N(t+1,n)}allowedFilters = [${e.allowedFilters.map(V).join(", ")}]`),e.parameterPolicy&&e.parameterPolicy.length>0){r.push(`${N(t+1,n)}parameterPolicy {`);for(const o of e.parameterPolicy)r.push(`${N(t+2,n)}${o.name} = ${V(o.policy)}`);r.push(`${N(t+1,n)}}`)}if(e.filterBindings&&e.filterBindings.length>0){r.push(`${N(t+1,n)}filterBindings {`);for(const o of e.filterBindings)r.push(`${N(t+2,n)}${o.filter} = ${V(o.binding)}`);r.push(`${N(t+1,n)}}`)}if(e.sourceSystems&&e.sourceSystems.length>0&&r.push(`${N(t+1,n)}sourceSystems = [${e.sourceSystems.map(V).join(", ")}]`),e.replacementFor&&e.replacementFor.length>0&&r.push(`${N(t+1,n)}replacementFor = [${e.replacementFor.map(V).join(", ")}]`),e.llmContext&&r.push(`${N(t+1,n)}llmContext = ${V(e.llmContext)}`),e.businessOutcome&&r.push(`${N(t+1,n)}businessOutcome = ${V(e.businessOutcome)}`),e.businessOwner&&r.push(`${N(t+1,n)}businessOwner = ${V(e.businessOwner)}`),e.decisionUse&&r.push(`${N(t+1,n)}decisionUse = ${V(e.decisionUse)}`),e.reviewCadence&&r.push(`${N(t+1,n)}reviewCadence = ${V(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${N(t+1,n)}businessRules = [${e.businessRules.map(V).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${N(t+1,n)}caveats = [${e.caveats.map(V).join(", ")}]`),e.examples&&e.examples.length>0&&r.push(`${N(t+1,n)}examples = [${O0(e.examples)}]`),e.invariants&&e.invariants.length>0&&r.push(`${N(t+1,n)}invariants = [${e.invariants.map(V).join(", ")}]`),e.blockType==="semantic"){const o=e.metricsRef??(e.metricRef!==void 0?[e.metricRef]:[]);r.push(`${N(t+1,n)}metrics = [${o.map(V).join(", ")}]`),r.push(`${N(t+1,n)}dimensions = [${(e.dimensionsRef??[]).map(V).join(", ")}]`),e.timeDimension&&r.push(`${N(t+1,n)}time_dimension = ${V(e.timeDimension)}`),e.granularity&&r.push(`${N(t+1,n)}granularity = ${V(e.granularity)}`),e.requestedFilters&&e.requestedFilters.length>0&&r.push(`${N(t+1,n)}requested_filters = [${e.requestedFilters.map(V).join(", ")}]`),e.orderBy&&e.orderBy.length>0&&r.push(`${N(t+1,n)}order_by = [${e.orderBy.map(V).join(", ")}]`),e.limit!==void 0&&r.push(`${N(t+1,n)}limit = ${e.limit}`)}if(e.params){r.push(`${N(t+1,n)}params {`);for(const o of e.params.params){const i=o.paramType?`: ${o.paramType}`:"",c=o.initializer?` = ${Ot(o.initializer)}`:"";r.push(`${N(t+2,n)}${o.name}${i}${c}`)}r.push(`${N(t+1,n)}}`)}if(e.query&&(r.push(`${N(t+1,n)}query = """`),r.push(..._p(e.query,t+2,n)),r.push(`${N(t+1,n)}"""`)),e.visualization){r.push(`${N(t+1,n)}visualization {`);for(const o of e.visualization.properties)r.push(`${N(t+2,n)}${Pa(o)}`);r.push(`${N(t+1,n)}}`)}if(e.tests&&e.tests.length>0){r.push(`${N(t+1,n)}tests {`);for(const o of e.tests)r.push(`${N(t+2,n)}assert ${o.field} ${o.operator} ${Ot(o.expected)}`);r.push(`${N(t+1,n)}}`)}return r.push(`${N(t,n)}}`),r.join(`
|
|
425
|
+
`)}function T0(e,t,n){var o,i,c,a,l,u,h,d;const r=[];return r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}domain ${V(e.name)} {`),e.id&&r.push(`${N(t+1,n)}id = ${V(e.id)}`),e.parent&&r.push(`${N(t+1,n)}parent = ${V(e.parent)}`),e.owner&&r.push(`${N(t+1,n)}owner = ${V(e.owner)}`),e.businessOwner&&r.push(`${N(t+1,n)}businessOwner = ${V(e.businessOwner)}`),e.boundedContext&&r.push(`${N(t+1,n)}boundedContext = ${V(e.boundedContext)}`),e.sourceSystems&&e.sourceSystems.length>0&&r.push(`${N(t+1,n)}sourceSystems = [${e.sourceSystems.map(V).join(", ")}]`),e.primaryTerms&&e.primaryTerms.length>0&&r.push(`${N(t+1,n)}primaryTerms = [${e.primaryTerms.map(V).join(", ")}]`),e.reviewCadence&&r.push(`${N(t+1,n)}reviewCadence = ${V(e.reviewCadence)}`),e.tags&&e.tags.length>0&&r.push(`${N(t+1,n)}tags = [${e.tags.map(V).join(", ")}]`),e.businessOutcome&&r.push(`${N(t+1,n)}businessOutcome = ${V(e.businessOutcome)}`),e.description&&r.push(`${N(t+1,n)}description = ${V(e.description)}`),(o=e.inScope)!=null&&o.length&&r.push(`${N(t+1,n)}inScope = [${e.inScope.map(V).join(", ")}]`),(i=e.outOfScope)!=null&&i.length&&r.push(`${N(t+1,n)}outOfScope = [${e.outOfScope.map(V).join(", ")}]`),(c=e.dbtGroups)!=null&&c.length&&r.push(`${N(t+1,n)}dbtGroups = [${e.dbtGroups.map(V).join(", ")}]`),(a=e.dbtPaths)!=null&&a.length&&r.push(`${N(t+1,n)}dbtPaths = [${e.dbtPaths.map(V).join(", ")}]`),(l=e.dbtTags)!=null&&l.length&&r.push(`${N(t+1,n)}dbtTags = [${e.dbtTags.map(V).join(", ")}]`),(u=e.semanticDomains)!=null&&u.length&&r.push(`${N(t+1,n)}semanticDomains = [${e.semanticDomains.map(V).join(", ")}]`),(h=e.semanticTags)!=null&&h.length&&r.push(`${N(t+1,n)}semanticTags = [${e.semanticTags.map(V).join(", ")}]`),(d=e.exports)!=null&&d.length&&r.push(`${N(t+1,n)}exports = [${e.exports.map(V).join(", ")}]`),r.push(`${N(t,n)}}`),r.join(`
|
|
426
|
+
`)}function A0(e,t,n){const r=[];return r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}term ${V(e.name)} {`),e.domain&&r.push(`${N(t+1,n)}domain = ${V(e.domain)}`),e.termType&&r.push(`${N(t+1,n)}type = ${V(e.termType)}`),e.status&&r.push(`${N(t+1,n)}status = ${V(e.status)}`),e.description&&r.push(`${N(t+1,n)}description = ${V(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${N(t+1,n)}tags = [${e.tags.map(V).join(", ")}]`),e.owner&&r.push(`${N(t+1,n)}owner = ${V(e.owner)}`),e.identifiers&&e.identifiers.length>0&&r.push(`${N(t+1,n)}identifiers = [${e.identifiers.map(V).join(", ")}]`),e.synonyms&&e.synonyms.length>0&&r.push(`${N(t+1,n)}synonyms = [${e.synonyms.map(V).join(", ")}]`),e.businessOutcome&&r.push(`${N(t+1,n)}businessOutcome = ${V(e.businessOutcome)}`),e.businessOwner&&r.push(`${N(t+1,n)}businessOwner = ${V(e.businessOwner)}`),e.decisionUse&&r.push(`${N(t+1,n)}decisionUse = ${V(e.decisionUse)}`),e.reviewCadence&&r.push(`${N(t+1,n)}reviewCadence = ${V(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${N(t+1,n)}businessRules = [${e.businessRules.map(V).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${N(t+1,n)}caveats = [${e.caveats.map(V).join(", ")}]`),r.push(`${N(t,n)}}`),r.join(`
|
|
427
|
+
`)}function R0(e,t,n){const r=[];r.push(...jn(e.decorators,t,n)),r.push(`${N(t,n)}business_view ${V(e.name)} {`),e.domain&&r.push(`${N(t+1,n)}domain = ${V(e.domain)}`),e.status&&r.push(`${N(t+1,n)}status = ${V(e.status)}`),e.description&&r.push(`${N(t+1,n)}description = ${V(e.description)}`),e.tags&&e.tags.length>0&&r.push(`${N(t+1,n)}tags = [${e.tags.map(V).join(", ")}]`),e.owner&&r.push(`${N(t+1,n)}owner = ${V(e.owner)}`),e.termRefs&&e.termRefs.length>0&&r.push(`${N(t+1,n)}terms = [${e.termRefs.map(V).join(", ")}]`),e.businessOutcome&&r.push(`${N(t+1,n)}businessOutcome = ${V(e.businessOutcome)}`),e.businessOwner&&r.push(`${N(t+1,n)}businessOwner = ${V(e.businessOwner)}`),e.decisionUse&&r.push(`${N(t+1,n)}decisionUse = ${V(e.decisionUse)}`),e.reviewCadence&&r.push(`${N(t+1,n)}reviewCadence = ${V(e.reviewCadence)}`),e.businessRules&&e.businessRules.length>0&&r.push(`${N(t+1,n)}businessRules = [${e.businessRules.map(V).join(", ")}]`),e.caveats&&e.caveats.length>0&&r.push(`${N(t+1,n)}caveats = [${e.caveats.map(V).join(", ")}]`),r.push(`${N(t+1,n)}includes {`);for(const o of e.includes)r.push(`${N(t+2,n)}${o.refType} ${V(o.name)}`);return r.push(`${N(t+1,n)}}`),r.push(`${N(t,n)}}`),r.join(`
|
|
428
|
+
`)}function _p(e,t,n){const r=e.rawSQL.replace(/^\n+|\s+$/g,"");if(!r.trim())return[`${N(t,n)}SELECT 1`];const o=r.split(`
|
|
429
|
+
`).map(l=>l.trimEnd()),i=o.slice(1).filter(l=>l.length>0),c=i.length?i:o.filter(l=>l.length>0),a=c.length?Math.min(...c.map(l=>l.match(/^[ \t]*/)[0].length)):0;return o.map(l=>{if(l.length===0)return"";const u=l.startsWith(" ".repeat(a))||l.startsWith(" ".repeat(a))?l.slice(a):l.trimStart();return`${N(t,n)}${u}`})}function Pa(e){return`${e.name} = ${Ot(e.value)}`}function O0(e){return e.map(t=>{const n=[`question = ${V(t.question)}`];return t.sql&&n.push(`sql = ${V(t.sql)}`),`{ ${n.join(", ")} }`}).join(", ")}function Ot(e){switch(e.kind){case Q.StringLiteral:return V(e.value);case Q.NumberLiteral:return String(e.value);case Q.BooleanLiteral:return e.value?"true":"false";case Q.Identifier:return e.name;case Q.ArrayLiteral:return`[${e.elements.map(t=>Ot(t)).join(", ")}]`;case Q.BinaryExpr:return`${Ot(e.left)} ${e.operator} ${Ot(e.right)}`;case Q.IntervalExpr:return`INTERVAL ${V(e.value)}`;case Q.FunctionCall:return`${e.callee}(${e.arguments.map(t=>Ot(t)).join(", ")})`;case Q.TemplateString:return V(e.parts.map(t=>typeof t=="string"?t:`{${Ot(t)}}`).join(""));default:return""}}function V(e){return JSON.stringify(e)}function _0(e){var u,h,d,f,m,S,v,b;const t=Lr(e.metrics),n=Lr(e.dimensions??[]),r=Lr(e.requestedFilters??[]),o=Lr((e.orderBy??[]).map(w=>typeof w=="string"?w:`${w.name} ${w.direction}`)),i=I0(e.parameters??[]),c=[`block ${ze(e.name)} {`,' type = "semantic"',` status = ${ze(((u=e.status)==null?void 0:u.trim())||"draft")}`],a=P0(e.domain);a&&c.push(` domain = ${ze(a)}`),(h=e.description)!=null&&h.trim()&&c.push(` description = ${ze(e.description.trim())}`);const l=Lr(e.tags??[]);if(l.length>0&&c.push(` tags = [${l.map(ze).join(", ")}]`),(d=e.owner)!=null&&d.trim()&&c.push(` owner = ${ze(e.owner.trim())}`),c.push(` metrics = [${t.map(ze).join(", ")}]`),c.push(` dimensions = [${n.map(ze).join(", ")}]`),(f=e.timeDimension)!=null&&f.name.trim()&&(c.push(` time_dimension = ${ze(e.timeDimension.name.trim())}`),e.timeDimension.granularity.trim()&&c.push(` granularity = ${ze(e.timeDimension.granularity.trim())}`)),r.length>0&&c.push(` requested_filters = [${r.map(ze).join(", ")}]`),o.length>0&&c.push(` order_by = [${o.map(ze).join(", ")}]`),D0(e.limit)&&c.push(` limit = ${Math.floor(e.limit)}`),i.length>0){c.push(" params {");for(const C of i){const x=(m=C.type)!=null&&m.trim()?`: ${C.type.trim()}`:"",E=C.default!==void 0?` = ${Pp(C.default)}`:"";c.push(` ${C.name}${x}${E}`)}c.push(" }");const w=i.filter(C=>{var x;return(x=C.policy)==null?void 0:x.trim()});if(w.length>0){c.push(" parameterPolicy {");for(const C of w)c.push(` ${C.name} = ${ze(C.policy.trim())}`);c.push(" }")}const j=i.filter(C=>{var x;return(x=C.binding)==null?void 0:x.trim()});if(j.length>0){c.push(" filterBindings {");for(const C of j)c.push(` ${C.name} = ${ze(C.binding.trim())}`);c.push(" }")}}return(S=e.visualization)!=null&&S.chart.trim()&&(c.push(" visualization {"),c.push(` chart = ${ze(e.visualization.chart.trim())}`),(v=e.visualization.x)!=null&&v.trim()&&c.push(` x = ${nl(e.visualization.x.trim())}`),(b=e.visualization.y)!=null&&b.trim()&&c.push(` y = ${nl(e.visualization.y.trim())}`),c.push(" }")),c.push("}"),p0(`${c.join(`
|
|
430
|
+
`)}
|
|
431
|
+
`)}function P0(e){const t=e==null?void 0:e.trim();if(!(!t||t==="uncategorized"||t==="_uncategorized"))return t}function Lr(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}function I0(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 D0(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Pp(e){return Array.isArray(e)?`[${e.map(Pp).join(", ")}]`:typeof e=="number"&&Number.isFinite(e)?String(e):typeof e=="boolean"?e?"true":"false":ze(String(e??""))}function ze(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function nl(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)?e:ze(e)}function $0(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 _0({name:i,status:"draft",metrics:n,dimensions:r}).trimEnd()}function M0(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 L0(e,t){var o;const n={path:"",folders:new Map,blocks:[]};for(const i of e){const c=((o=i.domain)==null?void 0:o.trim())||"uncategorized",l=M0(i.path,t||c).split("/").filter(Boolean),u=t?l.slice(0,-1):[c,...l.slice(0,-1)];let h=n;for(const d of u){const f=[h.path,d].filter(Boolean).join("/");let m=h.folders.get(d);m||(m={name:d,path:f,folders:new Map,blocks:[]},h.folders.set(d,m)),h=m}h.blocks.push(i)}const r=i=>[...Array.from(i.folders.values()).sort((c,a)=>c.name.localeCompare(a.name)).map(c=>({kind:"folder",name:c.name,path:c.path,children:r(c)})),...i.blocks.sort((c,a)=>c.name.localeCompare(a.name)).map(c=>({kind:"block",block:c}))];return r(n)}function N0(e,t){const n={path:"",folders:new Map,files:[]};for(const o of e){const i=B0(o,t);let c=n;for(const a of i){const l=[c.path,a].filter(Boolean).join("/");let u=c.folders.get(a);u||(u={name:a,path:l,folders:new Map,files:[]},c.folders.set(a,u)),c=u}c.files.push(o)}const r=o=>[...Array.from(o.folders.values()).sort((i,c)=>i.name.localeCompare(c.name)).map(i=>({kind:"folder",name:i.name,path:i.path,children:r(i)})),...o.files.sort((i,c)=>i.name.localeCompare(c.name)).map(i=>({kind:"file",file:i}))];return r(n)}function B0(e,t){const n=e.path.replace(/\\/g,"/").split("/").filter(Boolean);if(n[0]==="domains"){const i=["notebooks","workbooks"],c=n.findIndex((a,l)=>l>0&&i.includes(a));if(c>0)return["Domains",...n.slice(1,c),...n.slice(c+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(c=>c.trim()).filter(Boolean),...o]:["Project",...o]}function Ip({id:e,ariaLabel:t,value:n,options:r,onChange:o,summary:i,t:c}){return s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${c.headerBorder}`,display:"grid",gap:5},children:[s.jsx("label",{htmlFor:e,style:{color:c.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:c.inputBg,border:`1px solid ${c.inputBorder}`,borderRadius:6,color:c.textPrimary,fontFamily:c.font,fontSize:12,padding:"7px 8px"},children:[s.jsx("option",{value:"",children:"All domains"}),r.map(a=>{const l=typeof a=="string"?{value:a,label:a}:a;return s.jsx("option",{value:l.value,children:l.label??l.value},l.value)})]}),i!==void 0?s.jsx("span",{style:{color:c.textMuted,fontSize:10},children:i}):null]})}function F0(e,t){const n=wo(t),r=e.some(o=>o.type!=="notebook"?!1:![o.ownerDomain,...o.usesDomains??[]].map(c=>c==null?void 0:c.trim()).filter(c=>!!c).some(c=>n.has(c)));return[...Qn(t).map(o=>o.value),...r?["uncategorized"]:[]]}function rl(e,t,n="",r=[]){const o=t.trim().toLowerCase(),i=wo(r);return Array.from(new Map(e.filter(c=>c.type==="notebook").map(c=>[c.path,c])).values()).filter(c=>{var u,h;const a=[c.ownerDomain,...c.usesDomains??[]].map(d=>d==null?void 0:d.trim()).filter(d=>!!d);return(!n||(n==="uncategorized"?!a.some(d=>i.has(d)):i.has(n)&&a.includes(n)))&&(!o||c.name.toLowerCase().includes(o)||c.path.toLowerCase().includes(o)||((u=c.ownerDomain)==null?void 0:u.toLowerCase().includes(o))||((h=c.usesDomains)==null?void 0:h.some(d=>d.toLowerCase().includes(o))))}).sort((c,a)=>c.name.localeCompare(a.name))}const Js=25;function ol(e){var t;return!!((t=e.relation)!=null&&t.trim())}function sl(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:K0(e.binding.status)}:void 0}}function z0(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 q0(e,t){const n=new Map(t.map(i=>[i.name.toLowerCase(),i])),r=e.columns.map(i=>{var c;return{name:i.name,type:i.type??((c=n.get(i.name.toLowerCase()))==null?void 0:c.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 U0(e){return e.split(".").filter(Boolean).at(-1)??e}function W0(e){const t=e.split(".").filter(Boolean);return t.length>1?t.slice(0,-1).join("."):""}function K0(e){if(e==="draft"||e==="review"||e==="certified"||e==="deprecated"||e==="pending_recertification")return e}function V0({t:e,search:t,onInsert:n}){const{dispatch:r}=et(),[o,i]=p.useState([]),[c,a]=p.useState(0),[l,u]=p.useState(null),[h,d]=p.useState(!0),[f,m]=p.useState(!1),[S,v]=p.useState(null),[b,w]=p.useState(new Set),[j,C]=p.useState(new Set),[x,E]=p.useState(new Set),[P,A]=p.useState({}),g=p.useRef(0),I=t.trim();p.useEffect(()=>{const _=++g.current,M=window.setTimeout(()=>{d(!0),v(null),B.getDbtModelInventory({q:I,limit:Js,physicalOnly:!0}).then(q=>{if(_!==g.current)return;const G=q.items.filter(ol).map(sl);i(G),a(q.total),u(q.nextCursor),w(new Set),C(new Set),A({}),r({type:"MERGE_SCHEMA_TABLES",tables:G})}).catch(q=>{_===g.current&&(i([]),a(0),u(null),v(q instanceof Error?q:new Error(String(q))))}).finally(()=>{_===g.current&&d(!1)})},180);return()=>window.clearTimeout(M)},[r,I]);const T=async()=>{if(l===null||f)return;const _=g.current;m(!0);try{const M=await B.getDbtModelInventory({q:I,cursor:l,limit:Js,physicalOnly:!0});if(_!==g.current)return;const q=M.items.filter(ol).map(sl);i(G=>z0(G,q)),a(M.total),u(M.nextCursor),r({type:"MERGE_SCHEMA_TABLES",tables:q})}catch(M){_===g.current&&v(M instanceof Error?M:new Error(String(M)))}finally{_===g.current&&m(!1)}},O=async _=>{const M=!b.has(_.dbtUniqueId);if(w(q=>{const G=new Set(q);return M?G.add(_.dbtUniqueId):G.delete(_.dbtUniqueId),G}),!(!M||j.has(_.dbtUniqueId)||x.has(_.dbtUniqueId))){E(q=>new Set(q).add(_.dbtUniqueId)),A(q=>{const G={...q};return delete G[_.dbtUniqueId],G});try{const q=await B.getDbtModelingNode(_.dbtUniqueId),J=q.columns.length===0||q.columns.some($=>!$.type)?await B.describeTable(_.path):[],H=q0(q,J),L={..._,columns:H};i($=>$.map(X=>X.dbtUniqueId===_.dbtUniqueId?L:X)),C($=>new Set($).add(_.dbtUniqueId)),r({type:"MERGE_SCHEMA_TABLES",tables:[L]})}catch(q){A(G=>({...G,[_.dbtUniqueId]:q instanceof Error?q.message:String(q)}))}finally{E(q=>{const G=new Set(q);return G.delete(_.dbtUniqueId),G})}}};return h?s.jsxs(sr,{t:e,children:[s.jsx(qn,{size:13,className:"dql-spin"})," Loading dbt database objects…"]}):S?s.jsx(H0,{error:S,t:e}):o.length===0?s.jsx(sr,{t:e,children:I?`No dbt models or sources match “${I}”.`:"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 ",c.toLocaleString()," object",c===1?"":"s"]}),o.map(_=>{const M=b.has(_.dbtUniqueId),q=x.has(_.dbtUniqueId),G=P[_.dbtUniqueId],J=U0(_.path),H=W0(_.path);return s.jsxs("div",{children:[s.jsxs("div",{style:{...il(e),alignItems:"flex-start"},children:[s.jsx("button",{type:"button",onClick:()=>void O(_),"aria-label":`${M?"Collapse":"Expand"} ${J}`,title:M?"Collapse columns":"Load columns",style:G0(e),children:M?s.jsx(Ta,{size:13}):s.jsx(Rs,{size:13})}),s.jsxs("button",{type:"button",onClick:()=>n(`SELECT * FROM ${_.path} LIMIT 100`),title:`Insert a bounded SELECT from ${_.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(So,{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:J}),s.jsx("span",{style:{fontSize:8.5,color:e.textMuted,textTransform:"uppercase",letterSpacing:".04em",flexShrink:0},children:_.dbtResourceType}),j.has(_.dbtUniqueId)?s.jsx("span",{style:{fontSize:10,color:e.textMuted,flexShrink:0},children:_.columns.length}):null]}),H?s.jsx("span",{style:{paddingLeft:19,color:e.textMuted,fontSize:9.5,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H}):null]})]}),M?s.jsxs("div",{children:[q?s.jsxs(sr,{t:e,compact:!0,children:[s.jsx(qn,{size:11,className:"dql-spin"})," Loading columns…"]}):null,!q&&G?s.jsx(sr,{t:e,compact:!0,children:"Columns unavailable. The relation can still be inserted and queried."}):null,!q&&!G&&j.has(_.dbtUniqueId)&&_.columns.length===0?s.jsx(sr,{t:e,compact:!0,children:"No columns are documented in dbt or visible from the selected connection."}):null,!q&&_.columns.map(L=>s.jsxs("button",{type:"button",onClick:()=>n(L.name),title:`Insert column ${L.name}`,style:{...il(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:L.name}),s.jsx("span",{style:{fontSize:9.5,color:e.textMuted,flexShrink:0,fontFamily:e.fontMono},children:L.type||"unknown"})]},L.name))]}):null]},_.dbtUniqueId)}),l!==null?s.jsx("button",{type:"button",onClick:()=>void T(),disabled:f,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:f?"wait":"pointer",fontSize:10.5,fontFamily:e.font},children:f?"Loading…":`Load ${Math.min(Js,c-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 H0({error:e,t}){const n=e instanceof xt?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(sr,{t,children:r})}function sr({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 il=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}),G0=e=>({border:"none",background:"transparent",cursor:"pointer",color:e.textMuted,display:"flex",padding:"1px 0 0",flexShrink:0}),Q0=[{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 st(e){return String(e??"").trim()||"uncategorized"}function At(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 J0(e,t){return String((t==="dimension"||t==="time_dimension")&&e.reference||e.name)}function Y0(e,t,n){const r=J0(e,t),o=st(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)}:{},...At(e).length>0?{semanticModelIds:At(e).join(",")}:{},...e.owner?{owner:String(e.owner)}:{},...Array.isArray(e.tags)&&e.tags.length>0?{tags:e.tags.join(",")}:{}}}}function Kt(e,t,n,r,o){if(r.length===0)return null;const i=r.map(c=>Y0(c,n,o)).sort((c,a)=>c.label.localeCompare(a.label)||c.id.localeCompare(a.id));return{id:e,label:t,kind:"group",count:i.length,meta:{provider:o,objectKind:n},children:i}}function cr(e){var t;return(t=e.children)!=null&&t.length?e.children.reduce((n,r)=>n+cr(r),0):1}function X0(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(u=>[u.name,u])),o=new Set(e.semanticModels.map(u=>u.name));for(const u of n)for(const h of At(u))o.add(h);const i=u=>{const h=r.get(u);if(h)return st(h.domain);const d=n.find(f=>At(f).includes(u));return st(d==null?void 0:d.domain)},c=new Set([...e.domains.map(st),...e.semanticModels.map(u=>st(u.domain)),...n.map(u=>st(u.domain))]),a=Array.from(c).sort((u,h)=>u.localeCompare(h)).flatMap(u=>{const d=Array.from(o).filter(x=>i(x)===u).sort((x,E)=>x.localeCompare(E)).flatMap(x=>{const E=r.get(x),P=Q0.flatMap(({collection:g,kind:I,label:T})=>{const O=e[g].filter(M=>{const q=At(M);return q.length===1&&q[0]===x&&(g!=="dimensions"||!M.isTimeDimension)}),_=Kt(`group:${u}:${x}:${I}`,T,I,O,t);return _?[_]:[]});return P.length===0&&!E?[]:[{id:`semantic_model:${x}`,label:(E==null?void 0:E.label)||x,kind:"semantic_model",count:P.reduce((g,I)=>g+cr(I),0),meta:{provider:t,domain:u,cube:x,...E!=null&&E.table?{table:E.table}:{},...E!=null&&E.owner?{owner:E.owner}:{}},children:P}]}),f=e.metrics.filter(x=>st(x.domain)===u&&At(x).length>1),m=e.metrics.filter(x=>st(x.domain)===u&&At(x).length===0),S=[Kt(`group:${u}:unassigned-dimensions`,"Dimensions","dimension",e.dimensions.filter(x=>st(x.domain)===u&&At(x).length===0&&!x.isTimeDimension),t),Kt(`group:${u}:unassigned-time-dimensions`,"Time Dimensions","time_dimension",e.timeDimensions.filter(x=>st(x.domain)===u&&At(x).length===0),t),Kt(`group:${u}:unassigned-measures`,"Underlying measures","measure",e.measures.filter(x=>st(x.domain)===u&&At(x).length===0),t),Kt(`group:${u}:unassigned-entities`,"Entities","entity",e.entities.filter(x=>st(x.domain)===u&&At(x).length===0),t)].filter(x=>!!x),v=[...d],b=Kt(`group:${u}:cross-model-metrics`,"Cross-model metrics","metric",f,t);b&&v.push(b);const w=Kt(`group:${u}:unassigned-metrics`,"Unassigned metrics","metric",m,t);w&&v.push(w),S.length>0&&v.push({id:`group:${u}:unassigned-objects`,label:"Unassigned objects",kind:"group",count:S.reduce((x,E)=>x+cr(E),0),meta:{provider:t,domain:u},children:S});const j=Kt(`group:${u}:hierarchies`,"Hierarchies","hierarchy",e.hierarchies.filter(x=>st(x.domain)===u),t);j&&v.push(j);const C=Kt(`group:${u}:saved-queries`,"Saved Queries","saved_query",e.savedQueries.filter(x=>st(x.domain)===u),t);return C&&v.push(C),v.length===0?[]:[{id:`domain:${t}:${u}`,label:u,kind:"domain",count:v.reduce((x,E)=>x+cr(E),0),meta:{provider:t,domain:u},children:v}]});if(a.length===0)return null;const l=a.flatMap(u=>u.label==="uncategorized"?u.children??[]:[u]);return{id:"root:semantic",label:"Semantic Layer",kind:"group",children:[{id:`provider:${t}`,label:t.toUpperCase(),kind:"provider",count:l.reduce((u,h)=>u+cr(h),0),meta:{provider:t},children:l}]}}function Z0(e,t,n,r){const o=i=>{var a,l;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 u=String(((l=i.meta)==null?void 0:l.reference)||i.id.slice(i.id.indexOf(":")+1));return n.has(u)?{...i}:null}return null}const c=i.children.map(o).filter(u=>!!u);return c.length===0?null:{...i,count:c.reduce((u,h)=>u+cr(h),0),children:c}};return o(e)??{...e,children:[]}}const al=[{id:"notebooks",label:"Notebooks",icon:Aa},{id:"semantic",label:"Semantic",icon:mp},{id:"database",label:"Database",icon:So},{id:"blocks",label:"Blocks",icon:Ea}],ek={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 tk({defaultTab:e,onOpenFile:t,tabs:n,onInsertText:r,onSemanticCompose:o,blockDomain:i="",onBlockDomainChange:c,onNewBlock:a,onOpenBlock:l,onDeleteBlock:u,blockLibraryRefreshKey:h=0,footer:d,footerStatus:f="ready",onCollapse:m}){var I;const{state:S,dispatch:v}=et(),b=Qe[S.themeMode],w=n?n.map(T=>al.find(O=>O.id===T)).filter(T=>!!T):al,[j,C]=p.useState(e??((I=w[0])==null?void 0:I.id)??"notebooks"),[x,E]=p.useState(""),[P,A]=p.useState("");p.useEffect(()=>{e&&C(e)},[e]);const g=r??(T=>{qw(T)||v({type:"ADD_CELL",cell:ja("sql",T)})});return s.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",minHeight:0,background:b.cellBg,fontFamily:b.font},children:[s.jsxs("div",{style:{display:"flex",gap:2,padding:"6px 6px 0",borderBottom:`1px solid ${b.headerBorder}`},children:[w.map(({id:T,label:O,icon:_})=>{const M=j===T;return s.jsxs("button",{type:"button",onClick:()=>C(T),title:O,style:{flex:w.length>3?"1 1 auto":1,minWidth:0,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5,border:"none",borderBottom:`2px solid ${M?b.accent:"transparent"}`,background:"transparent",color:M?b.accent:b.textMuted,cursor:"pointer",fontSize:11,fontWeight:700,padding:"6px 3px 7px"},children:[s.jsx(_,{size:13,style:{flexShrink:0}}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O})]},T)}),m?s.jsx("button",{type:"button",onClick:m,title:"Collapse explorer",style:{border:"none",background:"transparent",color:b.textMuted,cursor:"pointer",fontSize:13,padding:"0 6px",flexShrink:0},children:"‹"}):null]}),j==="notebooks"?s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${b.headerBorder}`,display:"flex",gap:6},children:[s.jsxs("div",{style:{position:"relative",flex:1},children:[s.jsx(Uc,{size:12,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:b.textMuted}}),s.jsx("input",{value:x,onChange:T=>E(T.target.value),placeholder:"Search notebooks…","aria-label":"Search notebooks",style:{width:"100%",boxSizing:"border-box",background:b.inputBg,border:`1px solid ${b.inputBorder}`,borderRadius:6,color:b.textPrimary,fontSize:12,fontFamily:b.font,padding:"6px 8px 6px 26px",outline:"none"}})]}),s.jsx("button",{type:"button",onClick:()=>v({type:"OPEN_NEW_NOTEBOOK_MODAL"}),title:"Create notebook","aria-label":"Create notebook",style:{width:28,height:28,flexShrink:0,borderRadius:7,border:`1px solid ${b.accent}55`,background:"var(--accent-dim)",color:b.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s.jsx(pS,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}):s.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${b.headerBorder}`,display:"flex",gap:6},children:[s.jsxs("div",{style:{position:"relative",flex:1},children:[s.jsx(Uc,{size:12,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:b.textMuted}}),s.jsx("input",{value:x,onChange:T=>E(T.target.value),placeholder:`Search ${j}…`,style:{width:"100%",boxSizing:"border-box",background:b.inputBg,border:`1px solid ${b.inputBorder}`,borderRadius:6,color:b.textPrimary,fontSize:12,fontFamily:b.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 ${b.btnBorder}`,background:b.btnBg,color:b.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s.jsx(wS,{size:14,strokeWidth:2})}):null]}),s.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:[j==="notebooks"&&t&&s.jsx(nk,{t:b,onOpenFile:t,search:x,domain:P,onDomainChange:A}),j==="semantic"&&s.jsx(ik,{t:b,search:x,onInsert:g,notebookMode:!r||!!o,onSemanticCompose:o}),j==="database"&&s.jsx(V0,{t:b,search:x,onInsert:g}),j==="blocks"&&s.jsx(ak,{t:b,search:x,domain:i,onDomainChange:c,onOpenBlock:l,onDeleteBlock:u,refreshKey:h})]}),d?s.jsxs("div",{style:{padding:"9px 12px",borderTop:`1px solid ${b.headerBorder}`,fontSize:10.5,color:b.textMuted,display:"flex",alignItems:"center",gap:6,fontFamily:b.font},children:[s.jsx("span",{style:{width:6,height:6,borderRadius:999,background:f==="ready"?"var(--status-success)":"var(--status-warning)",flexShrink:0}}),s.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d})]}):null]})}const Dp=(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 ur({text:e,t}){return s.jsx("div",{style:{padding:"16px 12px",fontSize:11.5,color:t.textMuted,textAlign:"center"},children:e})}function nk({t:e,onOpenFile:t,search:n,domain:r,onDomainChange:o}){var P;const{state:i,dispatch:c}=et(),[a,l]=p.useState(null),[u,h]=p.useState(!1),[d,f]=p.useState(null),m=F0(i.files,i.authoredDomains),S=m.includes(r)?r:"",b=[...Qn(i.authoredDomains).filter(A=>m.includes(A.value)),...m.includes("uncategorized")?[{value:"uncategorized",label:"Unassigned"}]:[]],w=rl(i.files,"",S,i.authoredDomains),j=rl(i.files,n,S,i.authoredDomains),C=N0(j,"notebooks"),x=S==="uncategorized"?"unassigned":S||"all domains",E=async()=>{if(a){h(!0),f(null);try{const A=await B.deleteNotebook(a.path);if(!A.ok){f(A.error??"Could not delete this notebook.");return}c({type:"FILE_REMOVED",path:a.path}),l(null)}catch(A){f(A instanceof Error?A.message:String(A))}finally{h(!1)}}};return s.jsxs("div",{children:[s.jsx(Ip,{id:"notebook-domain-filter",ariaLabel:"Notebook domain",value:S,options:b,onChange:o,summary:s.jsxs(s.Fragment,{children:[j.length," notebook",j.length===1?"":"s"," · ",x]}),t:e}),j.length===0?s.jsx(ur,{text:w.length===0?S?`No notebooks are related to ${x} yet.`:"No notebooks yet. Use the notebook icon above to create one.":`No ${x} notebooks match “${n.trim()}”.`,t:e}):s.jsx($p,{nodes:C,activePath:(P=i.activeFile)==null?void 0:P.path,onOpenFile:t,onDelete:A=>{f(null),l(A)},t:e}),s.jsx("style",{children:`
|
|
432
|
+
.dql-nb-delete { opacity: 0; transition: opacity .12s, color .12s, background .12s, border-color .12s; }
|
|
433
|
+
.dql-nb-row:hover .dql-nb-delete { opacity: 1; }
|
|
434
|
+
.dql-nb-delete:hover { color: ${e.error} !important; background: ${e.error}12 !important; border-color: ${e.error}44 !important; }
|
|
435
|
+
.dql-nb-delete:focus-visible { opacity: 1; }
|
|
436
|
+
`}),a?s.jsx(sk,{file:a,t:e,busy:u,error:d,onCancel:()=>{l(null),f(null)},onConfirm:()=>void E()}):null]})}function $p({nodes:e,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i=0}){return s.jsx(s.Fragment,{children:e.map(c=>c.kind==="folder"?s.jsx(rk,{node:c,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i},`notebook-folder:${c.path}`):s.jsx(ok,{file:c.file,active:t===c.file.path,onOpenFile:n,onDelete:r,t:o,depth:i},c.file.path))})}function rk({node:e,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i}){const[c,a]=p.useState(!0);return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>a(l=>!l),"aria-expanded":c,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(Rs,{size:11,style:{transform:c?"rotate(90deg)":void 0,flexShrink:0}}),c?s.jsx(hp,{size:13}):s.jsx(Yr,{size:13}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]}),c?s.jsx($p,{nodes:e.children,activePath:t,onOpenFile:n,onDelete:r,t:o,depth:i+1}):null]})}function ok({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:{...Dp(o,t),paddingLeft:10+i*14,paddingRight:30},title:`${e.path}${e.ownerDomain?` · Owner domain: ${e.ownerDomain}`:""}`,children:[s.jsx(Aa,{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:c=>{c.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(yp,{size:12})})]})}function sk({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:c=>c.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:Re(t,{variant:"secondary",size:"md",disabled:n}),children:"Cancel"}),s.jsx("button",{type:"button",onClick:i,disabled:n,style:Re(t,{variant:"danger",size:"md",disabled:n}),children:n?"Deleting…":"Delete notebook"})]})]})})}function ik({t:e,search:t,onInsert:n,notebookMode:r,onSemanticCompose:o}){var X;const{state:i,dispatch:c}=et(),a=p.useMemo(()=>X0(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]),l=i.semanticLayer.loading,[u,h]=p.useState(new Set),[d,f]=p.useState(new Set),[m,S]=p.useState(null),[v,b]=p.useState("idle"),[w,j]=p.useState(null),[C,x]=p.useState(!1),[E,P]=p.useState(null),[A,g]=p.useState(null),[I,T]=p.useState(),O=new Map(i.semanticLayer.metrics.map(W=>[W.name,W])),_=()=>{c({type:"SET_SETTINGS_TAB",tab:"project"}),c({type:"SET_MAIN_VIEW",view:"settings"})};p.useEffect(()=>{let W=!0;return B.getConnections().then(te=>{W&&T(te.default?{target:"connection",connectionName:te.default}:void 0)}).catch(()=>{W&&T(void 0)}),()=>{W=!1}},[]),p.useEffect(()=>{let W=!0;if(P(null),g(null),u.size===0){S(null),b("idle"),j(null),f(new Set);return}return S(null),b("loading"),j(null),B.getCompatibility(Array.from(u)).then(te=>{if(!W)return;const F=new Set(te.dimensions.map(K=>K.reference??K.name));S(F),b("ready"),j(te.engine),f(K=>new Set(Array.from(K).filter(oe=>F.has(oe))))}).catch(te=>{W&&(S(new Set),b("error"),j(null),f(new Set),g(te instanceof xt?`${te.code?`${te.code}: `:""}${te.message}`:te instanceof Error?te.message:"Semantic compatibility could not be verified."))}),()=>{W=!1}},[Array.from(u).sort().join("|")]);const M=p.useMemo(()=>!a||!r?a:Z0(a,u.size,m,v),[a,r,u.size,m,v]),q=(W,te)=>{P(null),g(null),(W==="metric"?h:f)(K=>{const oe=new Set(K);return oe.has(te)?oe.delete(te):oe.add(te),oe})},G=(W,te)=>{var F;if(W==="metric"){const K=(F=O.get(te))==null?void 0:F.execution;return K&&K.status!=="ready"?{allowed:!1,reason:K.reason||"This metric requires semantic runtime setup."}:{allowed:!0}}return u.size===0?{allowed:!1,reason:"Select a metric first."}:m?m.has(te)?{allowed:!0}:{allowed:!1,reason:"This dimension has no governed join path to every selected metric."}:{allowed:!1,reason:"Checking compatibility…"}},J=new Set([...Array.from(u).map(W=>`metric:${W}`),...Array.from(d).map(W=>`dimension:${W}`)]),H=u.size>0&&v==="ready"&&!C,L=async()=>{if(u.size!==0){x(!0),g(null);try{const W=await B.previewSemanticBuilder({metrics:Array.from(u),dimensions:Array.from(d),executionTarget:I,limit:50});if("error"in W){P(null),g(W.error);return}P({sql:W.sql,rows:W.result.rowCount??W.result.rows.length,executionTarget:I,engine:W.engine})}catch(W){P(null),g(W instanceof xt?`${W.code?`${W.code}: `:""}${W.message}`:W instanceof Error?W.message:"The governed semantic preview could not run.")}finally{x(!1)}}},$=()=>{if(!H)return;const W=Array.from(u),te=Array.from(d);if(o){o(W,te),h(new Set),f(new Set),P(null),g(null);return}const F=$0(W,te),K=ja("dql",F);K.executionTarget=(E==null?void 0:E.executionTarget)??I,K.dqlArtifact={source:F,kind:"semantic_block",metrics:W,dimensions:te,persistence:"transient",trustState:"governed",reviewState:"draft",routeEvidence:[{route:"semantic",authoringState:E?"previewed":"selected",compatibilityState:v,...w?{compatibilityEngine:w}:{},...E?{engine:E.engine,executionTarget:E.executionTarget,previewRows:E.rows}:{}}],...E?{sql:E.sql,compiledSql:E.sql}:{}},c({type:"ADD_CELL",cell:K}),h(new Set),f(new Set),P(null),g(null)};return l&&!a?s.jsx(ur,{text:"Loading semantic layer…",t:e}):!a||!M||(((X=a.children)==null?void 0:X.length)??0)===0?s.jsx(ur,{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:u.size===0?"Choose a business metric. Related dimensions appear next.":v==="loading"?"Checking governed dimensions…":v==="ready"?`${u.size>1?"Common governed dimensions":"Governed dimensions"} · ${(m==null?void 0:m.size)??0} available${w?` · ${w}`:""}`:`${u.size} metric${u.size===1?"":"s"} selected`}),s.jsx("button",{type:"button",onClick:()=>void L(),disabled:C||u.size===0,style:{border:`1px solid ${e.btnBorder}`,background:e.btnBg,color:e.textSecondary,borderRadius:5,padding:"4px 7px",fontSize:10,cursor:u.size?"pointer":"not-allowed",opacity:u.size?1:.5},children:C?"Running…":"Preview & run"}),s.jsx("button",{type:"button",onClick:$,disabled:!H,title:H?o?"Apply this governed selection to the Block Studio visual builder":E?"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:H?"pointer":"not-allowed",opacity:H?1:.5},children:o?"Apply to block":"Add to cell"})]}),E&&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 · ",E.rows," row",E.rows===1?"":"s"]}),s.jsx("code",{style:{display:"block",maxHeight:48,overflow:"hidden",whiteSpace:"pre-wrap",fontSize:9,color:e.textMuted},children:E.sql})]}),A&&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:A}),/semantic runtime|MetricFlow/i.test(A)?s.jsx("button",{type:"button",onClick:_,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(W=>W.execution&&W.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:_,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(Qw,{tree:M,themeMode:i.themeMode,search:t,onInsert:n,selectionMode:r,selected:J,onToggleSelection:q,canSelect:G})]})}function ak({t:e,search:t,domain:n,onDomainChange:r,onOpenBlock:o,onDeleteBlock:i,refreshKey:c}){const{state:a,dispatch:l}=et(),[u,h]=p.useState([]),[d,f]=p.useState(!0),[m,S]=p.useState(new Set),v=a.files.filter(g=>g.type==="block").map(g=>g.path).sort().join("|");p.useEffect(()=>{let g=!0;return f(!0),B.getBlockLibrary().then(I=>{g&&h(I.blocks)}).finally(()=>{g&&f(!1)}),()=>{g=!1}},[v,c]);const b=Jw(u,a.authoredDomains),w=b.includes(n)?n:"",C=[...Qn(a.authoredDomains).filter(g=>b.includes(g.value)),...b.includes("uncategorized")?[{value:"uncategorized",label:"Unassigned"}]:[]],x=Yw(u,w,t,a.authoredDomains),E=p.useMemo(()=>L0(x,w),[x,w]),P=w==="uncategorized"?"unassigned":w||"all domains",A=g=>{if(o){o(g);return}const I={name:g.path.split("/").pop()??g.name,path:g.path,type:"block",folder:"blocks"};a.files.some(T=>T.path===g.path)||l({type:"FILE_ADDED",file:I}),B.openBlockStudio(g.path).then(T=>l({type:"OPEN_BLOCK_STUDIO",file:I,payload:T}))};return d?s.jsx(ur,{text:"Loading blocks…",t:e}):u.length===0?s.jsx(ur,{text:"No blocks yet.",t:e}):s.jsxs("div",{children:[s.jsx(Ip,{id:"block-domain-filter",ariaLabel:"Block domain",value:w,options:C,onChange:g=>r==null?void 0:r(g),summary:s.jsxs(s.Fragment,{children:[x.length," block",x.length===1?"":"s"," · ",P]}),t:e}),x.length===0?s.jsx(ur,{text:t?`No ${P} blocks match this search.`:w?`No blocks in ${w} yet.`:"No blocks yet.",t:e}):s.jsx(Mp,{nodes:E,depth:0,expandAll:!!t.trim(),expandedFolders:m,onToggleFolder:g=>S(I=>{const T=new Set(I);return T.has(g)?T.delete(g):T.add(g),T}),onOpen:A,onDelete:i,t:e})]})}function Mp({nodes:e,depth:t,expandAll:n,expandedFolders:r,onToggleFolder:o,onOpen:i,onDelete:c,t:a}){return s.jsx(s.Fragment,{children:e.map(l=>{if(l.kind==="block")return s.jsx(ck,{block:l.block,depth:t,t:a,onOpen:()=>i(l.block),onDelete:c?()=>c(l.block):void 0},l.block.path);const u=n||r.has(l.path);return s.jsxs(qe.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>o(l.path),title:l.path,style:{...Dp(a),paddingLeft:10+t*16,borderBottom:"none",fontWeight:650},children:[u?s.jsx(Ta,{size:13,color:a.textMuted}):s.jsx(Rs,{size:13,color:a.textMuted}),u?s.jsx(hp,{size:14,color:a.accent}):s.jsx(Yr,{size:14,color:a.textMuted}),s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:l.name}),s.jsx("span",{style:{fontSize:10,color:a.textMuted},children:Lp(l.children)})]}),u?s.jsx(Mp,{nodes:l.children,depth:t+1,expandAll:n,expandedFolders:r,onToggleFolder:o,onOpen:i,onDelete:c,t:a}):null]},`folder:${l.path}`)})})}function Lp(e){return e.reduce((t,n)=>t+(n.kind==="block"?1:Lp(n.children)),0)}function ck({block:e,depth:t=0,t:n,onOpen:r,onDelete:o}){const i=String(e.status??"draft"),c=ek[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(Ea,{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:c}}),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(yp,{size:13})}):null]})}const qo=(e,t)=>`https://cdn.simpleicons.org/${e}/${t}`,lk={duckdb:[qo("duckdb","FFF000")],file:[qo("duckdb","FFF000")],snowflake:[qo("snowflake","29B5E8")],databricks:[qo("databricks","FF3621")]},dk={duckdb:"#f4bc00",file:"#f4bc00",snowflake:"#29b5e8",databricks:"#ff3621"};function uk({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 Vr({driver:e,size:t=16,fallbackColor:n}){const r=lk[e]??[],o=n??dk[e]??"#888",[i,c]=p.useState(0);return r.length===0||i>=r.length?s.jsx(uk,{size:t,color:o}):s.jsx("img",{src:r[i],alt:`${e} logo`,width:t,height:t,loading:"lazy",onError:()=>c(i+1),style:{flexShrink:0,display:"block",objectFit:"contain"}})}function pk(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 Uo="http://127.0.0.1:11434";function fk({t:e,onStatus:t}){const[n,r]=p.useState("hashed"),[o,i]=p.useState(Uo),[c,a]=p.useState(""),[l,u]=p.useState(""),[h,d]=p.useState(!1),[f,m]=p.useState({ollama:[],openai:[]}),[S,v]=p.useState([]),[b,w]=p.useState(!1),[j,C]=p.useState({id:"",semantic:!1,reindexRequired:!1}),[x,E]=p.useState(null),[P,A]=p.useState(null),[g,I]=p.useState(null),T=p.useCallback($=>{r($.settings.provider),i($.settings.endpoint||Uo),a($.settings.model),d($.settings.apiKeySet),C({id:$.activeProviderId,semantic:$.semantic,reindexRequired:$.reindexRequired})},[]),O=p.useCallback(async $=>{try{const X=await B.listEmbeddingModels($);m(X.catalog),v(X.installed),w(X.ollamaReachable)}catch{}},[]);p.useEffect(()=>{(async()=>{try{const $=await B.getEmbeddingSettings();T($),await O($.settings.endpoint||Uo)}catch($){A($ instanceof Error?$.message:String($))}})()},[T,O]);const _=async($,X)=>{E($),A(null),I(null);try{await X()}catch(W){A(W instanceof Error?W.message:String(W))}finally{E(null)}},M=($,X)=>_("save",async()=>{const W=await B.saveEmbeddingSettings({provider:$,...$==="ollama"?{endpoint:o}:{},...X?{model:X}:{},...$==="openai"&&l?{apiKey:l}:{}});r($),a(X),l&&(d(!0),u("")),C({id:W.activeProviderId,semantic:W.semantic,reindexRequired:W.reindexRequired}),t==null||t(W.semantic?"Semantic embeddings enabled. Re-index to apply them to your catalog.":"Using the offline hashed embedder — retrieval stays lexical.")}),q=n==="openai"?f.openai:f.ollama,G={border:`1px solid ${e.headerBorder}`,borderRadius:10,padding:14,background:e.cellBg,marginTop:14},J={fontSize:11,fontWeight:700,color:e.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},H={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%"},L=$=>({display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 11px",borderRadius:6,border:`1px solid ${$?e.accent:e.btnBorder}`,background:$?e.accent:e.btnBg,color:$?"#fff":e.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:e.font});return s.jsxs("div",{style:G,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:j.semantic?"var(--status-success-bg)":"var(--status-warning-bg)",color:j.semantic?"var(--status-success)":"var(--status-warning)",border:`1px solid ${j.semantic?"var(--status-success-border)":"var(--status-warning-border)"}`},children:[j.semantic?s.jsx(PS,{size:11}):s.jsx(OS,{size:11}),j.semantic?"Semantic":"Lexical only"]})]}),s.jsx("div",{style:{display:"flex",gap:6,marginTop:12,flexWrap:"wrap"},children:["hashed","ollama","openai"].map($=>s.jsx("button",{type:"button",onClick:()=>{r($),$==="hashed"&&M("hashed","")},style:{...L(n===$),textTransform:"capitalize"},children:$==="hashed"?"Offline (default)":$==="ollama"?"Ollama (local)":"OpenAI"},$))}),n==="ollama"&&s.jsxs("div",{style:{marginTop:12},children:[s.jsx("div",{style:J,children:"Ollama endpoint"}),s.jsxs("div",{style:{display:"flex",gap:6,marginTop:4,alignItems:"center"},children:[s.jsx("input",{value:o,onChange:$=>i($.target.value),onBlur:()=>void O(o),style:H,placeholder:Uo}),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:J,children:["API key ",h?"(stored — leave blank to keep)":""]}),s.jsx("input",{type:"password",value:l,onChange:$=>u($.target.value),style:{...H,marginTop:4},placeholder:h?"••••••••":"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:J,children:"Model"}),s.jsx("div",{style:{display:"grid",gap:6,marginTop:6},children:q.map($=>{const X=n==="openai"||S.includes($.model),W=c===$.model;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 11px",borderRadius:8,border:`1px solid ${W?e.accent:e.btnBorder}`,background:W?`${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:$.model}),$.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:[$.dimensions," dims · ",$.size]})]}),s.jsx("div",{style:{fontSize:11.5,color:e.textSecondary,marginTop:3,lineHeight:1.45},children:$.description})]}),X?s.jsx("button",{type:"button",onClick:()=>void M(n,$.model),disabled:x!==null,style:L(W),children:W?s.jsxs(s.Fragment,{children:[s.jsx(dv,{size:12})," In use"]}):"Use this"}):s.jsx("button",{type:"button",disabled:x!==null||!b,onClick:()=>void _(`install:${$.model}`,async()=>{await B.installEmbeddingModel($.model,o),await O(o),await B.saveEmbeddingSettings({provider:"ollama",endpoint:o,model:$.model}),a($.model);const te=await B.getEmbeddingSettings();T(te),t==null||t(`${$.model} installed and selected. Re-index to apply it.`)}),style:L(!0),children:x===`install:${$.model}`?s.jsxs(s.Fragment,{children:[s.jsx(qn,{size:12,className:"dql-spin"})," Installing…"]}):s.jsxs(s.Fragment,{children:[s.jsx(pp,{size:12})," Install"]})})]},$.model)})})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,flexWrap:"wrap"},children:[s.jsxs("button",{type:"button",disabled:x!==null,onClick:()=>void _("test",async()=>{const $=await B.testEmbeddingProvider();t==null||t(`${$.providerId} responded in ${$.elapsedMs} ms (${$.dimensions} dims).`)}),style:L(),children:[x==="test"?s.jsx(qn,{size:12,className:"dql-spin"}):null," Test"]}),s.jsxs("button",{type:"button",disabled:x!==null,onClick:()=>void _("reindex",async()=>{const $=await B.reindexEmbeddings(),X=await B.getEmbeddingSettings();T(X);const W=pk($,X);I(W),t==null||t(W.message)}),style:L(j.reindexRequired),children:[x==="reindex"?s.jsx(qn,{size:12,className:"dql-spin"}):s.jsx(cs,{size:12}),x==="reindex"?"Re-indexing…":"Re-index catalog"]}),s.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.fontMono},children:["active: ",j.id||"—"]})]}),j.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."}),x==="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}),P&&s.jsx("div",{style:{fontSize:11.5,color:e.error,marginTop:8,lineHeight:1.5},children:P})]})}function hk({values:e,onChange:t,placeholder:n,style:r,ariaLabel:o,title:i,disabled:c}){const a=e.join(", "),[l,u]=p.useState(a),h=p.useRef(!1);return p.useEffect(()=>{h.current||u(a)},[a]),s.jsx("input",{type:"text",value:l,disabled:c,"aria-label":o,title:i,placeholder:n,style:r,onFocus:()=>{h.current=!0},onBlur:()=>{h.current=!1,u(cl(l).join(", "))},onChange:d=>{u(d.target.value),t(cl(d.target.value))}})}function cl(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function mk(e){var t;return((t=e.evaluation)==null?void 0:t.status)==="failed"?"Rerun checks & approve":"Run checks & approve"}function gk(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 yk(e,t,n){const r=n.trim();return{...e,[t]:r||void 0}}async function bk(e,t){try{return await e()}finally{await t()}}const xk=["claude-code","codex","anthropic","openai","gemini","ollama","custom-openai"],vk=["claude-code","codex"],Sk=["anthropic","openai","gemini","ollama","custom-openai"];function Np(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 Ys({includeMemory:e=!0,embedded:t=!1,section:n,editorMode:r="settings",onProviderConfigured:o}){const i=Qe[Ge(A=>A.themeMode)],[c,a]=p.useState([]),[l,u]=p.useState([]),[h,d]=p.useState({}),[f,m]=p.useState({path:"",entries:[],warnings:[]}),[S,v]=p.useState([]),[b,w]=p.useState(!0),[j,C]=p.useState(null),x=async()=>{w(!0);try{const A=!n||n==="providers",g=e&&(!n||n==="memory"),I=!n||n==="advanced",[T,O,_,M]=await Promise.all([I?B.getSettingsEnvStatus():Promise.resolve({groups:[]}),A?B.getProviderSettings():Promise.resolve({providers:[]}),I?B.getRemoteMcpSettings():Promise.resolve({settings:{path:"",entries:[],warnings:[]}}),g?B.listAgentMemory():Promise.resolve({memories:[]})]);a(T.groups),u(O.providers),m(_.settings),v(M.memories)}finally{w(!1)}};p.useEffect(()=>{x()},[]),p.useEffect(()=>{if(b||n&&n!=="providers")return;let A=!1;return B.getProviderCliStatus().then(g=>{A||d(g.status??{})}),()=>{A=!0}},[b]);const E=p.useMemo(()=>l.filter(A=>A.enabled&&A.configured).length,[l]),P=l.find(A=>A.active&&A.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:i.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(Tk,{configured:E,total:l.length||xk.length,activeLabel:P==null?void 0:P.label,t:i})]}),j&&s.jsx("div",{style:{marginTop:14,border:`1px solid ${i.headerBorder}`,borderRadius:8,padding:"10px 12px",fontSize:12,color:i.textSecondary,background:i.cellBg},children:j}),b?s.jsx("div",{style:{marginTop:24,color:i.textSecondary},children:"Loading settings..."}):s.jsxs(s.Fragment,{children:[n==="providers"&&s.jsxs(s.Fragment,{children:[s.jsx(Ck,{providers:l,cliStatus:h,t:i,onSaved:A=>u(A),onStatus:C,editorMode:r,onProviderConfigured:o}),s.jsx(fk,{t:i,onStatus:C})]}),!n&&s.jsxs("section",{style:{marginTop:22},children:[s.jsx(rr,{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:i}),s.jsx(dl,{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:i}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:vk.map(A=>{const g=l.find(I=>I.id===A);return g?s.jsx(fl,{provider:g,cliStatus:h[A],t:i,onSaved:I=>u(I),onStatus:C},A):null})}),s.jsx(dl,{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:i}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:Sk.map(A=>{const g=l.find(I=>I.id===A);return g?s.jsx(fl,{provider:g,t:i,onSaved:I=>u(I),onStatus:C},A):null})})]}),(!n||n==="memory")&&e&&s.jsxs("section",{style:{marginTop:n?0:22},children:[s.jsx(rr,{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:i}),s.jsx(Ek,{memories:S,t:i,onChange:v,onStatus:C}),s.jsx(jk,{t:i,onStatus:C})]}),n==="advanced"&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{children:[s.jsx(rr,{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:i}),s.jsx(ll,{settings:f,t:i,onChange:m,onStatus:C})]}),s.jsxs("section",{style:{marginTop:22},children:[s.jsx(rr,{title:"Runtime status",detail:"Environment variables remain supported for Docker, CI, and shell-based setup.",t:i}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:c.map(A=>s.jsx(ml,{group:A,t:i},A.id))})]})]}),!n&&s.jsxs("details",{style:{marginTop:22,border:`1px solid ${i.headerBorder}`,borderRadius:10,background:i.cellBg,overflow:"hidden"},children:[s.jsxs("summary",{style:{cursor:"pointer",padding:"13px 16px",fontSize:13,fontWeight:650,listStyle:"none",color:i.textPrimary},children:["Advanced — MCP connections & runtime status",s.jsx("span",{style:{color:i.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(rr,{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:i}),s.jsx(ll,{settings:f,t:i,onChange:m,onStatus:C})]}),s.jsxs("section",{style:{marginTop:22},children:[s.jsx(rr,{title:"Runtime status",detail:"Environment variables remain supported for Docker, CI, and shell-based setup.",t:i}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:14},children:c.map(A=>s.jsx(ml,{group:A,t:i},A.id))})]})]})]})]})]})}function ll({settings:e,t,onChange:n,onStatus:r}){const[o,i]=p.useState(e.entries),[c,a]=p.useState("form"),[l,u]=p.useState(()=>Br(e.entries)),[h,d]=p.useState(null),[f,m]=p.useState(!1);p.useEffect(()=>{i(e.entries),u(Br(e.entries)),d(null)},[e]);const S=O=>{i(O),u(Br(O)),d(null)},v=(O,_)=>{S(o.map((M,q)=>q===O?Vn({...M,..._}):M))},b=O=>{S(o.filter((_,M)=>M!==O))},w=()=>{S([...o,{kind:"server",name:"",url:"",enabled:!0,trusted:!1,providers:["openai","anthropic"]}])},j=()=>{S([...o,{kind:"connector",name:"",connectorId:"connector_googledrive",enabled:!0,trusted:!1,providers:["openai"]}])},C=O=>{O==="json"&&u(Br(o)),d(null),a(O)},x=()=>{const O=Ok(l);return i(O),u(Br(O)),d(null),O},E=()=>{try{x()}catch(O){d(O instanceof Error?O.message:String(O))}},P=()=>{try{x(),a("form"),r("MCP JSON applied.")}catch(O){d(O instanceof Error?O.message:String(O))}},A=async()=>{m(!0);try{const O=c==="json"?x():o,_=await B.saveRemoteMcpSettings(O.map(q=>Vn(q)));n(_.settings);const M=_.settings.warnings.length?` ${_.settings.warnings.join(" ")}`:"";r(`MCP connections saved.${M}`)}catch(O){const _=O instanceof Error?O.message:String(O);c==="json"&&d(_),r(_)}finally{m(!1)}},g=o.filter(O=>O.enabled&&O.trusted).length,I=o.filter(O=>O.kind==="server").length,T=o.filter(O=>O.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:[I," remote server",I===1?"":"s"," / ",T," OpenAI connector",T===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:()=>C("form"),style:gl(t,c==="form"),children:"Form"}),s.jsx("button",{type:"button",onClick:()=>C("json"),style:gl(t,c==="json"),children:"JSON import"})]}),s.jsx("button",{type:"button",onClick:w,style:Nt(t,!1),children:"Add MCP server"}),s.jsx("button",{type:"button",onClick:j,style:Nt(t,!1),children:"Add OpenAI connector"}),s.jsx("button",{type:"button",onClick:A,disabled:f,style:Nt(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(Xs,{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(Xs,{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(Xs,{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(" ")}),c==="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:l,onChange:O=>{u(O.target.value),d(null)},spellCheck:!1,rows:18,style:{...Ne(t),width:"100%",minHeight:360,resize:"vertical",fontFamily:t.fontMono,fontSize:12,lineHeight:1.45}}),h&&s.jsx("div",{style:{color:"#b42318",fontSize:12,marginTop:8},children:h}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[s.jsx("button",{type:"button",onClick:E,style:Nt(t,!1),children:"Format JSON"}),s.jsx("button",{type:"button",onClick:P,style:Nt(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((O,_)=>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:O.kind,onChange:M=>v(_,{kind:M.target.value==="connector"?"connector":"server",providers:M.target.value==="connector"?["openai"]:O.providers}),style:{...Ne(t),width:116},children:[s.jsx("option",{value:"server",children:"Server"}),s.jsx("option",{value:"connector",children:"Connector"})]}),s.jsx("input",{value:O.name,onChange:M=>v(_,{name:M.target.value}),placeholder:"Name",style:{...Ne(t),flex:1}}),s.jsx("button",{type:"button",onClick:()=>b(_),style:Nt(t,!1),children:"Remove"})]}),s.jsxs("div",{style:{display:"grid",gap:8,marginTop:10},children:[O.kind==="connector"?s.jsx("input",{value:O.connectorId??"",onChange:M=>v(_,{connectorId:M.target.value}),placeholder:"connector_googledrive",style:Ne(t)}):s.jsx("input",{value:O.url??"",onChange:M=>v(_,{url:M.target.value}),placeholder:"https://example.com/mcp or /sse",style:Ne(t)}),s.jsx("input",{value:O.description??"",onChange:M=>v(_,{description:M.target.value}),placeholder:"Description shown to the model",style:Ne(t)}),s.jsx("input",{value:O.authorizationTokenEnv??"",onChange:M=>v(_,{authorizationTokenEnv:M.target.value}),placeholder:"Authorization token env var",style:Ne(t)}),s.jsx("input",{value:O.authorizationToken??"",onChange:M=>v(_,{authorizationToken:M.target.value}),type:"password",placeholder:O.hasAuthorizationToken?`Leave blank to keep ${O.authorizationTokenPreview??"stored token"}`:"Optional OAuth token",style:Ne(t)}),s.jsx(hk,{values:O.allowedTools??[],onChange:M=>v(_,{allowedTools:M}),placeholder:"Allowed tools, comma separated",style:Ne(t)})]}),s.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginTop:10},children:[s.jsxs("label",{style:Nr(t),children:[s.jsx("input",{type:"checkbox",checked:O.enabled,onChange:M=>v(_,{enabled:M.target.checked})})," Enabled"]}),s.jsxs("label",{style:Nr(t),children:[s.jsx("input",{type:"checkbox",checked:O.trusted,onChange:M=>v(_,{trusted:M.target.checked})})," Trusted"]}),s.jsxs("label",{style:Nr(t),children:[s.jsx("input",{type:"checkbox",checked:!!O.deferLoading,onChange:M=>v(_,{deferLoading:M.target.checked})})," Defer tools"]}),s.jsxs("label",{style:Nr(t),children:[s.jsx("input",{type:"checkbox",checked:(O.providers??[]).includes("openai"),onChange:M=>v(_,{providers:bl(O.providers,"openai",M.target.checked)})})," OpenAI"]}),s.jsxs("label",{style:Nr(t),children:[s.jsx("input",{type:"checkbox",checked:(O.providers??[]).includes("anthropic"),disabled:O.kind==="connector",onChange:M=>v(_,{providers:bl(O.providers,"anthropic",M.target.checked)})})," Anthropic"]})]})]},`${O.kind}-${O.name||_}`))})]})}function Xs({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 wk({status:e,command:t,loginCmd:n,t:r}){let o=r.textMuted,i=r.textMuted,c="Checking for the CLI…";if(e)if(!e.installed)o=r.warning,i=r.warning,c=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,c=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(" · ");c=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:c})]})}function dl({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 Bp(e){return e==="codex"?"codex":"claude"}function Fp({oauthProvider:e,label:t,model:n,setModel:r,cliStatus:o,command:i,loginCmd:c,t:a,onStatus:l,onConnected:u}){const[h,d]=p.useState(null),[f,m]=p.useState(!1),S=p.useRef(null),v=p.useRef(!0),b=e==="codex"?"ChatGPT":"Claude",w=p.useCallback(()=>{S.current!==null&&(window.clearInterval(S.current),S.current=null)},[]);p.useEffect(()=>(v.current=!0,B.getOAuthStatus(e).then(x=>{v.current&&d(x)}).catch(()=>{}),()=>{v.current=!1,w()}),[e,w]);const j=async()=>{m(!0);try{const x=await B.startOAuth(e);d(x),window.open(x.url,"_blank","noopener,noreferrer"),l(`Opened your browser to sign in to ${b}. Complete it there — this updates automatically.`);const E=Date.now();w(),S.current=window.setInterval(async()=>{const P=await B.getOAuthStatus(e).catch(()=>null);if(!v.current){w();return}P&&d(P),P!=null&&P.connected?(w(),m(!1),u(P.defaultModel)):Date.now()-E>300*1e3&&(w(),m(!1),l(`${b} sign-in timed out. Try again.`))},2500)}catch(x){m(!1),l(x instanceof Error?x.message:String(x))}},C=async()=>{m(!0),w();try{d(await B.signOutOAuth(e)),l(`Signed out of ${b}.`)}catch(x){l(x instanceof Error?x.message:String(x))}finally{m(!1)}};if(h!=null&&h.connected){const x=h.models.length>0?h.models:[h.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]}),h.email?s.jsxs("span",{style:{color:a.textSecondary},children:["as ",h.email]}):null]}),s.jsx("label",{style:{fontSize:11,color:a.textSecondary,fontWeight:600},children:"Model"}),s.jsx("select",{value:n||h.defaultModel,onChange:E=>r(E.target.value),style:Ne(a),children:x.map(E=>s.jsx("option",{value:E,children:E},E))}),s.jsx("div",{children:s.jsx("button",{type:"button",onClick:C,disabled:f,style:Nt(a,!1),children:"Sign out"})})]})}return s.jsxs("div",{style:{display:"grid",gap:8},children:[s.jsx("button",{type:"button",onClick:j,disabled:f,style:Nt(a,!0),children:f||h!=null&&h.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(wk,{status:o,command:i,loginCmd:c,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," ",c]}),", then Enable + Save."]})]})]})]})}const Yo=[{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"}}],ul={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 kk(e){if(!e)return"claude";const t=Yo.find(n=>Object.values(n.modes).includes(e));return(t==null?void 0:t.key)??"claude"}function Ck({providers:e,cliStatus:t,t:n,onSaved:r,onStatus:o,editorMode:i,onProviderConfigured:c}){var F;const a=e.find(K=>K.active&&K.configured),[l,u]=p.useState(()=>kk(a==null?void 0:a.id)),h=Yo.find(K=>K.key===l)??Yo[0],d=Object.keys(h.modes),[f,m]=p.useState(()=>d.find(oe=>h.modes[oe]===(a==null?void 0:a.id))??d[0]),S=d.includes(f)?f:d[0],v=h.modes[S],b=e.find(K=>K.id===v),[w,j]=p.useState(""),[C,x]=p.useState((b==null?void 0:b.baseUrl)??""),[E,P]=p.useState((b==null?void 0:b.model)??""),[A,g]=p.useState((b==null?void 0:b.reasoningEffort)??"auto"),[I,T]=p.useState(!1),[O,_]=p.useState({state:"idle"}),[M,q]=p.useState({state:"idle"});p.useEffect(()=>{j(""),x((b==null?void 0:b.baseUrl)??""),P((b==null?void 0:b.model)??""),g((b==null?void 0:b.reasoningEffort)??"auto"),q({state:"idle"})},[v,b==null?void 0:b.baseUrl,b==null?void 0:b.model,b==null?void 0:b.reasoningEffort]);const G=async()=>{if(!a)return;_({state:"testing"});const K=Date.now(),oe=await B.testProviderSettings(a.id,{}),ee=oe.ok!==!1;_({state:"done",ok:ee,message:oe.message,seconds:((Date.now()-K)/1e3).toFixed(1)})},J=()=>{var K;return v==="custom-openai"&&!C.trim()?"Custom OpenAI-compatible providers require a Base URL.":v==="custom-openai"&&!E.trim()?"Custom OpenAI-compatible providers require a model.":S==="api"&&v!=="custom-openai"&&!w.trim()&&!(b!=null&&b.hasApiKey)?`Add an API key${(K=b==null?void 0:b.envVars)!=null&&K[0]?` or set ${b.envVars[0]}`:""}.`:S==="local"&&!C.trim()&&!E.trim()&&!(b!=null&&b.configured)?"Set an Ollama endpoint or model before testing.":null},H=async()=>{const K=J();if(K)return q({state:"done",ok:!1,message:K}),!1;q({state:"testing"});const oe=await B.testProviderSettings(v,{apiKey:w||void 0,baseUrl:C||void 0,model:E||void 0});return q({state:"done",ok:oe.ok,message:oe.message}),oe.ok},L=async()=>{T(!0);try{if(!await H()){o("Test failed. Your existing provider configuration was not changed.");return}const oe=await B.saveProviderSettings({id:v,enabled:!0,apiKey:w||void 0,baseUrl:C,model:E,reasoningEffort:A});r(oe.providers);const ee=oe.providers.find(ce=>ce.id===v);ee&&(c==null||c(ee)),o(`${h.label} passed its test and is now the active provider.`)}catch(K){o(K instanceof Error?K.message:String(K))}finally{T(!1)}},$=async K=>{const oe=E||K;P(oe);try{const ee=await B.saveProviderSettings({id:v,enabled:!0,model:oe});r(ee.providers);const ce=ee.providers.find(ke=>ke.id===v);ce&&(c==null||c(ce)),o(`${h.label} subscription configured and activated. Run Test to verify the next governed request.`)}catch(ee){o(ee instanceof Error?ee.message:String(ee))}},X={fontSize:11,fontWeight:650,color:n.textSecondary},W={...Ne(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(gp,{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:O.state==="done"&&O.ok===!1?"var(--status-error)":"var(--status-success)",marginTop:2},children:O.state==="testing"?"Testing…":O.state==="done"?O.ok?`Test passed · ${O.seconds}s`:O.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 G(),disabled:O.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:O.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:X,children:"Provider"}),s.jsx("select",{value:h.key,onChange:K=>{u(K.target.value),m("subscription")},style:W,children:Yo.map(K=>s.jsx("option",{value:K.key,children:K.label},K.key))})]})}),s.jsxs("div",{children:[s.jsx("span",{style:{...X,display:"block",marginBottom:6},children:"How do you want to connect?"}),s.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:d.map(K=>{const oe=K===S;return s.jsxs("button",{type:"button",onClick:()=>m(K),style:{display:"inline-flex",alignItems:"center",gap:7,padding:"8px 13px",borderRadius:9,border:`1.5px solid ${oe?n.accent:n.headerBorder}`,background:oe?"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 ${oe?n.accent:"var(--border-strong)"}`,background:oe?n.accent:n.cellBg,boxShadow:oe?`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:ul[K].label}),s.jsx("span",{style:{fontSize:10,color:n.textMuted},children:ul[K].hint})]})]},K)})})]}),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(Fp,{oauthProvider:Bp(v),label:b.label,model:E,setModel:P,cliStatus:t[v],command:b.command,loginCmd:v==="claude-code"?"/login":"login",t:n,onStatus:o,onConnected:$})}):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:X,children:"API key"}),s.jsx("input",{type:"password",value:w,onChange:K=>j(K.target.value),placeholder:b!=null&&b.hasApiKey?"Leave blank to keep existing key":"API key",style:{...W,fontFamily:n.fontMono}})]}),(F=b==null?void 0:b.envVars)!=null&&F[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:X,children:"Host"}),s.jsx("input",{value:C,onChange:K=>x(K.target.value),placeholder:"http://localhost:11434",style:{...W,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(pl,{providerId:v,provider:b,mode:S,baseUrl:C,setBaseUrl:x,model:E,setModel:P,reasoningEffort:A,setReasoningEffort:g,t:n,input:W,fieldLabel:X})})]}):s.jsx("div",{style:{display:"grid",gap:10},children:s.jsx(pl,{providerId:v,provider:b,mode:S,baseUrl:C,setBaseUrl:x,model:E,setModel:P,reasoningEffort:A,setReasoningEffort:g,t:n,input:W,fieldLabel:X})}),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 H(),disabled:I||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 L(),disabled:I,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:I?.7:1},children:I?"Testing…":"Test, save & activate"})]})]})]})}function pl({providerId:e,provider:t,mode:n,baseUrl:r,setBaseUrl:o,model:i,setModel:c,reasoningEffort:a,setReasoningEffort:l,t:u,input:h,fieldLabel:d}){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:d,children:e==="custom-openai"?"Base URL (required)":"Base URL (optional)"}),s.jsx("input",{value:r,onChange:f=>o(f.target.value),placeholder:Np(e),style:{...h,fontFamily:u.fontMono}})]}):null,s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:d,children:e==="custom-openai"?"Model (required)":"Model (optional)"}),s.jsx("input",{value:i,onChange:f=>c(f.target.value),placeholder:(t==null?void 0:t.model)||"Provider default",style:h})]}),t!=null&&t.supportsReasoningEffort&&n==="api"?s.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("span",{style:d,children:"Reasoning effort"}),s.jsxs("select",{value:a,onChange:f=>l(f.target.value),style:h,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 fl({provider:e,cliStatus:t,t:n,onSaved:r,onStatus:o}){const[i,c]=p.useState(e.enabled),[a,l]=p.useState(""),[u,h]=p.useState(e.baseUrl??""),[d,f]=p.useState(e.model??""),[m,S]=p.useState(e.reasoningEffort??"auto"),[v,b]=p.useState(!1),[w,j]=p.useState(!1),[C,x]=p.useState(null),E=e.authMode==="subscription_cli",P=e.id==="claude-code"?"/login":"login",A=e.supportsReasoningEffort===!0&&!E&&e.id!=="ollama";p.useEffect(()=>{c(e.enabled),h(e.baseUrl??""),f(e.model??""),S(e.reasoningEffort??"auto"),l(""),x(null)},[e.id,e.enabled,e.baseUrl,e.model,e.reasoningEffort]);const g=async()=>{b(!0);try{const O=await B.saveProviderSettings({id:e.id,enabled:i,apiKey:a||void 0,baseUrl:u,model:d,reasoningEffort:m});r(O.providers),o(`${e.label} settings saved.`)}catch(O){o(O instanceof Error?O.message:String(O))}finally{b(!1)}},I=async()=>{j(!0),x(null);const O=await B.testProviderSettings(e.id,{apiKey:a||void 0,baseUrl:u||void 0,model:d||void 0}),_=O.ok!==!1;x({ok:_,message:O.message||(_?`${e.label} is reachable.`:`${e.label} test failed.`)}),j(!1)},T=async O=>{const _=d||O;f(_),c(!0);try{const M=await B.saveProviderSettings({id:e.id,enabled:!0,model:_});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:Rk(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:O=>c(O.target.checked)}),"Enabled"]})]}),s.jsxs("div",{style:{display:"grid",gap:8,marginTop:12},children:[E?s.jsx(Fp,{oauthProvider:Bp(e.id),label:e.label,model:d,setModel:f,cliStatus:t,command:e.command,loginCmd:P,t:n,onStatus:o,onConnected:T}):s.jsxs(s.Fragment,{children:[e.id!=="ollama"&&s.jsx("input",{value:a,onChange:O=>l(O.target.value),type:"password",placeholder:e.hasApiKey?"Leave blank to keep existing key":"API key",style:Ne(n)}),s.jsx("input",{value:u,onChange:O=>h(O.target.value),placeholder:Np(e.id),style:Ne(n)})]}),!E&&s.jsx("input",{value:d,onChange:O=>f(O.target.value),placeholder:"Default model",style:Ne(n)}),A&&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:m,onChange:O=>S(O.target.value),style:Ne(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:m==="auto"?"The agent spends more reasoning on SQL generation, gates, and repairs, and less on chat.":`Caps every request at ${m} reasoning.`})]})]}),s.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[s.jsx("button",{type:"button",onClick:g,disabled:v||w,style:Nt(n,!0),children:e.active?"Save active provider":"Save and use"}),s.jsx("button",{type:"button",onClick:I,disabled:v||w,style:Nt(n,!1),children:w?"Testing…":"Test"})]}),C&&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:C.ok?n.success:n.error,background:`${C.ok?n.success:n.error}12`,border:`1px solid ${C.ok?n.success:n.error}40`},children:[s.jsx("span",{style:{flexShrink:0,fontWeight:700},children:C.ok?"✓":"✗"}),s.jsx("span",{children:C.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 rt(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 hl(e){return[...new Map(e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean).map(t=>[t.toLowerCase(),t])).values()].slice(0,8)}function jk({t:e,onStatus:t}){const[n,r]=p.useState([]),[o,i]=p.useState({candidate:0,approved:0,rejected:0,retired:0}),[c,a]=p.useState(null),[l,u]=p.useState(!1),[h,d]=p.useState({}),[f,m]=p.useState(null),S=p.useCallback(async()=>{try{const g=await B.listAgentHints();r(g.hints??[]),i(g.counts??{candidate:0,approved:0,rejected:0,retired:0})}catch{r([])}finally{u(!0)}},[]);p.useEffect(()=>{S()},[S]);const v=async(g,I)=>{var T;a(g.id),t(null);try{const O=(T=h[g.id])==null?void 0:T.trim(),_=await bk(()=>B.reviewAgentHint(g.id,I,O),S);_.ok?t(I==="approved"?`Approved. DQL will apply "${g.title}" to matching questions.`:`Rejected. "${g.title}" will not be used.`):t(_.error??`Could not ${I==="approved"?"approve":"reject"} this correction.`)}catch(O){t(O instanceof Error?O.message:String(O))}finally{a(null)}},b=async(g,I,T)=>{var O;a(g.id),t(null);try{const _=await B.transitionAgentHint(g.id,{action:I,targetHintId:T,note:((O=h[g.id])==null?void 0:O.trim())||void 0});t(_.ok?I==="retire"?`Retired "${g.title}". It is excluded from future answers.`:I==="reopen"?`Reopened "${g.title}" as a candidate.`:`Resolved the conflict. "${g.title}" is authoritative.`:_.error??`Could not ${I} this hint.`),await S()}catch(_){t(_ instanceof Error?_.message:String(_))}finally{a(null)}},w=async()=>{if(f){a(f.id),t(null);try{const g=await B.updateAgentHint(f.id,{title:f.title,guidance:f.guidance,lesson:{...rt(f),rule:f.guidance},correctedSql:f.correctedSql,scope:f.scope});g.ok?(t(`Updated "${f.title}" and refreshed its current dependencies.`),m(null)):t(g.error??"Could not update this candidate."),await S()}catch(g){t(g instanceof Error?g.message:String(g))}finally{a(null)}}},j=async g=>{var I;if(!((I=g.trace)!=null&&I.question)||!g.correctedSql){t("This hint is missing the question or SQL required for an analyst certification request.");return}a(g.id);try{const T=await B.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(T.ok?`Certification research requested for "${g.title}". Approval of a hint did not certify an asset.`:T.error??"Could not request certification.")}catch(T){t(T instanceof Error?T.message:String(T))}finally{a(null)}},C=n.filter(g=>g.status==="candidate"),x=n.filter(g=>g.status==="approved"),E=n.filter(g=>g.status==="rejected"||g.status==="retired");if(!l)return null;const P=g=>{var I,T,O,_,M,q,G,J,H;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:[(I=g.trace)!=null&&I.question?s.jsxs("div",{children:[s.jsx("b",{children:"Question:"})," ",g.trace.question]}):null,(T=g.trace)!=null&&T.wrongAnswer?s.jsxs("div",{children:[s.jsx("b",{children:"Previous answer:"})," ",g.trace.wrongAnswer]}):null,(O=g.trace)!=null&&O.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",(_=g.inspection)!=null&&_.currentSnapshotId?` · current ${g.inspection.currentSnapshotId}`:""]}),s.jsxs("div",{children:[s.jsx("b",{children:"Dependencies:"})," ",((M=g.dependencies)==null?void 0:M.map(L=>`${L.kind}:${L.id}@${L.fingerprint.slice(0,10)}`).join(", "))||"none recorded"]}),s.jsxs("div",{children:[s.jsx("b",{children:"Graph connections:"})," ",(q=g.graphEdges)!=null&&q.length?g.graphEdges.map(L=>`${L.kind.replace(/_/g," ")} → ${L.targetName}`).join(" · "):"none materialized"]}),(G=g.lifecycleErrors)==null?void 0:G.map(L=>s.jsxs("div",{style:{color:e.error},children:[s.jsxs("b",{children:[L.code,":"]})," ",L.message]},`${L.code}-${L.at}`)),g.evaluation?s.jsxs("div",{children:[s.jsxs("b",{children:["Evaluation ",g.evaluation.status,":"]}),g.evaluation.checks.map(L=>s.jsxs("div",{style:{color:L.passed?e.success:e.error},children:[L.passed?"✓":"✕"," ",L.name," — ",L.evidence]},L.name))]}):s.jsxs("div",{children:[s.jsx("b",{children:"Evaluation:"})," not run"]}),(J=g.inspection)==null?void 0:J.checks.map(L=>s.jsxs("div",{style:{color:L.passed?e.success:e.error},children:[L.passed?"✓":"✕"," live ",L.name," — ",L.evidence]},`live-${L.name}`)),(H=g.exclusions)==null?void 0:H.map((L,$)=>s.jsxs("div",{style:{color:e.error},children:[s.jsxs("b",{children:["Excluded: ",L.reason]})," — ",L.detail]},`${L.reason}-${$}`))]})]})},A=g=>{var _,M,q,G,J,H;const I=((_=g.exclusions)==null?void 0:_.filter(L=>L.reason==="conflict"&&L.relatedHintId))??[],T=(f==null?void 0:f.id)===g.id,O=g.status==="approved"&&((M=g.evaluation)==null?void 0:M.status)==="passed"&&((q=g.inspection)==null?void 0:q.state)==="current"&&(((G=g.exclusions)==null?void 0:G.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:(J=g.exclusions)!=null&&J.length||((H=g.evaluation)==null?void 0:H.status)==="failed"?e.error:e.success},children:gk(g)})]}),T?s.jsxs(s.Fragment,{children:[s.jsx("input",{value:f.title,onChange:L=>m({...f,title:L.target.value}),placeholder:"Hint title",style:Re(e,{size:"sm"})}),s.jsx("textarea",{value:f.guidance,onChange:L=>m({...f,guidance:L.target.value}),placeholder:"Guidance for matching questions",rows:3,style:{...Re(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:rt(f).category,onChange:L=>m({...f,lesson:{...rt(f),category:L.target.value}}),style:Re(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:rt(f).intentExamples.join(`
|
|
437
|
+
`),onChange:L=>m({...f,lesson:{...rt(f),intentExamples:L.target.value.split(/\r?\n/)}}),onBlur:()=>m({...f,lesson:{...rt(f),intentExamples:hl(rt(f).intentExamples.join(`
|
|
438
|
+
`))}}),placeholder:"Similar questions, one per line",rows:3,style:{...Re(e,{size:"sm"}),resize:"vertical"}}),s.jsx("textarea",{value:rt(f).avoid.join(`
|
|
439
|
+
`),onChange:L=>m({...f,lesson:{...rt(f),avoid:L.target.value.split(/\r?\n/)}}),onBlur:()=>m({...f,lesson:{...rt(f),avoid:hl(rt(f).avoid.join(`
|
|
440
|
+
`))}}),placeholder:"Known mistakes to avoid, one per line",rows:2,style:{...Re(e,{size:"sm"}),resize:"vertical"}}),s.jsx("input",{value:rt(f).expectedOutcome??"",onChange:L=>m({...f,lesson:{...rt(f),expectedOutcome:L.target.value||void 0}}),placeholder:"Expected outcome or result shape",style:Re(e,{size:"sm"})})]})]}),s.jsx("textarea",{value:f.correctedSql??"",onChange:L=>m({...f,correctedSql:L.target.value}),placeholder:"Read-only corrected SQL",rows:5,style:{...Re(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(([L,$])=>s.jsxs("label",{style:{display:"grid",gap:3,fontSize:10,color:e.textMuted},children:[$,s.jsx("input",{value:f.scope[L]??"",onChange:X=>m({...f,scope:yk(f.scope,L,X.target.value)}),placeholder:`Optional ${$}`,style:Re(e,{size:"sm"})})]},L))}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void w(),style:Re(e,{variant:"primary",size:"sm",disabled:c===g.id}),children:"Save & recheck"}),s.jsx("button",{type:"button",onClick:()=>m(null),style:Re(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,P(g),s.jsx("textarea",{value:h[g.id]??"",onChange:L=>d({...h,[g.id]:L.target.value}),placeholder:"Reviewer note or result assertion (required evidence when this surface cannot execute)",rows:2,style:{...Re(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:c===g.id,onClick:()=>void v(g,"approved"),style:Re(e,{variant:"primary",size:"sm",disabled:c===g.id}),children:c===g.id?"Checking…":mk(g)}),s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>m({...g,lesson:rt(g)}),style:Re(e,{size:"sm",disabled:c===g.id}),children:"Edit candidate"}),s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void v(g,"rejected"),style:Re(e,{variant:"danger",size:"sm",disabled:c===g.id}),children:"Reject"})]}):null,g.status==="approved"?s.jsxs(s.Fragment,{children:[O?s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void j(g),style:Re(e,{variant:"primary",size:"sm",disabled:c===g.id}),children:"Request certification"}):null,s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void b(g,"reopen"),style:Re(e,{size:"sm",disabled:c===g.id}),children:"Reopen & edit"}),s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void b(g,"retire"),style:Re(e,{variant:"danger",size:"sm",disabled:c===g.id}),children:"Retire"}),I.map(L=>s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void b(g,"supersede",L.relatedHintId),style:Re(e,{size:"sm",disabled:c===g.id}),children:"Keep this; supersede conflict"},L.relatedHintId))]}):null,g.status==="retired"?s.jsx("button",{type:"button",disabled:c===g.id,onClick:()=>void b(g,"reopen"),style:Re(e,{size:"sm",disabled:c===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`:""]})]}),C.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:C.map(A)}),x.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:x.map(A)})]}):null,E.length>0?s.jsxs("details",{style:{marginTop:16},children:[s.jsxs("summary",{style:{cursor:"pointer",fontSize:12,color:e.textSecondary},children:["Rejected & retired history (",E.length,")"]}),s.jsx("div",{style:{display:"grid",gap:8,marginTop:8},children:E.map(A)})]}):null]})}function Ek({memories:e,t,onChange:n,onStatus:r}){const[o,i]=p.useState("project"),[c,a]=p.useState(""),[l,u]=p.useState(""),[h,d]=p.useState(""),f=async()=>{const T=await B.listAgentMemory();n(T.memories)},m=async T=>{await B.deleteAgentMemory(T),await f(),r("Memory deleted.")},[S,v]=p.useState(!1),[b,w]=p.useState("all"),[j,C]=p.useState(null),x=T=>T==="project"?{label:"project",bg:"var(--accent-dim)",color:t.accent}:T==="user"?{label:"just me",bg:`${t.textMuted}1f`,color:t.textMuted}:{label:T,bg:"var(--status-success-bg)",color:"var(--status-success)"},E=e.filter(T=>b==="all"?!0:b==="project"?T.scope==="project":T.scope==="user"),P=T=>{C(T.id),i(T.scope),a(T.title),u(T.content),d(T.tags.join(", ")),v(!0)},A=()=>{v(!1),C(null),a(""),u(""),d("")},g=async()=>{if(!l.trim())return;c.trim()||a(l.trim().slice(0,60));const T=c.trim()||l.trim().slice(0,60);await B.saveAgentMemory({scope:o,title:T,content:l,tags:h.split(",").map(O=>O.trim()).filter(Boolean),source:"settings-ui",confidence:.8,importance:o==="project"?.7:.5,enabled:!0}),j&&await B.deleteAgentMemory(j).catch(()=>{}),A(),await f(),r(j?"Memory updated.":"Memory saved.")},I=(T,O)=>s.jsx("button",{type:"button",onClick:()=>w(T),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:t.font,background:b===T?"var(--accent-dim)":"transparent",color:b===T?t.accent:t.textMuted},children:O},T);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:[I("all","All"),I("project","Project"),I("me","Just me")]}),s.jsx("div",{style:{flex:1}}),s.jsx("button",{type:"button",onClick:()=>S?A():v(!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:l,onChange:T=>u(T.target.value),placeholder:"e.g. Fiscal quarters start in February. 'Sales' means recognized revenue unless someone says bookings.",style:{...Ne(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:T=>i(T.target.value),style:{...Ne(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:h,onChange:T=>d(T.target.value),placeholder:"Tags (optional)",style:{...Ne(t),width:160,borderRadius:7,padding:"5px 8px"}}),s.jsx("div",{style:{flex:1}}),s.jsx("button",{type:"button",onClick:A,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:!l.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:l.trim()?1:.6},children:j?"Update memory":"Save memory"})]})]}):null,s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:E.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."}):E.slice(0,30).map(T=>{const O=!["settings-ui","manual",""].includes(T.source),_=x(T.scope),M=O?`Saved from ${T.source}${typeof T.confidence=="number"?` · ${Math.round(T.confidence*100)}% confidence`:""}`:`Added by hand${T.tags.length?` · ${T.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:_.bg,color:_.color},children:_.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:T.content||T.title}),s.jsx("div",{style:{fontSize:10.5,color:t.textMuted,marginTop:4},children:M})]}),s.jsx("button",{type:"button",title:"Edit",onClick:()=>P(T),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 m(T.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:"🗑"})]},T.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 ml({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(Ak,{present:n.present})]},n.key))]})}function rr({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 Tk({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 Ak({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 Ne(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 Nt(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 gl(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 Rk(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 Nr(e){return{display:"flex",alignItems:"center",gap:5,fontSize:12,color:e.textSecondary}}function Br(e){const t=e.filter(r=>r.kind!=="connector").map(r=>yl({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:Vn(r).providers})),n=e.filter(r=>r.kind==="connector").map(r=>yl({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 Ok(e){let t;try{t=JSON.parse(e)}catch(r){throw new Error(`Invalid JSON: ${r instanceof Error?r.message:String(r)}`)}if(!Kn(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)=>us(r,"server",`servers[${o}]`))),Array.isArray(t.connectors)&&n.push(...t.connectors.map((r,o)=>us(r,"connector",`connectors[${o}]`))),Array.isArray(t.tools)&&n.push(..._k(t.tools)),Array.isArray(t.mcp_servers)&&n.push(...Pk(t.mcp_servers)),Kn(t.mcpServers)&&n.push(...Ik(t.mcpServers)),n.map(Vn)}function _k(e){return e.flatMap((t,n)=>{if(!Kn(t)||t.type!=="mcp")return[];const r=ct(t,["connectorId","connector_id"]),o=ct(t,["authorization"]);return r?[Vn({kind:"connector",name:ct(t,["name","server_label","serverLabel"])??r,connectorId:r,authorizationToken:o,allowedTools:io(t,["allowedTools","allowed_tools"]),enabled:!0,trusted:t.trusted===!0||t.require_approval==="never",providers:["openai"]})]:[us({...t,name:ct(t,["name","server_label","serverLabel"]),url:ct(t,["url","server_url","serverUrl"]),authorizationToken:o??Ia(t.headers),allowedTools:io(t,["allowedTools","allowed_tools"]),enabled:!0,trusted:t.trusted===!0||t.require_approval==="never",providers:["openai"]},"server",`tools[${n}]`)]})}function Pk(e){return e.map((t,n)=>{const r=us(t,"server",`mcp_servers[${n}]`);return Vn({...r,authorizationToken:r.authorizationToken??(Kn(t)?ct(t,["authorization_token"]):void 0),providers:["anthropic"]})})}function Ik(e){return Object.entries(e).map(([t,n])=>{if(!Kn(n))throw new Error(`mcpServers.${t} must be an object.`);const r=ct(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 Vn({kind:"server",name:t,url:r,authorizationToken:Ia(n.headers),enabled:n.enabled!==!1,trusted:n.trusted===!0,allowedTools:io(n,["allowedTools","allowed_tools"]),providers:zp(n,["providers"])??["openai","anthropic"]})})}function us(e,t,n){if(!Kn(e))throw new Error(`${n} must be an object.`);const r=ct(e,["name","server_label","serverLabel"]);if(!r)throw new Error(`${n} needs a name.`);const o=ct(e,["url","server_url","serverUrl"]),i=ct(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:ct(e,["description","server_description","serverDescription"]),authorizationToken:ct(e,["authorizationToken","authorization","authorization_token"])??Ia(e.headers),authorizationTokenEnv:ct(e,["authorizationTokenEnv","authorizationEnv","authorization_token_env"]),allowedTools:io(e,["allowedTools","allowed_tools"]),enabled:e.enabled!==!1,trusted:e.trusted===!0,deferLoading:e.deferLoading===!0||e.defer_loading===!0,providers:zp(e,["providers"])}}function yl(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>!(t==null||t===""||Array.isArray(t)&&t.length===0)))}function Kn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ct(e,t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function io(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 zp(e,t){const n=io(e,t);if(!n)return;const r=n.filter(o=>o==="openai"||o==="anthropic");return r.length?r:void 0}function Ia(e){if(!Kn(e))return;const t=ct(e,["Authorization","authorization"]);return(t==null?void 0:t.replace(/^Bearer\s+/i,"").trim())||void 0}function bl(e,t,n){const r=new Set(e??[]);return n?r.add(t):r.delete(t),Array.from(r)}function Vn(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 Zs(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 Dk=e=>new Promise(t=>{window.setTimeout(t,e)});async function $k({jobId:e,loadStatus:t,onCompleted:n,onFailed:r,isCancelled:o=()=>!1,wait:i=Dk,intervalMs:c=700}){for(;!o();){if(await i(c),o())return;const a=await t();if(o())return;const l=a.job;if(!l||l.id!==e)return;if(!(l.state==="queued"||l.state==="running")){l.state==="completed"?await n(a):l.state==="failed"&&await r(a);return}}}function Mk(e){return/^(?:https?:\/\/|ssh:\/\/|git@|file:\/\/)/i.test(e.trim())}function Lk(e){const t=e.trim();return t?Mk(t)?{repoUrl:t}:{projectDir:t}:{}}const ei={auto:"Auto",native:"Native (DQL)","metricflow-cli":"Local MetricFlow","dbt-cloud":"dbt Cloud"};function Nk({compact:e=!1,reapplyRequired:t=!1,onConfigured:n}){var Zt,en,En,Tn;const{state:r,dispatch:o}=et(),i=Qe[r.themeMode],[c,a]=p.useState(null),[l,u]=p.useState(!1),[h,d]=p.useState(""),[f,m]=p.useState(null),[S,v]=p.useState(null),[b,w]=p.useState("loading"),[j,C]=p.useState(null),[x,E]=p.useState(null),[P,A]=p.useState(""),[g,I]=p.useState(""),[T,O]=p.useState(""),[_,M]=p.useState(null),[q,G]=p.useState(null),[J,H]=p.useState(null),[L,$]=p.useState(""),[X,W]=p.useState(!1),te=p.useCallback(async()=>{const U=await B.getSemanticRuntimeSettings();return E(U),A(U.dbtCloud.host??""),I(U.dbtCloud.environmentId??""),O(""),U},[]),F=p.useCallback(async()=>{const U=await B.getMetricFlowInstallerStatus();return H(U),$(se=>se||U.recommendedAdapter||U.supportedAdapters[0]||""),U},[]),K=p.useCallback(async()=>{var me,tn,ie;const[U,se]=await Promise.all([B.getOnboardingStatus(),B.getBlockStudioDbtStatus().catch(()=>null)]);a(U),v(U.preparation??null);const je=((me=U.dbt)==null?void 0:me.configured)===!0||!!(se!=null&&se.configured&&se.artifacts.manifest.exists);u(je);const ve=((tn=U.dbt)==null?void 0:tn.repoUrl)||((ie=U.dbt)==null?void 0:ie.projectDir)||(se==null?void 0:se.projectPath)||"";return d(je?ve:""),U},[]);p.useEffect(()=>{let U=!0;return K().catch(se=>U&&C({ok:!1,text:se instanceof Error?se.message:String(se)})).finally(()=>U&&w(null)),()=>{U=!1}},[K]),p.useEffect(()=>{let U=!0;return Promise.all([te(),F()]).catch(se=>{U&&G({ok:!1,text:se instanceof Error?se.message:String(se)})}),()=>{U=!1}},[F,te]),p.useEffect(()=>{const U=J==null?void 0:J.job;if(!U||U.state!=="queued"&&U.state!=="running")return;let se=!1;return $k({jobId:U.id,loadStatus:F,isCancelled:()=>se,onCompleted:async je=>{var me;await te();const ve=await B.getSemanticLayer();se||(o({type:"SET_SEMANTIC_LAYER",layer:ve}),G({ok:!0,text:((me=je.job)==null?void 0:me.message)||"Local MetricFlow is installed and ready."}))},onFailed:je=>{var ve,me;se||G({ok:!1,text:((ve=je.job)==null?void 0:ve.error)||((me=je.job)==null?void 0:me.message)||"Local MetricFlow installation failed."})}}).catch(je=>{se||G({ok:!1,text:je instanceof Error?je.message:String(je)})}),()=>{se=!0}},[o,F,te,(Zt=J==null?void 0:J.job)==null?void 0:Zt.id]),p.useEffect(()=>{if(!S||S.status!=="queued"&&S.status!=="running")return;let U=!0,se;const je=async()=>{try{const ve=await B.getOnboardingJob(S.id);if(!U)return;const me=Zs(ve);if(!me)return;v(me),me.status==="completed"?(await K(),U&&C({ok:!0,text:me.message||"dbt metadata and governed search indexes are ready."})):me.status==="failed"||me.status==="cancelled"?C({ok:!1,text:me.error||me.message||`dbt preparation ${me.status}.`}):se=window.setTimeout(()=>void je(),650)}catch(ve){U&&C({ok:!1,text:ve instanceof Error?ve.message:String(ve)})}};return se=window.setTimeout(()=>void je(),350),()=>{U=!1,se!==void 0&&window.clearTimeout(se)}},[K,S==null?void 0:S.id,S==null?void 0:S.status]);const oe=async()=>{w("preview"),C(null);try{const U=await B.previewDbtOnboarding(Lk(h));m(U),C({ok:!0,text:`Preview ready: ${U.counts.models??0} models, ${U.counts.sources??0} sources, ${U.counts.metrics??0} metrics. Nothing has changed yet.`})}catch(U){m(null),C({ok:!1,text:U instanceof Error?U.message:String(U)})}finally{w(null)}},ee=async()=>{if(f){w("apply"),C(null);try{const U=await B.applyDbtOnboarding({...f.repoUrl?{repoUrl:f.repoUrl,branch:f.branch,subPath:f.subPath}:{projectDir:f.projectDir},manifestPath:f.manifestPath,profilesDir:f.profilesDir,expectedFingerprint:f.fingerprint}),se=Zs(U);se&&v(se);const je=await K();await F();const ve=je.preparation??se,me=`${f.counts.models??0} models · ${f.counts.sources??0} sources · ${f.counts.metrics??0} metrics`;C({ok:!0,text:(ve==null?void 0:ve.status)==="completed"?ve.message||`Connected ${f.projectName||f.projectDir}. Governed search is ready.`:ve?`Connected ${f.projectName||f.projectDir}. DQL is preparing ${me} for fast governed search in the background.`:`Applied ${f.projectName||f.projectDir}. ${me}.`}),n==null||n({name:f.projectName||"dbt project",path:f.projectDir,summary:me,readiness:(ve==null?void 0:ve.status)==="completed"?"ready":"preparing",readinessDetail:ve==null?void 0:ve.message}),m(null)}catch(U){C({ok:!1,text:U instanceof Error?U.message:String(U)})}finally{w(null)}}},ce=async()=>{w("refresh"),C(null);try{const U=await B.previewDbtOnboarding({}),se=await B.refreshDbtOnboarding({expectedFingerprint:U.fingerprint}),je=Zs(se);je&&v(je);const me=(await K()).preparation??je;C({ok:!0,text:(me==null?void 0:me.status)==="completed"?me.message||"dbt artifacts and governed search indexes are ready.":me?"dbt artifacts refreshed. Governed search indexes are updating in the background.":"dbt artifacts refreshed from the configured project."})}catch(U){C({ok:!1,text:U instanceof Error?U.message:String(U)})}finally{w(null)}},ke=()=>({preference:(x==null?void 0:x.preference)??"auto",dbtCloud:{host:P,environmentId:g,serviceToken:T}}),xe=async U=>{M("apply"),G(null);try{const se=await B.setSemanticRuntimePreference(U);E(se),G({ok:!0,text:`Preferred runtime set to ${ei[U]??U}.`})}catch(se){G({ok:!1,text:se instanceof Error?se.message:String(se)})}finally{M(null)}},De=async()=>{M("test"),G(null);try{const U=await B.testDbtCloudSemanticRuntime(ke());G({ok:U.ok,text:U.message||U.error||"dbt Cloud Semantic Layer test failed."})}finally{M(null)}},We=async()=>{M("apply"),G(null);try{const U=await B.applyDbtCloudSemanticRuntime(ke());E(U),O(""),G({ok:!0,text:`${U.dbtCloud.testMessage||"dbt Cloud Semantic Layer tested."} Compilation is now bound to the active warehouse target.`})}catch(U){G({ok:!1,text:U instanceof Error?U.message:String(U)})}finally{M(null)}},Be=async()=>{if(!L){G({ok:!1,text:"Choose the warehouse adapter used by this dbt project."});return}W(!0),G(null);try{const U=await B.installMetricFlow(L);H(se=>se?{...se,job:U.job}:{job:U.job,recommendedAdapter:L,supportedAdapters:[L],projectConfigured:!0,semanticManifestFound:!1})}catch(U){G({ok:!1,text:U instanceof Error?U.message:String(U)})}finally{W(!1)}},Ee=l,ge=(J==null?void 0:J.job)??null,Je=X||(ge==null?void 0:ge.state)==="queued"||(ge==null?void 0:ge.state)==="running",tt=(ge==null?void 0:ge.state)==="failed",Fe=(S==null?void 0:S.status)==="queued"||(S==null?void 0:S.status)==="running",Ke=(S==null?void 0:S.status)==="failed"||(S==null?void 0:S.status)==="cancelled",gt=t?"Reapply required after DQL update":Ke?"dbt project needs attention":Fe?"Preparing governed search":Ee?"dbt project ready":"dbt project missing",Dt=t?"Review the prefilled project, choose Preview, then Reapply project.":(S==null?void 0:S.message)??(Ee?((en=c==null?void 0:c.dbt)==null?void 0:en.repoUrl)||((En=c==null?void 0:c.dbt)==null?void 0:En.projectDir)||"Configured dbt project.":"Choose a local path or Git repository."),Ct={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"},jt={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)":Ke?"var(--status-error-border)":Fe?"var(--status-info-border)":Ee?"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)":Ke?"var(--status-error)":Fe?"var(--status-info)":Ee?"var(--status-success)":"var(--status-warning)",background:t?"var(--status-warning-bg)":Ke?"var(--status-error-bg)":Fe?"var(--status-info-bg)":Ee?"var(--status-success-bg)":"var(--status-warning-bg)"},children:t?s.jsx(cs,{size:17}):Ke?s.jsx(bv,{size:17}):Fe?s.jsx(qn,{className:"dql-dbt-preparing-icon",size:17}):Ee?s.jsx(up,{size:17}):s.jsx(Dr,{size:17})}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:13,fontWeight:700,color:i.textPrimary},children:gt}),s.jsx("div",{style:{fontSize:11.5,color:Ke?"var(--status-error)":i.textMuted,marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Dt}),Fe?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]}),Ee&&!t?s.jsxs("button",{type:"button",onClick:()=>void ce(),disabled:!!b,style:jt,children:[s.jsx(cs,{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:h,onChange:U=>{d(U.target.value),m(null)},placeholder:". or https://github.com/org/analytics.git",style:Ct})]}),f?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:f.projectName||f.projectDir}),s.jsx("br",{}),f.counts.models??0," models · ",f.counts.sources??0," sources · ",f.counts.metrics??0," metrics",s.jsx("br",{}),s.jsx("span",{style:{fontFamily:i.fontMono},children:f.manifestPath})]}):null,j?s.jsx("div",{role:j.ok?"status":"alert",style:{fontSize:11.5,lineHeight:1.5,color:j.ok?"var(--status-success)":"var(--status-error)"},children:j.text}):null,s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void oe(),disabled:!!b,style:jt,children:b==="preview"?"Inspecting…":"Preview"}),f?s.jsx("button",{type:"button",onClick:()=>void ee(),disabled:!!b,style:{...jt,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."}),x!=null&&x.dbtCloud.configured?s.jsxs("div",{style:{fontSize:10.5,color:x.dbtCloud.targetBindingState==="bound"&&x.dbtCloud.metricInventoryState==="complete"?"var(--status-success)":"var(--status-warning)",marginTop:6,lineHeight:1.5},children:["dbt Cloud target: ",x.dbtCloud.targetBindingState==="bound"?`bound · ${(Tn=x.dbtCloud.executionTargetFingerprint)==null?void 0:Tn.slice(0,12)}`:"reapply required before execution",s.jsx("br",{}),"Metric inventory: ",x.dbtCloud.metricInventoryState,x.dbtCloud.semanticCatalogFingerprint?` · ${x.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:(x==null?void 0:x.preference)??"auto",onChange:U=>{xe(U.target.value)},disabled:_==="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)"})]}),x!=null&&x.runtime.active?s.jsxs("span",{style:{fontSize:10.5,color:i.textMuted},children:["Active: ",s.jsx("strong",{style:{color:i.textSecondary},children:ei[x.runtime.active]??x.runtime.active}),x.preference&&x.preference!=="auto"&&x.preference!==x.runtime.active?` (preferred ${ei[x.preference]??x.preference} is not ready)`:""]}):null]})]}),s.jsx("div",{style:{display:"grid",gap:7},children:((x==null?void 0:x.runtime.adapters)??[]).map(U=>s.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,padding:"9px 10px",display:"grid",gap:U.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:U.ready?"var(--status-success)":U.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:U.label}),(x==null?void 0:x.runtime.active)===U.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:U.detail})]}),s.jsx("span",{style:{fontSize:9.5,color:U.ready?"var(--status-success)":i.textMuted},children:U.ready?"Ready":U.configured?"Configured":"Setup required"})]}),U.id==="metricflow-cli"&&(!U.ready||ge)?s.jsxs("div",{style:{marginLeft:17,paddingTop:9,borderTop:"1px solid var(--border-subtle)",display:"grid",gap:8},children:[U.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:L,onChange:se=>$(se.target.value),disabled:Je,style:{...Ct,width:160,height:32,fontFamily:i.font},children:((J==null?void 0:J.supportedAdapters)??[]).map(se=>s.jsx("option",{value:se,children:se==="postgres"?"PostgreSQL":se.charAt(0).toUpperCase()+se.slice(1)},se))}),s.jsxs("button",{type:"button",onClick:()=>void Be(),disabled:!Ee||Je||!L,style:{...jt,border:"none",background:i.accent,color:"#fff",opacity:!Ee||Je||!L?.55:1,cursor:!Ee||Je?"not-allowed":"pointer"},children:[Je?s.jsx(qn,{className:"dql-dbt-preparing-icon",size:12,style:{verticalAlign:-2,marginRight:6}}):s.jsx(pp,{size:12,style:{verticalAlign:-2,marginRight:6}}),Je?"Installing…":"Install local MetricFlow"]})]}),Ee?null:s.jsx("div",{style:{fontSize:9.5,color:i.textMuted},children:"Connect the dbt project first, then install its matching runtime."})]}),ge?s.jsxs("div",{style:{display:"grid",gap:6},children:[s.jsx("div",{role:tt?"alert":"status",style:{fontSize:10.5,color:tt?"var(--status-error)":ge.state==="completed"?"var(--status-success)":i.textSecondary,lineHeight:1.45},children:ge.message}),ge.state==="queued"||ge.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,ge.progress)}%`,background:i.accent,transition:"width 180ms ease"}})}):null,ge.error||ge.logs.length>0?s.jsxs("details",{children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:9.5,color:i.textMuted},children:tt?"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:tt?"var(--status-error)":i.textMuted},children:[...ge.logs.slice(-30),...ge.error?[ge.error]:[]].join(`
|
|
441
|
+
`)})]}):null]}):null]}):null]},U.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:P,onChange:U=>A(U.target.value),placeholder:"semantic-layer.cloud.getdbt.com",style:Ct})]}),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:U=>I(U.target.value),placeholder:"123456",style:Ct})]}),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:T,onChange:U=>O(U.target.value),placeholder:(x==null?void 0:x.dbtCloud.serviceTokenPreview)||"Semantic Layer service token",autoComplete:"off",style:Ct}),s.jsx("span",{style:{fontSize:9.5,color:i.textMuted},children:"Requires Semantic Layer and Metadata permissions. Leave blank to preserve the stored token."})]}),q?s.jsx("div",{role:q.ok?"status":"alert",style:{fontSize:11,color:q.ok?"var(--status-success)":"var(--status-error)"},children:q.text}):null,s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void De(),disabled:!!_,style:jt,children:_==="test"?"Testing…":"Test draft"}),s.jsx("button",{type:"button",onClick:()=>void We(),disabled:!!_,style:{...jt,border:"none",background:i.accent,color:"#fff"},children:_==="apply"?"Testing & binding…":"Test, bind & save"})]})]})]})]})]})}function Wo(e){return e.map(t=>`${t.catalogOrDatabase}: ${t.schemas.join(", ")}`).join(`
|
|
442
|
+
`)}function ti(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(l=>l.trim()).filter(Boolean);if(!o||i.length===0)continue;const c=o.toLowerCase(),a=t.get(c)??{catalogOrDatabase:o,schemas:new Set};for(const l of i)a.schemas.add(l);t.set(c,a)}return Array.from(t.values()).map(n=>({catalogOrDatabase:n.catalogOrDatabase,schemas:Array.from(n.schemas)}))}function Bk(e,t,n){return e.some(r=>r.catalogOrDatabase.toLowerCase()===t.toLowerCase()&&r.schemas.some(o=>o.toLowerCase()===n.toLowerCase()))}function Fk(e,t,n,r){const o=new Map(e.map(a=>[a.catalogOrDatabase.toLowerCase(),{catalogOrDatabase:a.catalogOrDatabase,schemas:new Map(a.schemas.map(l=>[l.toLowerCase(),l]))}])),i=t.toLowerCase(),c=o.get(i)??{catalogOrDatabase:t,schemas:new Map};return r?c.schemas.set(n.toLowerCase(),n):c.schemas.delete(n.toLowerCase()),c.schemas.size>0?o.set(i,c):o.delete(i),Array.from(o.values()).map(a=>({catalogOrDatabase:a.catalogOrDatabase,schemas:Array.from(a.schemas.values())}))}function zk(e){return e.scopes.reduce((t,n)=>t+n.schemas.filter(r=>!r.inDbtProject).length,0)}const ni={duckdb:"DuckDB",file:"Local File / DuckDB",snowflake:"Snowflake",databricks:"Databricks"},Xo={duckdb:"#f4bc00",file:"#f4bc00",snowflake:"#29b5e8",databricks:"#ff3621"},qk={duckdb:"In-process analytical database",file:"Local CSV / Parquet via DuckDB",snowflake:"Cloud data platform",databricks:"Lakehouse platform"},_s=[{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"}]}],Da=Object.fromEntries(_s.map(e=>[e.driver,e])),Uk=[{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 Hr(e){return e==="postgres"?"postgresql":e}function zi(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 Wk(e){return`${e.profileName}_${e.targetName}`.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"")||"dbt_profile"}function Kk(e){const t={};return Object.entries(e.connection??{}).forEach(([n,r])=>{n!=="driver"&&r!==void 0&&r!==null&&(t[zi(n)]=String(r))}),t}function Vk(e){const n=e.indexOf("/.dbt/");return n>=0?`~${e.slice(n)}`:e.split("/").slice(-3).join("/")}function Hk(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 xl(e,t){return e.startsWith("Error")||e.toLowerCase().includes("failed")?t.error:e.toLowerCase().includes("testing")?t.warning:t.success}function ao(e){const t=Hr(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 Gk(e,t,n,r){const o=r!==null&&r===t,i=!!(t&&e[t]),c=e[n];return r===null||o||!i||t==="default"&&ao(e.default)&&!ao(c)?n:t}function Qk(e){const t=Object.keys(e);return t.find(n=>!ao(e[n]))??t[0]}function qp({variant:e="panel",onConfigured:t}={}){var Wa,Ka,Va,Ha,Ga;const n=Ge(Ir(D=>({settingsTab:D.settingsTab,themeMode:D.themeMode}))),r=Cn(),o=Qe[n.themeMode],i=e==="page",c=e==="setup",[a,l]=p.useState(null),[u,h]=p.useState(!1),[d,f]=p.useState(null),[m,S]=p.useState(null),[v,b]=p.useState(!1),[w,j]=p.useState(!1),[C,x]=p.useState(null),[E,P]=p.useState(null),[A,g]=p.useState(""),[I,T]=p.useState(!1),[O,_]=p.useState(null),[M,q]=p.useState([]),[G,J]=p.useState(!1),[H,L]=p.useState(null),[$,X]=p.useState("dbt_relations"),[W,te]=p.useState(""),[F,K]=p.useState(!1),[oe,ee]=p.useState(null),[ce,ke]=p.useState(null),[xe,De]=p.useState(!1),[We,Be]=p.useState(""),[Ee,ge]=p.useState("duckdb"),[Je,tt]=p.useState({}),[Fe,Ke]=p.useState("duckdb"),[gt,Dt]=p.useState({}),Ct=p.useRef(null);p.useEffect(()=>{B.getConnections().then(D=>{l(D),D.metadataScope&&(X(D.metadataScope.mode),te(Wo(D.metadataScope.selectedScopes??D.metadataScope.scopes)))})},[]);const jt=a?`${a.default}:${JSON.stringify(((Wa=a.connections)==null?void 0:Wa[a.default])??null)}`:"";p.useEffect(()=>{if(!a||i&&n.settingsTab!=="database"||!Object.values(a.connections).some(z=>!ao(z)))return;let D=!0;return h(!0),B.testConnection().then(z=>{D&&f(z)}).catch(z=>{D&&f({ok:!1,message:z instanceof Error?z.message:String(z)})}).finally(()=>{D&&h(!1)}),()=>{D=!1}},[jt,i,n.settingsTab]),p.useEffect(()=>{if(!i)return;let D=!0;return Promise.all([B.getProviderSettings(),B.getOnboardingStatus(),B.getBlockStudioDbtStatus().catch(()=>null)]).then(([z,ae,re])=>{var ue;D&&(q(z.providers),J(((ue=ae.dbt)==null?void 0:ue.configured)===!0||!!(re!=null&&re.configured&&re.artifacts.manifest.exists)),L(ae.preparation??null))}).catch(()=>{}),()=>{D=!1}},[i]),p.useEffect(()=>{if(!i||!H||H.status!=="queued"&&H.status!=="running")return;let D=!0,z;const ae=async()=>{var re,ue,we;try{const Ve=await B.getOnboardingStatus();if(!D)return;L(Ve.preparation??null),J(((re=Ve.dbt)==null?void 0:re.configured)===!0),(((ue=Ve.preparation)==null?void 0:ue.status)==="queued"||((we=Ve.preparation)==null?void 0:we.status)==="running")&&(z=window.setTimeout(()=>void ae(),700))}catch{}};return z=window.setTimeout(()=>void ae(),500),()=>{D=!1,z!==void 0&&window.clearTimeout(z)}},[H==null?void 0:H.id,H==null?void 0:H.status,i]),p.useEffect(()=>{var re;if(!a)return;const D=a.default,z=D?(re=a.connections)==null?void 0:re[D]:void 0,ae=z?`${D}::${JSON.stringify(z)}`:"::none";if(Ct.current!==ae)if(Ct.current=ae,z){Ke(Hr(String(z.driver??z.type??"duckdb")));const ue={};Object.entries(z).forEach(([we,Ve])=>{we!=="driver"&&we!=="type"&&(ue[zi(we)]=String(Ve??""))}),Dt(ue)}else Ke("duckdb"),Dt({})},[a]);const Zt=async()=>{if(!a||Object.keys(a.connections??{}).length===0){f({ok:!1,message:"Add or import a connection before testing."});return}h(!0),f(null);const D=await B.testConnection();f(D),D.ok&&(t==null||t(D.message)),h(!1)},en=D=>{l(z=>z&&{...z,metadataScope:D.scope,metadataStatus:D.status}),X(D.scope.mode),te(Wo(D.scope.selectedScopes??D.scope.scopes))},En=async()=>{if(!(!(a!=null&&a.default)||!(d!=null&&d.ok))){De(!0),ee("Finding databases/catalogs and schemas visible to this connection…");try{const D=await B.discoverConnectionMetadataScopes(a.default);ke(D),ee(D.message)}catch(D){ke(null),ee(D instanceof Error?D.message:String(D))}finally{De(!1)}}},Tn=(D,z,ae)=>{const re=Fk(ti(W),D,z,ae);te(Wo(re)),X(((ce==null?void 0:ce.dbtScopes.length)??0)>0?"dbt_plus_selected":"selected_scopes")},U=async()=>{if(!(a!=null&&a.default))return;const D=ti(W);if($==="selected_scopes"&&D.length===0){ee("Add at least one line such as ANALYTICS_PROD: SALES, FINANCE.");return}K(!0),ee("Synchronizing selected metadata into local SQLite…");try{const z=await B.applyConnectionMetadataScope(a.default,{mode:$,...$==="dbt_relations"?{}:{scopes:D}});en(z),ee(`Ready · ${z.status.relationCount.toLocaleString()} relations · ${z.status.columnCount.toLocaleString()} columns · ${z.status.queryCount??0} metadata queries`)}catch(z){ee(z instanceof Error?z.message:String(z))}finally{K(!1)}},se=async()=>{if(a!=null&&a.default){K(!0),ee("Refreshing the applied metadata scope…");try{const D=await B.refreshConnectionMetadata(a.default);en(D),ee(`Refreshed · ${D.status.relationCount.toLocaleString()} relations · ${D.status.columnCount.toLocaleString()} columns`)}catch(D){ee(D instanceof Error?D.message:String(D))}finally{K(!1)}}},je=(D,z)=>{S(D),b(!1),Be(D),ge(Hr((z==null?void 0:z.driver)??(z==null?void 0:z.type)??"duckdb"));const ae={};Object.entries(z??{}).forEach(([re,ue])=>{re!=="driver"&&re!=="type"&&(ae[zi(re)]=String(ue??""))}),tt(ae)},ve=()=>{b(!0),S(null),Be(""),ge("duckdb"),tt({})},me=()=>{S(null),b(!1)},tn=async D=>{P(D),x(null);try{const z=await B.installConnector(D);if(z.connectorStatus&&a)l({...a,connectorStatus:z.connectorStatus});else{const ae=await B.getConnections();l(ae)}x(z.ok?"Connector installed":`Error: ${z.error??"Install failed"}`)}catch(z){x(`Error: ${(z==null?void 0:z.message)??"Install failed"}`)}finally{P(null)}},ie=async D=>{if(!a)return!1;j(!0),x(null);const z=D.name.trim()||(D.previousName??"default"),ae={driver:D.driver},re=Da[D.driver],ue=new Map(((re==null?void 0:re.fields)??[]).map(Ye=>[Ye.key,Ye]));Object.entries(D.fields).forEach(([Ye,nt])=>{const Tt=ue.get(Ye);if((Tt==null?void 0:Tt.type)==="checkbox"){nt!==""&&(ae[Ye]=nt==="true");return}const Ao=nt.trim();Ao&&((Tt==null?void 0:Tt.type)==="number"&&!isNaN(Number(Ao))?ae[Ye]=Number(Ao):ae[Ye]=Ao)});const we={...a.connections},Ve=a.default,Xn={...a.connections};D.previousName&&D.previousName!==z&&delete Xn[D.previousName],Xn[z]=ae;const vf=Gk(Xn,a.default,z,D.previousName);let Qa=!1;try{await B.saveConnections(Xn,vf);const Ye=await B.getConnections();l(Ye),Ye.metadataScope&&(X(Ye.metadataScope.mode),te(Wo(Ye.metadataScope.selectedScopes??Ye.metadataScope.scopes))),ke(null),x("Saved. Testing connection..."),S(null),b(!1);try{h(!0);const nt=await B.testConnection();if(f(nt),Qa=nt.ok,nt.ok)x("Test passed. Connection saved and activated."),t==null||t(nt.message),setTimeout(()=>x(null),2e3);else{await B.saveConnections(we,Ve||void 0);const Tt=await B.getConnections();l(Tt),x(`Test failed. Previous connection preserved: ${nt.message}`)}}catch(nt){await B.saveConnections(we,Ve||void 0).catch(()=>{});const Tt=await B.getConnections().catch(()=>null);Tt&&l(Tt),x(`Test failed. Previous connection preserved: ${nt.message??"Connection failed"}`)}finally{h(!1)}}catch(Ye){await B.saveConnections(we,Ve||void 0).catch(()=>{});const nt=await B.getConnections().catch(()=>null);nt&&l(nt),x(`Test or save failed. Previous connection preserved: ${Ye.message}`)}finally{j(!1)}return Qa},Y=D=>{const z=Hr(String(D.connection.driver??D.adapter??"duckdb")),ae=Kk(D);f(null),(i||c)&&(Ke(z),Dt(ae)),b(!1),S(null),ie({name:Wk(D),driver:z,fields:ae,previousName:null})},$e=async()=>{const D=A.trim();if(!D){_("Enter a profiles.yml file or folder path.");return}T(!0),_(null);try{const z=await B.previewDbtProfiles(D);l(ae=>{if(!ae)return ae;const re=new Map((ae.dbtProfiles??[]).map(ue=>[ue.id,ue]));return z.dbtProfiles.forEach(ue=>re.set(ue.id,ue)),{...ae,dbtProfiles:[...re.values()]}})}catch(z){_(z instanceof Error?z.message:"Could not read that profiles.yml path.")}finally{T(!1)}},Jn=()=>ie({name:We,driver:Ee,fields:Je,previousName:m}),Yn=()=>ie({name:(a==null?void 0:a.default)||"default",driver:Fe,fields:gt,previousName:(a==null?void 0:a.default)||null}),ko=D=>{Ke(D),Dt({}),f(null)},lf=async D=>{if(!a)return;const z={...a.connections};delete z[D];const ae=D===a.default?Qk(z):a.default;j(!0);try{await B.saveConnections(z,ae);const re=await B.getConnections();l(re),S(null)}finally{j(!1)}},df=async D=>{if(!a)return;const z=a.default;j(!0),x(null);try{await B.saveConnections(a.connections,D);const ae=await B.getConnections();l(ae),x("Default updated. Testing connection..."),h(!0);const re=await B.testConnection();if(f(re),re.ok)x("Test passed. Default connection updated."),t==null||t(re.message),setTimeout(()=>x(null),2e3);else{await B.saveConnections(a.connections,z||void 0);const ue=await B.getConnections();l(ue),x(`Test failed. Previous default preserved: ${re.message}`)}}catch(ae){await B.saveConnections(a.connections,z||void 0).catch(()=>{});const re=await B.getConnections().catch(()=>null);re&&l(re),x(`Test or save failed. Previous default preserved: ${ae.message}`)}finally{h(!1),j(!1)}},Co={fontSize:10,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",color:o.textMuted,fontFamily:o.font,marginBottom:6},jo={background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderRadius:7,padding:"10px 12px",marginBottom:10},Eo=(a==null?void 0:a.connections)??{},uf=(a==null?void 0:a.default)??"",Na=(a==null?void 0:a.dbtProfiles)??[],Ba=Object.fromEntries(((a==null?void 0:a.connectorStatus)??[]).map(D=>[D.driver,D])),Fa=Object.keys(Eo).length,To=Fa>0,pf=s.jsxs(s.Fragment,{children:[s.jsx("div",{style:Co,children:"Connections"}),a===null?s.jsx("div",{style:{fontSize:12,color:o.textMuted,fontFamily:o.font},children:"Loading…"}):Object.entries(Eo).map(([D,z])=>{const ae=(z==null?void 0:z.driver)??(z==null?void 0:z.type)??"unknown",re=D===uf,ue=Xo[ae]??o.accent;return m===D?s.jsx(vl,{t:o,editName:We,setEditName:Be,editDriver:Ee,setEditDriver:ge,editFields:Je,setEditFields:tt,onSave:Jn,onCancel:me,onDelete:()=>lf(D),saving:w,isNew:!1},D):s.jsxs("div",{style:{...jo,borderLeft:re?`3px solid ${ue}`:`1px solid ${o.cellBorder}`},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[s.jsx(Vr,{driver:ae,size:18,fallbackColor:ue}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:ni[ae]??ae}),s.jsx("span",{style:{fontSize:11,fontFamily:o.fontMono,color:o.textMuted},children:D}),re&&(d==null?void 0:d.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`}}),re&&d&&!d.ok&&s.jsx("span",{title:d.message,"aria-label":"Disconnected",style:{width:7,height:7,borderRadius:"50%",background:o.error,flexShrink:0,boxShadow:`0 0 0 2px ${o.error}25`}}),re&&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}}),!re&&s.jsx("button",{onClick:()=>df(D),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:()=>je(D,z),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(z??{}).filter(([we])=>we!=="driver"&&we!=="type").map(([we,Ve])=>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:we}),s.jsx("span",{style:{fontSize:11,color:o.textSecondary,fontFamily:o.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Hk(we)?"••••••••":String(Ve)})]},we))})]},D)}),a!==null&&Fa===0&&s.jsx("div",{style:{...jo,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."})]}),za=s.jsxs("div",{style:{...jo,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:A,onChange:D=>g(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),$e())},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 $e(),disabled:I,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:I?"wait":"pointer"},children:I?"Reading…":"Find profiles"})]}),O?s.jsx("div",{role:"alert",style:{marginTop:6,color:o.error,fontSize:10.5,fontFamily:o.font},children:O}):null]}),qa=s.jsx(s.Fragment,{children:!v&&!m&&Na.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...Co,marginTop:8},children:"dbt profiles"}),s.jsx("div",{style:{display:"grid",gap:8,marginBottom:12},children:Na.map(D=>{var we;const z=Hr(String(D.connection.driver??D.adapter)),ae=Xo[z]??o.accent,re=D.missingFields.length===0,ue=((we=a==null?void 0:a.activeConnection)==null?void 0:we.source)==="dbt_profile"&&a.activeConnection.profileId===D.id;return s.jsxs("div",{style:{...jo,marginBottom:0,display:"flex",alignItems:"center",gap:10},children:[s.jsx(Vr,{driver:z,size:18,fallbackColor:ae}),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:D.profileName}),s.jsx("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono},children:D.targetName})]}),s.jsxs("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[ni[z]??D.adapter," from ",Vk(D.path)]}),s.jsx("div",{style:{fontSize:10,color:re?o.success:o.warning,fontFamily:o.font,marginTop:2},children:re?ue?"Active runtime connection · import to save":"Ready to import and test":`Imports now · needs ${D.missingFields.join(", ")}`})]}),s.jsx("button",{onClick:()=>Y(D),disabled:w,title:D.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"})]},D.id)})})]})}),ff=s.jsx(s.Fragment,{children:!v&&!m&&Object.keys(Eo).length===0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...Co,marginTop:8},children:"Quick Connect"}),s.jsx("div",{style:{display:"grid",gap:6,marginBottom:12},children:Uk.map(D=>s.jsxs("button",{onClick:async()=>{j(!0);try{const z={...Eo,[D.name]:D.config};await B.saveConnections(z,D.name);const ae=await B.getConnections();l(ae),h(!0);const re=await B.testConnection();f(re),h(!1)}finally{j(!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(Vr,{driver:D.config.driver,size:18}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:D.label}),s.jsx("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:D.description})]})]},D.name))})]})}),hf=s.jsx(s.Fragment,{children:v?s.jsx(vl,{t:o,editName:We,setEditName:Be,editDriver:Ee,setEditDriver:ge,editFields:Je,setEditFields:tt,onSave:Jn,onCancel:me,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"]})}),mf=s.jsx(s.Fragment,{children:C&&s.jsx("div",{style:{fontSize:11,fontFamily:o.font,padding:"4px 10px",borderRadius:4,marginBottom:8,color:xl(C,o),background:`${xl(C,o)}12`},children:C})}),gf=s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:Zt,disabled:u||!To,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:u||!To?"not-allowed":"pointer",marginBottom:8,opacity:u||!To?.7:1,transition:"all 0.15s"},children:u?"Testing...":To?"Test Connection":"Add connection to test"}),d&&s.jsxs("div",{style:{fontSize:12,fontFamily:o.font,color:d.ok?o.success:o.error,background:d.ok?`${o.success}12`:`${o.error}12`,border:`1px solid ${d.ok?o.success:o.error}40`,borderRadius:6,padding:"7px 10px",marginBottom:12},children:[d.ok?"✓ ":"✗ ",d.message]})]}),yf=s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{...Co,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:_s.map(({driver:D,label:z})=>{const ae=Xo[D]??o.accent,re=qk[D]??"",ue=Ba[D],we=(ue==null?void 0:ue.installed)??!0,Ve=(ue==null?void 0:ue.builtIn)??!1,Xn=E===D;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(Vr,{driver:D,size:18,fallbackColor:ae}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:o.textPrimary,fontFamily:o.font},children:z})]}),s.jsx("div",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font,lineHeight:1.35},children:re}),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:we?o.success:o.warning,letterSpacing:"0.05em",textTransform:"uppercase"},children:Ve?"Built in":we?"Installed":"Install required"}),!we&&s.jsx("button",{onClick:()=>tn(D),disabled:!!E,title:ue==null?void 0:ue.installCommand,style:{border:`1px solid ${o.btnBorder}`,background:o.btnBg,color:o.textSecondary,borderRadius:4,padding:"2px 7px",fontSize:10,fontFamily:o.font,cursor:E?"not-allowed":"pointer",whiteSpace:"nowrap"},children:Xn?"Installing...":"Install"})]}),s.jsx("code",{style:{fontSize:9,color:o.textMuted,fontFamily:o.fontMono},children:D})]},D)})})]}),Et=!!(a&&Object.values(a.connections??{}).some(D=>!ao(D))),Me=a==null?void 0:a.metadataStatus,bf=ti(W),xf=Et?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 En(),disabled:xe||F||!(d!=null&&d.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:xe||F||!(d!=null&&d.ok)?"not-allowed":"pointer",opacity:d!=null&&d.ok?1:.55,fontFamily:o.font},children:xe?"Finding available schemas…":"Find available databases & schemas"})}),ce?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:[ce.dbtScopes.reduce((D,z)=>D+z.schemas.length,0).toLocaleString()," dbt-covered schema(s)"," · ",zk(ce).toLocaleString()," additional schema(s) available"," · ",ce.queryCount.toLocaleString()," discovery query(s)"]}),ce.scopes.map(D=>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:D.catalogOrDatabase}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:5},children:D.schemas.map(z=>{const ae=Bk(bf,D.catalogOrDatabase,z.name);return s.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:7,fontSize:11,lineHeight:1.35,color:z.inDbtProject?o.textMuted:o.textSecondary,fontFamily:o.font,cursor:z.inDbtProject?"default":"pointer"},children:[s.jsx("input",{type:"checkbox",checked:z.inDbtProject||ae,disabled:z.inDbtProject||F,onChange:re=>Tn(D.catalogOrDatabase,z.name,re.target.checked),style:{marginTop:1}}),s.jsxs("span",{children:[s.jsx("span",{style:{fontFamily:o.fontMono},children:z.name}),z.inDbtProject?` · in dbt (${z.dbtRelationCount} relation${z.dbtRelationCount===1?"":"s"}), included automatically`:" · outside dbt, select only if reporting needs it"]})]},`${D.catalogOrDatabase}.${z.name}`)})})]},D.catalogOrDatabase)),ce.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:$,onChange:D=>X(D.target.value),disabled:F,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"})]})]}),$!=="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:W,onChange:D=>te(D.target.value),disabled:F,placeholder:`ANALYTICS_PROD: SALES, FINANCE
|
|
443
|
+
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,Me?s.jsxs("div",{style:{fontSize:11.5,color:Me.state==="ready"?"var(--status-success)":"var(--status-warning)",fontFamily:o.font},children:[Me.state==="ready"?"Warehouse metadata index ready":Me.state==="stale"?"Warehouse metadata refresh required":G?"Optional warehouse metadata index not synchronized · dbt project objects remain available":"Warehouse metadata index not synchronized"," · ",Me.relationCount.toLocaleString()," indexed warehouse relations"," · ",Me.columnCount.toLocaleString()," indexed warehouse columns",Me.capturedAt?` · ${new Date(Me.capturedAt).toLocaleString()}`:""]}):null,Me!=null&&Me.observedTarget?s.jsx("div",{style:{fontSize:10.5,color:o.textMuted,fontFamily:o.fontMono},children:[Me.observedTarget.accountOrWorkspace,Me.observedTarget.role,Me.observedTarget.warehouse,Me.observedTarget.defaultCatalogOrDatabase,Me.observedTarget.defaultSchema].filter(Boolean).join(" · ")}):null,oe?s.jsx("div",{style:{fontSize:11.5,color:oe.toLowerCase().includes("failed")||oe.toLowerCase().includes("error")?"var(--status-error)":o.textSecondary,fontFamily:o.font},children:oe}):null,s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("button",{type:"button",onClick:()=>void U(),disabled:F||!(d!=null&&d.ok),style:{height:32,padding:"0 13px",borderRadius:8,border:"none",background:o.accent,color:"var(--accent-fg)",fontSize:12,fontWeight:700,cursor:F||!(d!=null&&d.ok)?"not-allowed":"pointer",opacity:F||!(d!=null&&d.ok)?.55:1,fontFamily:o.font},children:F?"Synchronizing…":"Apply and synchronize"}),s.jsx("button",{type:"button",onClick:()=>void se(),disabled:F||(Me==null?void 0:Me.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:F?"not-allowed":"pointer",fontFamily:o.font},children:"Refresh metadata"})]}),d!=null&&d.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,Ua=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 ${d!=null&&d.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:Et?"var(--status-success-bg)":"var(--status-warning-bg)",color:Et?"var(--status-success)":"var(--status-warning)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx(So,{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:[ni[String(((Va=(Ka=a==null?void 0:a.connections)==null?void 0:Ka[(a==null?void 0:a.default)??""])==null?void 0:Va.driver)??"")]??((Ga=(Ha=a==null?void 0:a.connections)==null?void 0:Ha[(a==null?void 0:a.default)??""])==null?void 0:Ga.driver)??"No connection yet",Et?" · configured":""]}),s.jsx("div",{style:{fontSize:11.5,marginTop:2,color:u?o.textMuted:d?d.ok?"var(--status-success)":"var(--status-error)":o.textMuted},children:u?"Testing…":d?d.ok?`Test passed · ${d.message}`:`Test failed · ${d.message}`:Et?"Configured — run Test connection to verify.":"Add a connection below to get started."})]}),s.jsx("button",{type:"button",onClick:()=>void Zt(),disabled:u||!Et,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:Et?"pointer":"not-allowed",fontFamily:o.font,flexShrink:0,opacity:Et?1:.55},children:u?"Testing…":"Test connection"})]}),s.jsxs("div",{style:{maxWidth:640},children:[za,qa]}),s.jsx(Zk,{t:o,driver:Fe,fields:gt,onDriverChange:ko,onFieldsChange:Dt,onSave:()=>void Yn(),saving:w,saveMessage:C,connectorStatus:Ba[Fe],installing:E===Fe,onInstall:()=>void tn(Fe)}),xf]});if(c)return Ua;if(i){const D=n.settingsTab,z=M.some(re=>re.configured&&re.enabled),ae=(re,ue,we,Ve)=>s.jsxs("button",{type:"button",onClick:we,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:re?"var(--accent-dim)":"transparent",color:re?o.accent:o.textSecondary},children:[s.jsx("span",{style:{flex:1},children:ue}),Ve]},ue);return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:Yk}),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:[ae(D==="overview","Overview",()=>r({type:"SET_SETTINGS_TAB",tab:"overview"})),ae(D==="project","Project & dbt",()=>r({type:"SET_SETTINGS_TAB",tab:"project"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:(H==null?void 0:H.status)==="failed"?"var(--status-error)":(H==null?void 0:H.status)==="running"||(H==null?void 0:H.status)==="queued"?"var(--status-info)":G?"var(--status-success)":"var(--status-warning)"},title:(H==null?void 0:H.status)==="failed"?"Needs attention":(H==null?void 0:H.status)==="running"||(H==null?void 0:H.status)==="queued"?"Preparing":G?"Ready":"Missing"})),ae(D==="database","Database",()=>r({type:"SET_SETTINGS_TAB",tab:"database"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:Et?"var(--status-success)":"var(--status-warning)"},title:Et?"Configured":"Missing"})),ae(D==="ai","AI provider",()=>r({type:"SET_SETTINGS_TAB",tab:"ai"}),s.jsx("span",{style:{width:7,height:7,borderRadius:999,background:z?"var(--status-success)":"var(--status-warning)"},title:z?"Configured":"Optional · missing"})),ae(D==="memory","Agent memory",()=>r({type:"SET_SETTINGS_TAB",tab:"memory"})),s.jsx("div",{style:{height:1,background:o.cellBorder,margin:"10px 10px 10px 0"}}),ae(D==="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:D==="overview"?s.jsx(Jk,{dbtConfigured:G,dbtPreparation:H,databaseConfigured:Et,databaseTest:d,providers:M}):D==="project"?s.jsx(Nk,{onConfigured:()=>{J(!0),B.getOnboardingStatus().then(re=>L(re.preparation??null)).catch(()=>{})}}):D==="advanced"?s.jsx(Ys,{embedded:!0,section:"advanced"}):D==="database"?Ua:D==="ai"?s.jsx(Ys,{embedded:!0,section:"providers",onProviderConfigured:re=>q(ue=>ue.map(we=>we.id===re.id?re:{...we,active:!1}))}):s.jsx(Ys,{embedded:!0,section:"memory"})})]})]})}return s.jsxs(ka,{title:"Connections",bodyPadding:12,children:[pf,za,qa,ff,hf,mf,gf,yf]})}function Jk({dbtConfigured:e,dbtPreparation:t,databaseConfigured:n,databaseTest:r,providers:o}){const i=Ge(d=>d.themeMode),c=Cn(),a=Qe[i],l=o.find(d=>d.active&&d.configured)??o.find(d=>d.enabled&&d.configured),u=[{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(Dr,{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(So,{size:18})},{title:"AI provider",detail:l?`${l.label}${l.model?` · ${l.model}`:""}. Run Test to verify reachability.`:"Optional. Deterministic and non-AI workflows remain available.",state:l?"configured":"missing",tab:"ai",icon:s.jsx(gp,{size:18}),optional:!0}],h={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:()=>c({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(ES,{size:14})," Guided Setup"]})]}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:12},children:u.map(d=>{const f=d.state==="configured"||d.state==="passed",m=d.state==="preparing",S=d.state==="failed",v=S?"var(--status-error)":m?"var(--status-info)":f?"var(--status-success)":"var(--status-warning)",b=S?"var(--status-error-bg)":m?"var(--status-info-bg)":f?"var(--status-success-bg)":"var(--status-warning-bg)";return s.jsxs("button",{type:"button",onClick:()=>c({type:"SET_SETTINGS_TAB",tab:d.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:v,background:b},children:f?s.jsx(up,{size:18}):d.icon}),s.jsx("span",{style:{fontSize:13.5,fontWeight:700,color:a.textPrimary,marginTop:12},children:d.title}),s.jsxs("span",{style:{fontSize:11,fontWeight:700,color:v,marginTop:4},children:[h[d.state],d.optional?" · optional":""]}),s.jsx("span",{style:{fontSize:11.5,color:a.textMuted,lineHeight:1.45,marginTop:7},children:d.detail})]},d.title)})}),l?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 Yk=`
|
|
444
|
+
.dql-connection-page-stack {
|
|
445
|
+
display: grid;
|
|
446
|
+
gap: 16px;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.dql-connection-page-grid {
|
|
450
|
+
display: grid;
|
|
451
|
+
grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
|
|
452
|
+
gap: 16px;
|
|
453
|
+
align-items: start;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
@media (max-width: 920px) {
|
|
457
|
+
.dql-connection-page-grid {
|
|
458
|
+
grid-template-columns: minmax(0, 1fr);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
@keyframes dql-connector-shimmer {
|
|
463
|
+
0% { opacity: 1; }
|
|
464
|
+
50% { opacity: 0.45; }
|
|
465
|
+
100% { opacity: 1; }
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.dql-connector-installing {
|
|
469
|
+
animation: dql-connector-shimmer 1.4s ease-in-out infinite;
|
|
470
|
+
}
|
|
471
|
+
`;function vl({t:e,editName:t,setEditName:n,editDriver:r,setEditDriver:o,editFields:i,setEditFields:c,onSave:a,onCancel:l,onDelete:u,saving:h,isNew:d}){const f=Da[r],m=(f==null?void 0:f.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%"},v={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:d?"New Connection":"Edit Connection"}),s.jsxs("div",{style:{marginBottom:6},children:[s.jsx("div",{style:v,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:v,children:"Driver"}),s.jsx("select",{style:{...S,fontFamily:e.font},value:r,onChange:b=>{o(b.target.value),c({})},children:_s.map(b=>s.jsx("option",{value:b.driver,children:b.label},b.driver))})]}),m.map(b=>s.jsxs("div",{style:{marginBottom:6},children:[s.jsxs("div",{style:v,children:[b.label,b.required?" *":""]}),b.type==="select"?s.jsxs("select",{style:{...S,fontFamily:e.font},value:i[b.key]??"",onChange:w=>c({...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=>c({...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=>c({...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=>c({...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:h,style:{flex:1,padding:"5px 0",borderRadius:5,border:"none",background:e.accent,color:"#fff",fontSize:11,fontFamily:e.font,fontWeight:600,cursor:h?"not-allowed":"pointer",opacity:h?.6:1},children:h?"Saving…":"Save"}),s.jsx("button",{onClick:l,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"}),u&&!d&&s.jsx("button",{onClick:u,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 Xk(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 Sl=new Set(["filepath","httpPath","accessUrl"]);function Zk({t:e,driver:t,fields:n,onDriverChange:r,onFieldsChange:o,onSave:i,saving:c,saveMessage:a,connectorStatus:l,installing:u,onInstall:h}){const[d,f]=p.useState(!1),m=Da[t],S=(m==null?void 0:m.fields)??[],v=Xk(t,n),b=new Set(v),w=S.filter(x=>b.has(x.key)),j=S.filter(x=>!b.has(x.key)),C=(x,E)=>o({...n,[x]:E});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:x=>r(x.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:_s.map(({driver:x,label:E})=>s.jsx("option",{value:x,children:E},x))})]}),s.jsx(e1,{t:e,driver:t,label:(m==null?void 0:m.label)??t,status:l,installing:u,onInstall:h}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:w.map(x=>s.jsx(wl,{t:e,field:x,value:n[x.key]??"",onChange:E=>C(x.key,E),fullWidth:Sl.has(x.key)},x.key))}),j.length>0&&s.jsxs("details",{open:d,onToggle:x=>f(x.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:d?"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:[j.length," more"]})]}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12},children:j.map(x=>s.jsx(wl,{t:e,field:x,value:n[x.key]??"",onChange:E=>C(x.key,E),fullWidth:Sl.has(x.key)||x.type==="textarea"},x.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:c,style:{height:30,padding:"0 15px",borderRadius:8,border:"none",background:e.accent,color:"#fff",fontSize:12,fontWeight:650,cursor:c?"not-allowed":"pointer",fontFamily:e.font,boxShadow:"0 1px 4px rgba(107,93,211,0.25)",opacity:c?.7:1},children:c?"Saving…":"Save connection"})]})]})}function e1({t:e,driver:t,label:n,status:r,installing:o,onInstall:i}){const c=(r==null?void 0:r.builtIn)??!0,a=(r==null?void 0:r.installed)??!0,l=!a&&!c,u=o||l?e.warning:e.success,h=o||l?"var(--status-warning-bg)":"var(--status-success-bg)",d=o||l?"var(--status-warning-border)":"var(--status-success-border)",f=o?"Installing connector package…":c?"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 ${d}`,borderRadius:9,background:h,padding:"10px 12px"},children:[s.jsx(Vr,{driver:t,size:18,fallbackColor:Xo[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:u,fontFamily:e.font,marginTop:1},children:f})]}),l||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:u,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"})}),c?"Ready":"Installed"]})]})}function wl({t:e,field:t,value:n,onChange:r,fullWidth:o}){const[i,c]=p.useState(!1),l={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"},u={display:"flex",flexDirection:"column",gap:4,gridColumn:o?"1 / -1":void 0},h=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:{...u,flexDirection:"row",alignItems:"center",gap:8},children:[s.jsx("input",{type:"checkbox",checked:n==="true",onChange:d=>r(d.target.checked?"true":"false")}),h]}):s.jsxs("label",{style:u,children:[h,t.type==="select"?s.jsxs("select",{value:n,onChange:d=>r(d.target.value),onFocus:()=>c(!0),onBlur:()=>c(!1),style:{...l,fontFamily:e.font,fontSize:12.5,padding:"8px 9px"},children:[s.jsx("option",{value:"",children:"Default"}),(t.options??[]).map(d=>s.jsx("option",{value:d.value,children:d.label},d.value))]}):t.type==="textarea"?s.jsx("textarea",{value:n,placeholder:t.placeholder??"",onChange:d=>r(d.target.value),onFocus:()=>c(!0),onBlur:()=>c(!1),style:{...l,minHeight:72,resize:"vertical"}}):s.jsx("input",{type:t.type==="password"?"password":t.type==="number"?"number":"text",value:n,placeholder:t.placeholder??"",onChange:d=>r(d.target.value),onFocus:()=>c(!0),onBlur:()=>c(!1),style:l}),t.helpText&&s.jsx("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font,lineHeight:1.35},children:t.helpText})]})}const t1=Object.freeze(Object.defineProperty({__proto__:null,ConnectionPanel:qp},Symbol.toStringTag,{value:"Module"}));function n1({type:e}){const t=ww[e]??"#8b949e";return s.jsx("span",{style:{color:t,fontSize:10,fontWeight:700,textTransform:"uppercase",minWidth:34},title:Sp[e]??e,children:kw[e]??e.slice(0,4).toUpperCase()})}function r1({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 Up({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(n1,{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 o1=30,ri=200;function ut(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 oi({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 ot({title:e,nodes:t,t:n,onSelect:r,secondaryFor:o}){const i=t.length>o1,[c,a]=p.useState(!i),[l,u]=p.useState(ri);if(t.length===0)return null;const h=c?Math.min(l,t.length):0,d=Math.max(0,t.length-h);return s.jsxs("div",{style:{padding:"8px 0",borderTop:`1px solid ${n.headerBorder}`},children:[s.jsxs("button",{onClick:()=>a(f=>!f),"aria-expanded":c,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:c?"▾":"▸"}),s.jsx("span",{children:e}),s.jsx("span",{style:{marginLeft:"auto",fontWeight:500},children:t.length})]}),c&&t.slice(0,h).map(f=>s.jsx(Up,{node:f,t:n,onClick:()=>r(f),secondary:o==null?void 0:o(f)},f.id)),c&&d>0&&s.jsxs("button",{onClick:()=>u(f=>f+ri),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(ri,d)," more (",d," hidden)"]})]})}function s1({variant:e="sidebar"}){const{state:t,dispatch:n}=et(),r=Qe[t.themeMode],o=e==="page",[i,c]=p.useState(()=>typeof window<"u"?window.innerWidth<700:!1),[a,l]=p.useState(!0),[u,h]=p.useState([]),[d,f]=p.useState([]),[m,S]=p.useState(""),[v,b]=p.useState([]),w=p.useCallback(async()=>{l(!0);const g=await B.fetchLineage();h(g.nodes??[]),f(g.edges??[]),l(!1)},[]);p.useEffect(()=>{w()},[w]),p.useEffect(()=>{if(!o)return;const g=()=>c(window.innerWidth<700);return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[o]),p.useEffect(()=>{let g=!1;if(m.trim().length<2){b([]);return}return B.searchLineage(m.trim()).then(I=>{g||b(I.matches??[])}),()=>{g=!0}},[m]);const j=p.useCallback(g=>{n({type:"OPEN_LINEAGE_DETAIL",nodeId:g.id})},[n]),[C,x]=p.useState("type"),E=p.useMemo(()=>({terms:u.filter(g=>g.type==="term"),businessViews:u.filter(g=>g.type==="business_view"),dashboards:u.filter(g=>g.type==="dashboard"),notebooks:u.filter(g=>g.type==="notebook"),apps:u.filter(g=>g.type==="app"),charts:u.filter(g=>g.type==="chart"),blocks:u.filter(g=>g.type==="block"),metrics:u.filter(g=>g.type==="metric"),dimensions:u.filter(g=>g.type==="dimension"),dbtModels:u.filter(g=>g.type==="dbt_model"),dbtSources:u.filter(g=>g.type==="dbt_source"),tables:u.filter(g=>g.type==="source_table"),domains:u.filter(g=>g.type==="domain")}),[u]),P=p.useMemo(()=>({businessNodes:E.terms.length+E.businessViews.length,businessEdges:d.filter(g=>g.type==="defines"||g.type==="composes").length,technicalNodes:E.tables.length+E.dbtSources.length+E.dbtModels.length+E.metrics.length+E.dimensions.length+E.blocks.length,consumptionNodes:E.charts.length+E.notebooks.length+E.dashboards.length+E.apps.length}),[d,E]),A=p.useMemo(()=>{const g={source:[],transform:[],answer:[],consumption:[]};for(const I of u){const T=Ew(I);g[T].push(I)}return g},[u]);return a?s.jsx("div",{style:{padding:16,color:r.textMuted,fontSize:12},children:"Loading lineage..."}):u.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(Jr,{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(r1,{value:m,onChange:S,placeholder:"Search lineage...",t:r})}),s.jsxs("div",{style:{flex:1,overflow:"auto"},children:[m.trim().length>=2&&v.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"}),v.slice(0,8).map(g=>s.jsx(Up,{node:g.node,t:r,onClick:()=>j(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(oi,{Icon:cv,label:"Business",value:P.businessNodes,detail:`${E.terms.length} terms · ${E.businessViews.length} views · ${P.businessEdges} edges`,t:r}),s.jsx(oi,{Icon:So,label:"Technical",value:P.technicalNodes,detail:`${E.tables.length} tables · ${E.dbtModels.length+E.dbtSources.length} dbt · ${E.blocks.length} blocks`,t:r}),s.jsx(oi,{Icon:cS,label:"Consumption",value:P.consumptionNodes,detail:`${E.dashboards.length} dashboards · ${E.notebooks.length} notebooks · ${E.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:[Qc.map(g=>{const I=A[g].length;return I===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:Cw[g],display:"inline-block"}}),Gc[g],": ",I]},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:()=>x("type"),style:{padding:"2px 6px",fontSize:9,fontWeight:700,border:"none",cursor:"pointer",background:C==="type"?`${r.headerBorder}`:"transparent",color:C==="type"?r.textPrimary:r.textMuted},children:"Type"}),s.jsx("button",{onClick:()=>x("layer"),style:{padding:"2px 6px",fontSize:9,fontWeight:700,border:"none",cursor:"pointer",borderLeft:`1px solid ${r.headerBorder}`,background:C==="layer"?`${r.headerBorder}`:"transparent",color:C==="layer"?r.textPrimary:r.textMuted},children:"Layer"})]})]}),C==="type"?s.jsxs(s.Fragment,{children:[s.jsx(ot,{title:"Business Terms",nodes:E.terms,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Business Views",nodes:E.businessViews,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"DQL Blocks",nodes:E.blocks,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Metrics",nodes:E.metrics,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Dimensions",nodes:E.dimensions,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Dashboards",nodes:E.dashboards,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Notebooks",nodes:E.notebooks,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Apps",nodes:E.apps,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Charts",nodes:E.charts,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"dbt Models",nodes:E.dbtModels,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"dbt Sources",nodes:E.dbtSources,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Source Tables",nodes:E.tables,t:r,onSelect:j,secondaryFor:ut}),s.jsx(ot,{title:"Business Domains",nodes:E.domains,t:r,onSelect:j,secondaryFor:ut})]}):s.jsx(s.Fragment,{children:Qc.map(g=>s.jsx(ot,{title:Gc[g],nodes:A[g],t:r,onSelect:j},g))})]})]})}function i1({diff:e,diffReport:t,activeFilePath:n,diffPath:r,onScopeToFile:o,onClearScope:i,t:c}){const a=t!==null&&!t.identical,l=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:Cl(r==null,c),children:"All"}),n&&s.jsx("button",{onClick:o,style:Cl(r===n,c),children:"Active file"}),r&&s.jsx("span",{style:{color:c.textMuted,fontSize:10,alignSelf:"center",fontFamily:c.fontMono},children:r})]}),a&&s.jsx(a1,{report:t,t:c}),!a&&l&&s.jsx(d1,{diff:e,t:c}),!a&&!l&&s.jsx("div",{style:{color:c.textMuted},children:t&&t.identical?"No semantic changes.":"No unstaged changes."})]})}function a1({report:e,t}){return s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.changes.map((n,r)=>s.jsx(c1,{change:n,t},r))})}function c1({change:e,t}){const{marker:n,color:r,label:o}=u1(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((c,a)=>s.jsx(l1,{field:c,t},a))})]})}function l1({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:kl(e.before)}),s.jsx("span",{style:{color:t.textMuted},children:" → "}),s.jsx("span",{style:{color:t.success},children:kl(e.after)})]})}function d1({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(`
|
|
472
|
+
`).map((n,r)=>s.jsx("div",{style:{color:p1(n,t)},children:n||" "},r))})}function u1(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 ${si(e.id,e.name)} [${e.cellType}]`};case"cell-removed":return{...n,label:`cell ${si(e.id,e.name)} [${e.cellType}]`};case"cell-changed":return{...r,label:`cell ${si(e.id,e.name)}`};case"notebook-changed":return{...r,label:"notebook"}}}function si(e,t){return t?`"${t}" (${e.slice(0,8)})`:e.slice(0,8)}function kl(e,t=60){if(e==null)return"∅";const n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}…`:n}function Cl(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 p1(e,t){return e.startsWith("+++")||e.startsWith("---")?t.textMuted:e.startsWith("+")?t.success:e.startsWith("-")?t.error:e.startsWith("@@")?t.accent:t.textPrimary}const f1=2e3,h1={modified:{label:"Modified",color:e=>e.warning,Icon:$v},added:{label:"Added",color:e=>e.success,Icon:fp},deleted:{label:"Deleted",color:e=>e.error,Icon:zv},renamed:{label:"Renamed",color:e=>e.accent,Icon:Xx},untracked:{label:"Untracked",color:e=>e.textMuted,Icon:Nv}},jl=["modified","added","renamed","deleted","untracked"];function m1(e){const t=e.trim();return t==="??"?"untracked":t.startsWith("R")?"renamed":t.includes("D")?"deleted":t.includes("A")?"added":"modified"}function g1(){var P;const{state:e}=et(),t=Qe[e.themeMode],[n,r]=p.useState("status"),[o,i]=p.useState(null),[c,a]=p.useState(null),[l,u]=p.useState(""),[h,d]=p.useState(null),[f,m]=p.useState(null),[S,v]=p.useState(!1),[b,w]=p.useState(!1),j=p.useCallback(async()=>{v(!0),w(!0);try{if(n==="status")i(await B.fetchGitStatus());else if(n==="log")a(await B.fetchGitLog(30));else{const A=await B.fetchGitDiff(f??void 0);u(A.diff),d(A.diffReport)}}finally{v(!1),window.setTimeout(()=>w(!1),400)}},[n,f]);p.useEffect(()=>{j()},[j]),p.useEffect(()=>{if(n!=="status")return;const A=window.setInterval(()=>{B.fetchGitStatus().then(g=>{i(I=>y1(I,g)?I:g)})},f1);return()=>window.clearInterval(A)},[n]);const C=((P=e.activeFile)==null?void 0:P.path)??null,x=s.jsxs("button",{onClick:()=>void j(),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(cs,{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); } }"})]}),E=s.jsxs(lp,{children:[s.jsx(ii,{t,active:n==="status",onClick:()=>r("status"),children:"Status"}),s.jsx(ii,{t,active:n==="log",onClick:()=>r("log"),children:"History"}),s.jsx(ii,{t,active:n==="diff",onClick:()=>r("diff"),children:"Diff"})]});return s.jsxs(ka,{title:"Git",actions:x,toolbar:E,bodyPadding:12,children:[S&&!o&&!c&&s.jsx(Jr,{title:"Loading…"}),n==="status"&&o&&s.jsx(b1,{status:o,t}),n==="log"&&c&&s.jsx(k1,{log:c,t}),n==="diff"&&s.jsx(i1,{diff:l,diffReport:h,activeFilePath:C,diffPath:f,onScopeToFile:()=>m(C),onClearScope:()=>m(null),t})]})}function y1(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 b1({status:e,t}){const n=p.useMemo(()=>{const r={modified:[],added:[],deleted:[],renamed:[],untracked:[]};for(const o of e.changes)r[m1(o.status)].push(o);for(const o of jl)r[o].sort((i,c)=>i.path.localeCompare(c.path));return r},[e.changes]);return e.inRepo?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[s.jsx(x1,{status:e,t}),e.changes.length===0?s.jsx(v1,{t}):jl.map(r=>{const o=n[r];return o.length===0?null:s.jsx(S1,{group:r,items:o,t},r)})]}):s.jsx(Wp,{t})}function x1({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(Dr,{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:ai(t.success,t),children:[s.jsx(ev,{size:11,strokeWidth:2})," ",n]}),r>0&&s.jsxs("span",{title:`${r} commit(s) behind upstream`,style:ai(t.warning,t),children:[s.jsx(Jx,{size:11,strokeWidth:2})," ",r]}),n===0&&r===0&&s.jsx("span",{style:{...ai(t.textMuted,t),opacity:.7},children:"up to date"})]})}function v1({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(Iv,{size:14,strokeWidth:1.75,color:e.success}),"Working tree clean"]})}function Wp({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 S1({group:e,items:t,t:n}){const r=h1[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((c,a)=>s.jsx(w1,{change:c,t:n,color:o,divider:a<t.length-1},c.path))})]})}function w1({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 k1({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(Xv,{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(Wp,{t})}function ii({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 ai(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 C1(e){const{state:t,dispatch:n}=et(),r=Qe[t.themeMode],[o,i]=p.useState([]),[c,a]=p.useState(!0),[l,u]=p.useState(""),[h,d]=p.useState(""),[f,m]=p.useState(new Set),S=()=>{a(!0),B.listApps().then(g=>i(g)).finally(()=>a(!1))};p.useEffect(()=>{S()},[]);const v=wo(t.authoredDomains),b=Qn(t.authoredDomains),w=o.some(g=>{var I;return!v.has(((I=g.domain)==null?void 0:I.trim())??"")}),j=o.filter(g=>{var T;const I=l.toLowerCase();return!(I&&!g.name.toLowerCase().includes(I)&&!(g.description??"").toLowerCase().includes(I)||h==="uncategorized"&&v.has(((T=g.domain)==null?void 0:T.trim())??"")||h&&h!=="uncategorized"&&(!v.has(h)||g.domain!==h))}),C=g=>{m(I=>{const T=new Set(I);return T.has(g)?T.delete(g):T.add(g),T})},x=(g,I)=>{n({type:"OPEN_APP",appId:g.id,dashboardId:I})},E={background:r.inputBg,border:`1px solid ${r.inputBorder}`,borderRadius:4,color:r.textPrimary,fontSize:11,fontFamily:r.font,padding:"4px 6px",outline:"none"},P=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"}),A=s.jsxs(lp,{children:[s.jsx("input",{value:l,onChange:g=>u(g.target.value),placeholder:"Search apps...",style:{...E,flex:1,minWidth:100}}),s.jsxs("select",{value:h,onChange:g=>d(g.target.value),style:E,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(ka,{title:"Apps",status:s.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font},children:j.length}),actions:P,toolbar:A,bodyPadding:0,children:c?s.jsx(Jr,{title:"Loading apps…"}):j.length===0?o.length===0?s.jsx(Jr,{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(Jr,{title:"No matches",description:"No apps match your filters."}):j.map(g=>{const I=f.has(g.id);return s.jsxs("div",{style:{borderBottom:`1px solid ${r.cellBorder}`},children:[s.jsxs("button",{onClick:()=>C(g.id),style:{display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",cursor:"pointer",padding:"10px 12px",transition:"background 0.1s"},onMouseEnter:T=>{T.currentTarget.style.background=`${r.accent}0a`},onMouseLeave:T=>{T.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:I?"▾":"▸"}),s.jsx("span",{style:{fontSize:12,fontWeight:600,color:r.textPrimary,fontFamily:r.font},children:g.name}),s.jsx(cp,{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"]})]})]}),I&&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(T=>s.jsx("button",{onClick:()=>x(g,T.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:T.title},T.id))]})]},g.id)})})}const j1={files:"Build",block_library:"Build",lineage:"Lineage",connection:"Connection",git:"Git",apps:"Apps"};function E1({onOpenFile:e}){const t=Ge(Ir(w=>({schemaTables:w.schemaTables,semanticLayer:w.semanticLayer,sidebarPanel:w.sidebarPanel,themeMode:w.themeMode}))),n=Cn(),r=Qe[t.themeMode],[o,i]=p.useState(!1),[c,a]=p.useState(340),[l,u]=p.useState(!1),[h,d]=p.useState(""),f=p.useRef(c),m=t.sidebarPanel,S=m==="files"||m==="block_library",v=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"}`;p.useEffect(()=>{if(!S)return;let w=!0;return n({type:"SET_SEMANTIC_LOADING",loading:!0}),B.getSemanticLayer().then(j=>{w&&n({type:"SET_SEMANTIC_LAYER",layer:j})}).catch(()=>{}).finally(()=>{w&&n({type:"SET_SEMANTIC_LOADING",loading:!1})}),()=>{w=!1}},[S,n]);const b=w=>{w.preventDefault();const j=w.clientX,C=f.current;u(!0);const x=P=>{const A=Math.min(560,Math.max(180,C+(P.clientX-j)));f.current=A,a(A)},E=()=>{u(!1),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",E)};window.addEventListener("mousemove",x),window.addEventListener("mouseup",E)};return s.jsxs("div",{style:{width:c,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:j1[m??""]??""}),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(tk,{defaultTab:m==="block_library"?"blocks":"notebooks",tabs:["notebooks","semantic","database","blocks"],onOpenFile:e,blockDomain:h,onBlockDomainChange:d,onNewBlock:()=>n({type:"OPEN_NEW_BLOCK_MODAL"}),onCollapse:()=>n({type:"TOGGLE_SIDEBAR"}),footer:v,footerStatus:t.semanticLayer.loading?"loading":"ready"}),m==="lineage"&&s.jsx(s1,{}),m==="connection"&&s.jsx(qp,{}),m==="git"&&s.jsx(g1,{}),m==="apps"&&s.jsx(C1,{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:l?r.accent:"transparent",zIndex:10,transition:l?"none":"background 0.15s"},onMouseEnter:w=>{l||(w.currentTarget.style.background=`${r.accent}40`)},onMouseLeave:w=>{l||(w.currentTarget.style.background="transparent")}})]})}const Kp=2;function T1(e,t={}){const n=t.version??Kp,r=JSON.parse(e),{dqlnbVersion:o,...i}=r,c={dqlnbVersion:n,...i};return JSON.stringify(c,A1(),2)+`
|
|
473
|
+
`}function A1(){return function(t,n){if(n===null||typeof n!="object"||Array.isArray(n))return n;const r=n,o=Object.keys(r);o.sort((c,a)=>{const l=El[c],u=El[a];return l!==void 0&&u!==void 0?l-u:l!==void 0?-1:u!==void 0?1:c<a?-1:c>a?1:0});const i={};for(const c of o)i[c]=r[c];return i}}const El={dqlnbVersion:0,version:1,title:2,metadata:3,cells:4,id:10,type:11,name:12,content:13};function R1(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 c=i[1],a=i[2].trim();r.push({id:bt(),type:"markdown",content:`# ${c}`,status:"idle"}),a&&r.push({id:bt(),type:"dql",name:c.toLowerCase().replace(/\s+/g,"_"),content:a,status:"idle"})}return r.length===0&&r.push({id:bt(),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:bt(),type:"dql",content:e.trim(),status:"idle"}]}}}const O1=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 _1(e){var t;try{const n=JSON.parse(e),r=n.title||((t=n.metadata)==null?void 0:t.title)||"Untitled",o=$i((n.cells||[]).map(a=>{const l=Object.fromEntries(Object.entries(a).filter(([u])=>!O1.has(u)));return{id:a.id||bt(),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(l).length>0?{preservedFields:l}:{}}})),{title:i,...c}=n.metadata??{};return{title:r,cells:o,metadata:c}}catch(n){return console.warn("parse-workbook: falling back after error",n),{title:"Untitled",cells:[{id:bt(),type:"sql",content:e,status:"idle"}]}}}function P1(e,t,n){const r={dqlnbVersion:Kp,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 T1(JSON.stringify(r))}function I1(e,t){return e.endsWith(".dql")?R1(t):_1(t)}const Vp=/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g;function Pj(e){const t=new Set;for(const n of e.matchAll(Vp))t.add(n[1]);return[...t]}function D1(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(c=>`(${n.map(l=>{const u=c[l];return u==null?"NULL":typeof u=="number"?String(u):typeof u=="boolean"?u?"TRUE":"FALSE":`'${String(u).replace(/'/g,"''")}'`}).join(", ")})`).join(`,
|
|
474
|
+
`),i=n.map(c=>`"${c.replace(/"/g,'""')}"`).join(", ");return`${e} AS (
|
|
475
|
+
SELECT * FROM (VALUES
|
|
476
|
+
${o}
|
|
477
|
+
) AS _t(${i})
|
|
478
|
+
)`}function $1(e,t){if(t==="number"){const n=Number(e);return isNaN(n)?`'${e.replace(/'/g,"''")}'`:String(n)}return`'${e.replace(/'/g,"''")}'`}function M1(e,t){var u;const n=[...e.matchAll(Vp)];if(n.length===0)return{sql:e,substituted:[],unresolved:[],ambiguous:[]};const r=new Map;for(const h of t){const d=[h.id,(u=h.name)==null?void 0:u.trim()].filter(f=>!!f);for(const f of d)r.set(f,[...r.get(f)??[],h])}const o=[],i=[],c=[],a=[];let l=e;for(const h of n){const d=h[1],f=r.get(d)??[];if(f.length===0){i.push(d);continue}if(f.length>1){c.push(d);continue}const m=f[0];if(m.type==="param"){const S=m.paramConfig,v=m.paramValue??(S==null?void 0:S.defaultValue)??"",b=(S==null?void 0:S.paramType)??"text";l=l.replace(h[0],$1(v,b)),o.push(d);continue}if(!m.result||m.error||m.stale){i.push(d);continue}a.push(D1(d,m.result)),l=l.replace(h[0],`"${d}"`),o.push(d)}if(a.length>0){const h=l.trimStart();/^WITH\s+/i.test(h)?l=l.replace(/^(\s*WITH\s+)/i,`$1${a.join(`,
|
|
479
|
+
`)},
|
|
480
|
+
`):l=`WITH ${a.join(`,
|
|
481
|
+
`)}
|
|
482
|
+
${l}`}return{sql:l,substituted:Array.from(new Set(o)),unresolved:Array.from(new Set(i)),ambiguous:Array.from(new Set(c))}}function Ij(e){if(!/^\s*block\s+"[^"]+"\s*\{/i.test(e))return!1;let t=0,n=!1,r=!1,o=!1,i=!1;for(let c=0;c<e.length;c+=1){if(e.slice(c,c+3)==='"""'&&!i){o=!o,c+=2,r=!1;continue}if(o)continue;const a=e[c];if(a==='"'&&!i&&(r=!r),!r){if(a==="{")t+=1,n=!0;else if(a==="}"&&(t-=1,t<0))return!1}i=a==="\\"&&!i,a!=="\\"&&(i=!1)}return n&&t===0&&!r&&!o}function Hp(e){const t=i=>{var c;return((c=e.match(new RegExp(`\\b${i}\\s*=\\s*"([^"]*)"`,"i")))==null?void 0:c[1])??""},n=i=>{const c=e.match(new RegExp(`\\b${i}\\s*=\\s*\\[([\\s\\S]*?)\\]`,"i"));return((c==null?void 0:c[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 Dj(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 Ma(n,` metrics = [${r.map(o=>`"${vn(o)}"`).join(", ")}]`)}function Gp(e,t,n){const r=Array.from(new Set(n.filter(Boolean))),o=`${t} = [${r.map(c=>`"${vn(c)}"`).join(", ")}]`,i=new RegExp(`\\b${t}\\s*=\\s*\\[[\\s\\S]*?\\]`,"i");return i.test(e)?e.replace(i,o):Ma(e,` ${o}`)}function Qp(e){const t=Al(e,"parameterPolicy"),n=Al(e,"filterBindings"),r=new Set(Array.from(e.matchAll(/\$\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}/g)).map(c=>c[1])),o=/\btype\s*=\s*"semantic"/i.test(e);return $a(e,"params").split(/\r?\n/).flatMap(c=>{const a=c.trim();if(!a||a.startsWith("//")||a.startsWith("#"))return[];const l=/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*(string|number|boolean|date)(\[\])?)?\s*(?:=\s*(.+))?$/.exec(a);if(!l)return[];const u=l[1],h=l[4]===void 0?void 0:ef(l[4]),d=l[2]?`${l[2]}${l[3]??""}`:L1(tf(h),u),f=n.get(u),m=r.has(u)?{kind:"sql_value"}:u==="top_n"||u==="limit"?{kind:"limit"}:o&&f?{kind:"semantic_filter",field:f,operator:u.endsWith("_set")?"in":"equals"}:void 0;return[{name:u,type:d,required:l[4]===void 0,...l[4]===void 0?{}:{default:h},policy:B1(t.get(u)),...m?{binding:m}:{}}]})}function L1(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=>Tl(i))?"date[]":o.length>0&&o.every(i=>ps(i))?"number[]":"string[]"}return n==="true"||n==="false"?"boolean":Tl(n)?"date":ps(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 Jp(e){return e.default===void 0?"":tf(e.default)}function $j(e){if(/^\s*block\s+"/i.test(e))return e;const t=e.trim();return`block "notebook_query" {
|
|
483
|
+
status = "draft"
|
|
484
|
+
domain = "uncategorized"
|
|
485
|
+
type = "custom"
|
|
486
|
+
description = "Notebook analysis"
|
|
487
|
+
|
|
488
|
+
query = """
|
|
489
|
+
${t?t.split(/\r?\n/).map(r=>` ${r}`).join(`
|
|
490
|
+
`):" -- Write query"}
|
|
491
|
+
"""
|
|
492
|
+
}
|
|
493
|
+
`}function Mj(e,t){const n=Zp(t.name);if(!n)return e;const r=Qp(e).filter(o=>o.name!==t.previousName&&o.name!==n).map(o=>({name:o.name,type:o.type,required:o.required,defaultText:Jp(o),policy:o.policy}));return r.push({name:n,type:t.type,required:t.required,defaultText:t.defaultText??"",policy:t.policy}),Yp(e,r)}function Lj(e,t){const n=Qp(e).filter(r=>r.name!==t).map(r=>({name:r.name,type:r.type,required:r.required,defaultText:Jp(r),policy:r.policy}));return Yp(e,n)}function Nj(e,t,n){const r=Zp(t),o=n.trim();if(!r||!o)return e;const c=$a(e,"filterBindings").split(/\r?\n/).filter(a=>a.trim()&&!new RegExp(`^${r}\\s*=`).test(a.trim()));return c.push(`${r} = "${vn(o)}"`),fs(e,"filterBindings",c.join(`
|
|
494
|
+
`))}function Yp(e,t){const n=t.map(i=>{const c=`${i.name}: ${i.type}`;return i.required?c:`${c} = ${Xp(i.defaultText,i.type)}`}).join(`
|
|
495
|
+
`),r=t.map(i=>`${i.name} = "${i.policy}"`).join(`
|
|
496
|
+
`);let o=fs(e,"params",n);return o=fs(o,"parameterPolicy",r),o}function Xp(e,t){const n=e.trim();if(t==="boolean")return n==="true"?"true":"false";if(t==="number")return ps(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=>Xp(i,r)).join(", ")}]`}return`"${vn(n)}"`}function Zp(e){const t=e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return/^[a-z_][a-z0-9_]*$/.test(t)?t:""}function ps(e){return e!==""&&Number.isFinite(Number(e))}function Tl(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)}function $a(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 Al(e,t){const n=new Map;for(const r of $a(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 ef(e){const t=e.trim();return t==="true"?!0:t==="false"?!1:ps(t)?Number(t):t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"):t.startsWith("[")&&t.endsWith("]")?N1(t.slice(1,-1)).map(ef):t}function N1(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 tf(e){return Array.isArray(e)?e.join(", "):String(e??"")}function B1(e){return e==="static"||e==="business"||e==="derived"||e==="optional"||e==="ambiguous_review_required"?e:"dynamic"}function F1(e,t){const n=new Set(Hp(e).requestedFilters),r=Array.from(new Set(t.filter(Boolean)));let o=Gp(e,"requested_filters",r);return o=ci(o,"params",n,r,i=>`${i}: string`),o=ci(o,"parameterPolicy",n,r,i=>`${i} = "dynamic"`),o=ci(o,"filterBindings",n,r,i=>`${i} = "${vn(i)}"`),o}function ci(e,t,n,r,o){const a=[...V1(e,t).split(/\r?\n/).filter(l=>{var h;const u=(h=l.trim().match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::|=)/))==null?void 0:h[1];return!u||!n.has(u)}).filter(l=>l.trim()),...r.map(o)].join(`
|
|
497
|
+
`);return fs(e,t,a)}function Rl(e,t,n){const r=vn(n),o=new RegExp(`(\\b${t}\\s*=\\s*)"[^"]*"`,"i");return o.test(e)?e.replace(o,`$1"${r}"`):Ma(e,` ${t} = "${r}"`)}function Bj(e,t){const n=new Set(t.filter(Boolean)),r=Hp(e);let o=Gp(e,"dimensions",r.dimensions.filter(i=>n.has(i)));return o=F1(o,r.requestedFilters.filter(i=>n.has(i))),r.timeDimension&&!n.has(r.timeDimension)&&(o=Rl(o,"time_dimension",""),o=Rl(o,"granularity","")),o}function vn(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function Ma(e,t){return/visualization\s*\{/i.test(e)?e.replace(/\n\s*visualization\s*\{/i,`
|
|
498
|
+
${t}
|
|
499
|
+
|
|
500
|
+
visualization {`):e.replace(/\n\}\s*$/,`
|
|
501
|
+
${t}
|
|
502
|
+
}
|
|
503
|
+
`)}function z1(e){var i;const t=e.match(/visualization\s*\{([^}]+)\}/is);if(!t)return;const n=t[1],r=c=>{var a;return(a=n.match(new RegExp(`\\b${c}\\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 q1(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 c=i.search(/\b(visualization|tests|block)\s*\{/i);return c>0&&(i=i.slice(0,c)),i=U1(i),i.trim()||null}return null}function U1(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 Fj(e){const t=La(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 W1(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}"`):$r(e,` ${t} = "${r}"`)}function K1(e,t){const n=t.replace(/"/g,'\\"');return/^\s*block\s+"/i.test(e)?e.replace(/^(\s*block\s+)"[^"]+"/i,`$1"${n}"`):e}function zj(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}]`):$r(e,` tags = [${n}]`)}function qj(e,t,n){const r=Array.from(new Set(n.map(c=>c.trim()).filter(Boolean))),o=`${t} = [${r.map(c=>`"${vn(c)}"`).join(", ")}]`,i=new RegExp(`(\\b${t}\\s*=\\s*)\\[[\\s\\S]*?\\]`,"i");return i.test(e)?e.replace(i,`$1[${r.map(c=>`"${vn(c)}"`).join(", ")}]`):$r(e,` ${o}`)}function Uj(e,t){const n=/visualization\s*\{[\s\S]*?\n\s*\}/i;if(!n.test(e)){const r=G1(t);return $r(e,` ${r.replace(/\n/g,`
|
|
504
|
+
`)}`,!0)}return e.replace(n,r=>{let o=r;for(const[i,c]of Object.entries(t)){if(c==null||c==="")continue;const a=String(c).replace(/"/g,'\\"'),l=new RegExp(`(\\b${i}\\s*=\\s*)"[^"]*"`,"i");l.test(o)?o=o.replace(l,`$1"${a}"`):o=o.replace(/\n(\s*)\}$/,`
|
|
505
|
+
$1 ${i} = "${a}"
|
|
506
|
+
$1}`)}return o})}function V1(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(`
|
|
507
|
+
`).trim())??""}function fs(e,t,n){const r=n.trim(),o=r?` ${t} {
|
|
508
|
+
${r.split(/\r?\n/).map(c=>` ${c.trimEnd()}`).join(`
|
|
509
|
+
`)}
|
|
510
|
+
}`:"",i=new RegExp(`\\n\\s*${t}\\s*\\{[\\s\\S]*?\\n\\s*\\}`,"i");return i.test(e)?e.replace(i,o?`
|
|
511
|
+
${o}`:""):o?/\n\s*visualization\s*\{/i.test(e)?e.replace(/\n\s*visualization\s*\{/i,`
|
|
512
|
+
${o}
|
|
513
|
+
|
|
514
|
+
visualization {`):$r(e,o,!0):e}function Wj(e,t){return e==="metric"?`@metric(${t})`:`@dim(${t})`}function Kj(e,t){const n=La(e);if(!n||n.blockType!=="custom")return`${e.trimEnd()}
|
|
515
|
+
${t}
|
|
516
|
+
`;const r=n.query.trimEnd(),o=r?`${r}
|
|
517
|
+
${t}`:t;return H1(e,o)}function H1(e,t){if(!La(e))return e;const r=W1(e,"type","custom"),o=` query = """
|
|
518
|
+
${t.trimEnd()}
|
|
519
|
+
"""`,i=/\n\s*query\s*=\s*"""[\s\S]*?"""/i;return i.test(r)?r.replace(i,`
|
|
520
|
+
${o}`):$r(r,o,!0)}function La(e){var i,c;if(!/^\s*block\s+"/i.test(e.trim()))return null;const t=a=>{var l;return((l=e.match(new RegExp(`\\b${a}\\s*=\\s*"([^"]*)"`,"i")))==null?void 0:l[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:Fr(e,"metrics"),dimensions:Fr(e,"dimensions"),requestedFilters:Fr(e,"requested_filters"),sourceDqlKind:t("source_dql_kind"),sourceDqlName:t("source_dql_name"),sourceDqlPath:t("source_dql_path"),sourceDqlHash:t("source_dql_hash"),sourceDqlMetrics:Fr(e,"source_dql_metrics"),sourceDqlDimensions:Fr(e,"source_dql_dimensions"),timeDimension:t("time_dimension"),granularity:t("granularity"),query:((c=o==null?void 0:o[1])==null?void 0:c.trim())??"",visualization:Ol(e,"visualization"),tests:Ol(e,"tests")}}function Fr(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 Ol(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 c=e[i];if(c==="{")r===0&&(o=i),r++;else if(c==="}"&&(r--,r===0&&o>=0))return e.slice(n.index,i+1).trim()}return""}function G1(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 = "${Q1(e.title)}"`),t.push("}"),t.join(`
|
|
521
|
+
`)}function Q1(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function $r(e,t,n=!1){const r=e.trimEnd();if(!/^\s*block\s+"/i.test(r))return`${r}
|
|
522
|
+
${t}
|
|
523
|
+
`;const o=n?`
|
|
524
|
+
|
|
525
|
+
${t}
|
|
526
|
+
`:`
|
|
527
|
+
${t}`;return r.replace(/\n\}\s*$/,`${o}
|
|
528
|
+
}`)}function _l(e,t){return t.filter(n=>n.datasetId&&(n.objectType==="dataset"||n.objectType==="staged_dataset")).filter(n=>nf(n.name).test(e)).map(n=>({id:n.datasetId,alias:n.name,role:n.objectType==="staged_dataset"?"staged":"source",fingerprint:n.fileFingerprint}))}function J1(e,t){return t.filter(n=>n.source==="database").filter(n=>nf(n.name).test(e)).map(n=>n.name)}function Vj(e,t){const n=[];for(const r of e)for(const o of t){const i=Y1(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 Hj(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(Z1)).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 Gj(e){const t=new Set(e.staged.columns??[]),r=[" warehouse.*",...(e.local.columns??[]).filter(i=>i!==e.localKey).map(i=>{const c=t.has(i)?`local_${i}`:i;return` local_data.${or(i)} AS ${or(c)}`})];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(`,
|
|
529
|
+
`),`FROM ${or(e.staged.alias)} AS warehouse`,`${e.joinType.toUpperCase()} JOIN ${or(e.local.alias)} AS local_data`,` ON warehouse.${or(e.warehouseKey)} = local_data.${or(e.localKey)}`,"LIMIT 1000"].join(`
|
|
530
|
+
`),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 Y1(e,t,n){const r=e.toLowerCase(),o=t.toLowerCase();if(r===o)return{score:100,reason:"Same column name"};const i=Pl(r),c=Pl(o);return i===c?{score:90,reason:"Same normalized name"}:(i.endsWith(c)||c.endsWith(i))&&(i.endsWith("id")||c.endsWith("id"))?{score:n.includes("identifier")?78:70,reason:"Related identifier names"}:Il(r).filter(l=>Il(o).includes(l)).length>0&&(r.includes("id")||o.includes("id"))?{score:n.includes("identifier")?62:55,reason:"Shared entity identifier"}:{score:0,reason:""}}function Pl(e){return e.replace(/[^a-z0-9]/g,"").replace(/identifier$/,"id")}function Il(e){return e.split(/[^a-z0-9]+/).filter(t=>t.length>1)}function nf(e){return new RegExp(`(?:^|[^a-zA-Z0-9_])(?:["\`])?${X1(e)}(?:["\`])?(?=$|[^a-zA-Z0-9_])`,"i")}function or(e){return`"${e.replace(/"/g,'""')}"`}function X1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z1(e){return typeof e=="string"?e:JSON.stringify(e)}const On=new Map,nn=new Map;function li(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 eC(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?q1(t):null}function tC(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 Gr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function nC(e){const t=Gr(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 zr(e,t,n){return new xt({status:400,code:e,message:t,recoverable:!0,details:{phase:"preflight",...n}})}function Ko(e){const t=e.error instanceof xt?e.error:void 0,n=Gr(t==null?void 0:t.details),r=Gr(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??nC(n==null?void 0:n.executionTarget),compiledSql:e.attemptedSql,semanticTrace:r,targetBinding:Gr(n==null?void 0:n.targetBinding),executionReceipt:Gr(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 Vo(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 rf(){const e=Cn(),t=p.useCallback(async(i,c)=>{var P,A,g,I;const a=Pn.getState(),l=c??a.cells,u=l.find(T=>T.id===i);if(!u)return{cellId:i,status:"skipped"};const h=u.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",d=u.type==="dql"?null:eC(u);if(u.type!=="dql"&&!d)return{cellId:i,status:"skipped"};const f=On.get(i);f&&f.controller.abort();const m=li(i),S=new Date().toISOString(),v=Date.now(),b=new AbortController,w={controller:b,runId:m,startedAt:S,route:h,executionTarget:u.executionTarget};On.set(i,w),nn.set(i,m);const j=()=>{var T;return((T=On.get(i))==null?void 0:T.runId)===m&&nn.get(i)===m},C=(u.executionCount??0)+1;let x=d??void 0;e({type:"UPDATE_CELL",id:i,updates:{status:"running",error:void 0,result:void 0,execution:void 0,fromSnapshot:!1}});const E=(T,O,_="error")=>{const M=new Date().toISOString(),q=Ko({cell:u,runId:m,route:h,startedAt:S,completedAt:M,durationMs:Date.now()-v,message:T,error:O,status:_,attemptedSql:x});return j()&&(e({type:"UPDATE_CELL",id:i,updates:{status:_==="cancelled"?"idle":"error",error:_==="cancelled"?void 0:T,result:void 0,execution:q,executionCount:C,stale:!1}}),e({type:"APPEND_QUERY_LOG",entry:{id:bt(),cellName:u.name??u.id,rows:0,time:q.durationMs,ts:new Date,..._==="cancelled"?{}:{error:T}}})),{cellId:i,runId:m,status:_,error:_==="cancelled"?void 0:T,execution:q}};try{if(u.type==="dql"){const ee=await B.executeNotebookCell(u,b.signal,{notebookPath:(P=a.activeFile)==null?void 0:P.path,cellId:u.id,cellName:u.name,source:h,runId:m});if(!ee.result)throw new Error("DQL cell produced no executable result.");if(!j())return{cellId:i,runId:m,status:"cancelled"};const ce=new Date().toISOString(),ke=Date.now()-v,xe={...ee.result,executionTime:ee.result.executionTime??ke,rowCount:ee.result.rowCount??ee.result.rows.length},De=tC(ee.chartConfig)??z1(u.content),We={version:1,runId:m,cellId:i,route:h,status:"success",startedAt:S,completedAt:ce,durationMs:ke,executionTarget:ee.executionTarget??u.executionTarget,engine:ee.engine,compiledSql:ee.compiledSql,executedSql:ee.executedSql,semanticTrace:ee.semanticTrace,targetBinding:ee.targetBinding,executionReceipt:ee.executionReceipt};return e({type:"UPDATE_CELL",id:i,updates:{status:"success",result:xe,error:void 0,execution:We,executionTarget:ee.executionTarget??u.executionTarget,...De?{chartConfig:De}:{},executionCount:C,stale:!1}}),e({type:"APPEND_QUERY_LOG",entry:{id:bt(),cellName:ee.blockName??u.name??u.id,rows:xe.rowCount??xe.rows.length,time:xe.executionTime??ke,ts:new Date}}),setTimeout(()=>{nn.get(i)===m&&(e({type:"UPDATE_CELL",id:i,updates:{status:"idle"}}),nn.delete(i))},2e3),{cellId:i,runId:m,status:"success",result:xe,execution:We}}const T=_l(d,a.schemaTables),O=J1(d,a.schemaTables);if(T.length>0&&O.length>0){const ee=[`Mixed-source query detected: ${O.join(", ")} runs in the warehouse, while ${T.map(ce=>ce.alias??ce.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 E(ee,zr("CROSS_ENGINE_JOIN_REQUIRED",ee,{warehouseTables:O,datasets:T.map(ce=>ce.alias??ce.id)}))}const _=T.length>0?{target:"local"}:u.executionTarget;T.length>0&&((A=u.executionTarget)==null?void 0:A.target)!=="local"&&e({type:"UPDATE_CELL",id:i,updates:{executionTarget:_,datasetRefs:T}});const M=M1(d,l);if(M.ambiguous.length>0){const ee=`Ambiguous notebook dependency: ${M.ambiguous.join(", ")} matches more than one cell. Rename the duplicate cells or reference a stable cell ID.`;return E(ee,zr("AMBIGUOUS_NOTEBOOK_DEPENDENCY",ee,{ambiguousReferences:M.ambiguous}))}if(M.unresolved.length>0){const ee=`Notebook dependency result is unavailable: ${M.unresolved.join(", ")}. Run or repair the upstream cell before retrying this cell.`;return E(ee,zr("UPSTREAM_RESULT_UNAVAILABLE",ee,{unresolvedReferences:M.unresolved}))}x=M.sql;const q=await B.executeQuery(M.sql,b.signal,{notebookPath:(g=a.activeFile)==null?void 0:g.path,cellId:u.id,cellName:u.name,source:h,runId:m},_);if(!j())return{cellId:i,runId:m,status:"cancelled"};const G=new Date().toISOString(),J=Date.now()-v,{executionTarget:H,compiledSql:L,executedSql:$,targetBinding:X,executionReceipt:W,...te}=q,F={...te,executionTime:te.executionTime??J,rowCount:te.rowCount??te.rows.length},K=(_==null?void 0:_.target)==="local"?_l(M.sql,a.schemaTables):u.datasetRefs,oe={version:1,runId:m,cellId:i,route:h,status:"success",startedAt:S,completedAt:G,durationMs:J,executionTarget:H??_,compiledSql:L??M.sql,executedSql:$??M.sql,targetBinding:X,executionReceipt:W};return e({type:"UPDATE_CELL",id:i,updates:{status:"success",result:F,error:void 0,execution:oe,executionCount:C,stale:!1,datasetRefs:K,executionTarget:H??_}}),e({type:"APPEND_QUERY_LOG",entry:{id:bt(),cellName:u.name??u.id,rows:F.rowCount??F.rows.length,time:F.executionTime??J,ts:new Date}}),setTimeout(()=>{nn.get(i)===m&&(e({type:"UPDATE_CELL",id:i,updates:{status:"idle"}}),nn.delete(i))},2e3),{cellId:i,runId:m,status:"success",result:F,execution:oe}}catch(T){if(b.signal.aborted||!j())return E("Cell execution was cancelled.",T,"cancelled");const O=T instanceof Error?T.message:String(T);return E(O,T)}finally{((I=On.get(i))==null?void 0:I.runId)===m&&On.delete(i)}},[e]),n=p.useCallback(async()=>{const i=Pn.getState().cells,c=Ix(i);let a=i.map(h=>({...h}));const l=new Map,u=new Map;for(const h of c.missing)u.set(h.cellId,[...u.get(h.cellId)??[],h.dependency]);for(const h of c.cycleCellIds){const d=a.find(w=>w.id===h);if(!d)continue;const f=li(h),m=new Date().toISOString(),S="Dependency cycle detected. Update the cell dependencies before running all.",v=Ko({cell:d,runId:f,route:d.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",startedAt:m,completedAt:m,durationMs:0,message:S,error:zr("DEPENDENCY_CYCLE",S,{cycleCellIds:c.cycleCellIds}),status:"blocked"}),b={cellId:h,runId:f,status:"blocked",error:S,execution:v};l.set(h,b),a=Vo(a,b),e({type:"UPDATE_CELL",id:h,updates:{status:"error",error:S,result:void 0,execution:v,executionCount:(d.executionCount??0)+1,stale:!1}})}for(const h of c.ordered){const d=a.find(v=>v.id===h.id)??h,f=u.get(d.id)??[],m=Ca(d,a).filter(v=>{const b=l.get(v.cellId);return b&&b.status!=="success"});if(f.length>0||m.length>0){const v=[...f,...m.map(E=>{var P;return((P=a.find(A=>A.id===E.cellId))==null?void 0:P.name)??E.cellId})],b=li(d.id),w=new Date().toISOString(),j=`Not executed because ${v.join(", ")} did not produce a valid upstream result.`,C=Ko({cell:d,runId:b,route:d.type==="dql"?"notebook_dql_cell":"notebook_sql_cell",startedAt:w,completedAt:w,durationMs:0,message:j,error:zr("UPSTREAM_EXECUTION_FAILED",j,{blockedBy:v}),status:"blocked"}),x={cellId:d.id,runId:b,status:"blocked",error:j,execution:C};l.set(d.id,x),a=Vo(a,x),e({type:"UPDATE_CELL",id:d.id,updates:{status:"error",error:j,result:void 0,execution:C,executionCount:(d.executionCount??0)+1,stale:!1}});continue}const S=await t(d.id,a);l.set(d.id,S),a=Vo(a,S)}},[e,t]),r=p.useCallback(async i=>{if(!i)return;const c=`{{${i}}}`;let a=Pn.getState().cells.map(l=>({...l}));for(const l of a){if(l.type==="markdown"||l.type==="param"||!l.content.includes(c))continue;const u=await t(l.id,a);a=Vo(a,u)}},[t]),o=p.useCallback(i=>{const c=On.get(i);if(!c)return;c.controller.abort(),On.delete(i),nn.get(i)===c.runId&&nn.delete(i);const a=new Date().toISOString(),l=Pn.getState().cells.find(u=>u.id===i);e({type:"UPDATE_CELL",id:i,updates:{status:"idle",error:void 0,result:void 0,...l?{execution:Ko({cell:l,runId:c.runId,route:c.route,startedAt:c.startedAt,completedAt:a,durationMs:Date.parse(a)-Date.parse(c.startedAt),message:"Cell execution was cancelled.",status:"cancelled"}),executionCount:(l.executionCount??0)+1}:{}}})},[e]);return{executeCell:t,executeAll:n,executeDependents:r,cancelCell:o}}function lt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function rC(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 oC(e){const t=e.split(`
|
|
531
|
+
`),n=[];let r=!1,o=!1;for(const i of t){const c=i;if(c.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(lt(c));continue}if(c.startsWith("### ")){o&&(n.push("</ul>"),o=!1),n.push(`<h3>${lt(c.slice(4))}</h3>`);continue}if(c.startsWith("## ")){o&&(n.push("</ul>"),o=!1),n.push(`<h2>${lt(c.slice(3))}</h2>`);continue}if(c.startsWith("# ")){o&&(n.push("</ul>"),o=!1),n.push(`<h1>${lt(c.slice(2))}</h1>`);continue}if(c.startsWith("> ")){o&&(n.push("</ul>"),o=!1),n.push(`<blockquote><p>${lt(c.slice(2))}</p></blockquote>`);continue}if(c.startsWith("- ")||c.startsWith("* ")){o||(n.push("<ul>"),o=!0),n.push(`<li>${Dl(c.slice(2))}</li>`);continue}if(o&&(n.push("</ul>"),o=!1),c.trim()===""){n.push("<br>");continue}n.push(`<p>${Dl(c)}</p>`)}return o&&n.push("</ul>"),r&&n.push("</code></pre>"),n.join(`
|
|
532
|
+
`)}function Dl(e){return lt(e).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>")}function sC(e){const{columns:t,rows:n}=e,r=n.slice(0,200),o=n.length>200,i=t.map(a=>`<th>${lt(a)}</th>`).join(""),c=r.map(a=>`<tr>${t.map(u=>{const h=a[u],d=typeof h=="number",f=h==null?"—":String(h);return`<td${d?' class="num"':""}>${lt(f)}</td>`}).join("")}</tr>`).join("");return`
|
|
533
|
+
<div class="table-wrap">
|
|
534
|
+
<table>
|
|
535
|
+
<thead><tr>${i}</tr></thead>
|
|
536
|
+
<tbody>${c}</tbody>
|
|
537
|
+
</table>
|
|
538
|
+
${o?`<p class="truncated">Showing first 200 of ${n.length.toLocaleString()} rows</p>`:""}
|
|
539
|
+
</div>`}function iC(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 aC(e){const t=iC(e);if(!t)return null;const n=e.rows.slice(0,20).map(h=>({label:String(h[t.labelCol]??""),value:Number(h[t.valueCol]??0)})),r=Math.max(...n.map(h=>h.value),1),o=28,i=6,c=140,a=440,l=n.length*(o+i)+40,u=n.map((h,d)=>{const f=d*(o+i)+20,m=Math.max(h.value/r*a,2);return`
|
|
540
|
+
<text x="${c-6}" y="${f+o/2+4}" text-anchor="end" font-size="11" fill="#8b949e">${lt(h.label.slice(0,20))}</text>
|
|
541
|
+
<rect x="${c}" y="${f}" width="${m}" height="${o}" rx="3" fill="#388bfd" />
|
|
542
|
+
<text x="${c+m+5}" y="${f+o/2+4}" font-size="11" fill="#e6edf3">${rC(h.value)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${c+a+80}" height="${l}" style="max-width:100%">${u}</svg>`}function cC(e,t){const n=t.map(r=>{if(r.type==="markdown")return`<section class="cell md-cell">${oC(r.content)}</section>`;const o=r.name?`<div class="cell-header"><span class="cell-type">${r.type.toUpperCase()}</span><span class="cell-name">${lt(r.name)}</span></div>`:`<div class="cell-header"><span class="cell-type">${r.type.toUpperCase()}</span></div>`,i=`<pre class="cell-code"><code>${lt(r.content)}</code></pre>`;let c="";if(r.result&&r.result.rows.length>0){const a=aC(r.result),l=sC(r.result);c=`<div class="cell-output">${`<div class="output-meta">${r.result.rows.length.toLocaleString()} rows${r.result.executionTime?` · ${r.result.executionTime}ms`:""}</div>`}${a??""}${a?"":l}</div>`}else r.error&&(c=`<div class="cell-error">⚠ ${lt(r.error)}</div>`);return`<section class="cell sql-cell">${o}${i}${c}</section>`}).join(`
|
|
543
|
+
`);return`<!DOCTYPE html>
|
|
544
|
+
<html lang="en">
|
|
545
|
+
<head>
|
|
546
|
+
<meta charset="UTF-8">
|
|
547
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
548
|
+
<title>${lt(e)}</title>
|
|
549
|
+
<style>
|
|
550
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
551
|
+
body {
|
|
552
|
+
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
553
|
+
background: #0d1117; color: #e6edf3;
|
|
554
|
+
line-height: 1.6; padding: 0;
|
|
555
|
+
}
|
|
556
|
+
.page-header {
|
|
557
|
+
background: #161b22; border-bottom: 1px solid #21262d;
|
|
558
|
+
padding: 16px 32px; display: flex; align-items: center; gap: 12px;
|
|
559
|
+
}
|
|
560
|
+
.logo {
|
|
561
|
+
width: 28px; height: 28px; border-radius: 6px;
|
|
562
|
+
background: linear-gradient(135deg, #388bfd, #1f6feb);
|
|
563
|
+
display: flex; align-items: center; justify-content: center;
|
|
564
|
+
font-size: 10px; font-weight: 700; color: #fff;
|
|
565
|
+
font-family: monospace; letter-spacing: -0.5px; flex-shrink: 0;
|
|
566
|
+
}
|
|
567
|
+
.page-title { font-size: 18px; font-weight: 600; color: #e6edf3; }
|
|
568
|
+
.page-meta { font-size: 12px; color: #8b949e; margin-left: auto; }
|
|
569
|
+
.content { max-width: 900px; margin: 0 auto; padding: 32px 24px; display: flex; flex-direction: column; gap: 24px; }
|
|
570
|
+
.cell { border-radius: 8px; overflow: hidden; }
|
|
571
|
+
.md-cell { padding: 4px 0; }
|
|
572
|
+
.md-cell h1 { font-size: 26px; font-weight: 700; color: #e6edf3; margin: 0 0 12px; }
|
|
573
|
+
.md-cell h2 { font-size: 20px; font-weight: 600; color: #e6edf3; margin: 20px 0 10px; }
|
|
574
|
+
.md-cell h3 { font-size: 16px; font-weight: 600; color: #e6edf3; margin: 16px 0 8px; }
|
|
575
|
+
.md-cell p { color: #c9d1d9; margin-bottom: 8px; }
|
|
576
|
+
.md-cell ul { padding-left: 20px; color: #c9d1d9; margin-bottom: 8px; }
|
|
577
|
+
.md-cell code { background: #21262d; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
|
|
578
|
+
.md-cell pre { background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 14px; overflow-x: auto; margin-bottom: 8px; }
|
|
579
|
+
.md-cell pre code { background: none; padding: 0; }
|
|
580
|
+
.md-cell blockquote { border-left: 3px solid #388bfd; padding-left: 14px; color: #8b949e; }
|
|
581
|
+
.sql-cell { background: #161b22; border: 1px solid #30363d; }
|
|
582
|
+
.cell-header { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid #21262d; background: #1c2128; }
|
|
583
|
+
.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; }
|
|
584
|
+
.cell-name { font-size: 12px; color: #388bfd; font-family: monospace; }
|
|
585
|
+
.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; }
|
|
586
|
+
.cell-output { padding: 14px; }
|
|
587
|
+
.output-meta { font-size: 11px; color: #8b949e; margin-bottom: 10px; }
|
|
588
|
+
.table-wrap { overflow-x: auto; }
|
|
589
|
+
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
590
|
+
th { background: #1c2128; color: #8b949e; font-weight: 600; text-align: left; padding: 7px 12px; border-bottom: 1px solid #30363d; white-space: nowrap; }
|
|
591
|
+
td { padding: 6px 12px; border-bottom: 1px solid #21262d; color: #e6edf3; }
|
|
592
|
+
td.num { text-align: right; font-family: monospace; }
|
|
593
|
+
tr:last-child td { border-bottom: none; }
|
|
594
|
+
.truncated { font-size: 11px; color: #8b949e; margin-top: 8px; }
|
|
595
|
+
.cell-error { padding: 12px 14px; background: #3d1a1a; border-top: 1px solid #f85149; color: #f85149; font-size: 13px; }
|
|
596
|
+
.exported-by { text-align: center; color: #484f58; font-size: 11px; padding: 40px 0 24px; }
|
|
597
|
+
</style>
|
|
598
|
+
</head>
|
|
599
|
+
<body>
|
|
600
|
+
<div class="page-header">
|
|
601
|
+
<div class="logo">DQL</div>
|
|
602
|
+
<span class="page-title">${lt(e)}</span>
|
|
603
|
+
<span class="page-meta">Exported ${new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}</span>
|
|
604
|
+
</div>
|
|
605
|
+
<div class="content">
|
|
606
|
+
${n}
|
|
607
|
+
</div>
|
|
608
|
+
<p class="exported-by">Built with DQL Workbench</p>
|
|
609
|
+
</body>
|
|
610
|
+
</html>`}function lC(e,t){const n=cC(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)}const Ho=["local-operations"],of=p.createContext(null);function di(e,t){const n=e.filter(r=>r.id!==t.id);return n.push(t),n.sort((r,o)=>o.updatedAt.localeCompare(r.updatedAt)).slice(0,50)}function dC({children:e}){const t=Hi(),n=p.useRef(new Set),r=Ge(a=>a.dispatch),o=ji({queryKey:Ho,queryFn:async()=>(await B.listOperations(50)).operations,staleTime:15e3,refetchOnWindowFocus:!1,refetchInterval:1500}),i=o.data??[];p.useEffect(()=>{let a=!0,l,u;const h=()=>{u=new AbortController,xp("/api/operations/events",d=>{if(d.event==="operation")try{const f=JSON.parse(d.data);t.setQueryData(Ho,(m=[])=>di(m,f))}catch{}},u.signal).catch(()=>{!a||u!=null&&u.signal.aborted||(l=setTimeout(h,5e3))})};return h(),()=>{a=!1,l&&clearTimeout(l),u==null||u.abort()}},[t]),p.useEffect(()=>{for(const a of i){if(a.type!=="block_certification"||a.status!=="succeeded"||n.current.has(a.id))continue;const l=a.result;!(l!=null&&l.block)||!l.outcome||(n.current.add(a.id),r({type:"RECONCILE_BLOCK_CERTIFICATION",outcome:l.outcome,oldPath:l.oldPath,draftPath:l.draftPath,newPath:l.newPath,payload:l.block}),window.dispatchEvent(new CustomEvent("dql:block-library-invalidated",{detail:{operationId:a.id,outcome:l.outcome}})))}},[r,i]);const c=p.useMemo(()=>({operations:i,activeCount:i.filter(a=>a.status==="queued"||a.status==="running").length,loading:o.isLoading,cancel:async a=>{const l=await B.cancelOperation(a);t.setQueryData(Ho,(u=[])=>di(u,l))},track:a=>{t.setQueryData(Ho,(l=[])=>di(l,a))}}),[i,o.isLoading,t]);return s.jsx(of.Provider,{value:c,children:e})}function uC(){const e=p.useContext(of);if(!e)throw new Error("useOperations must be used inside OperationsProvider.");return e}function $l(e){var n,r,o,i,c,a;if(e.status==="queued"||e.status==="running")return{active:!0,tone:"active",statusLabel:e.status,message:e.message,guidance:e.type==="block_certification"?"You can change pages while certification continues.":void 0};if(e.type==="block_certification"&&e.status==="succeeded"){const l=e.result;if((l==null?void 0:l.outcome)==="draft_saved_with_blockers"){const u=((r=(n=l.checklist)==null?void 0:n.issues)==null?void 0:r.length)??((o=l.blockers)==null?void 0:o.length)??((i=l.checklist)==null?void 0:i.blockers.length)??0;return{active:!1,tone:"attention",statusLabel:"needs attention",message:u>0?`Draft saved with ${u} certification blocker${u===1?"":"s"}.`:"Draft saved, but certification requirements are not ready.",guidance:"Open Block Studio to review the exact fixes and retry."}}if((l==null?void 0:l.outcome)==="certified")return{active:!1,tone:"success",statusLabel:"certified",message:"The block passed its required gates and was certified."}}return e.status==="failed"||e.status==="interrupted"?{active:!1,tone:"failure",statusLabel:e.status,message:((c=e.error)==null?void 0:c.message)??e.message,guidance:e.type==="block_certification"?"The saved draft is preserved for review or retry.":void 0}:e.status==="cancelled"?{active:!1,tone:"neutral",statusLabel:"cancelled",message:e.message}:{active:!1,tone:e.status==="succeeded"?"success":"neutral",statusLabel:e.status,message:((a=e.error)==null?void 0:a.message)??e.message}}const pC=new Set(["succeeded","failed","cancelled","interrupted"]);function fC(){const e=Ge(d=>d.themeMode),t=Qe[e],{operations:n,activeCount:r,loading:o,cancel:i}=uC(),[c,a]=p.useState(!1),l=p.useRef(null),u=n.filter(d=>!pC.has(d.status)||d.type!=="project_refresh").slice(0,8),h=u.filter(d=>$l(d).tone==="attention").length;return p.useEffect(()=>{if(!c)return;const d=m=>{l.current&&!l.current.contains(m.target)&&a(!1)},f=m=>{m.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[c]),!o&&u.length===0?null:s.jsxs("div",{ref:l,style:{position:"relative"},children:[s.jsxs("button",{type:"button","aria-label":"Background tasks","aria-expanded":c,onClick:()=>a(d=>!d),style:{height:28,padding:"0 9px",borderRadius:6,border:`1px solid ${r>0?t.accent:h>0?t.warning:t.btnBorder}`,background:c?t.btnHover:t.btnBg,color:t.textSecondary,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6,fontFamily:t.font,fontSize:11,fontWeight:600},children:[s.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:999,background:r>0?t.accent:h>0?t.warning:t.success,boxShadow:r>0?`0 0 0 3px ${t.accent}20`:"none"}}),r>0?`${r} running`:h>0?`${h} needs attention`:"Tasks"]}),c&&s.jsxs("div",{role:"dialog","aria-label":"Background tasks",style:{position:"absolute",top:34,right:0,zIndex:1200,width:340,maxHeight:420,overflowY:"auto",background:t.modalBg,border:`1px solid ${t.cellBorder}`,borderRadius:9,boxShadow:"0 14px 36px rgba(0,0,0,0.28)",padding:8},children:[s.jsx("div",{style:{padding:"4px 6px 8px",color:t.textPrimary,fontSize:12,fontWeight:700},children:"Background tasks"}),u.map(d=>{const f=$l(d),m=f.active,S=f.tone==="failure"?t.error:f.tone==="attention"?t.warning:f.tone==="success"?t.success:t.textMuted;return s.jsxs("div",{style:{padding:"9px 8px",borderTop:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",gap:6},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx("span",{style:{flex:1,color:t.textPrimary,fontSize:11.5,fontWeight:650},children:hC(d.type)}),s.jsx("span",{style:{color:S,fontSize:10},children:f.statusLabel})]}),s.jsx("div",{style:{color:f.tone==="failure"?t.error:f.tone==="attention"?t.warning:t.textSecondary,fontSize:10.5,lineHeight:1.4},children:f.message}),m&&s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s.jsx("div",{style:{flex:1,height:3,borderRadius:99,overflow:"hidden",background:t.headerBorder},children:s.jsx("div",{style:{width:`${Math.max(3,d.progress)}%`,height:"100%",background:t.accent,transition:"width 180ms ease"}})}),d.cancellable&&s.jsx("button",{type:"button",onClick:()=>void i(d.id),style:{border:0,background:"transparent",color:t.textMuted,cursor:"pointer",fontSize:10,padding:0},children:"Cancel"})]}),d.type==="block_certification"&&s.jsx("div",{style:{color:t.textMuted,fontSize:9.5},children:f.guidance??(f.tone==="success"?"Certification is complete.":"The saved draft is preserved for review or retry.")}),(d.type==="agent_run"||d.type==="app_ai_build")&&s.jsx("div",{style:{color:t.textMuted,fontSize:9.5},children:m?"This continues while you work on another page.":d.status==="succeeded"?"Completed in the background.":"Open the original surface to review or retry."})]},d.id)})]})]})}function hC(e){return e==="block_certification"?"Block certification":e==="project_refresh"?"Project metadata refresh":e==="agent_run"?"AI request":e==="app_ai_build"?"App proposal":e.replace(/_/g," ")}const Zo=new Map;function mC(e,t){let n=Zo.get(e);n||(n={running:!1},Zo.set(e,n));const r=n,o=new Promise((i,c)=>{r.pending?(r.pending.content=t,r.pending.waiters.push({resolve:i,reject:c})):r.pending={content:t,waiters:[{resolve:i,reject:c}]}});return r.running||(r.running=!0,(async()=>{for(;r.pending;){const i=r.pending;r.pending=void 0;try{await B.saveNotebook(e,i.content);for(const c of i.waiters)c.resolve()}catch(c){for(const a of i.waiters)a.reject(c)}}})().finally(()=>{r.running=!1,r.pending||Zo.delete(e)})),o}function gC(e){const t=Zo.get(e);return!!(t!=null&&t.running||t!=null&&t.pending)}function yC({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 bC(){var te;const e=Ge(Ir(F=>({activeBlockPath:F.activeBlockPath,activeFile:F.activeFile,appMode:F.appMode,autoSave:F.autoSave,blockStudioDirty:F.blockStudioDirty,blockStudioDraft:F.blockStudioDraft,blockStudioMetadata:F.blockStudioMetadata,cells:F.cells,files:F.files,mainView:F.mainView,notebookDirty:F.notebookDirty,notebookMetadata:F.notebookMetadata,notebookTitle:F.notebookTitle,savingFile:F.savingFile,themeMode:F.themeMode}))),t=Cn(),n=Qe[e.themeMode],{executeAll:r}=rf(),[o,i]=p.useState(!1),[c,a]=p.useState(""),[l,u]=p.useState(!1),[h,d]=p.useState(!1),[f,m]=p.useState(!1),[S,v]=p.useState(!1),[b,w]=p.useState(!1),j=p.useRef(null),[C,x]=p.useState(!1),[E,P]=p.useState(!1),A=p.useRef(null),g=p.useRef(null),I=e.mainView==="block_studio"?e.blockStudioDirty:e.notebookDirty,T=e.mainView==="notebook",O=e.mainView==="notebook"||e.mainView==="block_studio",_=O&&!!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:"Modeling",modeling:"Modeling"},q=O?e.activeFile?e.notebookTitle||"Untitled":e.mainView==="block_studio"?"Blocks":"Notebooks":M[e.mainView]??"DQL Workbench";p.useEffect(()=>{o&&g.current&&(g.current.focus(),g.current.select())},[o]),p.useEffect(()=>{if(!E)return;function F(K){A.current&&!A.current.contains(K.target)&&P(!1)}return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[E]);const G=()=>{a(e.notebookTitle),i(!0)},J=()=>{i(!1),c.trim()&&c!==e.notebookTitle&&(e.mainView==="block_studio"&&e.blockStudioMetadata?(t({type:"SET_BLOCK_STUDIO_METADATA",metadata:{...e.blockStudioMetadata,name:c.trim()}}),t({type:"SET_BLOCK_STUDIO_DRAFT",draft:K1(e.blockStudioDraft,c.trim())})):t({type:"SET_NOTEBOOK_DIRTY",dirty:!0}))},H=p.useCallback(async()=>{var K,oe,ee;const F=Pn.getState();if(F.activeFile){t({type:"SET_SAVING",saving:!0});try{if(F.mainView==="block_studio"){if(!F.blockStudioMetadata)return;const ce=await B.saveBlockStudio({path:F.activeBlockPath,source:F.blockStudioDraft,metadata:{name:F.blockStudioMetadata.name,domain:F.blockStudioMetadata.domain,folderPath:F.blockStudioMetadata.folderPath,description:F.blockStudioMetadata.description,owner:F.blockStudioMetadata.owner,tags:F.blockStudioMetadata.tags}});t({type:"OPEN_BLOCK_STUDIO",file:{name:`${ce.metadata.name}.dql`,path:ce.path,type:"block",folder:"blocks"},payload:ce}),F.files.some(ke=>ke.path===ce.path)||t({type:"FILE_ADDED",file:{name:`${ce.metadata.name}.dql`,path:ce.path,type:"block",folder:"blocks"}})}else{const ce=F.activeFile,ke=F.cells,xe=F.notebookTitle,De=F.notebookMetadata,We=ce.type==="block"?((K=ke[0])==null?void 0:K.content)??"":P1(xe,ke,De);await mC(ce.path,We);const Be=Pn.getState();((oe=Be.activeFile)==null?void 0:oe.path)===ce.path&&Be.cells===ke&&Be.notebookTitle===xe&&Be.notebookMetadata===De&&t({type:"SET_NOTEBOOK_DIRTY",dirty:!1})}u(!0),setTimeout(()=>u(!1),2e3)}catch(ce){console.error("Save failed:",ce)}finally{const ce=(ee=Pn.getState().activeFile)==null?void 0:ee.path;(!ce||!gC(ce))&&t({type:"SET_SAVING",saving:!1})}}},[t]);p.useEffect(()=>{const F=K=>{(K.metaKey||K.ctrlKey)&&K.key==="s"&&(K.preventDefault(),H())};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[H]),p.useEffect(()=>{if(!e.autoSave||!I||!e.activeFile||e.mainView==="block_studio")return;const F=setTimeout(()=>{H()},750);return()=>clearTimeout(F)},[e.autoSave,I,e.activeFile,e.cells,e.blockStudioDraft,H]);const L=[{mode:"obsidian",label:"Obsidian",glyph:"●",swatch:"#0d0e11"},{mode:"paper",label:"Paper",glyph:"☼",swatch:"#f7f4ed"},{mode:"white",label:"White",glyph:"○",swatch:"#ffffff"}],$=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode,X=L.find(F=>F.mode===$)??L[0];p.useEffect(()=>{if(!b)return;const F=oe=>{j.current&&!j.current.contains(oe.target)&&w(!1)},K=oe=>{oe.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",K)}},[b]);const W={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(yC,{t:n}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile&&O&&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&&O?o?s.jsx("input",{ref:g,value:c,onChange:F=>a(F.target.value),onBlur:J,onKeyDown:F=>{F.key==="Enter"&&J(),F.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:G,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:[q,I&&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:q||"DQL Workbench"})]}),s.jsx("div",{style:{flex:1}}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[s.jsx(fC,{}),e.appMode==="studio"&&_&&e.mainView!=="block_studio"&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:T?r:void 0,disabled:!e.activeFile||!T,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{...W,height:30,padding:"0 14px",borderRadius:999,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:!e.activeFile||!T?.4:h?.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:j,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>w(F=>!F),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),title:`Theme: ${X.label}`,"aria-haspopup":"true","aria-expanded":b,style:{...W,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:X.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,letterSpacing:"0.04em"},children:X.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:L.map(F=>{const K=F.mode===$;return s.jsxs("button",{role:"menuitemradio","aria-checked":K,onClick:()=>{t({type:"SET_THEME",mode:F.mode}),w(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",background:K?n.btnHover:"transparent",color:n.textPrimary,cursor:"pointer",borderRadius:4,fontSize:12,fontFamily:n.font,textAlign:"left"},onMouseEnter:oe=>{K||(oe.currentTarget.style.background=n.btnHover)},onMouseLeave:oe=>{K||(oe.currentTarget.style.background="transparent")},children:[s.jsx("span",{style:{width:14,height:14,borderRadius:3,background:F.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{flex:1},children:F.label}),K&&s.jsx("span",{style:{color:n.accent,fontSize:11},children:"✓"})]},F.mode)})})]}),e.appMode==="studio"&&_&&e.mainView!=="block_studio"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:H,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),title:"Save (Cmd+S)",style:{...W,background:f&&e.activeFile?n.btnHover:n.btnBg,color:l?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?s.jsxs(s.Fragment,{children:[s.jsx(vC,{}),"Saving…"]}):l?s.jsx(s.Fragment,{children:"✓ Saved"}):s.jsx(s.Fragment,{children:"Save"})}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),_&&e.mainView!=="block_studio"&&s.jsxs("div",{ref:A,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>{e.activeFile&&P(F=>!F)},disabled:!e.activeFile,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),title:"Share / export",style:{...W,height:30,padding:"0 14px",borderRadius:999,background:(C||E)&&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"})})]}),E&&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(xC,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{lC(e.notebookTitle||"dashboard",e.cells),P(!1)}})})]})]})]})}function xC({label:e,description:t,t:n,onClick:r}){const[o,i]=p.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 vC(){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 SC(e){return e.toTimeString().slice(0,8)}function wC(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function kC(){const{state:e,dispatch:t}=et(),n=Qe[e.themeMode],[r,o]=p.useState(!1),i=e.queryLog.filter(a=>a.error),c=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(CC,{label:a==="errors"?`Errors${i.length>0?` (${i.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>c(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(Ml,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>s.jsx(Ll,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(i.length===0?s.jsx(Ml,{t:n,message:"No errors."}):[...i].reverse().map(a=>s.jsx(Ll,{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 CC({label:e,active:t,onClick:n,t:r}){const[o,i]=p.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 Ml({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 Ll({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:SC(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:wC(e.time)})]})]})}function jC(){const{state:e,dispatch:t}=et(),{executeAll:n}=rf();p.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 EC=600;function TC(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 Nl(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 AC(){var o;const{state:e}=et(),t=p.useRef(null),n=p.useRef(""),r=p.useRef(null);p.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=Nl(e.cells);return}const c=Nl(e.cells);return c!==n.current&&(n.current=c,t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{const l=TC(i,e.cells);B.saveRunSnapshot(i,l).catch(()=>{})},EC)),()=>{t.current&&(clearTimeout(t.current),t.current=null)}},[e.cells,(o=e.activeFile)==null?void 0:o.path])}const Qj="core";function RC(e){var n;const t=e==null?void 0:e.trim();if(t)return((n=t.split("::").at(-1))==null?void 0:n.trim())||void 0}const OC=[{items:[{id:"diagram",label:"Modeling"},{id:"skills",label:"Skills"},{id:"blocks",label:"Blocks"},{id:"notebooks",label:"Notebooks"},{id:"apps",label:"Apps"}]}],_C=new Set(OC.flatMap(e=>e.items.map(t=>t.id)));function sf(e){return e!==null&&_C.has(e)}function Jj(e,t){const n=new URL(e);return t.domain?n.searchParams.set("domain",t.domain):n.searchParams.delete("domain"),n.searchParams.set("domainSection",t.section),t.modelAreaId?n.searchParams.set("modelArea",t.modelAreaId):n.searchParams.delete("modelArea"),t.selectedId?n.searchParams.set("domainObject",t.selectedId):n.searchParams.delete("domainObject"),`${n.pathname}${n.search}${n.hash}`}function PC(e){const t=new URL(e);for(const n of af)t.searchParams.delete(n);return`${t.pathname}${t.search}${t.hash}`}const af=["domain","domainSection","modelArea","domainObject"],Yj="dql.domain-studio.location";function Xj(e,t){const n=new URL(e).searchParams;if(af.some(r=>n.has(r))){const r=n.get("domainSection"),o=sf(r)?r:"diagram";return{domain:n.get("domain"),section:o,modelAreaId:n.get("modelArea"),selectedId:r==="diagram"?n.get("domainObject"):null}}return IC(t)}function IC(e){const t={domain:null,section:"diagram",modelAreaId:null,selectedId:null};if(!e)return t;try{const n=JSON.parse(e),r=typeof n.section=="string"&&sf(n.section)?n.section:"diagram",o=i=>typeof i=="string"&&i.trim()?i:null;return{domain:o(n.domain),section:r,modelAreaId:o(n.modelAreaId),selectedId:o(n.selectedId)}}catch{return t}}function Zj(e){return`modeling:${e??"all"}`}function eE(e){const t=Object.values(e),n=new Map;for(const c of t){const a=c.parent&&e[c.parent]?c.parent:void 0;n.set(a,[...n.get(a)??[],c])}for(const c of n.values())c.sort((a,l)=>a.id.localeCompare(l.id));const r=[],o=new Set,i=(c,a)=>{for(const l of n.get(c)??[])o.has(l.id)||(o.add(l.id),r.push({id:l.id,parent:l.parent,depth:a,label:a===0?l.id:`${"— ".repeat(a)}${l.id.split(".").at(-1)??l.id}`}),i(l.id,a+1))};i(void 0,0);for(const c of t.sort((a,l)=>a.id.localeCompare(l.id)))o.has(c.id)||r.push({id:c.id,parent:c.parent,depth:0,label:c.id});return r}function tE(e){const t=(e??"").toLowerCase();return t==="dimension"?"var(--status-success)":t==="bridge"?"var(--status-warning)":t==="event"||t==="snapshot"?"var(--accent)":"var(--text-tertiary)"}function cf(e){return Object.entries(e.entities).map(([t,n])=>({recordKey:t,entity:n}))}function nE(e,t){if(e.entities[t])return t;const n=cf(e).filter(({entity:r})=>r.id===t||r.qualifiedId===t);return n.length===1?n[0].recordKey:void 0}function rE(e,t){return cf(e).filter(({entity:n})=>!t||n.domain===t)}function oE(e,t,n){if(e.operation==="upsert_entity"){if(!t)return!1;const r=e.value;return r.dbtModel===t.dbtUniqueId&&(r.grain??void 0)===(t.grain??void 0)&&JSON.stringify(r.keys??[])===JSON.stringify(t.keys??[])&&(r.status??t.status)===t.status&&(r.areaId??void 0)===RC(t.areaId)&&r.domain===t.domain}return e.operation==="upsert_area"?!!n&&e.value.domain===n.domain&&e.value.id===n.localId:!1}const DC=p.lazy(()=>_e(()=>import("./HomePage-zGPFIvOY.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.HomePage}))),$C=p.lazy(()=>_e(()=>import("./AnalyticsHome-C2vJ2fxY.js"),__vite__mapDeps([7,8,9,10,1,11,12,3,13,14,15,16,17,2,18,6])).then(e=>({default:e.AnalyticsHome}))),MC=p.lazy(()=>_e(()=>import("./GlobalAiRail-BTZS11x5.js"),__vite__mapDeps([19,9,10,1,11,12,3,13,14,15,16,17,2,20,6])).then(e=>({default:e.GlobalAiRail}))),LC=p.lazy(()=>_e(()=>import("./NotebookEditor-D2fIUxjE.js"),__vite__mapDeps([21,4,2,5,22,23,24,10,1,11,12,3,13,14,9,15,16,17,8,25,26,6,27,28,20,29])).then(e=>({default:e.NotebookEditor}))),NC=p.lazy(()=>_e(()=>import("./NewNotebookModal-BUIByvYT.js"),__vite__mapDeps([30,4,15,6])).then(e=>({default:e.NewNotebookModal}))),BC=p.lazy(()=>_e(()=>import("./NewBlockModal-DKVkXD20.js"),__vite__mapDeps([31,6])).then(e=>({default:e.NewBlockModal}))),FC=p.lazy(()=>_e(()=>import("./SetupOnboarding-BF7ai_0t.js"),__vite__mapDeps([32,33,2,6])).then(e=>({default:e.SetupOnboarding}))),zC=p.lazy(()=>_e(()=>import("./BlockStudio-CaDNTKMM.js"),__vite__mapDeps([34,22,23,10,1,11,12,3,13,14,25,26,6,27,9,15,16,17,2,20,35,36])).then(e=>({default:e.BlockStudio}))),qC=p.lazy(()=>_e(()=>import("./BusinessArtifactView-zwUOtddi.js"),__vite__mapDeps([37,25,26,6,27])).then(e=>({default:e.BusinessArtifactView}))),UC=p.lazy(()=>_e(()=>import("./LineageDetailView-Ch1Db01I.js"),__vite__mapDeps([38,25,26,6,27,39,33,16])).then(e=>({default:e.LineageDetailView}))),WC=p.lazy(()=>_e(()=>import("./LineageDAG-DbXnQWu3.js"),__vite__mapDeps([39,26,6,27])).then(e=>({default:e.LineageDAG}))),KC=p.lazy(()=>_e(()=>import("./HelpDocsPage-C1UeP85v.js"),__vite__mapDeps([40,6])).then(e=>({default:e.HelpDocsPage}))),VC=p.lazy(()=>_e(()=>Promise.resolve().then(()=>t1),void 0).then(e=>({default:e.ConnectionPanel}))),HC=p.lazy(()=>_e(()=>import("./GitPage-Coevr9NJ.js"),__vite__mapDeps([41,42,15,6])).then(e=>({default:e.GitPage}))),GC=p.lazy(()=>_e(()=>import("./ReadinessPage-Ci4LyNiQ.js"),__vite__mapDeps([43,1,44,45,12,3,2,6])).then(e=>({default:e.ReadinessPage}))),QC=p.lazy(()=>_e(()=>import("./AgentLogPage-B3ugEb3H.js"),__vite__mapDeps([46,33,14,47,6])).then(e=>({default:e.AgentLogPage}))),JC=p.lazy(()=>_e(()=>import("./GovernedContextPage-CjyyM_ne.js"),__vite__mapDeps([48,3,12,9,10,1,11,13,14,15,16,17,2,49,6])).then(e=>({default:e.GovernedContextPage}))),YC=p.lazy(()=>_e(()=>import("./DbtFirstModelingPage-BlnhTMu3.js"),__vite__mapDeps([50,49,9,10,1,11,12,3,13,14,15,16,17,2,26,6,27,28,29,36,51,47])).then(e=>({default:e.DbtFirstModelingPage}))),XC=p.lazy(()=>_e(()=>import("./AppsView-DEWQ0sHT.js"),__vite__mapDeps([52,20,17,10,1,11,12,3,13,14,15,33,35,29,4,5,24,8,45,53,51,2,18,6])).then(e=>({default:e.AppsView}))),ZC=p.lazy(()=>_e(()=>import("./LineageDrawer-DLxqJO6D.js"),__vite__mapDeps([54,25,26,6,27,36,15,17,13,53,42])).then(e=>({default:e.LineageDrawer}))),ej=p.lazy(()=>_e(()=>import("./AiBuildDialog-BK_TDNcM.js"),__vite__mapDeps([55,44,11,12,3,13,15,6])).then(e=>({default:e.AiBuildDialog})));function tj(){const e=Ge(Ir(d=>({appMode:d.appMode,dashboardMode:d.dashboardMode,globalAi:d.globalAi,inspectorOpen:d.inspectorOpen,lineageDrawerOpen:d.lineageDrawerOpen,lineageFullscreen:d.lineageFullscreen,mainView:d.mainView,newBlockModalOpen:d.newBlockModalOpen,newNotebookModalOpen:d.newNotebookModalOpen,setupOpen:d.setupOpen,sidebarOpen:d.sidebarOpen,sidebarPanel:d.sidebarPanel,themeMode:d.themeMode}))),t=Cn(),n=Qe[e.themeMode],r=p.useRef({}),o=e.mainView==="block_studio"||e.mainView==="imports",[i,c]=p.useState(!1),[a,l]=p.useState(null);p.useEffect(()=>{let d=!0;return B.getSetupLaunch().then(f=>{d&&(l(f),f.shouldOpen&&t({type:"OPEN_SETUP"}))}).catch(()=>{}),()=>{d=!1}},[t]),p.useEffect(()=>{const d=()=>t({type:"SET_MAIN_VIEW",view:"modeling"});return window.addEventListener("dql:open-context-proposal",d),()=>window.removeEventListener("dql:open-context-proposal",d)},[t]),p.useEffect(()=>{if(e.mainView==="domains"||e.mainView==="modeling"||e.mainView==="skills")return;const d=PC(window.location.href),f=`${window.location.pathname}${window.location.search}${window.location.hash}`;d!==f&&window.history.replaceState(window.history.state,"",d)},[e.mainView]),jC(),AC(),p.useEffect(()=>{const d=f=>{(f.metaKey||f.ctrlKey)&&f.key.toLowerCase()==="k"&&!f.shiftKey&&(f.preventDefault(),c(m=>!m)),(f.metaKey||f.ctrlKey)&&f.shiftKey&&f.key.toLowerCase()==="i"&&(f.preventDefault(),t({type:"TOGGLE_INSPECTOR"}))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t]);const u=p.useCallback(async d=>{try{if(d.type==="term"||d.type==="business_view"){e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"}),t({type:"OPEN_BUSINESS_ARTIFACT",file:d});return}if(d.type==="block"){const j=await B.openBlockStudio(d.path);t({type:"OPEN_BLOCK_STUDIO",file:d,payload:j});return}const{content:f}=await B.readNotebook(d.path),{title:m,cells:S,metadata:v}=I1(d.path,f),b=d.path.endsWith(".dqlnb")?await B.fetchRunSnapshot(d.path):null;let w=S;if(b!=null&&b.found&&b.snapshot){const j=new Map(b.snapshot.cells.map(C=>[C.cellId,C]));w=S.map(C=>{const x=j.get(C.id);return x?{...C,status:x.status??C.status,result:x.result??C.result,error:x.error??C.error,executionCount:x.executionCount??C.executionCount,execution:x.execution??C.execution,fromSnapshot:x.result!=null}:C})}t({type:"OPEN_FILE",file:d,cells:w,title:m,metadata:v}),e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(f){if(console.error("Failed to open file:",f),d.type==="block")try{const{content:m}=await B.readNotebook(d.path);t({type:"OPEN_BLOCK_STUDIO",file:d,payload:{path:d.path,source:m,companionPath:null,metadata:{name:d.name.replace(/\.dql$/i,""),path:d.path,domain:d.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(m){console.error("Failed to open block fallback:",m)}else t({type:"OPEN_FILE",file:d,cells:[ja("sql")],title:d.name})}},[t,e.sidebarPanel]);p.useCallback(d=>{const f=r.current[d];f&&f.scrollIntoView({behavior:"smooth",block:"start"})},[]);const h=p.useCallback((d,f)=>{f?r.current[d]=f:delete r.current[d]},[]);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(bC,{}),s.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.appMode==="studio"&&s.jsx(Bw,{}),e.appMode==="studio"&&e.sidebarOpen&&!o&&s.jsx(E1,{onOpenFile:u}),s.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:s.jsx(p.Suspense,{fallback:s.jsx(nj,{t:n}),children:e.mainView==="home"?s.jsx(DC,{}):e.mainView==="ask"?s.jsx($C,{}):e.mainView==="business_artifact"?s.jsx(qC,{}):e.mainView==="lineage"?s.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:s.jsx(WC,{})}):e.mainView==="lineage_detail"?s.jsx(UC,{}):e.mainView==="help"?s.jsx(KC,{}):e.mainView==="connection"||e.mainView==="settings"?s.jsx(oj,{children:s.jsx(VC,{variant:"page"})}):e.mainView==="git"?s.jsx(HC,{}):e.mainView==="readiness"?s.jsx(GC,{}):e.mainView==="skills"?s.jsx(JC,{initialTab:"skills"}):e.mainView==="domains"||e.mainView==="modeling"?s.jsx(YC,{}):e.mainView==="apps"?s.jsx(XC,{}):e.mainView==="agent_log"?s.jsx(sj,{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(QC,{})}):s.jsx(s.Fragment,{children:e.mainView==="imports"||e.mainView==="block_studio"?s.jsx(zC,{},"block-editor"):s.jsxs(s.Fragment,{children:[s.jsx(LC,{onOpenFile:u,registerCellRef:h}),e.appMode==="studio"&&s.jsx(kC,{})]})})})}),e.appMode==="studio"&&e.lineageDrawerOpen&&!e.lineageFullscreen&&!e.dashboardMode&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(ZC,{})}),e.appMode==="studio"&&e.inspectorOpen&&!e.lineageFullscreen&&!e.lineageDrawerOpen&&!e.dashboardMode&&s.jsx(Tw,{}),e.globalAi.open&&e.mainView==="apps"&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(MC,{})})]}),e.newNotebookModalOpen&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(NC,{onFileOpened:u})}),e.newBlockModalOpen&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(BC,{onFileOpened:u})}),s.jsx(KS,{open:i,onClose:()=>c(!1)}),s.jsx(p.Suspense,{fallback:null,children:s.jsx(ej,{})}),e.setupOpen&&s.jsx(p.Suspense,{fallback:s.jsx(rj,{t:n}),children:s.jsx(FC,{launch:a!=null&&a.shouldOpen?a:void 0,onAcknowledged:()=>l(d=>d&&{...d,shouldOpen:!1,reason:null})})})]})}function nj({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 rj({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 oj({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 sj({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 ij(){const e=Cn(),t=Hi(),n=p.useRef(null);p.useEffect(()=>{let r=!0,o=null,i=null,c=null,a=null;const l=()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,B.listNotebooks().then(f=>{r&&(t.setQueryData(["notebooks"],f),e({type:"SET_FILES",files:f}))}).catch(()=>{})},150)},u=()=>{c&&clearTimeout(c),c=setTimeout(()=>{c=null,B.getDomains().then(({domains:f})=>{r&&(t.setQueryData(["authored-domains"],{domains:f}),e({type:"SET_AUTHORED_DOMAINS",domains:f}))}).catch(()=>{})},150)},h=()=>{a&&clearTimeout(a),a=setTimeout(()=>{a=null,e({type:"SET_SEMANTIC_LOADING",loading:!0}),B.getSemanticLayer().then(f=>{r&&(t.setQueryData(["semantic-layer"],f),e({type:"SET_SEMANTIC_LAYER",layer:f}))}).catch(()=>{})},100)},d=()=>{if(!r)return;const f=new AbortController;n.current=f,xp("/api/watch",m=>{if(m.event==="change")try{const S=JSON.parse(m.data);if(S.type==="file-added"||S.type==="file-deleted"||S.type==="file-changed"){const v=S.path??"";/^(?:notebooks|workbooks|blocks|skills|apps|dashboards)\//.test(v)&&l(),v.startsWith("domains/")&&(l(),u())}S.type==="semantic-reload"&&h()}catch{}},f.signal).catch(()=>{!r||f.signal.aborted||(o&&clearTimeout(o),o=setTimeout(d,5e3))})};return d(),()=>{var f;r=!1,o&&clearTimeout(o),i&&clearTimeout(i),c&&clearTimeout(c),a&&clearTimeout(a),(f=n.current)==null||f.abort(),n.current=null}},[e,t])}const aj=new Zf({defaultOptions:{queries:{staleTime:15e3,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});function cj(){const e=Ge(i=>i.themeMode),t=Ge(i=>i.dispatch),n=Qe[e];p.useEffect(()=>{const i="dql-global-styles";let c=document.getElementById(i);c||(c=document.createElement("style"),c.id=i,document.head.appendChild(c)),c.textContent=`
|
|
611
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
612
|
+
body {
|
|
613
|
+
font-family: var(--font-ui, ${n.font});
|
|
614
|
+
overflow: hidden;
|
|
615
|
+
background: var(--color-bg-primary);
|
|
616
|
+
color: var(--color-text-primary);
|
|
617
|
+
}
|
|
618
|
+
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
619
|
+
::-webkit-scrollbar-track { background: transparent; }
|
|
620
|
+
::-webkit-scrollbar-thumb {
|
|
621
|
+
background: var(--color-border-secondary);
|
|
622
|
+
border-radius: 3px;
|
|
623
|
+
}
|
|
624
|
+
::-webkit-scrollbar-thumb:hover {
|
|
625
|
+
background: var(--color-text-tertiary);
|
|
626
|
+
}
|
|
627
|
+
::selection {
|
|
628
|
+
background: color-mix(in srgb, var(--color-accent-blue) 25%, transparent);
|
|
629
|
+
color: var(--color-text-primary);
|
|
630
|
+
}
|
|
631
|
+
.dql-meta-pill:hover {
|
|
632
|
+
background: var(--dql-pill-hover-bg) !important;
|
|
633
|
+
border-color: var(--dql-pill-hover-border) !important;
|
|
634
|
+
}
|
|
635
|
+
`},[n]),p.useEffect(()=>{const i=e==="dark"||e==="midnight"?"obsidian":e==="light"?"paper":e==="arctic"?"white":e;document.documentElement.setAttribute("data-theme",i)},[e]);const r=ji({queryKey:["notebooks"],queryFn:()=>B.listNotebooks()}),o=ji({queryKey:["authored-domains"],queryFn:()=>B.getDomains()});return p.useEffect(()=>{t({type:"SET_FILES_LOADING",loading:r.isLoading}),r.data&&t({type:"SET_FILES",files:r.data})},[t,r.data,r.isLoading]),p.useEffect(()=>{o.data&&t({type:"SET_AUTHORED_DOMAINS",domains:o.data.domains})},[t,o.data]),ij(),s.jsx(hh,{theme:e,applyGlobal:!0,children:s.jsx(jg,{delayDuration:200,skipDelayDuration:400,children:s.jsx(tj,{})})})}function lj(){return s.jsx(eh,{client:aj,children:s.jsx(zx,{children:s.jsx(dC,{children:s.jsx(cj,{})})})})}Tf.createRoot(document.getElementById("root")).render(s.jsx(lj,{}));export{hp as $,Hp as A,Ea as B,Sv as C,So as D,L1 as E,Aa as F,Dr as G,Mj as H,$j as I,Pn as J,rf as K,qn as L,bt as M,dS as N,Gj as O,wS as P,hk as Q,qe as R,gp as S,yp as T,wo as U,Qn as V,$w as W,wj as X,kj as Y,Rj as Z,Cj as _,B as a,rS as a$,cs as a0,Nk as a1,qp as a2,Ys as a3,Mi as a4,Oj as a5,uC as a6,ji as a7,Fj as a8,tk as a9,jw as aA,Ew as aB,bj as aC,Qc as aD,iS as aE,Jx as aF,ev as aG,Xv as aH,Hv as aI,kv as aJ,bv as aK,nE as aL,cf as aM,tE as aN,Qj as aO,rE as aP,Yj as aQ,Xj as aR,Jj as aS,eE as aT,Ip as aU,OC as aV,Rv as aW,pp as aX,Zj as aY,oE as aZ,I1 as a_,Wj as aa,Kj as ab,W1 as ac,K1 as ad,zj as ae,Dj as af,Gp as ag,Ij as ah,qj as ai,H1 as aj,V1 as ak,Bj as al,Rl as am,Uj as an,fs as ao,_0 as ap,xt as aq,Uc as ar,Tj as as,Aj as at,Ej as au,jj as av,Sp as aw,xj as ax,vj as ay,Sj as az,Re as b,cS as b0,ES as b1,Qv as b2,_e as b3,Hi as b4,_j as b5,_v as b6,cp as b7,OS as b8,$v as b9,Li as ba,Nj as bb,Qi as bc,ne as c,Ta as d,Rs as e,up as f,dv as g,Ge as h,Ir as i,s as j,Cn as k,PS as l,ja as m,q1 as n,Pj as o,ww as p,kw as q,p as r,Vj as s,Qe as t,et as u,Hj as v,Qp as w,Jp as x,Lj as y,F1 as z};
|