@owox/web 0.14.0-next-20251202122822 → 0.14.0-next-20251202131000
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/assets/{cssMode-SV3LkZxl.js → cssMode-B0NUF229.js} +1 -1
- package/dist/assets/{freemarker2-CxFgQ1qv.js → freemarker2-Cbvq0A5z.js} +1 -1
- package/dist/assets/{handlebars-BGKxT387.js → handlebars-D5arQ79o.js} +1 -1
- package/dist/assets/{html-Dy2rlxNJ.js → html-CZ2H75FG.js} +1 -1
- package/dist/assets/{htmlMode-Dg66JQT7.js → htmlMode-StGZiG_r.js} +1 -1
- package/dist/assets/{index-jfUDZGPl.js → index-CZmguTJ0.js} +9 -9
- package/dist/assets/{javascript-CJzMD2IB.js → javascript-Dm8DVvch.js} +1 -1
- package/dist/assets/{jsonMode-BYOLXHGD.js → jsonMode-zPJy-dyb.js} +1 -1
- package/dist/assets/{liquid-B6hlZhnN.js → liquid-Y04yjT3Q.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-D_32hsSa.js → lspLanguageFeatures-DKpB_NS0.js} +1 -1
- package/dist/assets/{mdx-Ct4CZHnS.js → mdx-CihRvnyN.js} +1 -1
- package/dist/assets/{python-Dv7zLVcI.js → python-B-EbuC3t.js} +1 -1
- package/dist/assets/{razor-VFna7_Vy.js → razor-Br_9PE1M.js} +1 -1
- package/dist/assets/{tsMode-BH2YA4LN.js → tsMode-EHFp3iGo.js} +1 -1
- package/dist/assets/{typescript-x36q2fbo.js → typescript-DG4B7a6p.js} +1 -1
- package/dist/assets/{xml-Dx8dIreF.js → xml-BnPiM_Gl.js} +1 -1
- package/dist/assets/{yaml-CqG7IK-x.js → yaml-CGLjecYr.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cssMode-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cssMode-B0NUF229.js","assets/lspLanguageFeatures-DKpB_NS0.js","assets/htmlMode-StGZiG_r.js","assets/jsonMode-zPJy-dyb.js","assets/javascript-Dm8DVvch.js","assets/typescript-DG4B7a6p.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var y6e=Object.defineProperty;var S6e=(n,e,t)=>e in n?y6e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Yn=(n,e,t)=>S6e(n,typeof e!="symbol"?e+"":e,t);function x6e(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const r=Object.getOwnPropertyDescriptor(i,s);r&&Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();function vSe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var lU={exports:{}},aT={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -504,7 +504,7 @@ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}
|
|
|
504
504
|
`)},npe=function(){var n=parseInt(document.body.getAttribute(TE)||"0",10);return isFinite(n)?n:0},oze=function(){x.useEffect(function(){return document.body.setAttribute(TE,(npe()+1).toString()),function(){var n=npe()-1;n<=0?document.body.removeAttribute(TE):document.body.setAttribute(TE,n.toString())}},[])},aze=function(n){var e=n.noRelative,t=n.noImportant,i=n.gapMode,s=i===void 0?"margin":i;oze();var r=x.useMemo(function(){return nze(s)},[s]);return x.createElement(sze,{styles:rze(r,!e,s,t?"":"!important")})},oK=!1;if(typeof window<"u")try{var QP=Object.defineProperty({},"passive",{get:function(){return oK=!0,!0}});window.addEventListener("test",QP,QP),window.removeEventListener("test",QP,QP)}catch{oK=!1}var Gx=oK?{passive:!1}:!1,lze=function(n){return n.tagName==="TEXTAREA"},Nxe=function(n,e){if(!(n instanceof Element))return!1;var t=window.getComputedStyle(n);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!lze(n)&&t[e]==="visible")},cze=function(n){return Nxe(n,"overflowY")},dze=function(n){return Nxe(n,"overflowX")},spe=function(n,e){var t=e.ownerDocument,i=e;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var s=Txe(n,i);if(s){var r=Ixe(n,i),o=r[1],a=r[2];if(o>a)return!0}i=i.parentNode}while(i&&i!==t.body);return!1},uze=function(n){var e=n.scrollTop,t=n.scrollHeight,i=n.clientHeight;return[e,t,i]},hze=function(n){var e=n.scrollLeft,t=n.scrollWidth,i=n.clientWidth;return[e,t,i]},Txe=function(n,e){return n==="v"?cze(e):dze(e)},Ixe=function(n,e){return n==="v"?uze(e):hze(e)},fze=function(n,e){return n==="h"&&e==="rtl"?-1:1},gze=function(n,e,t,i,s){var r=fze(n,window.getComputedStyle(e).direction),o=r*i,a=t.target,l=e.contains(a),c=!1,d=o>0,u=0,h=0;do{if(!a)break;var g=Ixe(n,a),m=g[0],b=g[1],v=g[2],C=b-v-r*m;(m||C)&&Txe(n,a)&&(u+=C,h+=m);var y=a.parentNode;a=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(d&&Math.abs(u)<1||!d&&Math.abs(h)<1)&&(c=!0),c},JP=function(n){return"changedTouches"in n?[n.changedTouches[0].clientX,n.changedTouches[0].clientY]:[0,0]},rpe=function(n){return[n.deltaX,n.deltaY]},ope=function(n){return n&&"current"in n?n.current:n},pze=function(n,e){return n[0]===e[0]&&n[1]===e[1]},mze=function(n){return`
|
|
505
505
|
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
|
506
506
|
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
|
507
|
-
`)},_ze=0,qx=[];function bze(n){var e=x.useRef([]),t=x.useRef([0,0]),i=x.useRef(),s=x.useState(_ze++)[0],r=x.useState(Rxe)[0],o=x.useRef(n);x.useEffect(function(){o.current=n},[n]),x.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(s));var b=HWe([n.lockRef.current],(n.shards||[]).map(ope),!0).filter(Boolean);return b.forEach(function(v){return v.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),b.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(s))})}}},[n.inert,n.lockRef.current,n.shards]);var a=x.useCallback(function(b,v){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!o.current.allowPinchZoom;var C=JP(b),y=t.current,L="deltaX"in b?b.deltaX:y[0]-C[0],E="deltaY"in b?b.deltaY:y[1]-C[1],R,T=b.target,N=Math.abs(L)>Math.abs(E)?"h":"v";if("touches"in b&&N==="h"&&T.type==="range")return!1;var I=spe(N,T);if(!I)return!0;if(I?R=N:(R=N==="v"?"h":"v",I=spe(N,T)),!I)return!1;if(!i.current&&"changedTouches"in b&&(L||E)&&(i.current=R),!R)return!0;var M=i.current||R;return gze(M,v,b,M==="h"?L:E)},[]),l=x.useCallback(function(b){var v=b;if(!(!qx.length||qx[qx.length-1]!==r)){var C="deltaY"in v?rpe(v):JP(v),y=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&pze(R.delta,C)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var L=(o.current.shards||[]).map(ope).filter(Boolean).filter(function(R){return R.contains(v.target)}),E=L.length>0?a(v,L[0]):!o.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),c=x.useCallback(function(b,v,C,y){var L={name:b,delta:v,target:C,should:y,shadowParent:vze(C)};e.current.push(L),setTimeout(function(){e.current=e.current.filter(function(E){return E!==L})},1)},[]),d=x.useCallback(function(b){t.current=JP(b),i.current=void 0},[]),u=x.useCallback(function(b){c(b.type,rpe(b),b.target,a(b,n.lockRef.current))},[]),h=x.useCallback(function(b){c(b.type,JP(b),b.target,a(b,n.lockRef.current))},[]);x.useEffect(function(){return qx.push(r),n.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Gx),document.addEventListener("touchmove",l,Gx),document.addEventListener("touchstart",d,Gx),function(){qx=qx.filter(function(b){return b!==r}),document.removeEventListener("wheel",l,Gx),document.removeEventListener("touchmove",l,Gx),document.removeEventListener("touchstart",d,Gx)}},[]);var g=n.removeScrollBar,m=n.inert;return x.createElement(x.Fragment,null,m?x.createElement(r,{styles:mze(s)}):null,g?x.createElement(aze,{noRelative:n.noRelative,gapMode:n.gapMode}):null)}function vze(n){for(var e=null;n!==null;)n instanceof ShadowRoot&&(e=n.host,n=n.host),n=n.parentNode;return e}const Cze=KWe(Dxe,bze);var pM=x.forwardRef(function(n,e){return x.createElement(lH,Gg({},n,{ref:e,sideCar:Cze}))});pM.classNames=lH.classNames;var wze=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},Kx=new WeakMap,e4=new WeakMap,t4={},NU=0,kxe=function(n){return n&&(n.host||kxe(n.parentNode))},yze=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=kxe(t);return i&&n.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},Sze=function(n,e,t,i){var s=yze(e,Array.isArray(n)?n:[n]);t4[t]||(t4[t]=new WeakMap);var r=t4[t],o=[],a=new Set,l=new Set(s),c=function(u){!u||a.has(u)||(a.add(u),c(u.parentNode))};s.forEach(c);var d=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(h){if(a.has(h))d(h);else try{var g=h.getAttribute(i),m=g!==null&&g!=="false",b=(Kx.get(h)||0)+1,v=(r.get(h)||0)+1;Kx.set(h,b),r.set(h,v),o.push(h),b===1&&m&&e4.set(h,!0),v===1&&h.setAttribute(t,"true"),m||h.setAttribute(i,"true")}catch(C){console.error("aria-hidden: cannot operate on ",h,C)}})};return d(e),a.clear(),NU++,function(){o.forEach(function(u){var h=Kx.get(u)-1,g=r.get(u)-1;Kx.set(u,h),r.set(u,g),h||(e4.has(u)||u.removeAttribute(i),e4.delete(u)),g||u.removeAttribute(t)}),NU--,NU||(Kx=new WeakMap,Kx=new WeakMap,e4=new WeakMap,t4={})}},cH=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),s=wze(n);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),Sze(i,s,t,"aria-hidden")):function(){return null}};function xze(n){const e=Lze(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Dze);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Lze(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Nze(s),a=Rze(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Eze=Symbol("radix.slottable");function Dze(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Eze}function Rze(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Nze(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var dH="Dialog",[Axe,Mxe]=Ha(dH),[Tze,ng]=Axe(dH),Oxe=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:s,onOpenChange:r,modal:o=!0}=n,a=x.useRef(null),l=x.useRef(null),[c,d]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:dH});return f.jsx(Tze,{scope:e,triggerRef:a,contentRef:l,contentId:To(),titleId:To(),descriptionId:To(),open:c,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(u=>!u),[d]),modal:o,children:t})};Oxe.displayName=dH;var Pxe="DialogTrigger",Fxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Pxe,t),r=Ui(e,s.triggerRef);return f.jsx(ui.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Wne(s.open),...i,ref:r,onClick:Lt(n.onClick,s.onOpenToggle)})});Fxe.displayName=Pxe;var Bne="DialogPortal",[Ize,jxe]=Axe(Bne,{forceMount:void 0}),Hxe=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:s}=n,r=ng(Bne,e);return f.jsx(Ize,{scope:e,forceMount:t,children:x.Children.map(i,o=>f.jsx(kl,{present:t||r.open,children:f.jsx(HS,{asChild:!0,container:s,children:o})}))})};Hxe.displayName=Bne;var aF="DialogOverlay",Bxe=x.forwardRef((n,e)=>{const t=jxe(aF,n.__scopeDialog),{forceMount:i=t.forceMount,...s}=n,r=ng(aF,n.__scopeDialog);return r.modal?f.jsx(kl,{present:i||r.open,children:f.jsx(Aze,{...s,ref:e})}):null});Bxe.displayName=aF;var kze=xze("DialogOverlay.RemoveScroll"),Aze=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(aF,t);return f.jsx(pM,{as:kze,allowPinchZoom:!0,shards:[s.contentRef],children:f.jsx(ui.div,{"data-state":Wne(s.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),W0="DialogContent",Vxe=x.forwardRef((n,e)=>{const t=jxe(W0,n.__scopeDialog),{forceMount:i=t.forceMount,...s}=n,r=ng(W0,n.__scopeDialog);return f.jsx(kl,{present:i||r.open,children:r.modal?f.jsx(Mze,{...s,ref:e}):f.jsx(Oze,{...s,ref:e})})});Vxe.displayName=W0;var Mze=x.forwardRef((n,e)=>{const t=ng(W0,n.__scopeDialog),i=x.useRef(null),s=Ui(e,t.contentRef,i);return x.useEffect(()=>{const r=i.current;if(r)return cH(r)},[]),f.jsx(Wxe,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lt(n.onCloseAutoFocus,r=>{var o;r.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Lt(n.onPointerDownOutside,r=>{const o=r.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&r.preventDefault()}),onFocusOutside:Lt(n.onFocusOutside,r=>r.preventDefault())})}),Oze=x.forwardRef((n,e)=>{const t=ng(W0,n.__scopeDialog),i=x.useRef(!1),s=x.useRef(!1);return f.jsx(Wxe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,r),r.defaultPrevented||(i.current||(a=t.triggerRef.current)==null||a.focus(),r.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:r=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,r),r.defaultPrevented||(i.current=!0,r.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=r.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&s.current&&r.preventDefault()}})}),Wxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:r,...o}=n,a=ng(W0,t),l=x.useRef(null),c=Ui(e,l);return aH(),f.jsxs(f.Fragment,{children:[f.jsx(gM,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:r,children:f.jsx(jS,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Wne(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(Fze,{titleId:a.titleId}),f.jsx(Hze,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Vne="DialogTitle",zxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Vne,t);return f.jsx(ui.h2,{id:s.titleId,...i,ref:e})});zxe.displayName=Vne;var Uxe="DialogDescription",$xe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Uxe,t);return f.jsx(ui.p,{id:s.descriptionId,...i,ref:e})});$xe.displayName=Uxe;var Gxe="DialogClose",qxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Gxe,t);return f.jsx(ui.button,{type:"button",...i,ref:e,onClick:Lt(n.onClick,()=>s.onOpenChange(!1))})});qxe.displayName=Gxe;function Wne(n){return n?"open":"closed"}var Kxe="DialogTitleWarning",[Pze,Zxe]=oWe(Kxe,{contentName:W0,titleName:Vne,docsSlug:"dialog"}),Fze=({titleId:n})=>{const e=Zxe(Kxe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
507
|
+
`)},_ze=0,qx=[];function bze(n){var e=x.useRef([]),t=x.useRef([0,0]),i=x.useRef(),s=x.useState(_ze++)[0],r=x.useState(Rxe)[0],o=x.useRef(n);x.useEffect(function(){o.current=n},[n]),x.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(s));var b=HWe([n.lockRef.current],(n.shards||[]).map(ope),!0).filter(Boolean);return b.forEach(function(v){return v.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),b.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(s))})}}},[n.inert,n.lockRef.current,n.shards]);var a=x.useCallback(function(b,v){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!o.current.allowPinchZoom;var C=JP(b),y=t.current,L="deltaX"in b?b.deltaX:y[0]-C[0],E="deltaY"in b?b.deltaY:y[1]-C[1],R,T=b.target,N=Math.abs(L)>Math.abs(E)?"h":"v";if("touches"in b&&N==="h"&&T.type==="range")return!1;var I=window.getSelection(),M=I&&I.anchorNode,P=M?M===T||M.contains(T):!1;if(P)return!1;var H=spe(N,T);if(!H)return!0;if(H?R=N:(R=N==="v"?"h":"v",H=spe(N,T)),!H)return!1;if(!i.current&&"changedTouches"in b&&(L||E)&&(i.current=R),!R)return!0;var j=i.current||R;return gze(j,v,b,j==="h"?L:E)},[]),l=x.useCallback(function(b){var v=b;if(!(!qx.length||qx[qx.length-1]!==r)){var C="deltaY"in v?rpe(v):JP(v),y=e.current.filter(function(R){return R.name===v.type&&(R.target===v.target||v.target===R.shadowParent)&&pze(R.delta,C)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var L=(o.current.shards||[]).map(ope).filter(Boolean).filter(function(R){return R.contains(v.target)}),E=L.length>0?a(v,L[0]):!o.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),c=x.useCallback(function(b,v,C,y){var L={name:b,delta:v,target:C,should:y,shadowParent:vze(C)};e.current.push(L),setTimeout(function(){e.current=e.current.filter(function(E){return E!==L})},1)},[]),d=x.useCallback(function(b){t.current=JP(b),i.current=void 0},[]),u=x.useCallback(function(b){c(b.type,rpe(b),b.target,a(b,n.lockRef.current))},[]),h=x.useCallback(function(b){c(b.type,JP(b),b.target,a(b,n.lockRef.current))},[]);x.useEffect(function(){return qx.push(r),n.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Gx),document.addEventListener("touchmove",l,Gx),document.addEventListener("touchstart",d,Gx),function(){qx=qx.filter(function(b){return b!==r}),document.removeEventListener("wheel",l,Gx),document.removeEventListener("touchmove",l,Gx),document.removeEventListener("touchstart",d,Gx)}},[]);var g=n.removeScrollBar,m=n.inert;return x.createElement(x.Fragment,null,m?x.createElement(r,{styles:mze(s)}):null,g?x.createElement(aze,{noRelative:n.noRelative,gapMode:n.gapMode}):null)}function vze(n){for(var e=null;n!==null;)n instanceof ShadowRoot&&(e=n.host,n=n.host),n=n.parentNode;return e}const Cze=KWe(Dxe,bze);var pM=x.forwardRef(function(n,e){return x.createElement(lH,Gg({},n,{ref:e,sideCar:Cze}))});pM.classNames=lH.classNames;var wze=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},Kx=new WeakMap,e4=new WeakMap,t4={},NU=0,kxe=function(n){return n&&(n.host||kxe(n.parentNode))},yze=function(n,e){return e.map(function(t){if(n.contains(t))return t;var i=kxe(t);return i&&n.contains(i)?i:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},Sze=function(n,e,t,i){var s=yze(e,Array.isArray(n)?n:[n]);t4[t]||(t4[t]=new WeakMap);var r=t4[t],o=[],a=new Set,l=new Set(s),c=function(u){!u||a.has(u)||(a.add(u),c(u.parentNode))};s.forEach(c);var d=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(h){if(a.has(h))d(h);else try{var g=h.getAttribute(i),m=g!==null&&g!=="false",b=(Kx.get(h)||0)+1,v=(r.get(h)||0)+1;Kx.set(h,b),r.set(h,v),o.push(h),b===1&&m&&e4.set(h,!0),v===1&&h.setAttribute(t,"true"),m||h.setAttribute(i,"true")}catch(C){console.error("aria-hidden: cannot operate on ",h,C)}})};return d(e),a.clear(),NU++,function(){o.forEach(function(u){var h=Kx.get(u)-1,g=r.get(u)-1;Kx.set(u,h),r.set(u,g),h||(e4.has(u)||u.removeAttribute(i),e4.delete(u)),g||u.removeAttribute(t)}),NU--,NU||(Kx=new WeakMap,Kx=new WeakMap,e4=new WeakMap,t4={})}},cH=function(n,e,t){t===void 0&&(t="data-aria-hidden");var i=Array.from(Array.isArray(n)?n:[n]),s=wze(n);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),Sze(i,s,t,"aria-hidden")):function(){return null}};function xze(n){const e=Lze(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Dze);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Lze(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Nze(s),a=Rze(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Eze=Symbol("radix.slottable");function Dze(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Eze}function Rze(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Nze(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var dH="Dialog",[Axe,Mxe]=Ha(dH),[Tze,ng]=Axe(dH),Oxe=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:s,onOpenChange:r,modal:o=!0}=n,a=x.useRef(null),l=x.useRef(null),[c,d]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:dH});return f.jsx(Tze,{scope:e,triggerRef:a,contentRef:l,contentId:To(),titleId:To(),descriptionId:To(),open:c,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(u=>!u),[d]),modal:o,children:t})};Oxe.displayName=dH;var Pxe="DialogTrigger",Fxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Pxe,t),r=Ui(e,s.triggerRef);return f.jsx(ui.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Wne(s.open),...i,ref:r,onClick:Lt(n.onClick,s.onOpenToggle)})});Fxe.displayName=Pxe;var Bne="DialogPortal",[Ize,jxe]=Axe(Bne,{forceMount:void 0}),Hxe=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:s}=n,r=ng(Bne,e);return f.jsx(Ize,{scope:e,forceMount:t,children:x.Children.map(i,o=>f.jsx(kl,{present:t||r.open,children:f.jsx(HS,{asChild:!0,container:s,children:o})}))})};Hxe.displayName=Bne;var aF="DialogOverlay",Bxe=x.forwardRef((n,e)=>{const t=jxe(aF,n.__scopeDialog),{forceMount:i=t.forceMount,...s}=n,r=ng(aF,n.__scopeDialog);return r.modal?f.jsx(kl,{present:i||r.open,children:f.jsx(Aze,{...s,ref:e})}):null});Bxe.displayName=aF;var kze=xze("DialogOverlay.RemoveScroll"),Aze=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(aF,t);return f.jsx(pM,{as:kze,allowPinchZoom:!0,shards:[s.contentRef],children:f.jsx(ui.div,{"data-state":Wne(s.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),W0="DialogContent",Vxe=x.forwardRef((n,e)=>{const t=jxe(W0,n.__scopeDialog),{forceMount:i=t.forceMount,...s}=n,r=ng(W0,n.__scopeDialog);return f.jsx(kl,{present:i||r.open,children:r.modal?f.jsx(Mze,{...s,ref:e}):f.jsx(Oze,{...s,ref:e})})});Vxe.displayName=W0;var Mze=x.forwardRef((n,e)=>{const t=ng(W0,n.__scopeDialog),i=x.useRef(null),s=Ui(e,t.contentRef,i);return x.useEffect(()=>{const r=i.current;if(r)return cH(r)},[]),f.jsx(Wxe,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lt(n.onCloseAutoFocus,r=>{var o;r.preventDefault(),(o=t.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Lt(n.onPointerDownOutside,r=>{const o=r.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&r.preventDefault()}),onFocusOutside:Lt(n.onFocusOutside,r=>r.preventDefault())})}),Oze=x.forwardRef((n,e)=>{const t=ng(W0,n.__scopeDialog),i=x.useRef(!1),s=x.useRef(!1);return f.jsx(Wxe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,r),r.defaultPrevented||(i.current||(a=t.triggerRef.current)==null||a.focus(),r.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:r=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,r),r.defaultPrevented||(i.current=!0,r.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=r.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&s.current&&r.preventDefault()}})}),Wxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:r,...o}=n,a=ng(W0,t),l=x.useRef(null),c=Ui(e,l);return aH(),f.jsxs(f.Fragment,{children:[f.jsx(gM,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:r,children:f.jsx(jS,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Wne(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(Fze,{titleId:a.titleId}),f.jsx(Hze,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Vne="DialogTitle",zxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Vne,t);return f.jsx(ui.h2,{id:s.titleId,...i,ref:e})});zxe.displayName=Vne;var Uxe="DialogDescription",$xe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Uxe,t);return f.jsx(ui.p,{id:s.descriptionId,...i,ref:e})});$xe.displayName=Uxe;var Gxe="DialogClose",qxe=x.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,s=ng(Gxe,t);return f.jsx(ui.button,{type:"button",...i,ref:e,onClick:Lt(n.onClick,()=>s.onOpenChange(!1))})});qxe.displayName=Gxe;function Wne(n){return n?"open":"closed"}var Kxe="DialogTitleWarning",[Pze,Zxe]=oWe(Kxe,{contentName:W0,titleName:Vne,docsSlug:"dialog"}),Fze=({titleId:n})=>{const e=Zxe(Kxe),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
|
|
508
508
|
|
|
509
509
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
510
510
|
|
|
@@ -716,7 +716,7 @@ You can add a description to the \`${ME}\` by passing a \`${cRe}\` component as
|
|
|
716
716
|
|
|
717
717
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ME}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
718
718
|
|
|
719
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(e)},[e,n]),null},utt=nRe,htt=sRe,ftt=rRe,gtt=oRe,ptt=uRe,mtt=fRe,_tt=lRe,btt=dRe;function vtt({...n}){return f.jsx(utt,{"data-slot":"alert-dialog",...n})}function Ctt({...n}){return f.jsx(htt,{"data-slot":"alert-dialog-portal",...n})}function wtt({className:n,...e}){return f.jsx(ftt,{"data-slot":"alert-dialog-overlay",className:Le("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n),...e})}function ytt({className:n,...e}){return f.jsxs(Ctt,{children:[f.jsx(wtt,{}),f.jsx(gtt,{"data-slot":"alert-dialog-content",className:Le("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",n),...e})]})}function Stt({className:n,...e}){return f.jsx("div",{"data-slot":"alert-dialog-header",className:Le("flex flex-col gap-2 text-center sm:text-left",n),...e})}function xtt({className:n,...e}){return f.jsx("div",{"data-slot":"alert-dialog-footer",className:Le("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n),...e})}function Ltt({className:n,...e}){return f.jsx(_tt,{"data-slot":"alert-dialog-title",className:Le("text-lg font-semibold",n),...e})}function Ett({className:n,...e}){return f.jsx(btt,{"data-slot":"alert-dialog-description",className:Le("text-muted-foreground text-sm",n),...e})}function Dtt({className:n,...e}){return f.jsx(ptt,{className:Le(Hne(),n),...e})}function Rtt({className:n,...e}){return f.jsx(mtt,{className:Le(Hne({variant:"outline"}),n),...e})}const gRe=["facebook","linkedin","tiktok","microsoft","connector","sql","blank"],pRe={facebook:{title:"Facebook Ads",datamartTitle:"Facebook Ads Data Mart",connectorSourceTitle:"FacebookMarketing",definitionType:Yt.CONNECTOR,icon:XZe},linkedin:{title:"LinkedIn Ads",datamartTitle:"LinkedIn Ads Data Mart",connectorSourceTitle:"LinkedInAds",definitionType:Yt.CONNECTOR,icon:QZe},tiktok:{title:"TikTok Ads",datamartTitle:"TikTok Ads Data Mart",connectorSourceTitle:"TikTokAds",definitionType:Yt.CONNECTOR,icon:JZe},microsoft:{title:"Microsoft Ads",datamartTitle:"Microsoft Ads Data Mart",connectorSourceTitle:"MicrosoftAds",definitionType:Yt.CONNECTOR,icon:eYe},connector:{title:"Other connector",datamartTitle:"Connector-based Data Mart",definitionType:Yt.CONNECTOR,icon:Fne},sql:{title:"SQL query",datamartTitle:"SQL-based Data Mart",definitionType:Yt.SQL,icon:Pne},blank:{title:"Blank Data Mart",datamartTitle:"New Data Mart",icon:sF}},sme=gRe.map(n=>({key:n,...pRe[n]}));function Ntt(n){if(!n||!gRe.includes(n))return;const e=n;return{key:e,...pRe[e]}}function Ttt({children:n,className:e="",...t}){return f.jsx("div",{className:"dm-card",children:f.jsx("div",{className:Le("-m-4 flex flex-col items-start justify-between gap-12 overflow-hidden px-8 py-16 lg:flex-row-reverse lg:px-16 lg:py-24 2xl:items-center",e),...t,children:n})})}function Itt({children:n,className:e="",...t}){return f.jsx("div",{className:Le("pb-2",e),...t,children:n})}function ktt({children:n,className:e="",...t}){return f.jsx("h2",{className:Le("mb-6 text-4xl font-semibold xl:text-5xl",e),...t,children:n})}function Att({children:n,className:e="",...t}){return f.jsx("p",{className:Le("text-muted-foreground text-lg",e),...t,children:n})}function Mtt({children:n,rings:e=7,className:t="",...i}){return f.jsxs("div",{className:Le("relative flex w-full justify-center lg:w-[30%] 2xl:w-[35%]",t),...i,children:[f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Array.from({length:e},(s,r)=>{const o=`${(16*(r+1)+24).toString()}vmin`;return f.jsx("div",{className:"animate-ring-pulse",style:{height:o,width:o,animationDelay:`${(r*.3).toString()}s`,animationDuration:"4s",opacity:.2+r*.1,filter:r===0?"blur(1px)":"none"}},r)})}),f.jsx("div",{className:"animate-glow-burst"}),f.jsx("div",{className:"animate-icon-entrance","aria-label":"Illustration",children:n})]})}function Ott({children:n,className:e="",...t}){return f.jsx("div",{className:Le("w-full space-y-8 lg:w-[70%] 2xl:w-[65%]",e),...t,children:n})}function ZU({separator:n=!0,children:e,className:t="",...i}){return f.jsx("section",{className:Le("relative pb-10",n&&"after:from-border after:absolute after:bottom-0 after:left-0 after:h-px after:w-full after:bg-gradient-to-r after:to-transparent",t),...i,children:e})}function rme({children:n,className:e="",...t}){return f.jsx("h3",{className:Le("mb-4 text-xl font-medium",e),...t,children:n})}function YU({children:n,className:e="",...t}){return f.jsx("div",{className:Le("flex flex-wrap items-center gap-4",e),...t,children:n})}function u4({href:n,icon:e,title:t,variant:i="outline",size:s,className:r="",target:o,...a}){const l=i==="outline"?"lg":"sm",c=f.jsxs("span",{className:Le("flex items-center gap-2"),children:[e,t]});return n?f.jsx(rt,{asChild:!0,variant:i,size:s??l,className:Le(i==="ghost"?"text-muted-foreground":"",r),...a,children:f.jsx(Vc,{to:n,target:o,children:c})}):f.jsx(rt,{variant:i,size:s??l,className:r,...a,children:c})}function Ptt(){const{scope:n}=hb(),e=sme.filter(i=>i.definitionType===Yt.CONNECTOR),t=sme.filter(i=>i.definitionType!==Yt.CONNECTOR);return f.jsxs(Ttt,{children:[f.jsx(Mtt,{children:f.jsx(YZe,{className:"animate-icon-entrance","aria-label":"Data Mart creation illustration"})}),f.jsxs(Ott,{children:[f.jsxs(Itt,{children:[f.jsx(ktt,{children:"Let’s Build Your First Data Mart"}),f.jsx(Att,{children:"A Data Mart is the key element of self-service analytics — it provides both control for data analyst and freedom for business users. To get started, connect the source you need or query the data you already have in storage"})]}),f.jsxs(ZU,{children:[f.jsx(rme,{children:"Connect a data source"}),f.jsx(YU,{children:e.map(i=>f.jsx(u4,{href:n(`/data-marts/create?preset=${i.key}`),icon:i.icon&&f.jsx(i.icon,{className:"h-4 w-4"}),title:i.title,variant:"outline"},i.key))})]}),f.jsxs(ZU,{children:[f.jsx(rme,{children:"Use existing SQL or start from scratch"}),f.jsx(YU,{children:t.map((i,s)=>f.jsxs(f.Fragment,{children:[f.jsx(u4,{href:n(`/data-marts/create?preset=${i.key}`),icon:i.icon&&f.jsx(i.icon,{className:"h-4 w-4"}),title:i.title,variant:"outline"},i.key),s<t.length-1&&f.jsx("span",{className:"text-muted-foreground text-sm",children:"or"})]}))})]}),f.jsx(ZU,{separator:!1,children:f.jsxs(YU,{children:[f.jsx(u4,{href:"https://www.youtube.com/playlist?list=PLvcNVLV5BVbHHCekyAZBEIVnlC4i1qcHx",icon:f.jsx(sxe,{className:"h-4 w-4"}),title:"Watch a 2-minute demo",variant:"ghost",target:"_blank"}),f.jsx(u4,{href:"https://docs.owox.com/docs/getting-started/core-concepts/?utm_source=owox_data_marts&utm_medium=empty_data_marts_page&utm_campaign=help_buttons",icon:f.jsx(uBe,{className:"h-4 w-4"}),title:"Core concepts",variant:"ghost",target:"_blank"})]})})]})]})}function Ftt(){return f.jsx(bl,{className:"bg-muted/50 h-72 w-full rounded-md border-b border-gray-200 dark:border-white/10 dark:bg-white/4"})}const Zx={DEFAULT_SORTING_COLUMN:"createdAt",DEFAULT_EXCLUDED_COLUMNS:["actions"],STORAGE_KEYS:{SORTING_SUFFIX:"-sorting",COLUMN_VISIBILITY_SUFFIX:"-column-visibility"}},jtt={extractColumnIds:n=>n.map(e=>{if(e.id)return e.id;if("accessorKey"in e&&typeof e.accessorKey=="string")return e.accessorKey}).filter(e=>e!==void 0)};function zS({columns:n,storageKeyPrefix:e,defaultSortingColumn:t=Zx.DEFAULT_SORTING_COLUMN,defaultColumnVisibility:i={},excludedColumnsFromSorting:s=Zx.DEFAULT_EXCLUDED_COLUMNS,excludedColumnsFromVisibility:r=Zx.DEFAULT_EXCLUDED_COLUMNS}){const o=x.useMemo(()=>({SORTING:`${e}${Zx.STORAGE_KEYS.SORTING_SUFFIX}`,COLUMN_VISIBILITY:`${e}${Zx.STORAGE_KEYS.COLUMN_VISIBILITY_SUFFIX}`}),[e]),a=x.useMemo(()=>jtt.extractColumnIds(n),[n]),l=x.useMemo(()=>a.filter(b=>!s.includes(b)),[a,s]),c=x.useCallback(()=>{const b=np.get(o.SORTING,"json");return b&&Array.isArray(b)&&b.length>0?b:[{id:l.includes(t)?t:l[0]??Zx.DEFAULT_SORTING_COLUMN,desc:!0}]},[o.SORTING,l,t]),d=x.useCallback(()=>{const b=np.get(o.COLUMN_VISIBILITY,"json");if(b&&typeof b=="object"&&!Array.isArray(b)){const v={};for(const C of a)r.includes(C)||(v[C]=b[C]);return v}return i},[o.COLUMN_VISIBILITY,a,r,i]),[u,h]=x.useState(c),[g,m]=x.useState(d);return x.useEffect(()=>{u.length>0&&l.includes(u[0].id)&&np.set(o.SORTING,u)},[u,l,o.SORTING]),x.useEffect(()=>{const b={};for(const v of a){if(r.includes(v))continue;const C=g[v];typeof C=="boolean"&&(b[v]=C)}np.set(o.COLUMN_VISIBILITY,b)},[g,a,r,o.COLUMN_VISIBILITY]),{sorting:u,setSorting:h,columnVisibility:g,setColumnVisibility:m}}function Htt({columns:n,data:e,deleteDataMart:t,refetchDataMarts:i,isLoading:s}){var T;const{navigate:r,scope:o}=hb(),{sorting:a,setSorting:l,columnVisibility:c,setColumnVisibility:d}=zS({columns:n,storageKeyPrefix:"data-mart-list",defaultColumnVisibility:{triggersCount:!1,reportsCount:!1,createdByUser:!1}}),[u,h]=x.useState([]),[g,m]=x.useState({}),[b,v]=x.useState(!1),[C,y]=x.useState(!1),L=async()=>{try{y(!0);const I=R.getSelectedRowModel().rows.map(M=>M.original.id);for(const M of I)await t(M);Sr.success(`Successfully deleted ${String(I.length)} data mart${I.length!==1?"s":""}`),m({}),await i()}catch(N){console.error("Error deleting data marts:",N),Sr.error("Failed to delete some data marts. Please try again.")}finally{y(!1),v(!1)}},E=Object.keys(g).length>0,R=pC({data:e,columns:[{id:"select",size:40,header:({table:N})=>f.jsx("button",{type:"button",role:"checkbox","aria-checked":N.getIsAllRowsSelected(),"data-state":N.getIsAllRowsSelected()?"checked":"unchecked","aria-label":"Select all rows",className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:N.getToggleAllRowsSelectedHandler(),children:N.getIsAllRowsSelected()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),cell:({row:N})=>f.jsx("button",{type:"button",role:"checkbox","aria-checked":N.getIsSelected(),"data-state":N.getIsSelected()?"checked":"unchecked","aria-label":"Select row",className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:N.getToggleSelectedHandler(),children:N.getIsSelected()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),enableSorting:!1,enableHiding:!1},...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:l,getSortedRowModel:WS(),onColumnFiltersChange:h,getFilteredRowModel:HR(),onColumnVisibilityChange:d,onRowSelectionChange:m,state:{sorting:a,columnFilters:u,columnVisibility:c,rowSelection:g},enableRowSelection:!0});return s?f.jsx("div",{children:f.jsx(Ftt,{})}):e.length?f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsxs("div",{className:"dm-card-toolbar-left",children:[E&&f.jsx(rt,{variant:"destructive",size:"sm",className:"dm-card-toolbar-btn-delete",onClick:()=>{v(!0)},disabled:C,children:f.jsx(Wh,{className:"h-4 w-4"})}),f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(T=R.getColumn("title"))==null?void 0:T.getFilterValue(),onChange:N=>{var I;return(I=R.getColumn("title"))==null?void 0:I.setFilterValue(N.target.value)},className:"dm-card-toolbar-search-input"})]})]}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsx(Vc,{to:o("/data-marts/create"),children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Data Mart"]})})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Data Marts table",children:[f.jsx(_C,{className:"dm-card-table-header",children:R.getHeaderGroups().map(N=>f.jsx(qr,{className:"dm-card-table-header-row",children:N.headers.map(I=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:I.column.id==="select"?{width:40,minWidth:40,maxWidth:40}:I.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(I.getSize())}%`},children:I.isPlaceholder?null:jD(I.column.columnDef.header,I.getContext())},I.id))},N.id))}),f.jsx(bC,{className:"dm-card-table-body",children:R.getRowModel().rows.length?R.getRowModel().rows.map(N=>f.jsx(qr,{"data-state":N.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:I=>{if(I.target instanceof HTMLElement&&(I.target.closest('[role="checkbox"]')||I.target.closest(".actions-cell")||I.target.closest('[role="menuitem"]')||I.target.closest('[data-state="open"]')))return;const M=N.original.id;r(`/data-marts/${M}/data-setup`)},children:N.getVisibleCells().map(I=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${I.column.id==="actions"?"actions-cell":""} ${I.column.id==="createdAt"?"whitespace-nowrap":""}`,style:I.column.id==="select"?{width:40,minWidth:40,maxWidth:40}:I.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(I.column.getSize())}%`},children:jD(I.column.columnDef.cell,I.getContext())},I.id))},N.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{R.previousPage()},disabled:!R.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{R.nextPage()},disabled:!R.getCanNextPage(),children:"Next"})]}),f.jsx(vtt,{open:b,onOpenChange:v,children:f.jsxs(ytt,{children:[f.jsxs(Stt,{children:[f.jsx(Ltt,{children:"Are you sure?"}),f.jsxs(Ett,{children:["You're about to delete ",Object.keys(g).length," selected data mart",Object.keys(g).length!==1?"s":"",". This action cannot be undone."]})]}),f.jsxs(xtt,{children:[f.jsx(Rtt,{disabled:C,children:"Cancel"}),f.jsx(Dtt,{onClick:()=>{L()},disabled:C,className:"bg-destructive hover:bg-destructive/90",children:C?"Deleting...":"Delete"})]})]})})]}):f.jsx(Ptt,{})}function mRe({userProjection:n}){const{fullName:e,email:t,avatar:i}=n,s=e??t??"Unknown User",r=fDe(e,t);return f.jsxs(jH,{children:[f.jsx(HH,{asChild:!0,children:f.jsxs("div",{className:"mx-1 inline-flex min-w-max items-center gap-1 rounded-full bg-neutral-100 py-1 pr-3 pl-1 dark:bg-neutral-900",children:[f.jsx(NK,{avatar:i,initials:r,displayName:s,size:AE.SMALL}),f.jsx("span",{className:"text-muted-foreground inline text-sm leading-tight","aria-label":s,children:s})]})}),f.jsx(BH,{side:"top",align:"start",className:"w-max p-3",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(NK,{avatar:i,initials:r,displayName:s,size:AE.LARGE}),f.jsxs("div",{className:"grid text-left text-sm leading-tight",children:[f.jsx("span",{className:"truncate font-medium",children:e??t??"Unknown User"}),t&&f.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t})]})]})})]})}function Vse({...n}){return f.jsx(uH,{"data-slot":"dialog",...n})}function Btt({...n}){return f.jsx(hH,{"data-slot":"dialog-portal",...n})}function Vtt({className:n,...e}){return f.jsx(fH,{"data-slot":"dialog-overlay",className:Le("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n),...e})}function Wse({className:n,children:e,showCloseButton:t=!0,...i}){return f.jsxs(Btt,{"data-slot":"dialog-portal",children:[f.jsx(Vtt,{}),f.jsxs(gH,{"data-slot":"dialog-content",className:Le("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",n),...i,children:[e,t&&f.jsxs(pH,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[f.jsx(ID,{}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function zse({className:n,...e}){return f.jsx("div",{"data-slot":"dialog-header",className:Le("flex flex-col gap-2 text-center sm:text-left",n),...e})}function Wtt({className:n,...e}){return f.jsx("div",{"data-slot":"dialog-footer",className:Le("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n),...e})}function Use({className:n,...e}){return f.jsx(zne,{"data-slot":"dialog-title",className:Le("text-lg leading-none font-semibold",n),...e})}function $se({className:n,...e}){return f.jsx(Une,{"data-slot":"dialog-description",className:Le("text-muted-foreground text-sm",n),...e})}const ztt=RR("",{variants:{variant:{brand:"bg-primary text-white shadow-xs hover:bg-primary-hover focus-visible:ring-brand-blue-200 dark:focus-visible:ring-brand-blue-400"}}});function OE({className:n,variant:e,...t}){return e==="brand"?f.jsx(rt,{variant:"default",className:Le(ztt({variant:e}),n),...t}):f.jsx(rt,{variant:e,className:n,...t})}const Ma=({open:n,onOpenChange:e,title:t,description:i,confirmLabel:s="Confirm",cancelLabel:r,onConfirm:o,onCancel:a,variant:l="destructive",children:c})=>{const d=()=>{e(!1),a==null||a()};return f.jsx(Vse,{open:n,onOpenChange:e,children:f.jsxs(Wse,{children:[f.jsxs(zse,{children:[f.jsx(Use,{children:t}),f.jsx($se,{children:i})]}),c,f.jsxs(Wtt,{children:[r&&f.jsx(OE,{variant:"secondary",onClick:d,children:r}),f.jsx(OE,{variant:l,onClick:o,children:s})]})]})})},Utt=({row:n,onDeleteSuccess:e})=>{const{scope:t}=hb(),[i,s]=x.useState(!1),[r,o]=x.useState(!1),{deleteDataMart:a,refreshList:l}=GDe(),c=async()=>{try{await a(n.original.id),s(!1),await l(),e==null||e()}catch(d){console.error("Failed to delete data mart:",d)}};return f.jsxs("div",{className:"text-right",children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsx(wn,{children:f.jsxs(Vc,{to:t(`/data-marts/${n.original.id}/data-setup`),className:"flex gap-2 text-left",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]})}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>{s(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]}),f.jsx(Ma,{open:i,onOpenChange:s,title:"Delete Data Mart",description:"Are you sure you want to delete this data mart? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>void c(),variant:"destructive"})]})},ome={types:{[Yt.SQL]:{type:Yt.SQL,displayName:"SQL",icon:Pne},[Yt.TABLE]:{type:Yt.TABLE,displayName:"Table",icon:iVe},[Yt.VIEW]:{type:Yt.VIEW,displayName:"View",icon:gBe},[Yt.TABLE_PATTERN]:{type:Yt.TABLE_PATTERN,displayName:"Pattern",icon:vHe},[Yt.CONNECTOR]:{type:Yt.CONNECTOR,displayName:"Connector",icon:Fne}},getInfo(n){return n?this.types[n]:{type:null,displayName:"—",icon:()=>null}}};var Ur=(n=>(n.TITLE="title",n.DEFINITION_TYPE="definitionType",n.STORAGE_TYPE="storageType",n.STATUS="status",n.TRIGGERS_COUNT="triggersCount",n.REPORTS_COUNT="reportsCount",n.CREATED_AT="createdAt",n.CREATED_BY_USER="createdByUser",n))(Ur||{});const Yb={[Ur.TITLE]:"Title",[Ur.DEFINITION_TYPE]:"Input Source",[Ur.STORAGE_TYPE]:"Storage",[Ur.STATUS]:"Status",[Ur.TRIGGERS_COUNT]:"Triggers",[Ur.REPORTS_COUNT]:"Reports",[Ur.CREATED_AT]:"Created at",[Ur.CREATED_BY_USER]:"Created by"};function La({column:n,children:e,label:t}){const i=n.getIsSorted(),s=x.useCallback(()=>{n.toggleSorting(n.getIsSorted()==="asc")},[n]),r=()=>i==="asc"?"sorted ascending":i==="desc"?"sorted descending":"not sorted",o=()=>i==="asc"?"ascending":i==="desc"?"descending":"none",a=t??(typeof e=="string"?e:"Column");return f.jsxs(rt,{variant:"ghost",onClick:s,className:"group dm-card-table-header-row-btn","aria-label":`${a} - ${r()}. Click to sort.`,"aria-sort":o(),children:[e,f.jsxs("span",{className:"flex h-4 w-4 items-center justify-center","aria-hidden":"true",children:[i==="asc"&&f.jsx(TD,{className:"text-foreground h-4 w-4"}),i==="desc"&&f.jsx(Pp,{className:"text-foreground h-4 w-4"}),!i&&f.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:f.jsx(TD,{className:"text-muted-foreground h-4 w-4"})})]})]})}function BR({table:n,getColumnLabel:e}){return f.jsx("div",{className:"text-right",children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn","aria-label":"Toggle columns",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:n.getAllColumns().filter(t=>t.getCanHide()&&t.id!=="actions").map(t=>{var s;const i=(e==null?void 0:e(t.id,t))??((s=t.columnDef.meta)==null?void 0:s.title)??t.id;return f.jsx(wn,{className:"capitalize",children:f.jsxs("label",{className:"flex items-center space-x-2",children:[f.jsx("button",{type:"button",role:"checkbox","aria-checked":t.getIsVisible(),"data-state":t.getIsVisible()?"checked":"unchecked","aria-label":`Toggle column ${i}`,className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:()=>{t.toggleVisibility(!t.getIsVisible())},children:t.getIsVisible()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),f.jsx("span",{children:i})]})},t.id)})})]})})}const $tt=({onDeleteSuccess:n,connectors:e=[]}={})=>[{accessorKey:Ur.TITLE,size:40,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.TITLE]}),cell:({row:t})=>f.jsx("div",{children:t.getValue("title")})},{accessorFn:t=>{const i=t.definitionType;if(i===Yt.CONNECTOR){const s=t.definition,r=e.find(o=>o.name===s.connector.source.name);return(r==null?void 0:r.displayName)??(r==null?void 0:r.name)??"Unknown"}else{const{displayName:s}=ome.getInfo(i);return s}},id:Ur.DEFINITION_TYPE,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.DEFINITION_TYPE]}),cell:({row:t})=>{const i=t.original.definitionType;switch(i){case Yt.CONNECTOR:{const s=t.original.definition,r=e.find(o=>o.name===s.connector.source.name);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[(r==null?void 0:r.logoBase64)&&f.jsx(VS,{base64:r.logoBase64,size:18}),(r==null?void 0:r.displayName)??"Unknown"]})}default:{const{displayName:s,icon:r}=ome.getInfo(i);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(r,{className:"h-4 w-4"}),s]})}}}},{accessorKey:Ur.STORAGE_TYPE,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.STORAGE_TYPE]}),cell:({row:t})=>{const i=t.getValue("storageType"),s=t.original.storageTitle,{displayName:r,icon:o}=fC.getInfo(i),a=s??r;return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),a]})}},{accessorKey:Ur.CREATED_AT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.CREATED_AT]}),cell:({row:t})=>{const i=t.getValue("createdAt"),s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(i);return f.jsx("div",{className:"text-muted-foreground",children:s})}},{id:Ur.CREATED_BY_USER,size:15,accessorFn:t=>{const i=t.createdByUser;return(i==null?void 0:i.fullName)??(i==null?void 0:i.email)},header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.CREATED_BY_USER]}),cell:({row:t})=>{const i=t.original.createdByUser;return i?f.jsx(mRe,{userProjection:i}):f.jsx("div",{className:"text-muted-foreground",children:"—"})}},{accessorKey:Ur.STATUS,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.STATUS]}),cell:({row:t})=>{const i=t.getValue("status");return f.jsx(kM,{type:KJe(i.code),variant:"ghost",showIcon:!1,children:i.displayName})}},{accessorKey:Ur.TRIGGERS_COUNT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.TRIGGERS_COUNT]}),cell:({row:t})=>{const i=t.getValue("triggersCount")>0?t.getValue("triggersCount"):"—";return f.jsx("div",{className:"text-muted-foreground",children:i})}},{accessorKey:Ur.REPORTS_COUNT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.REPORTS_COUNT]}),cell:({row:t})=>{const i=t.getValue("reportsCount")>0?t.getValue("reportsCount"):"—";return f.jsx("div",{className:"text-muted-foreground",children:i})}},{id:"actions",size:80,header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(Utt,{row:t,onDeleteSuccess:n})}];var Sa=(n=>(n.FETCH_CONNECTORS_START="FETCH_CONNECTORS_START",n.FETCH_CONNECTORS_SUCCESS="FETCH_CONNECTORS_SUCCESS",n.FETCH_CONNECTORS_ERROR="FETCH_CONNECTORS_ERROR",n.FETCH_CONNECTOR_SPECIFICATION_START="FETCH_CONNECTOR_SPECIFICATION_START",n.FETCH_CONNECTOR_SPECIFICATION_SUCCESS="FETCH_CONNECTOR_SPECIFICATION_SUCCESS",n.FETCH_CONNECTOR_SPECIFICATION_ERROR="FETCH_CONNECTOR_SPECIFICATION_ERROR",n.FETCH_CONNECTOR_FIELDS_START="FETCH_CONNECTOR_FIELDS_START",n.FETCH_CONNECTOR_FIELDS_SUCCESS="FETCH_CONNECTOR_FIELDS_SUCCESS",n.FETCH_CONNECTOR_FIELDS_ERROR="FETCH_CONNECTOR_FIELDS_ERROR",n))(Sa||{});const Gtt={connectors:[],connectorSpecification:null,connectorFields:null,loading:!1,loadingSpecification:!1,loadingFields:!1,error:null};function qtt(n,e){switch(e.type){case Sa.FETCH_CONNECTORS_START:return{...n,loading:!0,error:null};case Sa.FETCH_CONNECTORS_SUCCESS:return{...n,connectors:e.payload,loading:!1,error:null};case Sa.FETCH_CONNECTORS_ERROR:return{...n,loading:!1,error:e.payload};case Sa.FETCH_CONNECTOR_SPECIFICATION_START:return{...n,loadingSpecification:!0,error:null};case Sa.FETCH_CONNECTOR_SPECIFICATION_SUCCESS:return{...n,connectorSpecification:e.payload,loadingSpecification:!1,error:null};case Sa.FETCH_CONNECTOR_SPECIFICATION_ERROR:return{...n,loadingSpecification:!1,error:e.payload};case Sa.FETCH_CONNECTOR_FIELDS_START:return{...n,loadingFields:!0,error:null};case Sa.FETCH_CONNECTOR_FIELDS_SUCCESS:return{...n,connectorFields:e.payload,loadingFields:!1,error:null};case Sa.FETCH_CONNECTOR_FIELDS_ERROR:return{...n,loadingFields:!1,error:e.payload};default:return n}}const _Re=x.createContext(void 0);function HD({children:n}){const[e,t]=x.useReducer(qtt,Gtt);return f.jsx(_Re.Provider,{value:{state:e,dispatch:t},children:n})}function Ktt(){const n=x.useContext(_Re);if(!n)throw new Error("useConnectorContext must be used within a ConnectorContextProvider");return n}var mf=(n=>(n.STRING="string",n.NUMBER="number",n.BOOLEAN="boolean",n.OBJECT="object",n.ARRAY="array",n.DATE="date",n))(mf||{});class kI extends hC{constructor(){super("/connectors")}async getAvailableConnectors(){return this.get("/")}async getConnectorSpecification(e){return this.get(`/${e}/specification`)}async getConnectorFields(e){return this.get(`/${e}/fields`)}async exchangeCredentials(e,t){return this.post(`/${e}/oauth/exchange`,t)}async checkOAuthStatus(e,t){return this.get(`/${e}/oauth/status/${t}`)}async getOAuthSettings(e,t){return this.get(`/${e}/oauth/settings?path=${encodeURIComponent(t)}`)}}function bRe(n){return n.map(e=>({name:e.name,displayName:e.title??e.name,description:e.description??"",logoBase64:e.logo,docUrl:e.docUrl})).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function US(){const{state:n,dispatch:e}=Ktt(),t=x.useMemo(()=>bRe(n.connectors),[n.connectors]),i=x.useCallback(async()=>{e({type:Sa.FETCH_CONNECTORS_START});try{const a=await new kI().getAvailableConnectors();e({type:Sa.FETCH_CONNECTORS_SUCCESS,payload:a})}catch(o){const a=o instanceof Error?o.message:"Unknown error";e({type:Sa.FETCH_CONNECTORS_ERROR,payload:a}),Vt({event:"connector_error",category:"Connector",action:"ListError",label:a})}},[e]),s=x.useCallback(async o=>{e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_START});try{const l=await new kI().getConnectorSpecification(o);e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_SUCCESS,payload:l})}catch(a){const l=a instanceof Error?a.message:"Unknown error";e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_ERROR,payload:l}),Vt({event:"connector_error",category:"Connector",action:"SpecificationError",label:o})}},[e]),r=x.useCallback(async o=>{e({type:Sa.FETCH_CONNECTOR_FIELDS_START});try{const l=await new kI().getConnectorFields(o);e({type:Sa.FETCH_CONNECTOR_FIELDS_SUCCESS,payload:l})}catch(a){const l=a instanceof Error?a.message:"Unknown error";e({type:Sa.FETCH_CONNECTOR_FIELDS_ERROR,payload:l}),Vt({event:"connector_error",category:"Connector",action:"FieldsError",label:o})}},[e]);return{connectors:t,connectorSpecification:n.connectorSpecification,connectorFields:n.connectorFields,loading:n.loading,loadingSpecification:n.loadingSpecification,loadingFields:n.loadingFields,error:n.error,fetchAvailableConnectors:i,fetchConnectorSpecification:s,fetchConnectorFields:r}}const Ztt=()=>{const{items:n,loadDataMarts:e,deleteDataMart:t,refreshList:i,loading:s}=GDe(),{connectors:r,fetchAvailableConnectors:o}=US();return x.useEffect(()=>{o()},[o]),x.useEffect(()=>{e()},[e]),f.jsx(Htt,{columns:$tt({connectors:r}),data:n,deleteDataMart:t,refetchDataMarts:i,isLoading:s})};function ame(){return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Data Marts"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(uQe,{children:f.jsx(HD,{children:f.jsx(Ztt,{})})})})]})}const vRe=x.createContext(void 0),pT=n=>{const e=iet(n);return{...n,canPublish:e.length===0,validationErrors:e}};var Mu=(n=>(n.CONNECTED="CONNECTED",n.CONNECTED_WITH_DEFINITION_MISMATCH="CONNECTED_WITH_DEFINITION_MISMATCH",n.DISCONNECTED="DISCONNECTED",n))(Mu||{}),d2=(n=>(n.NULLABLE="NULLABLE",n.REQUIRED="REQUIRED",n.REPEATED="REPEATED",n))(d2||{}),Ho=(n=>(n.INTEGER="INTEGER",n.FLOAT="FLOAT",n.NUMERIC="NUMERIC",n.BIGNUMERIC="BIGNUMERIC",n.STRING="STRING",n.BYTES="BYTES",n.BOOLEAN="BOOLEAN",n.DATE="DATE",n.TIME="TIME",n.DATETIME="DATETIME",n.TIMESTAMP="TIMESTAMP",n.GEOGRAPHY="GEOGRAPHY",n.JSON="JSON",n.RECORD="RECORD",n.STRUCT="STRUCT",n.RANGE="RANGE",n.INTERVAL="INTERVAL",n))(Ho||{}),Gse=(n=>(n.BOOLEAN="BOOLEAN",n.TINYINT="TINYINT",n.SMALLINT="SMALLINT",n.INTEGER="INTEGER",n.BIGINT="BIGINT",n.REAL="REAL",n.FLOAT="FLOAT",n.DOUBLE="DOUBLE",n.DECIMAL="DECIMAL",n.CHAR="CHAR",n.VARCHAR="VARCHAR",n.STRING="STRING",n.BINARY="BINARY",n.VARBINARY="VARBINARY",n.DATE="DATE",n.TIME="TIME",n.TIMESTAMP="TIMESTAMP",n.TIME_WITH_TIME_ZONE="TIME WITH TIME ZONE",n.TIMESTAMP_WITH_TIME_ZONE="TIMESTAMP WITH TIME ZONE",n.INTERVAL_YEAR_TO_MONTH="INTERVAL YEAR TO MONTH",n.INTERVAL_DAY_TO_SECOND="INTERVAL DAY TO SECOND",n.ARRAY="ARRAY",n.MAP="MAP",n.STRUCT="STRUCT",n.ROW="ROW",n.JSON="JSON",n))(Gse||{}),qse=(n=>(n.NUMBER="NUMBER",n.DECIMAL="DECIMAL",n.NUMERIC="NUMERIC",n.INT="INT",n.INTEGER="INTEGER",n.BIGINT="BIGINT",n.SMALLINT="SMALLINT",n.TINYINT="TINYINT",n.BYTEINT="BYTEINT",n.FLOAT="FLOAT",n.FLOAT4="FLOAT4",n.FLOAT8="FLOAT8",n.DOUBLE="DOUBLE",n.DOUBLE_PRECISION="DOUBLE PRECISION",n.REAL="REAL",n.VARCHAR="VARCHAR",n.CHAR="CHAR",n.CHARACTER="CHARACTER",n.STRING="STRING",n.TEXT="TEXT",n.BINARY="BINARY",n.VARBINARY="VARBINARY",n.BOOLEAN="BOOLEAN",n.DATE="DATE",n.DATETIME="DATETIME",n.TIME="TIME",n.TIMESTAMP="TIMESTAMP",n.TIMESTAMP_LTZ="TIMESTAMP_LTZ",n.TIMESTAMP_NTZ="TIMESTAMP_NTZ",n.TIMESTAMP_TZ="TIMESTAMP_TZ",n.VARIANT="VARIANT",n.OBJECT="OBJECT",n.ARRAY="ARRAY",n.GEOGRAPHY="GEOGRAPHY",n.GEOMETRY="GEOMETRY",n))(qse||{});const Ytt=(n,e)=>n!==Yt.CONNECTOR||e===null?!0:e.fields.some(i=>i.status===Mu.CONNECTED),CRe={dataMart:null,isLoading:!1,error:null,runs:[]};function Xtt(n,e){switch(e.type){case"FETCH_DATA_MART_START":case"CREATE_DATA_MART_START":case"UPDATE_DATA_MART_START":case"UPDATE_DATA_MART_TITLE_START":case"UPDATE_DATA_MART_DESCRIPTION_START":case"UPDATE_DATA_MART_DEFINITION_START":case"DELETE_DATA_MART_START":case"PUBLISH_DATA_MART_START":case"RUN_DATA_MART_START":case"ACTUALIZE_DATA_MART_SCHEMA_START":case"UPDATE_DATA_MART_SCHEMA_START":case"FETCH_DATA_MART_RUNS_START":case"LOAD_MORE_DATA_MART_RUNS_START":return{...n,isLoading:!0,error:null};case"CREATE_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null};case"FETCH_DATA_MART_SUCCESS":case"UPDATE_DATA_MART_SUCCESS":case"PUBLISH_DATA_MART_SUCCESS":case"ACTUALIZE_DATA_MART_SCHEMA_SUCCESS":case"UPDATE_DATA_MART_SCHEMA_SUCCESS":return{...n,isLoading:!1,error:null,dataMart:pT(e.payload)};case"UPDATE_DATA_MART_TITLE_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,title:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_DESCRIPTION_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,description:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_STORAGE":return n.dataMart?{...n,dataMart:pT({...n.dataMart,storage:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_DEFINITION_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,definitionType:e.payload.definitionType,definition:e.payload.definition,modifiedAt:new Date})}:n;case"DELETE_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null,dataMart:null};case"RUN_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null};case"FETCH_DATA_MART_RUNS_SUCCESS":return{...n,isLoading:!1,error:null,runs:e.payload};case"LOAD_MORE_DATA_MART_RUNS_SUCCESS":return{...n,isLoading:!1,error:null,runs:[...n.runs,...e.payload]};case"FETCH_DATA_MART_ERROR":case"CREATE_DATA_MART_ERROR":case"UPDATE_DATA_MART_ERROR":case"UPDATE_DATA_MART_TITLE_ERROR":case"UPDATE_DATA_MART_DESCRIPTION_ERROR":case"UPDATE_DATA_MART_DEFINITION_ERROR":case"DELETE_DATA_MART_ERROR":case"PUBLISH_DATA_MART_ERROR":case"RUN_DATA_MART_ERROR":case"ACTUALIZE_DATA_MART_SCHEMA_ERROR":case"UPDATE_DATA_MART_SCHEMA_ERROR":case"FETCH_DATA_MART_RUNS_ERROR":case"LOAD_MORE_DATA_MART_RUNS_ERROR":return{...n,isLoading:!1,error:e.payload};case"RESET":return CRe;default:return n}}function og(){const n=x.useContext(vRe);if(n===void 0)throw new Error("useDataMartContext must be used within a DataMartProvider");return n}class Qtt{mapFromDto(e){const t=e.config,i=e.credentials;let s="";return i&&Object.keys(i).length>0&&(s=JSON.stringify(i,null,2)),{id:e.id,title:e.title,type:lt.GOOGLE_BIGQUERY,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:{serviceAccount:s},config:{projectId:(t==null?void 0:t.projectId)??"",location:(t==null?void 0:t.location)??""}}}mapToUpdateRequest(e){const t={config:{projectId:e.config.projectId,location:e.config.location}};return e.credentials&&(t.credentials={...JSON.parse(e.credentials.serviceAccount)}),t}}class Jtt{mapFromDto(e){const t=e.config,i=e.credentials;return{id:e.id,title:e.title,type:lt.AWS_ATHENA,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:{accessKeyId:(i==null?void 0:i.accessKeyId)??"",secretAccessKey:(i==null?void 0:i.secretAccessKey)??""},config:{region:(t==null?void 0:t.region)??"",outputBucket:(t==null?void 0:t.outputBucket)??""}}}mapToUpdateRequest(e){const t={config:{region:e.config.region,outputBucket:e.config.outputBucket}};return e.credentials&&(t.credentials={accessKeyId:e.credentials.accessKeyId,secretAccessKey:e.credentials.secretAccessKey}),t}}class eit{mapFromDto(e){const t=e.config,i=e.credentials,s=i?i.authMethod==="KEY_PAIR"?{authMethod:Tf.KEY_PAIR,username:i.username??"",privateKey:i.privateKey??"",privateKeyPassphrase:i.privateKeyPassphrase}:{authMethod:Tf.PASSWORD,username:i.username??"",password:i.password??""}:void 0;return{id:e.id,title:e.title,type:lt.SNOWFLAKE,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:s??{authMethod:Tf.PASSWORD,username:"",password:""},config:t?{account:t.account,warehouse:t.warehouse}:{account:"",warehouse:""}}}mapToUpdateRequest(e){const t={config:{account:e.config.account,warehouse:e.config.warehouse}};if(e.credentials){const i=e.credentials;t.credentials={authMethod:i.authMethod,username:i.username,...i.authMethod===Tf.PASSWORD?{password:i.password}:{privateKey:i.privateKey,privateKeyPassphrase:i.privateKeyPassphrase}}}return t}}const wRe={getMapper(n){switch(n){case lt.GOOGLE_BIGQUERY:return new Qtt;case lt.AWS_ATHENA:return new Jtt;case lt.SNOWFLAKE:return new eit;default:throw new Error(`Unknown storage type: ${n}`)}}};function o5(n){return wRe.getMapper(n.type).mapFromDto(n)}function tit(n){const e=wRe.getMapper(n.type);return{title:n.title,...e.mapToUpdateRequest(n)}}function iit(n){return{id:n.id,type:n.type,title:n.title,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt)}}function nit(n){return{type:n}}let h4=null;async function sit(){if(h4)return h4;const n=await rit();return h4=bRe(n),h4}async function rit(){return await new kI().getAvailableConnectors()}async function oit(n){const e=await sit();return e.length===0?null:e.find(i=>i.name===n)??null}function ait(n,e){const t=e.find(i=>i.name===n.source.name);return(t==null?void 0:t.displayName)??n.source.name}function lit(n){return{sqlQuery:n.sqlQuery}}function cit(n){return{sqlQuery:n.sqlQuery}}function dit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function uit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function hit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function fit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function git(n){return{pattern:n.pattern}}function pit(n){return{pattern:n.pattern}}function mit(n){return{connector:{source:{name:n.connector.source.name,configuration:n.connector.source.configuration,node:n.connector.source.node,fields:n.connector.source.fields},storage:{fullyQualifiedName:n.connector.storage.fullyQualifiedName}}}}function _it(n){const e=n.connector;return{connector:{source:{name:e.source.name,configuration:e.source.configuration,node:e.source.node,fields:e.source.fields},storage:{fullyQualifiedName:e.storage.fullyQualifiedName}}}}async function bit(n,e){if(!n||!e)return null;switch(n){case Yt.SQL:return cit(e);case Yt.TABLE:return uit(e);case Yt.VIEW:return fit(e);case Yt.TABLE_PATTERN:return pit(e);case Yt.CONNECTOR:{const t=_it(e);return t.connector.info=await oit(t.connector.source.name),t}default:return console.warn(`Unknown definition type: ${String(n)}`),null}}async function Yx(n){const e={id:n.id,title:n.title,description:n.description,status:vDe.getInfo(n.status),storage:o5(n.storage),definitionType:n.definitionType,definition:await bit(n.definitionType,n.definition),schema:n.schema,connectorState:n.connectorState??null,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt),canPublish:!1,canActualizeSchema:!1,validationErrors:[]};return e.canActualizeSchema=Ytt(e.definitionType,e.schema),e}function vit(n){return{id:n.id,title:n.title}}const Cit=n=>({id:n.id,status:n.status,createdAt:new Date(n.createdAt),logs:n.logs??[],errors:n.errors??[],definitionRun:n.definitionRun,type:n.type,triggerType:n.runType,startedAt:n.startedAt?new Date(n.startedAt):null,finishedAt:n.finishedAt?new Date(n.finishedAt):null,reportDefinition:n.reportDefinition?n.reportDefinition:null,reportId:n.reportId,insightDefinition:n.insightDefinition??null,insightId:n.insightId,createdByUser:n.createdByUser}),lme=n=>n.runs.map(Cit),zH=n=>{if(!n)return"—";let e;if(typeof n=="string"){if(e=new Date(n),isNaN(e.getTime()))return"—"}else if(e=n,isNaN(e.getTime()))return"—";const i=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),s=new Map(i.map(u=>[u.type,u.value])),r=s.get("year")??"",o=s.get("month")??"",a=s.get("day")??"",l=s.get("hour")??"",c=s.get("minute")??"",d=s.get("second")??"";return`${r}-${o}-${a} ${l}:${c}:${d}`},Xx=n=>zH(yRe(n).toISOString()),yRe=n=>{const e=n.trim();if(e.includes("T")||e.includes("Z")){const s=new Date(e);if(!isNaN(s.getTime()))return s}let t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/.exec(e);if(t)return new Date(Date.UTC(parseInt(t[1],10),parseInt(t[2],10)-1,parseInt(t[3],10),parseInt(t[4],10),parseInt(t[5],10),t[6]?parseInt(t[6],10):0));if(t=/^(\d{1,2})[./](\d{1,2})[./](\d{4})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/.exec(e),t)return new Date(Date.UTC(parseInt(t[3],10),parseInt(t[2],10)-1,parseInt(t[1],10),parseInt(t[4],10),parseInt(t[5],10),t[6]?parseInt(t[6],10):0));const i=new Date(e);return isNaN(i.getTime())?(console.warn(`Failed to parse date string: "${n}", using current date as fallback`),new Date):i},wit=(n,e)=>{const t=e.getTime()-n.getTime(),i=Math.floor(t/1e3),s=Math.floor(i/60),r=Math.floor(s/60),o=s%60,a=i%60,l=[];return r>0&&l.push(`${String(r)} h`),o>0&&l.push(`${String(o)} min`),l.push(`${String(a)} sec`),l.join(" ")};function SRe(n){return JSON.parse(JSON.stringify(n))}function yit(n){if(n===0)return"0 Bytes";const e=1024,t=["Bytes","KB","MB","GB","TB"],i=Math.floor(Math.log(n)/Math.log(e));return`${Number.parseFloat((n/Math.pow(e,i)).toFixed(2)).toString()} ${t[i]}`}const xRe=n=>{try{const e=JSON.parse(n),{project_id:t,client_id:i,client_email:s}=e;return!t||!i||!s?null:{url:`https://console.cloud.google.com/iam-admin/serviceaccounts/details/${i}?project=${t}`,email:s}}catch{return null}};function Sit(n){return n&&n.charAt(0).toUpperCase()+n.slice(1)}function xit(n){return!n||typeof n!="object"?!0:n.LICENSED_APP_EDITION==="COMMUNITY"}const Lit=n=>n?n.split(",").map(e=>e.trim()).filter(Boolean):[];function LRe({children:n}){const[e,t]=x.useReducer(Xtt,CRe),i=x.useCallback(async T=>{try{t({type:"FETCH_DATA_MART_START"});const N=await hr.getDataMartById(T),I=await Yx(N);t({type:"FETCH_DATA_MART_SUCCESS",payload:I})}catch(N){t({type:"FETCH_DATA_MART_ERROR",payload:ys(N)})}},[]),s=x.useCallback(async T=>{try{t({type:"CREATE_DATA_MART_START"});const N=await hr.createDataMart(T),I=vit(N);return t({type:"CREATE_DATA_MART_SUCCESS",payload:I}),Vt({event:"data_mart_created",category:"DataMart",action:"Create",label:I.id}),Rn.success("Data Mart created"),I}catch(N){const I=ys(N);throw t({type:"CREATE_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"CreateError",label:I.message}),N}},[]),r=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_START"});const I=await hr.updateDataMart(T,N),M=await Yx(I);t({type:"UPDATE_DATA_MART_SUCCESS",payload:M}),Vt({event:"data_mart_updated",category:"DataMart",action:"Update",label:M.id})}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateError",label:M.message})}},[]),o=x.useCallback(async T=>{try{t({type:"DELETE_DATA_MART_START"}),await hr.deleteDataMart(T),t({type:"DELETE_DATA_MART_SUCCESS"}),Vt({event:"data_mart_deleted",category:"DataMart",action:"Delete",label:T}),Rn.success("Data Mart deleted")}catch(N){const I=ys(N);t({type:"DELETE_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"DeleteError",label:I.message})}},[]),a=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_TITLE_START"}),await hr.updateDataMartTitle(T,N),t({type:"UPDATE_DATA_MART_TITLE_SUCCESS",payload:N}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateTitle",label:N}),Rn.success("Title updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_TITLE_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateTitleError",label:M.message})}},[]),l=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_DESCRIPTION_START"}),await hr.updateDataMartDescription(T,N),t({type:"UPDATE_DATA_MART_DESCRIPTION_SUCCESS",payload:N??""}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateDescription"}),Rn.success("Description updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_DESCRIPTION_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateDescriptionError",label:M.message})}},[]),c=x.useCallback(T=>{t({type:"UPDATE_DATA_MART_STORAGE",payload:T})},[]),d=x.useCallback(async(T,N,I)=>{try{t({type:"UPDATE_DATA_MART_DEFINITION_START"});let M;switch(N){case Yt.SQL:M={definitionType:N,definition:lit(I)};break;case Yt.TABLE:M={definitionType:N,definition:dit(I)};break;case Yt.VIEW:M={definitionType:N,definition:hit(I)};break;case Yt.TABLE_PATTERN:M={definitionType:N,definition:git(I)};break;case Yt.CONNECTOR:{const j=I;let V;for(const W of j.connector.source.configuration){const U=W;if(U._copiedFrom){V=U._copiedFrom.dataMartId;break}}M={definitionType:Yt.CONNECTOR,definition:mit(j),sourceDataMartId:V};break}default:throw new Error(`Unsupported definition type: ${String(N)}`)}const P=await hr.updateDataMartDefinition(T,M),H=await Yx(P);t({type:"UPDATE_DATA_MART_DEFINITION_SUCCESS",payload:{definitionType:N,definition:I}}),t({type:"UPDATE_DATA_MART_SUCCESS",payload:H}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateDefinition",label:N})}catch(M){const P=ys(M);t({type:"UPDATE_DATA_MART_DEFINITION_ERROR",payload:P}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateDefinitionError",label:P.message})}},[]),u=x.useCallback(async T=>{try{t({type:"PUBLISH_DATA_MART_START"});const N=await hr.publishDataMart(T),I=await Yx(N);t({type:"PUBLISH_DATA_MART_SUCCESS",payload:I}),Rn.success("Data Mart published")}catch(N){const I=ys(N);throw t({type:"PUBLISH_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"PublishError",label:I.message}),N}},[]),h=x.useCallback(async(T,N=5,I=0,M)=>{try{M!=null&&M.silent||t({type:"FETCH_DATA_MART_RUNS_START"});const P=await hr.getDataMartRuns(T,N,I,M!=null&&M.silent?{skipLoadingIndicator:!0}:void 0),H=lme(P);return t({type:"FETCH_DATA_MART_RUNS_SUCCESS",payload:H}),H}catch(P){throw t({type:"FETCH_DATA_MART_RUNS_ERROR",payload:ys(P)}),P}},[]),g=x.useCallback(async(T,N,I=5)=>{try{t({type:"LOAD_MORE_DATA_MART_RUNS_START"});const M=await hr.getDataMartRuns(T,I,N),P=lme(M);return t({type:"LOAD_MORE_DATA_MART_RUNS_SUCCESS",payload:P}),P}catch(M){throw t({type:"LOAD_MORE_DATA_MART_RUNS_ERROR",payload:ys(M)}),M}},[]),m=x.useCallback(async T=>{const N=Rn.loading("Manual run started");try{t({type:"RUN_DATA_MART_START"}),await hr.runDataMart(T.id,T.payload),t({type:"RUN_DATA_MART_SUCCESS"})}catch(I){Rn.dismiss(N);const M=ys(I);t({type:"RUN_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"RunError",label:M.message})}},[]),b=x.useCallback(async(T,N)=>{try{await hr.cancelDataMartRun(T,N),await h(T),Rn.success("Data Mart run canceled")}catch(I){const M=ys(I);t({type:"RUN_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"CancelRunError",label:M.message})}},[h]),v=x.useCallback(async(T,N)=>{try{return await hr.getDataMartRunById(T,N)}catch(I){const M=ys(I);throw Vt({event:"data_mart_error",category:"DataMart",action:"FetchRunDetailsError",label:M.message}),I}},[]),C=x.useCallback(async T=>{try{t({type:"ACTUALIZE_DATA_MART_SCHEMA_START"});const N=await hr.actualizeDataMartSchema(T),I=await Yx(N);t({type:"ACTUALIZE_DATA_MART_SCHEMA_SUCCESS",payload:I}),Rn.success("Output schema actualized")}catch(N){const I=ys(N);t({type:"ACTUALIZE_DATA_MART_SCHEMA_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"ActualizeSchemaError",label:I.message})}},[]),y=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_SCHEMA_START"});const I=await hr.updateDataMartSchema(T,{schema:N}),M=await Yx(I);t({type:"UPDATE_DATA_MART_SCHEMA_SUCCESS",payload:M}),Rn.success("Output schema updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_SCHEMA_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateSchemaError",label:M.message})}},[]),L=x.useCallback(()=>{t({type:"RESET"})},[]),E=x.useCallback(()=>e.error?e.error.message:null,[e.error]),R={...e,getDataMart:i,createDataMart:s,updateDataMart:r,deleteDataMart:o,updateDataMartTitle:a,updateDataMartDescription:l,updateDataMartStorage:c,updateDataMartDefinition:d,publishDataMart:u,runDataMart:m,cancelDataMartRun:b,actualizeDataMartSchema:C,updateDataMartSchema:y,getDataMartRuns:h,getDataMartRunById:v,loadMoreDataMartRuns:g,getErrorMessage:E,reset:L};return f.jsx(vRe.Provider,{value:R,children:n})}var PM=n=>n.type==="checkbox",oy=n=>n instanceof Date,yd=n=>n==null;const ERe=n=>typeof n=="object";var ha=n=>!yd(n)&&!Array.isArray(n)&&ERe(n)&&!oy(n),DRe=n=>ha(n)&&n.target?PM(n.target)?n.target.checked:n.target.value:n,Eit=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,RRe=(n,e)=>n.has(Eit(e)),Dit=n=>{const e=n.constructor&&n.constructor.prototype;return ha(e)&&e.hasOwnProperty("isPrototypeOf")},Kse=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function wa(n){let e;const t=Array.isArray(n),i=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)e=new Date(n);else if(!(Kse&&(n instanceof Blob||i))&&(t||ha(n)))if(e=t?[]:Object.create(Object.getPrototypeOf(n)),!t&&!Dit(n))e=n;else for(const s in n)n.hasOwnProperty(s)&&(e[s]=wa(n[s]));else return n;return e}var UH=n=>/^\w*$/.test(n),Lo=n=>n===void 0,Zse=n=>Array.isArray(n)?n.filter(Boolean):[],Yse=n=>Zse(n.replace(/["|']|\]/g,"").split(/\.|\[/)),Mt=(n,e,t)=>{if(!e||!ha(n))return t;const i=(UH(e)?[e]:Yse(e)).reduce((s,r)=>yd(s)?s:s[r],n);return Lo(i)||i===n?Lo(n[e])?t:n[e]:i},mu=n=>typeof n=="boolean",Js=(n,e,t)=>{let i=-1;const s=UH(e)?[e]:Yse(e),r=s.length,o=r-1;for(;++i<r;){const a=s[i];let l=t;if(i!==o){const c=n[a];l=ha(c)||Array.isArray(c)?c:isNaN(+s[i+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;n[a]=l,n=n[a]}};const kF={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},xf={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},pm={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Xse=nt.createContext(null);Xse.displayName="HookFormContext";const VR=()=>nt.useContext(Xse),NRe=n=>{const{children:e,...t}=n;return nt.createElement(Xse.Provider,{value:t},e)};var TRe=(n,e,t,i=!0)=>{const s={defaultValues:e._defaultValues};for(const r in n)Object.defineProperty(s,r,{get:()=>{const o=r;return e._proxyFormState[o]!==xf.all&&(e._proxyFormState[o]=!i||xf.all),t&&(t[o]=!0),n[o]}});return s};const Qse=typeof window<"u"?nt.useLayoutEffect:nt.useEffect;function IRe(n){const e=VR(),{control:t=e.control,disabled:i,name:s,exact:r}=n||{},[o,a]=nt.useState(t._formState),l=nt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Qse(()=>t._subscribe({name:s,formState:l.current,exact:r,callback:c=>{!i&&a({...t._formState,...c})}}),[s,i,r]),nt.useEffect(()=>{l.current.isValid&&t._setValid(!0)},[t]),nt.useMemo(()=>TRe(o,t,l.current,!1),[o,t])}var Su=n=>typeof n=="string",OK=(n,e,t,i,s)=>Su(n)?(i&&e.watch.add(n),Mt(t,n,s)):Array.isArray(n)?n.map(r=>(i&&e.watch.add(r),Mt(t,r))):(i&&(e.watchAll=!0),t),PK=n=>yd(n)||!ERe(n);function Lf(n,e,t=new WeakSet){if(PK(n)||PK(e))return Object.is(n,e);if(oy(n)&&oy(e))return n.getTime()===e.getTime();const i=Object.keys(n),s=Object.keys(e);if(i.length!==s.length)return!1;if(t.has(n)||t.has(e))return!0;t.add(n),t.add(e);for(const r of i){const o=n[r];if(!s.includes(r))return!1;if(r!=="ref"){const a=e[r];if(oy(o)&&oy(a)||ha(o)&&ha(a)||Array.isArray(o)&&Array.isArray(a)?!Lf(o,a,t):!Object.is(o,a))return!1}}return!0}function Rit(n){const e=VR(),{control:t=e.control,name:i,defaultValue:s,disabled:r,exact:o,compute:a}=n||{},l=nt.useRef(s),c=nt.useRef(a),d=nt.useRef(void 0),u=nt.useRef(t),h=nt.useRef(i);c.current=a;const[g,m]=nt.useState(()=>{const E=t._getWatch(i,l.current);return c.current?c.current(E):E}),b=nt.useCallback(E=>{const R=OK(i,t._names,E||t._formValues,!1,l.current);return c.current?c.current(R):R},[t._formValues,t._names,i]),v=nt.useCallback(E=>{if(!r){const R=OK(i,t._names,E||t._formValues,!1,l.current);if(c.current){const T=c.current(R);Lf(T,d.current)||(m(T),d.current=T)}else m(R)}},[t._formValues,t._names,r,i]);Qse(()=>((u.current!==t||!Lf(h.current,i))&&(u.current=t,h.current=i,v()),t._subscribe({name:i,formState:{values:!0},exact:o,callback:E=>{v(E.values)}})),[t,o,i,v]),nt.useEffect(()=>t._removeUnmounted());const C=u.current!==t,y=h.current,L=nt.useMemo(()=>{if(r)return null;const E=!C&&!Lf(y,i);return C||E?b():null},[r,C,i,y,b]);return L!==null?L:g}function Nit(n){const e=VR(),{name:t,disabled:i,control:s=e.control,shouldUnregister:r,defaultValue:o}=n,a=RRe(s._names.array,t),l=nt.useMemo(()=>Mt(s._formValues,t,Mt(s._defaultValues,t,o)),[s,t,o]),c=Rit({control:s,name:t,defaultValue:l,exact:!0}),d=IRe({control:s,name:t,exact:!0}),u=nt.useRef(n),h=nt.useRef(void 0),g=nt.useRef(s.register(t,{...n.rules,value:c,...mu(n.disabled)?{disabled:n.disabled}:{}}));u.current=n;const m=nt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Mt(d.errors,t)},isDirty:{enumerable:!0,get:()=>!!Mt(d.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!Mt(d.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!Mt(d.validatingFields,t)},error:{enumerable:!0,get:()=>Mt(d.errors,t)}}),[d,t]),b=nt.useCallback(L=>g.current.onChange({target:{value:DRe(L),name:t},type:kF.CHANGE}),[t]),v=nt.useCallback(()=>g.current.onBlur({target:{value:Mt(s._formValues,t),name:t},type:kF.BLUR}),[t,s._formValues]),C=nt.useCallback(L=>{const E=Mt(s._fields,t);E&&L&&(E._f.ref={focus:()=>L.focus&&L.focus(),select:()=>L.select&&L.select(),setCustomValidity:R=>L.setCustomValidity(R),reportValidity:()=>L.reportValidity()})},[s._fields,t]),y=nt.useMemo(()=>({name:t,value:c,...mu(i)||d.disabled?{disabled:d.disabled||i}:{},onChange:b,onBlur:v,ref:C}),[t,i,d.disabled,b,v,C,c]);return nt.useEffect(()=>{const L=s._options.shouldUnregister||r,E=h.current;E&&E!==t&&!a&&s.unregister(E),s.register(t,{...u.current.rules,...mu(u.current.disabled)?{disabled:u.current.disabled}:{}});const R=(T,N)=>{const I=Mt(s._fields,T);I&&I._f&&(I._f.mount=N)};if(R(t,!0),L){const T=wa(Mt(s._options.defaultValues,t,u.current.defaultValue));Js(s._defaultValues,t,T),Lo(Mt(s._formValues,t))&&Js(s._formValues,t,T)}return!a&&s.register(t),h.current=t,()=>{(a?L&&!s._state.action:L)?s.unregister(t):R(t,!1)}},[t,s,a,r]),nt.useEffect(()=>{s._setDisabledField({disabled:i,name:t})},[i,t,s]),nt.useMemo(()=>({field:y,formState:d,fieldState:m}),[y,d,m])}const Tit=n=>n.render(Nit(n));var Jse=(n,e,t,i,s)=>e?{...t[n],types:{...t[n]&&t[n].types?t[n].types:{},[i]:s||!0}}:{},AI=n=>Array.isArray(n)?n:[n],cme=()=>{let n=[];return{get observers(){return n},next:s=>{for(const r of n)r.next&&r.next(s)},subscribe:s=>(n.push(s),{unsubscribe:()=>{n=n.filter(r=>r!==s)}}),unsubscribe:()=>{n=[]}}};function kRe(n,e){const t={};for(const i in n)if(n.hasOwnProperty(i)){const s=n[i],r=e[i];if(s&&ha(s)&&r){const o=kRe(s,r);ha(o)&&(t[i]=o)}else n[i]&&(t[i]=r)}return t}var Sc=n=>ha(n)&&!Object.keys(n).length,ere=n=>n.type==="file",Ef=n=>typeof n=="function",AF=n=>{if(!Kse)return!1;const e=n?n.ownerDocument:0;return n instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ARe=n=>n.type==="select-multiple",tre=n=>n.type==="radio",Iit=n=>tre(n)||PM(n),XU=n=>AF(n)&&n.isConnected;function kit(n,e){const t=e.slice(0,-1).length;let i=0;for(;i<t;)n=Lo(n)?i++:n[e[i++]];return n}function Ait(n){for(const e in n)if(n.hasOwnProperty(e)&&!Lo(n[e]))return!1;return!0}function Jo(n,e){const t=Array.isArray(e)?e:UH(e)?[e]:Yse(e),i=t.length===1?n:kit(n,t),s=t.length-1,r=t[s];return i&&delete i[r],s!==0&&(ha(i)&&Sc(i)||Array.isArray(i)&&Ait(i))&&Jo(n,t.slice(0,-1)),n}var Mit=n=>{for(const e in n)if(Ef(n[e]))return!0;return!1};function MRe(n){return Array.isArray(n)||ha(n)&&!Mit(n)}function FK(n,e={}){for(const t in n){const i=n[t];MRe(i)?(e[t]=Array.isArray(i)?[]:{},FK(i,e[t])):Lo(i)||(e[t]=!0)}return e}function NL(n,e,t){t||(t=FK(e));for(const i in n){const s=n[i];if(MRe(s))Lo(e)||PK(t[i])?t[i]=FK(s,Array.isArray(s)?[]:{}):NL(s,yd(e)?{}:e[i],t[i]);else{const r=e[i];t[i]=!Lf(s,r)}}return t}const dme={value:!1,isValid:!1},ume={value:!0,isValid:!0};var ORe=n=>{if(Array.isArray(n)){if(n.length>1){const e=n.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:e,isValid:!!e.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!Lo(n[0].attributes.value)?Lo(n[0].value)||n[0].value===""?ume:{value:n[0].value,isValid:!0}:ume:dme}return dme},PRe=(n,{valueAsNumber:e,valueAsDate:t,setValueAs:i})=>Lo(n)?n:e?n===""?NaN:n&&+n:t&&Su(n)?new Date(n):i?i(n):n;const hme={isValid:!1,value:null};var FRe=n=>Array.isArray(n)?n.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,hme):hme;function fme(n){const e=n.ref;return ere(e)?e.files:tre(e)?FRe(n.refs).value:ARe(e)?[...e.selectedOptions].map(({value:t})=>t):PM(e)?ORe(n.refs).value:PRe(Lo(e.value)?n.ref.value:e.value,n)}var Oit=(n,e,t,i)=>{const s={};for(const r of n){const o=Mt(e,r);o&&Js(s,r,o._f)}return{criteriaMode:t,names:[...n],fields:s,shouldUseNativeValidation:i}},MF=n=>n instanceof RegExp,mT=n=>Lo(n)?n:MF(n)?n.source:ha(n)?MF(n.value)?n.value.source:n.value:n,gme=n=>({isOnSubmit:!n||n===xf.onSubmit,isOnBlur:n===xf.onBlur,isOnChange:n===xf.onChange,isOnAll:n===xf.all,isOnTouch:n===xf.onTouched});const pme="AsyncFunction";var Pit=n=>!!n&&!!n.validate&&!!(Ef(n.validate)&&n.validate.constructor.name===pme||ha(n.validate)&&Object.values(n.validate).find(e=>e.constructor.name===pme)),Fit=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),mme=(n,e,t)=>!t&&(e.watchAll||e.watch.has(n)||[...e.watch].some(i=>n.startsWith(i)&&/^\.\w+/.test(n.slice(i.length))));const MI=(n,e,t,i)=>{for(const s of t||Object.keys(n)){const r=Mt(n,s);if(r){const{_f:o,...a}=r;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!i)return!0;if(o.ref&&e(o.ref,o.name)&&!i)return!0;if(MI(a,e))break}else if(ha(a)&&MI(a,e))break}}};function _me(n,e,t){const i=Mt(n,t);if(i||UH(t))return{error:i,name:t};const s=t.split(".");for(;s.length;){const r=s.join("."),o=Mt(e,r),a=Mt(n,r);if(o&&!Array.isArray(o)&&t!==r)return{name:t};if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};s.pop()}return{name:t}}var jit=(n,e,t,i)=>{t(n);const{name:s,...r}=n;return Sc(r)||Object.keys(r).length>=Object.keys(e).length||Object.keys(r).find(o=>e[o]===(!i||xf.all))},Hit=(n,e,t)=>!n||!e||n===e||AI(n).some(i=>i&&(t?i===e:i.startsWith(e)||e.startsWith(i))),Bit=(n,e,t,i,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(e||n):(t?i.isOnBlur:s.isOnBlur)?!n:(t?i.isOnChange:s.isOnChange)?n:!0,Vit=(n,e)=>!Zse(Mt(n,e)).length&&Jo(n,e),Wit=(n,e,t)=>{const i=AI(Mt(n,t));return Js(i,"root",e[t]),Js(n,t,i),n};function bme(n,e,t="validate"){if(Su(n)||Array.isArray(n)&&n.every(Su)||mu(n)&&!n)return{type:t,message:Su(n)?n:"",ref:e}}var Qx=n=>ha(n)&&!MF(n)?n:{value:n,message:""},vme=async(n,e,t,i,s,r)=>{const{ref:o,refs:a,required:l,maxLength:c,minLength:d,min:u,max:h,pattern:g,validate:m,name:b,valueAsNumber:v,mount:C}=n._f,y=Mt(t,b);if(!C||e.has(b))return{};const L=a?a[0]:o,E=j=>{s&&L.reportValidity&&(L.setCustomValidity(mu(j)?"":j||""),L.reportValidity())},R={},T=tre(o),N=PM(o),I=T||N,M=(v||ere(o))&&Lo(o.value)&&Lo(y)||AF(o)&&o.value===""||y===""||Array.isArray(y)&&!y.length,P=Jse.bind(null,b,i,R),H=(j,V,W,U=pm.maxLength,B=pm.minLength)=>{const K=j?V:W;R[b]={type:j?U:B,message:K,ref:o,...P(j?U:B,K)}};if(r?!Array.isArray(y)||!y.length:l&&(!I&&(M||yd(y))||mu(y)&&!y||N&&!ORe(a).isValid||T&&!FRe(a).isValid)){const{value:j,message:V}=Su(l)?{value:!!l,message:l}:Qx(l);if(j&&(R[b]={type:pm.required,message:V,ref:L,...P(pm.required,V)},!i))return E(V),R}if(!M&&(!yd(u)||!yd(h))){let j,V;const W=Qx(h),U=Qx(u);if(!yd(y)&&!isNaN(y)){const B=o.valueAsNumber||y&&+y;yd(W.value)||(j=B>W.value),yd(U.value)||(V=B<U.value)}else{const B=o.valueAsDate||new Date(y),K=fe=>new Date(new Date().toDateString()+" "+fe),X=o.type=="time",ne=o.type=="week";Su(W.value)&&y&&(j=X?K(y)>K(W.value):ne?y>W.value:B>new Date(W.value)),Su(U.value)&&y&&(V=X?K(y)<K(U.value):ne?y<U.value:B<new Date(U.value))}if((j||V)&&(H(!!j,W.message,U.message,pm.max,pm.min),!i))return E(R[b].message),R}if((c||d)&&!M&&(Su(y)||r&&Array.isArray(y))){const j=Qx(c),V=Qx(d),W=!yd(j.value)&&y.length>+j.value,U=!yd(V.value)&&y.length<+V.value;if((W||U)&&(H(W,j.message,V.message),!i))return E(R[b].message),R}if(g&&!M&&Su(y)){const{value:j,message:V}=Qx(g);if(MF(j)&&!y.match(j)&&(R[b]={type:pm.pattern,message:V,ref:o,...P(pm.pattern,V)},!i))return E(V),R}if(m){if(Ef(m)){const j=await m(y,t),V=bme(j,L);if(V&&(R[b]={...V,...P(pm.validate,V.message)},!i))return E(V.message),R}else if(ha(m)){let j={};for(const V in m){if(!Sc(j)&&!i)break;const W=bme(await m[V](y,t),L,V);W&&(j={...W,...P(V,W.message)},E(W.message),i&&(R[b]=j))}if(!Sc(j)&&(R[b]={ref:L,...j},!i))return R}}return E(!0),R};const zit={mode:xf.onSubmit,reValidateMode:xf.onChange,shouldFocusError:!0};function Uit(n={}){let e={...zit,...n},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ef(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},i={},s=ha(e.defaultValues)||ha(e.values)?wa(e.defaultValues||e.values)||{}:{},r=e.shouldUnregister?{}:wa(s),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let u={...d};const h={array:cme(),state:cme()},g=e.criteriaMode===xf.all,m=oe=>Ce=>{clearTimeout(c),c=setTimeout(oe,Ce)},b=async oe=>{if(!e.disabled&&(d.isValid||u.isValid||oe)){const Ce=e.resolver?Sc((await N()).errors):await M(i,!0);Ce!==t.isValid&&h.state.next({isValid:Ce})}},v=(oe,Ce)=>{!e.disabled&&(d.isValidating||d.validatingFields||u.isValidating||u.validatingFields)&&((oe||Array.from(a.mount)).forEach(je=>{je&&(Ce?Js(t.validatingFields,je,Ce):Jo(t.validatingFields,je))}),h.state.next({validatingFields:t.validatingFields,isValidating:!Sc(t.validatingFields)}))},C=(oe,Ce=[],je,bt,tt=!0,ct=!0)=>{if(bt&&je&&!e.disabled){if(o.action=!0,ct&&Array.isArray(Mt(i,oe))){const $t=je(Mt(i,oe),bt.argA,bt.argB);tt&&Js(i,oe,$t)}if(ct&&Array.isArray(Mt(t.errors,oe))){const $t=je(Mt(t.errors,oe),bt.argA,bt.argB);tt&&Js(t.errors,oe,$t),Vit(t.errors,oe)}if((d.touchedFields||u.touchedFields)&&ct&&Array.isArray(Mt(t.touchedFields,oe))){const $t=je(Mt(t.touchedFields,oe),bt.argA,bt.argB);tt&&Js(t.touchedFields,oe,$t)}(d.dirtyFields||u.dirtyFields)&&(t.dirtyFields=NL(s,r)),h.state.next({name:oe,isDirty:H(oe,Ce),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else Js(r,oe,Ce)},y=(oe,Ce)=>{Js(t.errors,oe,Ce),h.state.next({errors:t.errors})},L=oe=>{t.errors=oe,h.state.next({errors:t.errors,isValid:!1})},E=(oe,Ce,je,bt)=>{const tt=Mt(i,oe);if(tt){const ct=Mt(r,oe,Lo(je)?Mt(s,oe):je);Lo(ct)||bt&&bt.defaultChecked||Ce?Js(r,oe,Ce?ct:fme(tt._f)):W(oe,ct),o.mount&&!o.action&&b()}},R=(oe,Ce,je,bt,tt)=>{let ct=!1,$t=!1;const yi={name:oe};if(!e.disabled){if(!je||bt){(d.isDirty||u.isDirty)&&($t=t.isDirty,t.isDirty=yi.isDirty=H(),ct=$t!==yi.isDirty);const xi=Lf(Mt(s,oe),Ce);$t=!!Mt(t.dirtyFields,oe),xi?Jo(t.dirtyFields,oe):Js(t.dirtyFields,oe,!0),yi.dirtyFields=t.dirtyFields,ct=ct||(d.dirtyFields||u.dirtyFields)&&$t!==!xi}if(je){const xi=Mt(t.touchedFields,oe);xi||(Js(t.touchedFields,oe,je),yi.touchedFields=t.touchedFields,ct=ct||(d.touchedFields||u.touchedFields)&&xi!==je)}ct&&tt&&h.state.next(yi)}return ct?yi:{}},T=(oe,Ce,je,bt)=>{const tt=Mt(t.errors,oe),ct=(d.isValid||u.isValid)&&mu(Ce)&&t.isValid!==Ce;if(e.delayError&&je?(l=m(()=>y(oe,je)),l(e.delayError)):(clearTimeout(c),l=null,je?Js(t.errors,oe,je):Jo(t.errors,oe)),(je?!Lf(tt,je):tt)||!Sc(bt)||ct){const $t={...bt,...ct&&mu(Ce)?{isValid:Ce}:{},errors:t.errors,name:oe};t={...t,...$t},h.state.next($t)}},N=async oe=>{v(oe,!0);const Ce=await e.resolver(r,e.context,Oit(oe||a.mount,i,e.criteriaMode,e.shouldUseNativeValidation));return v(oe),Ce},I=async oe=>{const{errors:Ce}=await N(oe);if(oe)for(const je of oe){const bt=Mt(Ce,je);bt?Js(t.errors,je,bt):Jo(t.errors,je)}else t.errors=Ce;return Ce},M=async(oe,Ce,je={valid:!0})=>{for(const bt in oe){const tt=oe[bt];if(tt){const{_f:ct,...$t}=tt;if(ct){const yi=a.array.has(ct.name),xi=tt._f&&Pit(tt._f);xi&&d.validatingFields&&v([ct.name],!0);const Nr=await vme(tt,a.disabled,r,g,e.shouldUseNativeValidation&&!Ce,yi);if(xi&&d.validatingFields&&v([ct.name]),Nr[ct.name]&&(je.valid=!1,Ce))break;!Ce&&(Mt(Nr,ct.name)?yi?Wit(t.errors,Nr,ct.name):Js(t.errors,ct.name,Nr[ct.name]):Jo(t.errors,ct.name))}!Sc($t)&&await M($t,Ce,je)}}return je.valid},P=()=>{for(const oe of a.unMount){const Ce=Mt(i,oe);Ce&&(Ce._f.refs?Ce._f.refs.every(je=>!XU(je)):!XU(Ce._f.ref))&&ue(oe)}a.unMount=new Set},H=(oe,Ce)=>!e.disabled&&(oe&&Ce&&Js(r,oe,Ce),!Lf(fe(),s)),j=(oe,Ce,je)=>OK(oe,a,{...o.mount?r:Lo(Ce)?s:Su(oe)?{[oe]:Ce}:Ce},je,Ce),V=oe=>Zse(Mt(o.mount?r:s,oe,e.shouldUnregister?Mt(s,oe,[]):[])),W=(oe,Ce,je={})=>{const bt=Mt(i,oe);let tt=Ce;if(bt){const ct=bt._f;ct&&(!ct.disabled&&Js(r,oe,PRe(Ce,ct)),tt=AF(ct.ref)&&yd(Ce)?"":Ce,ARe(ct.ref)?[...ct.ref.options].forEach($t=>$t.selected=tt.includes($t.value)):ct.refs?PM(ct.ref)?ct.refs.forEach($t=>{(!$t.defaultChecked||!$t.disabled)&&(Array.isArray(tt)?$t.checked=!!tt.find(yi=>yi===$t.value):$t.checked=tt===$t.value||!!tt)}):ct.refs.forEach($t=>$t.checked=$t.value===tt):ere(ct.ref)?ct.ref.value="":(ct.ref.value=tt,ct.ref.type||h.state.next({name:oe,values:wa(r)})))}(je.shouldDirty||je.shouldTouch)&&R(oe,tt,je.shouldTouch,je.shouldDirty,!0),je.shouldValidate&&ne(oe)},U=(oe,Ce,je)=>{for(const bt in Ce){if(!Ce.hasOwnProperty(bt))return;const tt=Ce[bt],ct=oe+"."+bt,$t=Mt(i,ct);(a.array.has(oe)||ha(tt)||$t&&!$t._f)&&!oy(tt)?U(ct,tt,je):W(ct,tt,je)}},B=(oe,Ce,je={})=>{const bt=Mt(i,oe),tt=a.array.has(oe),ct=wa(Ce);Js(r,oe,ct),tt?(h.array.next({name:oe,values:wa(r)}),(d.isDirty||d.dirtyFields||u.isDirty||u.dirtyFields)&&je.shouldDirty&&h.state.next({name:oe,dirtyFields:NL(s,r),isDirty:H(oe,ct)})):bt&&!bt._f&&!yd(ct)?U(oe,ct,je):W(oe,ct,je),mme(oe,a)&&h.state.next({...t,name:oe}),h.state.next({name:o.mount?oe:void 0,values:wa(r)})},K=async oe=>{o.mount=!0;const Ce=oe.target;let je=Ce.name,bt=!0;const tt=Mt(i,je),ct=xi=>{bt=Number.isNaN(xi)||oy(xi)&&isNaN(xi.getTime())||Lf(xi,Mt(r,je,xi))},$t=gme(e.mode),yi=gme(e.reValidateMode);if(tt){let xi,Nr;const Wl=Ce.type?fme(tt._f):DRe(oe),Tr=oe.type===kF.BLUR||oe.type===kF.FOCUS_OUT,Qd=!Fit(tt._f)&&!e.resolver&&!Mt(t.errors,je)&&!tt._f.deps||Bit(Tr,Mt(t.touchedFields,je),t.isSubmitted,yi,$t),Ir=mme(je,a,Tr);Js(r,je,Wl),Tr?(!Ce||!Ce.readOnly)&&(tt._f.onBlur&&tt._f.onBlur(oe),l&&l(0)):tt._f.onChange&&tt._f.onChange(oe);const vs=R(je,Wl,Tr),Kr=!Sc(vs)||Ir;if(!Tr&&h.state.next({name:je,type:oe.type,values:wa(r)}),Qd)return(d.isValid||u.isValid)&&(e.mode==="onBlur"?Tr&&b():Tr||b()),Kr&&h.state.next({name:je,...Ir?{}:vs});if(!Tr&&Ir&&h.state.next({...t}),e.resolver){const{errors:kr}=await N([je]);if(ct(Wl),bt){const Kh=_me(t.errors,i,je),th=_me(kr,i,Kh.name||je);xi=th.error,je=th.name,Nr=Sc(kr)}}else v([je],!0),xi=(await vme(tt,a.disabled,r,g,e.shouldUseNativeValidation))[je],v([je]),ct(Wl),bt&&(xi?Nr=!1:(d.isValid||u.isValid)&&(Nr=await M(i,!0)));bt&&(tt._f.deps&&(!Array.isArray(tt._f.deps)||tt._f.deps.length>0)&&ne(tt._f.deps),T(je,Nr,xi,vs))}},X=(oe,Ce)=>{if(Mt(t.errors,Ce)&&oe.focus)return oe.focus(),1},ne=async(oe,Ce={})=>{let je,bt;const tt=AI(oe);if(e.resolver){const ct=await I(Lo(oe)?oe:tt);je=Sc(ct),bt=oe?!tt.some($t=>Mt(ct,$t)):je}else oe?(bt=(await Promise.all(tt.map(async ct=>{const $t=Mt(i,ct);return await M($t&&$t._f?{[ct]:$t}:$t)}))).every(Boolean),!(!bt&&!t.isValid)&&b()):bt=je=await M(i);return h.state.next({...!Su(oe)||(d.isValid||u.isValid)&&je!==t.isValid?{}:{name:oe},...e.resolver||!oe?{isValid:je}:{},errors:t.errors}),Ce.shouldFocus&&!bt&&MI(i,X,oe?tt:a.mount),bt},fe=(oe,Ce)=>{let je={...o.mount?r:s};return Ce&&(je=kRe(Ce.dirtyFields?t.dirtyFields:t.touchedFields,je)),Lo(oe)?je:Su(oe)?Mt(je,oe):oe.map(bt=>Mt(je,bt))},Z=(oe,Ce)=>({invalid:!!Mt((Ce||t).errors,oe),isDirty:!!Mt((Ce||t).dirtyFields,oe),error:Mt((Ce||t).errors,oe),isValidating:!!Mt(t.validatingFields,oe),isTouched:!!Mt((Ce||t).touchedFields,oe)}),Y=oe=>{oe&&AI(oe).forEach(Ce=>Jo(t.errors,Ce)),h.state.next({errors:oe?t.errors:{}})},ee=(oe,Ce,je)=>{const bt=(Mt(i,oe,{_f:{}})._f||{}).ref,tt=Mt(t.errors,oe)||{},{ref:ct,message:$t,type:yi,...xi}=tt;Js(t.errors,oe,{...xi,...Ce,ref:bt}),h.state.next({name:oe,errors:t.errors,isValid:!1}),je&&je.shouldFocus&&bt&&bt.focus&&bt.focus()},se=(oe,Ce)=>Ef(oe)?h.state.subscribe({next:je=>"values"in je&&oe(j(void 0,Ce),je)}):j(oe,Ce,!0),ae=oe=>h.state.subscribe({next:Ce=>{Hit(oe.name,Ce.name,oe.exact)&&jit(Ce,oe.formState||d,br,oe.reRenderRoot)&&oe.callback({values:{...r},...t,...Ce,defaultValues:s})}}).unsubscribe,Se=oe=>(o.mount=!0,u={...u,...oe.formState},ae({...oe,formState:u})),ue=(oe,Ce={})=>{for(const je of oe?AI(oe):a.mount)a.mount.delete(je),a.array.delete(je),Ce.keepValue||(Jo(i,je),Jo(r,je)),!Ce.keepError&&Jo(t.errors,je),!Ce.keepDirty&&Jo(t.dirtyFields,je),!Ce.keepTouched&&Jo(t.touchedFields,je),!Ce.keepIsValidating&&Jo(t.validatingFields,je),!e.shouldUnregister&&!Ce.keepDefaultValue&&Jo(s,je);h.state.next({values:wa(r)}),h.state.next({...t,...Ce.keepDirty?{isDirty:H()}:{}}),!Ce.keepIsValid&&b()},Re=({disabled:oe,name:Ce})=>{(mu(oe)&&o.mount||oe||a.disabled.has(Ce))&&(oe?a.disabled.add(Ce):a.disabled.delete(Ce))},Ve=(oe,Ce={})=>{let je=Mt(i,oe);const bt=mu(Ce.disabled)||mu(e.disabled);return Js(i,oe,{...je||{},_f:{...je&&je._f?je._f:{ref:{name:oe}},name:oe,mount:!0,...Ce}}),a.mount.add(oe),je?Re({disabled:mu(Ce.disabled)?Ce.disabled:e.disabled,name:oe}):E(oe,!0,Ce.value),{...bt?{disabled:Ce.disabled||e.disabled}:{},...e.progressive?{required:!!Ce.required,min:mT(Ce.min),max:mT(Ce.max),minLength:mT(Ce.minLength),maxLength:mT(Ce.maxLength),pattern:mT(Ce.pattern)}:{},name:oe,onChange:K,onBlur:K,ref:tt=>{if(tt){Ve(oe,Ce),je=Mt(i,oe);const ct=Lo(tt.value)&&tt.querySelectorAll&&tt.querySelectorAll("input,select,textarea")[0]||tt,$t=Iit(ct),yi=je._f.refs||[];if($t?yi.find(xi=>xi===ct):ct===je._f.ref)return;Js(i,oe,{_f:{...je._f,...$t?{refs:[...yi.filter(XU),ct,...Array.isArray(Mt(s,oe))?[{}]:[]],ref:{type:ct.type,name:oe}}:{ref:ct}}}),E(oe,!1,void 0,ct)}else je=Mt(i,oe,{}),je._f&&(je._f.mount=!1),(e.shouldUnregister||Ce.shouldUnregister)&&!(RRe(a.array,oe)&&o.action)&&a.unMount.add(oe)}}},Qe=()=>e.shouldFocusError&&MI(i,X,a.mount),dt=oe=>{mu(oe)&&(h.state.next({disabled:oe}),MI(i,(Ce,je)=>{const bt=Mt(i,je);bt&&(Ce.disabled=bt._f.disabled||oe,Array.isArray(bt._f.refs)&&bt._f.refs.forEach(tt=>{tt.disabled=bt._f.disabled||oe}))},0,!1))},yt=(oe,Ce)=>async je=>{let bt;je&&(je.preventDefault&&je.preventDefault(),je.persist&&je.persist());let tt=wa(r);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:ct,values:$t}=await N();t.errors=ct,tt=wa($t)}else await M(i);if(a.disabled.size)for(const ct of a.disabled)Jo(tt,ct);if(Jo(t.errors,"root"),Sc(t.errors)){h.state.next({errors:{}});try{await oe(tt,je)}catch(ct){bt=ct}}else Ce&&await Ce({...t.errors},je),Qe(),setTimeout(Qe);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Sc(t.errors)&&!bt,submitCount:t.submitCount+1,errors:t.errors}),bt)throw bt},fi=(oe,Ce={})=>{Mt(i,oe)&&(Lo(Ce.defaultValue)?B(oe,wa(Mt(s,oe))):(B(oe,Ce.defaultValue),Js(s,oe,wa(Ce.defaultValue))),Ce.keepTouched||Jo(t.touchedFields,oe),Ce.keepDirty||(Jo(t.dirtyFields,oe),t.isDirty=Ce.defaultValue?H(oe,wa(Mt(s,oe))):H()),Ce.keepError||(Jo(t.errors,oe),d.isValid&&b()),h.state.next({...t}))},_i=(oe,Ce={})=>{const je=oe?wa(oe):s,bt=wa(je),tt=Sc(oe),ct=tt?s:bt;if(Ce.keepDefaultValues||(s=je),!Ce.keepValues){if(Ce.keepDirtyValues){const $t=new Set([...a.mount,...Object.keys(NL(s,r))]);for(const yi of Array.from($t))Mt(t.dirtyFields,yi)?Js(ct,yi,Mt(r,yi)):B(yi,Mt(ct,yi))}else{if(Kse&&Lo(oe))for(const $t of a.mount){const yi=Mt(i,$t);if(yi&&yi._f){const xi=Array.isArray(yi._f.refs)?yi._f.refs[0]:yi._f.ref;if(AF(xi)){const Nr=xi.closest("form");if(Nr){Nr.reset();break}}}}if(Ce.keepFieldsRef)for(const $t of a.mount)B($t,Mt(ct,$t));else i={}}r=e.shouldUnregister?Ce.keepDefaultValues?wa(s):{}:wa(ct),h.array.next({values:{...ct}}),h.state.next({values:{...ct}})}a={mount:Ce.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!Ce.keepIsValid||!!Ce.keepDirtyValues||!e.shouldUnregister&&!Sc(ct),o.watch=!!e.shouldUnregister,h.state.next({submitCount:Ce.keepSubmitCount?t.submitCount:0,isDirty:tt?!1:Ce.keepDirty?t.isDirty:!!(Ce.keepDefaultValues&&!Lf(oe,s)),isSubmitted:Ce.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:tt?{}:Ce.keepDirtyValues?Ce.keepDefaultValues&&r?NL(s,r):t.dirtyFields:Ce.keepDefaultValues&&oe?NL(s,oe):Ce.keepDirty?t.dirtyFields:{},touchedFields:Ce.keepTouched?t.touchedFields:{},errors:Ce.keepErrors?t.errors:{},isSubmitSuccessful:Ce.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Sn=(oe,Ce)=>_i(Ef(oe)?oe(r):oe,Ce),Es=(oe,Ce={})=>{const je=Mt(i,oe),bt=je&&je._f;if(bt){const tt=bt.refs?bt.refs[0]:bt.ref;tt.focus&&(tt.focus(),Ce.shouldSelect&&Ef(tt.select)&&tt.select())}},br=oe=>{t={...t,...oe}},Ht={control:{register:Ve,unregister:ue,getFieldState:Z,handleSubmit:yt,setError:ee,_subscribe:ae,_runSchema:N,_focusError:Qe,_getWatch:j,_getDirty:H,_setValid:b,_setFieldArray:C,_setDisabledField:Re,_setErrors:L,_getFieldArray:V,_reset:_i,_resetDefaultValues:()=>Ef(e.defaultValues)&&e.defaultValues().then(oe=>{Sn(oe,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:dt,_subjects:h,_proxyFormState:d,get _fields(){return i},get _formValues(){return r},get _state(){return o},set _state(oe){o=oe},get _defaultValues(){return s},get _names(){return a},set _names(oe){a=oe},get _formState(){return t},get _options(){return e},set _options(oe){e={...e,...oe}}},subscribe:Se,trigger:ne,register:Ve,handleSubmit:yt,watch:se,setValue:B,getValues:fe,reset:Sn,resetField:fi,clearErrors:Y,unregister:ue,setError:ee,setFocus:Es,getFieldState:Z};return{...Ht,formControl:Ht}}function Bp(n={}){const e=nt.useRef(void 0),t=nt.useRef(void 0),[i,s]=nt.useState({isDirty:!1,isValidating:!1,isLoading:Ef(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:Ef(n.defaultValues)?void 0:n.defaultValues});if(!e.current)if(n.formControl)e.current={...n.formControl,formState:i},n.defaultValues&&!Ef(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:o,...a}=Uit(n);e.current={...a,formState:i}}const r=e.current.control;return r._options=n,Qse(()=>{const o=r._subscribe({formState:r._proxyFormState,callback:()=>s({...r._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),r._formState.isReady=!0,o},[r]),nt.useEffect(()=>r._disableForm(n.disabled),[r,n.disabled]),nt.useEffect(()=>{n.mode&&(r._options.mode=n.mode),n.reValidateMode&&(r._options.reValidateMode=n.reValidateMode)},[r,n.mode,n.reValidateMode]),nt.useEffect(()=>{n.errors&&(r._setErrors(n.errors),r._focusError())},[r,n.errors]),nt.useEffect(()=>{n.shouldUnregister&&r._subjects.state.next({values:r._getWatch()})},[r,n.shouldUnregister]),nt.useEffect(()=>{if(r._proxyFormState.isDirty){const o=r._getDirty();o!==i.isDirty&&r._subjects.state.next({isDirty:o})}},[r,i.isDirty]),nt.useEffect(()=>{var o;n.values&&!Lf(n.values,t.current)?(r._reset(n.values,{keepFieldsRef:!0,...r._options.resetOptions}),!((o=r._options.resetOptions)===null||o===void 0)&&o.keepIsValid||r._setValid(),t.current=n.values,s(a=>({...a}))):r._resetDefaultValues()},[r,n.values]),nt.useEffect(()=>{r._state.mount||(r._setValid(),r._state.mount=!0),r._state.watch&&(r._state.watch=!1,r._subjects.state.next({...r._formState})),r._removeUnmounted()}),e.current.formState=TRe(i,r),e.current}var $it=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Git=$it.reduce((n,e)=>{const t=Ane(`Primitive.${e}`),i=x.forwardRef((s,r)=>{const{asChild:o,...a}=s,l=o?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...a,ref:r})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),qit="Label",jRe=x.forwardRef((n,e)=>f.jsx(Git.label,{...n,ref:e,onMouseDown:t=>{var s;t.target.closest("button, input, select, textarea")||((s=n.onMouseDown)==null||s.call(n,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));jRe.displayName=qit;var Kit=jRe;function Bu({className:n,...e}){return f.jsx(Kit,{"data-slot":"label",className:Le("flex items-center gap-2 text-sm leading-none font-medium group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",n),...e})}const CC=NRe,HRe=x.createContext({}),fn=({...n})=>f.jsx(HRe.Provider,{value:{name:n.name},children:f.jsx(Tit,{...n})}),FM=()=>{const n=x.useContext(HRe),e=x.useContext(BRe),{getFieldState:t}=VR(),i=IRe({name:n.name}),s=t(n.name,i);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:r}=e;return{id:r,name:n.name,formItemId:`${r}-form-item`,formDescriptionId:`${r}-form-item-description`,formMessageId:`${r}-form-item-message`,...s}},BRe=x.createContext({});function tn({className:n="",...e}){const t=x.useId();return f.jsx(BRe.Provider,{value:{id:t},children:f.jsx("div",{"data-slot":"form-item",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",n),...e})})}function Ji({className:n="",tooltip:e,tooltipProps:t,children:i,...s}){const{error:r,formItemId:o}=FM();return f.jsxs(Bu,{"data-slot":"form-label","data-error":!!r,className:Le("text-foreground flex items-center justify-between gap-2 text-sm font-medium","data-[error=true]:text-destructive",n),htmlFor:o,...s,children:[f.jsx("span",{children:i}),e&&f.jsxs(Tn,{...t,children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",tabIndex:-1,className:"pointer-events-none opacity-0 transition group-hover:pointer-events-auto group-hover:opacity-100","aria-label":"Help information",children:f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:e})]})]})}function cn({...n}){const{error:e,formItemId:t,formDescriptionId:i,formMessageId:s}=FM();return f.jsx(hM,{"data-slot":"form-control",id:t,"aria-describedby":e?`${i} ${s}`:`${i}`,"aria-invalid":!!e,...n})}function Hs({className:n,...e}){const{formDescriptionId:t}=FM();return f.jsx("div",{"data-slot":"form-description",id:t,className:Le("text-muted-foreground text-sm",n),...e})}function Cn({className:n,...e}){const{error:t,formMessageId:i}=FM(),s=t?String((t==null?void 0:t.message)??""):e.children;return s?f.jsx("p",{"data-slot":"form-message",id:i,className:Le("text-destructive text-sm",n),...e,children:s}):null}function wC({children:n,className:e="",variant:t="default"}){const i=t==="light"?"flex-1 overflow-y-auto":"bg-muted dark:bg-sidebar flex-1 overflow-y-auto p-4";return f.jsx("div",{className:i,children:f.jsx("div",{className:Le("flex min-h-full flex-col gap-4",e),children:n})})}function yC({className:n="",children:e,variant:t="default"}){const i=t==="light"?"flex flex-col gap-1.5 pt-4":"flex flex-col gap-1.5 border-t px-4 py-3";return f.jsx("div",{className:Le(i,n),children:e})}function tc({title:n,children:e}){return f.jsxs("section",{className:"mb-4",children:[n&&f.jsx("h3",{className:"text-muted-foreground/75 mb-2 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx("div",{className:"flex flex-col gap-2",children:e})]})}function Zit({value:n,label:e,checked:t,onChange:i,disabled:s=!1,orientation:r="vertical",className:o=""}){const{formItemId:a}=FM();return f.jsxs("label",{htmlFor:`${a}-${n}`,className:Le("flex cursor-pointer items-center gap-2 rounded-md py-1 pr-4 pl-2 text-sm",s&&"cursor-not-allowed opacity-50",r==="horizontal"?"flex-row":"flex-col",t?"bg-muted border-input border-b":"hover:bg-muted border-border bg-transparent",o),children:[f.jsx("input",{type:"radio",id:`${a}-${n}`,value:n,checked:t,onChange:i,disabled:s,className:Le("peer border-input ring-offset-background h-4 w-4 rounded-full border","checked:bg-primary checked:border-primary","focus-visible:ring-ring focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50")}),f.jsx("span",{className:Le("peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),children:e})]})}function Yit({options:n,value:e,onChange:t,orientation:i="vertical",className:s=""}){return f.jsx("div",{tabIndex:-1,className:Le(i==="horizontal"?"flex gap-6":"flex flex-col gap-2","border-input rounded-md border bg-transparent px-1 py-1 transition-colors","focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]","text-foreground selection:bg-primary selection:text-primary-foreground","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40","disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",s),children:n.map(r=>f.jsx(Zit,{value:r.value,label:r.label,checked:e===r.value,onChange:o=>t(o.target.value),disabled:r.disabled,orientation:i},r.value))})}const gb=x.forwardRef(({children:n,className:e="",...t},i)=>f.jsx("form",{ref:i,className:Le("flex flex-1 flex-col overflow-hidden",e),...t,children:n}));gb.displayName="AppForm";function Cme(n,[e,t]){return Math.min(t,Math.max(e,n))}function jK(n){const e=Xit(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Jit);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Xit(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=tnt(s),a=ent(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Qit=Symbol("radix.slottable");function Jit(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Qit}function ent(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function tnt(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}function int(n){const e=n+"CollectionProvider",[t,i]=Ha(e),[s,r]=t(e,{collectionRef:{current:null},itemMap:new Map}),o=b=>{const{scope:v,children:C}=b,y=nt.useRef(null),L=nt.useRef(new Map).current;return f.jsx(s,{scope:v,itemMap:L,collectionRef:y,children:C})};o.displayName=e;const a=n+"CollectionSlot",l=jK(a),c=nt.forwardRef((b,v)=>{const{scope:C,children:y}=b,L=r(a,C),E=Ui(v,L.collectionRef);return f.jsx(l,{ref:E,children:y})});c.displayName=a;const d=n+"CollectionItemSlot",u="data-radix-collection-item",h=jK(d),g=nt.forwardRef((b,v)=>{const{scope:C,children:y,...L}=b,E=nt.useRef(null),R=Ui(v,E),T=r(d,C);return nt.useEffect(()=>(T.itemMap.set(E,{ref:E,...L}),()=>void T.itemMap.delete(E))),f.jsx(h,{[u]:"",ref:R,children:y})});g.displayName=d;function m(b){const v=r(n+"CollectionConsumer",b);return nt.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const L=Array.from(y.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((T,N)=>L.indexOf(T.ref.current)-L.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:c,ItemSlot:g},m,i]}function ire(n){const e=x.useRef({value:n,previous:n});return x.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}var nnt=[" ","Enter","ArrowUp","ArrowDown"],snt=[" ","Enter"],Z0="Select",[$H,GH,rnt]=int(Z0),[WR]=Ha(Z0,[rnt,jp]),qH=jp(),[ont,SC]=WR(Z0),[ant,lnt]=WR(Z0),VRe=n=>{const{__scopeSelect:e,children:t,open:i,defaultOpen:s,onOpenChange:r,value:o,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:u,disabled:h,required:g,form:m}=n,b=qH(e),[v,C]=x.useState(null),[y,L]=x.useState(null),[E,R]=x.useState(!1),T=wM(c),[N,I]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:Z0}),[M,P]=zc({prop:o,defaultProp:a,onChange:l,caller:Z0}),H=x.useRef(null),j=v?m||!!v.closest("form"):!0,[V,W]=x.useState(new Set),U=Array.from(V).map(B=>B.props.value).join(";");return f.jsx(OR,{...b,children:f.jsxs(ont,{required:g,scope:e,trigger:v,onTriggerChange:C,valueNode:y,onValueNodeChange:L,valueNodeHasChildren:E,onValueNodeHasChildrenChange:R,contentId:To(),value:M,onValueChange:P,open:N,onOpenChange:I,dir:T,triggerPointerDownPosRef:H,disabled:h,children:[f.jsx($H.Provider,{scope:e,children:f.jsx(ant,{scope:n.__scopeSelect,onNativeOptionAdd:x.useCallback(B=>{W(K=>new Set(K).add(B))},[]),onNativeOptionRemove:x.useCallback(B=>{W(K=>{const X=new Set(K);return X.delete(B),X})},[]),children:t})}),j?f.jsxs(uNe,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:u,value:M,onChange:B=>P(B.target.value),disabled:h,form:m,children:[M===void 0?f.jsx("option",{value:""}):null,Array.from(V)]},U):null]})})};VRe.displayName=Z0;var WRe="SelectTrigger",zRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,disabled:i=!1,...s}=n,r=qH(t),o=SC(WRe,t),a=o.disabled||i,l=Ui(e,o.onTriggerChange),c=GH(t),d=x.useRef("touch"),[u,h,g]=fNe(b=>{const v=c().filter(L=>!L.disabled),C=v.find(L=>L.value===o.value),y=gNe(v,b,C);y!==void 0&&o.onValueChange(y.value)}),m=b=>{a||(o.onOpenChange(!0),g()),b&&(o.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return f.jsx(PR,{asChild:!0,...r,children:f.jsx(ui.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":hNe(o.value)?"":void 0,...s,ref:l,onClick:Lt(s.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&m(b)}),onPointerDown:Lt(s.onPointerDown,b=>{d.current=b.pointerType;const v=b.target;v.hasPointerCapture(b.pointerId)&&v.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(m(b),b.preventDefault())}),onKeyDown:Lt(s.onKeyDown,b=>{const v=u.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&h(b.key),!(v&&b.key===" ")&&nnt.includes(b.key)&&(m(),b.preventDefault())})})})});zRe.displayName=WRe;var URe="SelectValue",$Re=x.forwardRef((n,e)=>{const{__scopeSelect:t,className:i,style:s,children:r,placeholder:o="",...a}=n,l=SC(URe,t),{onValueNodeHasChildrenChange:c}=l,d=r!==void 0,u=Ui(e,l.onValueNodeChange);return Dl(()=>{c(d)},[c,d]),f.jsx(ui.span,{...a,ref:u,style:{pointerEvents:"none"},children:hNe(l.value)?f.jsx(f.Fragment,{children:o}):r})});$Re.displayName=URe;var cnt="SelectIcon",GRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,children:i,...s}=n;return f.jsx(ui.span,{"aria-hidden":!0,...s,ref:e,children:i||"▼"})});GRe.displayName=cnt;var dnt="SelectPortal",qRe=n=>f.jsx(HS,{asChild:!0,...n});qRe.displayName=dnt;var Y0="SelectContent",KRe=x.forwardRef((n,e)=>{const t=SC(Y0,n.__scopeSelect),[i,s]=x.useState();if(Dl(()=>{s(new DocumentFragment)},[]),!t.open){const r=i;return r?Rf.createPortal(f.jsx(ZRe,{scope:n.__scopeSelect,children:f.jsx($H.Slot,{scope:n.__scopeSelect,children:f.jsx("div",{children:n.children})})}),r):null}return f.jsx(YRe,{...n,ref:e})});KRe.displayName=Y0;var sf=10,[ZRe,xC]=WR(Y0),unt="SelectContentImpl",hnt=jK("SelectContent.RemoveScroll"),YRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:r,onPointerDownOutside:o,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:m,hideWhenDetached:b,avoidCollisions:v,...C}=n,y=SC(Y0,t),[L,E]=x.useState(null),[R,T]=x.useState(null),N=Ui(e,ue=>E(ue)),[I,M]=x.useState(null),[P,H]=x.useState(null),j=GH(t),[V,W]=x.useState(!1),U=x.useRef(!1);x.useEffect(()=>{if(L)return cH(L)},[L]),aH();const B=x.useCallback(ue=>{const[Re,...Ve]=j().map(yt=>yt.ref.current),[Qe]=Ve.slice(-1),dt=document.activeElement;for(const yt of ue)if(yt===dt||(yt==null||yt.scrollIntoView({block:"nearest"}),yt===Re&&R&&(R.scrollTop=0),yt===Qe&&R&&(R.scrollTop=R.scrollHeight),yt==null||yt.focus(),document.activeElement!==dt))return},[j,R]),K=x.useCallback(()=>B([I,L]),[B,I,L]);x.useEffect(()=>{V&&K()},[V,K]);const{onOpenChange:X,triggerPointerDownPosRef:ne}=y;x.useEffect(()=>{if(L){let ue={x:0,y:0};const Re=Qe=>{var dt,yt;ue={x:Math.abs(Math.round(Qe.pageX)-(((dt=ne.current)==null?void 0:dt.x)??0)),y:Math.abs(Math.round(Qe.pageY)-(((yt=ne.current)==null?void 0:yt.y)??0))}},Ve=Qe=>{ue.x<=10&&ue.y<=10?Qe.preventDefault():L.contains(Qe.target)||X(!1),document.removeEventListener("pointermove",Re),ne.current=null};return ne.current!==null&&(document.addEventListener("pointermove",Re),document.addEventListener("pointerup",Ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",Ve,{capture:!0})}}},[L,X,ne]),x.useEffect(()=>{const ue=()=>X(!1);return window.addEventListener("blur",ue),window.addEventListener("resize",ue),()=>{window.removeEventListener("blur",ue),window.removeEventListener("resize",ue)}},[X]);const[fe,Z]=fNe(ue=>{const Re=j().filter(dt=>!dt.disabled),Ve=Re.find(dt=>dt.ref.current===document.activeElement),Qe=gNe(Re,ue,Ve);Qe&&setTimeout(()=>Qe.ref.current.focus())}),Y=x.useCallback((ue,Re,Ve)=>{const Qe=!U.current&&!Ve;(y.value!==void 0&&y.value===Re||Qe)&&(M(ue),Qe&&(U.current=!0))},[y.value]),ee=x.useCallback(()=>L==null?void 0:L.focus(),[L]),se=x.useCallback((ue,Re,Ve)=>{const Qe=!U.current&&!Ve;(y.value!==void 0&&y.value===Re||Qe)&&H(ue)},[y.value]),ae=i==="popper"?HK:XRe,Se=ae===HK?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:m,hideWhenDetached:b,avoidCollisions:v}:{};return f.jsx(ZRe,{scope:t,content:L,viewport:R,onViewportChange:T,itemRefCallback:Y,selectedItem:I,onItemLeave:ee,itemTextRefCallback:se,focusSelectedItem:K,selectedItemText:P,position:i,isPositioned:V,searchRef:fe,children:f.jsx(pM,{as:hnt,allowPinchZoom:!0,children:f.jsx(gM,{asChild:!0,trapped:y.open,onMountAutoFocus:ue=>{ue.preventDefault()},onUnmountAutoFocus:Lt(s,ue=>{var Re;(Re=y.trigger)==null||Re.focus({preventScroll:!0}),ue.preventDefault()}),children:f.jsx(jS,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:ue=>ue.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:f.jsx(ae,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ue=>ue.preventDefault(),...C,...Se,onPlaced:()=>W(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:Lt(C.onKeyDown,ue=>{const Re=ue.ctrlKey||ue.altKey||ue.metaKey;if(ue.key==="Tab"&&ue.preventDefault(),!Re&&ue.key.length===1&&Z(ue.key),["ArrowUp","ArrowDown","Home","End"].includes(ue.key)){let Qe=j().filter(dt=>!dt.disabled).map(dt=>dt.ref.current);if(["ArrowUp","End"].includes(ue.key)&&(Qe=Qe.slice().reverse()),["ArrowUp","ArrowDown"].includes(ue.key)){const dt=ue.target,yt=Qe.indexOf(dt);Qe=Qe.slice(yt+1)}setTimeout(()=>B(Qe)),ue.preventDefault()}})})})})})})});YRe.displayName=unt;var fnt="SelectItemAlignedPosition",XRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,onPlaced:i,...s}=n,r=SC(Y0,t),o=xC(Y0,t),[a,l]=x.useState(null),[c,d]=x.useState(null),u=Ui(e,N=>d(N)),h=GH(t),g=x.useRef(!1),m=x.useRef(!0),{viewport:b,selectedItem:v,selectedItemText:C,focusSelectedItem:y}=o,L=x.useCallback(()=>{if(r.trigger&&r.valueNode&&a&&c&&b&&v&&C){const N=r.trigger.getBoundingClientRect(),I=c.getBoundingClientRect(),M=r.valueNode.getBoundingClientRect(),P=C.getBoundingClientRect();if(r.dir!=="rtl"){const dt=P.left-I.left,yt=M.left-dt,fi=N.left-yt,_i=N.width+fi,Sn=Math.max(_i,I.width),Es=window.innerWidth-sf,br=Cme(yt,[sf,Math.max(sf,Es-Sn)]);a.style.minWidth=_i+"px",a.style.left=br+"px"}else{const dt=I.right-P.right,yt=window.innerWidth-M.right-dt,fi=window.innerWidth-N.right-yt,_i=N.width+fi,Sn=Math.max(_i,I.width),Es=window.innerWidth-sf,br=Cme(yt,[sf,Math.max(sf,Es-Sn)]);a.style.minWidth=_i+"px",a.style.right=br+"px"}const H=h(),j=window.innerHeight-sf*2,V=b.scrollHeight,W=window.getComputedStyle(c),U=parseInt(W.borderTopWidth,10),B=parseInt(W.paddingTop,10),K=parseInt(W.borderBottomWidth,10),X=parseInt(W.paddingBottom,10),ne=U+B+V+X+K,fe=Math.min(v.offsetHeight*5,ne),Z=window.getComputedStyle(b),Y=parseInt(Z.paddingTop,10),ee=parseInt(Z.paddingBottom,10),se=N.top+N.height/2-sf,ae=j-se,Se=v.offsetHeight/2,ue=v.offsetTop+Se,Re=U+B+ue,Ve=ne-Re;if(Re<=se){const dt=H.length>0&&v===H[H.length-1].ref.current;a.style.bottom="0px";const yt=c.clientHeight-b.offsetTop-b.offsetHeight,fi=Math.max(ae,Se+(dt?ee:0)+yt+K),_i=Re+fi;a.style.height=_i+"px"}else{const dt=H.length>0&&v===H[0].ref.current;a.style.top="0px";const fi=Math.max(se,U+b.offsetTop+(dt?Y:0)+Se)+Ve;a.style.height=fi+"px",b.scrollTop=Re-se+b.offsetTop}a.style.margin=`${sf}px 0`,a.style.minHeight=fe+"px",a.style.maxHeight=j+"px",i==null||i(),requestAnimationFrame(()=>g.current=!0)}},[h,r.trigger,r.valueNode,a,c,b,v,C,r.dir,i]);Dl(()=>L(),[L]);const[E,R]=x.useState();Dl(()=>{c&&R(window.getComputedStyle(c).zIndex)},[c]);const T=x.useCallback(N=>{N&&m.current===!0&&(L(),y==null||y(),m.current=!1)},[L,y]);return f.jsx(pnt,{scope:t,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:f.jsx(ui.div,{...s,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});XRe.displayName=fnt;var gnt="SelectPopperPosition",HK=x.forwardRef((n,e)=>{const{__scopeSelect:t,align:i="start",collisionPadding:s=sf,...r}=n,o=qH(t);return f.jsx(_M,{...o,...r,ref:e,align:i,collisionPadding:s,style:{boxSizing:"border-box",...r.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});HK.displayName=gnt;var[pnt,nre]=WR(Y0,{}),BK="SelectViewport",QRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,nonce:i,...s}=n,r=xC(BK,t),o=nre(BK,t),a=Ui(e,r.onViewportChange),l=x.useRef(0);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),f.jsx($H.Slot,{scope:t,children:f.jsx(ui.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Lt(s.onScroll,c=>{const d=c.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:h}=o;if(h!=null&&h.current&&u){const g=Math.abs(l.current-d.scrollTop);if(g>0){const m=window.innerHeight-sf*2,b=parseFloat(u.style.minHeight),v=parseFloat(u.style.height),C=Math.max(b,v);if(C<m){const y=C+g,L=Math.min(m,y),E=y-L;u.style.height=L+"px",u.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,u.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});QRe.displayName=BK;var JRe="SelectGroup",[mnt,_nt]=WR(JRe),eNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=To();return f.jsx(mnt,{scope:t,id:s,children:f.jsx(ui.div,{role:"group","aria-labelledby":s,...i,ref:e})})});eNe.displayName=JRe;var tNe="SelectLabel",bnt=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=_nt(tNe,t);return f.jsx(ui.div,{id:s.id,...i,ref:e})});bnt.displayName=tNe;var OF="SelectItem",[vnt,iNe]=WR(OF),nNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,value:i,disabled:s=!1,textValue:r,...o}=n,a=SC(OF,t),l=xC(OF,t),c=a.value===i,[d,u]=x.useState(r??""),[h,g]=x.useState(!1),m=Ui(e,y=>{var L;return(L=l.itemRefCallback)==null?void 0:L.call(l,y,i,s)}),b=To(),v=x.useRef("touch"),C=()=>{s||(a.onValueChange(i),a.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return f.jsx(vnt,{scope:t,value:i,disabled:s,textId:b,isSelected:c,onItemTextChange:x.useCallback(y=>{u(L=>L||((y==null?void 0:y.textContent)??"").trim())},[]),children:f.jsx($H.ItemSlot,{scope:t,value:i,disabled:s,textValue:d,children:f.jsx(ui.div,{role:"option","aria-labelledby":b,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...o,ref:m,onFocus:Lt(o.onFocus,()=>g(!0)),onBlur:Lt(o.onBlur,()=>g(!1)),onClick:Lt(o.onClick,()=>{v.current!=="mouse"&&C()}),onPointerUp:Lt(o.onPointerUp,()=>{v.current==="mouse"&&C()}),onPointerDown:Lt(o.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Lt(o.onPointerMove,y=>{var L;v.current=y.pointerType,s?(L=l.onItemLeave)==null||L.call(l):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,y=>{var L;y.currentTarget===document.activeElement&&((L=l.onItemLeave)==null||L.call(l))}),onKeyDown:Lt(o.onKeyDown,y=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&y.key===" "||(snt.includes(y.key)&&C(),y.key===" "&&y.preventDefault())})})})})});nNe.displayName=OF;var aI="SelectItemText",sNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,className:i,style:s,...r}=n,o=SC(aI,t),a=xC(aI,t),l=iNe(aI,t),c=lnt(aI,t),[d,u]=x.useState(null),h=Ui(e,C=>u(C),l.onItemTextChange,C=>{var y;return(y=a.itemTextRefCallback)==null?void 0:y.call(a,C,l.value,l.disabled)}),g=d==null?void 0:d.textContent,m=x.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:g},l.value),[l.disabled,l.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:v}=c;return Dl(()=>(b(m),()=>v(m)),[b,v,m]),f.jsxs(f.Fragment,{children:[f.jsx(ui.span,{id:l.textId,...r,ref:h}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Rf.createPortal(r.children,o.valueNode):null]})});sNe.displayName=aI;var rNe="SelectItemIndicator",oNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n;return iNe(rNe,t).isSelected?f.jsx(ui.span,{"aria-hidden":!0,...i,ref:e}):null});oNe.displayName=rNe;var VK="SelectScrollUpButton",aNe=x.forwardRef((n,e)=>{const t=xC(VK,n.__scopeSelect),i=nre(VK,n.__scopeSelect),[s,r]=x.useState(!1),o=Ui(e,i.onScrollButtonChange);return Dl(()=>{if(t.viewport&&t.isPositioned){let a=function(){const c=l.scrollTop>0;r(c)};const l=t.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[t.viewport,t.isPositioned]),s?f.jsx(cNe,{...n,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=t;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});aNe.displayName=VK;var WK="SelectScrollDownButton",lNe=x.forwardRef((n,e)=>{const t=xC(WK,n.__scopeSelect),i=nre(WK,n.__scopeSelect),[s,r]=x.useState(!1),o=Ui(e,i.onScrollButtonChange);return Dl(()=>{if(t.viewport&&t.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;r(d)};const l=t.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[t.viewport,t.isPositioned]),s?f.jsx(cNe,{...n,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=t;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});lNe.displayName=WK;var cNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,onAutoScroll:i,...s}=n,r=xC("SelectScrollButton",t),o=x.useRef(null),a=GH(t),l=x.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return x.useEffect(()=>()=>l(),[l]),Dl(()=>{var d;const c=a().find(u=>u.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),f.jsx(ui.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Lt(s.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(i,50))}),onPointerMove:Lt(s.onPointerMove,()=>{var c;(c=r.onItemLeave)==null||c.call(r),o.current===null&&(o.current=window.setInterval(i,50))}),onPointerLeave:Lt(s.onPointerLeave,()=>{l()})})}),Cnt="SelectSeparator",dNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n;return f.jsx(ui.div,{"aria-hidden":!0,...i,ref:e})});dNe.displayName=Cnt;var zK="SelectArrow",wnt=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=qH(t),r=SC(zK,t),o=xC(zK,t);return r.open&&o.position==="popper"?f.jsx(bM,{...s,...i,ref:e}):null});wnt.displayName=zK;var ynt="SelectBubbleInput",uNe=x.forwardRef(({__scopeSelect:n,value:e,...t},i)=>{const s=x.useRef(null),r=Ui(i,s),o=ire(e);return x.useEffect(()=>{const a=s.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==e&&d){const u=new Event("change",{bubbles:!0});d.call(a,e),a.dispatchEvent(u)}},[o,e]),f.jsx(ui.select,{...t,style:{..._Le,...t.style},ref:r,defaultValue:e})});uNe.displayName=ynt;function hNe(n){return n===""||n===void 0}function fNe(n){const e=Vf(n),t=x.useRef(""),i=x.useRef(0),s=x.useCallback(o=>{const a=t.current+o;e(a),(function l(c){t.current=c,window.clearTimeout(i.current),c!==""&&(i.current=window.setTimeout(()=>l(""),1e3))})(a)},[e]),r=x.useCallback(()=>{t.current="",window.clearTimeout(i.current)},[]);return x.useEffect(()=>()=>window.clearTimeout(i.current),[]),[t,s,r]}function gNe(n,e,t){const s=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,r=t?n.indexOf(t):-1;let o=Snt(n,Math.max(r,0));s.length===1&&(o=o.filter(c=>c!==t));const l=o.find(c=>c.textValue.toLowerCase().startsWith(s.toLowerCase()));return l!==t?l:void 0}function Snt(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var xnt=VRe,Lnt=zRe,Ent=$Re,Dnt=GRe,Rnt=qRe,Nnt=KRe,Tnt=QRe,Int=eNe,knt=nNe,Ant=sNe,Mnt=oNe,Ont=aNe,Pnt=lNe,Fnt=dNe;function $c({...n}){return f.jsx(xnt,{"data-slot":"select",...n})}function KH({...n}){return f.jsx(Int,{"data-slot":"select-group",...n})}function Gc({...n}){return f.jsx(Ent,{"data-slot":"select-value",...n})}function qc({className:n,size:e="default",children:t,...i}){return f.jsxs(Lnt,{"data-slot":"select-trigger","data-size":e,className:Le("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...i,children:[t,f.jsx(Dnt,{asChild:!0,children:f.jsx(Pp,{className:"size-4 opacity-50"})})]})}function Kc({className:n,children:e,position:t="popper",...i}){return f.jsx(Rnt,{children:f.jsxs(Nnt,{"data-slot":"select-content",className:Le("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:t,...i,children:[f.jsx(Hnt,{}),f.jsx(Tnt,{className:Le("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),f.jsx(Bnt,{})]})})}function fo({className:n,children:e,...t}){return f.jsxs(knt,{"data-slot":"select-item",className:Le("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",n),...t,children:[f.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:f.jsx(Mnt,{children:f.jsx(Wc,{className:"size-4"})})}),f.jsx(Ant,{children:e})]})}function jnt({className:n,...e}){return f.jsx(Fnt,{"data-slot":"select-separator",className:Le("bg-border pointer-events-none -mx-1 my-1 h-px",n),...e})}function Hnt({className:n,...e}){return f.jsx(Ont,{"data-slot":"select-scroll-up-button",className:Le("flex cursor-default items-center justify-center py-1",n),...e,children:f.jsx(TD,{className:"size-4"})})}function Bnt({className:n,...e}){return f.jsx(Pnt,{"data-slot":"select-scroll-down-button",className:Le("flex cursor-default items-center justify-center py-1",n),...e,children:f.jsx(Pp,{className:"size-4"})})}const Vnt=_s({title:pn().min(1,"Title is required").max(100,"Title must be less than 100 characters"),storageId:pn().min(1,"Storage is required")});function Wnt(){const{createDataMart:n,isLoading:e,error:t}=og();return{handleCreate:x.useCallback(async s=>{try{return await n(s)}catch(r){return console.error(r),null}},[n]),isSubmitting:e,serverError:t}}function znt(n){const{getDataMart:e,deleteDataMart:t,updateDataMartTitle:i,updateDataMartDescription:s,updateDataMartDefinition:r,updateDataMartSchema:o,actualizeDataMartSchema:a,publishDataMart:l,runDataMart:c,cancelDataMartRun:d,getDataMartRuns:u,loadMoreDataMartRuns:h,reset:g,dataMart:m,isLoading:b,error:v,getErrorMessage:C,runs:y}=og();return x.useEffect(()=>(n?e(n):g(),()=>{g()}),[n,e,g]),{dataMart:m,isLoading:b,error:v,getErrorMessage:C,deleteDataMart:t,updateDataMartTitle:i,updateDataMartDescription:s,updateDataMartDefinition:r,updateDataMartSchema:o,actualizeDataMartSchema:a,publishDataMart:l,runDataMart:c,cancelDataMartRun:d,getDataMartRuns:u,loadMoreDataMartRuns:h,runs:y,getDataMart:e}}const wme=(n,e,t)=>{if(n&&"reportValidity"in n){const i=Mt(t,e);n.setCustomValidity(i&&i.message||""),n.reportValidity()}},UK=(n,e)=>{for(const t in e.fields){const i=e.fields[t];i&&i.ref&&"reportValidity"in i.ref?wme(i.ref,t,n):i&&i.refs&&i.refs.forEach(s=>wme(s,t,n))}},yme=(n,e)=>{e.shouldUseNativeValidation&&UK(n,e);const t={};for(const i in n){const s=Mt(e.fields,i),r=Object.assign(n[i]||{},{ref:s&&s.ref});if(Unt(e.names||Object.keys(n),i)){const o=Object.assign({},Mt(t,i));Js(o,"root",r),Js(t,i,o)}else Js(t,i,r)}return t},Unt=(n,e)=>{const t=Sme(e);return n.some(i=>Sme(i).match(`^${t}\\.\\d+`))};function Sme(n){return n.replace(/\]|\[/g,"")}function pNe(n,e,t){function i(a,l){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(n),e(a,l);for(const d in o.prototype)d in a||Object.defineProperty(a,d,{value:o.prototype[d].bind(a)});a._zod.constr=o,a._zod.def=l}const s=(t==null?void 0:t.Parent)??Object;class r extends s{}Object.defineProperty(r,"name",{value:n});function o(a){var l;const c=t!=null&&t.Parent?new r:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class $nt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Gnt={};function mNe(n){return Gnt}function qnt(n,e){return typeof e=="bigint"?e.toString():e}const _Ne=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};function f4(n){return typeof n=="string"?n:n==null?void 0:n.message}function bNe(n,e,t){var s,r,o,a,l,c;const i={...n,path:n.path??[]};if(!n.message){const d=f4((o=(r=(s=n.inst)==null?void 0:s._zod.def)==null?void 0:r.error)==null?void 0:o.call(r,n))??f4((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??f4((l=t.customError)==null?void 0:l.call(t,n))??f4((c=t.localeError)==null?void 0:c.call(t,n))??"Invalid input";i.message=d}return delete i.inst,delete i.continue,e!=null&&e.reportInput||delete i.input,i}const vNe=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(e,qnt,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Knt=pNe("$ZodError",vNe),CNe=pNe("$ZodError",vNe,{Parent:Error}),Znt=n=>(e,t,i,s)=>{const r=i?Object.assign(i,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new $nt;if(o.issues.length){const a=new((s==null?void 0:s.Err)??n)(o.issues.map(l=>bNe(l,r,mNe())));throw _Ne(a,s==null?void 0:s.callee),a}return o.value},Ynt=Znt(CNe),Xnt=n=>async(e,t,i,s)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??n)(o.issues.map(l=>bNe(l,r,mNe())));throw _Ne(a,s==null?void 0:s.callee),a}return o.value},Qnt=Xnt(CNe);function xme(n,e){try{var t=n()}catch(i){return e(i)}return t&&t.then?t.then(void 0,e):t}function Jnt(n,e){for(var t={};n.length;){var i=n[0],s=i.code,r=i.message,o=i.path.join(".");if(!t[o])if("unionErrors"in i){var a=i.unionErrors[0].errors[0];t[o]={message:a.message,type:a.code}}else t[o]={message:r,type:s};if("unionErrors"in i&&i.unionErrors.forEach(function(d){return d.errors.forEach(function(u){return n.push(u)})}),e){var l=t[o].types,c=l&&l[i.code];t[o]=Jse(o,e,t,s,c?[].concat(c,i.message):i.message)}n.shift()}return t}function est(n,e){for(var t={};n.length;){var i=n[0],s=i.code,r=i.message,o=i.path.join(".");if(!t[o])if(i.code==="invalid_union"&&i.errors.length>0){var a=i.errors[0][0];t[o]={message:a.message,type:a.code}}else t[o]={message:r,type:s};if(i.code==="invalid_union"&&i.errors.forEach(function(d){return d.forEach(function(u){return n.push(u)})}),e){var l=t[o].types,c=l&&l[i.code];t[o]=Jse(o,e,t,s,c?[].concat(c,i.message):i.message)}n.shift()}return t}function pb(n,e,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(n))return function(i,s,r){try{return Promise.resolve(xme(function(){return Promise.resolve(n[t.mode==="sync"?"parse":"parseAsync"](i,e)).then(function(o){return r.shouldUseNativeValidation&&UK({},r),{errors:{},values:t.raw?Object.assign({},i):o}})},function(o){if((function(a){return Array.isArray(a==null?void 0:a.issues)})(o))return{values:{},errors:yme(Jnt(o.errors,!r.shouldUseNativeValidation&&r.criteriaMode==="all"),r)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(n))return function(i,s,r){try{return Promise.resolve(xme(function(){return Promise.resolve((t.mode==="sync"?Ynt:Qnt)(n,i,e)).then(function(o){return r.shouldUseNativeValidation&&UK({},r),{errors:{},values:t.raw?Object.assign({},i):o}})},function(o){if((function(a){return a instanceof Knt})(o))return{values:{},errors:yme(est(o.issues,!r.shouldUseNativeValidation&&r.criteriaMode==="all"),r)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const wNe=x.createContext(void 0);function tst(){const n=x.useContext(wNe);if(n===void 0)throw new Error("useDataStorageContext must be used within a DataStorageProvider");return n}var ps=(n=>(n.FETCH_STORAGES_START="FETCH_STORAGES_START",n.FETCH_STORAGES_SUCCESS="FETCH_STORAGES_SUCCESS",n.FETCH_STORAGES_ERROR="FETCH_STORAGES_ERROR",n.FETCH_STORAGE_START="FETCH_STORAGE_START",n.FETCH_STORAGE_SUCCESS="FETCH_STORAGE_SUCCESS",n.FETCH_STORAGE_ERROR="FETCH_STORAGE_ERROR",n.CLEAR_CURRENT_STORAGE="CLEAR_CURRENT_STORAGE",n.CREATE_STORAGE_START="CREATE_STORAGE_START",n.CREATE_STORAGE_SUCCESS="CREATE_STORAGE_SUCCESS",n.CREATE_STORAGE_ERROR="CREATE_STORAGE_ERROR",n.UPDATE_STORAGE_START="UPDATE_STORAGE_START",n.UPDATE_STORAGE_SUCCESS="UPDATE_STORAGE_SUCCESS",n.UPDATE_STORAGE_ERROR="UPDATE_STORAGE_ERROR",n.DELETE_STORAGE_START="DELETE_STORAGE_START",n.DELETE_STORAGE_SUCCESS="DELETE_STORAGE_SUCCESS",n.DELETE_STORAGE_ERROR="DELETE_STORAGE_ERROR",n.CLEAR_ERROR="CLEAR_ERROR",n))(ps||{});const ist={dataStorages:[],currentDataStorage:null,loading:!1,error:null};function nst(n,e){switch(e.type){case ps.FETCH_STORAGES_START:case ps.FETCH_STORAGE_START:case ps.CREATE_STORAGE_START:case ps.UPDATE_STORAGE_START:return{...n,error:null};case ps.DELETE_STORAGE_START:return{...n,loading:!0,error:null};case ps.FETCH_STORAGES_SUCCESS:return{...n,dataStorages:e.payload,loading:!1,error:null};case ps.FETCH_STORAGE_SUCCESS:return{...n,currentDataStorage:e.payload,loading:!1,error:null};case ps.CREATE_STORAGE_SUCCESS:return{...n,dataStorages:[...n.dataStorages,e.payload],loading:!1,error:null};case ps.UPDATE_STORAGE_SUCCESS:return{...n,currentDataStorage:e.payload,dataStorages:n.dataStorages.map(t=>t.id===e.payload.id?e.payload:t),loading:!1,error:null};case ps.DELETE_STORAGE_SUCCESS:return{...n,dataStorages:n.dataStorages.filter(t=>t.id!==e.payload),loading:!1,error:null};case ps.FETCH_STORAGES_ERROR:case ps.FETCH_STORAGE_ERROR:case ps.CREATE_STORAGE_ERROR:case ps.UPDATE_STORAGE_ERROR:case ps.DELETE_STORAGE_ERROR:return{...n,loading:!1,error:e.payload};case ps.CLEAR_CURRENT_STORAGE:return{...n,currentDataStorage:null};case ps.CLEAR_ERROR:return{...n,error:null};default:return n}}function sre({children:n}){const[e,t]=x.useReducer(nst,ist);return f.jsx(wNe.Provider,{value:{state:e,dispatch:t},children:n})}class sst extends hC{constructor(){super("/data-storages")}async getDataStorages(){return this.get("/")}async getDataStorageById(e){return this.get(`/${e}`)}async createDataStorage(e){return this.post("",e)}async updateDataStorage(e,t){return this.put(`/${e}`,t)}async deleteDataStorage(e){return this.delete(`/${e}`)}}const _T=new sst;function ZH(){const{state:n,dispatch:e}=tst(),t=x.useCallback(async()=>{e({type:ps.FETCH_STORAGES_START});try{const l=await _T.getDataStorages();e({type:ps.FETCH_STORAGES_SUCCESS,payload:l.map(iit)})}catch(l){throw e({type:ps.FETCH_STORAGES_ERROR,payload:ys(l)}),l}},[e]),i=x.useCallback(async l=>{try{const c=await _T.getDataStorageById(l),d=o5(c);e({type:ps.FETCH_STORAGE_SUCCESS,payload:d})}catch(c){throw e({type:ps.FETCH_STORAGE_ERROR,payload:ys(c)}),c}},[e]),s=x.useCallback(async l=>{e({type:ps.CREATE_STORAGE_START});try{const c=nit(l),d=await _T.createDataStorage(c),u=o5(d);return e({type:ps.CREATE_STORAGE_SUCCESS,payload:u}),Vt({event:"data_storage_created",category:"DataStorage",action:"Create",label:u.type}),Rn.success("Storage created"),u}catch(c){return e({type:ps.CREATE_STORAGE_ERROR,payload:ys(c)}),null}},[e]),r=x.useCallback(async(l,c)=>{e({type:ps.UPDATE_STORAGE_START});try{const d=tit(c),u=await _T.updateDataStorage(l,d),h=o5(u);return e({type:ps.UPDATE_STORAGE_SUCCESS,payload:h}),Vt({event:"data_storage_updated",category:"DataStorage",action:"Update",label:h.type}),Rn.success("Storage updated"),h}catch(d){return e({type:ps.UPDATE_STORAGE_ERROR,payload:ys(d)}),null}},[e]),o=x.useCallback(async l=>{e({type:ps.DELETE_STORAGE_START});try{await _T.deleteDataStorage(l),e({type:ps.DELETE_STORAGE_SUCCESS,payload:l}),Vt({event:"data_storage_deleted",category:"DataStorage",action:"Delete",label:l}),Rn.success("Storage deleted")}catch(c){throw e({type:ps.DELETE_STORAGE_ERROR,payload:ys(c)}),c}},[e]),a=x.useCallback(()=>{e({type:ps.CLEAR_CURRENT_STORAGE})},[e]);return{dataStorages:n.dataStorages,currentDataStorage:n.currentDataStorage,loading:n.loading,error:n.error,fetchDataStorages:t,getDataStorageById:i,createDataStorage:s,updateDataStorage:r,deleteDataStorage:o,clearCurrentDataStorage:a}}const yNe=({isOpen:n,onClose:e,onSelect:t})=>f.jsx(Vse,{open:n,onOpenChange:e,children:f.jsxs(Wse,{className:"sm:max-w-sm",children:[f.jsxs(zse,{children:[f.jsx(Use,{children:"New Storage"}),f.jsx($se,{children:"Choose the type of storage you want to create"})]}),f.jsx("div",{className:"flex flex-col gap-4 py-4",children:fC.getAllTypes().map(i=>{const s=i.icon,r=i.status===Km.ACTIVE;return f.jsxs(rt,{variant:"outline",className:"flex px-4 py-6",onClick:()=>void t(i.type),disabled:!r,children:[f.jsxs("span",{className:"flex flex-grow items-center gap-2",children:[f.jsx(s,{size:24}),f.jsx("span",{className:"font-medium",children:i.displayName})]}),!r&&f.jsx(Ya,{variant:"secondary",children:"Coming soon"})]},i.type)})})]})});function rst({initialData:n,onSuccess:e}){const{handleCreate:t,isSubmitting:i,serverError:s}=Wnt(),{dataStorages:r,loading:o,fetchDataStorages:a,createDataStorage:l,getDataStorageById:c}=ZH(),[d,u]=x.useState(!1);x.useEffect(()=>{a()},[a]);const h=Bp({resolver:pb(Vnt),defaultValues:{title:(n==null?void 0:n.title)??"",storageId:""},mode:"onTouched"}),g=async v=>{const C=await t(v);C&&e&&e(C)},m=()=>{u(!0)},b=async v=>{try{const C=await l(v);C!=null&&C.id&&(await c(C.id),h.setValue("storageId",C.id))}catch(C){console.error("Failed to create storage:",C)}u(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(CC,{...h,children:f.jsxs(gb,{onSubmit:v=>{h.handleSubmit(g)(v)},children:[f.jsxs(wC,{variant:"light",children:[s&&f.jsx("div",{className:"rounded bg-red-100 p-3 text-red-700",children:s.message}),f.jsx(fn,{control:h.control,name:"title",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{id:"title",placeholder:"Enter title",...v,disabled:i})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:h.control,name:"storageId",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"Storage"}),f.jsx(cn,{children:f.jsxs($c,{onValueChange:C=>{C==="create_new"?m():v.onChange(C)},value:v.value,disabled:i||o,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a storage"})}),f.jsx(Kc,{children:f.jsxs(KH,{children:[o&&f.jsx(fo,{value:"loading",disabled:!0,children:"Loading..."}),!o&&r.map(C=>{const y=fC.getInfo(C.type).icon;return f.jsx(fo,{value:C.id,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(y,{size:20}),f.jsx("span",{children:C.title})]})},C.id)}),!o&&r.length>0&&f.jsx(jnt,{}),f.jsx(fo,{value:"create_new",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"flex h-5 w-5 items-center justify-center",children:f.jsx(Gd,{size:20})}),f.jsx("span",{children:"Create new storage"})]})})]})})]})}),f.jsx(Cn,{})]})})]}),f.jsxs(yC,{variant:"light",children:[f.jsx(rt,{type:"submit",children:"Create Data Mart"}),f.jsx(rt,{variant:"outline",type:"button",onClick:()=>{window.history.back()},children:"Go back"})]})]})}),f.jsx(yNe,{isOpen:d,onClose:()=>{u(!1)},onSelect:v=>b(v)})]})}function SNe({title:n,onUpdate:e,className:t,errorMessage:i="Title cannot be empty",minWidth:s="200px"}){const[r,o]=x.useState(n),[a,l]=x.useState(!1),c=x.useRef(null);x.useEffect(()=>{o(n)},[n]),x.useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=`${String(c.current.scrollHeight)}px`)},[r]);const d=async()=>{if(r.trim()===""){o(n);return}if(r.trim()!==n)try{l(!0),await e(r.trim())}catch(h){o(n),console.error(h)}finally{l(!1)}},u=h=>{if(h.key==="Enter"&&!h.shiftKey){if(h.preventDefault(),r.trim()===""){Rn.error(i),o(n);return}d()}else h.key==="Escape"&&o(n)};return f.jsx("h2",{className:Le("m-0 cursor-pointer p-0 hover:opacity-80",t),children:f.jsx(Hp,{ref:c,value:r,onChange:h=>{o(h.target.value);const g=h.target;g.style.height="auto",g.style.height=`${String(g.scrollHeight)}px`},onBlur:()=>void d(),onKeyDown:u,className:Le("m-0 w-full border-0 p-0 shadow-none","bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",{"opacity-50":a}),style:{fontSize:"inherit",fontWeight:"inherit",lineHeight:"inherit",fontFamily:"inherit",color:"inherit",resize:"none",overflow:"hidden",minHeight:"inherit",height:"auto",minWidth:s},disabled:a})})}var _w=(n=>(n.MANUAL_BACKFILL="MANUAL_BACKFILL",n.INCREMENTAL="INCREMENTAL",n))(_w||{}),xNe=(n=>(n.MANUAL_BACKFILL="MANUAL_BACKFILL",n.HIDE_IN_CONFIG_FORM="HIDE_IN_CONFIG_FORM",n))(xNe||{}),YH="Tabs",[ost]=Ha(YH,[yH]),LNe=yH(),[ast,rre]=ost(YH),ENe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,onValueChange:s,defaultValue:r,orientation:o="horizontal",dir:a,activationMode:l="automatic",...c}=n,d=wM(a),[u,h]=zc({prop:i,onChange:s,defaultProp:r??"",caller:YH});return f.jsx(ast,{scope:t,baseId:To(),value:u,onValueChange:h,orientation:o,dir:d,activationMode:l,children:f.jsx(ui.div,{dir:d,"data-orientation":o,...c,ref:e})})});ENe.displayName=YH;var DNe="TabsList",RNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,loop:i=!0,...s}=n,r=rre(DNe,t),o=LNe(t);return f.jsx(MLe,{asChild:!0,...o,orientation:r.orientation,dir:r.dir,loop:i,children:f.jsx(ui.div,{role:"tablist","aria-orientation":r.orientation,...s,ref:e})})});RNe.displayName=DNe;var NNe="TabsTrigger",TNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,disabled:s=!1,...r}=n,o=rre(NNe,t),a=LNe(t),l=ANe(o.baseId,i),c=MNe(o.baseId,i),d=i===o.value;return f.jsx(OLe,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(ui.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:l,...r,ref:e,onMouseDown:Lt(n.onMouseDown,u=>{!s&&u.button===0&&u.ctrlKey===!1?o.onValueChange(i):u.preventDefault()}),onKeyDown:Lt(n.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&o.onValueChange(i)}),onFocus:Lt(n.onFocus,()=>{const u=o.activationMode!=="manual";!d&&!s&&u&&o.onValueChange(i)})})})});TNe.displayName=NNe;var INe="TabsContent",kNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,forceMount:s,children:r,...o}=n,a=rre(INe,t),l=ANe(a.baseId,i),c=MNe(a.baseId,i),d=i===a.value,u=x.useRef(d);return x.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),f.jsx(kl,{present:s||d,children:({present:h})=>f.jsx(ui.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...o,ref:e,style:{...n.style,animationDuration:u.current?"0s":void 0},children:h&&r})})});kNe.displayName=INe;function ANe(n,e){return`${n}-trigger-${e}`}function MNe(n,e){return`${n}-content-${e}`}var lst=ENe,cst=RNe,dst=TNe,ust=kNe;function ore({className:n,...e}){return f.jsx(lst,{"data-slot":"tabs",className:Le("flex flex-col gap-2",n),...e})}function are({className:n,...e}){return f.jsx(cst,{"data-slot":"tabs-list",className:Le("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",n),...e})}function u2({className:n,...e}){return f.jsx(dst,{"data-slot":"tabs-trigger",className:Le("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function hst({className:n,...e}){return f.jsx(ust,{"data-slot":"tabs-content",className:Le("flex-1 outline-none",n),...e})}var XH="Collapsible",[fst,ONe]=Ha(XH),[gst,lre]=fst(XH),PNe=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:i,defaultOpen:s,disabled:r,onOpenChange:o,...a}=n,[l,c]=zc({prop:i,defaultProp:s??!1,onChange:o,caller:XH});return f.jsx(gst,{scope:t,disabled:r,contentId:To(),open:l,onOpenToggle:x.useCallback(()=>c(d=>!d),[c]),children:f.jsx(ui.div,{"data-state":hre(l),"data-disabled":r?"":void 0,...a,ref:e})})});PNe.displayName=XH;var FNe="CollapsibleTrigger",cre=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,...i}=n,s=lre(FNe,t);return f.jsx(ui.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":hre(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:e,onClick:Lt(n.onClick,s.onOpenToggle)})});cre.displayName=FNe;var dre="CollapsibleContent",ure=x.forwardRef((n,e)=>{const{forceMount:t,...i}=n,s=lre(dre,n.__scopeCollapsible);return f.jsx(kl,{present:t||s.open,children:({present:r})=>f.jsx(pst,{...i,ref:e,present:r})})});ure.displayName=dre;var pst=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:i,children:s,...r}=n,o=lre(dre,t),[a,l]=x.useState(i),c=x.useRef(null),d=Ui(e,c),u=x.useRef(0),h=u.current,g=x.useRef(0),m=g.current,b=o.open||a,v=x.useRef(b),C=x.useRef(void 0);return x.useEffect(()=>{const y=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(y)},[]),Dl(()=>{const y=c.current;if(y){C.current=C.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const L=y.getBoundingClientRect();u.current=L.height,g.current=L.width,v.current||(y.style.transitionDuration=C.current.transitionDuration,y.style.animationName=C.current.animationName),l(i)}},[o.open,i]),f.jsx(ui.div,{"data-state":hre(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!b,...r,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:b&&s})});function hre(n){return n?"open":"closed"}var jNe=PNe,mst=cre,_st=ure;const bst=jNe,vst=cre,Cst=ure;function wst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("flex flex-1 flex-col overflow-hidden",e),...t,children:n})}function yst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("bg-muted dark:bg-sidebar flex-1 overflow-y-auto p-4",e),...t,children:f.jsx("div",{className:"flex min-h-full flex-col gap-4",children:n})})}function Sst({children:n,className:e="",variant:t="horizontal",...i}){const s=t==="vertical"?"flex flex-col gap-1.5 pt-4":"flex items-center justify-between border-t px-4 py-3";return f.jsx("div",{className:Le(s,e),...i,children:n})}function iv({children:n,className:e="",...t}){return f.jsx("div",{"data-slot":"wizard-step-item",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",e),...t,children:n})}function xst({label:n,children:e,className:t="",options:i,value:s,onValueChange:r,required:o=!1,tooltip:a,...l}){return f.jsx("div",{"data-slot":"wizard-step-item-one-of",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",t),...l,children:f.jsxs(ore,{value:s,onValueChange:r,children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx(_u,{required:o,tooltip:a,className:"w-full",children:n}),i.length>1&&f.jsx(are,{children:i.map(c=>f.jsx(u2,{value:c.value,children:c.label},c.value))})]}),e]})})}function HNe({title:n,children:e,defaultOpen:t=!1,className:i=""}){const[s,r]=x.useState(t);return f.jsxs(bst,{open:s,onOpenChange:r,"data-slot":"wizard-collapsible",className:Le("group/collapsible flex flex-col gap-2 py-3",i),children:[f.jsx(vst,{asChild:!0,children:f.jsxs("button",{type:"button",className:Le("flex cursor-pointer items-center gap-1"),children:[f.jsx("span",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx($d,{className:Le("text-foreground/75 h-3.5 w-3.5 transition-transform duration-200",s&&"rotate-90")})]})}),f.jsx(Cst,{className:"data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up overflow-hidden",children:f.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e})})]})}function _u({children:n,required:e=!1,tooltip:t,tooltipProps:i,className:s="",...r}){return f.jsxs(Bu,{"data-slot":"wizard-step-label",className:Le("text-foreground flex items-center justify-between gap-2 text-sm font-medium",s),...r,children:[e?f.jsxs(Tn,{...i,children:[f.jsx(In,{asChild:!0,children:f.jsxs("span",{className:"flex items-center gap-1",children:[n,f.jsx("span",{className:"ml-1 text-red-500",children:"*"})]})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:"Required"})]}):f.jsx("span",{children:n}),t&&f.jsxs(Tn,{...i,children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",tabIndex:-1,className:"pointer-events-none opacity-0 transition group-hover:pointer-events-auto group-hover:opacity-100","aria-label":"Help information",children:f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:t})]})]})}function Hv({title:n,children:e,className:t="",...i}){return f.jsxs("section",{"data-slot":"wizard-step-section",className:Le("mb-8",t),...i,children:[n&&f.jsx("h3",{className:"text-muted-foreground/75 mb-2 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx("div",{className:"flex flex-col gap-2",children:e})]})}function x_({icon:n,title:e,subtitle:t,docUrl:i,variant:s="default",className:r,...o}){return s==="compact"?f.jsxs("div",{"data-slot":"wizard-step-hero",className:Le("border-border mb-6 flex items-center justify-between gap-4 border-b pb-4",r),...o,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[n&&f.jsx("div",{children:n}),f.jsx("h2",{className:"text-md font-medium",children:e})]}),i!=null&&f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:i,target:"_blank",rel:"noopener noreferrer",children:["Documentation",f.jsx(F_,{className:"h-4 w-4"})]})})]}):f.jsxs("div",{"data-slot":"wizard-step-hero",className:Le("mb-6 flex flex-col items-center justify-center text-center",r),...o,children:[n&&f.jsx("div",{className:"mt-6 mb-3",children:n}),f.jsx("h2",{className:"text-xl font-medium",children:e}),t&&f.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:t}),i!=null&&f.jsx(rt,{variant:"outline",className:"mt-3 mb-6",asChild:!0,children:f.jsxs(Vc,{to:i,target:"_blank",rel:"noopener noreferrer",children:["Documentation",f.jsx(F_,{className:"h-4 w-4"})]})})]})}function L_({children:n,className:e="",...t}){return f.jsx("div",{"data-slot":"wizard-step",className:Le("space-y-4",e),...t,children:n})}function Lst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("grid grid-cols-1 gap-4 md:grid-cols-2",e),...t,children:n})}function Est({icon:n,title:e,selected:t=!1,disabled:i=!1,onClick:s,onDoubleClick:r,className:o="",...a}){return f.jsxs("div",{className:Le("border-border flex items-center gap-4 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 select-none hover:shadow-sm dark:border-transparent dark:bg-white/4",i?"cursor-not-allowed opacity-50 hover:shadow-none":"cursor-pointer hover:shadow-sm dark:hover:bg-white/8",t&&!i?"ring-primary border-transparent ring-2 dark:bg-white/8":"",o),onClick:s,onDoubleClick:r,...a,children:[n&&f.jsx("span",{className:"shrink-0",children:n}),i?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{className:"cursor-not-allowed text-sm font-medium opacity-70",children:e})}),f.jsx(kn,{side:"top",align:"center",children:"Coming soon"})]}):f.jsx("span",{className:"text-sm font-medium",children:e})]})}function BNe({type:n,id:e,name:t,value:i,label:s,checked:r,selected:o=!1,disabled:a=!1,tooltip:l,rightIcon:c,onChange:d,className:u="",...h}){const g=b=>{d&&d(n==="checkbox"?b.target.checked:b.target.value)},m=x.useRef(null);return f.jsxs("div",{"data-slot":"wizard-step-card-item",onClick:b=>{if(a)return;const v=b.target;v.tagName==="INPUT"||v.tagName==="LABEL"||v.closest("label")||m.current&&m.current.click()},className:Le("group border-border flex items-center gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 select-none hover:shadow-sm dark:border-transparent dark:bg-white/4",a?"cursor-not-allowed":"cursor-pointer hover:shadow-sm dark:hover:bg-white/8",o?"ring-primary border-transparent ring-2 dark:bg-white/8":"",u),children:[f.jsx("input",{ref:m,id:e,type:n,name:t,value:i,checked:r,disabled:a,onChange:g,className:Le("text-primary focus:ring-primary border-border cursor-pointer",n==="radio"||n==="checkbox"?"h-4 w-4":"h-8 w-full rounded-md border px-2"),...h}),s&&f.jsx(_u,{htmlFor:e,className:Le("cursor-pointer",a&&"cursor-not-allowed"),children:s}),(l||c)&&f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[l&&f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"text-muted-foreground/75 pointer-events-none h-4 w-4 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100","data-tooltip-trigger":!0})}),f.jsx(kn,{side:"top",align:"center",children:l})]}),c&&f.jsx("div",{className:"flex items-center",children:c})]})]})}function fre({variant:n="grid",items:e,className:t=""}){const i=e??(n==="grid"?12:6),s=n==="grid"?"grid grid-cols-1 gap-4 md:grid-cols-2":"flex flex-col gap-4";return f.jsx("div",{"data-slot":"wizard-step-loading",className:Le(s,t),children:Array.from({length:i}).map((r,o)=>f.jsx(bl,{className:"border-border h-12 rounded-md border-b bg-white dark:bg-white/4"},o))})}function Lme(n){const e=Dst(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Nst);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Dst(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Ist(s),a=Tst(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Rst=Symbol("radix.slottable");function Nst(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Rst}function Tst(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Ist(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}function kst(n){const e=n+"CollectionProvider",[t,i]=Ha(e),[s,r]=t(e,{collectionRef:{current:null},itemMap:new Map}),o=b=>{const{scope:v,children:C}=b,y=nt.useRef(null),L=nt.useRef(new Map).current;return f.jsx(s,{scope:v,itemMap:L,collectionRef:y,children:C})};o.displayName=e;const a=n+"CollectionSlot",l=Lme(a),c=nt.forwardRef((b,v)=>{const{scope:C,children:y}=b,L=r(a,C),E=Ui(v,L.collectionRef);return f.jsx(l,{ref:E,children:y})});c.displayName=a;const d=n+"CollectionItemSlot",u="data-radix-collection-item",h=Lme(d),g=nt.forwardRef((b,v)=>{const{scope:C,children:y,...L}=b,E=nt.useRef(null),R=Ui(v,E),T=r(d,C);return nt.useEffect(()=>(T.itemMap.set(E,{ref:E,...L}),()=>void T.itemMap.delete(E))),f.jsx(h,{[u]:"",ref:R,children:y})});g.displayName=d;function m(b){const v=r(n+"CollectionConsumer",b);return nt.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const L=Array.from(y.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((T,N)=>L.indexOf(T.ref.current)-L.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:c,ItemSlot:g},m,i]}var ag="Accordion",Ast=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[gre,Mst,Ost]=kst(ag),[QH]=Ha(ag,[Ost,ONe]),pre=ONe(),VNe=nt.forwardRef((n,e)=>{const{type:t,...i}=n,s=i,r=i;return f.jsx(gre.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?f.jsx(Hst,{...r,ref:e}):f.jsx(jst,{...s,ref:e})})});VNe.displayName=ag;var[WNe,Pst]=QH(ag),[zNe,Fst]=QH(ag,{collapsible:!1}),jst=nt.forwardRef((n,e)=>{const{value:t,defaultValue:i,onValueChange:s=()=>{},collapsible:r=!1,...o}=n,[a,l]=zc({prop:t,defaultProp:i??"",onChange:s,caller:ag});return f.jsx(WNe,{scope:n.__scopeAccordion,value:nt.useMemo(()=>a?[a]:[],[a]),onItemOpen:l,onItemClose:nt.useCallback(()=>r&&l(""),[r,l]),children:f.jsx(zNe,{scope:n.__scopeAccordion,collapsible:r,children:f.jsx(UNe,{...o,ref:e})})})}),Hst=nt.forwardRef((n,e)=>{const{value:t,defaultValue:i,onValueChange:s=()=>{},...r}=n,[o,a]=zc({prop:t,defaultProp:i??[],onChange:s,caller:ag}),l=nt.useCallback(d=>a((u=[])=>[...u,d]),[a]),c=nt.useCallback(d=>a((u=[])=>u.filter(h=>h!==d)),[a]);return f.jsx(WNe,{scope:n.__scopeAccordion,value:o,onItemOpen:l,onItemClose:c,children:f.jsx(zNe,{scope:n.__scopeAccordion,collapsible:!0,children:f.jsx(UNe,{...r,ref:e})})})}),[Bst,JH]=QH(ag),UNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:i,dir:s,orientation:r="vertical",...o}=n,a=nt.useRef(null),l=Ui(a,e),c=Mst(t),u=wM(s)==="ltr",h=Lt(n.onKeyDown,g=>{var I;if(!Ast.includes(g.key))return;const m=g.target,b=c().filter(M=>{var P;return!((P=M.ref.current)!=null&&P.disabled)}),v=b.findIndex(M=>M.ref.current===m),C=b.length;if(v===-1)return;g.preventDefault();let y=v;const L=0,E=C-1,R=()=>{y=v+1,y>E&&(y=L)},T=()=>{y=v-1,y<L&&(y=E)};switch(g.key){case"Home":y=L;break;case"End":y=E;break;case"ArrowRight":r==="horizontal"&&(u?R():T());break;case"ArrowDown":r==="vertical"&&R();break;case"ArrowLeft":r==="horizontal"&&(u?T():R());break;case"ArrowUp":r==="vertical"&&T();break}const N=y%C;(I=b[N].ref.current)==null||I.focus()});return f.jsx(Bst,{scope:t,disabled:i,direction:s,orientation:r,children:f.jsx(gre.Slot,{scope:t,children:f.jsx(ui.div,{...o,"data-orientation":r,ref:l,onKeyDown:i?void 0:h})})})}),PF="AccordionItem",[Vst,mre]=QH(PF),$Ne=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,value:i,...s}=n,r=JH(PF,t),o=Pst(PF,t),a=pre(t),l=To(),c=i&&o.value.includes(i)||!1,d=r.disabled||n.disabled;return f.jsx(Vst,{scope:t,open:c,disabled:d,triggerId:l,children:f.jsx(jNe,{"data-orientation":r.orientation,"data-state":XNe(c),...a,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?o.onItemOpen(i):o.onItemClose(i)}})})});$Ne.displayName=PF;var GNe="AccordionHeader",qNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre(GNe,t);return f.jsx(ui.h3,{"data-orientation":s.orientation,"data-state":XNe(r.open),"data-disabled":r.disabled?"":void 0,...i,ref:e})});qNe.displayName=GNe;var $K="AccordionTrigger",KNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre($K,t),o=Fst($K,t),a=pre(t);return f.jsx(gre.ItemSlot,{scope:t,children:f.jsx(mst,{"aria-disabled":r.open&&!o.collapsible||void 0,"data-orientation":s.orientation,id:r.triggerId,...a,...i,ref:e})})});KNe.displayName=$K;var ZNe="AccordionContent",YNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre(ZNe,t),o=pre(t);return f.jsx(_st,{role:"region","aria-labelledby":r.triggerId,"data-orientation":s.orientation,...o,...i,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});YNe.displayName=ZNe;function XNe(n){return n?"open":"closed"}var Wst=VNe,zst=$Ne,Ust=qNe,$st=KNe,Gst=YNe;const _re={default:{itemClass:"border-b last:border-b-0",triggerClass:"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",icon:null,chevronClass:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200",contentClass:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",contentInnerClass:"pt-0 pb-4",headerClass:"flex"},common:{itemClass:"overflow-hidden",triggerClass:"group focus-visible:ring-primary hover:bg-muted [&[data-state=open]]:bg-muted flex items-center gap-1 rounded-sm px-2 py-1 transition-all outline-none focus-visible:ring-2 [&[data-state=open]]:rounded-br-none [&[data-state=open]]:rounded-bl-none [&[data-state=open]]:font-semibold",icon:f.jsx(DBe,{className:"size-4 shrink-0","aria-hidden":"true"}),chevronClass:"size-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180",contentClass:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down bg-muted overflow-hidden rounded-sm rounded-tl-none py-0 pr-2 pl-7 text-sm",contentInnerClass:"pt-2 pb-4",headerClass:void 0}},QNe=x.createContext("default");function sr({variant:n="default",...e}){return f.jsx(QNe.Provider,{value:n,children:f.jsx(Wst,{"data-slot":"accordion",...e})})}function bre(n){const e=x.useContext(QNe);return n??e??"default"}function ts({className:n,variant:e,...t}){const i=bre(e),{itemClass:s}=_re[i];return f.jsx(zst,{"data-slot":"accordion-item",className:Le(s,n),...t})}function is({className:n,children:e,variant:t,...i}){const s=bre(t),{triggerClass:r,icon:o,chevronClass:a,headerClass:l}=_re[s];return f.jsx(Ust,{className:l,children:f.jsxs($st,{"data-slot":"accordion-trigger",className:Le(r,n),...i,children:[o,e,f.jsx(Pp,{className:a,"aria-hidden":"true"})]})})}function ns({className:n,children:e,variant:t,...i}){const s=bre(t),{contentClass:r,contentInnerClass:o}=_re[s];return f.jsx(Gst,{"data-slot":"accordion-content",className:Le(r,n),...i,children:f.jsx("div",{className:o,children:e})})}function ir({href:n,children:e,className:t,...i}){return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Le("text-muted-foreground hover:bg-muted inline-flex items-center px-1 font-medium hover:rounded-md",t),...i,children:[e,f.jsx(F_,{className:"ml-1 inline h-3 w-3","aria-hidden":"true"})]})}function Eme(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"connector-state-details",children:[f.jsx(is,{children:"What’s connector state?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The connector state stores internal data between runs and updates automatically with each execution. It’s used to track progress and ensure consistent data processing across runs."}),f.jsx("p",{className:"mb-2",children:"Connector state is available only for connectors that support incremental runs, helping add only new or updated records since the last run without reloading existing data."}),f.jsxs("p",{className:"mb-2",children:["For more details, see the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/?utm_source=owox_data_marts&utm_medium=manual_run_sheet&utm_campaign=tooltip_connector_state",children:"OWOX documentation"}),"."]})]})]})})}function qst({configuration:n,connectorState:e}){const i=((n==null?void 0:n.connector.source.configuration)??[]).map((a,l)=>{const c=a;return typeof c._id=="string"?{id:c._id,index:l}:void 0}).filter(a=>!!a),s=(e==null?void 0:e.states)??[],r=new Map(s.map(a=>[a._id,a])),o=i.map(({id:a,index:l})=>{const c=r.get(a);return c?{state:c,index:l}:void 0}).filter(a=>!!a);return f.jsx(HNe,{title:"State Info",children:o.length===0?f.jsxs(tn,{children:[f.jsx(Ji,{children:"Connector state"}),f.jsx(cn,{children:f.jsx("div",{className:"bg-muted min-h-[70px] cursor-not-allowed overflow-auto rounded-md px-3 py-2 font-mono text-sm whitespace-pre-wrap opacity-70",children:"No state available"})}),f.jsx(Hs,{children:f.jsx(Eme,{})})]}):f.jsx(f.Fragment,{children:o.map(({state:a,index:l})=>{const c=a.at||"",d=c?zH(yRe(c).toISOString()):"—",u=a.state,h=(()=>{try{return JSON.stringify(u,null,2)}catch{return typeof u=="string"?u:'"—"'}})();return f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:`Created at ${d}`,children:`Connector state of configuration #${String(l+1)}`}),f.jsx(cn,{children:f.jsx(eDe,{value:h,displayOnly:!0,className:"bg-muted overflow-auto rounded-md text-sm",minHeightClass:"min-h-0",showCopyButton:!0})}),f.jsx(Hs,{children:f.jsx(Eme,{})})]},a._id)})})})}function Kst({configuration:n,onClose:e,onSubmit:t}){const[i,s]=x.useState(new Set),r=x.useId(),o=Bp({defaultValues:{runType:_w.INCREMENTAL}}),{loading:a,loadingSpecification:l,connectorSpecification:c,fetchConnectorSpecification:d}=US(),{dataMart:u}=og(),h=x.useCallback(async v=>{!i.has(v)&&!l&&(s(C=>new Set(C).add(v)),await d(v))},[i,l,d]);x.useEffect(()=>{n!=null&&n.connector.source.name&&h(n.connector.source.name)},[n,a,h]);const g=v=>{t&&t(v)},m=()=>{e&&e()},b=v=>{if(!v)return"text";switch(v){case mf.DATE:return"date";case mf.NUMBER:return"number";default:return"text"}};return l?f.jsx("div",{children:"Loading..."}):c?f.jsx(CC,{...o,children:f.jsxs(gb,{id:r,noValidate:!0,onSubmit:v=>void o.handleSubmit(g)(v),children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:o.control,name:"runType",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select how you want to load data: incremental updates or full backfill for a period",children:"Run type"}),f.jsx(cn,{children:f.jsxs(f.Fragment,{children:[f.jsx(Yit,{options:[{value:_w.INCREMENTAL,label:"Incremental load"},{value:_w.MANUAL_BACKFILL,label:"Backfill (custom period)"}],value:v.value,onChange:v.onChange,orientation:"horizontal"}),f.jsx(Hs,{children:o.watch("runType")===_w.MANUAL_BACKFILL?"Reloads all data for a specific time range from the source, replacing existing records for that period. Use when you need to correct or update historical data.":"Adds only new or updated records since the last run, using the current state of your Data Mart as a reference. Ideal for keeping data fresh without reloading what`s already there."})]})})]})}),o.watch("runType")===_w.INCREMENTAL&&f.jsx(qst,{configuration:n,connectorState:(u==null?void 0:u.connectorState)??null})]}),o.watch("runType")===_w.MANUAL_BACKFILL&&f.jsx(tc,{title:"Run configuration",children:c.filter(v=>{var C;return(C=v.attributes)==null?void 0:C.includes(xNe.MANUAL_BACKFILL)}).map(v=>f.jsx(fn,{control:o.control,name:`data.${v.name}`,render:()=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:v.description,children:v.title??v.name}),f.jsx(cn,{children:f.jsx(vn,{id:v.name,placeholder:v.description,type:b(v.requiredType),defaultValue:typeof v.default=="string"||typeof v.default=="number"?v.default.toString():void 0,...o.register(`data.${v.name}`,{required:!0})})}),f.jsx(Cn,{})]},v.name)}))})]}),f.jsxs(yC,{children:[f.jsx(rt,{type:"submit",disabled:!o.formState.isValid||l,children:"Run"}),f.jsx(rt,{type:"button",variant:"outline",onClick:m,children:"Cancel"})]})]})}):f.jsx("div",{children:"No connector specification found"})}function Zst({isOpen:n,onClose:e,configuration:t,onSubmit:i}){return f.jsx(ab,{open:n,onOpenChange:e,children:f.jsxs(lb,{children:[f.jsx(cb,{children:f.jsx(db,{children:"Manual Run"})}),f.jsx(Kst,{configuration:t,onClose:e,onSubmit:i})]})})}function JNe({children:n,configuration:e,onManualRun:t,open:i}){const[s,r]=x.useState(i??!1),o=()=>{r(!0)},a=c=>{t(c),r(!1)},l=()=>n?f.jsx("div",{onClick:o,style:{cursor:"pointer"},children:n}):null;return f.jsxs(f.Fragment,{children:[l(),s&&f.jsx(HD,{children:f.jsx(Zst,{isOpen:s,onClose:()=>{r(!1)},configuration:e,onSubmit:a})})]})}const Yst=1e3;function Xst(n,e){const[t,i]=x.useState(!1),[s,r]=x.useState(null),o=x.useRef(null),a=x.useRef(null),l=x.useRef(!0),c=x.useRef(e);c.current=e;const d=x.useCallback(v=>{l.current&&i(v)},[]),u=x.useCallback(v=>{l.current&&r(v)},[]),h=x.useCallback((v,C)=>{const y=v instanceof Error?v.message:"Schema actualization failed";Rn.dismiss(C),u(y),d(!1),o.current=null,a.current=null,Rn.error(y,{duration:void 0,id:C})},[u,d]),g=x.useCallback(async()=>{var C;const v=o.current;if((C=a.current)==null||C.abort(),v){Rn.dismiss(v);try{await hr.abortSchemaActualizeTrigger(n,v)}catch{}}o.current=null,a.current=null,d(!1)},[n,d]),m=x.useCallback(async(v,C)=>{var L;const y=E=>E===Au.SUCCESS||E===Au.ERROR||E===Au.CANCELLED;for(;!C.aborted&&o.current===v;)try{const E=await hr.getSchemaActualizeTriggerStatus(n,v);if(y(E)){try{const R=await hr.getSchemaActualizeTriggerResponse(n,v);if(Rn.dismiss(v),R.success)(L=c.current)==null||L.call(c),Rn.success("Output schema actualized",{duration:void 0,id:v});else{const T=R.error??"Schema actualization failed";u(T),Rn.error(T,{duration:void 0,id:v})}}catch(R){const T=R instanceof Error?R.message:"Schema actualization failed";Rn.dismiss(v),u(T),Rn.error(T,{duration:void 0,id:v})}d(!1),o.current=null,a.current=null;return}await new Promise(R=>setTimeout(R,Yst))}catch(E){h(E,v)}},[n,u,d,h]),b=x.useCallback(async()=>{o.current&&await g(),u(null),d(!0);try{const{triggerId:v}=await hr.createSchemaActualizeTrigger(n);Rn.loading("Synchronizing schema with the data storage state. This may take a while.",{duration:1/0,id:v}),o.current=v;const C=new AbortController;a.current=C;try{await m(v,C.signal)}catch(y){h(y,v)}}catch(v){d(!1),u(v instanceof Error?v.message:"Failed to start schema actualization")}},[n,g,m,u,d,h]);return x.useEffect(()=>(l.current=!0,()=>{var C;l.current=!1;const v=o.current;(C=a.current)==null||C.abort(),v&&(Rn.dismiss(v),hr.abortSchemaActualizeTrigger(n,v).catch(()=>{})),o.current=null,a.current=null}),[n]),{run:b,isLoading:t,cancel:g,error:s}}function Qst({id:n}){const{navigate:e}=hb(),{user:t}=ub(),{flags:i}=EM(),{dataMart:s,deleteDataMart:r,updateDataMartTitle:o,updateDataMartDescription:a,updateDataMartDefinition:l,actualizeDataMartSchema:c,updateDataMartSchema:d,publishDataMart:u,runDataMart:h,cancelDataMartRun:g,getDataMartRuns:m,loadMoreDataMartRuns:b,isLoading:v,error:C,getErrorMessage:y,runs:L,getDataMart:E}=znt(n),[R,T]=x.useState(!1),[N,I]=x.useState(!1),{id:M="",canPublish:P=!1,canActualizeSchema:H=!1,status:j={code:null,displayName:"",description:""},title:V="",definition:W=null,definitionType:U=null,validationErrors:B=[]}=s??{},K=x.useCallback(()=>{M&&E(M)},[M,E]),{run:X,isLoading:ne}=Xst(M,K),fe=x.useCallback(async()=>{H&&await X()},[H,X]),Z=i==null?void 0:i.INSIGHTS_ENABLED_PROJECT_IDS,Y=(t==null?void 0:t.projectId)??"",ee=Y.length>0&&Lit(Z??"").includes(Y),se=[{name:"Overview",path:"overview"},{name:"Data Setup",path:"data-setup"},...ee?[{name:"Insights",path:"insights"}]:[],{name:"Destinations",path:"reports"},{name:"Triggers",path:"triggers"},{name:"Run History",path:"run-history"}],ae=x.useCallback(async Re=>{M&&await o(M,Re)},[M,o]),Se=x.useCallback(async()=>{if(M){I(!0);try{await u(M),fe()}catch(Re){console.log(Re instanceof Error?Re.message:"Failed to publish Data Mart")}finally{I(!1)}}},[M,u,fe]),ue=x.useCallback(async Re=>{if(M){if(j.code!==Ll.PUBLISHED){Sr.error("Manual run is only available for published Data Marts");return}await h({id:M,payload:Re})}},[M,j,h]);return s?f.jsxs("div",{className:"px-12 py-6",children:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center space-x-1 md:-ml-10",children:[f.jsx(OE,{onClick:()=>{e("/data-marts")},variant:"ghost",size:"sm","aria-label":"Back to Data Marts",title:"Back to Data Marts",className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:f.jsx(uHe,{className:"h-5 w-5"})}),f.jsx(SNe,{title:V,onUpdate:ae,className:"text-2xl font-medium"})]}),f.jsxs("div",{className:"flex items-center gap-2"+(N?" opacity-50":""),style:{minWidth:"120px"},children:[f.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsx(kM,{type:j.code===Ll.PUBLISHED?Do.SUCCESS:Do.NEUTRAL,variant:"subtle",children:j.displayName})})}),f.jsx(kn,{children:j.code===Ll.PUBLISHED?"Your published Data Mart is ready for scheduled runs":"Draft Data Mart is not available for scheduled runs. Publish it to activate scheduling."})]}),j.code===Ll.DRAFT&&f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsxs(OE,{variant:"default",onClick:()=>{Se()},disabled:N||!P,className:"ml-2 flex items-center gap-1",children:[f.jsx(sH,{className:"h-4 w-4"}),"Publish Data Mart"]})})}),!P&&f.jsxs(kn,{children:[f.jsx("div",{children:"Cannot publish Data Mart. Fix the issues below."}),B.length>0&&f.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:net(B).map((Re,Ve)=>f.jsx("li",{children:Re},Ve))})]})]})]}),f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(OE,{variant:"ghost",children:f.jsx(XSe,{className:"h-5 w-5"})})}),f.jsxs(Ol,{align:"end",children:[U===Yt.CONNECTOR&&f.jsxs(f.Fragment,{children:[f.jsx(JNe,{configuration:W??null,onManualRun:Re=>{ue({runType:Re.runType,data:Re.data})},children:f.jsxs(wn,{onClick:Re=>{Re.preventDefault()},children:[f.jsx(rH,{className:"text-foreground h-4 w-4"}),f.jsx("span",{children:"Manual Run..."})]})}),f.jsx(Vd,{})]}),f.jsxs(wn,{onClick:()=>{T(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600"}),f.jsx("span",{className:"text-red-600",children:"Delete Data Mart"})]})]})]})]})]}),f.jsx("div",{children:f.jsx("nav",{className:"-mb-px flex space-x-4 border-b","aria-label":"Tabs",role:"tablist",children:se.map(Re=>f.jsx(uM,{to:Re.path,className:({isActive:Ve})=>Le("border-b-2 px-4 py-2 text-sm font-medium whitespace-nowrap",Ve?"border-primary text-primary":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-200 dark:hover:text-gray-200"),children:Re.name},Re.name))})}),f.jsx("div",{className:"pt-4",children:f.jsx(Tne,{context:{dataMart:s,isLoading:v,error:C,getErrorMessage:y,updateDataMartDescription:a,updateDataMartDefinition:l,actualizeDataMartSchema:c,updateDataMartSchema:d,runDataMart:h,cancelDataMartRun:g,getDataMartRuns:m,loadMoreDataMartRuns:b,runs:L,getDataMart:E,runSchemaActualization:fe,isSchemaActualizationLoading:ne}})}),f.jsx(Ma,{open:R,onOpenChange:T,title:"Delete Data Mart",description:f.jsxs(f.Fragment,{children:["Are you sure you want to delete ",f.jsxs("strong",{children:['"',V,'"']}),"? This action cannot be undone."]}),confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{(async()=>{try{await r(M),T(!1),e("/data-marts")}catch(Re){console.error("Failed to delete Data Mart:",Re)}})()}})]}):f.jsxs("div",{className:"dm-page-content flex flex-col gap-4 py-4 md:py-8",children:[f.jsx(bl,{className:"h-16 w-full"},0),Array.from({length:3}).map((Re,Ve)=>f.jsx(bl,{className:"h-48 w-full"},Ve+1))]})}function Jst({description:n,onUpdate:e,className:t,placeholder:i="Add description...",minWidth:s="100%",minHeight:r="100px"}){const[o,a]=x.useState(n??""),[l,c]=x.useState(!1),[d,u]=x.useState(!1),h=x.useRef(null);x.useEffect(()=>{a(n??"")},[n]),x.useEffect(()=>{if(h.current&&l){h.current.focus();const C=h.current.value.length;h.current.setSelectionRange(C,C),g(h.current)}},[l]);const g=C=>{C.style.height="auto",C.style.height=`${String(C.scrollHeight)}px`},m=C=>{a(C.target.value),g(C.target)},b=async()=>{const C=o.trim();if(C===(n??"")){c(!1);return}try{u(!0),await e(C===""?null:C),c(!1)}catch(L){console.error("Failed to update description:",L),a(n??"")}finally{u(!1)}},v=C=>{C.key==="Enter"&&C.ctrlKey?(C.preventDefault(),b()):C.key==="Escape"&&(C.preventDefault(),a(n??""),c(!1))};return l?f.jsxs("div",{className:"w-full",children:[f.jsx(Hp,{ref:h,value:o,onChange:m,onBlur:()=>void b(),onKeyDown:v,placeholder:i,className:Le("m-0 w-full border-0 bg-white p-2 shadow-none dark:bg-white/4","focus-visible:ring-primary focus-visible:ring-0",{"opacity-50":d}),style:{fontSize:"inherit",lineHeight:"inherit",fontFamily:"inherit",resize:"vertical",minHeight:r,minWidth:s},disabled:d}),f.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[f.jsxs("span",{children:["Press"," ",f.jsx("kbd",{className:"rounded border border-neutral-200 bg-neutral-100 px-1 py-0.5 font-sans dark:border-neutral-900 dark:bg-neutral-900",children:"Ctrl+Enter"})," ","to save •"," "]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"rounded border border-neutral-200 bg-neutral-100 px-1 py-0.5 font-sans dark:border-neutral-900 dark:bg-neutral-900",children:"Esc"})," ","to cancel •"," "]}),f.jsx("span",{children:"Changes are also saved when you click outside"})]})]}):f.jsx("div",{className:"flex w-full items-center gap-4 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-sm dark:border-0 dark:bg-white/4",children:f.jsx("div",{onClick:()=>{c(!0)},className:Le("min-h-24 cursor-pointer rounded p-2 whitespace-pre-wrap","transition-colors duration-150",!n&&"text-gray-400 italic",t),style:{minWidth:s},children:n??i})})}function ert(){const{dataMart:n,updateDataMartDescription:e}=Zu(),t=async i=>{await e(n.id,i)};return f.jsx("div",{children:f.jsx(Jst,{description:n.description,onUpdate:t,placeholder:"Add a description for this Data Mart..."})})}function Dme(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function trt(n){if(Array.isArray(n))return n}function irt(n,e,t){return(e=crt(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function nrt(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,s,r,o,a=[],l=!0,c=!1;try{if(r=(t=t.call(n)).next,e!==0)for(;!(l=(i=r.call(t)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(d){c=!0,s=d}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}function srt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
719
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{var i;document.getElementById((i=n.current)==null?void 0:i.getAttribute("aria-describedby"))||console.warn(e)},[e,n]),null},utt=nRe,htt=sRe,ftt=rRe,gtt=oRe,ptt=uRe,mtt=fRe,_tt=lRe,btt=dRe;function vtt({...n}){return f.jsx(utt,{"data-slot":"alert-dialog",...n})}function Ctt({...n}){return f.jsx(htt,{"data-slot":"alert-dialog-portal",...n})}function wtt({className:n,...e}){return f.jsx(ftt,{"data-slot":"alert-dialog-overlay",className:Le("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n),...e})}function ytt({className:n,...e}){return f.jsxs(Ctt,{children:[f.jsx(wtt,{}),f.jsx(gtt,{"data-slot":"alert-dialog-content",className:Le("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",n),...e})]})}function Stt({className:n,...e}){return f.jsx("div",{"data-slot":"alert-dialog-header",className:Le("flex flex-col gap-2 text-center sm:text-left",n),...e})}function xtt({className:n,...e}){return f.jsx("div",{"data-slot":"alert-dialog-footer",className:Le("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n),...e})}function Ltt({className:n,...e}){return f.jsx(_tt,{"data-slot":"alert-dialog-title",className:Le("text-lg font-semibold",n),...e})}function Ett({className:n,...e}){return f.jsx(btt,{"data-slot":"alert-dialog-description",className:Le("text-muted-foreground text-sm",n),...e})}function Dtt({className:n,...e}){return f.jsx(ptt,{className:Le(Hne(),n),...e})}function Rtt({className:n,...e}){return f.jsx(mtt,{className:Le(Hne({variant:"outline"}),n),...e})}const gRe=["facebook","linkedin","tiktok","microsoft","connector","sql","blank"],pRe={facebook:{title:"Facebook Ads",datamartTitle:"Facebook Ads Data Mart",connectorSourceTitle:"FacebookMarketing",definitionType:Yt.CONNECTOR,icon:XZe},linkedin:{title:"LinkedIn Ads",datamartTitle:"LinkedIn Ads Data Mart",connectorSourceTitle:"LinkedInAds",definitionType:Yt.CONNECTOR,icon:QZe},tiktok:{title:"TikTok Ads",datamartTitle:"TikTok Ads Data Mart",connectorSourceTitle:"TikTokAds",definitionType:Yt.CONNECTOR,icon:JZe},microsoft:{title:"Microsoft Ads",datamartTitle:"Microsoft Ads Data Mart",connectorSourceTitle:"MicrosoftAds",definitionType:Yt.CONNECTOR,icon:eYe},connector:{title:"Other connector",datamartTitle:"Connector-based Data Mart",definitionType:Yt.CONNECTOR,icon:Fne},sql:{title:"SQL query",datamartTitle:"SQL-based Data Mart",definitionType:Yt.SQL,icon:Pne},blank:{title:"Blank Data Mart",datamartTitle:"New Data Mart",icon:sF}},sme=gRe.map(n=>({key:n,...pRe[n]}));function Ntt(n){if(!n||!gRe.includes(n))return;const e=n;return{key:e,...pRe[e]}}function Ttt({children:n,className:e="",...t}){return f.jsx("div",{className:"dm-card",children:f.jsx("div",{className:Le("-m-4 flex flex-col items-start justify-between gap-12 overflow-hidden px-8 py-16 lg:flex-row-reverse lg:px-16 lg:py-24 2xl:items-center",e),...t,children:n})})}function Itt({children:n,className:e="",...t}){return f.jsx("div",{className:Le("pb-2",e),...t,children:n})}function ktt({children:n,className:e="",...t}){return f.jsx("h2",{className:Le("mb-6 text-4xl font-semibold xl:text-5xl",e),...t,children:n})}function Att({children:n,className:e="",...t}){return f.jsx("p",{className:Le("text-muted-foreground text-lg",e),...t,children:n})}function Mtt({children:n,rings:e=7,className:t="",...i}){return f.jsxs("div",{className:Le("relative flex w-full justify-center lg:w-[30%] 2xl:w-[35%]",t),...i,children:[f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Array.from({length:e},(s,r)=>{const o=`${(16*(r+1)+24).toString()}vmin`;return f.jsx("div",{className:"animate-ring-pulse",style:{height:o,width:o,animationDelay:`${(r*.3).toString()}s`,animationDuration:"4s",opacity:.2+r*.1,filter:r===0?"blur(1px)":"none"}},r)})}),f.jsx("div",{className:"animate-glow-burst"}),f.jsx("div",{className:"animate-icon-entrance","aria-label":"Illustration",children:n})]})}function Ott({children:n,className:e="",...t}){return f.jsx("div",{className:Le("w-full space-y-8 lg:w-[70%] 2xl:w-[65%]",e),...t,children:n})}function ZU({separator:n=!0,children:e,className:t="",...i}){return f.jsx("section",{className:Le("relative pb-10",n&&"after:from-border after:absolute after:bottom-0 after:left-0 after:h-px after:w-full after:bg-gradient-to-r after:to-transparent",t),...i,children:e})}function rme({children:n,className:e="",...t}){return f.jsx("h3",{className:Le("mb-4 text-xl font-medium",e),...t,children:n})}function YU({children:n,className:e="",...t}){return f.jsx("div",{className:Le("flex flex-wrap items-center gap-4",e),...t,children:n})}function u4({href:n,icon:e,title:t,variant:i="outline",size:s,className:r="",target:o,...a}){const l=i==="outline"?"lg":"sm",c=f.jsxs("span",{className:Le("flex items-center gap-2"),children:[e,t]});return n?f.jsx(rt,{asChild:!0,variant:i,size:s??l,className:Le(i==="ghost"?"text-muted-foreground":"",r),...a,children:f.jsx(Vc,{to:n,target:o,children:c})}):f.jsx(rt,{variant:i,size:s??l,className:r,...a,children:c})}function Ptt(){const{scope:n}=hb(),e=sme.filter(i=>i.definitionType===Yt.CONNECTOR),t=sme.filter(i=>i.definitionType!==Yt.CONNECTOR);return f.jsxs(Ttt,{children:[f.jsx(Mtt,{children:f.jsx(YZe,{className:"animate-icon-entrance","aria-label":"Data Mart creation illustration"})}),f.jsxs(Ott,{children:[f.jsxs(Itt,{children:[f.jsx(ktt,{children:"Let’s Build Your First Data Mart"}),f.jsx(Att,{children:"A Data Mart is the key element of self-service analytics — it provides both control for data analyst and freedom for business users. To get started, connect the source you need or query the data you already have in storage"})]}),f.jsxs(ZU,{children:[f.jsx(rme,{children:"Connect a data source"}),f.jsx(YU,{children:e.map(i=>f.jsx(u4,{href:n(`/data-marts/create?preset=${i.key}`),icon:i.icon&&f.jsx(i.icon,{className:"h-4 w-4"}),title:i.title,variant:"outline"},i.key))})]}),f.jsxs(ZU,{children:[f.jsx(rme,{children:"Use existing SQL or start from scratch"}),f.jsx(YU,{children:t.map((i,s)=>f.jsxs(f.Fragment,{children:[f.jsx(u4,{href:n(`/data-marts/create?preset=${i.key}`),icon:i.icon&&f.jsx(i.icon,{className:"h-4 w-4"}),title:i.title,variant:"outline"},i.key),s<t.length-1&&f.jsx("span",{className:"text-muted-foreground text-sm",children:"or"})]}))})]}),f.jsx(ZU,{separator:!1,children:f.jsxs(YU,{children:[f.jsx(u4,{href:"https://www.youtube.com/playlist?list=PLvcNVLV5BVbHHCekyAZBEIVnlC4i1qcHx",icon:f.jsx(sxe,{className:"h-4 w-4"}),title:"Watch a 2-minute demo",variant:"ghost",target:"_blank"}),f.jsx(u4,{href:"https://docs.owox.com/docs/getting-started/core-concepts/?utm_source=owox_data_marts&utm_medium=empty_data_marts_page&utm_campaign=help_buttons",icon:f.jsx(uBe,{className:"h-4 w-4"}),title:"Core concepts",variant:"ghost",target:"_blank"})]})})]})]})}function Ftt(){return f.jsx(bl,{className:"bg-muted/50 h-72 w-full rounded-md border-b border-gray-200 dark:border-white/10 dark:bg-white/4"})}const Zx={DEFAULT_SORTING_COLUMN:"createdAt",DEFAULT_EXCLUDED_COLUMNS:["actions"],STORAGE_KEYS:{SORTING_SUFFIX:"-sorting",COLUMN_VISIBILITY_SUFFIX:"-column-visibility"}},jtt={extractColumnIds:n=>n.map(e=>{if(e.id)return e.id;if("accessorKey"in e&&typeof e.accessorKey=="string")return e.accessorKey}).filter(e=>e!==void 0)};function zS({columns:n,storageKeyPrefix:e,defaultSortingColumn:t=Zx.DEFAULT_SORTING_COLUMN,defaultColumnVisibility:i={},excludedColumnsFromSorting:s=Zx.DEFAULT_EXCLUDED_COLUMNS,excludedColumnsFromVisibility:r=Zx.DEFAULT_EXCLUDED_COLUMNS}){const o=x.useMemo(()=>({SORTING:`${e}${Zx.STORAGE_KEYS.SORTING_SUFFIX}`,COLUMN_VISIBILITY:`${e}${Zx.STORAGE_KEYS.COLUMN_VISIBILITY_SUFFIX}`}),[e]),a=x.useMemo(()=>jtt.extractColumnIds(n),[n]),l=x.useMemo(()=>a.filter(b=>!s.includes(b)),[a,s]),c=x.useCallback(()=>{const b=np.get(o.SORTING,"json");return b&&Array.isArray(b)&&b.length>0?b:[{id:l.includes(t)?t:l[0]??Zx.DEFAULT_SORTING_COLUMN,desc:!0}]},[o.SORTING,l,t]),d=x.useCallback(()=>{const b=np.get(o.COLUMN_VISIBILITY,"json");if(b&&typeof b=="object"&&!Array.isArray(b)){const v={};for(const C of a)r.includes(C)||(v[C]=b[C]);return v}return i},[o.COLUMN_VISIBILITY,a,r,i]),[u,h]=x.useState(c),[g,m]=x.useState(d);return x.useEffect(()=>{u.length>0&&l.includes(u[0].id)&&np.set(o.SORTING,u)},[u,l,o.SORTING]),x.useEffect(()=>{const b={};for(const v of a){if(r.includes(v))continue;const C=g[v];typeof C=="boolean"&&(b[v]=C)}np.set(o.COLUMN_VISIBILITY,b)},[g,a,r,o.COLUMN_VISIBILITY]),{sorting:u,setSorting:h,columnVisibility:g,setColumnVisibility:m}}function Htt({columns:n,data:e,deleteDataMart:t,refetchDataMarts:i,isLoading:s}){var T;const{navigate:r,scope:o}=hb(),{sorting:a,setSorting:l,columnVisibility:c,setColumnVisibility:d}=zS({columns:n,storageKeyPrefix:"data-mart-list",defaultColumnVisibility:{triggersCount:!1,reportsCount:!1,createdByUser:!1}}),[u,h]=x.useState([]),[g,m]=x.useState({}),[b,v]=x.useState(!1),[C,y]=x.useState(!1),L=async()=>{try{y(!0);const I=R.getSelectedRowModel().rows.map(M=>M.original.id);for(const M of I)await t(M);Sr.success(`Successfully deleted ${String(I.length)} data mart${I.length!==1?"s":""}`),m({}),await i()}catch(N){console.error("Error deleting data marts:",N),Sr.error("Failed to delete some data marts. Please try again.")}finally{y(!1),v(!1)}},E=Object.keys(g).length>0,R=pC({data:e,columns:[{id:"select",size:40,header:({table:N})=>f.jsx("button",{type:"button",role:"checkbox","aria-checked":N.getIsAllRowsSelected(),"data-state":N.getIsAllRowsSelected()?"checked":"unchecked","aria-label":"Select all rows",className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:N.getToggleAllRowsSelectedHandler(),children:N.getIsAllRowsSelected()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),cell:({row:N})=>f.jsx("button",{type:"button",role:"checkbox","aria-checked":N.getIsSelected(),"data-state":N.getIsSelected()?"checked":"unchecked","aria-label":"Select row",className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:N.getToggleSelectedHandler(),children:N.getIsSelected()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),enableSorting:!1,enableHiding:!1},...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:l,getSortedRowModel:WS(),onColumnFiltersChange:h,getFilteredRowModel:HR(),onColumnVisibilityChange:d,onRowSelectionChange:m,state:{sorting:a,columnFilters:u,columnVisibility:c,rowSelection:g},enableRowSelection:!0});return s?f.jsx("div",{children:f.jsx(Ftt,{})}):e.length?f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsxs("div",{className:"dm-card-toolbar-left",children:[E&&f.jsx(rt,{variant:"destructive",size:"sm",className:"dm-card-toolbar-btn-delete",onClick:()=>{v(!0)},disabled:C,children:f.jsx(Wh,{className:"h-4 w-4"})}),f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(T=R.getColumn("title"))==null?void 0:T.getFilterValue(),onChange:N=>{var I;return(I=R.getColumn("title"))==null?void 0:I.setFilterValue(N.target.value)},className:"dm-card-toolbar-search-input"})]})]}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsx(Vc,{to:o("/data-marts/create"),children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Data Mart"]})})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Data Marts table",children:[f.jsx(_C,{className:"dm-card-table-header",children:R.getHeaderGroups().map(N=>f.jsx(qr,{className:"dm-card-table-header-row",children:N.headers.map(I=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:I.column.id==="select"?{width:40,minWidth:40,maxWidth:40}:I.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(I.getSize())}%`},children:I.isPlaceholder?null:jD(I.column.columnDef.header,I.getContext())},I.id))},N.id))}),f.jsx(bC,{className:"dm-card-table-body",children:R.getRowModel().rows.length?R.getRowModel().rows.map(N=>f.jsx(qr,{"data-state":N.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:I=>{if(I.target instanceof HTMLElement&&(I.target.closest('[role="checkbox"]')||I.target.closest(".actions-cell")||I.target.closest('[role="menuitem"]')||I.target.closest('[data-state="open"]')))return;const M=N.original.id;r(`/data-marts/${M}/data-setup`)},children:N.getVisibleCells().map(I=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${I.column.id==="actions"?"actions-cell":""} ${I.column.id==="createdAt"?"whitespace-nowrap":""}`,style:I.column.id==="select"?{width:40,minWidth:40,maxWidth:40}:I.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(I.column.getSize())}%`},children:jD(I.column.columnDef.cell,I.getContext())},I.id))},N.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{R.previousPage()},disabled:!R.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{R.nextPage()},disabled:!R.getCanNextPage(),children:"Next"})]}),f.jsx(vtt,{open:b,onOpenChange:v,children:f.jsxs(ytt,{children:[f.jsxs(Stt,{children:[f.jsx(Ltt,{children:"Are you sure?"}),f.jsxs(Ett,{children:["You're about to delete ",Object.keys(g).length," selected data mart",Object.keys(g).length!==1?"s":"",". This action cannot be undone."]})]}),f.jsxs(xtt,{children:[f.jsx(Rtt,{disabled:C,children:"Cancel"}),f.jsx(Dtt,{onClick:()=>{L()},disabled:C,className:"bg-destructive hover:bg-destructive/90",children:C?"Deleting...":"Delete"})]})]})})]}):f.jsx(Ptt,{})}function mRe({userProjection:n}){const{fullName:e,email:t,avatar:i}=n,s=e??t??"Unknown User",r=fDe(e,t);return f.jsxs(jH,{children:[f.jsx(HH,{asChild:!0,children:f.jsxs("div",{className:"mx-1 inline-flex min-w-max items-center gap-1 rounded-full bg-neutral-100 py-1 pr-3 pl-1 dark:bg-neutral-900",children:[f.jsx(NK,{avatar:i,initials:r,displayName:s,size:AE.SMALL}),f.jsx("span",{className:"text-muted-foreground inline text-sm leading-tight","aria-label":s,children:s})]})}),f.jsx(BH,{side:"top",align:"start",className:"w-max p-3",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(NK,{avatar:i,initials:r,displayName:s,size:AE.LARGE}),f.jsxs("div",{className:"grid text-left text-sm leading-tight",children:[f.jsx("span",{className:"truncate font-medium",children:e??t??"Unknown User"}),t&&f.jsx("span",{className:"text-muted-foreground truncate text-xs",children:t})]})]})})]})}function Vse({...n}){return f.jsx(uH,{"data-slot":"dialog",...n})}function Btt({...n}){return f.jsx(hH,{"data-slot":"dialog-portal",...n})}function Vtt({className:n,...e}){return f.jsx(fH,{"data-slot":"dialog-overlay",className:Le("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n),...e})}function Wse({className:n,children:e,showCloseButton:t=!0,...i}){return f.jsxs(Btt,{"data-slot":"dialog-portal",children:[f.jsx(Vtt,{}),f.jsxs(gH,{"data-slot":"dialog-content",className:Le("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",n),...i,children:[e,t&&f.jsxs(pH,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[f.jsx(ID,{}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function zse({className:n,...e}){return f.jsx("div",{"data-slot":"dialog-header",className:Le("flex flex-col gap-2 text-center sm:text-left",n),...e})}function Wtt({className:n,...e}){return f.jsx("div",{"data-slot":"dialog-footer",className:Le("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n),...e})}function Use({className:n,...e}){return f.jsx(zne,{"data-slot":"dialog-title",className:Le("text-lg leading-none font-semibold",n),...e})}function $se({className:n,...e}){return f.jsx(Une,{"data-slot":"dialog-description",className:Le("text-muted-foreground text-sm",n),...e})}const ztt=RR("",{variants:{variant:{brand:"bg-primary text-white shadow-xs hover:bg-primary-hover focus-visible:ring-brand-blue-200 dark:focus-visible:ring-brand-blue-400"}}});function OE({className:n,variant:e,...t}){return e==="brand"?f.jsx(rt,{variant:"default",className:Le(ztt({variant:e}),n),...t}):f.jsx(rt,{variant:e,className:n,...t})}const Ma=({open:n,onOpenChange:e,title:t,description:i,confirmLabel:s="Confirm",cancelLabel:r,onConfirm:o,onCancel:a,variant:l="destructive",children:c})=>{const d=()=>{e(!1),a==null||a()};return f.jsx(Vse,{open:n,onOpenChange:e,children:f.jsxs(Wse,{children:[f.jsxs(zse,{children:[f.jsx(Use,{children:t}),f.jsx($se,{children:i})]}),c,f.jsxs(Wtt,{children:[r&&f.jsx(OE,{variant:"secondary",onClick:d,children:r}),f.jsx(OE,{variant:l,onClick:o,children:s})]})]})})},Utt=({row:n,onDeleteSuccess:e})=>{const{scope:t}=hb(),[i,s]=x.useState(!1),[r,o]=x.useState(!1),{deleteDataMart:a,refreshList:l}=GDe(),c=async()=>{try{await a(n.original.id),s(!1),await l(),e==null||e()}catch(d){console.error("Failed to delete data mart:",d)}};return f.jsxs("div",{className:"text-right",children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsx(wn,{children:f.jsxs(Vc,{to:t(`/data-marts/${n.original.id}/data-setup`),className:"flex gap-2 text-left",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]})}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>{s(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]}),f.jsx(Ma,{open:i,onOpenChange:s,title:"Delete Data Mart",description:"Are you sure you want to delete this data mart? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>void c(),variant:"destructive"})]})},ome={types:{[Yt.SQL]:{type:Yt.SQL,displayName:"SQL",icon:Pne},[Yt.TABLE]:{type:Yt.TABLE,displayName:"Table",icon:iVe},[Yt.VIEW]:{type:Yt.VIEW,displayName:"View",icon:gBe},[Yt.TABLE_PATTERN]:{type:Yt.TABLE_PATTERN,displayName:"Pattern",icon:vHe},[Yt.CONNECTOR]:{type:Yt.CONNECTOR,displayName:"Connector",icon:Fne}},getInfo(n){return n?this.types[n]:{type:null,displayName:"—",icon:()=>null}}};var Ur=(n=>(n.TITLE="title",n.DEFINITION_TYPE="definitionType",n.STORAGE_TYPE="storageType",n.STATUS="status",n.TRIGGERS_COUNT="triggersCount",n.REPORTS_COUNT="reportsCount",n.CREATED_AT="createdAt",n.CREATED_BY_USER="createdByUser",n))(Ur||{});const Yb={[Ur.TITLE]:"Title",[Ur.DEFINITION_TYPE]:"Input Source",[Ur.STORAGE_TYPE]:"Storage",[Ur.STATUS]:"Status",[Ur.TRIGGERS_COUNT]:"Triggers",[Ur.REPORTS_COUNT]:"Reports",[Ur.CREATED_AT]:"Created at",[Ur.CREATED_BY_USER]:"Created by"};function La({column:n,children:e,label:t}){const i=n.getIsSorted(),s=x.useCallback(()=>{n.toggleSorting(n.getIsSorted()==="asc")},[n]),r=()=>i==="asc"?"sorted ascending":i==="desc"?"sorted descending":"not sorted",o=()=>i==="asc"?"ascending":i==="desc"?"descending":"none",a=t??(typeof e=="string"?e:"Column");return f.jsxs(rt,{variant:"ghost",onClick:s,className:"group dm-card-table-header-row-btn","aria-label":`${a} - ${r()}. Click to sort.`,"aria-sort":o(),children:[e,f.jsxs("span",{className:"flex h-4 w-4 items-center justify-center","aria-hidden":"true",children:[i==="asc"&&f.jsx(TD,{className:"text-foreground h-4 w-4"}),i==="desc"&&f.jsx(Pp,{className:"text-foreground h-4 w-4"}),!i&&f.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:f.jsx(TD,{className:"text-muted-foreground h-4 w-4"})})]})]})}function BR({table:n,getColumnLabel:e}){return f.jsx("div",{className:"text-right",children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn","aria-label":"Toggle columns",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:n.getAllColumns().filter(t=>t.getCanHide()&&t.id!=="actions").map(t=>{var s;const i=(e==null?void 0:e(t.id,t))??((s=t.columnDef.meta)==null?void 0:s.title)??t.id;return f.jsx(wn,{className:"capitalize",children:f.jsxs("label",{className:"flex items-center space-x-2",children:[f.jsx("button",{type:"button",role:"checkbox","aria-checked":t.getIsVisible(),"data-state":t.getIsVisible()?"checked":"unchecked","aria-label":`Toggle column ${i}`,className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:()=>{t.toggleVisibility(!t.getIsVisible())},children:t.getIsVisible()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),f.jsx("span",{children:i})]})},t.id)})})]})})}const $tt=({onDeleteSuccess:n,connectors:e=[]}={})=>[{accessorKey:Ur.TITLE,size:40,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.TITLE]}),cell:({row:t})=>f.jsx("div",{children:t.getValue("title")})},{accessorFn:t=>{const i=t.definitionType;if(i===Yt.CONNECTOR){const s=t.definition,r=e.find(o=>o.name===s.connector.source.name);return(r==null?void 0:r.displayName)??(r==null?void 0:r.name)??"Unknown"}else{const{displayName:s}=ome.getInfo(i);return s}},id:Ur.DEFINITION_TYPE,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.DEFINITION_TYPE]}),cell:({row:t})=>{const i=t.original.definitionType;switch(i){case Yt.CONNECTOR:{const s=t.original.definition,r=e.find(o=>o.name===s.connector.source.name);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[(r==null?void 0:r.logoBase64)&&f.jsx(VS,{base64:r.logoBase64,size:18}),(r==null?void 0:r.displayName)??"Unknown"]})}default:{const{displayName:s,icon:r}=ome.getInfo(i);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(r,{className:"h-4 w-4"}),s]})}}}},{accessorKey:Ur.STORAGE_TYPE,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.STORAGE_TYPE]}),cell:({row:t})=>{const i=t.getValue("storageType"),s=t.original.storageTitle,{displayName:r,icon:o}=fC.getInfo(i),a=s??r;return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),a]})}},{accessorKey:Ur.CREATED_AT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.CREATED_AT]}),cell:({row:t})=>{const i=t.getValue("createdAt"),s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(i);return f.jsx("div",{className:"text-muted-foreground",children:s})}},{id:Ur.CREATED_BY_USER,size:15,accessorFn:t=>{const i=t.createdByUser;return(i==null?void 0:i.fullName)??(i==null?void 0:i.email)},header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.CREATED_BY_USER]}),cell:({row:t})=>{const i=t.original.createdByUser;return i?f.jsx(mRe,{userProjection:i}):f.jsx("div",{className:"text-muted-foreground",children:"—"})}},{accessorKey:Ur.STATUS,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.STATUS]}),cell:({row:t})=>{const i=t.getValue("status");return f.jsx(kM,{type:KJe(i.code),variant:"ghost",showIcon:!1,children:i.displayName})}},{accessorKey:Ur.TRIGGERS_COUNT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.TRIGGERS_COUNT]}),cell:({row:t})=>{const i=t.getValue("triggersCount")>0?t.getValue("triggersCount"):"—";return f.jsx("div",{className:"text-muted-foreground",children:i})}},{accessorKey:Ur.REPORTS_COUNT,size:15,header:({column:t})=>f.jsx(La,{column:t,children:Yb[Ur.REPORTS_COUNT]}),cell:({row:t})=>{const i=t.getValue("reportsCount")>0?t.getValue("reportsCount"):"—";return f.jsx("div",{className:"text-muted-foreground",children:i})}},{id:"actions",size:80,header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(Utt,{row:t,onDeleteSuccess:n})}];var Sa=(n=>(n.FETCH_CONNECTORS_START="FETCH_CONNECTORS_START",n.FETCH_CONNECTORS_SUCCESS="FETCH_CONNECTORS_SUCCESS",n.FETCH_CONNECTORS_ERROR="FETCH_CONNECTORS_ERROR",n.FETCH_CONNECTOR_SPECIFICATION_START="FETCH_CONNECTOR_SPECIFICATION_START",n.FETCH_CONNECTOR_SPECIFICATION_SUCCESS="FETCH_CONNECTOR_SPECIFICATION_SUCCESS",n.FETCH_CONNECTOR_SPECIFICATION_ERROR="FETCH_CONNECTOR_SPECIFICATION_ERROR",n.FETCH_CONNECTOR_FIELDS_START="FETCH_CONNECTOR_FIELDS_START",n.FETCH_CONNECTOR_FIELDS_SUCCESS="FETCH_CONNECTOR_FIELDS_SUCCESS",n.FETCH_CONNECTOR_FIELDS_ERROR="FETCH_CONNECTOR_FIELDS_ERROR",n))(Sa||{});const Gtt={connectors:[],connectorSpecification:null,connectorFields:null,loading:!1,loadingSpecification:!1,loadingFields:!1,error:null};function qtt(n,e){switch(e.type){case Sa.FETCH_CONNECTORS_START:return{...n,loading:!0,error:null};case Sa.FETCH_CONNECTORS_SUCCESS:return{...n,connectors:e.payload,loading:!1,error:null};case Sa.FETCH_CONNECTORS_ERROR:return{...n,loading:!1,error:e.payload};case Sa.FETCH_CONNECTOR_SPECIFICATION_START:return{...n,loadingSpecification:!0,error:null};case Sa.FETCH_CONNECTOR_SPECIFICATION_SUCCESS:return{...n,connectorSpecification:e.payload,loadingSpecification:!1,error:null};case Sa.FETCH_CONNECTOR_SPECIFICATION_ERROR:return{...n,loadingSpecification:!1,error:e.payload};case Sa.FETCH_CONNECTOR_FIELDS_START:return{...n,loadingFields:!0,error:null};case Sa.FETCH_CONNECTOR_FIELDS_SUCCESS:return{...n,connectorFields:e.payload,loadingFields:!1,error:null};case Sa.FETCH_CONNECTOR_FIELDS_ERROR:return{...n,loadingFields:!1,error:e.payload};default:return n}}const _Re=x.createContext(void 0);function HD({children:n}){const[e,t]=x.useReducer(qtt,Gtt);return f.jsx(_Re.Provider,{value:{state:e,dispatch:t},children:n})}function Ktt(){const n=x.useContext(_Re);if(!n)throw new Error("useConnectorContext must be used within a ConnectorContextProvider");return n}var mf=(n=>(n.STRING="string",n.NUMBER="number",n.BOOLEAN="boolean",n.OBJECT="object",n.ARRAY="array",n.DATE="date",n))(mf||{});class kI extends hC{constructor(){super("/connectors")}async getAvailableConnectors(){return this.get("/")}async getConnectorSpecification(e){return this.get(`/${e}/specification`)}async getConnectorFields(e){return this.get(`/${e}/fields`)}async exchangeCredentials(e,t){return this.post(`/${e}/oauth/exchange`,t)}async checkOAuthStatus(e,t){return this.get(`/${e}/oauth/status/${t}`)}async getOAuthSettings(e,t){return this.get(`/${e}/oauth/settings?path=${encodeURIComponent(t)}`)}}function bRe(n){return n.map(e=>({name:e.name,displayName:e.title??e.name,description:e.description??"",logoBase64:e.logo,docUrl:e.docUrl})).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function US(){const{state:n,dispatch:e}=Ktt(),t=x.useMemo(()=>bRe(n.connectors),[n.connectors]),i=x.useCallback(async()=>{e({type:Sa.FETCH_CONNECTORS_START});try{const a=await new kI().getAvailableConnectors();e({type:Sa.FETCH_CONNECTORS_SUCCESS,payload:a})}catch(o){const a=o instanceof Error?o.message:"Unknown error";e({type:Sa.FETCH_CONNECTORS_ERROR,payload:a}),Vt({event:"connector_error",category:"Connector",action:"ListError",label:a})}},[e]),s=x.useCallback(async o=>{e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_START});try{const l=await new kI().getConnectorSpecification(o);e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_SUCCESS,payload:l})}catch(a){const l=a instanceof Error?a.message:"Unknown error";e({type:Sa.FETCH_CONNECTOR_SPECIFICATION_ERROR,payload:l}),Vt({event:"connector_error",category:"Connector",action:"SpecificationError",label:o})}},[e]),r=x.useCallback(async o=>{e({type:Sa.FETCH_CONNECTOR_FIELDS_START});try{const l=await new kI().getConnectorFields(o);e({type:Sa.FETCH_CONNECTOR_FIELDS_SUCCESS,payload:l})}catch(a){const l=a instanceof Error?a.message:"Unknown error";e({type:Sa.FETCH_CONNECTOR_FIELDS_ERROR,payload:l}),Vt({event:"connector_error",category:"Connector",action:"FieldsError",label:o})}},[e]);return{connectors:t,connectorSpecification:n.connectorSpecification,connectorFields:n.connectorFields,loading:n.loading,loadingSpecification:n.loadingSpecification,loadingFields:n.loadingFields,error:n.error,fetchAvailableConnectors:i,fetchConnectorSpecification:s,fetchConnectorFields:r}}const Ztt=()=>{const{items:n,loadDataMarts:e,deleteDataMart:t,refreshList:i,loading:s}=GDe(),{connectors:r,fetchAvailableConnectors:o}=US();return x.useEffect(()=>{o()},[o]),x.useEffect(()=>{e()},[e]),f.jsx(Htt,{columns:$tt({connectors:r}),data:n,deleteDataMart:t,refetchDataMarts:i,isLoading:s})};function ame(){return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Data Marts"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(uQe,{children:f.jsx(HD,{children:f.jsx(Ztt,{})})})})]})}const vRe=x.createContext(void 0),pT=n=>{const e=iet(n);return{...n,canPublish:e.length===0,validationErrors:e}};var Mu=(n=>(n.CONNECTED="CONNECTED",n.CONNECTED_WITH_DEFINITION_MISMATCH="CONNECTED_WITH_DEFINITION_MISMATCH",n.DISCONNECTED="DISCONNECTED",n))(Mu||{}),d2=(n=>(n.NULLABLE="NULLABLE",n.REQUIRED="REQUIRED",n.REPEATED="REPEATED",n))(d2||{}),Ho=(n=>(n.INTEGER="INTEGER",n.FLOAT="FLOAT",n.NUMERIC="NUMERIC",n.BIGNUMERIC="BIGNUMERIC",n.STRING="STRING",n.BYTES="BYTES",n.BOOLEAN="BOOLEAN",n.DATE="DATE",n.TIME="TIME",n.DATETIME="DATETIME",n.TIMESTAMP="TIMESTAMP",n.GEOGRAPHY="GEOGRAPHY",n.JSON="JSON",n.RECORD="RECORD",n.STRUCT="STRUCT",n.RANGE="RANGE",n.INTERVAL="INTERVAL",n))(Ho||{}),Gse=(n=>(n.BOOLEAN="BOOLEAN",n.TINYINT="TINYINT",n.SMALLINT="SMALLINT",n.INTEGER="INTEGER",n.BIGINT="BIGINT",n.REAL="REAL",n.FLOAT="FLOAT",n.DOUBLE="DOUBLE",n.DECIMAL="DECIMAL",n.CHAR="CHAR",n.VARCHAR="VARCHAR",n.STRING="STRING",n.BINARY="BINARY",n.VARBINARY="VARBINARY",n.DATE="DATE",n.TIME="TIME",n.TIMESTAMP="TIMESTAMP",n.TIME_WITH_TIME_ZONE="TIME WITH TIME ZONE",n.TIMESTAMP_WITH_TIME_ZONE="TIMESTAMP WITH TIME ZONE",n.INTERVAL_YEAR_TO_MONTH="INTERVAL YEAR TO MONTH",n.INTERVAL_DAY_TO_SECOND="INTERVAL DAY TO SECOND",n.ARRAY="ARRAY",n.MAP="MAP",n.STRUCT="STRUCT",n.ROW="ROW",n.JSON="JSON",n))(Gse||{}),qse=(n=>(n.NUMBER="NUMBER",n.DECIMAL="DECIMAL",n.NUMERIC="NUMERIC",n.INT="INT",n.INTEGER="INTEGER",n.BIGINT="BIGINT",n.SMALLINT="SMALLINT",n.TINYINT="TINYINT",n.BYTEINT="BYTEINT",n.FLOAT="FLOAT",n.FLOAT4="FLOAT4",n.FLOAT8="FLOAT8",n.DOUBLE="DOUBLE",n.DOUBLE_PRECISION="DOUBLE PRECISION",n.REAL="REAL",n.VARCHAR="VARCHAR",n.CHAR="CHAR",n.CHARACTER="CHARACTER",n.STRING="STRING",n.TEXT="TEXT",n.BINARY="BINARY",n.VARBINARY="VARBINARY",n.BOOLEAN="BOOLEAN",n.DATE="DATE",n.DATETIME="DATETIME",n.TIME="TIME",n.TIMESTAMP="TIMESTAMP",n.TIMESTAMP_LTZ="TIMESTAMP_LTZ",n.TIMESTAMP_NTZ="TIMESTAMP_NTZ",n.TIMESTAMP_TZ="TIMESTAMP_TZ",n.VARIANT="VARIANT",n.OBJECT="OBJECT",n.ARRAY="ARRAY",n.GEOGRAPHY="GEOGRAPHY",n.GEOMETRY="GEOMETRY",n))(qse||{});const Ytt=(n,e)=>n!==Yt.CONNECTOR||e===null?!0:e.fields.some(i=>i.status===Mu.CONNECTED),CRe={dataMart:null,isLoading:!1,error:null,runs:[]};function Xtt(n,e){switch(e.type){case"FETCH_DATA_MART_START":case"CREATE_DATA_MART_START":case"UPDATE_DATA_MART_START":case"UPDATE_DATA_MART_TITLE_START":case"UPDATE_DATA_MART_DESCRIPTION_START":case"UPDATE_DATA_MART_DEFINITION_START":case"DELETE_DATA_MART_START":case"PUBLISH_DATA_MART_START":case"RUN_DATA_MART_START":case"ACTUALIZE_DATA_MART_SCHEMA_START":case"UPDATE_DATA_MART_SCHEMA_START":case"FETCH_DATA_MART_RUNS_START":case"LOAD_MORE_DATA_MART_RUNS_START":return{...n,isLoading:!0,error:null};case"CREATE_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null};case"FETCH_DATA_MART_SUCCESS":case"UPDATE_DATA_MART_SUCCESS":case"PUBLISH_DATA_MART_SUCCESS":case"ACTUALIZE_DATA_MART_SCHEMA_SUCCESS":case"UPDATE_DATA_MART_SCHEMA_SUCCESS":return{...n,isLoading:!1,error:null,dataMart:pT(e.payload)};case"UPDATE_DATA_MART_TITLE_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,title:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_DESCRIPTION_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,description:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_STORAGE":return n.dataMart?{...n,dataMart:pT({...n.dataMart,storage:e.payload,modifiedAt:new Date})}:n;case"UPDATE_DATA_MART_DEFINITION_SUCCESS":return n.dataMart?{...n,isLoading:!1,error:null,dataMart:pT({...n.dataMart,definitionType:e.payload.definitionType,definition:e.payload.definition,modifiedAt:new Date})}:n;case"DELETE_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null,dataMart:null};case"RUN_DATA_MART_SUCCESS":return{...n,isLoading:!1,error:null};case"FETCH_DATA_MART_RUNS_SUCCESS":return{...n,isLoading:!1,error:null,runs:e.payload};case"LOAD_MORE_DATA_MART_RUNS_SUCCESS":return{...n,isLoading:!1,error:null,runs:[...n.runs,...e.payload]};case"FETCH_DATA_MART_ERROR":case"CREATE_DATA_MART_ERROR":case"UPDATE_DATA_MART_ERROR":case"UPDATE_DATA_MART_TITLE_ERROR":case"UPDATE_DATA_MART_DESCRIPTION_ERROR":case"UPDATE_DATA_MART_DEFINITION_ERROR":case"DELETE_DATA_MART_ERROR":case"PUBLISH_DATA_MART_ERROR":case"RUN_DATA_MART_ERROR":case"ACTUALIZE_DATA_MART_SCHEMA_ERROR":case"UPDATE_DATA_MART_SCHEMA_ERROR":case"FETCH_DATA_MART_RUNS_ERROR":case"LOAD_MORE_DATA_MART_RUNS_ERROR":return{...n,isLoading:!1,error:e.payload};case"RESET":return CRe;default:return n}}function og(){const n=x.useContext(vRe);if(n===void 0)throw new Error("useDataMartContext must be used within a DataMartProvider");return n}class Qtt{mapFromDto(e){const t=e.config,i=e.credentials;let s="";return i&&Object.keys(i).length>0&&(s=JSON.stringify(i,null,2)),{id:e.id,title:e.title,type:lt.GOOGLE_BIGQUERY,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:{serviceAccount:s},config:{projectId:(t==null?void 0:t.projectId)??"",location:(t==null?void 0:t.location)??""}}}mapToUpdateRequest(e){const t={config:{projectId:e.config.projectId,location:e.config.location}};return e.credentials&&(t.credentials={...JSON.parse(e.credentials.serviceAccount)}),t}}class Jtt{mapFromDto(e){const t=e.config,i=e.credentials;return{id:e.id,title:e.title,type:lt.AWS_ATHENA,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:{accessKeyId:(i==null?void 0:i.accessKeyId)??"",secretAccessKey:(i==null?void 0:i.secretAccessKey)??""},config:{region:(t==null?void 0:t.region)??"",outputBucket:(t==null?void 0:t.outputBucket)??""}}}mapToUpdateRequest(e){const t={config:{region:e.config.region,outputBucket:e.config.outputBucket}};return e.credentials&&(t.credentials={accessKeyId:e.credentials.accessKeyId,secretAccessKey:e.credentials.secretAccessKey}),t}}class eit{mapFromDto(e){const t=e.config,i=e.credentials,s=i?i.authMethod==="KEY_PAIR"?{authMethod:Tf.KEY_PAIR,username:i.username??"",privateKey:i.privateKey??"",privateKeyPassphrase:i.privateKeyPassphrase}:{authMethod:Tf.PASSWORD,username:i.username??"",password:i.password??""}:void 0;return{id:e.id,title:e.title,type:lt.SNOWFLAKE,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt),credentials:s??{authMethod:Tf.PASSWORD,username:"",password:""},config:t?{account:t.account,warehouse:t.warehouse}:{account:"",warehouse:""}}}mapToUpdateRequest(e){const t={config:{account:e.config.account,warehouse:e.config.warehouse}};if(e.credentials){const i=e.credentials;t.credentials={authMethod:i.authMethod,username:i.username,...i.authMethod===Tf.PASSWORD?{password:i.password}:{privateKey:i.privateKey,privateKeyPassphrase:i.privateKeyPassphrase}}}return t}}const wRe={getMapper(n){switch(n){case lt.GOOGLE_BIGQUERY:return new Qtt;case lt.AWS_ATHENA:return new Jtt;case lt.SNOWFLAKE:return new eit;default:throw new Error(`Unknown storage type: ${n}`)}}};function o5(n){return wRe.getMapper(n.type).mapFromDto(n)}function tit(n){const e=wRe.getMapper(n.type);return{title:n.title,...e.mapToUpdateRequest(n)}}function iit(n){return{id:n.id,type:n.type,title:n.title,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt)}}function nit(n){return{type:n}}let h4=null;async function sit(){if(h4)return h4;const n=await rit();return h4=bRe(n),h4}async function rit(){return await new kI().getAvailableConnectors()}async function oit(n){const e=await sit();return e.length===0?null:e.find(i=>i.name===n)??null}function ait(n,e){const t=e.find(i=>i.name===n.source.name);return(t==null?void 0:t.displayName)??n.source.name}function lit(n){return{sqlQuery:n.sqlQuery}}function cit(n){return{sqlQuery:n.sqlQuery}}function dit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function uit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function hit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function fit(n){return{fullyQualifiedName:n.fullyQualifiedName}}function git(n){return{pattern:n.pattern}}function pit(n){return{pattern:n.pattern}}function mit(n){return{connector:{source:{name:n.connector.source.name,configuration:n.connector.source.configuration,node:n.connector.source.node,fields:n.connector.source.fields},storage:{fullyQualifiedName:n.connector.storage.fullyQualifiedName}}}}function _it(n){const e=n.connector;return{connector:{source:{name:e.source.name,configuration:e.source.configuration,node:e.source.node,fields:e.source.fields},storage:{fullyQualifiedName:e.storage.fullyQualifiedName}}}}async function bit(n,e){if(!n||!e)return null;switch(n){case Yt.SQL:return cit(e);case Yt.TABLE:return uit(e);case Yt.VIEW:return fit(e);case Yt.TABLE_PATTERN:return pit(e);case Yt.CONNECTOR:{const t=_it(e);return t.connector.info=await oit(t.connector.source.name),t}default:return console.warn(`Unknown definition type: ${String(n)}`),null}}async function Yx(n){const e={id:n.id,title:n.title,description:n.description,status:vDe.getInfo(n.status),storage:o5(n.storage),definitionType:n.definitionType,definition:await bit(n.definitionType,n.definition),schema:n.schema,connectorState:n.connectorState??null,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt),canPublish:!1,canActualizeSchema:!1,validationErrors:[]};return e.canActualizeSchema=Ytt(e.definitionType,e.schema),e}function vit(n){return{id:n.id,title:n.title}}const Cit=n=>({id:n.id,status:n.status,createdAt:new Date(n.createdAt),logs:n.logs??[],errors:n.errors??[],definitionRun:n.definitionRun,type:n.type,triggerType:n.runType,startedAt:n.startedAt?new Date(n.startedAt):null,finishedAt:n.finishedAt?new Date(n.finishedAt):null,reportDefinition:n.reportDefinition?n.reportDefinition:null,reportId:n.reportId,insightDefinition:n.insightDefinition??null,insightId:n.insightId,createdByUser:n.createdByUser}),lme=n=>n.runs.map(Cit),zH=n=>{if(!n)return"—";let e;if(typeof n=="string"){if(e=new Date(n),isNaN(e.getTime()))return"—"}else if(e=n,isNaN(e.getTime()))return"—";const i=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),s=new Map(i.map(u=>[u.type,u.value])),r=s.get("year")??"",o=s.get("month")??"",a=s.get("day")??"",l=s.get("hour")??"",c=s.get("minute")??"",d=s.get("second")??"";return`${r}-${o}-${a} ${l}:${c}:${d}`},Xx=n=>zH(yRe(n).toISOString()),yRe=n=>{const e=n.trim();if(e.includes("T")||e.includes("Z")){const s=new Date(e);if(!isNaN(s.getTime()))return s}let t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/.exec(e);if(t)return new Date(Date.UTC(parseInt(t[1],10),parseInt(t[2],10)-1,parseInt(t[3],10),parseInt(t[4],10),parseInt(t[5],10),t[6]?parseInt(t[6],10):0));if(t=/^(\d{1,2})[./](\d{1,2})[./](\d{4})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/.exec(e),t)return new Date(Date.UTC(parseInt(t[3],10),parseInt(t[2],10)-1,parseInt(t[1],10),parseInt(t[4],10),parseInt(t[5],10),t[6]?parseInt(t[6],10):0));const i=new Date(e);return isNaN(i.getTime())?(console.warn(`Failed to parse date string: "${n}", using current date as fallback`),new Date):i},wit=(n,e)=>{const t=e.getTime()-n.getTime(),i=Math.floor(t/1e3),s=Math.floor(i/60),r=Math.floor(s/60),o=s%60,a=i%60,l=[];return r>0&&l.push(`${String(r)} h`),o>0&&l.push(`${String(o)} min`),l.push(`${String(a)} sec`),l.join(" ")};function SRe(n){return JSON.parse(JSON.stringify(n))}function yit(n){if(n===0)return"0 Bytes";const e=1024,t=["Bytes","KB","MB","GB","TB"],i=Math.floor(Math.log(n)/Math.log(e));return`${Number.parseFloat((n/Math.pow(e,i)).toFixed(2)).toString()} ${t[i]}`}const xRe=n=>{try{const e=JSON.parse(n),{project_id:t,client_id:i,client_email:s}=e;return!t||!i||!s?null:{url:`https://console.cloud.google.com/iam-admin/serviceaccounts/details/${i}?project=${t}`,email:s}}catch{return null}};function Sit(n){return n&&n.charAt(0).toUpperCase()+n.slice(1)}function xit(n){return!n||typeof n!="object"?!0:n.LICENSED_APP_EDITION==="COMMUNITY"}const Lit=n=>n?n.split(",").map(e=>e.trim()).filter(Boolean):[];function LRe({children:n}){const[e,t]=x.useReducer(Xtt,CRe),i=x.useCallback(async T=>{try{t({type:"FETCH_DATA_MART_START"});const N=await hr.getDataMartById(T),I=await Yx(N);t({type:"FETCH_DATA_MART_SUCCESS",payload:I})}catch(N){t({type:"FETCH_DATA_MART_ERROR",payload:ys(N)})}},[]),s=x.useCallback(async T=>{try{t({type:"CREATE_DATA_MART_START"});const N=await hr.createDataMart(T),I=vit(N);return t({type:"CREATE_DATA_MART_SUCCESS",payload:I}),Vt({event:"data_mart_created",category:"DataMart",action:"Create",label:I.id}),Rn.success("Data Mart created"),I}catch(N){const I=ys(N);throw t({type:"CREATE_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"CreateError",label:I.message}),N}},[]),r=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_START"});const I=await hr.updateDataMart(T,N),M=await Yx(I);t({type:"UPDATE_DATA_MART_SUCCESS",payload:M}),Vt({event:"data_mart_updated",category:"DataMart",action:"Update",label:M.id})}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateError",label:M.message})}},[]),o=x.useCallback(async T=>{try{t({type:"DELETE_DATA_MART_START"}),await hr.deleteDataMart(T),t({type:"DELETE_DATA_MART_SUCCESS"}),Vt({event:"data_mart_deleted",category:"DataMart",action:"Delete",label:T}),Rn.success("Data Mart deleted")}catch(N){const I=ys(N);t({type:"DELETE_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"DeleteError",label:I.message})}},[]),a=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_TITLE_START"}),await hr.updateDataMartTitle(T,N),t({type:"UPDATE_DATA_MART_TITLE_SUCCESS",payload:N}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateTitle",label:N}),Rn.success("Title updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_TITLE_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateTitleError",label:M.message})}},[]),l=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_DESCRIPTION_START"}),await hr.updateDataMartDescription(T,N),t({type:"UPDATE_DATA_MART_DESCRIPTION_SUCCESS",payload:N??""}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateDescription"}),Rn.success("Description updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_DESCRIPTION_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateDescriptionError",label:M.message})}},[]),c=x.useCallback(T=>{t({type:"UPDATE_DATA_MART_STORAGE",payload:T})},[]),d=x.useCallback(async(T,N,I)=>{try{t({type:"UPDATE_DATA_MART_DEFINITION_START"});let M;switch(N){case Yt.SQL:M={definitionType:N,definition:lit(I)};break;case Yt.TABLE:M={definitionType:N,definition:dit(I)};break;case Yt.VIEW:M={definitionType:N,definition:hit(I)};break;case Yt.TABLE_PATTERN:M={definitionType:N,definition:git(I)};break;case Yt.CONNECTOR:{const j=I;let V;for(const W of j.connector.source.configuration){const U=W;if(U._copiedFrom){V=U._copiedFrom.dataMartId;break}}M={definitionType:Yt.CONNECTOR,definition:mit(j),sourceDataMartId:V};break}default:throw new Error(`Unsupported definition type: ${String(N)}`)}const P=await hr.updateDataMartDefinition(T,M),H=await Yx(P);t({type:"UPDATE_DATA_MART_DEFINITION_SUCCESS",payload:{definitionType:N,definition:I}}),t({type:"UPDATE_DATA_MART_SUCCESS",payload:H}),Vt({event:"data_mart_updated",category:"DataMart",action:"UpdateDefinition",label:N})}catch(M){const P=ys(M);t({type:"UPDATE_DATA_MART_DEFINITION_ERROR",payload:P}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateDefinitionError",label:P.message})}},[]),u=x.useCallback(async T=>{try{t({type:"PUBLISH_DATA_MART_START"});const N=await hr.publishDataMart(T),I=await Yx(N);t({type:"PUBLISH_DATA_MART_SUCCESS",payload:I}),Rn.success("Data Mart published")}catch(N){const I=ys(N);throw t({type:"PUBLISH_DATA_MART_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"PublishError",label:I.message}),N}},[]),h=x.useCallback(async(T,N=5,I=0,M)=>{try{M!=null&&M.silent||t({type:"FETCH_DATA_MART_RUNS_START"});const P=await hr.getDataMartRuns(T,N,I,M!=null&&M.silent?{skipLoadingIndicator:!0}:void 0),H=lme(P);return t({type:"FETCH_DATA_MART_RUNS_SUCCESS",payload:H}),H}catch(P){throw t({type:"FETCH_DATA_MART_RUNS_ERROR",payload:ys(P)}),P}},[]),g=x.useCallback(async(T,N,I=5)=>{try{t({type:"LOAD_MORE_DATA_MART_RUNS_START"});const M=await hr.getDataMartRuns(T,I,N),P=lme(M);return t({type:"LOAD_MORE_DATA_MART_RUNS_SUCCESS",payload:P}),P}catch(M){throw t({type:"LOAD_MORE_DATA_MART_RUNS_ERROR",payload:ys(M)}),M}},[]),m=x.useCallback(async T=>{const N=Rn.loading("Manual run started");try{t({type:"RUN_DATA_MART_START"}),await hr.runDataMart(T.id,T.payload),t({type:"RUN_DATA_MART_SUCCESS"})}catch(I){Rn.dismiss(N);const M=ys(I);t({type:"RUN_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"RunError",label:M.message})}},[]),b=x.useCallback(async(T,N)=>{try{await hr.cancelDataMartRun(T,N),await h(T),Rn.success("Data Mart run canceled")}catch(I){const M=ys(I);t({type:"RUN_DATA_MART_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"CancelRunError",label:M.message})}},[h]),v=x.useCallback(async(T,N)=>{try{return await hr.getDataMartRunById(T,N)}catch(I){const M=ys(I);throw Vt({event:"data_mart_error",category:"DataMart",action:"FetchRunDetailsError",label:M.message}),I}},[]),C=x.useCallback(async T=>{try{t({type:"ACTUALIZE_DATA_MART_SCHEMA_START"});const N=await hr.actualizeDataMartSchema(T),I=await Yx(N);t({type:"ACTUALIZE_DATA_MART_SCHEMA_SUCCESS",payload:I}),Rn.success("Output schema actualized")}catch(N){const I=ys(N);t({type:"ACTUALIZE_DATA_MART_SCHEMA_ERROR",payload:I}),Vt({event:"data_mart_error",category:"DataMart",action:"ActualizeSchemaError",label:I.message})}},[]),y=x.useCallback(async(T,N)=>{try{t({type:"UPDATE_DATA_MART_SCHEMA_START"});const I=await hr.updateDataMartSchema(T,{schema:N}),M=await Yx(I);t({type:"UPDATE_DATA_MART_SCHEMA_SUCCESS",payload:M}),Rn.success("Output schema updated")}catch(I){const M=ys(I);t({type:"UPDATE_DATA_MART_SCHEMA_ERROR",payload:M}),Vt({event:"data_mart_error",category:"DataMart",action:"UpdateSchemaError",label:M.message})}},[]),L=x.useCallback(()=>{t({type:"RESET"})},[]),E=x.useCallback(()=>e.error?e.error.message:null,[e.error]),R={...e,getDataMart:i,createDataMart:s,updateDataMart:r,deleteDataMart:o,updateDataMartTitle:a,updateDataMartDescription:l,updateDataMartStorage:c,updateDataMartDefinition:d,publishDataMart:u,runDataMart:m,cancelDataMartRun:b,actualizeDataMartSchema:C,updateDataMartSchema:y,getDataMartRuns:h,getDataMartRunById:v,loadMoreDataMartRuns:g,getErrorMessage:E,reset:L};return f.jsx(vRe.Provider,{value:R,children:n})}var PM=n=>n.type==="checkbox",oy=n=>n instanceof Date,yd=n=>n==null;const ERe=n=>typeof n=="object";var ha=n=>!yd(n)&&!Array.isArray(n)&&ERe(n)&&!oy(n),DRe=n=>ha(n)&&n.target?PM(n.target)?n.target.checked:n.target.value:n,Eit=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,RRe=(n,e)=>n.has(Eit(e)),Dit=n=>{const e=n.constructor&&n.constructor.prototype;return ha(e)&&e.hasOwnProperty("isPrototypeOf")},Kse=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function wa(n){let e;const t=Array.isArray(n),i=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)e=new Date(n);else if(!(Kse&&(n instanceof Blob||i))&&(t||ha(n)))if(e=t?[]:Object.create(Object.getPrototypeOf(n)),!t&&!Dit(n))e=n;else for(const s in n)n.hasOwnProperty(s)&&(e[s]=wa(n[s]));else return n;return e}var UH=n=>/^\w*$/.test(n),Lo=n=>n===void 0,Zse=n=>Array.isArray(n)?n.filter(Boolean):[],Yse=n=>Zse(n.replace(/["|']|\]/g,"").split(/\.|\[/)),Mt=(n,e,t)=>{if(!e||!ha(n))return t;const i=(UH(e)?[e]:Yse(e)).reduce((s,r)=>yd(s)?s:s[r],n);return Lo(i)||i===n?Lo(n[e])?t:n[e]:i},mu=n=>typeof n=="boolean",Js=(n,e,t)=>{let i=-1;const s=UH(e)?[e]:Yse(e),r=s.length,o=r-1;for(;++i<r;){const a=s[i];let l=t;if(i!==o){const c=n[a];l=ha(c)||Array.isArray(c)?c:isNaN(+s[i+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;n[a]=l,n=n[a]}};const kF={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},xf={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},pm={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Xse=nt.createContext(null);Xse.displayName="HookFormContext";const VR=()=>nt.useContext(Xse),NRe=n=>{const{children:e,...t}=n;return nt.createElement(Xse.Provider,{value:t},e)};var TRe=(n,e,t,i=!0)=>{const s={defaultValues:e._defaultValues};for(const r in n)Object.defineProperty(s,r,{get:()=>{const o=r;return e._proxyFormState[o]!==xf.all&&(e._proxyFormState[o]=!i||xf.all),t&&(t[o]=!0),n[o]}});return s};const Qse=typeof window<"u"?nt.useLayoutEffect:nt.useEffect;function IRe(n){const e=VR(),{control:t=e.control,disabled:i,name:s,exact:r}=n||{},[o,a]=nt.useState(t._formState),l=nt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Qse(()=>t._subscribe({name:s,formState:l.current,exact:r,callback:c=>{!i&&a({...t._formState,...c})}}),[s,i,r]),nt.useEffect(()=>{l.current.isValid&&t._setValid(!0)},[t]),nt.useMemo(()=>TRe(o,t,l.current,!1),[o,t])}var Su=n=>typeof n=="string",OK=(n,e,t,i,s)=>Su(n)?(i&&e.watch.add(n),Mt(t,n,s)):Array.isArray(n)?n.map(r=>(i&&e.watch.add(r),Mt(t,r))):(i&&(e.watchAll=!0),t),PK=n=>yd(n)||!ERe(n);function Lf(n,e,t=new WeakSet){if(PK(n)||PK(e))return Object.is(n,e);if(oy(n)&&oy(e))return n.getTime()===e.getTime();const i=Object.keys(n),s=Object.keys(e);if(i.length!==s.length)return!1;if(t.has(n)||t.has(e))return!0;t.add(n),t.add(e);for(const r of i){const o=n[r];if(!s.includes(r))return!1;if(r!=="ref"){const a=e[r];if(oy(o)&&oy(a)||ha(o)&&ha(a)||Array.isArray(o)&&Array.isArray(a)?!Lf(o,a,t):!Object.is(o,a))return!1}}return!0}function Rit(n){const e=VR(),{control:t=e.control,name:i,defaultValue:s,disabled:r,exact:o,compute:a}=n||{},l=nt.useRef(s),c=nt.useRef(a),d=nt.useRef(void 0),u=nt.useRef(t),h=nt.useRef(i);c.current=a;const[g,m]=nt.useState(()=>{const E=t._getWatch(i,l.current);return c.current?c.current(E):E}),b=nt.useCallback(E=>{const R=OK(i,t._names,E||t._formValues,!1,l.current);return c.current?c.current(R):R},[t._formValues,t._names,i]),v=nt.useCallback(E=>{if(!r){const R=OK(i,t._names,E||t._formValues,!1,l.current);if(c.current){const T=c.current(R);Lf(T,d.current)||(m(T),d.current=T)}else m(R)}},[t._formValues,t._names,r,i]);Qse(()=>((u.current!==t||!Lf(h.current,i))&&(u.current=t,h.current=i,v()),t._subscribe({name:i,formState:{values:!0},exact:o,callback:E=>{v(E.values)}})),[t,o,i,v]),nt.useEffect(()=>t._removeUnmounted());const C=u.current!==t,y=h.current,L=nt.useMemo(()=>{if(r)return null;const E=!C&&!Lf(y,i);return C||E?b():null},[r,C,i,y,b]);return L!==null?L:g}function Nit(n){const e=VR(),{name:t,disabled:i,control:s=e.control,shouldUnregister:r,defaultValue:o,exact:a=!0}=n,l=RRe(s._names.array,t),c=nt.useMemo(()=>Mt(s._formValues,t,Mt(s._defaultValues,t,o)),[s,t,o]),d=Rit({control:s,name:t,defaultValue:c,exact:a}),u=IRe({control:s,name:t,exact:a}),h=nt.useRef(n),g=nt.useRef(void 0),m=nt.useRef(s.register(t,{...n.rules,value:d,...mu(n.disabled)?{disabled:n.disabled}:{}}));h.current=n;const b=nt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Mt(u.errors,t)},isDirty:{enumerable:!0,get:()=>!!Mt(u.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!Mt(u.touchedFields,t)},isValidating:{enumerable:!0,get:()=>!!Mt(u.validatingFields,t)},error:{enumerable:!0,get:()=>Mt(u.errors,t)}}),[u,t]),v=nt.useCallback(E=>m.current.onChange({target:{value:DRe(E),name:t},type:kF.CHANGE}),[t]),C=nt.useCallback(()=>m.current.onBlur({target:{value:Mt(s._formValues,t),name:t},type:kF.BLUR}),[t,s._formValues]),y=nt.useCallback(E=>{const R=Mt(s._fields,t);R&&E&&(R._f.ref={focus:()=>E.focus&&E.focus(),select:()=>E.select&&E.select(),setCustomValidity:T=>E.setCustomValidity(T),reportValidity:()=>E.reportValidity()})},[s._fields,t]),L=nt.useMemo(()=>({name:t,value:d,...mu(i)||u.disabled?{disabled:u.disabled||i}:{},onChange:v,onBlur:C,ref:y}),[t,i,u.disabled,v,C,y,d]);return nt.useEffect(()=>{const E=s._options.shouldUnregister||r,R=g.current;R&&R!==t&&!l&&s.unregister(R),s.register(t,{...h.current.rules,...mu(h.current.disabled)?{disabled:h.current.disabled}:{}});const T=(N,I)=>{const M=Mt(s._fields,N);M&&M._f&&(M._f.mount=I)};if(T(t,!0),E){const N=wa(Mt(s._options.defaultValues,t,h.current.defaultValue));Js(s._defaultValues,t,N),Lo(Mt(s._formValues,t))&&Js(s._formValues,t,N)}return!l&&s.register(t),g.current=t,()=>{(l?E&&!s._state.action:E)?s.unregister(t):T(t,!1)}},[t,s,l,r]),nt.useEffect(()=>{s._setDisabledField({disabled:i,name:t})},[i,t,s]),nt.useMemo(()=>({field:L,formState:u,fieldState:b}),[L,u,b])}const Tit=n=>n.render(Nit(n));var Jse=(n,e,t,i,s)=>e?{...t[n],types:{...t[n]&&t[n].types?t[n].types:{},[i]:s||!0}}:{},AI=n=>Array.isArray(n)?n:[n],cme=()=>{let n=[];return{get observers(){return n},next:s=>{for(const r of n)r.next&&r.next(s)},subscribe:s=>(n.push(s),{unsubscribe:()=>{n=n.filter(r=>r!==s)}}),unsubscribe:()=>{n=[]}}};function kRe(n,e){const t={};for(const i in n)if(n.hasOwnProperty(i)){const s=n[i],r=e[i];if(s&&ha(s)&&r){const o=kRe(s,r);ha(o)&&(t[i]=o)}else n[i]&&(t[i]=r)}return t}var Sc=n=>ha(n)&&!Object.keys(n).length,ere=n=>n.type==="file",Ef=n=>typeof n=="function",AF=n=>{if(!Kse)return!1;const e=n?n.ownerDocument:0;return n instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ARe=n=>n.type==="select-multiple",tre=n=>n.type==="radio",Iit=n=>tre(n)||PM(n),XU=n=>AF(n)&&n.isConnected;function kit(n,e){const t=e.slice(0,-1).length;let i=0;for(;i<t;)n=Lo(n)?i++:n[e[i++]];return n}function Ait(n){for(const e in n)if(n.hasOwnProperty(e)&&!Lo(n[e]))return!1;return!0}function Jo(n,e){const t=Array.isArray(e)?e:UH(e)?[e]:Yse(e),i=t.length===1?n:kit(n,t),s=t.length-1,r=t[s];return i&&delete i[r],s!==0&&(ha(i)&&Sc(i)||Array.isArray(i)&&Ait(i))&&Jo(n,t.slice(0,-1)),n}var Mit=n=>{for(const e in n)if(Ef(n[e]))return!0;return!1};function MRe(n){return Array.isArray(n)||ha(n)&&!Mit(n)}function FK(n,e={}){for(const t in n){const i=n[t];MRe(i)?(e[t]=Array.isArray(i)?[]:{},FK(i,e[t])):Lo(i)||(e[t]=!0)}return e}function NL(n,e,t){t||(t=FK(e));for(const i in n){const s=n[i];if(MRe(s))Lo(e)||PK(t[i])?t[i]=FK(s,Array.isArray(s)?[]:{}):NL(s,yd(e)?{}:e[i],t[i]);else{const r=e[i];t[i]=!Lf(s,r)}}return t}const dme={value:!1,isValid:!1},ume={value:!0,isValid:!0};var ORe=n=>{if(Array.isArray(n)){if(n.length>1){const e=n.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:e,isValid:!!e.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!Lo(n[0].attributes.value)?Lo(n[0].value)||n[0].value===""?ume:{value:n[0].value,isValid:!0}:ume:dme}return dme},PRe=(n,{valueAsNumber:e,valueAsDate:t,setValueAs:i})=>Lo(n)?n:e?n===""?NaN:n&&+n:t&&Su(n)?new Date(n):i?i(n):n;const hme={isValid:!1,value:null};var FRe=n=>Array.isArray(n)?n.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,hme):hme;function fme(n){const e=n.ref;return ere(e)?e.files:tre(e)?FRe(n.refs).value:ARe(e)?[...e.selectedOptions].map(({value:t})=>t):PM(e)?ORe(n.refs).value:PRe(Lo(e.value)?n.ref.value:e.value,n)}var Oit=(n,e,t,i)=>{const s={};for(const r of n){const o=Mt(e,r);o&&Js(s,r,o._f)}return{criteriaMode:t,names:[...n],fields:s,shouldUseNativeValidation:i}},MF=n=>n instanceof RegExp,mT=n=>Lo(n)?n:MF(n)?n.source:ha(n)?MF(n.value)?n.value.source:n.value:n,gme=n=>({isOnSubmit:!n||n===xf.onSubmit,isOnBlur:n===xf.onBlur,isOnChange:n===xf.onChange,isOnAll:n===xf.all,isOnTouch:n===xf.onTouched});const pme="AsyncFunction";var Pit=n=>!!n&&!!n.validate&&!!(Ef(n.validate)&&n.validate.constructor.name===pme||ha(n.validate)&&Object.values(n.validate).find(e=>e.constructor.name===pme)),Fit=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),mme=(n,e,t)=>!t&&(e.watchAll||e.watch.has(n)||[...e.watch].some(i=>n.startsWith(i)&&/^\.\w+/.test(n.slice(i.length))));const MI=(n,e,t,i)=>{for(const s of t||Object.keys(n)){const r=Mt(n,s);if(r){const{_f:o,...a}=r;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!i)return!0;if(o.ref&&e(o.ref,o.name)&&!i)return!0;if(MI(a,e))break}else if(ha(a)&&MI(a,e))break}}};function _me(n,e,t){const i=Mt(n,t);if(i||UH(t))return{error:i,name:t};const s=t.split(".");for(;s.length;){const r=s.join("."),o=Mt(e,r),a=Mt(n,r);if(o&&!Array.isArray(o)&&t!==r)return{name:t};if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};s.pop()}return{name:t}}var jit=(n,e,t,i)=>{t(n);const{name:s,...r}=n;return Sc(r)||Object.keys(r).length>=Object.keys(e).length||Object.keys(r).find(o=>e[o]===(!i||xf.all))},Hit=(n,e,t)=>!n||!e||n===e||AI(n).some(i=>i&&(t?i===e:i.startsWith(e)||e.startsWith(i))),Bit=(n,e,t,i,s)=>s.isOnAll?!1:!t&&s.isOnTouch?!(e||n):(t?i.isOnBlur:s.isOnBlur)?!n:(t?i.isOnChange:s.isOnChange)?n:!0,Vit=(n,e)=>!Zse(Mt(n,e)).length&&Jo(n,e),Wit=(n,e,t)=>{const i=AI(Mt(n,t));return Js(i,"root",e[t]),Js(n,t,i),n};function bme(n,e,t="validate"){if(Su(n)||Array.isArray(n)&&n.every(Su)||mu(n)&&!n)return{type:t,message:Su(n)?n:"",ref:e}}var Qx=n=>ha(n)&&!MF(n)?n:{value:n,message:""},vme=async(n,e,t,i,s,r)=>{const{ref:o,refs:a,required:l,maxLength:c,minLength:d,min:u,max:h,pattern:g,validate:m,name:b,valueAsNumber:v,mount:C}=n._f,y=Mt(t,b);if(!C||e.has(b))return{};const L=a?a[0]:o,E=j=>{s&&L.reportValidity&&(L.setCustomValidity(mu(j)?"":j||""),L.reportValidity())},R={},T=tre(o),N=PM(o),I=T||N,M=(v||ere(o))&&Lo(o.value)&&Lo(y)||AF(o)&&o.value===""||y===""||Array.isArray(y)&&!y.length,P=Jse.bind(null,b,i,R),H=(j,V,W,U=pm.maxLength,B=pm.minLength)=>{const K=j?V:W;R[b]={type:j?U:B,message:K,ref:o,...P(j?U:B,K)}};if(r?!Array.isArray(y)||!y.length:l&&(!I&&(M||yd(y))||mu(y)&&!y||N&&!ORe(a).isValid||T&&!FRe(a).isValid)){const{value:j,message:V}=Su(l)?{value:!!l,message:l}:Qx(l);if(j&&(R[b]={type:pm.required,message:V,ref:L,...P(pm.required,V)},!i))return E(V),R}if(!M&&(!yd(u)||!yd(h))){let j,V;const W=Qx(h),U=Qx(u);if(!yd(y)&&!isNaN(y)){const B=o.valueAsNumber||y&&+y;yd(W.value)||(j=B>W.value),yd(U.value)||(V=B<U.value)}else{const B=o.valueAsDate||new Date(y),K=fe=>new Date(new Date().toDateString()+" "+fe),X=o.type=="time",ne=o.type=="week";Su(W.value)&&y&&(j=X?K(y)>K(W.value):ne?y>W.value:B>new Date(W.value)),Su(U.value)&&y&&(V=X?K(y)<K(U.value):ne?y<U.value:B<new Date(U.value))}if((j||V)&&(H(!!j,W.message,U.message,pm.max,pm.min),!i))return E(R[b].message),R}if((c||d)&&!M&&(Su(y)||r&&Array.isArray(y))){const j=Qx(c),V=Qx(d),W=!yd(j.value)&&y.length>+j.value,U=!yd(V.value)&&y.length<+V.value;if((W||U)&&(H(W,j.message,V.message),!i))return E(R[b].message),R}if(g&&!M&&Su(y)){const{value:j,message:V}=Qx(g);if(MF(j)&&!y.match(j)&&(R[b]={type:pm.pattern,message:V,ref:o,...P(pm.pattern,V)},!i))return E(V),R}if(m){if(Ef(m)){const j=await m(y,t),V=bme(j,L);if(V&&(R[b]={...V,...P(pm.validate,V.message)},!i))return E(V.message),R}else if(ha(m)){let j={};for(const V in m){if(!Sc(j)&&!i)break;const W=bme(await m[V](y,t),L,V);W&&(j={...W,...P(V,W.message)},E(W.message),i&&(R[b]=j))}if(!Sc(j)&&(R[b]={ref:L,...j},!i))return R}}return E(!0),R};const zit={mode:xf.onSubmit,reValidateMode:xf.onChange,shouldFocusError:!0};function Uit(n={}){let e={...zit,...n},t={submitCount:0,isDirty:!1,isReady:!1,isLoading:Ef(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},i={},s=ha(e.defaultValues)||ha(e.values)?wa(e.defaultValues||e.values)||{}:{},r=e.shouldUnregister?{}:wa(s),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let u={...d};const h={array:cme(),state:cme()},g=e.criteriaMode===xf.all,m=oe=>Ce=>{clearTimeout(c),c=setTimeout(oe,Ce)},b=async oe=>{if(!e.disabled&&(d.isValid||u.isValid||oe)){const Ce=e.resolver?Sc((await N()).errors):await M(i,!0);Ce!==t.isValid&&h.state.next({isValid:Ce})}},v=(oe,Ce)=>{!e.disabled&&(d.isValidating||d.validatingFields||u.isValidating||u.validatingFields)&&((oe||Array.from(a.mount)).forEach(je=>{je&&(Ce?Js(t.validatingFields,je,Ce):Jo(t.validatingFields,je))}),h.state.next({validatingFields:t.validatingFields,isValidating:!Sc(t.validatingFields)}))},C=(oe,Ce=[],je,bt,tt=!0,ct=!0)=>{if(bt&&je&&!e.disabled){if(o.action=!0,ct&&Array.isArray(Mt(i,oe))){const $t=je(Mt(i,oe),bt.argA,bt.argB);tt&&Js(i,oe,$t)}if(ct&&Array.isArray(Mt(t.errors,oe))){const $t=je(Mt(t.errors,oe),bt.argA,bt.argB);tt&&Js(t.errors,oe,$t),Vit(t.errors,oe)}if((d.touchedFields||u.touchedFields)&&ct&&Array.isArray(Mt(t.touchedFields,oe))){const $t=je(Mt(t.touchedFields,oe),bt.argA,bt.argB);tt&&Js(t.touchedFields,oe,$t)}(d.dirtyFields||u.dirtyFields)&&(t.dirtyFields=NL(s,r)),h.state.next({name:oe,isDirty:H(oe,Ce),dirtyFields:t.dirtyFields,errors:t.errors,isValid:t.isValid})}else Js(r,oe,Ce)},y=(oe,Ce)=>{Js(t.errors,oe,Ce),h.state.next({errors:t.errors})},L=oe=>{t.errors=oe,h.state.next({errors:t.errors,isValid:!1})},E=(oe,Ce,je,bt)=>{const tt=Mt(i,oe);if(tt){const ct=Mt(r,oe,Lo(je)?Mt(s,oe):je);Lo(ct)||bt&&bt.defaultChecked||Ce?Js(r,oe,Ce?ct:fme(tt._f)):W(oe,ct),o.mount&&!o.action&&b()}},R=(oe,Ce,je,bt,tt)=>{let ct=!1,$t=!1;const yi={name:oe};if(!e.disabled){if(!je||bt){(d.isDirty||u.isDirty)&&($t=t.isDirty,t.isDirty=yi.isDirty=H(),ct=$t!==yi.isDirty);const xi=Lf(Mt(s,oe),Ce);$t=!!Mt(t.dirtyFields,oe),xi?Jo(t.dirtyFields,oe):Js(t.dirtyFields,oe,!0),yi.dirtyFields=t.dirtyFields,ct=ct||(d.dirtyFields||u.dirtyFields)&&$t!==!xi}if(je){const xi=Mt(t.touchedFields,oe);xi||(Js(t.touchedFields,oe,je),yi.touchedFields=t.touchedFields,ct=ct||(d.touchedFields||u.touchedFields)&&xi!==je)}ct&&tt&&h.state.next(yi)}return ct?yi:{}},T=(oe,Ce,je,bt)=>{const tt=Mt(t.errors,oe),ct=(d.isValid||u.isValid)&&mu(Ce)&&t.isValid!==Ce;if(e.delayError&&je?(l=m(()=>y(oe,je)),l(e.delayError)):(clearTimeout(c),l=null,je?Js(t.errors,oe,je):Jo(t.errors,oe)),(je?!Lf(tt,je):tt)||!Sc(bt)||ct){const $t={...bt,...ct&&mu(Ce)?{isValid:Ce}:{},errors:t.errors,name:oe};t={...t,...$t},h.state.next($t)}},N=async oe=>{v(oe,!0);const Ce=await e.resolver(r,e.context,Oit(oe||a.mount,i,e.criteriaMode,e.shouldUseNativeValidation));return v(oe),Ce},I=async oe=>{const{errors:Ce}=await N(oe);if(oe)for(const je of oe){const bt=Mt(Ce,je);bt?Js(t.errors,je,bt):Jo(t.errors,je)}else t.errors=Ce;return Ce},M=async(oe,Ce,je={valid:!0})=>{for(const bt in oe){const tt=oe[bt];if(tt){const{_f:ct,...$t}=tt;if(ct){const yi=a.array.has(ct.name),xi=tt._f&&Pit(tt._f);xi&&d.validatingFields&&v([ct.name],!0);const Nr=await vme(tt,a.disabled,r,g,e.shouldUseNativeValidation&&!Ce,yi);if(xi&&d.validatingFields&&v([ct.name]),Nr[ct.name]&&(je.valid=!1,Ce))break;!Ce&&(Mt(Nr,ct.name)?yi?Wit(t.errors,Nr,ct.name):Js(t.errors,ct.name,Nr[ct.name]):Jo(t.errors,ct.name))}!Sc($t)&&await M($t,Ce,je)}}return je.valid},P=()=>{for(const oe of a.unMount){const Ce=Mt(i,oe);Ce&&(Ce._f.refs?Ce._f.refs.every(je=>!XU(je)):!XU(Ce._f.ref))&&ue(oe)}a.unMount=new Set},H=(oe,Ce)=>!e.disabled&&(oe&&Ce&&Js(r,oe,Ce),!Lf(fe(),s)),j=(oe,Ce,je)=>OK(oe,a,{...o.mount?r:Lo(Ce)?s:Su(oe)?{[oe]:Ce}:Ce},je,Ce),V=oe=>Zse(Mt(o.mount?r:s,oe,e.shouldUnregister?Mt(s,oe,[]):[])),W=(oe,Ce,je={})=>{const bt=Mt(i,oe);let tt=Ce;if(bt){const ct=bt._f;ct&&(!ct.disabled&&Js(r,oe,PRe(Ce,ct)),tt=AF(ct.ref)&&yd(Ce)?"":Ce,ARe(ct.ref)?[...ct.ref.options].forEach($t=>$t.selected=tt.includes($t.value)):ct.refs?PM(ct.ref)?ct.refs.forEach($t=>{(!$t.defaultChecked||!$t.disabled)&&(Array.isArray(tt)?$t.checked=!!tt.find(yi=>yi===$t.value):$t.checked=tt===$t.value||!!tt)}):ct.refs.forEach($t=>$t.checked=$t.value===tt):ere(ct.ref)?ct.ref.value="":(ct.ref.value=tt,ct.ref.type||h.state.next({name:oe,values:wa(r)})))}(je.shouldDirty||je.shouldTouch)&&R(oe,tt,je.shouldTouch,je.shouldDirty,!0),je.shouldValidate&&ne(oe)},U=(oe,Ce,je)=>{for(const bt in Ce){if(!Ce.hasOwnProperty(bt))return;const tt=Ce[bt],ct=oe+"."+bt,$t=Mt(i,ct);(a.array.has(oe)||ha(tt)||$t&&!$t._f)&&!oy(tt)?U(ct,tt,je):W(ct,tt,je)}},B=(oe,Ce,je={})=>{const bt=Mt(i,oe),tt=a.array.has(oe),ct=wa(Ce);Js(r,oe,ct),tt?(h.array.next({name:oe,values:wa(r)}),(d.isDirty||d.dirtyFields||u.isDirty||u.dirtyFields)&&je.shouldDirty&&h.state.next({name:oe,dirtyFields:NL(s,r),isDirty:H(oe,ct)})):bt&&!bt._f&&!yd(ct)?U(oe,ct,je):W(oe,ct,je),mme(oe,a)&&h.state.next({...t,name:oe}),h.state.next({name:o.mount?oe:void 0,values:wa(r)})},K=async oe=>{o.mount=!0;const Ce=oe.target;let je=Ce.name,bt=!0;const tt=Mt(i,je),ct=xi=>{bt=Number.isNaN(xi)||oy(xi)&&isNaN(xi.getTime())||Lf(xi,Mt(r,je,xi))},$t=gme(e.mode),yi=gme(e.reValidateMode);if(tt){let xi,Nr;const Wl=Ce.type?fme(tt._f):DRe(oe),Tr=oe.type===kF.BLUR||oe.type===kF.FOCUS_OUT,Qd=!Fit(tt._f)&&!e.resolver&&!Mt(t.errors,je)&&!tt._f.deps||Bit(Tr,Mt(t.touchedFields,je),t.isSubmitted,yi,$t),Ir=mme(je,a,Tr);Js(r,je,Wl),Tr?(!Ce||!Ce.readOnly)&&(tt._f.onBlur&&tt._f.onBlur(oe),l&&l(0)):tt._f.onChange&&tt._f.onChange(oe);const vs=R(je,Wl,Tr),Kr=!Sc(vs)||Ir;if(!Tr&&h.state.next({name:je,type:oe.type,values:wa(r)}),Qd)return(d.isValid||u.isValid)&&(e.mode==="onBlur"?Tr&&b():Tr||b()),Kr&&h.state.next({name:je,...Ir?{}:vs});if(!Tr&&Ir&&h.state.next({...t}),e.resolver){const{errors:kr}=await N([je]);if(ct(Wl),bt){const Kh=_me(t.errors,i,je),th=_me(kr,i,Kh.name||je);xi=th.error,je=th.name,Nr=Sc(kr)}}else v([je],!0),xi=(await vme(tt,a.disabled,r,g,e.shouldUseNativeValidation))[je],v([je]),ct(Wl),bt&&(xi?Nr=!1:(d.isValid||u.isValid)&&(Nr=await M(i,!0)));bt&&(tt._f.deps&&(!Array.isArray(tt._f.deps)||tt._f.deps.length>0)&&ne(tt._f.deps),T(je,Nr,xi,vs))}},X=(oe,Ce)=>{if(Mt(t.errors,Ce)&&oe.focus)return oe.focus(),1},ne=async(oe,Ce={})=>{let je,bt;const tt=AI(oe);if(e.resolver){const ct=await I(Lo(oe)?oe:tt);je=Sc(ct),bt=oe?!tt.some($t=>Mt(ct,$t)):je}else oe?(bt=(await Promise.all(tt.map(async ct=>{const $t=Mt(i,ct);return await M($t&&$t._f?{[ct]:$t}:$t)}))).every(Boolean),!(!bt&&!t.isValid)&&b()):bt=je=await M(i);return h.state.next({...!Su(oe)||(d.isValid||u.isValid)&&je!==t.isValid?{}:{name:oe},...e.resolver||!oe?{isValid:je}:{},errors:t.errors}),Ce.shouldFocus&&!bt&&MI(i,X,oe?tt:a.mount),bt},fe=(oe,Ce)=>{let je={...o.mount?r:s};return Ce&&(je=kRe(Ce.dirtyFields?t.dirtyFields:t.touchedFields,je)),Lo(oe)?je:Su(oe)?Mt(je,oe):oe.map(bt=>Mt(je,bt))},Z=(oe,Ce)=>({invalid:!!Mt((Ce||t).errors,oe),isDirty:!!Mt((Ce||t).dirtyFields,oe),error:Mt((Ce||t).errors,oe),isValidating:!!Mt(t.validatingFields,oe),isTouched:!!Mt((Ce||t).touchedFields,oe)}),Y=oe=>{oe&&AI(oe).forEach(Ce=>Jo(t.errors,Ce)),h.state.next({errors:oe?t.errors:{}})},ee=(oe,Ce,je)=>{const bt=(Mt(i,oe,{_f:{}})._f||{}).ref,tt=Mt(t.errors,oe)||{},{ref:ct,message:$t,type:yi,...xi}=tt;Js(t.errors,oe,{...xi,...Ce,ref:bt}),h.state.next({name:oe,errors:t.errors,isValid:!1}),je&&je.shouldFocus&&bt&&bt.focus&&bt.focus()},se=(oe,Ce)=>Ef(oe)?h.state.subscribe({next:je=>"values"in je&&oe(j(void 0,Ce),je)}):j(oe,Ce,!0),ae=oe=>h.state.subscribe({next:Ce=>{Hit(oe.name,Ce.name,oe.exact)&&jit(Ce,oe.formState||d,br,oe.reRenderRoot)&&oe.callback({values:{...r},...t,...Ce,defaultValues:s})}}).unsubscribe,Se=oe=>(o.mount=!0,u={...u,...oe.formState},ae({...oe,formState:u})),ue=(oe,Ce={})=>{for(const je of oe?AI(oe):a.mount)a.mount.delete(je),a.array.delete(je),Ce.keepValue||(Jo(i,je),Jo(r,je)),!Ce.keepError&&Jo(t.errors,je),!Ce.keepDirty&&Jo(t.dirtyFields,je),!Ce.keepTouched&&Jo(t.touchedFields,je),!Ce.keepIsValidating&&Jo(t.validatingFields,je),!e.shouldUnregister&&!Ce.keepDefaultValue&&Jo(s,je);h.state.next({values:wa(r)}),h.state.next({...t,...Ce.keepDirty?{isDirty:H()}:{}}),!Ce.keepIsValid&&b()},Re=({disabled:oe,name:Ce})=>{(mu(oe)&&o.mount||oe||a.disabled.has(Ce))&&(oe?a.disabled.add(Ce):a.disabled.delete(Ce))},Ve=(oe,Ce={})=>{let je=Mt(i,oe);const bt=mu(Ce.disabled)||mu(e.disabled);return Js(i,oe,{...je||{},_f:{...je&&je._f?je._f:{ref:{name:oe}},name:oe,mount:!0,...Ce}}),a.mount.add(oe),je?Re({disabled:mu(Ce.disabled)?Ce.disabled:e.disabled,name:oe}):E(oe,!0,Ce.value),{...bt?{disabled:Ce.disabled||e.disabled}:{},...e.progressive?{required:!!Ce.required,min:mT(Ce.min),max:mT(Ce.max),minLength:mT(Ce.minLength),maxLength:mT(Ce.maxLength),pattern:mT(Ce.pattern)}:{},name:oe,onChange:K,onBlur:K,ref:tt=>{if(tt){Ve(oe,Ce),je=Mt(i,oe);const ct=Lo(tt.value)&&tt.querySelectorAll&&tt.querySelectorAll("input,select,textarea")[0]||tt,$t=Iit(ct),yi=je._f.refs||[];if($t?yi.find(xi=>xi===ct):ct===je._f.ref)return;Js(i,oe,{_f:{...je._f,...$t?{refs:[...yi.filter(XU),ct,...Array.isArray(Mt(s,oe))?[{}]:[]],ref:{type:ct.type,name:oe}}:{ref:ct}}}),E(oe,!1,void 0,ct)}else je=Mt(i,oe,{}),je._f&&(je._f.mount=!1),(e.shouldUnregister||Ce.shouldUnregister)&&!(RRe(a.array,oe)&&o.action)&&a.unMount.add(oe)}}},Qe=()=>e.shouldFocusError&&MI(i,X,a.mount),dt=oe=>{mu(oe)&&(h.state.next({disabled:oe}),MI(i,(Ce,je)=>{const bt=Mt(i,je);bt&&(Ce.disabled=bt._f.disabled||oe,Array.isArray(bt._f.refs)&&bt._f.refs.forEach(tt=>{tt.disabled=bt._f.disabled||oe}))},0,!1))},yt=(oe,Ce)=>async je=>{let bt;je&&(je.preventDefault&&je.preventDefault(),je.persist&&je.persist());let tt=wa(r);if(h.state.next({isSubmitting:!0}),e.resolver){const{errors:ct,values:$t}=await N();t.errors=ct,tt=wa($t)}else await M(i);if(a.disabled.size)for(const ct of a.disabled)Jo(tt,ct);if(Jo(t.errors,"root"),Sc(t.errors)){h.state.next({errors:{}});try{await oe(tt,je)}catch(ct){bt=ct}}else Ce&&await Ce({...t.errors},je),Qe(),setTimeout(Qe);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Sc(t.errors)&&!bt,submitCount:t.submitCount+1,errors:t.errors}),bt)throw bt},fi=(oe,Ce={})=>{Mt(i,oe)&&(Lo(Ce.defaultValue)?B(oe,wa(Mt(s,oe))):(B(oe,Ce.defaultValue),Js(s,oe,wa(Ce.defaultValue))),Ce.keepTouched||Jo(t.touchedFields,oe),Ce.keepDirty||(Jo(t.dirtyFields,oe),t.isDirty=Ce.defaultValue?H(oe,wa(Mt(s,oe))):H()),Ce.keepError||(Jo(t.errors,oe),d.isValid&&b()),h.state.next({...t}))},_i=(oe,Ce={})=>{const je=oe?wa(oe):s,bt=wa(je),tt=Sc(oe),ct=tt?s:bt;if(Ce.keepDefaultValues||(s=je),!Ce.keepValues){if(Ce.keepDirtyValues){const $t=new Set([...a.mount,...Object.keys(NL(s,r))]);for(const yi of Array.from($t))Mt(t.dirtyFields,yi)?Js(ct,yi,Mt(r,yi)):B(yi,Mt(ct,yi))}else{if(Kse&&Lo(oe))for(const $t of a.mount){const yi=Mt(i,$t);if(yi&&yi._f){const xi=Array.isArray(yi._f.refs)?yi._f.refs[0]:yi._f.ref;if(AF(xi)){const Nr=xi.closest("form");if(Nr){Nr.reset();break}}}}if(Ce.keepFieldsRef)for(const $t of a.mount)B($t,Mt(ct,$t));else i={}}r=e.shouldUnregister?Ce.keepDefaultValues?wa(s):{}:wa(ct),h.array.next({values:{...ct}}),h.state.next({values:{...ct}})}a={mount:Ce.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!Ce.keepIsValid||!!Ce.keepDirtyValues||!e.shouldUnregister&&!Sc(ct),o.watch=!!e.shouldUnregister,h.state.next({submitCount:Ce.keepSubmitCount?t.submitCount:0,isDirty:tt?!1:Ce.keepDirty?t.isDirty:!!(Ce.keepDefaultValues&&!Lf(oe,s)),isSubmitted:Ce.keepIsSubmitted?t.isSubmitted:!1,dirtyFields:tt?{}:Ce.keepDirtyValues?Ce.keepDefaultValues&&r?NL(s,r):t.dirtyFields:Ce.keepDefaultValues&&oe?NL(s,oe):Ce.keepDirty?t.dirtyFields:{},touchedFields:Ce.keepTouched?t.touchedFields:{},errors:Ce.keepErrors?t.errors:{},isSubmitSuccessful:Ce.keepIsSubmitSuccessful?t.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},Sn=(oe,Ce)=>_i(Ef(oe)?oe(r):oe,Ce),Es=(oe,Ce={})=>{const je=Mt(i,oe),bt=je&&je._f;if(bt){const tt=bt.refs?bt.refs[0]:bt.ref;tt.focus&&(tt.focus(),Ce.shouldSelect&&Ef(tt.select)&&tt.select())}},br=oe=>{t={...t,...oe}},Ht={control:{register:Ve,unregister:ue,getFieldState:Z,handleSubmit:yt,setError:ee,_subscribe:ae,_runSchema:N,_focusError:Qe,_getWatch:j,_getDirty:H,_setValid:b,_setFieldArray:C,_setDisabledField:Re,_setErrors:L,_getFieldArray:V,_reset:_i,_resetDefaultValues:()=>Ef(e.defaultValues)&&e.defaultValues().then(oe=>{Sn(oe,e.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:dt,_subjects:h,_proxyFormState:d,get _fields(){return i},get _formValues(){return r},get _state(){return o},set _state(oe){o=oe},get _defaultValues(){return s},get _names(){return a},set _names(oe){a=oe},get _formState(){return t},get _options(){return e},set _options(oe){e={...e,...oe}}},subscribe:Se,trigger:ne,register:Ve,handleSubmit:yt,watch:se,setValue:B,getValues:fe,reset:Sn,resetField:fi,clearErrors:Y,unregister:ue,setError:ee,setFocus:Es,getFieldState:Z};return{...Ht,formControl:Ht}}function Bp(n={}){const e=nt.useRef(void 0),t=nt.useRef(void 0),[i,s]=nt.useState({isDirty:!1,isValidating:!1,isLoading:Ef(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:Ef(n.defaultValues)?void 0:n.defaultValues});if(!e.current)if(n.formControl)e.current={...n.formControl,formState:i},n.defaultValues&&!Ef(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:o,...a}=Uit(n);e.current={...a,formState:i}}const r=e.current.control;return r._options=n,Qse(()=>{const o=r._subscribe({formState:r._proxyFormState,callback:()=>s({...r._formState}),reRenderRoot:!0});return s(a=>({...a,isReady:!0})),r._formState.isReady=!0,o},[r]),nt.useEffect(()=>r._disableForm(n.disabled),[r,n.disabled]),nt.useEffect(()=>{n.mode&&(r._options.mode=n.mode),n.reValidateMode&&(r._options.reValidateMode=n.reValidateMode)},[r,n.mode,n.reValidateMode]),nt.useEffect(()=>{n.errors&&(r._setErrors(n.errors),r._focusError())},[r,n.errors]),nt.useEffect(()=>{n.shouldUnregister&&r._subjects.state.next({values:r._getWatch()})},[r,n.shouldUnregister]),nt.useEffect(()=>{if(r._proxyFormState.isDirty){const o=r._getDirty();o!==i.isDirty&&r._subjects.state.next({isDirty:o})}},[r,i.isDirty]),nt.useEffect(()=>{var o;n.values&&!Lf(n.values,t.current)?(r._reset(n.values,{keepFieldsRef:!0,...r._options.resetOptions}),!((o=r._options.resetOptions)===null||o===void 0)&&o.keepIsValid||r._setValid(),t.current=n.values,s(a=>({...a}))):r._resetDefaultValues()},[r,n.values]),nt.useEffect(()=>{r._state.mount||(r._setValid(),r._state.mount=!0),r._state.watch&&(r._state.watch=!1,r._subjects.state.next({...r._formState})),r._removeUnmounted()}),e.current.formState=TRe(i,r),e.current}var $it=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Git=$it.reduce((n,e)=>{const t=Ane(`Primitive.${e}`),i=x.forwardRef((s,r)=>{const{asChild:o,...a}=s,l=o?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...a,ref:r})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),qit="Label",jRe=x.forwardRef((n,e)=>f.jsx(Git.label,{...n,ref:e,onMouseDown:t=>{var s;t.target.closest("button, input, select, textarea")||((s=n.onMouseDown)==null||s.call(n,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));jRe.displayName=qit;var Kit=jRe;function Bu({className:n,...e}){return f.jsx(Kit,{"data-slot":"label",className:Le("flex items-center gap-2 text-sm leading-none font-medium group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",n),...e})}const CC=NRe,HRe=x.createContext({}),fn=({...n})=>f.jsx(HRe.Provider,{value:{name:n.name},children:f.jsx(Tit,{...n})}),FM=()=>{const n=x.useContext(HRe),e=x.useContext(BRe),{getFieldState:t}=VR(),i=IRe({name:n.name}),s=t(n.name,i);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:r}=e;return{id:r,name:n.name,formItemId:`${r}-form-item`,formDescriptionId:`${r}-form-item-description`,formMessageId:`${r}-form-item-message`,...s}},BRe=x.createContext({});function tn({className:n="",...e}){const t=x.useId();return f.jsx(BRe.Provider,{value:{id:t},children:f.jsx("div",{"data-slot":"form-item",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",n),...e})})}function Ji({className:n="",tooltip:e,tooltipProps:t,children:i,...s}){const{error:r,formItemId:o}=FM();return f.jsxs(Bu,{"data-slot":"form-label","data-error":!!r,className:Le("text-foreground flex items-center justify-between gap-2 text-sm font-medium","data-[error=true]:text-destructive",n),htmlFor:o,...s,children:[f.jsx("span",{children:i}),e&&f.jsxs(Tn,{...t,children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",tabIndex:-1,className:"pointer-events-none opacity-0 transition group-hover:pointer-events-auto group-hover:opacity-100","aria-label":"Help information",children:f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:e})]})]})}function cn({...n}){const{error:e,formItemId:t,formDescriptionId:i,formMessageId:s}=FM();return f.jsx(hM,{"data-slot":"form-control",id:t,"aria-describedby":e?`${i} ${s}`:`${i}`,"aria-invalid":!!e,...n})}function Hs({className:n,...e}){const{formDescriptionId:t}=FM();return f.jsx("div",{"data-slot":"form-description",id:t,className:Le("text-muted-foreground text-sm",n),...e})}function Cn({className:n,...e}){const{error:t,formMessageId:i}=FM(),s=t?String((t==null?void 0:t.message)??""):e.children;return s?f.jsx("p",{"data-slot":"form-message",id:i,className:Le("text-destructive text-sm",n),...e,children:s}):null}function wC({children:n,className:e="",variant:t="default"}){const i=t==="light"?"flex-1 overflow-y-auto":"bg-muted dark:bg-sidebar flex-1 overflow-y-auto p-4";return f.jsx("div",{className:i,children:f.jsx("div",{className:Le("flex min-h-full flex-col gap-4",e),children:n})})}function yC({className:n="",children:e,variant:t="default"}){const i=t==="light"?"flex flex-col gap-1.5 pt-4":"flex flex-col gap-1.5 border-t px-4 py-3";return f.jsx("div",{className:Le(i,n),children:e})}function tc({title:n,children:e}){return f.jsxs("section",{className:"mb-4",children:[n&&f.jsx("h3",{className:"text-muted-foreground/75 mb-2 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx("div",{className:"flex flex-col gap-2",children:e})]})}function Zit({value:n,label:e,checked:t,onChange:i,disabled:s=!1,orientation:r="vertical",className:o=""}){const{formItemId:a}=FM();return f.jsxs("label",{htmlFor:`${a}-${n}`,className:Le("flex cursor-pointer items-center gap-2 rounded-md py-1 pr-4 pl-2 text-sm",s&&"cursor-not-allowed opacity-50",r==="horizontal"?"flex-row":"flex-col",t?"bg-muted border-input border-b":"hover:bg-muted border-border bg-transparent",o),children:[f.jsx("input",{type:"radio",id:`${a}-${n}`,value:n,checked:t,onChange:i,disabled:s,className:Le("peer border-input ring-offset-background h-4 w-4 rounded-full border","checked:bg-primary checked:border-primary","focus-visible:ring-ring focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50")}),f.jsx("span",{className:Le("peer-disabled:cursor-not-allowed peer-disabled:opacity-50"),children:e})]})}function Yit({options:n,value:e,onChange:t,orientation:i="vertical",className:s=""}){return f.jsx("div",{tabIndex:-1,className:Le(i==="horizontal"?"flex gap-6":"flex flex-col gap-2","border-input rounded-md border bg-transparent px-1 py-1 transition-colors","focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]","text-foreground selection:bg-primary selection:text-primary-foreground","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40","disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",s),children:n.map(r=>f.jsx(Zit,{value:r.value,label:r.label,checked:e===r.value,onChange:o=>t(o.target.value),disabled:r.disabled,orientation:i},r.value))})}const gb=x.forwardRef(({children:n,className:e="",...t},i)=>f.jsx("form",{ref:i,className:Le("flex flex-1 flex-col overflow-hidden",e),...t,children:n}));gb.displayName="AppForm";function Cme(n,[e,t]){return Math.min(t,Math.max(e,n))}function jK(n){const e=Xit(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Jit);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Xit(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=tnt(s),a=ent(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Qit=Symbol("radix.slottable");function Jit(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Qit}function ent(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function tnt(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}function int(n){const e=n+"CollectionProvider",[t,i]=Ha(e),[s,r]=t(e,{collectionRef:{current:null},itemMap:new Map}),o=b=>{const{scope:v,children:C}=b,y=nt.useRef(null),L=nt.useRef(new Map).current;return f.jsx(s,{scope:v,itemMap:L,collectionRef:y,children:C})};o.displayName=e;const a=n+"CollectionSlot",l=jK(a),c=nt.forwardRef((b,v)=>{const{scope:C,children:y}=b,L=r(a,C),E=Ui(v,L.collectionRef);return f.jsx(l,{ref:E,children:y})});c.displayName=a;const d=n+"CollectionItemSlot",u="data-radix-collection-item",h=jK(d),g=nt.forwardRef((b,v)=>{const{scope:C,children:y,...L}=b,E=nt.useRef(null),R=Ui(v,E),T=r(d,C);return nt.useEffect(()=>(T.itemMap.set(E,{ref:E,...L}),()=>void T.itemMap.delete(E))),f.jsx(h,{[u]:"",ref:R,children:y})});g.displayName=d;function m(b){const v=r(n+"CollectionConsumer",b);return nt.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const L=Array.from(y.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((T,N)=>L.indexOf(T.ref.current)-L.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:c,ItemSlot:g},m,i]}function ire(n){const e=x.useRef({value:n,previous:n});return x.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}var nnt=[" ","Enter","ArrowUp","ArrowDown"],snt=[" ","Enter"],Z0="Select",[$H,GH,rnt]=int(Z0),[WR]=Ha(Z0,[rnt,jp]),qH=jp(),[ont,SC]=WR(Z0),[ant,lnt]=WR(Z0),VRe=n=>{const{__scopeSelect:e,children:t,open:i,defaultOpen:s,onOpenChange:r,value:o,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:u,disabled:h,required:g,form:m}=n,b=qH(e),[v,C]=x.useState(null),[y,L]=x.useState(null),[E,R]=x.useState(!1),T=wM(c),[N,I]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:Z0}),[M,P]=zc({prop:o,defaultProp:a,onChange:l,caller:Z0}),H=x.useRef(null),j=v?m||!!v.closest("form"):!0,[V,W]=x.useState(new Set),U=Array.from(V).map(B=>B.props.value).join(";");return f.jsx(OR,{...b,children:f.jsxs(ont,{required:g,scope:e,trigger:v,onTriggerChange:C,valueNode:y,onValueNodeChange:L,valueNodeHasChildren:E,onValueNodeHasChildrenChange:R,contentId:To(),value:M,onValueChange:P,open:N,onOpenChange:I,dir:T,triggerPointerDownPosRef:H,disabled:h,children:[f.jsx($H.Provider,{scope:e,children:f.jsx(ant,{scope:n.__scopeSelect,onNativeOptionAdd:x.useCallback(B=>{W(K=>new Set(K).add(B))},[]),onNativeOptionRemove:x.useCallback(B=>{W(K=>{const X=new Set(K);return X.delete(B),X})},[]),children:t})}),j?f.jsxs(uNe,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:u,value:M,onChange:B=>P(B.target.value),disabled:h,form:m,children:[M===void 0?f.jsx("option",{value:""}):null,Array.from(V)]},U):null]})})};VRe.displayName=Z0;var WRe="SelectTrigger",zRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,disabled:i=!1,...s}=n,r=qH(t),o=SC(WRe,t),a=o.disabled||i,l=Ui(e,o.onTriggerChange),c=GH(t),d=x.useRef("touch"),[u,h,g]=fNe(b=>{const v=c().filter(L=>!L.disabled),C=v.find(L=>L.value===o.value),y=gNe(v,b,C);y!==void 0&&o.onValueChange(y.value)}),m=b=>{a||(o.onOpenChange(!0),g()),b&&(o.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return f.jsx(PR,{asChild:!0,...r,children:f.jsx(ui.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":hNe(o.value)?"":void 0,...s,ref:l,onClick:Lt(s.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&m(b)}),onPointerDown:Lt(s.onPointerDown,b=>{d.current=b.pointerType;const v=b.target;v.hasPointerCapture(b.pointerId)&&v.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(m(b),b.preventDefault())}),onKeyDown:Lt(s.onKeyDown,b=>{const v=u.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&h(b.key),!(v&&b.key===" ")&&nnt.includes(b.key)&&(m(),b.preventDefault())})})})});zRe.displayName=WRe;var URe="SelectValue",$Re=x.forwardRef((n,e)=>{const{__scopeSelect:t,className:i,style:s,children:r,placeholder:o="",...a}=n,l=SC(URe,t),{onValueNodeHasChildrenChange:c}=l,d=r!==void 0,u=Ui(e,l.onValueNodeChange);return Dl(()=>{c(d)},[c,d]),f.jsx(ui.span,{...a,ref:u,style:{pointerEvents:"none"},children:hNe(l.value)?f.jsx(f.Fragment,{children:o}):r})});$Re.displayName=URe;var cnt="SelectIcon",GRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,children:i,...s}=n;return f.jsx(ui.span,{"aria-hidden":!0,...s,ref:e,children:i||"▼"})});GRe.displayName=cnt;var dnt="SelectPortal",qRe=n=>f.jsx(HS,{asChild:!0,...n});qRe.displayName=dnt;var Y0="SelectContent",KRe=x.forwardRef((n,e)=>{const t=SC(Y0,n.__scopeSelect),[i,s]=x.useState();if(Dl(()=>{s(new DocumentFragment)},[]),!t.open){const r=i;return r?Rf.createPortal(f.jsx(ZRe,{scope:n.__scopeSelect,children:f.jsx($H.Slot,{scope:n.__scopeSelect,children:f.jsx("div",{children:n.children})})}),r):null}return f.jsx(YRe,{...n,ref:e})});KRe.displayName=Y0;var sf=10,[ZRe,xC]=WR(Y0),unt="SelectContentImpl",hnt=jK("SelectContent.RemoveScroll"),YRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:r,onPointerDownOutside:o,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:m,hideWhenDetached:b,avoidCollisions:v,...C}=n,y=SC(Y0,t),[L,E]=x.useState(null),[R,T]=x.useState(null),N=Ui(e,ue=>E(ue)),[I,M]=x.useState(null),[P,H]=x.useState(null),j=GH(t),[V,W]=x.useState(!1),U=x.useRef(!1);x.useEffect(()=>{if(L)return cH(L)},[L]),aH();const B=x.useCallback(ue=>{const[Re,...Ve]=j().map(yt=>yt.ref.current),[Qe]=Ve.slice(-1),dt=document.activeElement;for(const yt of ue)if(yt===dt||(yt==null||yt.scrollIntoView({block:"nearest"}),yt===Re&&R&&(R.scrollTop=0),yt===Qe&&R&&(R.scrollTop=R.scrollHeight),yt==null||yt.focus(),document.activeElement!==dt))return},[j,R]),K=x.useCallback(()=>B([I,L]),[B,I,L]);x.useEffect(()=>{V&&K()},[V,K]);const{onOpenChange:X,triggerPointerDownPosRef:ne}=y;x.useEffect(()=>{if(L){let ue={x:0,y:0};const Re=Qe=>{var dt,yt;ue={x:Math.abs(Math.round(Qe.pageX)-(((dt=ne.current)==null?void 0:dt.x)??0)),y:Math.abs(Math.round(Qe.pageY)-(((yt=ne.current)==null?void 0:yt.y)??0))}},Ve=Qe=>{ue.x<=10&&ue.y<=10?Qe.preventDefault():L.contains(Qe.target)||X(!1),document.removeEventListener("pointermove",Re),ne.current=null};return ne.current!==null&&(document.addEventListener("pointermove",Re),document.addEventListener("pointerup",Ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",Ve,{capture:!0})}}},[L,X,ne]),x.useEffect(()=>{const ue=()=>X(!1);return window.addEventListener("blur",ue),window.addEventListener("resize",ue),()=>{window.removeEventListener("blur",ue),window.removeEventListener("resize",ue)}},[X]);const[fe,Z]=fNe(ue=>{const Re=j().filter(dt=>!dt.disabled),Ve=Re.find(dt=>dt.ref.current===document.activeElement),Qe=gNe(Re,ue,Ve);Qe&&setTimeout(()=>Qe.ref.current.focus())}),Y=x.useCallback((ue,Re,Ve)=>{const Qe=!U.current&&!Ve;(y.value!==void 0&&y.value===Re||Qe)&&(M(ue),Qe&&(U.current=!0))},[y.value]),ee=x.useCallback(()=>L==null?void 0:L.focus(),[L]),se=x.useCallback((ue,Re,Ve)=>{const Qe=!U.current&&!Ve;(y.value!==void 0&&y.value===Re||Qe)&&H(ue)},[y.value]),ae=i==="popper"?HK:XRe,Se=ae===HK?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:m,hideWhenDetached:b,avoidCollisions:v}:{};return f.jsx(ZRe,{scope:t,content:L,viewport:R,onViewportChange:T,itemRefCallback:Y,selectedItem:I,onItemLeave:ee,itemTextRefCallback:se,focusSelectedItem:K,selectedItemText:P,position:i,isPositioned:V,searchRef:fe,children:f.jsx(pM,{as:hnt,allowPinchZoom:!0,children:f.jsx(gM,{asChild:!0,trapped:y.open,onMountAutoFocus:ue=>{ue.preventDefault()},onUnmountAutoFocus:Lt(s,ue=>{var Re;(Re=y.trigger)==null||Re.focus({preventScroll:!0}),ue.preventDefault()}),children:f.jsx(jS,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:ue=>ue.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:f.jsx(ae,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ue=>ue.preventDefault(),...C,...Se,onPlaced:()=>W(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:Lt(C.onKeyDown,ue=>{const Re=ue.ctrlKey||ue.altKey||ue.metaKey;if(ue.key==="Tab"&&ue.preventDefault(),!Re&&ue.key.length===1&&Z(ue.key),["ArrowUp","ArrowDown","Home","End"].includes(ue.key)){let Qe=j().filter(dt=>!dt.disabled).map(dt=>dt.ref.current);if(["ArrowUp","End"].includes(ue.key)&&(Qe=Qe.slice().reverse()),["ArrowUp","ArrowDown"].includes(ue.key)){const dt=ue.target,yt=Qe.indexOf(dt);Qe=Qe.slice(yt+1)}setTimeout(()=>B(Qe)),ue.preventDefault()}})})})})})})});YRe.displayName=unt;var fnt="SelectItemAlignedPosition",XRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,onPlaced:i,...s}=n,r=SC(Y0,t),o=xC(Y0,t),[a,l]=x.useState(null),[c,d]=x.useState(null),u=Ui(e,N=>d(N)),h=GH(t),g=x.useRef(!1),m=x.useRef(!0),{viewport:b,selectedItem:v,selectedItemText:C,focusSelectedItem:y}=o,L=x.useCallback(()=>{if(r.trigger&&r.valueNode&&a&&c&&b&&v&&C){const N=r.trigger.getBoundingClientRect(),I=c.getBoundingClientRect(),M=r.valueNode.getBoundingClientRect(),P=C.getBoundingClientRect();if(r.dir!=="rtl"){const dt=P.left-I.left,yt=M.left-dt,fi=N.left-yt,_i=N.width+fi,Sn=Math.max(_i,I.width),Es=window.innerWidth-sf,br=Cme(yt,[sf,Math.max(sf,Es-Sn)]);a.style.minWidth=_i+"px",a.style.left=br+"px"}else{const dt=I.right-P.right,yt=window.innerWidth-M.right-dt,fi=window.innerWidth-N.right-yt,_i=N.width+fi,Sn=Math.max(_i,I.width),Es=window.innerWidth-sf,br=Cme(yt,[sf,Math.max(sf,Es-Sn)]);a.style.minWidth=_i+"px",a.style.right=br+"px"}const H=h(),j=window.innerHeight-sf*2,V=b.scrollHeight,W=window.getComputedStyle(c),U=parseInt(W.borderTopWidth,10),B=parseInt(W.paddingTop,10),K=parseInt(W.borderBottomWidth,10),X=parseInt(W.paddingBottom,10),ne=U+B+V+X+K,fe=Math.min(v.offsetHeight*5,ne),Z=window.getComputedStyle(b),Y=parseInt(Z.paddingTop,10),ee=parseInt(Z.paddingBottom,10),se=N.top+N.height/2-sf,ae=j-se,Se=v.offsetHeight/2,ue=v.offsetTop+Se,Re=U+B+ue,Ve=ne-Re;if(Re<=se){const dt=H.length>0&&v===H[H.length-1].ref.current;a.style.bottom="0px";const yt=c.clientHeight-b.offsetTop-b.offsetHeight,fi=Math.max(ae,Se+(dt?ee:0)+yt+K),_i=Re+fi;a.style.height=_i+"px"}else{const dt=H.length>0&&v===H[0].ref.current;a.style.top="0px";const fi=Math.max(se,U+b.offsetTop+(dt?Y:0)+Se)+Ve;a.style.height=fi+"px",b.scrollTop=Re-se+b.offsetTop}a.style.margin=`${sf}px 0`,a.style.minHeight=fe+"px",a.style.maxHeight=j+"px",i==null||i(),requestAnimationFrame(()=>g.current=!0)}},[h,r.trigger,r.valueNode,a,c,b,v,C,r.dir,i]);Dl(()=>L(),[L]);const[E,R]=x.useState();Dl(()=>{c&&R(window.getComputedStyle(c).zIndex)},[c]);const T=x.useCallback(N=>{N&&m.current===!0&&(L(),y==null||y(),m.current=!1)},[L,y]);return f.jsx(pnt,{scope:t,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:f.jsx(ui.div,{...s,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});XRe.displayName=fnt;var gnt="SelectPopperPosition",HK=x.forwardRef((n,e)=>{const{__scopeSelect:t,align:i="start",collisionPadding:s=sf,...r}=n,o=qH(t);return f.jsx(_M,{...o,...r,ref:e,align:i,collisionPadding:s,style:{boxSizing:"border-box",...r.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});HK.displayName=gnt;var[pnt,nre]=WR(Y0,{}),BK="SelectViewport",QRe=x.forwardRef((n,e)=>{const{__scopeSelect:t,nonce:i,...s}=n,r=xC(BK,t),o=nre(BK,t),a=Ui(e,r.onViewportChange),l=x.useRef(0);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),f.jsx($H.Slot,{scope:t,children:f.jsx(ui.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Lt(s.onScroll,c=>{const d=c.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:h}=o;if(h!=null&&h.current&&u){const g=Math.abs(l.current-d.scrollTop);if(g>0){const m=window.innerHeight-sf*2,b=parseFloat(u.style.minHeight),v=parseFloat(u.style.height),C=Math.max(b,v);if(C<m){const y=C+g,L=Math.min(m,y),E=y-L;u.style.height=L+"px",u.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,u.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});QRe.displayName=BK;var JRe="SelectGroup",[mnt,_nt]=WR(JRe),eNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=To();return f.jsx(mnt,{scope:t,id:s,children:f.jsx(ui.div,{role:"group","aria-labelledby":s,...i,ref:e})})});eNe.displayName=JRe;var tNe="SelectLabel",bnt=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=_nt(tNe,t);return f.jsx(ui.div,{id:s.id,...i,ref:e})});bnt.displayName=tNe;var OF="SelectItem",[vnt,iNe]=WR(OF),nNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,value:i,disabled:s=!1,textValue:r,...o}=n,a=SC(OF,t),l=xC(OF,t),c=a.value===i,[d,u]=x.useState(r??""),[h,g]=x.useState(!1),m=Ui(e,y=>{var L;return(L=l.itemRefCallback)==null?void 0:L.call(l,y,i,s)}),b=To(),v=x.useRef("touch"),C=()=>{s||(a.onValueChange(i),a.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return f.jsx(vnt,{scope:t,value:i,disabled:s,textId:b,isSelected:c,onItemTextChange:x.useCallback(y=>{u(L=>L||((y==null?void 0:y.textContent)??"").trim())},[]),children:f.jsx($H.ItemSlot,{scope:t,value:i,disabled:s,textValue:d,children:f.jsx(ui.div,{role:"option","aria-labelledby":b,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...o,ref:m,onFocus:Lt(o.onFocus,()=>g(!0)),onBlur:Lt(o.onBlur,()=>g(!1)),onClick:Lt(o.onClick,()=>{v.current!=="mouse"&&C()}),onPointerUp:Lt(o.onPointerUp,()=>{v.current==="mouse"&&C()}),onPointerDown:Lt(o.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Lt(o.onPointerMove,y=>{var L;v.current=y.pointerType,s?(L=l.onItemLeave)==null||L.call(l):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,y=>{var L;y.currentTarget===document.activeElement&&((L=l.onItemLeave)==null||L.call(l))}),onKeyDown:Lt(o.onKeyDown,y=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&y.key===" "||(snt.includes(y.key)&&C(),y.key===" "&&y.preventDefault())})})})})});nNe.displayName=OF;var aI="SelectItemText",sNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,className:i,style:s,...r}=n,o=SC(aI,t),a=xC(aI,t),l=iNe(aI,t),c=lnt(aI,t),[d,u]=x.useState(null),h=Ui(e,C=>u(C),l.onItemTextChange,C=>{var y;return(y=a.itemTextRefCallback)==null?void 0:y.call(a,C,l.value,l.disabled)}),g=d==null?void 0:d.textContent,m=x.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:g},l.value),[l.disabled,l.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:v}=c;return Dl(()=>(b(m),()=>v(m)),[b,v,m]),f.jsxs(f.Fragment,{children:[f.jsx(ui.span,{id:l.textId,...r,ref:h}),l.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Rf.createPortal(r.children,o.valueNode):null]})});sNe.displayName=aI;var rNe="SelectItemIndicator",oNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n;return iNe(rNe,t).isSelected?f.jsx(ui.span,{"aria-hidden":!0,...i,ref:e}):null});oNe.displayName=rNe;var VK="SelectScrollUpButton",aNe=x.forwardRef((n,e)=>{const t=xC(VK,n.__scopeSelect),i=nre(VK,n.__scopeSelect),[s,r]=x.useState(!1),o=Ui(e,i.onScrollButtonChange);return Dl(()=>{if(t.viewport&&t.isPositioned){let a=function(){const c=l.scrollTop>0;r(c)};const l=t.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[t.viewport,t.isPositioned]),s?f.jsx(cNe,{...n,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=t;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});aNe.displayName=VK;var WK="SelectScrollDownButton",lNe=x.forwardRef((n,e)=>{const t=xC(WK,n.__scopeSelect),i=nre(WK,n.__scopeSelect),[s,r]=x.useState(!1),o=Ui(e,i.onScrollButtonChange);return Dl(()=>{if(t.viewport&&t.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;r(d)};const l=t.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[t.viewport,t.isPositioned]),s?f.jsx(cNe,{...n,ref:o,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=t;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});lNe.displayName=WK;var cNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,onAutoScroll:i,...s}=n,r=xC("SelectScrollButton",t),o=x.useRef(null),a=GH(t),l=x.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return x.useEffect(()=>()=>l(),[l]),Dl(()=>{var d;const c=a().find(u=>u.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),f.jsx(ui.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Lt(s.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(i,50))}),onPointerMove:Lt(s.onPointerMove,()=>{var c;(c=r.onItemLeave)==null||c.call(r),o.current===null&&(o.current=window.setInterval(i,50))}),onPointerLeave:Lt(s.onPointerLeave,()=>{l()})})}),Cnt="SelectSeparator",dNe=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n;return f.jsx(ui.div,{"aria-hidden":!0,...i,ref:e})});dNe.displayName=Cnt;var zK="SelectArrow",wnt=x.forwardRef((n,e)=>{const{__scopeSelect:t,...i}=n,s=qH(t),r=SC(zK,t),o=xC(zK,t);return r.open&&o.position==="popper"?f.jsx(bM,{...s,...i,ref:e}):null});wnt.displayName=zK;var ynt="SelectBubbleInput",uNe=x.forwardRef(({__scopeSelect:n,value:e,...t},i)=>{const s=x.useRef(null),r=Ui(i,s),o=ire(e);return x.useEffect(()=>{const a=s.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==e&&d){const u=new Event("change",{bubbles:!0});d.call(a,e),a.dispatchEvent(u)}},[o,e]),f.jsx(ui.select,{...t,style:{..._Le,...t.style},ref:r,defaultValue:e})});uNe.displayName=ynt;function hNe(n){return n===""||n===void 0}function fNe(n){const e=Vf(n),t=x.useRef(""),i=x.useRef(0),s=x.useCallback(o=>{const a=t.current+o;e(a),(function l(c){t.current=c,window.clearTimeout(i.current),c!==""&&(i.current=window.setTimeout(()=>l(""),1e3))})(a)},[e]),r=x.useCallback(()=>{t.current="",window.clearTimeout(i.current)},[]);return x.useEffect(()=>()=>window.clearTimeout(i.current),[]),[t,s,r]}function gNe(n,e,t){const s=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,r=t?n.indexOf(t):-1;let o=Snt(n,Math.max(r,0));s.length===1&&(o=o.filter(c=>c!==t));const l=o.find(c=>c.textValue.toLowerCase().startsWith(s.toLowerCase()));return l!==t?l:void 0}function Snt(n,e){return n.map((t,i)=>n[(e+i)%n.length])}var xnt=VRe,Lnt=zRe,Ent=$Re,Dnt=GRe,Rnt=qRe,Nnt=KRe,Tnt=QRe,Int=eNe,knt=nNe,Ant=sNe,Mnt=oNe,Ont=aNe,Pnt=lNe,Fnt=dNe;function $c({...n}){return f.jsx(xnt,{"data-slot":"select",...n})}function KH({...n}){return f.jsx(Int,{"data-slot":"select-group",...n})}function Gc({...n}){return f.jsx(Ent,{"data-slot":"select-value",...n})}function qc({className:n,size:e="default",children:t,...i}){return f.jsxs(Lnt,{"data-slot":"select-trigger","data-size":e,className:Le("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...i,children:[t,f.jsx(Dnt,{asChild:!0,children:f.jsx(Pp,{className:"size-4 opacity-50"})})]})}function Kc({className:n,children:e,position:t="popper",...i}){return f.jsx(Rnt,{children:f.jsxs(Nnt,{"data-slot":"select-content",className:Le("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:t,...i,children:[f.jsx(Hnt,{}),f.jsx(Tnt,{className:Le("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),f.jsx(Bnt,{})]})})}function fo({className:n,children:e,...t}){return f.jsxs(knt,{"data-slot":"select-item",className:Le("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",n),...t,children:[f.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:f.jsx(Mnt,{children:f.jsx(Wc,{className:"size-4"})})}),f.jsx(Ant,{children:e})]})}function jnt({className:n,...e}){return f.jsx(Fnt,{"data-slot":"select-separator",className:Le("bg-border pointer-events-none -mx-1 my-1 h-px",n),...e})}function Hnt({className:n,...e}){return f.jsx(Ont,{"data-slot":"select-scroll-up-button",className:Le("flex cursor-default items-center justify-center py-1",n),...e,children:f.jsx(TD,{className:"size-4"})})}function Bnt({className:n,...e}){return f.jsx(Pnt,{"data-slot":"select-scroll-down-button",className:Le("flex cursor-default items-center justify-center py-1",n),...e,children:f.jsx(Pp,{className:"size-4"})})}const Vnt=_s({title:pn().min(1,"Title is required").max(100,"Title must be less than 100 characters"),storageId:pn().min(1,"Storage is required")});function Wnt(){const{createDataMart:n,isLoading:e,error:t}=og();return{handleCreate:x.useCallback(async s=>{try{return await n(s)}catch(r){return console.error(r),null}},[n]),isSubmitting:e,serverError:t}}function znt(n){const{getDataMart:e,deleteDataMart:t,updateDataMartTitle:i,updateDataMartDescription:s,updateDataMartDefinition:r,updateDataMartSchema:o,actualizeDataMartSchema:a,publishDataMart:l,runDataMart:c,cancelDataMartRun:d,getDataMartRuns:u,loadMoreDataMartRuns:h,reset:g,dataMart:m,isLoading:b,error:v,getErrorMessage:C,runs:y}=og();return x.useEffect(()=>(n?e(n):g(),()=>{g()}),[n,e,g]),{dataMart:m,isLoading:b,error:v,getErrorMessage:C,deleteDataMart:t,updateDataMartTitle:i,updateDataMartDescription:s,updateDataMartDefinition:r,updateDataMartSchema:o,actualizeDataMartSchema:a,publishDataMart:l,runDataMart:c,cancelDataMartRun:d,getDataMartRuns:u,loadMoreDataMartRuns:h,runs:y,getDataMart:e}}const wme=(n,e,t)=>{if(n&&"reportValidity"in n){const i=Mt(t,e);n.setCustomValidity(i&&i.message||""),n.reportValidity()}},UK=(n,e)=>{for(const t in e.fields){const i=e.fields[t];i&&i.ref&&"reportValidity"in i.ref?wme(i.ref,t,n):i&&i.refs&&i.refs.forEach(s=>wme(s,t,n))}},yme=(n,e)=>{e.shouldUseNativeValidation&&UK(n,e);const t={};for(const i in n){const s=Mt(e.fields,i),r=Object.assign(n[i]||{},{ref:s&&s.ref});if(Unt(e.names||Object.keys(n),i)){const o=Object.assign({},Mt(t,i));Js(o,"root",r),Js(t,i,o)}else Js(t,i,r)}return t},Unt=(n,e)=>{const t=Sme(e);return n.some(i=>Sme(i).match(`^${t}\\.\\d+`))};function Sme(n){return n.replace(/\]|\[/g,"")}function pNe(n,e,t){function i(a,l){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(n),e(a,l);for(const d in o.prototype)d in a||Object.defineProperty(a,d,{value:o.prototype[d].bind(a)});a._zod.constr=o,a._zod.def=l}const s=(t==null?void 0:t.Parent)??Object;class r extends s{}Object.defineProperty(r,"name",{value:n});function o(a){var l;const c=t!=null&&t.Parent?new r:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(n)}}),Object.defineProperty(o,"name",{value:n}),o}class $nt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Gnt={};function mNe(n){return Gnt}function qnt(n,e){return typeof e=="bigint"?e.toString():e}const _Ne=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};function f4(n){return typeof n=="string"?n:n==null?void 0:n.message}function bNe(n,e,t){var s,r,o,a,l,c;const i={...n,path:n.path??[]};if(!n.message){const d=f4((o=(r=(s=n.inst)==null?void 0:s._zod.def)==null?void 0:r.error)==null?void 0:o.call(r,n))??f4((a=e==null?void 0:e.error)==null?void 0:a.call(e,n))??f4((l=t.customError)==null?void 0:l.call(t,n))??f4((c=t.localeError)==null?void 0:c.call(t,n))??"Invalid input";i.message=d}return delete i.inst,delete i.continue,e!=null&&e.reportInput||delete i.input,i}const vNe=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(e,qnt,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Knt=pNe("$ZodError",vNe),CNe=pNe("$ZodError",vNe,{Parent:Error}),Znt=n=>(e,t,i,s)=>{const r=i?Object.assign(i,{async:!1}):{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new $nt;if(o.issues.length){const a=new((s==null?void 0:s.Err)??n)(o.issues.map(l=>bNe(l,r,mNe())));throw _Ne(a,s==null?void 0:s.callee),a}return o.value},Ynt=Znt(CNe),Xnt=n=>async(e,t,i,s)=>{const r=i?Object.assign(i,{async:!0}):{async:!0};let o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??n)(o.issues.map(l=>bNe(l,r,mNe())));throw _Ne(a,s==null?void 0:s.callee),a}return o.value},Qnt=Xnt(CNe);function xme(n,e){try{var t=n()}catch(i){return e(i)}return t&&t.then?t.then(void 0,e):t}function Jnt(n,e){for(var t={};n.length;){var i=n[0],s=i.code,r=i.message,o=i.path.join(".");if(!t[o])if("unionErrors"in i){var a=i.unionErrors[0].errors[0];t[o]={message:a.message,type:a.code}}else t[o]={message:r,type:s};if("unionErrors"in i&&i.unionErrors.forEach(function(d){return d.errors.forEach(function(u){return n.push(u)})}),e){var l=t[o].types,c=l&&l[i.code];t[o]=Jse(o,e,t,s,c?[].concat(c,i.message):i.message)}n.shift()}return t}function est(n,e){for(var t={};n.length;){var i=n[0],s=i.code,r=i.message,o=i.path.join(".");if(!t[o])if(i.code==="invalid_union"&&i.errors.length>0){var a=i.errors[0][0];t[o]={message:a.message,type:a.code}}else t[o]={message:r,type:s};if(i.code==="invalid_union"&&i.errors.forEach(function(d){return d.forEach(function(u){return n.push(u)})}),e){var l=t[o].types,c=l&&l[i.code];t[o]=Jse(o,e,t,s,c?[].concat(c,i.message):i.message)}n.shift()}return t}function pb(n,e,t){if(t===void 0&&(t={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(n))return function(i,s,r){try{return Promise.resolve(xme(function(){return Promise.resolve(n[t.mode==="sync"?"parse":"parseAsync"](i,e)).then(function(o){return r.shouldUseNativeValidation&&UK({},r),{errors:{},values:t.raw?Object.assign({},i):o}})},function(o){if((function(a){return Array.isArray(a==null?void 0:a.issues)})(o))return{values:{},errors:yme(Jnt(o.errors,!r.shouldUseNativeValidation&&r.criteriaMode==="all"),r)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(n))return function(i,s,r){try{return Promise.resolve(xme(function(){return Promise.resolve((t.mode==="sync"?Ynt:Qnt)(n,i,e)).then(function(o){return r.shouldUseNativeValidation&&UK({},r),{errors:{},values:t.raw?Object.assign({},i):o}})},function(o){if((function(a){return a instanceof Knt})(o))return{values:{},errors:yme(est(o.issues,!r.shouldUseNativeValidation&&r.criteriaMode==="all"),r)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const wNe=x.createContext(void 0);function tst(){const n=x.useContext(wNe);if(n===void 0)throw new Error("useDataStorageContext must be used within a DataStorageProvider");return n}var ps=(n=>(n.FETCH_STORAGES_START="FETCH_STORAGES_START",n.FETCH_STORAGES_SUCCESS="FETCH_STORAGES_SUCCESS",n.FETCH_STORAGES_ERROR="FETCH_STORAGES_ERROR",n.FETCH_STORAGE_START="FETCH_STORAGE_START",n.FETCH_STORAGE_SUCCESS="FETCH_STORAGE_SUCCESS",n.FETCH_STORAGE_ERROR="FETCH_STORAGE_ERROR",n.CLEAR_CURRENT_STORAGE="CLEAR_CURRENT_STORAGE",n.CREATE_STORAGE_START="CREATE_STORAGE_START",n.CREATE_STORAGE_SUCCESS="CREATE_STORAGE_SUCCESS",n.CREATE_STORAGE_ERROR="CREATE_STORAGE_ERROR",n.UPDATE_STORAGE_START="UPDATE_STORAGE_START",n.UPDATE_STORAGE_SUCCESS="UPDATE_STORAGE_SUCCESS",n.UPDATE_STORAGE_ERROR="UPDATE_STORAGE_ERROR",n.DELETE_STORAGE_START="DELETE_STORAGE_START",n.DELETE_STORAGE_SUCCESS="DELETE_STORAGE_SUCCESS",n.DELETE_STORAGE_ERROR="DELETE_STORAGE_ERROR",n.CLEAR_ERROR="CLEAR_ERROR",n))(ps||{});const ist={dataStorages:[],currentDataStorage:null,loading:!1,error:null};function nst(n,e){switch(e.type){case ps.FETCH_STORAGES_START:case ps.FETCH_STORAGE_START:case ps.CREATE_STORAGE_START:case ps.UPDATE_STORAGE_START:return{...n,error:null};case ps.DELETE_STORAGE_START:return{...n,loading:!0,error:null};case ps.FETCH_STORAGES_SUCCESS:return{...n,dataStorages:e.payload,loading:!1,error:null};case ps.FETCH_STORAGE_SUCCESS:return{...n,currentDataStorage:e.payload,loading:!1,error:null};case ps.CREATE_STORAGE_SUCCESS:return{...n,dataStorages:[...n.dataStorages,e.payload],loading:!1,error:null};case ps.UPDATE_STORAGE_SUCCESS:return{...n,currentDataStorage:e.payload,dataStorages:n.dataStorages.map(t=>t.id===e.payload.id?e.payload:t),loading:!1,error:null};case ps.DELETE_STORAGE_SUCCESS:return{...n,dataStorages:n.dataStorages.filter(t=>t.id!==e.payload),loading:!1,error:null};case ps.FETCH_STORAGES_ERROR:case ps.FETCH_STORAGE_ERROR:case ps.CREATE_STORAGE_ERROR:case ps.UPDATE_STORAGE_ERROR:case ps.DELETE_STORAGE_ERROR:return{...n,loading:!1,error:e.payload};case ps.CLEAR_CURRENT_STORAGE:return{...n,currentDataStorage:null};case ps.CLEAR_ERROR:return{...n,error:null};default:return n}}function sre({children:n}){const[e,t]=x.useReducer(nst,ist);return f.jsx(wNe.Provider,{value:{state:e,dispatch:t},children:n})}class sst extends hC{constructor(){super("/data-storages")}async getDataStorages(){return this.get("/")}async getDataStorageById(e){return this.get(`/${e}`)}async createDataStorage(e){return this.post("",e)}async updateDataStorage(e,t){return this.put(`/${e}`,t)}async deleteDataStorage(e){return this.delete(`/${e}`)}}const _T=new sst;function ZH(){const{state:n,dispatch:e}=tst(),t=x.useCallback(async()=>{e({type:ps.FETCH_STORAGES_START});try{const l=await _T.getDataStorages();e({type:ps.FETCH_STORAGES_SUCCESS,payload:l.map(iit)})}catch(l){throw e({type:ps.FETCH_STORAGES_ERROR,payload:ys(l)}),l}},[e]),i=x.useCallback(async l=>{try{const c=await _T.getDataStorageById(l),d=o5(c);e({type:ps.FETCH_STORAGE_SUCCESS,payload:d})}catch(c){throw e({type:ps.FETCH_STORAGE_ERROR,payload:ys(c)}),c}},[e]),s=x.useCallback(async l=>{e({type:ps.CREATE_STORAGE_START});try{const c=nit(l),d=await _T.createDataStorage(c),u=o5(d);return e({type:ps.CREATE_STORAGE_SUCCESS,payload:u}),Vt({event:"data_storage_created",category:"DataStorage",action:"Create",label:u.type}),Rn.success("Storage created"),u}catch(c){return e({type:ps.CREATE_STORAGE_ERROR,payload:ys(c)}),null}},[e]),r=x.useCallback(async(l,c)=>{e({type:ps.UPDATE_STORAGE_START});try{const d=tit(c),u=await _T.updateDataStorage(l,d),h=o5(u);return e({type:ps.UPDATE_STORAGE_SUCCESS,payload:h}),Vt({event:"data_storage_updated",category:"DataStorage",action:"Update",label:h.type}),Rn.success("Storage updated"),h}catch(d){return e({type:ps.UPDATE_STORAGE_ERROR,payload:ys(d)}),null}},[e]),o=x.useCallback(async l=>{e({type:ps.DELETE_STORAGE_START});try{await _T.deleteDataStorage(l),e({type:ps.DELETE_STORAGE_SUCCESS,payload:l}),Vt({event:"data_storage_deleted",category:"DataStorage",action:"Delete",label:l}),Rn.success("Storage deleted")}catch(c){throw e({type:ps.DELETE_STORAGE_ERROR,payload:ys(c)}),c}},[e]),a=x.useCallback(()=>{e({type:ps.CLEAR_CURRENT_STORAGE})},[e]);return{dataStorages:n.dataStorages,currentDataStorage:n.currentDataStorage,loading:n.loading,error:n.error,fetchDataStorages:t,getDataStorageById:i,createDataStorage:s,updateDataStorage:r,deleteDataStorage:o,clearCurrentDataStorage:a}}const yNe=({isOpen:n,onClose:e,onSelect:t})=>f.jsx(Vse,{open:n,onOpenChange:e,children:f.jsxs(Wse,{className:"sm:max-w-sm",children:[f.jsxs(zse,{children:[f.jsx(Use,{children:"New Storage"}),f.jsx($se,{children:"Choose the type of storage you want to create"})]}),f.jsx("div",{className:"flex flex-col gap-4 py-4",children:fC.getAllTypes().map(i=>{const s=i.icon,r=i.status===Km.ACTIVE;return f.jsxs(rt,{variant:"outline",className:"flex px-4 py-6",onClick:()=>void t(i.type),disabled:!r,children:[f.jsxs("span",{className:"flex flex-grow items-center gap-2",children:[f.jsx(s,{size:24}),f.jsx("span",{className:"font-medium",children:i.displayName})]}),!r&&f.jsx(Ya,{variant:"secondary",children:"Coming soon"})]},i.type)})})]})});function rst({initialData:n,onSuccess:e}){const{handleCreate:t,isSubmitting:i,serverError:s}=Wnt(),{dataStorages:r,loading:o,fetchDataStorages:a,createDataStorage:l,getDataStorageById:c}=ZH(),[d,u]=x.useState(!1);x.useEffect(()=>{a()},[a]);const h=Bp({resolver:pb(Vnt),defaultValues:{title:(n==null?void 0:n.title)??"",storageId:""},mode:"onTouched"}),g=async v=>{const C=await t(v);C&&e&&e(C)},m=()=>{u(!0)},b=async v=>{try{const C=await l(v);C!=null&&C.id&&(await c(C.id),h.setValue("storageId",C.id))}catch(C){console.error("Failed to create storage:",C)}u(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(CC,{...h,children:f.jsxs(gb,{onSubmit:v=>{h.handleSubmit(g)(v)},children:[f.jsxs(wC,{variant:"light",children:[s&&f.jsx("div",{className:"rounded bg-red-100 p-3 text-red-700",children:s.message}),f.jsx(fn,{control:h.control,name:"title",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{id:"title",placeholder:"Enter title",...v,disabled:i})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:h.control,name:"storageId",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"Storage"}),f.jsx(cn,{children:f.jsxs($c,{onValueChange:C=>{C==="create_new"?m():v.onChange(C)},value:v.value,disabled:i||o,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a storage"})}),f.jsx(Kc,{children:f.jsxs(KH,{children:[o&&f.jsx(fo,{value:"loading",disabled:!0,children:"Loading..."}),!o&&r.map(C=>{const y=fC.getInfo(C.type).icon;return f.jsx(fo,{value:C.id,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(y,{size:20}),f.jsx("span",{children:C.title})]})},C.id)}),!o&&r.length>0&&f.jsx(jnt,{}),f.jsx(fo,{value:"create_new",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"flex h-5 w-5 items-center justify-center",children:f.jsx(Gd,{size:20})}),f.jsx("span",{children:"Create new storage"})]})})]})})]})}),f.jsx(Cn,{})]})})]}),f.jsxs(yC,{variant:"light",children:[f.jsx(rt,{type:"submit",children:"Create Data Mart"}),f.jsx(rt,{variant:"outline",type:"button",onClick:()=>{window.history.back()},children:"Go back"})]})]})}),f.jsx(yNe,{isOpen:d,onClose:()=>{u(!1)},onSelect:v=>b(v)})]})}function SNe({title:n,onUpdate:e,className:t,errorMessage:i="Title cannot be empty",minWidth:s="200px"}){const[r,o]=x.useState(n),[a,l]=x.useState(!1),c=x.useRef(null);x.useEffect(()=>{o(n)},[n]),x.useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=`${String(c.current.scrollHeight)}px`)},[r]);const d=async()=>{if(r.trim()===""){o(n);return}if(r.trim()!==n)try{l(!0),await e(r.trim())}catch(h){o(n),console.error(h)}finally{l(!1)}},u=h=>{if(h.key==="Enter"&&!h.shiftKey){if(h.preventDefault(),r.trim()===""){Rn.error(i),o(n);return}d()}else h.key==="Escape"&&o(n)};return f.jsx("h2",{className:Le("m-0 cursor-pointer p-0 hover:opacity-80",t),children:f.jsx(Hp,{ref:c,value:r,onChange:h=>{o(h.target.value);const g=h.target;g.style.height="auto",g.style.height=`${String(g.scrollHeight)}px`},onBlur:()=>void d(),onKeyDown:u,className:Le("m-0 w-full border-0 p-0 shadow-none","bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",{"opacity-50":a}),style:{fontSize:"inherit",fontWeight:"inherit",lineHeight:"inherit",fontFamily:"inherit",color:"inherit",resize:"none",overflow:"hidden",minHeight:"inherit",height:"auto",minWidth:s},disabled:a})})}var _w=(n=>(n.MANUAL_BACKFILL="MANUAL_BACKFILL",n.INCREMENTAL="INCREMENTAL",n))(_w||{}),xNe=(n=>(n.MANUAL_BACKFILL="MANUAL_BACKFILL",n.HIDE_IN_CONFIG_FORM="HIDE_IN_CONFIG_FORM",n))(xNe||{}),YH="Tabs",[ost]=Ha(YH,[yH]),LNe=yH(),[ast,rre]=ost(YH),ENe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,onValueChange:s,defaultValue:r,orientation:o="horizontal",dir:a,activationMode:l="automatic",...c}=n,d=wM(a),[u,h]=zc({prop:i,onChange:s,defaultProp:r??"",caller:YH});return f.jsx(ast,{scope:t,baseId:To(),value:u,onValueChange:h,orientation:o,dir:d,activationMode:l,children:f.jsx(ui.div,{dir:d,"data-orientation":o,...c,ref:e})})});ENe.displayName=YH;var DNe="TabsList",RNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,loop:i=!0,...s}=n,r=rre(DNe,t),o=LNe(t);return f.jsx(MLe,{asChild:!0,...o,orientation:r.orientation,dir:r.dir,loop:i,children:f.jsx(ui.div,{role:"tablist","aria-orientation":r.orientation,...s,ref:e})})});RNe.displayName=DNe;var NNe="TabsTrigger",TNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,disabled:s=!1,...r}=n,o=rre(NNe,t),a=LNe(t),l=ANe(o.baseId,i),c=MNe(o.baseId,i),d=i===o.value;return f.jsx(OLe,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(ui.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:l,...r,ref:e,onMouseDown:Lt(n.onMouseDown,u=>{!s&&u.button===0&&u.ctrlKey===!1?o.onValueChange(i):u.preventDefault()}),onKeyDown:Lt(n.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&o.onValueChange(i)}),onFocus:Lt(n.onFocus,()=>{const u=o.activationMode!=="manual";!d&&!s&&u&&o.onValueChange(i)})})})});TNe.displayName=NNe;var INe="TabsContent",kNe=x.forwardRef((n,e)=>{const{__scopeTabs:t,value:i,forceMount:s,children:r,...o}=n,a=rre(INe,t),l=ANe(a.baseId,i),c=MNe(a.baseId,i),d=i===a.value,u=x.useRef(d);return x.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),f.jsx(kl,{present:s||d,children:({present:h})=>f.jsx(ui.div,{"data-state":d?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...o,ref:e,style:{...n.style,animationDuration:u.current?"0s":void 0},children:h&&r})})});kNe.displayName=INe;function ANe(n,e){return`${n}-trigger-${e}`}function MNe(n,e){return`${n}-content-${e}`}var lst=ENe,cst=RNe,dst=TNe,ust=kNe;function ore({className:n,...e}){return f.jsx(lst,{"data-slot":"tabs",className:Le("flex flex-col gap-2",n),...e})}function are({className:n,...e}){return f.jsx(cst,{"data-slot":"tabs-list",className:Le("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",n),...e})}function u2({className:n,...e}){return f.jsx(dst,{"data-slot":"tabs-trigger",className:Le("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function hst({className:n,...e}){return f.jsx(ust,{"data-slot":"tabs-content",className:Le("flex-1 outline-none",n),...e})}var XH="Collapsible",[fst,ONe]=Ha(XH),[gst,lre]=fst(XH),PNe=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:i,defaultOpen:s,disabled:r,onOpenChange:o,...a}=n,[l,c]=zc({prop:i,defaultProp:s??!1,onChange:o,caller:XH});return f.jsx(gst,{scope:t,disabled:r,contentId:To(),open:l,onOpenToggle:x.useCallback(()=>c(d=>!d),[c]),children:f.jsx(ui.div,{"data-state":hre(l),"data-disabled":r?"":void 0,...a,ref:e})})});PNe.displayName=XH;var FNe="CollapsibleTrigger",cre=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,...i}=n,s=lre(FNe,t);return f.jsx(ui.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":hre(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:e,onClick:Lt(n.onClick,s.onOpenToggle)})});cre.displayName=FNe;var dre="CollapsibleContent",ure=x.forwardRef((n,e)=>{const{forceMount:t,...i}=n,s=lre(dre,n.__scopeCollapsible);return f.jsx(kl,{present:t||s.open,children:({present:r})=>f.jsx(pst,{...i,ref:e,present:r})})});ure.displayName=dre;var pst=x.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:i,children:s,...r}=n,o=lre(dre,t),[a,l]=x.useState(i),c=x.useRef(null),d=Ui(e,c),u=x.useRef(0),h=u.current,g=x.useRef(0),m=g.current,b=o.open||a,v=x.useRef(b),C=x.useRef(void 0);return x.useEffect(()=>{const y=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(y)},[]),Dl(()=>{const y=c.current;if(y){C.current=C.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const L=y.getBoundingClientRect();u.current=L.height,g.current=L.width,v.current||(y.style.transitionDuration=C.current.transitionDuration,y.style.animationName=C.current.animationName),l(i)}},[o.open,i]),f.jsx(ui.div,{"data-state":hre(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!b,...r,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:b&&s})});function hre(n){return n?"open":"closed"}var jNe=PNe,mst=cre,_st=ure;const bst=jNe,vst=cre,Cst=ure;function wst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("flex flex-1 flex-col overflow-hidden",e),...t,children:n})}function yst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("bg-muted dark:bg-sidebar flex-1 overflow-y-auto p-4",e),...t,children:f.jsx("div",{className:"flex min-h-full flex-col gap-4",children:n})})}function Sst({children:n,className:e="",variant:t="horizontal",...i}){const s=t==="vertical"?"flex flex-col gap-1.5 pt-4":"flex items-center justify-between border-t px-4 py-3";return f.jsx("div",{className:Le(s,e),...i,children:n})}function iv({children:n,className:e="",...t}){return f.jsx("div",{"data-slot":"wizard-step-item",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",e),...t,children:n})}function xst({label:n,children:e,className:t="",options:i,value:s,onValueChange:r,required:o=!1,tooltip:a,...l}){return f.jsx("div",{"data-slot":"wizard-step-item-one-of",className:Le("group border-border flex flex-col gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4",t),...l,children:f.jsxs(ore,{value:s,onValueChange:r,children:[f.jsxs("div",{className:"flex items-center",children:[f.jsx(_u,{required:o,tooltip:a,className:"w-full",children:n}),i.length>1&&f.jsx(are,{children:i.map(c=>f.jsx(u2,{value:c.value,children:c.label},c.value))})]}),e]})})}function HNe({title:n,children:e,defaultOpen:t=!1,className:i=""}){const[s,r]=x.useState(t);return f.jsxs(bst,{open:s,onOpenChange:r,"data-slot":"wizard-collapsible",className:Le("group/collapsible flex flex-col gap-2 py-3",i),children:[f.jsx(vst,{asChild:!0,children:f.jsxs("button",{type:"button",className:Le("flex cursor-pointer items-center gap-1"),children:[f.jsx("span",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx($d,{className:Le("text-foreground/75 h-3.5 w-3.5 transition-transform duration-200",s&&"rotate-90")})]})}),f.jsx(Cst,{className:"data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up overflow-hidden",children:f.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e})})]})}function _u({children:n,required:e=!1,tooltip:t,tooltipProps:i,className:s="",...r}){return f.jsxs(Bu,{"data-slot":"wizard-step-label",className:Le("text-foreground flex items-center justify-between gap-2 text-sm font-medium",s),...r,children:[e?f.jsxs(Tn,{...i,children:[f.jsx(In,{asChild:!0,children:f.jsxs("span",{className:"flex items-center gap-1",children:[n,f.jsx("span",{className:"ml-1 text-red-500",children:"*"})]})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:"Required"})]}):f.jsx("span",{children:n}),t&&f.jsxs(Tn,{...i,children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",tabIndex:-1,className:"pointer-events-none opacity-0 transition group-hover:pointer-events-auto group-hover:opacity-100","aria-label":"Help information",children:f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:t})]})]})}function Hv({title:n,children:e,className:t="",...i}){return f.jsxs("section",{"data-slot":"wizard-step-section",className:Le("mb-8",t),...i,children:[n&&f.jsx("h3",{className:"text-muted-foreground/75 mb-2 text-xs font-semibold tracking-wide uppercase",children:n}),f.jsx("div",{className:"flex flex-col gap-2",children:e})]})}function x_({icon:n,title:e,subtitle:t,docUrl:i,variant:s="default",className:r,...o}){return s==="compact"?f.jsxs("div",{"data-slot":"wizard-step-hero",className:Le("border-border mb-6 flex items-center justify-between gap-4 border-b pb-4",r),...o,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[n&&f.jsx("div",{children:n}),f.jsx("h2",{className:"text-md font-medium",children:e})]}),i!=null&&f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:i,target:"_blank",rel:"noopener noreferrer",children:["Documentation",f.jsx(F_,{className:"h-4 w-4"})]})})]}):f.jsxs("div",{"data-slot":"wizard-step-hero",className:Le("mb-6 flex flex-col items-center justify-center text-center",r),...o,children:[n&&f.jsx("div",{className:"mt-6 mb-3",children:n}),f.jsx("h2",{className:"text-xl font-medium",children:e}),t&&f.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:t}),i!=null&&f.jsx(rt,{variant:"outline",className:"mt-3 mb-6",asChild:!0,children:f.jsxs(Vc,{to:i,target:"_blank",rel:"noopener noreferrer",children:["Documentation",f.jsx(F_,{className:"h-4 w-4"})]})})]})}function L_({children:n,className:e="",...t}){return f.jsx("div",{"data-slot":"wizard-step",className:Le("space-y-4",e),...t,children:n})}function Lst({children:n,className:e="",...t}){return f.jsx("div",{className:Le("grid grid-cols-1 gap-4 md:grid-cols-2",e),...t,children:n})}function Est({icon:n,title:e,selected:t=!1,disabled:i=!1,onClick:s,onDoubleClick:r,className:o="",...a}){return f.jsxs("div",{className:Le("border-border flex items-center gap-4 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 select-none hover:shadow-sm dark:border-transparent dark:bg-white/4",i?"cursor-not-allowed opacity-50 hover:shadow-none":"cursor-pointer hover:shadow-sm dark:hover:bg-white/8",t&&!i?"ring-primary border-transparent ring-2 dark:bg-white/8":"",o),onClick:s,onDoubleClick:r,...a,children:[n&&f.jsx("span",{className:"shrink-0",children:n}),i?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{className:"cursor-not-allowed text-sm font-medium opacity-70",children:e})}),f.jsx(kn,{side:"top",align:"center",children:"Coming soon"})]}):f.jsx("span",{className:"text-sm font-medium",children:e})]})}function BNe({type:n,id:e,name:t,value:i,label:s,checked:r,selected:o=!1,disabled:a=!1,tooltip:l,rightIcon:c,onChange:d,className:u="",...h}){const g=b=>{d&&d(n==="checkbox"?b.target.checked:b.target.value)},m=x.useRef(null);return f.jsxs("div",{"data-slot":"wizard-step-card-item",onClick:b=>{if(a)return;const v=b.target;v.tagName==="INPUT"||v.tagName==="LABEL"||v.closest("label")||m.current&&m.current.click()},className:Le("group border-border flex items-center gap-2 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 select-none hover:shadow-sm dark:border-transparent dark:bg-white/4",a?"cursor-not-allowed":"cursor-pointer hover:shadow-sm dark:hover:bg-white/8",o?"ring-primary border-transparent ring-2 dark:bg-white/8":"",u),children:[f.jsx("input",{ref:m,id:e,type:n,name:t,value:i,checked:r,disabled:a,onChange:g,className:Le("text-primary focus:ring-primary border-border cursor-pointer",n==="radio"||n==="checkbox"?"h-4 w-4":"h-8 w-full rounded-md border px-2"),...h}),s&&f.jsx(_u,{htmlFor:e,className:Le("cursor-pointer",a&&"cursor-not-allowed"),children:s}),(l||c)&&f.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[l&&f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"text-muted-foreground/75 pointer-events-none h-4 w-4 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100","data-tooltip-trigger":!0})}),f.jsx(kn,{side:"top",align:"center",children:l})]}),c&&f.jsx("div",{className:"flex items-center",children:c})]})]})}function fre({variant:n="grid",items:e,className:t=""}){const i=e??(n==="grid"?12:6),s=n==="grid"?"grid grid-cols-1 gap-4 md:grid-cols-2":"flex flex-col gap-4";return f.jsx("div",{"data-slot":"wizard-step-loading",className:Le(s,t),children:Array.from({length:i}).map((r,o)=>f.jsx(bl,{className:"border-border h-12 rounded-md border-b bg-white dark:bg-white/4"},o))})}function Lme(n){const e=Dst(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Nst);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Dst(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Ist(s),a=Tst(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Rst=Symbol("radix.slottable");function Nst(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Rst}function Tst(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Ist(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}function kst(n){const e=n+"CollectionProvider",[t,i]=Ha(e),[s,r]=t(e,{collectionRef:{current:null},itemMap:new Map}),o=b=>{const{scope:v,children:C}=b,y=nt.useRef(null),L=nt.useRef(new Map).current;return f.jsx(s,{scope:v,itemMap:L,collectionRef:y,children:C})};o.displayName=e;const a=n+"CollectionSlot",l=Lme(a),c=nt.forwardRef((b,v)=>{const{scope:C,children:y}=b,L=r(a,C),E=Ui(v,L.collectionRef);return f.jsx(l,{ref:E,children:y})});c.displayName=a;const d=n+"CollectionItemSlot",u="data-radix-collection-item",h=Lme(d),g=nt.forwardRef((b,v)=>{const{scope:C,children:y,...L}=b,E=nt.useRef(null),R=Ui(v,E),T=r(d,C);return nt.useEffect(()=>(T.itemMap.set(E,{ref:E,...L}),()=>void T.itemMap.delete(E))),f.jsx(h,{[u]:"",ref:R,children:y})});g.displayName=d;function m(b){const v=r(n+"CollectionConsumer",b);return nt.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const L=Array.from(y.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((T,N)=>L.indexOf(T.ref.current)-L.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:c,ItemSlot:g},m,i]}var ag="Accordion",Ast=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[gre,Mst,Ost]=kst(ag),[QH]=Ha(ag,[Ost,ONe]),pre=ONe(),VNe=nt.forwardRef((n,e)=>{const{type:t,...i}=n,s=i,r=i;return f.jsx(gre.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?f.jsx(Hst,{...r,ref:e}):f.jsx(jst,{...s,ref:e})})});VNe.displayName=ag;var[WNe,Pst]=QH(ag),[zNe,Fst]=QH(ag,{collapsible:!1}),jst=nt.forwardRef((n,e)=>{const{value:t,defaultValue:i,onValueChange:s=()=>{},collapsible:r=!1,...o}=n,[a,l]=zc({prop:t,defaultProp:i??"",onChange:s,caller:ag});return f.jsx(WNe,{scope:n.__scopeAccordion,value:nt.useMemo(()=>a?[a]:[],[a]),onItemOpen:l,onItemClose:nt.useCallback(()=>r&&l(""),[r,l]),children:f.jsx(zNe,{scope:n.__scopeAccordion,collapsible:r,children:f.jsx(UNe,{...o,ref:e})})})}),Hst=nt.forwardRef((n,e)=>{const{value:t,defaultValue:i,onValueChange:s=()=>{},...r}=n,[o,a]=zc({prop:t,defaultProp:i??[],onChange:s,caller:ag}),l=nt.useCallback(d=>a((u=[])=>[...u,d]),[a]),c=nt.useCallback(d=>a((u=[])=>u.filter(h=>h!==d)),[a]);return f.jsx(WNe,{scope:n.__scopeAccordion,value:o,onItemOpen:l,onItemClose:c,children:f.jsx(zNe,{scope:n.__scopeAccordion,collapsible:!0,children:f.jsx(UNe,{...r,ref:e})})})}),[Bst,JH]=QH(ag),UNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:i,dir:s,orientation:r="vertical",...o}=n,a=nt.useRef(null),l=Ui(a,e),c=Mst(t),u=wM(s)==="ltr",h=Lt(n.onKeyDown,g=>{var I;if(!Ast.includes(g.key))return;const m=g.target,b=c().filter(M=>{var P;return!((P=M.ref.current)!=null&&P.disabled)}),v=b.findIndex(M=>M.ref.current===m),C=b.length;if(v===-1)return;g.preventDefault();let y=v;const L=0,E=C-1,R=()=>{y=v+1,y>E&&(y=L)},T=()=>{y=v-1,y<L&&(y=E)};switch(g.key){case"Home":y=L;break;case"End":y=E;break;case"ArrowRight":r==="horizontal"&&(u?R():T());break;case"ArrowDown":r==="vertical"&&R();break;case"ArrowLeft":r==="horizontal"&&(u?T():R());break;case"ArrowUp":r==="vertical"&&T();break}const N=y%C;(I=b[N].ref.current)==null||I.focus()});return f.jsx(Bst,{scope:t,disabled:i,direction:s,orientation:r,children:f.jsx(gre.Slot,{scope:t,children:f.jsx(ui.div,{...o,"data-orientation":r,ref:l,onKeyDown:i?void 0:h})})})}),PF="AccordionItem",[Vst,mre]=QH(PF),$Ne=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,value:i,...s}=n,r=JH(PF,t),o=Pst(PF,t),a=pre(t),l=To(),c=i&&o.value.includes(i)||!1,d=r.disabled||n.disabled;return f.jsx(Vst,{scope:t,open:c,disabled:d,triggerId:l,children:f.jsx(jNe,{"data-orientation":r.orientation,"data-state":XNe(c),...a,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?o.onItemOpen(i):o.onItemClose(i)}})})});$Ne.displayName=PF;var GNe="AccordionHeader",qNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre(GNe,t);return f.jsx(ui.h3,{"data-orientation":s.orientation,"data-state":XNe(r.open),"data-disabled":r.disabled?"":void 0,...i,ref:e})});qNe.displayName=GNe;var $K="AccordionTrigger",KNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre($K,t),o=Fst($K,t),a=pre(t);return f.jsx(gre.ItemSlot,{scope:t,children:f.jsx(mst,{"aria-disabled":r.open&&!o.collapsible||void 0,"data-orientation":s.orientation,id:r.triggerId,...a,...i,ref:e})})});KNe.displayName=$K;var ZNe="AccordionContent",YNe=nt.forwardRef((n,e)=>{const{__scopeAccordion:t,...i}=n,s=JH(ag,t),r=mre(ZNe,t),o=pre(t);return f.jsx(_st,{role:"region","aria-labelledby":r.triggerId,"data-orientation":s.orientation,...o,...i,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});YNe.displayName=ZNe;function XNe(n){return n?"open":"closed"}var Wst=VNe,zst=$Ne,Ust=qNe,$st=KNe,Gst=YNe;const _re={default:{itemClass:"border-b last:border-b-0",triggerClass:"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",icon:null,chevronClass:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200",contentClass:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",contentInnerClass:"pt-0 pb-4",headerClass:"flex"},common:{itemClass:"overflow-hidden",triggerClass:"group focus-visible:ring-primary hover:bg-muted [&[data-state=open]]:bg-muted flex items-center gap-1 rounded-sm px-2 py-1 transition-all outline-none focus-visible:ring-2 [&[data-state=open]]:rounded-br-none [&[data-state=open]]:rounded-bl-none [&[data-state=open]]:font-semibold",icon:f.jsx(DBe,{className:"size-4 shrink-0","aria-hidden":"true"}),chevronClass:"size-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180",contentClass:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down bg-muted overflow-hidden rounded-sm rounded-tl-none py-0 pr-2 pl-7 text-sm",contentInnerClass:"pt-2 pb-4",headerClass:void 0}},QNe=x.createContext("default");function sr({variant:n="default",...e}){return f.jsx(QNe.Provider,{value:n,children:f.jsx(Wst,{"data-slot":"accordion",...e})})}function bre(n){const e=x.useContext(QNe);return n??e??"default"}function ts({className:n,variant:e,...t}){const i=bre(e),{itemClass:s}=_re[i];return f.jsx(zst,{"data-slot":"accordion-item",className:Le(s,n),...t})}function is({className:n,children:e,variant:t,...i}){const s=bre(t),{triggerClass:r,icon:o,chevronClass:a,headerClass:l}=_re[s];return f.jsx(Ust,{className:l,children:f.jsxs($st,{"data-slot":"accordion-trigger",className:Le(r,n),...i,children:[o,e,f.jsx(Pp,{className:a,"aria-hidden":"true"})]})})}function ns({className:n,children:e,variant:t,...i}){const s=bre(t),{contentClass:r,contentInnerClass:o}=_re[s];return f.jsx(Gst,{"data-slot":"accordion-content",className:Le(r,n),...i,children:f.jsx("div",{className:o,children:e})})}function ir({href:n,children:e,className:t,...i}){return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Le("text-muted-foreground hover:bg-muted inline-flex items-center px-1 font-medium hover:rounded-md",t),...i,children:[e,f.jsx(F_,{className:"ml-1 inline h-3 w-3","aria-hidden":"true"})]})}function Eme(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"connector-state-details",children:[f.jsx(is,{children:"What’s connector state?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The connector state stores internal data between runs and updates automatically with each execution. It’s used to track progress and ensure consistent data processing across runs."}),f.jsx("p",{className:"mb-2",children:"Connector state is available only for connectors that support incremental runs, helping add only new or updated records since the last run without reloading existing data."}),f.jsxs("p",{className:"mb-2",children:["For more details, see the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/?utm_source=owox_data_marts&utm_medium=manual_run_sheet&utm_campaign=tooltip_connector_state",children:"OWOX documentation"}),"."]})]})]})})}function qst({configuration:n,connectorState:e}){const i=((n==null?void 0:n.connector.source.configuration)??[]).map((a,l)=>{const c=a;return typeof c._id=="string"?{id:c._id,index:l}:void 0}).filter(a=>!!a),s=(e==null?void 0:e.states)??[],r=new Map(s.map(a=>[a._id,a])),o=i.map(({id:a,index:l})=>{const c=r.get(a);return c?{state:c,index:l}:void 0}).filter(a=>!!a);return f.jsx(HNe,{title:"State Info",children:o.length===0?f.jsxs(tn,{children:[f.jsx(Ji,{children:"Connector state"}),f.jsx(cn,{children:f.jsx("div",{className:"bg-muted min-h-[70px] cursor-not-allowed overflow-auto rounded-md px-3 py-2 font-mono text-sm whitespace-pre-wrap opacity-70",children:"No state available"})}),f.jsx(Hs,{children:f.jsx(Eme,{})})]}):f.jsx(f.Fragment,{children:o.map(({state:a,index:l})=>{const c=a.at||"",d=c?zH(yRe(c).toISOString()):"—",u=a.state,h=(()=>{try{return JSON.stringify(u,null,2)}catch{return typeof u=="string"?u:'"—"'}})();return f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:`Created at ${d}`,children:`Connector state of configuration #${String(l+1)}`}),f.jsx(cn,{children:f.jsx(eDe,{value:h,displayOnly:!0,className:"bg-muted overflow-auto rounded-md text-sm",minHeightClass:"min-h-0",showCopyButton:!0})}),f.jsx(Hs,{children:f.jsx(Eme,{})})]},a._id)})})})}function Kst({configuration:n,onClose:e,onSubmit:t}){const[i,s]=x.useState(new Set),r=x.useId(),o=Bp({defaultValues:{runType:_w.INCREMENTAL}}),{loading:a,loadingSpecification:l,connectorSpecification:c,fetchConnectorSpecification:d}=US(),{dataMart:u}=og(),h=x.useCallback(async v=>{!i.has(v)&&!l&&(s(C=>new Set(C).add(v)),await d(v))},[i,l,d]);x.useEffect(()=>{n!=null&&n.connector.source.name&&h(n.connector.source.name)},[n,a,h]);const g=v=>{t&&t(v)},m=()=>{e&&e()},b=v=>{if(!v)return"text";switch(v){case mf.DATE:return"date";case mf.NUMBER:return"number";default:return"text"}};return l?f.jsx("div",{children:"Loading..."}):c?f.jsx(CC,{...o,children:f.jsxs(gb,{id:r,noValidate:!0,onSubmit:v=>void o.handleSubmit(g)(v),children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:o.control,name:"runType",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select how you want to load data: incremental updates or full backfill for a period",children:"Run type"}),f.jsx(cn,{children:f.jsxs(f.Fragment,{children:[f.jsx(Yit,{options:[{value:_w.INCREMENTAL,label:"Incremental load"},{value:_w.MANUAL_BACKFILL,label:"Backfill (custom period)"}],value:v.value,onChange:v.onChange,orientation:"horizontal"}),f.jsx(Hs,{children:o.watch("runType")===_w.MANUAL_BACKFILL?"Reloads all data for a specific time range from the source, replacing existing records for that period. Use when you need to correct or update historical data.":"Adds only new or updated records since the last run, using the current state of your Data Mart as a reference. Ideal for keeping data fresh without reloading what`s already there."})]})})]})}),o.watch("runType")===_w.INCREMENTAL&&f.jsx(qst,{configuration:n,connectorState:(u==null?void 0:u.connectorState)??null})]}),o.watch("runType")===_w.MANUAL_BACKFILL&&f.jsx(tc,{title:"Run configuration",children:c.filter(v=>{var C;return(C=v.attributes)==null?void 0:C.includes(xNe.MANUAL_BACKFILL)}).map(v=>f.jsx(fn,{control:o.control,name:`data.${v.name}`,render:()=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:v.description,children:v.title??v.name}),f.jsx(cn,{children:f.jsx(vn,{id:v.name,placeholder:v.description,type:b(v.requiredType),defaultValue:typeof v.default=="string"||typeof v.default=="number"?v.default.toString():void 0,...o.register(`data.${v.name}`,{required:!0})})}),f.jsx(Cn,{})]},v.name)}))})]}),f.jsxs(yC,{children:[f.jsx(rt,{type:"submit",disabled:!o.formState.isValid||l,children:"Run"}),f.jsx(rt,{type:"button",variant:"outline",onClick:m,children:"Cancel"})]})]})}):f.jsx("div",{children:"No connector specification found"})}function Zst({isOpen:n,onClose:e,configuration:t,onSubmit:i}){return f.jsx(ab,{open:n,onOpenChange:e,children:f.jsxs(lb,{children:[f.jsx(cb,{children:f.jsx(db,{children:"Manual Run"})}),f.jsx(Kst,{configuration:t,onClose:e,onSubmit:i})]})})}function JNe({children:n,configuration:e,onManualRun:t,open:i}){const[s,r]=x.useState(i??!1),o=()=>{r(!0)},a=c=>{t(c),r(!1)},l=()=>n?f.jsx("div",{onClick:o,style:{cursor:"pointer"},children:n}):null;return f.jsxs(f.Fragment,{children:[l(),s&&f.jsx(HD,{children:f.jsx(Zst,{isOpen:s,onClose:()=>{r(!1)},configuration:e,onSubmit:a})})]})}const Yst=1e3;function Xst(n,e){const[t,i]=x.useState(!1),[s,r]=x.useState(null),o=x.useRef(null),a=x.useRef(null),l=x.useRef(!0),c=x.useRef(e);c.current=e;const d=x.useCallback(v=>{l.current&&i(v)},[]),u=x.useCallback(v=>{l.current&&r(v)},[]),h=x.useCallback((v,C)=>{const y=v instanceof Error?v.message:"Schema actualization failed";Rn.dismiss(C),u(y),d(!1),o.current=null,a.current=null,Rn.error(y,{duration:void 0,id:C})},[u,d]),g=x.useCallback(async()=>{var C;const v=o.current;if((C=a.current)==null||C.abort(),v){Rn.dismiss(v);try{await hr.abortSchemaActualizeTrigger(n,v)}catch{}}o.current=null,a.current=null,d(!1)},[n,d]),m=x.useCallback(async(v,C)=>{var L;const y=E=>E===Au.SUCCESS||E===Au.ERROR||E===Au.CANCELLED;for(;!C.aborted&&o.current===v;)try{const E=await hr.getSchemaActualizeTriggerStatus(n,v);if(y(E)){try{const R=await hr.getSchemaActualizeTriggerResponse(n,v);if(Rn.dismiss(v),R.success)(L=c.current)==null||L.call(c),Rn.success("Output schema actualized",{duration:void 0,id:v});else{const T=R.error??"Schema actualization failed";u(T),Rn.error(T,{duration:void 0,id:v})}}catch(R){const T=R instanceof Error?R.message:"Schema actualization failed";Rn.dismiss(v),u(T),Rn.error(T,{duration:void 0,id:v})}d(!1),o.current=null,a.current=null;return}await new Promise(R=>setTimeout(R,Yst))}catch(E){h(E,v)}},[n,u,d,h]),b=x.useCallback(async()=>{o.current&&await g(),u(null),d(!0);try{const{triggerId:v}=await hr.createSchemaActualizeTrigger(n);Rn.loading("Synchronizing schema with the data storage state. This may take a while.",{duration:1/0,id:v}),o.current=v;const C=new AbortController;a.current=C;try{await m(v,C.signal)}catch(y){h(y,v)}}catch(v){d(!1),u(v instanceof Error?v.message:"Failed to start schema actualization")}},[n,g,m,u,d,h]);return x.useEffect(()=>(l.current=!0,()=>{var C;l.current=!1;const v=o.current;(C=a.current)==null||C.abort(),v&&(Rn.dismiss(v),hr.abortSchemaActualizeTrigger(n,v).catch(()=>{})),o.current=null,a.current=null}),[n]),{run:b,isLoading:t,cancel:g,error:s}}function Qst({id:n}){const{navigate:e}=hb(),{user:t}=ub(),{flags:i}=EM(),{dataMart:s,deleteDataMart:r,updateDataMartTitle:o,updateDataMartDescription:a,updateDataMartDefinition:l,actualizeDataMartSchema:c,updateDataMartSchema:d,publishDataMart:u,runDataMart:h,cancelDataMartRun:g,getDataMartRuns:m,loadMoreDataMartRuns:b,isLoading:v,error:C,getErrorMessage:y,runs:L,getDataMart:E}=znt(n),[R,T]=x.useState(!1),[N,I]=x.useState(!1),{id:M="",canPublish:P=!1,canActualizeSchema:H=!1,status:j={code:null,displayName:"",description:""},title:V="",definition:W=null,definitionType:U=null,validationErrors:B=[]}=s??{},K=x.useCallback(()=>{M&&E(M)},[M,E]),{run:X,isLoading:ne}=Xst(M,K),fe=x.useCallback(async()=>{H&&await X()},[H,X]),Z=i==null?void 0:i.INSIGHTS_ENABLED_PROJECT_IDS,Y=(t==null?void 0:t.projectId)??"",ee=Y.length>0&&Lit(Z??"").includes(Y),se=[{name:"Overview",path:"overview"},{name:"Data Setup",path:"data-setup"},...ee?[{name:"Insights",path:"insights"}]:[],{name:"Destinations",path:"reports"},{name:"Triggers",path:"triggers"},{name:"Run History",path:"run-history"}],ae=x.useCallback(async Re=>{M&&await o(M,Re)},[M,o]),Se=x.useCallback(async()=>{if(M){I(!0);try{await u(M),fe()}catch(Re){console.log(Re instanceof Error?Re.message:"Failed to publish Data Mart")}finally{I(!1)}}},[M,u,fe]),ue=x.useCallback(async Re=>{if(M){if(j.code!==Ll.PUBLISHED){Sr.error("Manual run is only available for published Data Marts");return}await h({id:M,payload:Re})}},[M,j,h]);return s?f.jsxs("div",{className:"px-12 py-6",children:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center space-x-1 md:-ml-10",children:[f.jsx(OE,{onClick:()=>{e("/data-marts")},variant:"ghost",size:"sm","aria-label":"Back to Data Marts",title:"Back to Data Marts",className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:f.jsx(uHe,{className:"h-5 w-5"})}),f.jsx(SNe,{title:V,onUpdate:ae,className:"text-2xl font-medium"})]}),f.jsxs("div",{className:"flex items-center gap-2"+(N?" opacity-50":""),style:{minWidth:"120px"},children:[f.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsx(kM,{type:j.code===Ll.PUBLISHED?Do.SUCCESS:Do.NEUTRAL,variant:"subtle",children:j.displayName})})}),f.jsx(kn,{children:j.code===Ll.PUBLISHED?"Your published Data Mart is ready for scheduled runs":"Draft Data Mart is not available for scheduled runs. Publish it to activate scheduling."})]}),j.code===Ll.DRAFT&&f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsxs(OE,{variant:"default",onClick:()=>{Se()},disabled:N||!P,className:"ml-2 flex items-center gap-1",children:[f.jsx(sH,{className:"h-4 w-4"}),"Publish Data Mart"]})})}),!P&&f.jsxs(kn,{children:[f.jsx("div",{children:"Cannot publish Data Mart. Fix the issues below."}),B.length>0&&f.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-4",children:net(B).map((Re,Ve)=>f.jsx("li",{children:Re},Ve))})]})]})]}),f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(OE,{variant:"ghost",children:f.jsx(XSe,{className:"h-5 w-5"})})}),f.jsxs(Ol,{align:"end",children:[U===Yt.CONNECTOR&&f.jsxs(f.Fragment,{children:[f.jsx(JNe,{configuration:W??null,onManualRun:Re=>{ue({runType:Re.runType,data:Re.data})},children:f.jsxs(wn,{onClick:Re=>{Re.preventDefault()},children:[f.jsx(rH,{className:"text-foreground h-4 w-4"}),f.jsx("span",{children:"Manual Run..."})]})}),f.jsx(Vd,{})]}),f.jsxs(wn,{onClick:()=>{T(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600"}),f.jsx("span",{className:"text-red-600",children:"Delete Data Mart"})]})]})]})]})]}),f.jsx("div",{children:f.jsx("nav",{className:"-mb-px flex space-x-4 border-b","aria-label":"Tabs",role:"tablist",children:se.map(Re=>f.jsx(uM,{to:Re.path,className:({isActive:Ve})=>Le("border-b-2 px-4 py-2 text-sm font-medium whitespace-nowrap",Ve?"border-primary text-primary":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-200 dark:hover:text-gray-200"),children:Re.name},Re.name))})}),f.jsx("div",{className:"pt-4",children:f.jsx(Tne,{context:{dataMart:s,isLoading:v,error:C,getErrorMessage:y,updateDataMartDescription:a,updateDataMartDefinition:l,actualizeDataMartSchema:c,updateDataMartSchema:d,runDataMart:h,cancelDataMartRun:g,getDataMartRuns:m,loadMoreDataMartRuns:b,runs:L,getDataMart:E,runSchemaActualization:fe,isSchemaActualizationLoading:ne}})}),f.jsx(Ma,{open:R,onOpenChange:T,title:"Delete Data Mart",description:f.jsxs(f.Fragment,{children:["Are you sure you want to delete ",f.jsxs("strong",{children:['"',V,'"']}),"? This action cannot be undone."]}),confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{(async()=>{try{await r(M),T(!1),e("/data-marts")}catch(Re){console.error("Failed to delete Data Mart:",Re)}})()}})]}):f.jsxs("div",{className:"dm-page-content flex flex-col gap-4 py-4 md:py-8",children:[f.jsx(bl,{className:"h-16 w-full"},0),Array.from({length:3}).map((Re,Ve)=>f.jsx(bl,{className:"h-48 w-full"},Ve+1))]})}function Jst({description:n,onUpdate:e,className:t,placeholder:i="Add description...",minWidth:s="100%",minHeight:r="100px"}){const[o,a]=x.useState(n??""),[l,c]=x.useState(!1),[d,u]=x.useState(!1),h=x.useRef(null);x.useEffect(()=>{a(n??"")},[n]),x.useEffect(()=>{if(h.current&&l){h.current.focus();const C=h.current.value.length;h.current.setSelectionRange(C,C),g(h.current)}},[l]);const g=C=>{C.style.height="auto",C.style.height=`${String(C.scrollHeight)}px`},m=C=>{a(C.target.value),g(C.target)},b=async()=>{const C=o.trim();if(C===(n??"")){c(!1);return}try{u(!0),await e(C===""?null:C),c(!1)}catch(L){console.error("Failed to update description:",L),a(n??"")}finally{u(!1)}},v=C=>{C.key==="Enter"&&C.ctrlKey?(C.preventDefault(),b()):C.key==="Escape"&&(C.preventDefault(),a(n??""),c(!1))};return l?f.jsxs("div",{className:"w-full",children:[f.jsx(Hp,{ref:h,value:o,onChange:m,onBlur:()=>void b(),onKeyDown:v,placeholder:i,className:Le("m-0 w-full border-0 bg-white p-2 shadow-none dark:bg-white/4","focus-visible:ring-primary focus-visible:ring-0",{"opacity-50":d}),style:{fontSize:"inherit",lineHeight:"inherit",fontFamily:"inherit",resize:"vertical",minHeight:r,minWidth:s},disabled:d}),f.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[f.jsxs("span",{children:["Press"," ",f.jsx("kbd",{className:"rounded border border-neutral-200 bg-neutral-100 px-1 py-0.5 font-sans dark:border-neutral-900 dark:bg-neutral-900",children:"Ctrl+Enter"})," ","to save •"," "]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"rounded border border-neutral-200 bg-neutral-100 px-1 py-0.5 font-sans dark:border-neutral-900 dark:bg-neutral-900",children:"Esc"})," ","to cancel •"," "]}),f.jsx("span",{children:"Changes are also saved when you click outside"})]})]}):f.jsx("div",{className:"flex w-full items-center gap-4 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-sm dark:border-0 dark:bg-white/4",children:f.jsx("div",{onClick:()=>{c(!0)},className:Le("min-h-24 cursor-pointer rounded p-2 whitespace-pre-wrap","transition-colors duration-150",!n&&"text-gray-400 italic",t),style:{minWidth:s},children:n??i})})}function ert(){const{dataMart:n,updateDataMartDescription:e}=Zu(),t=async i=>{await e(n.id,i)};return f.jsx("div",{children:f.jsx(Jst,{description:n.description,onUpdate:t,placeholder:"Add a description for this Data Mart..."})})}function Dme(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function trt(n){if(Array.isArray(n))return n}function irt(n,e,t){return(e=crt(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function nrt(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,s,r,o,a=[],l=!0,c=!1;try{if(r=(t=t.call(n)).next,e!==0)for(;!(l=(i=r.call(t)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(d){c=!0,s=d}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}function srt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
720
720
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rme(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,i)}return t}function Nme(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Rme(Object(t),!0).forEach(function(i){irt(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Rme(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function rrt(n,e){if(n==null)return{};var t,i,s=ort(n,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(i=0;i<r.length;i++)t=r[i],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function ort(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}function art(n,e){return trt(n)||nrt(n,e)||drt(n,e)||srt()}function lrt(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function crt(n){var e=lrt(n,"string");return typeof e=="symbol"?e:e+""}function drt(n,e){if(n){if(typeof n=="string")return Dme(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Dme(n,e):void 0}}function urt(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Tme(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,i)}return t}function Ime(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Tme(Object(t),!0).forEach(function(i){urt(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Tme(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function hrt(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return function(i){return e.reduceRight(function(s,r){return r(s)},i)}}function lI(n){return function e(){for(var t=this,i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length>=n.length?n.apply(this,s):function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return e.apply(t,[].concat(s,a))}}}function FF(n){return{}.toString.call(n).includes("Object")}function frt(n){return!Object.keys(n).length}function h2(n){return typeof n=="function"}function grt(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function prt(n,e){return FF(e)||a1("changeType"),Object.keys(e).some(function(t){return!grt(n,t)})&&a1("changeField"),e}function mrt(n){h2(n)||a1("selectorType")}function _rt(n){h2(n)||FF(n)||a1("handlerType"),FF(n)&&Object.values(n).some(function(e){return!h2(e)})&&a1("handlersType")}function brt(n){n||a1("initialIsRequired"),FF(n)||a1("initialType"),frt(n)&&a1("initialContent")}function vrt(n,e){throw new Error(n[e]||n.default)}var Crt={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},a1=lI(vrt)(Crt),g4={changes:prt,selector:mrt,handler:_rt,initial:brt};function wrt(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g4.initial(n),g4.handler(e);var t={current:n},i=lI(xrt)(t,e),s=lI(Srt)(t),r=lI(g4.changes)(n),o=lI(yrt)(t);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return g4.selector(c),c(t.current)}function l(c){hrt(i,s,r,o)(c)}return[a,l]}function yrt(n,e){return h2(e)?e(n.current):e}function Srt(n,e){return n.current=Ime(Ime({},n.current),e),e}function xrt(n,e,t){return h2(e)?e(n.current):Object.keys(t).forEach(function(i){var s;return(s=e[i])===null||s===void 0?void 0:s.call(e,n.current[i])}),t}var Lrt={create:wrt},Ert={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Drt(n){return function e(){for(var t=this,i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length>=n.length?n.apply(this,s):function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return e.apply(t,[].concat(s,a))}}}function Rrt(n){return{}.toString.call(n).includes("Object")}function Nrt(n){return n||kme("configIsRequired"),Rrt(n)||kme("configType"),n.urls?(Trt(),{paths:{vs:n.urls.monacoBase}}):n}function Trt(){console.warn(eTe.deprecation)}function Irt(n,e){throw new Error(n[e]||n.default)}var eTe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
721
721
|
You are using deprecated way of configuration.
|
|
722
722
|
|
|
@@ -726,24 +726,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
726
726
|
monaco.config({ paths: { vs: '...' } })
|
|
727
727
|
|
|
728
728
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
729
|
-
`},kme=Drt(Irt)(eTe),krt={config:Nrt},Art=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(s){return t.reduceRight(function(r,o){return o(r)},s)}};function tTe(n,e){return Object.keys(e).forEach(function(t){e[t]instanceof Object&&n[t]&&Object.assign(e[t],tTe(n[t],e[t]))}),Nme(Nme({},n),e)}var Mrt={type:"cancelation",msg:"operation is manually canceled"};function QU(n){var e=!1,t=new Promise(function(i,s){n.then(function(r){return e?s(Mrt):i(r)}),n.catch(s)});return t.cancel=function(){return e=!0},t}var Ort=["monaco"],Prt=Lrt.create({config:Ert,isInitialized:!1,resolve:null,reject:null,monaco:null}),iTe=art(Prt,2),jM=iTe[0],eB=iTe[1];function Frt(n){var e=krt.config(n),t=e.monaco,i=rrt(e,Ort);eB(function(s){return{config:tTe(s.config,i),monaco:t}})}function jrt(){var n=jM(function(e){var t=e.monaco,i=e.isInitialized,s=e.resolve;return{monaco:t,isInitialized:i,resolve:s}});if(!n.isInitialized){if(eB({isInitialized:!0}),n.monaco)return n.resolve(n.monaco),QU(JU);if(window.monaco&&window.monaco.editor)return nTe(window.monaco),n.resolve(window.monaco),QU(JU);Art(Hrt,Vrt)(Wrt)}return QU(JU)}function Hrt(n){return document.body.appendChild(n)}function Brt(n){var e=document.createElement("script");return n&&(e.src=n),e}function Vrt(n){var e=jM(function(i){var s=i.config,r=i.reject;return{config:s,reject:r}}),t=Brt("".concat(e.config.paths.vs,"/loader.js"));return t.onload=function(){return n()},t.onerror=e.reject,t}function Wrt(){var n=jM(function(t){var i=t.config,s=t.resolve,r=t.reject;return{config:i,resolve:s,reject:r}}),e=window.require;e.config(n.config),e(["vs/editor/editor.main"],function(t){var i=t.m||t;nTe(i),n.resolve(i)},function(t){n.reject(t)})}function nTe(n){jM().monaco||eB({monaco:n})}function zrt(){return jM(function(n){var e=n.monaco;return e})}var JU=new Promise(function(n,e){return eB({resolve:n,reject:e})}),sTe={config:Frt,init:jrt,__getMonacoInstance:zrt},Urt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},e$=Urt,$rt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Grt=$rt;function qrt({children:n}){return nt.createElement("div",{style:Grt.container},n)}var Krt=qrt,Zrt=Krt;function Yrt({width:n,height:e,isEditorReady:t,loading:i,_ref:s,className:r,wrapperProps:o}){return nt.createElement("section",{style:{...e$.wrapper,width:n,height:e},...o},!t&&nt.createElement(Zrt,null,i),nt.createElement("div",{ref:s,style:{...e$.fullWidth,...!t&&e$.hide},className:r}))}var Xrt=Yrt,rTe=x.memo(Xrt);function Qrt(n){x.useEffect(n,[])}var oTe=Qrt;function Jrt(n,e,t=!0){let i=x.useRef(!0);x.useEffect(i.current||!t?()=>{i.current=!1}:n,e)}var bu=Jrt;function OI(){}function zL(n,e,t,i){return eot(n,i)||tot(n,e,t,i)}function eot(n,e){return n.editor.getModel(aTe(n,e))}function tot(n,e,t,i){return n.editor.createModel(e,t,i?aTe(n,i):void 0)}function aTe(n,e){return n.Uri.parse(e)}function iot({original:n,modified:e,language:t,originalLanguage:i,modifiedLanguage:s,originalModelPath:r,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:l=!1,theme:c="light",loading:d="Loading...",options:u={},height:h="100%",width:g="100%",className:m,wrapperProps:b={},beforeMount:v=OI,onMount:C=OI}){let[y,L]=x.useState(!1),[E,R]=x.useState(!0),T=x.useRef(null),N=x.useRef(null),I=x.useRef(null),M=x.useRef(C),P=x.useRef(v),H=x.useRef(!1);oTe(()=>{let U=sTe.init();return U.then(B=>(N.current=B)&&R(!1)).catch(B=>(B==null?void 0:B.type)!=="cancelation"&&console.error("Monaco initialization: error:",B)),()=>T.current?W():U.cancel()}),bu(()=>{if(T.current&&N.current){let U=T.current.getOriginalEditor(),B=zL(N.current,n||"",i||t||"text",r||"");B!==U.getModel()&&U.setModel(B)}},[r],y),bu(()=>{if(T.current&&N.current){let U=T.current.getModifiedEditor(),B=zL(N.current,e||"",s||t||"text",o||"");B!==U.getModel()&&U.setModel(B)}},[o],y),bu(()=>{let U=T.current.getModifiedEditor();U.getOption(N.current.editor.EditorOption.readOnly)?U.setValue(e||""):e!==U.getValue()&&(U.executeEdits("",[{range:U.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),U.pushUndoStop())},[e],y),bu(()=>{var U,B;(B=(U=T.current)==null?void 0:U.getModel())==null||B.original.setValue(n||"")},[n],y),bu(()=>{let{original:U,modified:B}=T.current.getModel();N.current.editor.setModelLanguage(U,i||t||"text"),N.current.editor.setModelLanguage(B,s||t||"text")},[t,i,s],y),bu(()=>{var U;(U=N.current)==null||U.editor.setTheme(c)},[c],y),bu(()=>{var U;(U=T.current)==null||U.updateOptions(u)},[u],y);let j=x.useCallback(()=>{var K;if(!N.current)return;P.current(N.current);let U=zL(N.current,n||"",i||t||"text",r||""),B=zL(N.current,e||"",s||t||"text",o||"");(K=T.current)==null||K.setModel({original:U,modified:B})},[t,e,s,n,i,r,o]),V=x.useCallback(()=>{var U;!H.current&&I.current&&(T.current=N.current.editor.createDiffEditor(I.current,{automaticLayout:!0,...u}),j(),(U=N.current)==null||U.editor.setTheme(c),L(!0),H.current=!0)},[u,c,j]);x.useEffect(()=>{y&&M.current(T.current,N.current)},[y]),x.useEffect(()=>{!E&&!y&&V()},[E,y,V]);function W(){var B,K,X,ne;let U=(B=T.current)==null?void 0:B.getModel();a||((K=U==null?void 0:U.original)==null||K.dispose()),l||((X=U==null?void 0:U.modified)==null||X.dispose()),(ne=T.current)==null||ne.dispose()}return nt.createElement(rTe,{width:g,height:h,isEditorReady:y,loading:d,_ref:I,className:m,wrapperProps:b})}var not=iot;x.memo(not);function sot(n){let e=x.useRef();return x.useEffect(()=>{e.current=n},[n]),e.current}var rot=sot,p4=new Map;function oot({defaultValue:n,defaultLanguage:e,defaultPath:t,value:i,language:s,path:r,theme:o="light",line:a,loading:l="Loading...",options:c={},overrideServices:d={},saveViewState:u=!0,keepCurrentModel:h=!1,width:g="100%",height:m="100%",className:b,wrapperProps:v={},beforeMount:C=OI,onMount:y=OI,onChange:L,onValidate:E=OI}){let[R,T]=x.useState(!1),[N,I]=x.useState(!0),M=x.useRef(null),P=x.useRef(null),H=x.useRef(null),j=x.useRef(y),V=x.useRef(C),W=x.useRef(),U=x.useRef(i),B=rot(r),K=x.useRef(!1),X=x.useRef(!1);oTe(()=>{let Z=sTe.init();return Z.then(Y=>(M.current=Y)&&I(!1)).catch(Y=>(Y==null?void 0:Y.type)!=="cancelation"&&console.error("Monaco initialization: error:",Y)),()=>P.current?fe():Z.cancel()}),bu(()=>{var Y,ee,se,ae;let Z=zL(M.current,n||i||"",e||s||"",r||t||"");Z!==((Y=P.current)==null?void 0:Y.getModel())&&(u&&p4.set(B,(ee=P.current)==null?void 0:ee.saveViewState()),(se=P.current)==null||se.setModel(Z),u&&((ae=P.current)==null||ae.restoreViewState(p4.get(r))))},[r],R),bu(()=>{var Z;(Z=P.current)==null||Z.updateOptions(c)},[c],R),bu(()=>{!P.current||i===void 0||(P.current.getOption(M.current.editor.EditorOption.readOnly)?P.current.setValue(i):i!==P.current.getValue()&&(X.current=!0,P.current.executeEdits("",[{range:P.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),P.current.pushUndoStop(),X.current=!1))},[i],R),bu(()=>{var Y,ee;let Z=(Y=P.current)==null?void 0:Y.getModel();Z&&s&&((ee=M.current)==null||ee.editor.setModelLanguage(Z,s))},[s],R),bu(()=>{var Z;a!==void 0&&((Z=P.current)==null||Z.revealLine(a))},[a],R),bu(()=>{var Z;(Z=M.current)==null||Z.editor.setTheme(o)},[o],R);let ne=x.useCallback(()=>{var Z;if(!(!H.current||!M.current)&&!K.current){V.current(M.current);let Y=r||t,ee=zL(M.current,i||n||"",e||s||"",Y||"");P.current=(Z=M.current)==null?void 0:Z.editor.create(H.current,{model:ee,automaticLayout:!0,...c},d),u&&P.current.restoreViewState(p4.get(Y)),M.current.editor.setTheme(o),a!==void 0&&P.current.revealLine(a),T(!0),K.current=!0}},[n,e,t,i,s,r,c,d,u,o,a]);x.useEffect(()=>{R&&j.current(P.current,M.current)},[R]),x.useEffect(()=>{!N&&!R&&ne()},[N,R,ne]),U.current=i,x.useEffect(()=>{var Z,Y;R&&L&&((Z=W.current)==null||Z.dispose(),W.current=(Y=P.current)==null?void 0:Y.onDidChangeModelContent(ee=>{X.current||L(P.current.getValue(),ee)}))},[R,L]),x.useEffect(()=>{if(R){let Z=M.current.editor.onDidChangeMarkers(Y=>{var se;let ee=(se=P.current.getModel())==null?void 0:se.uri;if(ee&&Y.find(ae=>ae.path===ee.path)){let ae=M.current.editor.getModelMarkers({resource:ee});E==null||E(ae)}});return()=>{Z==null||Z.dispose()}}return()=>{}},[R,E]);function fe(){var Z,Y;(Z=W.current)==null||Z.dispose(),h?u&&p4.set(r,P.current.saveViewState()):(Y=P.current.getModel())==null||Y.dispose(),P.current.dispose()}return nt.createElement(rTe,{width:g,height:m,isEditorReady:R,loading:l,_ref:H,className:b,wrapperProps:v})}var aot=oot,vre=x.memo(aot);function lot({initialValue:n,onChange:e}){const[t,i]=x.useState((n==null?void 0:n.sqlQuery)??""),{resolvedTheme:s}=AH();x.useEffect(()=>{n!=null&&n.sqlQuery&&n.sqlQuery!==t&&i(n.sqlQuery)},[n,t]);function r(o){o!==void 0&&(i(o),e({sqlQuery:o}))}return f.jsx("div",{className:"shadow-xs",children:f.jsx(vre,{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-200/4",height:"30vh",language:"sql",value:t,onChange:r,theme:s==="dark"?"vs-dark":"light",options:{selectOnLineNumbers:!0,hideCursorInOverviewRuler:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,overviewRulerBorder:!1}})})}function GK({icon:n,title:e,subtitle:t,rightContent:i,onClick:s,className:r}){const o=n;return f.jsxs("div",{className:Le("group flex items-center gap-4 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-xs dark:border-0 dark:bg-white/2",s&&"cursor-pointer dark:hover:bg-white/5",r),onClick:s,children:[f.jsxs("div",{className:"flex flex-grow items-start justify-center gap-3 px-6 py-5",children:[n&&f.jsx("div",{className:"flex items-center justify-center",children:f.jsx(o,{className:"h-6 w-6"})}),f.jsxs("div",{className:"flex flex-grow flex-col gap-1",children:[f.jsx("div",{className:"text-md font-medium",children:e}),t&&f.jsx("div",{className:"text-muted-foreground/60 text-sm",children:t})]})]}),f.jsxs("div",{className:"flex items-center justify-center gap-2 p-4",children:[i,s&&f.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 group-hover:bg-gray-200/50 dark:group-hover:bg-white/4",children:f.jsx($d,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})]})]})}var Ame=1,cot=.9,dot=.8,uot=.17,t$=.1,i$=.999,hot=.9999,fot=.99,got=/[\\\/_+.#"@\[\(\{&]/,pot=/[\\\/_+.#"@\[\(\{&]/g,mot=/[\s-]/,lTe=/[\s-]/g;function qK(n,e,t,i,s,r,o){if(r===e.length)return s===n.length?Ame:fot;var a=`${s},${r}`;if(o[a]!==void 0)return o[a];for(var l=i.charAt(r),c=t.indexOf(l,s),d=0,u,h,g,m;c>=0;)u=qK(n,e,t,i,c+1,r+1,o),u>d&&(c===s?u*=Ame:got.test(n.charAt(c-1))?(u*=dot,g=n.slice(s,c-1).match(pot),g&&s>0&&(u*=Math.pow(i$,g.length))):mot.test(n.charAt(c-1))?(u*=cot,m=n.slice(s,c-1).match(lTe),m&&s>0&&(u*=Math.pow(i$,m.length))):(u*=uot,s>0&&(u*=Math.pow(i$,c-s))),n.charAt(c)!==e.charAt(r)&&(u*=hot)),(u<t$&&t.charAt(c-1)===i.charAt(r+1)||i.charAt(r+1)===i.charAt(r)&&t.charAt(c-1)!==i.charAt(r))&&(h=qK(n,e,t,i,c+1,r+2,o),h*t$>u&&(u=h*t$)),u>d&&(d=u),c=t.indexOf(l,c+1);return o[a]=d,d}function Mme(n){return n.toLowerCase().replace(lTe," ")}function _ot(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,qK(n,e,Mme(n),Mme(e),0,0,{})}var bT='[cmdk-group=""]',n$='[cmdk-group-items=""]',bot='[cmdk-group-heading=""]',cTe='[cmdk-item=""]',Ome=`${cTe}:not([aria-disabled="true"])`,KK="cmdk-item-select",TL="data-value",vot=(n,e,t)=>_ot(n,e,t),dTe=x.createContext(void 0),HM=()=>x.useContext(dTe),uTe=x.createContext(void 0),Cre=()=>x.useContext(uTe),hTe=x.createContext(void 0),fTe=x.forwardRef((n,e)=>{let t=IL(()=>{var Y,ee;return{search:"",value:(ee=(Y=n.value)!=null?Y:n.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=IL(()=>new Set),s=IL(()=>new Map),r=IL(()=>new Map),o=IL(()=>new Set),a=gTe(n),{label:l,children:c,value:d,onValueChange:u,filter:h,shouldFilter:g,loop:m,disablePointerSelection:b=!1,vimBindings:v=!0,...C}=n,y=To(),L=To(),E=To(),R=x.useRef(null),T=Tot();X0(()=>{if(d!==void 0){let Y=d.trim();t.current.value=Y,N.emit()}},[d]),X0(()=>{T(6,V)},[]);let N=x.useMemo(()=>({subscribe:Y=>(o.current.add(Y),()=>o.current.delete(Y)),snapshot:()=>t.current,setState:(Y,ee,se)=>{var ae,Se,ue,Re;if(!Object.is(t.current[Y],ee)){if(t.current[Y]=ee,Y==="search")j(),P(),T(1,H);else if(Y==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ve=document.getElementById(E);Ve?Ve.focus():(ae=document.getElementById(y))==null||ae.focus()}if(T(7,()=>{var Ve;t.current.selectedItemId=(Ve=W())==null?void 0:Ve.id,N.emit()}),se||T(5,V),((Se=a.current)==null?void 0:Se.value)!==void 0){let Ve=ee??"";(Re=(ue=a.current).onValueChange)==null||Re.call(ue,Ve);return}}N.emit()}},emit:()=>{o.current.forEach(Y=>Y())}}),[]),I=x.useMemo(()=>({value:(Y,ee,se)=>{var ae;ee!==((ae=r.current.get(Y))==null?void 0:ae.value)&&(r.current.set(Y,{value:ee,keywords:se}),t.current.filtered.items.set(Y,M(ee,se)),T(2,()=>{P(),N.emit()}))},item:(Y,ee)=>(i.current.add(Y),ee&&(s.current.has(ee)?s.current.get(ee).add(Y):s.current.set(ee,new Set([Y]))),T(3,()=>{j(),P(),t.current.value||H(),N.emit()}),()=>{r.current.delete(Y),i.current.delete(Y),t.current.filtered.items.delete(Y);let se=W();T(4,()=>{j(),(se==null?void 0:se.getAttribute("id"))===Y&&H(),N.emit()})}),group:Y=>(s.current.has(Y)||s.current.set(Y,new Set),()=>{r.current.delete(Y),s.current.delete(Y)}),filter:()=>a.current.shouldFilter,label:l||n["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:y,inputId:E,labelId:L,listInnerRef:R}),[]);function M(Y,ee){var se,ae;let Se=(ae=(se=a.current)==null?void 0:se.filter)!=null?ae:vot;return Y?Se(Y,t.current.search,ee):0}function P(){if(!t.current.search||a.current.shouldFilter===!1)return;let Y=t.current.filtered.items,ee=[];t.current.filtered.groups.forEach(ae=>{let Se=s.current.get(ae),ue=0;Se.forEach(Re=>{let Ve=Y.get(Re);ue=Math.max(Ve,ue)}),ee.push([ae,ue])});let se=R.current;U().sort((ae,Se)=>{var ue,Re;let Ve=ae.getAttribute("id"),Qe=Se.getAttribute("id");return((ue=Y.get(Qe))!=null?ue:0)-((Re=Y.get(Ve))!=null?Re:0)}).forEach(ae=>{let Se=ae.closest(n$);Se?Se.appendChild(ae.parentElement===Se?ae:ae.closest(`${n$} > *`)):se.appendChild(ae.parentElement===se?ae:ae.closest(`${n$} > *`))}),ee.sort((ae,Se)=>Se[1]-ae[1]).forEach(ae=>{var Se;let ue=(Se=R.current)==null?void 0:Se.querySelector(`${bT}[${TL}="${encodeURIComponent(ae[0])}"]`);ue==null||ue.parentElement.appendChild(ue)})}function H(){let Y=U().find(se=>se.getAttribute("aria-disabled")!=="true"),ee=Y==null?void 0:Y.getAttribute(TL);N.setState("value",ee||void 0)}function j(){var Y,ee,se,ae;if(!t.current.search||a.current.shouldFilter===!1){t.current.filtered.count=i.current.size;return}t.current.filtered.groups=new Set;let Se=0;for(let ue of i.current){let Re=(ee=(Y=r.current.get(ue))==null?void 0:Y.value)!=null?ee:"",Ve=(ae=(se=r.current.get(ue))==null?void 0:se.keywords)!=null?ae:[],Qe=M(Re,Ve);t.current.filtered.items.set(ue,Qe),Qe>0&&Se++}for(let[ue,Re]of s.current)for(let Ve of Re)if(t.current.filtered.items.get(Ve)>0){t.current.filtered.groups.add(ue);break}t.current.filtered.count=Se}function V(){var Y,ee,se;let ae=W();ae&&(((Y=ae.parentElement)==null?void 0:Y.firstChild)===ae&&((se=(ee=ae.closest(bT))==null?void 0:ee.querySelector(bot))==null||se.scrollIntoView({block:"nearest"})),ae.scrollIntoView({block:"nearest"}))}function W(){var Y;return(Y=R.current)==null?void 0:Y.querySelector(`${cTe}[aria-selected="true"]`)}function U(){var Y;return Array.from(((Y=R.current)==null?void 0:Y.querySelectorAll(Ome))||[])}function B(Y){let ee=U()[Y];ee&&N.setState("value",ee.getAttribute(TL))}function K(Y){var ee;let se=W(),ae=U(),Se=ae.findIndex(Re=>Re===se),ue=ae[Se+Y];(ee=a.current)!=null&&ee.loop&&(ue=Se+Y<0?ae[ae.length-1]:Se+Y===ae.length?ae[0]:ae[Se+Y]),ue&&N.setState("value",ue.getAttribute(TL))}function X(Y){let ee=W(),se=ee==null?void 0:ee.closest(bT),ae;for(;se&&!ae;)se=Y>0?Rot(se,bT):Not(se,bT),ae=se==null?void 0:se.querySelector(Ome);ae?N.setState("value",ae.getAttribute(TL)):K(Y)}let ne=()=>B(U().length-1),fe=Y=>{Y.preventDefault(),Y.metaKey?ne():Y.altKey?X(1):K(1)},Z=Y=>{Y.preventDefault(),Y.metaKey?B(0):Y.altKey?X(-1):K(-1)};return x.createElement(ui.div,{ref:e,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:Y=>{var ee;(ee=C.onKeyDown)==null||ee.call(C,Y);let se=Y.nativeEvent.isComposing||Y.keyCode===229;if(!(Y.defaultPrevented||se))switch(Y.key){case"n":case"j":{v&&Y.ctrlKey&&fe(Y);break}case"ArrowDown":{fe(Y);break}case"p":case"k":{v&&Y.ctrlKey&&Z(Y);break}case"ArrowUp":{Z(Y);break}case"Home":{Y.preventDefault(),B(0);break}case"End":{Y.preventDefault(),ne();break}case"Enter":{Y.preventDefault();let ae=W();if(ae){let Se=new Event(KK);ae.dispatchEvent(Se)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:I.inputId,id:I.labelId,style:kot},l),tB(n,Y=>x.createElement(uTe.Provider,{value:N},x.createElement(dTe.Provider,{value:I},Y))))}),Cot=x.forwardRef((n,e)=>{var t,i;let s=To(),r=x.useRef(null),o=x.useContext(hTe),a=HM(),l=gTe(n),c=(i=(t=l.current)==null?void 0:t.forceMount)!=null?i:o==null?void 0:o.forceMount;X0(()=>{if(!c)return a.item(s,o==null?void 0:o.id)},[c]);let d=pTe(s,r,[n.value,n.children,r],n.keywords),u=Cre(),h=U1(T=>T.value&&T.value===d.current),g=U1(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(s)>0:!0);x.useEffect(()=>{let T=r.current;if(!(!T||n.disabled))return T.addEventListener(KK,m),()=>T.removeEventListener(KK,m)},[g,n.onSelect,n.disabled]);function m(){var T,N;b(),(N=(T=l.current).onSelect)==null||N.call(T,d.current)}function b(){u.setState("value",d.current,!0)}if(!g)return null;let{disabled:v,value:C,onSelect:y,forceMount:L,keywords:E,...R}=n;return x.createElement(ui.div,{ref:ac(r,e),...R,id:s,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!h,"data-disabled":!!v,"data-selected":!!h,onPointerMove:v||a.getDisablePointerSelection()?void 0:b,onClick:v?void 0:m},n.children)}),wot=x.forwardRef((n,e)=>{let{heading:t,children:i,forceMount:s,...r}=n,o=To(),a=x.useRef(null),l=x.useRef(null),c=To(),d=HM(),u=U1(g=>s||d.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);X0(()=>d.group(o),[]),pTe(o,a,[n.value,n.heading,l]);let h=x.useMemo(()=>({id:o,forceMount:s}),[s]);return x.createElement(ui.div,{ref:ac(a,e),...r,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&x.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),tB(n,g=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},x.createElement(hTe.Provider,{value:h},g))))}),yot=x.forwardRef((n,e)=>{let{alwaysRender:t,...i}=n,s=x.useRef(null),r=U1(o=>!o.search);return!t&&!r?null:x.createElement(ui.div,{ref:ac(s,e),...i,"cmdk-separator":"",role:"separator"})}),Sot=x.forwardRef((n,e)=>{let{onValueChange:t,...i}=n,s=n.value!=null,r=Cre(),o=U1(c=>c.search),a=U1(c=>c.selectedItemId),l=HM();return x.useEffect(()=>{n.value!=null&&r.setState("search",n.value)},[n.value]),x.createElement(ui.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?n.value:o,onChange:c=>{s||r.setState("search",c.target.value),t==null||t(c.target.value)}})}),xot=x.forwardRef((n,e)=>{let{children:t,label:i="Suggestions",...s}=n,r=x.useRef(null),o=x.useRef(null),a=U1(c=>c.selectedItemId),l=HM();return x.useEffect(()=>{if(o.current&&r.current){let c=o.current,d=r.current,u,h=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let g=c.offsetHeight;d.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(u),h.unobserve(c)}}},[]),x.createElement(ui.div,{ref:ac(r,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":i,id:l.listId},tB(n,c=>x.createElement("div",{ref:ac(o,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Lot=x.forwardRef((n,e)=>{let{open:t,onOpenChange:i,overlayClassName:s,contentClassName:r,container:o,...a}=n;return x.createElement(uH,{open:t,onOpenChange:i},x.createElement(hH,{container:o},x.createElement(fH,{"cmdk-overlay":"",className:s}),x.createElement(gH,{"aria-label":n.label,"cmdk-dialog":"",className:r},x.createElement(fTe,{ref:e,...a}))))}),Eot=x.forwardRef((n,e)=>U1(t=>t.filtered.count===0)?x.createElement(ui.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),Dot=x.forwardRef((n,e)=>{let{progress:t,children:i,label:s="Loading...",...r}=n;return x.createElement(ui.div,{ref:e,...r,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},tB(n,o=>x.createElement("div",{"aria-hidden":!0},o)))}),zR=Object.assign(fTe,{List:xot,Item:Cot,Input:Sot,Group:wot,Separator:yot,Dialog:Lot,Empty:Eot,Loading:Dot});function Rot(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function Not(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function gTe(n){let e=x.useRef(n);return X0(()=>{e.current=n}),e}var X0=typeof window>"u"?x.useEffect:x.useLayoutEffect;function IL(n){let e=x.useRef();return e.current===void 0&&(e.current=n()),e}function U1(n){let e=Cre(),t=()=>n(e.snapshot());return x.useSyncExternalStore(e.subscribe,t,t)}function pTe(n,e,t,i=[]){let s=x.useRef(),r=HM();return X0(()=>{var o;let a=(()=>{var c;for(let d of t){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():s.current}})(),l=i.map(c=>c.trim());r.value(n,a,l),(o=e.current)==null||o.setAttribute(TL,a),s.current=a}),s}var Tot=()=>{let[n,e]=x.useState(),t=IL(()=>new Map);return X0(()=>{t.current.forEach(i=>i()),t.current=new Map},[n]),(i,s)=>{t.current.set(i,s),e({})}};function Iot(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function tB({asChild:n,children:e},t){return n&&x.isValidElement(e)?x.cloneElement(Iot(e),{ref:e.ref},t(e.props.children)):t(e)}var kot={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function mTe({className:n,...e}){return f.jsx(zR,{"data-slot":"command",className:Le("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",n),...e})}function _Te({className:n,...e}){return f.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[f.jsx(FS,{className:"size-4 shrink-0 opacity-50"}),f.jsx(zR.Input,{"data-slot":"command-input",className:Le("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",n),...e})]})}function Aot({className:n,...e}){return f.jsx(zR.List,{"data-slot":"command-list",className:Le("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",n),...e})}function bTe({...n}){return f.jsx(zR.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...n})}function vTe({className:n,...e}){return f.jsx(zR.Group,{"data-slot":"command-group",className:Le("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",n),...e})}function CTe({className:n,...e}){return f.jsx(zR.Item,{"data-slot":"command-item",className:Le("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function Mot(n){const e=Oot(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Fot);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Oot(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Hot(s),a=jot(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Pot=Symbol("radix.slottable");function Fot(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Pot}function jot(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Hot(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var iB="Popover",[wTe]=Ha(iB,[jp]),BM=jp(),[Bot,LC]=wTe(iB),yTe=n=>{const{__scopePopover:e,children:t,open:i,defaultOpen:s,onOpenChange:r,modal:o=!1}=n,a=BM(e),l=x.useRef(null),[c,d]=x.useState(!1),[u,h]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:iB});return f.jsx(OR,{...a,children:f.jsx(Bot,{scope:e,contentId:To(),triggerRef:l,open:u,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:c,onCustomAnchorAdd:x.useCallback(()=>d(!0),[]),onCustomAnchorRemove:x.useCallback(()=>d(!1),[]),modal:o,children:t})})};yTe.displayName=iB;var STe="PopoverAnchor",Vot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(STe,t),r=BM(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return x.useEffect(()=>(o(),()=>a()),[o,a]),f.jsx(PR,{...r,...i,ref:e})});Vot.displayName=STe;var xTe="PopoverTrigger",LTe=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(xTe,t),r=BM(t),o=Ui(e,s.triggerRef),a=f.jsx(ui.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":TTe(s.open),...i,ref:o,onClick:Lt(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:f.jsx(PR,{asChild:!0,...r,children:a})});LTe.displayName=xTe;var wre="PopoverPortal",[Wot,zot]=wTe(wre,{forceMount:void 0}),ETe=n=>{const{__scopePopover:e,forceMount:t,children:i,container:s}=n,r=LC(wre,e);return f.jsx(Wot,{scope:e,forceMount:t,children:f.jsx(kl,{present:t||r.open,children:f.jsx(HS,{asChild:!0,container:s,children:i})})})};ETe.displayName=wre;var BD="PopoverContent",DTe=x.forwardRef((n,e)=>{const t=zot(BD,n.__scopePopover),{forceMount:i=t.forceMount,...s}=n,r=LC(BD,n.__scopePopover);return f.jsx(kl,{present:i||r.open,children:r.modal?f.jsx($ot,{...s,ref:e}):f.jsx(Got,{...s,ref:e})})});DTe.displayName=BD;var Uot=Mot("PopoverContent.RemoveScroll"),$ot=x.forwardRef((n,e)=>{const t=LC(BD,n.__scopePopover),i=x.useRef(null),s=Ui(e,i),r=x.useRef(!1);return x.useEffect(()=>{const o=i.current;if(o)return cH(o)},[]),f.jsx(pM,{as:Uot,allowPinchZoom:!0,children:f.jsx(RTe,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lt(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),r.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Lt(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;r.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Lt(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Got=x.forwardRef((n,e)=>{const t=LC(BD,n.__scopePopover),i=x.useRef(!1),s=x.useRef(!1);return f.jsx(RTe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,r),r.defaultPrevented||(i.current||(a=t.triggerRef.current)==null||a.focus(),r.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:r=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,r),r.defaultPrevented||(i.current=!0,r.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=r.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&s.current&&r.preventDefault()}})}),RTe=x.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:r,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...u}=n,h=LC(BD,t),g=BM(t);return aH(),f.jsx(gM,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:r,children:f.jsx(jS,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(_M,{"data-state":TTe(h.open),role:"dialog",id:h.contentId,...g,...u,ref:e,style:{...u.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)"}})})})}),NTe="PopoverClose",qot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(NTe,t);return f.jsx(ui.button,{type:"button",...i,ref:e,onClick:Lt(n.onClick,()=>s.onOpenChange(!1))})});qot.displayName=NTe;var Kot="PopoverArrow",Zot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=BM(t);return f.jsx(bM,{...s,...i,ref:e})});Zot.displayName=Kot;function TTe(n){return n?"open":"closed"}var Yot=yTe,Xot=LTe,Qot=ETe,Jot=DTe;function yre({...n}){return f.jsx(Yot,{"data-slot":"popover",...n})}function Sre({...n}){return f.jsx(Xot,{"data-slot":"popover-trigger",...n})}function xre({className:n,align:e="center",sideOffset:t=4,...i}){return f.jsx(Qot,{children:f.jsx(Jot,{"data-slot":"popover-content",align:e,sideOffset:t,className:Le("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",n),...i})})}function Lre({options:n,value:e,onValueChange:t,placeholder:i="Select an option",emptyMessage:s="No results found.",className:r,disabled:o=!1}){const[a,l]=x.useState(!1),[c,d]=x.useState(""),u=x.useMemo(()=>{const m={};return n.forEach(b=>{const v=b.group??"";Object.prototype.hasOwnProperty.call(m,v)||(m[v]=[]),m[v].push(b)}),m},[n]),h=n.find(m=>m.value===e),g=x.useCallback(m=>{t(m),requestAnimationFrame(()=>{d(""),l(!1)})},[t]);return f.jsxs(yre,{open:a,onOpenChange:l,modal:!0,children:[f.jsx(Sre,{asChild:!0,children:f.jsxs(rt,{variant:"outline",role:"combobox","aria-expanded":a,className:Le("w-full justify-between",!e&&"text-muted-foreground",r),disabled:o,children:[h?h.label:i,f.jsx(One,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(xre,{className:"max-h-[300px] min-w-[300px] overflow-auto p-0",align:"start",sideOffset:5,children:f.jsxs(mTe,{children:[f.jsx(_Te,{placeholder:`Search ${i.toLowerCase()}...`,value:c,onValueChange:d}),f.jsx(bTe,{children:s}),Object.entries(u).map(([m,b])=>f.jsx(vTe,{heading:m,children:b.map(v=>f.jsxs(CTe,{value:v.value,onSelect:()=>{g(v.value)},keywords:[v.label],children:[f.jsx(Wc,{className:Le("mr-2 h-4 w-4",e===v.value?"opacity-100":"opacity-0")}),v.label]},v.value))},m||"default"))]})})]})}function eat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a Service Account JSON key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the JSON key, you'll need to create or use an existing service account in Google Cloud."}),f.jsx("p",{className:"mb-2",children:"Here's what to do:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Go to"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"}),"."]}),f.jsxs("li",{children:["Open ",f.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),f.jsx("li",{children:"Create a new service account or select an existing one."}),f.jsxs("li",{children:["Assign the ",f.jsx("strong",{children:"bigquery.dataEditor"})," and ",f.jsx("strong",{children:"bigquery.jobUser"})," ","roles to this service account to allow read, write, and create access to your project resources."]}),f.jsxs("li",{children:["Open the Service Accounts page, go to the ",f.jsx("strong",{children:"Keys"})," tab, click"," ",f.jsx("strong",{children:"Add key"}),", and select ",f.jsx("strong",{children:"Create new key"}),"."]}),f.jsxs("li",{children:["Choose ",f.jsx("strong",{children:"JSON"})," format and click ",f.jsx("strong",{children:"Create"}),"."]}),f.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function tat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"project-id-details",children:[f.jsx(is,{children:"How do I find my Project ID?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"This is the ID of your Google Cloud project. BigQuery usage costs will be charged to this project."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your billing project ID:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/",children:"Google Cloud Console"})," ","and sign in with your Google account."]}),f.jsx("li",{children:'Click the project selector dropdown at the top of the page (it shows the current project name or "Select a project").'}),f.jsxs("li",{children:["Find your project in the list. The ",f.jsx("strong",{children:"Project ID"})," is shown in the ID column."]}),f.jsx("li",{children:"If you don't see your project, use the search box to find it by name or ID."})]})]})]})})}function iat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"gbq-location-details",children:[f.jsx(is,{children:"How do I find my dataset location?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"BigQuery data is stored in specific regions. To avoid query errors, your SQL queries must process data stored in the same location."}),f.jsx("p",{className:"mb-2",children:"Here's how to check your dataset location:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/bigquery",children:"Google Cloud Console BigQuery page"}),"."]}),f.jsx("li",{children:"In the left panel, expand your project and find your datasets."}),f.jsxs("li",{children:["Click each dataset name to open its details. The ",f.jsx("strong",{children:"Data location"})," field shows the region where that dataset is stored (for example,"," ",f.jsx("code",{className:"text-sm font-semibold",children:"US"}),","," ",f.jsx("code",{className:"text-sm font-semibold",children:"EU"}),","," ",f.jsx("code",{className:"text-sm font-semibold",children:"asia-northeast1"}),")."]}),f.jsx("li",{children:"Make sure all your datasets are stored in the same location. If they are in different locations, select the location where most of your data is stored or create separate Storage for each location."}),f.jsx("li",{children:"Put this location value in the field above."})]})]})]})})}const nat=({form:n})=>{const[e,t]=x.useState(!1);if(n.watch("type")!==lt.GOOGLE_BIGQUERY)return null;const i=()=>{t(!0),n.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{t(!1),n.resetField("credentials.serviceAccount")},r=n.watch("credentials.serviceAccount"),o=r?xRe(r):null;return f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.projectId",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the ID of your Google Cloud project where BigQuery usage will be billed",children:"Project ID"}),f.jsx(cn,{children:f.jsx(vn,{...a,placeholder:"Enter a Project Id"})}),f.jsx(Hs,{children:f.jsx(tat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.location",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Choose the same region where your BigQuery data is stored to ensure queries work correctly",children:"Location"}),f.jsx(cn,{children:f.jsx(Lre,{options:vQe,value:a.value,onValueChange:a.onChange,placeholder:"Select a location",emptyMessage:"No locations found",className:"w-full"})}),f.jsx(Hs,{children:f.jsx(iat,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Authentication",children:f.jsx(fn,{control:n.control,name:"credentials.serviceAccount",render:({field:a})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{tooltip:"Paste a JSON key from a service account that has access to the selected storage provider",children:"Service Account"}),!e&&r&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:i,type:"button",children:"Edit"}),e&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),f.jsx(cn,{children:!e&&o?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(ir,{href:o.url,children:o.email})}),f.jsx(kn,{children:f.jsx("p",{children:"View in Google Cloud Console"})})]}):f.jsx(Hp,{...a,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),f.jsx(Hs,{children:f.jsx(eat,{})}),f.jsx(Cn,{})]})})})]})};function sat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-region-details",children:[f.jsx(is,{children:"How do I find my Athena region?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Athena queries run in a specific AWS region. You must select the region where your Athena service and data are located."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your Athena region:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"}),"."]}),f.jsx("li",{children:"Look at the top right corner of the console. The selected region is shown in the region selector dropdown."}),f.jsx("li",{children:"Make sure to copy and paste the same region here in the form to avoid connection or query errors."})]})]})]})})}function rat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-output-bucket-details",children:[f.jsx(is,{children:"How do I find a bucket?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["Athena saves query results in an ",f.jsx("strong",{children:"S3 bucket"}),". You need to specify the bucket used for query output."]}),f.jsx("p",{className:"mb-2",children:"Here's how to find or create an S3 bucket for Athena output:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/s3/",children:"the AWS S3 console"}),"."]}),f.jsx("li",{children:"Look for an existing bucket used for Athena query results, or create a new one."}),f.jsx("li",{children:"If creating a new bucket, make sure it is in the same region as your Athena service."}),f.jsx("li",{children:"Enter the bucket name in this form field."})]})]})]})})}function oat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-access-key-id-details",children:[f.jsx(is,{children:"How do I get my AWS Access Key ID?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Before accessing your AWS Access Key ID, make sure you have a user with the necessary permissions to use Athena and Glue in your AWS account."}),f.jsxs("p",{className:"mb-4 text-sm",children:["Learn more about how to create a user in AWS ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/storages/supported-storages/aws-athena/?utm_source=owox_data_marts&utm_medium=storage_enity&utm_campaign=tooltip_aws",children:"in documentation"}),"."]}),f.jsx(Cxe,{className:"my-4"}),f.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS credentials needed to connect and authenticate."}),f.jsx("p",{className:"mb-2",children:"Here's how to find or create an Access Key ID:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),f.jsxs("li",{children:["Under ",f.jsx("strong",{children:"Access keys"}),", find your existing keys or create a new access key."]}),f.jsx("li",{children:"When you create a new key, download and securely store the Access Key ID and Secret Access Key."})]})]})]})})}function aat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-secret-access-key-details",children:[f.jsx(is,{children:"How do I get my AWS Secret Access Key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The Secret Access Key is part of your AWS credentials needed to connect and authenticate. It is only shown when you create a new key."}),f.jsx("p",{className:"mb-2",children:"Here's how to get your Secret Access Key:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),f.jsxs("li",{children:["Under ",f.jsx("strong",{children:"Access keys"}),", create a new access key if you don't have one or lost the secret key."]}),f.jsx("li",{children:"When you create a new key, copy and securely store the Secret Access Key — you won't be able to see it again."})]})]})]})})}const lat=({form:n})=>{const[e,t]=x.useState("");return x.useEffect(()=>{const i=n.getValues("credentials.accessKeyId");if(i){const s="_".repeat(i.length);t(s),n.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[n]),n.watch("type")!==lt.AWS_ATHENA?null:f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.region",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the AWS region where your Athena service is active",children:"Region"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter a region"})}),f.jsx(Hs,{children:f.jsx(sat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.outputBucket",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Specify the S3 bucket where Athena query results will be stored",children:"Output Bucket"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter an output bucket"})}),f.jsx(Hs,{children:f.jsx(rat,{})}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Authentication",children:[f.jsx(fn,{control:n.control,name:"credentials.accessKeyId",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter an access key id"})}),f.jsx(Hs,{children:f.jsx(oat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.secretAccessKey",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),f.jsx(cn,{children:f.jsx(vn,{...i,type:"password",placeholder:e||"Enter a secret access key"})}),f.jsx(Hs,{children:f.jsx(aat,{})}),f.jsx(Cn,{})]})})]})]})};function cat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-account-details",children:[f.jsx(is,{children:"How do I find my Snowflake account identifier?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["Your Snowflake account identifier is in the URL when you"," ",f.jsx(ir,{className:"underline",href:"https://app.snowflake.com/",children:"log into Snowflake"}),". The format depends on your Snowflake URL type:"]}),f.jsxs("ol",{className:"list-inside list-decimal space-y-3 text-sm",children:[f.jsxs("li",{children:[f.jsx("strong",{children:"app.snowflake.com format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://app.snowflake.com/europe-west3.gcp/xy12345/"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.europe-west3.gcp"})]}),f.jsxs("li",{children:[f.jsx("strong",{children:"snowflakecomputing.com format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://xy12345.us-east-1.snowflakecomputing.com"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.us-east-1"})]}),f.jsxs("li",{children:[f.jsx("strong",{children:"Organization format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://myorg-account123.snowflakecomputing.com"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"myorg-account123"})]})]})]})]})})}function dat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-warehouse-details",children:[f.jsx(is,{children:"How do I find my Snowflake warehouse?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A warehouse in Snowflake is a cluster of compute resources that executes queries and performs data loading operations."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your warehouse:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:'Log in to your Snowflake account and navigate to the "Warehouses" section in the left sidebar.'}),f.jsx("li",{children:`You'll see a list of available warehouses. Common default names include "COMPUTE_WH" or "PROD_WH".`}),f.jsx("li",{children:"Select the warehouse you want to use for this connection. Make sure it has the appropriate size and auto-suspend settings for your workload."}),f.jsx("li",{children:`If you don't have a warehouse, you can create one using the "Create Warehouse" button or run: CREATE WAREHOUSE my_warehouse;`})]})]})]})})}function uat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-auth-method-details",children:[f.jsx(is,{children:"Which authentication method should I choose?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Snowflake supports two authentication methods for programmatic access:"}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{children:[f.jsx("strong",{className:"font-medium",children:"Username & Password:"}),f.jsx("p",{className:"mt-1",children:"The simplest method using your Snowflake username and password. Suitable for development and testing environments."})]}),f.jsxs("div",{children:[f.jsx("strong",{className:"font-medium",children:"Key Pair Authentication:"}),f.jsx("p",{className:"mt-1",children:"More secure method using public/private key cryptography. Recommended for production environments. You'll need to generate an RSA key pair and assign the public key to your Snowflake user."}),f.jsxs("p",{className:"mt-1",children:["Learn more about"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"key pair authentication"}),"."]})]})]})]})]})})}function hat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-username-details",children:[f.jsx(is,{children:"How do I find my Snowflake username?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Your Snowflake username is the login identifier for your Snowflake account."}),f.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"Use the same username you use to log in to the Snowflake web interface."}),f.jsx("li",{children:"Snowflake usernames are case-insensitive and are typically in uppercase by default."}),f.jsx("li",{children:"If you're using SSO (Single Sign-On) for the web interface, you may need to create a separate user account with password authentication for programmatic access."}),f.jsx("li",{children:"You can view all users in your account by running: SHOW USERS; (requires appropriate privileges)"})]})]})]})})}function fat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-password-details",children:[f.jsx(is,{children:"How do I manage my Snowflake password?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Use the password associated with your Snowflake user account for authentication."}),f.jsx("p",{className:"mb-2",children:"Important security considerations:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"Your password must meet Snowflake's security requirements (minimum length, complexity, etc.)."}),f.jsx("li",{children:"If you've forgotten your password, a Snowflake administrator can reset it using: ALTER USER username SET PASSWORD = 'new_password';"}),f.jsxs("li",{children:["For production environments, consider using"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Key-Pair authentication"})," ","instead of passwords for enhanced security."]}),f.jsx("li",{children:"Your password is encrypted and securely stored. It will never be displayed in plain text after saving."})]})]})]})})}function gat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-keypair-details",children:[f.jsx(is,{children:"How do I set up key pair authentication?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To use key pair authentication, you need to generate an RSA key pair and configure your Snowflake user."}),f.jsx("p",{className:"mb-2",children:"Here's how to set it up:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Generate an RSA key pair using OpenSSL:",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt"})]}),f.jsxs("li",{children:["Extract the public key:",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub"})]}),f.jsxs("li",{children:["Assign the public key to your Snowflake user (run this in Snowflake as ACCOUNTADMIN):",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"ALTER USER your_username SET RSA_PUBLIC_KEY='MIIBIjANBg...';"})]}),f.jsx("li",{children:"Copy the private key content from rsa_key.p8 and paste it in the Private Key field above."})]}),f.jsxs("p",{className:"mt-2 text-xs",children:["For more details, see"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Snowflake's key pair authentication documentation"}),"."]})]})]})})}function pat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-passphrase-details",children:[f.jsx(is,{children:"What is a passphrase and when do I need it?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A passphrase is an optional encryption password that protects your private key."}),f.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"If you generated your private key with a passphrase (encrypted key), you must provide it here."}),f.jsx("li",{children:"If your private key is not encrypted (generated without the -nocrypt flag), leave this field empty."}),f.jsx("li",{children:"When generating an encrypted key with OpenSSL, you set the passphrase during the key generation process."}),f.jsx("li",{children:"The passphrase adds an extra layer of security by encrypting the private key file itself."}),f.jsx("li",{children:"This passphrase is only used to decrypt the private key and is never sent to Snowflake."})]})]})]})})}const mat=({form:n})=>{const e=n.watch("credentials.authMethod");return n.watch("type")!==lt.SNOWFLAKE?null:f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.account",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter your Snowflake account identifier",children:"Account"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"e.g., xy12345.us-east-1"})}),f.jsx(Hs,{children:f.jsx(cat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.warehouse",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Specify the Snowflake warehouse to use for query execution",children:"Warehouse"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"Enter warehouse name"})}),f.jsx(Hs,{children:f.jsx(dat,{})}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Authentication",children:[f.jsx(fn,{control:n.control,name:"credentials.authMethod",render:({field:t})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{children:"Authentication Method"}),f.jsx(ore,{value:t.value,onValueChange:t.onChange,children:f.jsxs(are,{children:[f.jsx(u2,{value:Tf.PASSWORD,children:"Username & Password"}),f.jsx(u2,{value:Tf.KEY_PAIR,children:"Key Pair"})]})})]}),f.jsx(Hs,{children:f.jsx(uat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.username",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your Snowflake username",children:"Username"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"Enter username"})}),f.jsx(Hs,{children:f.jsx(hat,{})}),f.jsx(Cn,{})]})}),e===Tf.PASSWORD&&f.jsx(fn,{control:n.control,name:"credentials.password",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your Snowflake password",children:"Password"}),f.jsx(cn,{children:f.jsx(vn,{...t,type:"password",placeholder:"Enter password"})}),f.jsx(Hs,{children:f.jsx(fat,{})}),f.jsx(Cn,{})]})}),e===Tf.KEY_PAIR&&f.jsxs(f.Fragment,{children:[f.jsx(fn,{control:n.control,name:"credentials.privateKey",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Paste your private key in PEM format",children:"Private Key"}),f.jsx(cn,{children:f.jsx(Hp,{...t,placeholder:`-----BEGIN PRIVATE KEY-----
|
|
729
|
+
`},kme=Drt(Irt)(eTe),krt={config:Nrt},Art=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(s){return t.reduceRight(function(r,o){return o(r)},s)}};function tTe(n,e){return Object.keys(e).forEach(function(t){e[t]instanceof Object&&n[t]&&Object.assign(e[t],tTe(n[t],e[t]))}),Nme(Nme({},n),e)}var Mrt={type:"cancelation",msg:"operation is manually canceled"};function QU(n){var e=!1,t=new Promise(function(i,s){n.then(function(r){return e?s(Mrt):i(r)}),n.catch(s)});return t.cancel=function(){return e=!0},t}var Ort=["monaco"],Prt=Lrt.create({config:Ert,isInitialized:!1,resolve:null,reject:null,monaco:null}),iTe=art(Prt,2),jM=iTe[0],eB=iTe[1];function Frt(n){var e=krt.config(n),t=e.monaco,i=rrt(e,Ort);eB(function(s){return{config:tTe(s.config,i),monaco:t}})}function jrt(){var n=jM(function(e){var t=e.monaco,i=e.isInitialized,s=e.resolve;return{monaco:t,isInitialized:i,resolve:s}});if(!n.isInitialized){if(eB({isInitialized:!0}),n.monaco)return n.resolve(n.monaco),QU(JU);if(window.monaco&&window.monaco.editor)return nTe(window.monaco),n.resolve(window.monaco),QU(JU);Art(Hrt,Vrt)(Wrt)}return QU(JU)}function Hrt(n){return document.body.appendChild(n)}function Brt(n){var e=document.createElement("script");return n&&(e.src=n),e}function Vrt(n){var e=jM(function(i){var s=i.config,r=i.reject;return{config:s,reject:r}}),t=Brt("".concat(e.config.paths.vs,"/loader.js"));return t.onload=function(){return n()},t.onerror=e.reject,t}function Wrt(){var n=jM(function(t){var i=t.config,s=t.resolve,r=t.reject;return{config:i,resolve:s,reject:r}}),e=window.require;e.config(n.config),e(["vs/editor/editor.main"],function(t){var i=t.m||t;nTe(i),n.resolve(i)},function(t){n.reject(t)})}function nTe(n){jM().monaco||eB({monaco:n})}function zrt(){return jM(function(n){var e=n.monaco;return e})}var JU=new Promise(function(n,e){return eB({resolve:n,reject:e})}),sTe={config:Frt,init:jrt,__getMonacoInstance:zrt},Urt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},e$=Urt,$rt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Grt=$rt;function qrt({children:n}){return nt.createElement("div",{style:Grt.container},n)}var Krt=qrt,Zrt=Krt;function Yrt({width:n,height:e,isEditorReady:t,loading:i,_ref:s,className:r,wrapperProps:o}){return nt.createElement("section",{style:{...e$.wrapper,width:n,height:e},...o},!t&&nt.createElement(Zrt,null,i),nt.createElement("div",{ref:s,style:{...e$.fullWidth,...!t&&e$.hide},className:r}))}var Xrt=Yrt,rTe=x.memo(Xrt);function Qrt(n){x.useEffect(n,[])}var oTe=Qrt;function Jrt(n,e,t=!0){let i=x.useRef(!0);x.useEffect(i.current||!t?()=>{i.current=!1}:n,e)}var bu=Jrt;function OI(){}function zL(n,e,t,i){return eot(n,i)||tot(n,e,t,i)}function eot(n,e){return n.editor.getModel(aTe(n,e))}function tot(n,e,t,i){return n.editor.createModel(e,t,i?aTe(n,i):void 0)}function aTe(n,e){return n.Uri.parse(e)}function iot({original:n,modified:e,language:t,originalLanguage:i,modifiedLanguage:s,originalModelPath:r,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:l=!1,theme:c="light",loading:d="Loading...",options:u={},height:h="100%",width:g="100%",className:m,wrapperProps:b={},beforeMount:v=OI,onMount:C=OI}){let[y,L]=x.useState(!1),[E,R]=x.useState(!0),T=x.useRef(null),N=x.useRef(null),I=x.useRef(null),M=x.useRef(C),P=x.useRef(v),H=x.useRef(!1);oTe(()=>{let U=sTe.init();return U.then(B=>(N.current=B)&&R(!1)).catch(B=>(B==null?void 0:B.type)!=="cancelation"&&console.error("Monaco initialization: error:",B)),()=>T.current?W():U.cancel()}),bu(()=>{if(T.current&&N.current){let U=T.current.getOriginalEditor(),B=zL(N.current,n||"",i||t||"text",r||"");B!==U.getModel()&&U.setModel(B)}},[r],y),bu(()=>{if(T.current&&N.current){let U=T.current.getModifiedEditor(),B=zL(N.current,e||"",s||t||"text",o||"");B!==U.getModel()&&U.setModel(B)}},[o],y),bu(()=>{let U=T.current.getModifiedEditor();U.getOption(N.current.editor.EditorOption.readOnly)?U.setValue(e||""):e!==U.getValue()&&(U.executeEdits("",[{range:U.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),U.pushUndoStop())},[e],y),bu(()=>{var U,B;(B=(U=T.current)==null?void 0:U.getModel())==null||B.original.setValue(n||"")},[n],y),bu(()=>{let{original:U,modified:B}=T.current.getModel();N.current.editor.setModelLanguage(U,i||t||"text"),N.current.editor.setModelLanguage(B,s||t||"text")},[t,i,s],y),bu(()=>{var U;(U=N.current)==null||U.editor.setTheme(c)},[c],y),bu(()=>{var U;(U=T.current)==null||U.updateOptions(u)},[u],y);let j=x.useCallback(()=>{var K;if(!N.current)return;P.current(N.current);let U=zL(N.current,n||"",i||t||"text",r||""),B=zL(N.current,e||"",s||t||"text",o||"");(K=T.current)==null||K.setModel({original:U,modified:B})},[t,e,s,n,i,r,o]),V=x.useCallback(()=>{var U;!H.current&&I.current&&(T.current=N.current.editor.createDiffEditor(I.current,{automaticLayout:!0,...u}),j(),(U=N.current)==null||U.editor.setTheme(c),L(!0),H.current=!0)},[u,c,j]);x.useEffect(()=>{y&&M.current(T.current,N.current)},[y]),x.useEffect(()=>{!E&&!y&&V()},[E,y,V]);function W(){var B,K,X,ne;let U=(B=T.current)==null?void 0:B.getModel();a||((K=U==null?void 0:U.original)==null||K.dispose()),l||((X=U==null?void 0:U.modified)==null||X.dispose()),(ne=T.current)==null||ne.dispose()}return nt.createElement(rTe,{width:g,height:h,isEditorReady:y,loading:d,_ref:I,className:m,wrapperProps:b})}var not=iot;x.memo(not);function sot(n){let e=x.useRef();return x.useEffect(()=>{e.current=n},[n]),e.current}var rot=sot,p4=new Map;function oot({defaultValue:n,defaultLanguage:e,defaultPath:t,value:i,language:s,path:r,theme:o="light",line:a,loading:l="Loading...",options:c={},overrideServices:d={},saveViewState:u=!0,keepCurrentModel:h=!1,width:g="100%",height:m="100%",className:b,wrapperProps:v={},beforeMount:C=OI,onMount:y=OI,onChange:L,onValidate:E=OI}){let[R,T]=x.useState(!1),[N,I]=x.useState(!0),M=x.useRef(null),P=x.useRef(null),H=x.useRef(null),j=x.useRef(y),V=x.useRef(C),W=x.useRef(),U=x.useRef(i),B=rot(r),K=x.useRef(!1),X=x.useRef(!1);oTe(()=>{let Z=sTe.init();return Z.then(Y=>(M.current=Y)&&I(!1)).catch(Y=>(Y==null?void 0:Y.type)!=="cancelation"&&console.error("Monaco initialization: error:",Y)),()=>P.current?fe():Z.cancel()}),bu(()=>{var Y,ee,se,ae;let Z=zL(M.current,n||i||"",e||s||"",r||t||"");Z!==((Y=P.current)==null?void 0:Y.getModel())&&(u&&p4.set(B,(ee=P.current)==null?void 0:ee.saveViewState()),(se=P.current)==null||se.setModel(Z),u&&((ae=P.current)==null||ae.restoreViewState(p4.get(r))))},[r],R),bu(()=>{var Z;(Z=P.current)==null||Z.updateOptions(c)},[c],R),bu(()=>{!P.current||i===void 0||(P.current.getOption(M.current.editor.EditorOption.readOnly)?P.current.setValue(i):i!==P.current.getValue()&&(X.current=!0,P.current.executeEdits("",[{range:P.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),P.current.pushUndoStop(),X.current=!1))},[i],R),bu(()=>{var Y,ee;let Z=(Y=P.current)==null?void 0:Y.getModel();Z&&s&&((ee=M.current)==null||ee.editor.setModelLanguage(Z,s))},[s],R),bu(()=>{var Z;a!==void 0&&((Z=P.current)==null||Z.revealLine(a))},[a],R),bu(()=>{var Z;(Z=M.current)==null||Z.editor.setTheme(o)},[o],R);let ne=x.useCallback(()=>{var Z;if(!(!H.current||!M.current)&&!K.current){V.current(M.current);let Y=r||t,ee=zL(M.current,i||n||"",e||s||"",Y||"");P.current=(Z=M.current)==null?void 0:Z.editor.create(H.current,{model:ee,automaticLayout:!0,...c},d),u&&P.current.restoreViewState(p4.get(Y)),M.current.editor.setTheme(o),a!==void 0&&P.current.revealLine(a),T(!0),K.current=!0}},[n,e,t,i,s,r,c,d,u,o,a]);x.useEffect(()=>{R&&j.current(P.current,M.current)},[R]),x.useEffect(()=>{!N&&!R&&ne()},[N,R,ne]),U.current=i,x.useEffect(()=>{var Z,Y;R&&L&&((Z=W.current)==null||Z.dispose(),W.current=(Y=P.current)==null?void 0:Y.onDidChangeModelContent(ee=>{X.current||L(P.current.getValue(),ee)}))},[R,L]),x.useEffect(()=>{if(R){let Z=M.current.editor.onDidChangeMarkers(Y=>{var se;let ee=(se=P.current.getModel())==null?void 0:se.uri;if(ee&&Y.find(ae=>ae.path===ee.path)){let ae=M.current.editor.getModelMarkers({resource:ee});E==null||E(ae)}});return()=>{Z==null||Z.dispose()}}return()=>{}},[R,E]);function fe(){var Z,Y;(Z=W.current)==null||Z.dispose(),h?u&&p4.set(r,P.current.saveViewState()):(Y=P.current.getModel())==null||Y.dispose(),P.current.dispose()}return nt.createElement(rTe,{width:g,height:m,isEditorReady:R,loading:l,_ref:H,className:b,wrapperProps:v})}var aot=oot,vre=x.memo(aot);function lot({initialValue:n,onChange:e}){const[t,i]=x.useState((n==null?void 0:n.sqlQuery)??""),{resolvedTheme:s}=AH();x.useEffect(()=>{n!=null&&n.sqlQuery&&n.sqlQuery!==t&&i(n.sqlQuery)},[n,t]);function r(o){o!==void 0&&(i(o),e({sqlQuery:o}))}return f.jsx("div",{className:"shadow-xs",children:f.jsx(vre,{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-200/4",height:"30vh",language:"sql",value:t,onChange:r,theme:s==="dark"?"vs-dark":"light",options:{selectOnLineNumbers:!0,hideCursorInOverviewRuler:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,overviewRulerBorder:!1}})})}function GK({icon:n,title:e,subtitle:t,rightContent:i,onClick:s,className:r}){const o=n;return f.jsxs("div",{className:Le("group flex items-center gap-4 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-xs dark:border-0 dark:bg-white/2",s&&"cursor-pointer dark:hover:bg-white/5",r),onClick:s,children:[f.jsxs("div",{className:"flex flex-grow items-start justify-center gap-3 px-6 py-5",children:[n&&f.jsx("div",{className:"flex items-center justify-center",children:f.jsx(o,{className:"h-6 w-6"})}),f.jsxs("div",{className:"flex flex-grow flex-col gap-1",children:[f.jsx("div",{className:"text-md font-medium",children:e}),t&&f.jsx("div",{className:"text-muted-foreground/60 text-sm",children:t})]})]}),f.jsxs("div",{className:"flex items-center justify-center gap-2 p-4",children:[i,s&&f.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 group-hover:bg-gray-200/50 dark:group-hover:bg-white/4",children:f.jsx($d,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})]})]})}var Ame=1,cot=.9,dot=.8,uot=.17,t$=.1,i$=.999,hot=.9999,fot=.99,got=/[\\\/_+.#"@\[\(\{&]/,pot=/[\\\/_+.#"@\[\(\{&]/g,mot=/[\s-]/,lTe=/[\s-]/g;function qK(n,e,t,i,s,r,o){if(r===e.length)return s===n.length?Ame:fot;var a=`${s},${r}`;if(o[a]!==void 0)return o[a];for(var l=i.charAt(r),c=t.indexOf(l,s),d=0,u,h,g,m;c>=0;)u=qK(n,e,t,i,c+1,r+1,o),u>d&&(c===s?u*=Ame:got.test(n.charAt(c-1))?(u*=dot,g=n.slice(s,c-1).match(pot),g&&s>0&&(u*=Math.pow(i$,g.length))):mot.test(n.charAt(c-1))?(u*=cot,m=n.slice(s,c-1).match(lTe),m&&s>0&&(u*=Math.pow(i$,m.length))):(u*=uot,s>0&&(u*=Math.pow(i$,c-s))),n.charAt(c)!==e.charAt(r)&&(u*=hot)),(u<t$&&t.charAt(c-1)===i.charAt(r+1)||i.charAt(r+1)===i.charAt(r)&&t.charAt(c-1)!==i.charAt(r))&&(h=qK(n,e,t,i,c+1,r+2,o),h*t$>u&&(u=h*t$)),u>d&&(d=u),c=t.indexOf(l,c+1);return o[a]=d,d}function Mme(n){return n.toLowerCase().replace(lTe," ")}function _ot(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,qK(n,e,Mme(n),Mme(e),0,0,{})}var bT='[cmdk-group=""]',n$='[cmdk-group-items=""]',bot='[cmdk-group-heading=""]',cTe='[cmdk-item=""]',Ome=`${cTe}:not([aria-disabled="true"])`,KK="cmdk-item-select",TL="data-value",vot=(n,e,t)=>_ot(n,e,t),dTe=x.createContext(void 0),HM=()=>x.useContext(dTe),uTe=x.createContext(void 0),Cre=()=>x.useContext(uTe),hTe=x.createContext(void 0),fTe=x.forwardRef((n,e)=>{let t=IL(()=>{var Y,ee;return{search:"",value:(ee=(Y=n.value)!=null?Y:n.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=IL(()=>new Set),s=IL(()=>new Map),r=IL(()=>new Map),o=IL(()=>new Set),a=gTe(n),{label:l,children:c,value:d,onValueChange:u,filter:h,shouldFilter:g,loop:m,disablePointerSelection:b=!1,vimBindings:v=!0,...C}=n,y=To(),L=To(),E=To(),R=x.useRef(null),T=Tot();X0(()=>{if(d!==void 0){let Y=d.trim();t.current.value=Y,N.emit()}},[d]),X0(()=>{T(6,V)},[]);let N=x.useMemo(()=>({subscribe:Y=>(o.current.add(Y),()=>o.current.delete(Y)),snapshot:()=>t.current,setState:(Y,ee,se)=>{var ae,Se,ue,Re;if(!Object.is(t.current[Y],ee)){if(t.current[Y]=ee,Y==="search")j(),P(),T(1,H);else if(Y==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ve=document.getElementById(E);Ve?Ve.focus():(ae=document.getElementById(y))==null||ae.focus()}if(T(7,()=>{var Ve;t.current.selectedItemId=(Ve=W())==null?void 0:Ve.id,N.emit()}),se||T(5,V),((Se=a.current)==null?void 0:Se.value)!==void 0){let Ve=ee??"";(Re=(ue=a.current).onValueChange)==null||Re.call(ue,Ve);return}}N.emit()}},emit:()=>{o.current.forEach(Y=>Y())}}),[]),I=x.useMemo(()=>({value:(Y,ee,se)=>{var ae;ee!==((ae=r.current.get(Y))==null?void 0:ae.value)&&(r.current.set(Y,{value:ee,keywords:se}),t.current.filtered.items.set(Y,M(ee,se)),T(2,()=>{P(),N.emit()}))},item:(Y,ee)=>(i.current.add(Y),ee&&(s.current.has(ee)?s.current.get(ee).add(Y):s.current.set(ee,new Set([Y]))),T(3,()=>{j(),P(),t.current.value||H(),N.emit()}),()=>{r.current.delete(Y),i.current.delete(Y),t.current.filtered.items.delete(Y);let se=W();T(4,()=>{j(),(se==null?void 0:se.getAttribute("id"))===Y&&H(),N.emit()})}),group:Y=>(s.current.has(Y)||s.current.set(Y,new Set),()=>{r.current.delete(Y),s.current.delete(Y)}),filter:()=>a.current.shouldFilter,label:l||n["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:y,inputId:E,labelId:L,listInnerRef:R}),[]);function M(Y,ee){var se,ae;let Se=(ae=(se=a.current)==null?void 0:se.filter)!=null?ae:vot;return Y?Se(Y,t.current.search,ee):0}function P(){if(!t.current.search||a.current.shouldFilter===!1)return;let Y=t.current.filtered.items,ee=[];t.current.filtered.groups.forEach(ae=>{let Se=s.current.get(ae),ue=0;Se.forEach(Re=>{let Ve=Y.get(Re);ue=Math.max(Ve,ue)}),ee.push([ae,ue])});let se=R.current;U().sort((ae,Se)=>{var ue,Re;let Ve=ae.getAttribute("id"),Qe=Se.getAttribute("id");return((ue=Y.get(Qe))!=null?ue:0)-((Re=Y.get(Ve))!=null?Re:0)}).forEach(ae=>{let Se=ae.closest(n$);Se?Se.appendChild(ae.parentElement===Se?ae:ae.closest(`${n$} > *`)):se.appendChild(ae.parentElement===se?ae:ae.closest(`${n$} > *`))}),ee.sort((ae,Se)=>Se[1]-ae[1]).forEach(ae=>{var Se;let ue=(Se=R.current)==null?void 0:Se.querySelector(`${bT}[${TL}="${encodeURIComponent(ae[0])}"]`);ue==null||ue.parentElement.appendChild(ue)})}function H(){let Y=U().find(se=>se.getAttribute("aria-disabled")!=="true"),ee=Y==null?void 0:Y.getAttribute(TL);N.setState("value",ee||void 0)}function j(){var Y,ee,se,ae;if(!t.current.search||a.current.shouldFilter===!1){t.current.filtered.count=i.current.size;return}t.current.filtered.groups=new Set;let Se=0;for(let ue of i.current){let Re=(ee=(Y=r.current.get(ue))==null?void 0:Y.value)!=null?ee:"",Ve=(ae=(se=r.current.get(ue))==null?void 0:se.keywords)!=null?ae:[],Qe=M(Re,Ve);t.current.filtered.items.set(ue,Qe),Qe>0&&Se++}for(let[ue,Re]of s.current)for(let Ve of Re)if(t.current.filtered.items.get(Ve)>0){t.current.filtered.groups.add(ue);break}t.current.filtered.count=Se}function V(){var Y,ee,se;let ae=W();ae&&(((Y=ae.parentElement)==null?void 0:Y.firstChild)===ae&&((se=(ee=ae.closest(bT))==null?void 0:ee.querySelector(bot))==null||se.scrollIntoView({block:"nearest"})),ae.scrollIntoView({block:"nearest"}))}function W(){var Y;return(Y=R.current)==null?void 0:Y.querySelector(`${cTe}[aria-selected="true"]`)}function U(){var Y;return Array.from(((Y=R.current)==null?void 0:Y.querySelectorAll(Ome))||[])}function B(Y){let ee=U()[Y];ee&&N.setState("value",ee.getAttribute(TL))}function K(Y){var ee;let se=W(),ae=U(),Se=ae.findIndex(Re=>Re===se),ue=ae[Se+Y];(ee=a.current)!=null&&ee.loop&&(ue=Se+Y<0?ae[ae.length-1]:Se+Y===ae.length?ae[0]:ae[Se+Y]),ue&&N.setState("value",ue.getAttribute(TL))}function X(Y){let ee=W(),se=ee==null?void 0:ee.closest(bT),ae;for(;se&&!ae;)se=Y>0?Rot(se,bT):Not(se,bT),ae=se==null?void 0:se.querySelector(Ome);ae?N.setState("value",ae.getAttribute(TL)):K(Y)}let ne=()=>B(U().length-1),fe=Y=>{Y.preventDefault(),Y.metaKey?ne():Y.altKey?X(1):K(1)},Z=Y=>{Y.preventDefault(),Y.metaKey?B(0):Y.altKey?X(-1):K(-1)};return x.createElement(ui.div,{ref:e,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:Y=>{var ee;(ee=C.onKeyDown)==null||ee.call(C,Y);let se=Y.nativeEvent.isComposing||Y.keyCode===229;if(!(Y.defaultPrevented||se))switch(Y.key){case"n":case"j":{v&&Y.ctrlKey&&fe(Y);break}case"ArrowDown":{fe(Y);break}case"p":case"k":{v&&Y.ctrlKey&&Z(Y);break}case"ArrowUp":{Z(Y);break}case"Home":{Y.preventDefault(),B(0);break}case"End":{Y.preventDefault(),ne();break}case"Enter":{Y.preventDefault();let ae=W();if(ae){let Se=new Event(KK);ae.dispatchEvent(Se)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:I.inputId,id:I.labelId,style:kot},l),tB(n,Y=>x.createElement(uTe.Provider,{value:N},x.createElement(dTe.Provider,{value:I},Y))))}),Cot=x.forwardRef((n,e)=>{var t,i;let s=To(),r=x.useRef(null),o=x.useContext(hTe),a=HM(),l=gTe(n),c=(i=(t=l.current)==null?void 0:t.forceMount)!=null?i:o==null?void 0:o.forceMount;X0(()=>{if(!c)return a.item(s,o==null?void 0:o.id)},[c]);let d=pTe(s,r,[n.value,n.children,r],n.keywords),u=Cre(),h=U1(T=>T.value&&T.value===d.current),g=U1(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(s)>0:!0);x.useEffect(()=>{let T=r.current;if(!(!T||n.disabled))return T.addEventListener(KK,m),()=>T.removeEventListener(KK,m)},[g,n.onSelect,n.disabled]);function m(){var T,N;b(),(N=(T=l.current).onSelect)==null||N.call(T,d.current)}function b(){u.setState("value",d.current,!0)}if(!g)return null;let{disabled:v,value:C,onSelect:y,forceMount:L,keywords:E,...R}=n;return x.createElement(ui.div,{ref:ac(r,e),...R,id:s,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!h,"data-disabled":!!v,"data-selected":!!h,onPointerMove:v||a.getDisablePointerSelection()?void 0:b,onClick:v?void 0:m},n.children)}),wot=x.forwardRef((n,e)=>{let{heading:t,children:i,forceMount:s,...r}=n,o=To(),a=x.useRef(null),l=x.useRef(null),c=To(),d=HM(),u=U1(g=>s||d.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);X0(()=>d.group(o),[]),pTe(o,a,[n.value,n.heading,l]);let h=x.useMemo(()=>({id:o,forceMount:s}),[s]);return x.createElement(ui.div,{ref:ac(a,e),...r,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},t&&x.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),tB(n,g=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},x.createElement(hTe.Provider,{value:h},g))))}),yot=x.forwardRef((n,e)=>{let{alwaysRender:t,...i}=n,s=x.useRef(null),r=U1(o=>!o.search);return!t&&!r?null:x.createElement(ui.div,{ref:ac(s,e),...i,"cmdk-separator":"",role:"separator"})}),Sot=x.forwardRef((n,e)=>{let{onValueChange:t,...i}=n,s=n.value!=null,r=Cre(),o=U1(c=>c.search),a=U1(c=>c.selectedItemId),l=HM();return x.useEffect(()=>{n.value!=null&&r.setState("search",n.value)},[n.value]),x.createElement(ui.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?n.value:o,onChange:c=>{s||r.setState("search",c.target.value),t==null||t(c.target.value)}})}),xot=x.forwardRef((n,e)=>{let{children:t,label:i="Suggestions",...s}=n,r=x.useRef(null),o=x.useRef(null),a=U1(c=>c.selectedItemId),l=HM();return x.useEffect(()=>{if(o.current&&r.current){let c=o.current,d=r.current,u,h=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let g=c.offsetHeight;d.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(u),h.unobserve(c)}}},[]),x.createElement(ui.div,{ref:ac(r,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":i,id:l.listId},tB(n,c=>x.createElement("div",{ref:ac(o,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Lot=x.forwardRef((n,e)=>{let{open:t,onOpenChange:i,overlayClassName:s,contentClassName:r,container:o,...a}=n;return x.createElement(uH,{open:t,onOpenChange:i},x.createElement(hH,{container:o},x.createElement(fH,{"cmdk-overlay":"",className:s}),x.createElement(gH,{"aria-label":n.label,"cmdk-dialog":"",className:r},x.createElement(fTe,{ref:e,...a}))))}),Eot=x.forwardRef((n,e)=>U1(t=>t.filtered.count===0)?x.createElement(ui.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),Dot=x.forwardRef((n,e)=>{let{progress:t,children:i,label:s="Loading...",...r}=n;return x.createElement(ui.div,{ref:e,...r,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},tB(n,o=>x.createElement("div",{"aria-hidden":!0},o)))}),zR=Object.assign(fTe,{List:xot,Item:Cot,Input:Sot,Group:wot,Separator:yot,Dialog:Lot,Empty:Eot,Loading:Dot});function Rot(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function Not(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function gTe(n){let e=x.useRef(n);return X0(()=>{e.current=n}),e}var X0=typeof window>"u"?x.useEffect:x.useLayoutEffect;function IL(n){let e=x.useRef();return e.current===void 0&&(e.current=n()),e}function U1(n){let e=Cre(),t=()=>n(e.snapshot());return x.useSyncExternalStore(e.subscribe,t,t)}function pTe(n,e,t,i=[]){let s=x.useRef(),r=HM();return X0(()=>{var o;let a=(()=>{var c;for(let d of t){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():s.current}})(),l=i.map(c=>c.trim());r.value(n,a,l),(o=e.current)==null||o.setAttribute(TL,a),s.current=a}),s}var Tot=()=>{let[n,e]=x.useState(),t=IL(()=>new Map);return X0(()=>{t.current.forEach(i=>i()),t.current=new Map},[n]),(i,s)=>{t.current.set(i,s),e({})}};function Iot(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function tB({asChild:n,children:e},t){return n&&x.isValidElement(e)?x.cloneElement(Iot(e),{ref:e.ref},t(e.props.children)):t(e)}var kot={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function mTe({className:n,...e}){return f.jsx(zR,{"data-slot":"command",className:Le("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",n),...e})}function _Te({className:n,...e}){return f.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[f.jsx(FS,{className:"size-4 shrink-0 opacity-50"}),f.jsx(zR.Input,{"data-slot":"command-input",className:Le("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",n),...e})]})}function Aot({className:n,...e}){return f.jsx(zR.List,{"data-slot":"command-list",className:Le("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",n),...e})}function bTe({...n}){return f.jsx(zR.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...n})}function vTe({className:n,...e}){return f.jsx(zR.Group,{"data-slot":"command-group",className:Le("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",n),...e})}function CTe({className:n,...e}){return f.jsx(zR.Item,{"data-slot":"command-item",className:Le("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function Mot(n){const e=Oot(n),t=x.forwardRef((i,s)=>{const{children:r,...o}=i,a=x.Children.toArray(r),l=a.find(Fot);if(l){const c=l.props.children,d=a.map(u=>u===l?x.Children.count(c)>1?x.Children.only(null):x.isValidElement(c)?c.props.children:null:u);return f.jsx(e,{...o,ref:s,children:x.isValidElement(c)?x.cloneElement(c,void 0,d):null})}return f.jsx(e,{...o,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}function Oot(n){const e=x.forwardRef((t,i)=>{const{children:s,...r}=t;if(x.isValidElement(s)){const o=Hot(s),a=jot(r,s.props);return s.type!==x.Fragment&&(a.ref=i?ac(i,o):o),x.cloneElement(s,a)}return x.Children.count(s)>1?x.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Pot=Symbol("radix.slottable");function Fot(n){return x.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Pot}function jot(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function Hot(n){var i,s;let e=(i=Object.getOwnPropertyDescriptor(n.props,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=(s=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var iB="Popover",[wTe]=Ha(iB,[jp]),BM=jp(),[Bot,LC]=wTe(iB),yTe=n=>{const{__scopePopover:e,children:t,open:i,defaultOpen:s,onOpenChange:r,modal:o=!1}=n,a=BM(e),l=x.useRef(null),[c,d]=x.useState(!1),[u,h]=zc({prop:i,defaultProp:s??!1,onChange:r,caller:iB});return f.jsx(OR,{...a,children:f.jsx(Bot,{scope:e,contentId:To(),triggerRef:l,open:u,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:c,onCustomAnchorAdd:x.useCallback(()=>d(!0),[]),onCustomAnchorRemove:x.useCallback(()=>d(!1),[]),modal:o,children:t})})};yTe.displayName=iB;var STe="PopoverAnchor",Vot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(STe,t),r=BM(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return x.useEffect(()=>(o(),()=>a()),[o,a]),f.jsx(PR,{...r,...i,ref:e})});Vot.displayName=STe;var xTe="PopoverTrigger",LTe=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(xTe,t),r=BM(t),o=Ui(e,s.triggerRef),a=f.jsx(ui.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":TTe(s.open),...i,ref:o,onClick:Lt(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:f.jsx(PR,{asChild:!0,...r,children:a})});LTe.displayName=xTe;var wre="PopoverPortal",[Wot,zot]=wTe(wre,{forceMount:void 0}),ETe=n=>{const{__scopePopover:e,forceMount:t,children:i,container:s}=n,r=LC(wre,e);return f.jsx(Wot,{scope:e,forceMount:t,children:f.jsx(kl,{present:t||r.open,children:f.jsx(HS,{asChild:!0,container:s,children:i})})})};ETe.displayName=wre;var BD="PopoverContent",DTe=x.forwardRef((n,e)=>{const t=zot(BD,n.__scopePopover),{forceMount:i=t.forceMount,...s}=n,r=LC(BD,n.__scopePopover);return f.jsx(kl,{present:i||r.open,children:r.modal?f.jsx($ot,{...s,ref:e}):f.jsx(Got,{...s,ref:e})})});DTe.displayName=BD;var Uot=Mot("PopoverContent.RemoveScroll"),$ot=x.forwardRef((n,e)=>{const t=LC(BD,n.__scopePopover),i=x.useRef(null),s=Ui(e,i),r=x.useRef(!1);return x.useEffect(()=>{const o=i.current;if(o)return cH(o)},[]),f.jsx(pM,{as:Uot,allowPinchZoom:!0,children:f.jsx(RTe,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lt(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),r.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Lt(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;r.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Lt(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Got=x.forwardRef((n,e)=>{const t=LC(BD,n.__scopePopover),i=x.useRef(!1),s=x.useRef(!1);return f.jsx(RTe,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,r),r.defaultPrevented||(i.current||(a=t.triggerRef.current)==null||a.focus(),r.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:r=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,r),r.defaultPrevented||(i.current=!0,r.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=r.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&s.current&&r.preventDefault()}})}),RTe=x.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:r,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...u}=n,h=LC(BD,t),g=BM(t);return aH(),f.jsx(gM,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:r,children:f.jsx(jS,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(_M,{"data-state":TTe(h.open),role:"dialog",id:h.contentId,...g,...u,ref:e,style:{...u.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)"}})})})}),NTe="PopoverClose",qot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=LC(NTe,t);return f.jsx(ui.button,{type:"button",...i,ref:e,onClick:Lt(n.onClick,()=>s.onOpenChange(!1))})});qot.displayName=NTe;var Kot="PopoverArrow",Zot=x.forwardRef((n,e)=>{const{__scopePopover:t,...i}=n,s=BM(t);return f.jsx(bM,{...s,...i,ref:e})});Zot.displayName=Kot;function TTe(n){return n?"open":"closed"}var Yot=yTe,Xot=LTe,Qot=ETe,Jot=DTe;function yre({...n}){return f.jsx(Yot,{"data-slot":"popover",...n})}function Sre({...n}){return f.jsx(Xot,{"data-slot":"popover-trigger",...n})}function xre({className:n,align:e="center",sideOffset:t=4,...i}){return f.jsx(Qot,{children:f.jsx(Jot,{"data-slot":"popover-content",align:e,sideOffset:t,className:Le("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",n),...i})})}function Lre({options:n,value:e,onValueChange:t,placeholder:i="Select an option",emptyMessage:s="No results found.",className:r,disabled:o=!1}){const[a,l]=x.useState(!1),[c,d]=x.useState(""),u=x.useMemo(()=>{const m={};return n.forEach(b=>{const v=b.group??"";Object.prototype.hasOwnProperty.call(m,v)||(m[v]=[]),m[v].push(b)}),m},[n]),h=n.find(m=>m.value===e),g=x.useCallback(m=>{t(m),requestAnimationFrame(()=>{d(""),l(!1)})},[t]);return f.jsxs(yre,{open:a,onOpenChange:l,modal:!0,children:[f.jsx(Sre,{asChild:!0,children:f.jsxs(rt,{variant:"outline",role:"combobox","aria-expanded":a,className:Le("w-full justify-between",!e&&"text-muted-foreground",r),disabled:o,children:[h?h.label:i,f.jsx(One,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(xre,{className:"max-h-[300px] min-w-[300px] overflow-auto p-0",align:"start",sideOffset:5,children:f.jsxs(mTe,{children:[f.jsx(_Te,{placeholder:`Search ${i.toLowerCase()}...`,value:c,onValueChange:d}),f.jsx(bTe,{children:s}),Object.entries(u).map(([m,b])=>f.jsx(vTe,{heading:m,children:b.map(v=>f.jsxs(CTe,{value:v.value,onSelect:()=>{g(v.value)},keywords:[v.label],children:[f.jsx(Wc,{className:Le("mr-2 h-4 w-4",e===v.value?"opacity-100":"opacity-0")}),v.label]},v.value))},m||"default"))]})})]})}function eat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a Service Account JSON key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the JSON key, you'll need to create or use an existing service account in Google Cloud."}),f.jsx("p",{className:"mb-2",children:"Here's what to do:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Go to"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"}),"."]}),f.jsxs("li",{children:["Open ",f.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),f.jsx("li",{children:"Create a new service account or select an existing one."}),f.jsxs("li",{children:["Assign the ",f.jsx("strong",{children:"bigquery.dataEditor"})," and ",f.jsx("strong",{children:"bigquery.jobUser"})," ","roles to this service account to allow read, write, and create access to your project resources."]}),f.jsxs("li",{children:["Open the Service Accounts page, go to the ",f.jsx("strong",{children:"Keys"})," tab, click"," ",f.jsx("strong",{children:"Add key"}),", and select ",f.jsx("strong",{children:"Create new key"}),"."]}),f.jsxs("li",{children:["Choose ",f.jsx("strong",{children:"JSON"})," format and click ",f.jsx("strong",{children:"Create"}),"."]}),f.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function tat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"project-id-details",children:[f.jsx(is,{children:"How do I find my Project ID?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"This is the ID of your Google Cloud project. BigQuery usage costs will be charged to this project."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your billing project ID:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/",children:"Google Cloud Console"})," ","and sign in with your Google account."]}),f.jsx("li",{children:'Click the project selector dropdown at the top of the page (it shows the current project name or "Select a project").'}),f.jsxs("li",{children:["Find your project in the list. The ",f.jsx("strong",{children:"Project ID"})," is shown in the ID column."]}),f.jsx("li",{children:"If you don't see your project, use the search box to find it by name or ID."})]})]})]})})}function iat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"gbq-location-details",children:[f.jsx(is,{children:"How do I find my dataset location?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"BigQuery data is stored in specific regions. To avoid query errors, your SQL queries must process data stored in the same location."}),f.jsx("p",{className:"mb-2",children:"Here's how to check your dataset location:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/bigquery",children:"Google Cloud Console BigQuery page"}),"."]}),f.jsx("li",{children:"In the left panel, expand your project and find your datasets."}),f.jsxs("li",{children:["Click each dataset name to open its details. The ",f.jsx("strong",{children:"Data location"})," field shows the region where that dataset is stored (for example,"," ",f.jsx("code",{className:"text-sm font-semibold",children:"US"}),","," ",f.jsx("code",{className:"text-sm font-semibold",children:"EU"}),","," ",f.jsx("code",{className:"text-sm font-semibold",children:"asia-northeast1"}),")."]}),f.jsx("li",{children:"Make sure all your datasets are stored in the same location. If they are in different locations, select the location where most of your data is stored or create separate Storage for each location."}),f.jsx("li",{children:"Put this location value in the field above."})]})]})]})})}const nat=({form:n})=>{const[e,t]=x.useState(!1);if(n.watch("type")!==lt.GOOGLE_BIGQUERY)return null;const i=()=>{t(!0),n.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{t(!1),n.resetField("credentials.serviceAccount")},r=n.watch("credentials.serviceAccount"),o=r?xRe(r):null;return f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.projectId",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the ID of your Google Cloud project where BigQuery usage will be billed",children:"Project ID"}),f.jsx(cn,{children:f.jsx(vn,{...a,placeholder:"Enter a Project Id"})}),f.jsx(Hs,{children:f.jsx(tat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.location",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Choose the same region where your BigQuery data is stored to ensure queries work correctly",children:"Location"}),f.jsx(cn,{children:f.jsx(Lre,{options:vQe,value:a.value??"",onValueChange:a.onChange,placeholder:"Select a location",emptyMessage:"No locations found",className:"w-full"})}),f.jsx(Hs,{children:f.jsx(iat,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Authentication",children:f.jsx(fn,{control:n.control,name:"credentials.serviceAccount",render:({field:a})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{tooltip:"Paste a JSON key from a service account that has access to the selected storage provider",children:"Service Account"}),!e&&r&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:i,type:"button",children:"Edit"}),e&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),f.jsx(cn,{children:!e&&o?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(ir,{href:o.url,children:o.email})}),f.jsx(kn,{children:f.jsx("p",{children:"View in Google Cloud Console"})})]}):f.jsx(Hp,{...a,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),f.jsx(Hs,{children:f.jsx(eat,{})}),f.jsx(Cn,{})]})})})]})};function sat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-region-details",children:[f.jsx(is,{children:"How do I find my Athena region?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Athena queries run in a specific AWS region. You must select the region where your Athena service and data are located."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your Athena region:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"}),"."]}),f.jsx("li",{children:"Look at the top right corner of the console. The selected region is shown in the region selector dropdown."}),f.jsx("li",{children:"Make sure to copy and paste the same region here in the form to avoid connection or query errors."})]})]})]})})}function rat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-output-bucket-details",children:[f.jsx(is,{children:"How do I find a bucket?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["Athena saves query results in an ",f.jsx("strong",{children:"S3 bucket"}),". You need to specify the bucket used for query output."]}),f.jsx("p",{className:"mb-2",children:"Here's how to find or create an S3 bucket for Athena output:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/s3/",children:"the AWS S3 console"}),"."]}),f.jsx("li",{children:"Look for an existing bucket used for Athena query results, or create a new one."}),f.jsx("li",{children:"If creating a new bucket, make sure it is in the same region as your Athena service."}),f.jsx("li",{children:"Enter the bucket name in this form field."})]})]})]})})}function oat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-access-key-id-details",children:[f.jsx(is,{children:"How do I get my AWS Access Key ID?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Before accessing your AWS Access Key ID, make sure you have a user with the necessary permissions to use Athena and Glue in your AWS account."}),f.jsxs("p",{className:"mb-4 text-sm",children:["Learn more about how to create a user in AWS ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/storages/supported-storages/aws-athena/?utm_source=owox_data_marts&utm_medium=storage_enity&utm_campaign=tooltip_aws",children:"in documentation"}),"."]}),f.jsx(Cxe,{className:"my-4"}),f.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS credentials needed to connect and authenticate."}),f.jsx("p",{className:"mb-2",children:"Here's how to find or create an Access Key ID:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),f.jsxs("li",{children:["Under ",f.jsx("strong",{children:"Access keys"}),", find your existing keys or create a new access key."]}),f.jsx("li",{children:"When you create a new key, download and securely store the Access Key ID and Secret Access Key."})]})]})]})})}function aat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-secret-access-key-details",children:[f.jsx(is,{children:"How do I get my AWS Secret Access Key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The Secret Access Key is part of your AWS credentials needed to connect and authenticate. It is only shown when you create a new key."}),f.jsx("p",{className:"mb-2",children:"Here's how to get your Secret Access Key:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),f.jsxs("li",{children:["Under ",f.jsx("strong",{children:"Access keys"}),", create a new access key if you don't have one or lost the secret key."]}),f.jsx("li",{children:"When you create a new key, copy and securely store the Secret Access Key — you won't be able to see it again."})]})]})]})})}const lat=({form:n})=>{const[e,t]=x.useState("");return x.useEffect(()=>{const i=n.getValues("credentials.accessKeyId");if(i){const s="_".repeat(i.length);t(s),n.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[n]),n.watch("type")!==lt.AWS_ATHENA?null:f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.region",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the AWS region where your Athena service is active",children:"Region"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter a region"})}),f.jsx(Hs,{children:f.jsx(sat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.outputBucket",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Specify the S3 bucket where Athena query results will be stored",children:"Output Bucket"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter an output bucket"})}),f.jsx(Hs,{children:f.jsx(rat,{})}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Authentication",children:[f.jsx(fn,{control:n.control,name:"credentials.accessKeyId",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),f.jsx(cn,{children:f.jsx(vn,{...i,placeholder:"Enter an access key id"})}),f.jsx(Hs,{children:f.jsx(oat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.secretAccessKey",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),f.jsx(cn,{children:f.jsx(vn,{...i,type:"password",placeholder:e||"Enter a secret access key"})}),f.jsx(Hs,{children:f.jsx(aat,{})}),f.jsx(Cn,{})]})})]})]})};function cat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-account-details",children:[f.jsx(is,{children:"How do I find my Snowflake account identifier?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["Your Snowflake account identifier is in the URL when you"," ",f.jsx(ir,{className:"underline",href:"https://app.snowflake.com/",children:"log into Snowflake"}),". The format depends on your Snowflake URL type:"]}),f.jsxs("ol",{className:"list-inside list-decimal space-y-3 text-sm",children:[f.jsxs("li",{children:[f.jsx("strong",{children:"app.snowflake.com format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://app.snowflake.com/europe-west3.gcp/xy12345/"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.europe-west3.gcp"})]}),f.jsxs("li",{children:[f.jsx("strong",{children:"snowflakecomputing.com format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://xy12345.us-east-1.snowflakecomputing.com"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.us-east-1"})]}),f.jsxs("li",{children:[f.jsx("strong",{children:"Organization format:"})," If your URL looks like"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"https://myorg-account123.snowflakecomputing.com"}),", then your account identifier is"," ",f.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"myorg-account123"})]})]})]})]})})}function dat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-warehouse-details",children:[f.jsx(is,{children:"How do I find my Snowflake warehouse?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A warehouse in Snowflake is a cluster of compute resources that executes queries and performs data loading operations."}),f.jsx("p",{className:"mb-2",children:"Here's how to find your warehouse:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:'Log in to your Snowflake account and navigate to the "Warehouses" section in the left sidebar.'}),f.jsx("li",{children:`You'll see a list of available warehouses. Common default names include "COMPUTE_WH" or "PROD_WH".`}),f.jsx("li",{children:"Select the warehouse you want to use for this connection. Make sure it has the appropriate size and auto-suspend settings for your workload."}),f.jsx("li",{children:`If you don't have a warehouse, you can create one using the "Create Warehouse" button or run: CREATE WAREHOUSE my_warehouse;`})]})]})]})})}function uat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-auth-method-details",children:[f.jsx(is,{children:"Which authentication method should I choose?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Snowflake supports two authentication methods for programmatic access:"}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{children:[f.jsx("strong",{className:"font-medium",children:"Username & Password:"}),f.jsx("p",{className:"mt-1",children:"The simplest method using your Snowflake username and password. Suitable for development and testing environments."})]}),f.jsxs("div",{children:[f.jsx("strong",{className:"font-medium",children:"Key Pair Authentication:"}),f.jsx("p",{className:"mt-1",children:"More secure method using public/private key cryptography. Recommended for production environments. You'll need to generate an RSA key pair and assign the public key to your Snowflake user."}),f.jsxs("p",{className:"mt-1",children:["Learn more about"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"key pair authentication"}),"."]})]})]})]})]})})}function hat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-username-details",children:[f.jsx(is,{children:"How do I find my Snowflake username?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Your Snowflake username is the login identifier for your Snowflake account."}),f.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"Use the same username you use to log in to the Snowflake web interface."}),f.jsx("li",{children:"Snowflake usernames are case-insensitive and are typically in uppercase by default."}),f.jsx("li",{children:"If you're using SSO (Single Sign-On) for the web interface, you may need to create a separate user account with password authentication for programmatic access."}),f.jsx("li",{children:"You can view all users in your account by running: SHOW USERS; (requires appropriate privileges)"})]})]})]})})}function fat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-password-details",children:[f.jsx(is,{children:"How do I manage my Snowflake password?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"Use the password associated with your Snowflake user account for authentication."}),f.jsx("p",{className:"mb-2",children:"Important security considerations:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"Your password must meet Snowflake's security requirements (minimum length, complexity, etc.)."}),f.jsx("li",{children:"If you've forgotten your password, a Snowflake administrator can reset it using: ALTER USER username SET PASSWORD = 'new_password';"}),f.jsxs("li",{children:["For production environments, consider using"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Key-Pair authentication"})," ","instead of passwords for enhanced security."]}),f.jsx("li",{children:"Your password is encrypted and securely stored. It will never be displayed in plain text after saving."})]})]})]})})}function gat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-keypair-details",children:[f.jsx(is,{children:"How do I set up key pair authentication?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To use key pair authentication, you need to generate an RSA key pair and configure your Snowflake user."}),f.jsx("p",{className:"mb-2",children:"Here's how to set it up:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Generate an RSA key pair using OpenSSL:",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt"})]}),f.jsxs("li",{children:["Extract the public key:",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub"})]}),f.jsxs("li",{children:["Assign the public key to your Snowflake user (run this in Snowflake as ACCOUNTADMIN):",f.jsx("pre",{className:"mt-1 rounded bg-gray-100 p-2 text-xs dark:bg-gray-800",children:"ALTER USER your_username SET RSA_PUBLIC_KEY='MIIBIjANBg...';"})]}),f.jsx("li",{children:"Copy the private key content from rsa_key.p8 and paste it in the Private Key field above."})]}),f.jsxs("p",{className:"mt-2 text-xs",children:["For more details, see"," ",f.jsx(ir,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Snowflake's key pair authentication documentation"}),"."]})]})]})})}function pat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"snowflake-passphrase-details",children:[f.jsx(is,{children:"What is a passphrase and when do I need it?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A passphrase is an optional encryption password that protects your private key."}),f.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),f.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[f.jsx("li",{children:"If you generated your private key with a passphrase (encrypted key), you must provide it here."}),f.jsx("li",{children:"If your private key is not encrypted (generated without the -nocrypt flag), leave this field empty."}),f.jsx("li",{children:"When generating an encrypted key with OpenSSL, you set the passphrase during the key generation process."}),f.jsx("li",{children:"The passphrase adds an extra layer of security by encrypting the private key file itself."}),f.jsx("li",{children:"This passphrase is only used to decrypt the private key and is never sent to Snowflake."})]})]})]})})}const mat=({form:n})=>{const e=n.watch("credentials.authMethod");return n.watch("type")!==lt.SNOWFLAKE?null:f.jsxs(f.Fragment,{children:[f.jsxs(tc,{title:"Connection Settings",children:[f.jsx(fn,{control:n.control,name:"config.account",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter your Snowflake account identifier",children:"Account"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"e.g., xy12345.us-east-1"})}),f.jsx(Hs,{children:f.jsx(cat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"config.warehouse",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Specify the Snowflake warehouse to use for query execution",children:"Warehouse"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"Enter warehouse name"})}),f.jsx(Hs,{children:f.jsx(dat,{})}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Authentication",children:[f.jsx(fn,{control:n.control,name:"credentials.authMethod",render:({field:t})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{children:"Authentication Method"}),f.jsx(ore,{value:t.value,onValueChange:t.onChange,children:f.jsxs(are,{children:[f.jsx(u2,{value:Tf.PASSWORD,children:"Username & Password"}),f.jsx(u2,{value:Tf.KEY_PAIR,children:"Key Pair"})]})})]}),f.jsx(Hs,{children:f.jsx(uat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.username",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your Snowflake username",children:"Username"}),f.jsx(cn,{children:f.jsx(vn,{...t,placeholder:"Enter username"})}),f.jsx(Hs,{children:f.jsx(hat,{})}),f.jsx(Cn,{})]})}),e===Tf.PASSWORD&&f.jsx(fn,{control:n.control,name:"credentials.password",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Your Snowflake password",children:"Password"}),f.jsx(cn,{children:f.jsx(vn,{...t,type:"password",placeholder:"Enter password"})}),f.jsx(Hs,{children:f.jsx(fat,{})}),f.jsx(Cn,{})]})}),e===Tf.KEY_PAIR&&f.jsxs(f.Fragment,{children:[f.jsx(fn,{control:n.control,name:"credentials.privateKey",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Paste your private key in PEM format",children:"Private Key"}),f.jsx(cn,{children:f.jsx(Hp,{...t,placeholder:`-----BEGIN PRIVATE KEY-----
|
|
730
730
|
...
|
|
731
|
-
-----END PRIVATE KEY-----`,rows:6})}),f.jsx(Hs,{children:f.jsx(gat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.privateKeyPassphrase",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the passphrase if your private key is encrypted",children:"Passphrase (Optional)"}),f.jsx(cn,{children:f.jsx(vn,{...t,type:"password",value:t.value??"",placeholder:"Enter passphrase if key is encrypted"})}),f.jsx(Hs,{children:f.jsx(pat,{})}),f.jsx(Cn,{})]})})]})]})]})},_at=()=>f.jsx(f.Fragment,{children:f.jsx(sr,{variant:"common",type:"single",collapsible:!0,className:"mt-2",children:f.jsxs(ts,{value:"snowflake-setup",children:[f.jsx(is,{children:"How do I get started with Snowflake?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To use Snowflake as your storage provider, you'll need an active Snowflake account with appropriate permissions."}),f.jsx("p",{className:"mb-2",children:"Here's how to get started:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Sign up for a"," ",f.jsx(ir,{className:"underline",href:"https://signup.snowflake.com/",children:"Snowflake account"})," ","if you don't have one yet."]}),f.jsx("li",{children:"Make sure you have the necessary privileges to create and access databases, schemas, and warehouses."}),f.jsx("li",{children:"Choose your authentication method: Username & Password for quick setup, or Key-Pair authentication for production environments."}),f.jsx("li",{children:"Fill in the connection details below (account identifier and warehouse)."}),f.jsx("li",{children:"You can access tables using the full path format: database.schema.table (similar to BigQuery and Athena)."})]})]})]})})});function bat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"bigquery-api-details",children:[f.jsx(is,{children:"How do I enable the BigQuery API?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To run queries and process data in Google BigQuery, you need to enable the"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/apis/library/bigquery.googleapis.com",children:"BigQuery API"})," ","in your Google Cloud project."]}),f.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),f.jsxs("li",{children:["If the API isn't enabled yet, click ",f.jsx("strong",{children:"Enable"}),"."]}),f.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})})}function vat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-api-details",children:[f.jsx(is,{children:"How do I activate Athena API?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"AWS Athena is a serverless interactive query service. To use it, you need to activate Athena in your AWS account."}),f.jsx("p",{className:"mb-2",children:"Here's how to activate Athena:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"})," ","and sign in to your AWS account."]}),f.jsx("li",{children:"If you haven't used Athena before, you may need to set up a query result location (an S3 bucket)."}),f.jsx("li",{children:"You can start running queries immediately after setup."})]})]})]})})}function Cat({initialData:n,onSubmit:e,onCancel:t,onDirtyChange:i}){const s=Bp({resolver:pb(UQe),defaultValues:n}),{watch:r,control:o,formState:{isDirty:a,isSubmitting:l}}=s,c=r("type");nt.useEffect(()=>{i==null||i(a)},[a,i]);const d=async u=>{const{dirtyFields:h}=s.formState,g=SRe(u);return h.credentials||delete g.credentials,e(g)};return f.jsx(CC,{...s,children:f.jsxs(gb,{onSubmit:u=>{s.handleSubmit(d)(u)},noValidate:!0,children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:o,name:"title",render:({field:u})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Name the storage to clarify its purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{...u,placeholder:"Storage title"})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:o,name:"type",render:({field:u})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"The selected source will be used to process data in your Data Marts",children:"Storage Type"}),f.jsx(cn,{children:f.jsxs($c,{value:u.value,onValueChange:u.onChange,disabled:!!n,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a storage type"})}),f.jsx(Kc,{children:f.jsx(KH,{children:fC.getAllTypes().map(({type:h,displayName:g,icon:m,status:b})=>f.jsx(fo,{value:h,disabled:b===Km.COMING_SOON,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(m,{size:20}),g]})},h))})})]})}),f.jsxs(Hs,{children:[c===lt.GOOGLE_BIGQUERY&&f.jsx(bat,{}),c===lt.AWS_ATHENA&&f.jsx(vat,{}),c===lt.SNOWFLAKE&&f.jsx(_at,{})]}),f.jsx(Cn,{})]})})]}),c===lt.GOOGLE_BIGQUERY&&f.jsx(nat,{form:s}),c===lt.AWS_ATHENA&&f.jsx(lat,{form:s}),c===lt.SNOWFLAKE&&f.jsx(mat,{form:s})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!a||l,children:"Save"}),f.jsx(rt,{variant:"outline",type:"button",onClick:t,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function ITe({isOpen:n,onClose:e,dataStorage:t,onSaveSuccess:i}){const{updateDataStorage:s}=ZH(),[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(m=>{l(m)},[]),h=async m=>{if(t){const b=await s(t.id,m);b&&(i(b),e())}},g=x.useRef(!1);return x.useEffect(()=>{const m=t?"Edit":"Create";n&&!g.current?(Vt({event:"data_storage_config_open",category:"DataStorage",action:m,label:t==null?void 0:t.type}),g.current=!0):!n&&g.current&&(Vt({event:"data_storage_config_close",category:"DataStorage",action:m,label:t==null?void 0:t.type}),g.current=!1)},[n,t]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:m=>{m||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:"Configure Storage Provider"}),f.jsx(cC,{children:"Customize settings for your storage provider"})]}),f.jsx(Cat,{initialData:t??void 0,onSubmit:h,onCancel:c,onDirtyChange:u})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const wat=({dataStorage:n,onDataStorageChange:e})=>{const[t,i]=x.useState(!1),s=fC.getInfo(n.type),r=()=>{i(!0)},o=()=>{i(!1)},a=()=>{if(!DDe(n))return f.jsxs("div",{className:"flex items-center space-x-2 text-sm",children:[f.jsx(oH,{className:"h-4 w-4 text-red-500"}),f.jsx("span",{className:"text-red-500",children:"Storage configuration is incomplete"})]});const c=(u,h)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[u,":"]})," ",f.jsx("span",{className:"text-muted-foreground font-medium",children:h})]}),d=(u,h,g)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[u,":"]})," ",f.jsx(ir,{href:g,onClick:m=>{m.stopPropagation()},children:h})]});switch(n.type){case lt.GOOGLE_BIGQUERY:{const u=n.config.projectId,h=n.config.location,g=`https://console.cloud.google.com/bigquery?project=${u}`;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[d("Project ID",u,g),f.jsx("span",{className:"text-muted-foreground",children:"•"}),c("Location",h)]})}case lt.AWS_ATHENA:{const u=n.config.region,h=n.config.outputBucket,g=`https://s3.console.aws.amazon.com/s3/buckets/${h}?region=${u}`;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[c("Region",u),f.jsx("span",{className:"text-muted-foreground",children:"•"}),d("Bucket",h,g)]})}case lt.SNOWFLAKE:{const u=n.config.account,h=n.config.warehouse;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[d("Account",u,"https://app.snowflake.com/"),f.jsx("span",{className:"text-muted-foreground",children:"•"}),c("Warehouse",h)]})}default:return"Unknown storage type configuration"}};return f.jsxs(f.Fragment,{children:[f.jsx(GK,{title:n.title,icon:s.icon,subtitle:a(),onClick:r}),f.jsx(sre,{children:f.jsx(ITe,{isOpen:t,onClose:o,dataStorage:n,onSaveSuccess:l=>{e&&e(l)}})})]})};function yat({initialType:n,onTypeSelect:e}){var o;const[t,i]=x.useState(n??null);x.useEffect(()=>{n!==void 0&&n!==t&&i(n)},[n,t]);const s=a=>{i(a),e(a)},r=[{type:Yt.SQL,label:"SQL",description:"SQL query"},{type:Yt.TABLE,label:"Table",description:"Existing table"},{type:Yt.VIEW,label:"View",description:"Existing view"},{type:Yt.TABLE_PATTERN,label:"Pattern",description:"Table pattern"},{type:Yt.CONNECTOR,label:"Connector",description:"Data import from Source to Storage"}];return f.jsxs("div",{className:"dm-card-block",children:[f.jsx(Bu,{className:"text-foreground",children:"Definition Type"}),f.jsxs($c,{value:t??"",onValueChange:a=>{s(a)},children:[f.jsx(qc,{className:"dm-card-formcontrol w-full","aria-label":"Definition Type",children:f.jsx(Gc,{placeholder:"Select definition type",children:t&&((o=r.find(a=>a.type===t))==null?void 0:o.label)})}),f.jsx(Kc,{children:f.jsx(KH,{children:r.map(a=>f.jsxs(fo,{value:a.type,children:[a.label,f.jsx("span",{className:"text-muted-foreground/80 ml-2",children:a.description})]},a.type))})})]})]})}const Sat=_s({definitionType:Pl(Yt.SQL),definition:_s({sqlQuery:pn().min(1,"SQL query is required")})}),xat=n=>{const e=$De(n);return _s({definitionType:Pl(Yt.TABLE),definition:e})},Lat=n=>{const e=$De(n);return _s({definitionType:Pl(Yt.VIEW),definition:e})},Eat=n=>{const e=tet(n);return _s({definitionType:Pl(Yt.TABLE_PATTERN),definition:e})},Dat=_s({definitionType:Pl(Yt.CONNECTOR),definition:_s({connector:_s({source:_s({name:pn().min(1,"Connector name is required"),configuration:LK(MYe(kYe())).min(1,"At least one configuration is required"),node:pn().min(1,"Node is required"),fields:LK(pn()).min(1,"At least one field is required")}),storage:_s({fullyQualifiedName:pn().min(1,"fully qualified name is required")})})})}),Rat=(n,e)=>{if(!n)return _s({definitionType:OYe(TH(Yt)),definition:_s({}).optional()});switch(n){case Yt.SQL:return Sat;case Yt.TABLE:return xat(e);case Yt.VIEW:return Lat(e);case Yt.TABLE_PATTERN:return Eat(e);case Yt.CONNECTOR:return Dat;default:return _s({})}};function Nat({control:n}){return f.jsx(fn,{control:n,name:"definition.sqlQuery",render:({field:e})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{className:"text-foreground",children:"SQL Query"}),f.jsx(cn,{children:f.jsx(lot,{initialValue:{sqlQuery:e.value},onChange:t=>{e.onChange(t.sqlQuery)}})}),f.jsx(Cn,{})]})})}function Tat({control:n,storageType:e}){const t=TDe(e),i=IDe(e);return f.jsx(fn,{control:n,name:"definition.fullyQualifiedName",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Fully Qualified Table Name"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value||"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}function Iat({control:n,storageType:e}){const t=TDe(e),i=IDe(e);return f.jsx(fn,{control:n,name:"definition.fullyQualifiedName",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Fully Qualified View Name"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value||"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}function kat({control:n,storageType:e}){const t=XQe(e),i=QQe(e);return f.jsx(fn,{control:n,name:"definition.pattern",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Table Pattern"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value||"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}const Ere=n=>{switch(n){case Yt.SQL:return{sqlQuery:""};case Yt.TABLE:return{fullyQualifiedName:""};case Yt.VIEW:return{fullyQualifiedName:""};case Yt.TABLE_PATTERN:return{pattern:""};case Yt.CONNECTOR:return{connector:{source:{name:"",configuration:[],node:"",fields:[]},storage:{fullyQualifiedName:""}}};default:return{}}},Aat=RR("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Dre({className:n,variant:e,...t}){return f.jsx("div",{"data-slot":"alert",role:"alert",className:Le(Aat({variant:e}),n),...t})}function kTe({className:n,...e}){return f.jsx("div",{"data-slot":"alert-title",className:Le("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",n),...e})}function Rre({className:n,...e}){return f.jsx("div",{"data-slot":"alert-description",className:Le("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",n),...e})}function Mat({connectors:n,selectedConnector:e,loading:t,error:i,onConnectorSelect:s,onConnectorDoubleClick:r}){return t?f.jsx(fre,{variant:"grid"}):i?f.jsxs(Dre,{variant:"destructive",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(Rre,{children:"Failed to load available connectors. Please try again."})]}):f.jsxs(L_,{children:[f.jsx(Hv,{title:"Choose Connector",children:f.jsx(Lst,{children:n.map(o=>f.jsx(Est,{icon:o.logoBase64?f.jsx(VS,{base64:o.logoBase64,size:20}):null,title:o.displayName,selected:(e==null?void 0:e.name)===o.name,onClick:()=>{s(o)},onDoubleClick:()=>{s(o),r==null||r(o)}},o.name))})}),n.length===0&&f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No connectors available",subtitle:"Ask your administrator to configure connectors."})]})}function Oat({currentStep:n,totalSteps:e,canGoNext:t,canGoBack:i,isLoading:s=!1,onNext:r,onBack:o,onFinish:a,nextLabel:l="Next",backLabel:c="Back",finishLabel:d="Save"}){const u=n===e;return e===1?f.jsx("div",{className:"w-full",children:f.jsx(rt,{className:"w-full",variant:"default",onClick:a,disabled:!t||s,children:d})}):f.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[f.jsx("div",{className:"flex-1",children:i&&f.jsxs(rt,{variant:"outline",onClick:o,disabled:s,children:[f.jsx(OHe,{className:"h-4 w-4"}),c]})}),f.jsxs("div",{className:"text-muted-foreground/75 px-4 text-sm",children:["Step ",n," of ",e]}),f.jsx("div",{className:"flex flex-1 justify-end",children:u?f.jsx(rt,{variant:"default",onClick:a,disabled:!t||s,children:d}):f.jsxs(rt,{variant:"default",onClick:r,disabled:!t||s,children:[l,f.jsx($d,{className:"h-4 w-4"})]})})]})}function Ey({connector:n,size:e=24,variant:t="compact"}){return f.jsx(x_,{icon:f.jsx(VS,{base64:n.logoBase64,size:e}),title:n.displayName,docUrl:n.docUrl,variant:t})}function PE({label:n}){return f.jsx("div",{className:"border-border text-muted-foreground mt-3 flex items-center justify-center gap-2 border-t pt-3 text-sm",children:f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:"https://github.com/OWOX/owox-data-marts/issues",target:"_blank",rel:"noopener noreferrer",children:[n," Open issue here",f.jsx(F_,{className:"h-4 w-4"})]})})})}const ZK="**********";function Pat({specification:n,configuration:e,onValueChange:t}){const{name:i,title:s}=n,r=s??i,o=i;return f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(vn,{type:"checkbox",id:o,name:i,checked:e[i]||!1,onChange:a=>{t(i,a.target.checked)},className:"text-primary focus:ring-primary border-border h-4 w-4 rounded"}),f.jsx(Bu,{htmlFor:o,className:"cursor-pointer text-sm",children:f.jsx(_u,{htmlFor:o,required:n.required,tooltip:n.description,children:r})})]})}function Fat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s}=n,r=n.title??n.name;return f.jsx(vn,{id:i,name:i,type:"number",value:e[i]||"",placeholder:s??`Enter ${r.toLowerCase()}`,onChange:o=>{const a=o.target.value,l=a===""?void 0:parseFloat(a);t(i,l)}})}function jat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s,default:r}=n,o=n.title??n.name;return f.jsx(Hp,{id:i,name:i,value:Array.isArray(e[i])?e[i].join(`
|
|
731
|
+
-----END PRIVATE KEY-----`,rows:6})}),f.jsx(Hs,{children:f.jsx(gat,{})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:n.control,name:"credentials.privateKeyPassphrase",render:({field:t})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Enter the passphrase if your private key is encrypted",children:"Passphrase (Optional)"}),f.jsx(cn,{children:f.jsx(vn,{...t,type:"password",value:t.value??"",placeholder:"Enter passphrase if key is encrypted"})}),f.jsx(Hs,{children:f.jsx(pat,{})}),f.jsx(Cn,{})]})})]})]})]})},_at=()=>f.jsx(f.Fragment,{children:f.jsx(sr,{variant:"common",type:"single",collapsible:!0,className:"mt-2",children:f.jsxs(ts,{value:"snowflake-setup",children:[f.jsx(is,{children:"How do I get started with Snowflake?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To use Snowflake as your storage provider, you'll need an active Snowflake account with appropriate permissions."}),f.jsx("p",{className:"mb-2",children:"Here's how to get started:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Sign up for a"," ",f.jsx(ir,{className:"underline",href:"https://signup.snowflake.com/",children:"Snowflake account"})," ","if you don't have one yet."]}),f.jsx("li",{children:"Make sure you have the necessary privileges to create and access databases, schemas, and warehouses."}),f.jsx("li",{children:"Choose your authentication method: Username & Password for quick setup, or Key-Pair authentication for production environments."}),f.jsx("li",{children:"Fill in the connection details below (account identifier and warehouse)."}),f.jsx("li",{children:"You can access tables using the full path format: database.schema.table (similar to BigQuery and Athena)."})]})]})]})})});function bat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"bigquery-api-details",children:[f.jsx(is,{children:"How do I enable the BigQuery API?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To run queries and process data in Google BigQuery, you need to enable the"," ",f.jsx(ir,{className:"underline",href:"https://console.cloud.google.com/apis/library/bigquery.googleapis.com",children:"BigQuery API"})," ","in your Google Cloud project."]}),f.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),f.jsxs("li",{children:["If the API isn't enabled yet, click ",f.jsx("strong",{children:"Enable"}),"."]}),f.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})})}function vat(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"athena-api-details",children:[f.jsx(is,{children:"How do I activate Athena API?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"AWS Athena is a serverless interactive query service. To use it, you need to activate Athena in your AWS account."}),f.jsx("p",{className:"mb-2",children:"Here's how to activate Athena:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open"," ",f.jsx(ir,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"})," ","and sign in to your AWS account."]}),f.jsx("li",{children:"If you haven't used Athena before, you may need to set up a query result location (an S3 bucket)."}),f.jsx("li",{children:"You can start running queries immediately after setup."})]})]})]})})}function Cat({initialData:n,onSubmit:e,onCancel:t,onDirtyChange:i}){const s=Bp({resolver:pb(UQe),defaultValues:n}),{watch:r,control:o,formState:{isDirty:a,isSubmitting:l}}=s,c=r("type");nt.useEffect(()=>{i==null||i(a)},[a,i]);const d=async u=>{const{dirtyFields:h}=s.formState,g=SRe(u);return h.credentials||delete g.credentials,e(g)};return f.jsx(CC,{...s,children:f.jsxs(gb,{onSubmit:u=>{s.handleSubmit(d)(u)},noValidate:!0,children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:o,name:"title",render:({field:u})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Name the storage to clarify its purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{...u,placeholder:"Storage title"})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:o,name:"type",render:({field:u})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"The selected source will be used to process data in your Data Marts",children:"Storage Type"}),f.jsx(cn,{children:f.jsxs($c,{value:u.value,onValueChange:u.onChange,disabled:!!n,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a storage type"})}),f.jsx(Kc,{children:f.jsx(KH,{children:fC.getAllTypes().map(({type:h,displayName:g,icon:m,status:b})=>f.jsx(fo,{value:h,disabled:b===Km.COMING_SOON,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(m,{size:20}),g]})},h))})})]})}),f.jsxs(Hs,{children:[c===lt.GOOGLE_BIGQUERY&&f.jsx(bat,{}),c===lt.AWS_ATHENA&&f.jsx(vat,{}),c===lt.SNOWFLAKE&&f.jsx(_at,{})]}),f.jsx(Cn,{})]})})]}),c===lt.GOOGLE_BIGQUERY&&f.jsx(nat,{form:s}),c===lt.AWS_ATHENA&&f.jsx(lat,{form:s}),c===lt.SNOWFLAKE&&f.jsx(mat,{form:s})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!a||l,children:"Save"}),f.jsx(rt,{variant:"outline",type:"button",onClick:t,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function ITe({isOpen:n,onClose:e,dataStorage:t,onSaveSuccess:i}){const{updateDataStorage:s}=ZH(),[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(m=>{l(m)},[]),h=async m=>{if(t){const b=await s(t.id,m);b&&(i(b),e())}},g=x.useRef(!1);return x.useEffect(()=>{const m=t?"Edit":"Create";n&&!g.current?(Vt({event:"data_storage_config_open",category:"DataStorage",action:m,label:t==null?void 0:t.type}),g.current=!0):!n&&g.current&&(Vt({event:"data_storage_config_close",category:"DataStorage",action:m,label:t==null?void 0:t.type}),g.current=!1)},[n,t]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:m=>{m||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:"Configure Storage Provider"}),f.jsx(cC,{children:"Customize settings for your storage provider"})]}),f.jsx(Cat,{initialData:t??void 0,onSubmit:h,onCancel:c,onDirtyChange:u})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const wat=({dataStorage:n,onDataStorageChange:e})=>{const[t,i]=x.useState(!1),s=fC.getInfo(n.type),r=()=>{i(!0)},o=()=>{i(!1)},a=()=>{if(!DDe(n))return f.jsxs("div",{className:"flex items-center space-x-2 text-sm",children:[f.jsx(oH,{className:"h-4 w-4 text-red-500"}),f.jsx("span",{className:"text-red-500",children:"Storage configuration is incomplete"})]});const c=(u,h)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[u,":"]})," ",f.jsx("span",{className:"text-muted-foreground font-medium",children:h})]}),d=(u,h,g)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[u,":"]})," ",f.jsx(ir,{href:g,onClick:m=>{m.stopPropagation()},children:h})]});switch(n.type){case lt.GOOGLE_BIGQUERY:{const u=n.config.projectId,h=n.config.location,g=`https://console.cloud.google.com/bigquery?project=${u}`;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[d("Project ID",u,g),f.jsx("span",{className:"text-muted-foreground",children:"•"}),c("Location",h)]})}case lt.AWS_ATHENA:{const u=n.config.region,h=n.config.outputBucket,g=`https://s3.console.aws.amazon.com/s3/buckets/${h}?region=${u}`;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[c("Region",u),f.jsx("span",{className:"text-muted-foreground",children:"•"}),d("Bucket",h,g)]})}case lt.SNOWFLAKE:{const u=n.config.account,h=n.config.warehouse;return f.jsxs("div",{className:"flex flex-wrap gap-2",children:[d("Account",u,"https://app.snowflake.com/"),f.jsx("span",{className:"text-muted-foreground",children:"•"}),c("Warehouse",h)]})}default:return"Unknown storage type configuration"}};return f.jsxs(f.Fragment,{children:[f.jsx(GK,{title:n.title,icon:s.icon,subtitle:a(),onClick:r}),f.jsx(sre,{children:f.jsx(ITe,{isOpen:t,onClose:o,dataStorage:n,onSaveSuccess:l=>{e&&e(l)}})})]})};function yat({initialType:n,onTypeSelect:e}){var o;const[t,i]=x.useState(n??null);x.useEffect(()=>{n!==void 0&&n!==t&&i(n)},[n,t]);const s=a=>{i(a),e(a)},r=[{type:Yt.SQL,label:"SQL",description:"SQL query"},{type:Yt.TABLE,label:"Table",description:"Existing table"},{type:Yt.VIEW,label:"View",description:"Existing view"},{type:Yt.TABLE_PATTERN,label:"Pattern",description:"Table pattern"},{type:Yt.CONNECTOR,label:"Connector",description:"Data import from Source to Storage"}];return f.jsxs("div",{className:"dm-card-block",children:[f.jsx(Bu,{className:"text-foreground",children:"Definition Type"}),f.jsxs($c,{value:t??"",onValueChange:a=>{s(a)},children:[f.jsx(qc,{className:"dm-card-formcontrol w-full","aria-label":"Definition Type",children:f.jsx(Gc,{placeholder:"Select definition type",children:t&&((o=r.find(a=>a.type===t))==null?void 0:o.label)})}),f.jsx(Kc,{children:f.jsx(KH,{children:r.map(a=>f.jsxs(fo,{value:a.type,children:[a.label,f.jsx("span",{className:"text-muted-foreground/80 ml-2",children:a.description})]},a.type))})})]})]})}const Sat=_s({definitionType:Pl(Yt.SQL),definition:_s({sqlQuery:pn().min(1,"SQL query is required")})}),xat=n=>{const e=$De(n);return _s({definitionType:Pl(Yt.TABLE),definition:e})},Lat=n=>{const e=$De(n);return _s({definitionType:Pl(Yt.VIEW),definition:e})},Eat=n=>{const e=tet(n);return _s({definitionType:Pl(Yt.TABLE_PATTERN),definition:e})},Dat=_s({definitionType:Pl(Yt.CONNECTOR),definition:_s({connector:_s({source:_s({name:pn().min(1,"Connector name is required"),configuration:LK(MYe(kYe())).min(1,"At least one configuration is required"),node:pn().min(1,"Node is required"),fields:LK(pn()).min(1,"At least one field is required")}),storage:_s({fullyQualifiedName:pn().min(1,"fully qualified name is required")})})})}),Rat=(n,e)=>{if(!n)return _s({definitionType:OYe(TH(Yt)),definition:_s({}).optional()});switch(n){case Yt.SQL:return Sat;case Yt.TABLE:return xat(e);case Yt.VIEW:return Lat(e);case Yt.TABLE_PATTERN:return Eat(e);case Yt.CONNECTOR:return Dat;default:return _s({})}};function Nat({control:n}){return f.jsx(fn,{control:n,name:"definition.sqlQuery",render:({field:e})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{className:"text-foreground",children:"SQL Query"}),f.jsx(cn,{children:f.jsx(lot,{initialValue:e.value?{sqlQuery:e.value}:void 0,onChange:t=>{e.onChange(t.sqlQuery)}})}),f.jsx(Cn,{})]})})}function Tat({control:n,storageType:e}){const t=TDe(e),i=IDe(e);return f.jsx(fn,{control:n,name:"definition.fullyQualifiedName",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Fully Qualified Table Name"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value??"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}function Iat({control:n,storageType:e}){const t=TDe(e),i=IDe(e);return f.jsx(fn,{control:n,name:"definition.fullyQualifiedName",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Fully Qualified View Name"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value??"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}function kat({control:n,storageType:e}){const t=XQe(e),i=QQe(e);return f.jsx(fn,{control:n,name:"definition.pattern",render:({field:s})=>f.jsxs(tn,{className:"dm-card-block",children:[f.jsx(Ji,{children:"Table Pattern"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:t,value:s.value??"",onChange:s.onChange,className:"dm-card-formcontrol"})}),f.jsx(Hs,{className:"text-muted-foreground/75",children:i}),f.jsx(Cn,{})]})})}const Ere=n=>{switch(n){case Yt.SQL:return{sqlQuery:""};case Yt.TABLE:return{fullyQualifiedName:""};case Yt.VIEW:return{fullyQualifiedName:""};case Yt.TABLE_PATTERN:return{pattern:""};case Yt.CONNECTOR:return{connector:{source:{name:"",configuration:[],node:"",fields:[]},storage:{fullyQualifiedName:""}}};default:return{}}},Aat=RR("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Dre({className:n,variant:e,...t}){return f.jsx("div",{"data-slot":"alert",role:"alert",className:Le(Aat({variant:e}),n),...t})}function kTe({className:n,...e}){return f.jsx("div",{"data-slot":"alert-title",className:Le("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",n),...e})}function Rre({className:n,...e}){return f.jsx("div",{"data-slot":"alert-description",className:Le("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",n),...e})}function Mat({connectors:n,selectedConnector:e,loading:t,error:i,onConnectorSelect:s,onConnectorDoubleClick:r}){return t?f.jsx(fre,{variant:"grid"}):i?f.jsxs(Dre,{variant:"destructive",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(Rre,{children:"Failed to load available connectors. Please try again."})]}):f.jsxs(L_,{children:[f.jsx(Hv,{title:"Choose Connector",children:f.jsx(Lst,{children:n.map(o=>f.jsx(Est,{icon:o.logoBase64?f.jsx(VS,{base64:o.logoBase64,size:20}):null,title:o.displayName,selected:(e==null?void 0:e.name)===o.name,onClick:()=>{s(o)},onDoubleClick:()=>{s(o),r==null||r(o)}},o.name))})}),n.length===0&&f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No connectors available",subtitle:"Ask your administrator to configure connectors."})]})}function Oat({currentStep:n,totalSteps:e,canGoNext:t,canGoBack:i,isLoading:s=!1,onNext:r,onBack:o,onFinish:a,nextLabel:l="Next",backLabel:c="Back",finishLabel:d="Save"}){const u=n===e;return e===1?f.jsx("div",{className:"w-full",children:f.jsx(rt,{className:"w-full",variant:"default",onClick:a,disabled:!t||s,children:d})}):f.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[f.jsx("div",{className:"flex-1",children:i&&f.jsxs(rt,{variant:"outline",onClick:o,disabled:s,children:[f.jsx(OHe,{className:"h-4 w-4"}),c]})}),f.jsxs("div",{className:"text-muted-foreground/75 px-4 text-sm",children:["Step ",n," of ",e]}),f.jsx("div",{className:"flex flex-1 justify-end",children:u?f.jsx(rt,{variant:"default",onClick:a,disabled:!t||s,children:d}):f.jsxs(rt,{variant:"default",onClick:r,disabled:!t||s,children:[l,f.jsx($d,{className:"h-4 w-4"})]})})]})}function Ey({connector:n,size:e=24,variant:t="compact"}){return f.jsx(x_,{icon:f.jsx(VS,{base64:n.logoBase64,size:e}),title:n.displayName,docUrl:n.docUrl,variant:t})}function PE({label:n}){return f.jsx("div",{className:"border-border text-muted-foreground mt-3 flex items-center justify-center gap-2 border-t pt-3 text-sm",children:f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:"https://github.com/OWOX/owox-data-marts/issues",target:"_blank",rel:"noopener noreferrer",children:[n," Open issue here",f.jsx(F_,{className:"h-4 w-4"})]})})})}const ZK="**********";function Pat({specification:n,configuration:e,onValueChange:t}){const{name:i,title:s}=n,r=s??i,o=i;return f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(vn,{type:"checkbox",id:o,name:i,checked:e[i]||!1,onChange:a=>{t(i,a.target.checked)},className:"text-primary focus:ring-primary border-border h-4 w-4 rounded"}),f.jsx(Bu,{htmlFor:o,className:"cursor-pointer text-sm",children:f.jsx(_u,{htmlFor:o,required:n.required,tooltip:n.description,children:r})})]})}function Fat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s}=n,r=n.title??n.name;return f.jsx(vn,{id:i,name:i,type:"number",value:e[i]||"",placeholder:s??`Enter ${r.toLowerCase()}`,onChange:o=>{const a=o.target.value,l=a===""?void 0:parseFloat(a);t(i,l)}})}function jat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s,default:r}=n,o=n.title??n.name;return f.jsx(Hp,{id:i,name:i,value:Array.isArray(e[i])?e[i].join(`
|
|
732
732
|
`):Array.isArray(r)?r.join(`
|
|
733
733
|
`):"",placeholder:s??`Enter ${o.toLowerCase()} (one per line)`,rows:4,onChange:a=>{const l=a.target.value.split(`
|
|
734
|
-
`).filter(c=>c.trim());t(i,l)}})}function Hat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s,default:r}=n,o=n.title??n.name,a=l=>{if(!l||typeof l!="string"&&typeof l!="number")return"";const c=typeof l=="string"?l:l.toString();try{const d=new Date(c);return isNaN(d.getTime())?"":d.toISOString().split("T")[0]}catch{return""}};return f.jsx(vn,{id:i,name:i,type:"date",value:e[i]||a(r)||"",placeholder:s??`Enter ${o.toLowerCase()}`,onChange:l=>{t(i,l.target.value)}})}function Bat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s}=n,r=n.title??n.name;return f.jsx(vn,{id:i,name:i,type:"text",value:e[i]||"",placeholder:s??`Enter ${r.toLowerCase()}`,onChange:o=>{t(i,o.target.value)}})}function Vat({specification:n,configuration:e,onValueChange:t}){const i=n.title??n.name,{name:s,placeholder:r,default:o}=n;return f.jsx(Hp,{id:s,name:s,value:e[s]&&typeof e[s]=="object"?JSON.stringify(e[s],null,2):typeof o=="object"?JSON.stringify(o,null,2):"",placeholder:r??`Enter ${i.toLowerCase()} as JSON`,rows:6,className:"font-mono",onChange:a=>{try{const l=JSON.parse(a.target.value);t(s,l)}catch{t(s,a.target.value)}}})}function Wat({specification:n,configuration:e,onValueChange:t,isEditingExisting:i,isSecretEditing:s}){const r=n.title??n.name,o=i&&!s;return f.jsx(vn,{id:n.name,...o?{}:{name:n.name},type:o?"password":"text",autoComplete:o?"new-password":"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:o?ZK:e[n.name]||"",...o?{readOnly:!0,disabled:!0}:{},...o?{}:{placeholder:n.placeholder??`Enter ${r.toLowerCase()}`},...o?{}:{onChange:a=>{t(n.name,a.target.value)}}})}function zat({specification:n,configuration:e,onValueChange:t,specOptions:i}){const{name:s,placeholder:r,default:o}=n,a=n.title??n.name,l=i.map(c=>({value:c,label:c}));return f.jsx(Lre,{options:l,value:e[s]||o||"",onValueChange:c=>{t(s,c)},placeholder:r??`Select ${a.toLowerCase()}`,emptyMessage:"No options available",className:"w-full"})}function Uat(){const n=x.useRef(new kI),e=x.useCallback(async(s,r,o)=>await n.current.exchangeCredentials(s,{fieldPath:o,payload:r}),[]),t=x.useCallback(async(s,r)=>{try{return await n.current.checkOAuthStatus(s,r)}catch{return{valid:!1}}},[]),i=x.useCallback(async(s,r)=>await n.current.getOAuthSettings(s,r),[]);return{exchangeCredentials:e,checkStatus:t,getSettings:i}}let vT=null;function $at({appId:n,scope:e,onSuccess:t,onError:i,disabled:s=!1,children:r}){const[o,a]=x.useState(!1),[l,c]=x.useState(!1),[d,u]=x.useState(null);x.useEffect(()=>{if(window.FB){c(!0);return}if(document.getElementById("facebook-jssdk")){const v=setInterval(()=>{window.FB&&(c(!0),clearInterval(v))},100);return()=>{clearInterval(v)}}if(!n)return;if(vT&&vT!==n){console.warn("Facebook SDK already initialized with different appId");return}vT??(vT=n),window.fbAsyncInit=function(){window.FB&&vT&&(window.FB.init({appId:vT,cookie:!0,xfbml:!0,version:"v23.0"}),c(!0))};const b=document.createElement("script");b.id="facebook-jssdk",b.src="https://connect.facebook.net/en_US/sdk.js",b.async=!0,b.defer=!0,b.crossOrigin="anonymous",document.body.appendChild(b)},[n]);const h=()=>{if(!window.FB||!l){const b=new Error("Facebook SDK not loaded or not ready");u(b.message),i==null||i(b);return}a(!0),u(null),window.FB.login(b=>{var v;if(b.status==="connected"&&b.authResponse){const{accessToken:C,expiresIn:y,userID:L}=b.authResponse;(v=window.FB)==null||v.api("/me?fields=name,email",E=>{const R={accessToken:C,expiresIn:y,userID:L,userName:E.name,userEmail:E.email};t(R),a(!1)})}else{const C=new Error("User cancelled login or did not fully authorize");u(C.message),i==null||i(C),a(!1)}},{scope:e})},g=s||o||!l,m=()=>o?"Connecting...":r||(l?"Continue with Facebook":"Loading...");return f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs(rt,{type:"button",onClick:h,disabled:g,className:"flex items-center justify-center gap-2 rounded-md border-none bg-[#1877F2] px-4 py-2.5 text-sm font-semibold text-white hover:bg-[#166FE5] disabled:cursor-not-allowed disabled:opacity-60",children:[f.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:f.jsx("path",{d:"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z"})}),m()]}),d&&f.jsx("div",{className:"mt-1 text-xs text-red-600",children:d})]})}function Gat({isLoading:n,status:e,settings:t,onOAuthSuccess:i}){const s=r=>{i({accessToken:r.accessToken})};return f.jsx("div",{className:"mt-2 mb-2",children:f.jsx($at,{appId:t==null?void 0:t.vars.AppId,scope:t==null?void 0:t.vars.Scopes,onSuccess:s,disabled:n,children:e!=null&&e.user?f.jsxs(f.Fragment,{children:["Authenticated as ",f.jsx("strong",{children:e.user.name??e.user.id})]}):"Continue with Facebook"})})}function ATe({specification:n,option:e,configuration:t,onValueChange:i,connectorName:s,onSecretEditToggle:r,secretEditing:o={},isEditingExisting:a=!1}){const[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,g]=x.useState(null),[m,b]=x.useState(null),v=x.useMemo(()=>{const V=t[n.name],W=e!=null&&e.value&&V?V[e.value]:V;return W==null?void 0:W._source_credential_id},[t,n.name,e==null?void 0:e.value]),C=x.useMemo(()=>e?`${n.name}.${e.value}`:n.name,[n.name,e]),y=x.useMemo(()=>{const V=t[n.name];if(e!=null&&e.value&&V){const W=V[e.value];return W&&typeof W=="object"&&!Array.isArray(W)?W:{}}return V&&typeof V=="object"&&!Array.isArray(V)?V:{}},[t,n.name,e==null?void 0:e.value]),L=x.useMemo(()=>{const V=y;return"_source_credential_id"in V?!1:!!(e!=null&&e.items&&Object.keys(e.items).some(U=>U in V&&V[U]!==void 0&&V[U]!==""))},[y,e]),[E,R]=x.useState(L);x.useEffect(()=>{const V="_source_credential_id"in y,W=(e==null?void 0:e.items)&&Object.keys(e.items).some(U=>U in y&&y[U]!==void 0&&y[U]!=="");V&&E?R(!1):W&&!E&&R(!0)},[y,e,E]);const T=(V,W)=>{if(!(e!=null&&e.value))return;const U=t[n.name]&&typeof t[n.name]=="object"?t[n.name]:{};i(n.name,{...U,[e.value]:{...typeof U[e.value]=="object"&&U[e.value]!==null?U[e.value]:{},[V]:W}})},{checkStatus:N,getSettings:I,exchangeCredentials:M}=Uat(),P=async V=>{try{c(!0),b(null);const W=await M(s,V,C),U=t[n.name];e?i(n.name,{...U,[e.value]:{_source_credential_id:W.credentialId}}):i(n.name,{_source_credential_id:W.credentialId})}catch(W){const U=W instanceof Error?W.message:"Failed to exchange OAuth credentials";console.error("Failed to exchange OAuth credentials:",W),b(U)}finally{c(!1)}};x.useEffect(()=>{if(!v){u(null),c(!1);return}let V=!1;return(async()=>{try{c(!0);const U=await N(s,v);V||u(U)}catch(U){V||(console.error("Failed to validate credentials:",U),u({valid:!1}))}finally{V||c(!1)}})(),()=>{V=!0}},[v,s,N]),x.useEffect(()=>{(async()=>{try{const W=await I(s,C);g(W)}catch(W){console.error("Failed to fetch settings:",W),g(null)}})()},[s,C,I]);const H=!!(h!=null&&h.isEnabled);if((E||!H)&&(e!=null&&e.items))return f.jsxs("div",{className:"space-y-4",children:[Object.entries(e.items).map(([V,W])=>{const U=Array.isArray(W.attributes)?W.attributes.includes("SECRET")&&y[V]!==void 0:!1,B=o[n.name]??!1;return f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:V,required:W.required,tooltip:W.description,className:"mb-2 justify-start",children:W.title??V}),U&&a&&r&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{r(n.name,!B)},children:B?"Cancel":"Edit"})]}),Nre({specification:{...W,name:V},configuration:y,onValueChange:(K,X)=>{T(K,X)},flags:{isEditingExisting:a,isSecret:U,isSecretEditing:B},connectorName:s})]},V)}),H&&f.jsx(rt,{variant:"link",size:"sm",type:"button",onClick:()=>{i(n.name,{[e.value]:{}}),R(!1),c(!1)},className:"px-0",children:"Back to OAuth"})]});const j=(()=>{switch(s){case"FacebookMarketing":return f.jsx(Gat,{isLoading:l,status:d,settings:h,onOAuthSuccess:P});default:return null}})();return f.jsxs("div",{className:"space-y-3",children:[j,m&&f.jsx("div",{className:"text-destructive text-sm",children:m}),(e==null?void 0:e.items)&&Object.keys(e.items).length>0&&f.jsx(rt,{variant:"link",size:"sm",type:"button",onClick:()=>{i(n.name,{[e.value]:{}}),R(!0)},className:"px-0",children:"Manually"})]})}function Nre({specification:n,configuration:e,onValueChange:t,flags:i,connectorName:s}){const{requiredType:r,options:o}=n,{isSecret:a=!1,isEditingExisting:l=!1,isSecretEditing:c=!1}=i??{};if(n.attributes&&Array.isArray(n.attributes)&&n.attributes.includes("OAUTH_FLOW"))return f.jsx(ATe,{specification:n,configuration:e,onValueChange:t,connectorName:s});if(a)return f.jsx(Wat,{specification:n,configuration:e,onValueChange:t,isEditingExisting:l,isSecretEditing:c});if(o&&o.length>0)return f.jsx(zat,{specification:n,configuration:e,onValueChange:t,specOptions:o});switch(r){case mf.BOOLEAN:return f.jsx(Pat,{specification:n,configuration:e,onValueChange:t});case mf.NUMBER:return f.jsx(Fat,{specification:n,configuration:e,onValueChange:t});case mf.ARRAY:return f.jsx(jat,{specification:n,configuration:e,onValueChange:t});case mf.OBJECT:return f.jsx(Vat,{specification:n,configuration:e,onValueChange:t});case mf.DATE:return f.jsx(Hat,{specification:n,configuration:e,onValueChange:t});case mf.STRING:default:return f.jsx(Bat,{specification:n,configuration:e,onValueChange:t})}}function qat({specification:n,configuration:e,isEditingExisting:t,isSecretEditing:i,isSecret:s,onValueChange:r,onSecretEditToggle:o,connectorName:a}){return f.jsxs(iv,{children:[n.requiredType!==mf.BOOLEAN&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:n.name,required:n.required,tooltip:n.description,children:n.title??n.name}),s&&t&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{o(n.name,!i)},children:i?"Cancel":"Edit"})]}),Nre({specification:n,configuration:e,onValueChange:r,flags:{isSecret:s,isEditingExisting:t,isSecretEditing:i},connectorName:a})]},n.name)}function Kat({specification:n,configuration:e,onValueChange:t,isEditingExisting:i,isSecretEditing:s,onSecretEditToggle:r,connectorName:o}){const a=x.useMemo(()=>{var g,m;const h=e[n.name];if(h&&typeof h=="object"){const b=Object.keys(h);if(b.length>0)return b[0]}return((m=(g=n.oneOf)==null?void 0:g[0])==null?void 0:m.value)??""},[e,n.name,n.oneOf]),[l,c]=x.useState(a);if(x.useEffect(()=>{c(a)},[a]),x.useEffect(()=>{if(l){const h=e[n.name];h&&typeof h=="object"&&l in h||t(n.name,{[l]:{}})}},[l,n.name]),!n.oneOf)return null;const d=h=>{c(h)},u=(h,g,m)=>{const b=e[n.name]&&typeof e[n.name]=="object"?e[n.name]:{};t(n.name,{[h]:{...typeof b[h]=="object"&&b[h]!==null?b[h]:{},[g]:m}})};return f.jsx(xst,{label:n.title??n.name,options:n.oneOf.map(h=>({value:h.value,label:h.label})),value:l,onValueChange:d,children:n.oneOf.map(h=>{const g=h.attributes&&Array.isArray(h.attributes)&&h.attributes.includes("OAUTH_FLOW");return f.jsx(hst,{value:h.value,children:g?f.jsx(ATe,{specification:n,option:h,configuration:e,onValueChange:t,connectorName:o,onSecretEditToggle:r,secretEditing:{[n.name]:s},isEditingExisting:i}):Object.entries(h.items).map(([m,b])=>{const v=e[n.name]&&typeof e[n.name]=="object"?e[n.name]:{},C=Array.isArray(b.attributes)&&Object.keys(v)[0]===h.value?b.attributes.includes("SECRET"):!1,y=typeof e[n.name]=="object"&&e[n.name]!==null?e[n.name]:{},L=typeof y[h.value]=="object"&&y[h.value]!==null?y[h.value]:{};return f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:m,required:b.required,tooltip:b.description,className:"mb-2 justify-start",children:m}),C&&i&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{r(n.name,!s)},children:s?"Cancel":"Edit"})]}),Nre({specification:{...b,name:m},configuration:L,onValueChange:(E,R)=>{u(h.value,E,R)},flags:{isEditingExisting:i,isSecret:C,isSecretEditing:s},connectorName:o})]},m)})},h.value)})},n.name)}function Pme(n,e,t,i,s,r,o){return n.map(a=>{const l=Array.isArray(a.attributes)?a.attributes.includes("SECRET"):!1,c=s[a.name];return a.oneOf&&a.requiredType===mf.OBJECT?f.jsx(Kat,{specification:a,configuration:e,onValueChange:t,isEditingExisting:r,isSecretEditing:c,onSecretEditToggle:i,connectorName:o},a.name):f.jsx(qat,{specification:a,configuration:e,isEditingExisting:r,isSecret:l,isSecretEditing:c,onValueChange:t,onSecretEditToggle:i,connectorName:o},a.name)})}function Fme({collapsibleTitle:n,items:e,configuration:t,onValueChange:i,onSecretEditToggle:s,secretEditing:r,isEditingExisting:o,connectorName:a}){return n?f.jsx(HNe,{title:n,children:Pme(e,t,i,s,r,o,a)}):Pme(e,t,i,s,r,o,a)}function Zat({currentConnectorName:n,onCopyConfiguration:e,connectorSpecification:t}){const[i,s]=x.useState([]),[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(async()=>{o(!0);try{const h=await hr.getDataMartsByConnectorName(n);s(h)}catch{s([])}finally{o(!1)}},[n]);x.useEffect(()=>{a&&c()},[a,c]);const d=(h,g)=>{const m=g._id;if(!m){console.error("Configuration does not have _id field");return}e({dataMartId:h.id,dataMartTitle:h.title,configId:m,configuration:g}),l(!1)},u=h=>{const m=[],b=C=>{if(!t)return!0;const y=t.find(L=>L.name===C);return(y==null?void 0:y.required)??!1},v=(C,y,L=0,E=!0)=>{if(C.startsWith("_")||E&&L===0&&!b(C))return;let R=null;if(y==null)R="N/A";else if(typeof y=="string")R=y;else if(typeof y=="number"||typeof y=="boolean")R=String(y);else if(Array.isArray(y))R=JSON.stringify(y);else if(typeof y=="object"){m.push({key:C,value:"{",indent:L}),Object.entries(y).forEach(([T,N])=>{v(T,N,L+1,!1)}),m.push({key:"",value:"}",indent:L});return}else R=JSON.stringify(y);m.push({key:C,value:R,indent:L})};for(const[C,y]of Object.entries(h))v(C,y);return f.jsx("div",{className:"space-y-1 font-mono text-xs",children:m.map(({key:C,value:y,indent:L},E)=>f.jsxs("div",{className:"flex gap-2",style:{paddingLeft:`${String(L*12)}px`},children:[C&&f.jsxs("span",{className:"font-medium",children:[C,":"]}),f.jsx("span",{className:"text-muted-foreground truncate",title:y,children:y})]},E))})};return f.jsx(Nf,{children:f.jsxs(Al,{open:a,onOpenChange:l,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{type:"button",variant:"ghost",size:"sm",className:"cursor-pointer",children:[f.jsx("span",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Copy from…"}),f.jsx($d,{className:Le("text-foreground/75 h-3.5 w-3.5 transition-transform duration-200",a&&"rotate-90")})]})}),f.jsx(Ol,{side:"bottom",align:"end",className:"w-72",children:r?f.jsx(wn,{disabled:!0,children:"Loading…"}):i.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-4 text-center",children:[f.jsx("div",{className:"bg-muted/70 rounded-full p-3",children:f.jsx(HBe,{className:"text-muted-foreground h-6 w-6",strokeWidth:1.5})}),f.jsx("span",{className:"text-foreground text-sm font-medium",children:"No matching Data Marts"}),f.jsx("span",{className:"text-muted-foreground text-sm",children:"You can reuse configuration settings only from connector-based Data Marts that use the same source."})]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:"text-muted-foreground border-b p-2 text-sm",children:"Select one of your existing Data Marts to reuse its configuration settings."}),f.jsx("div",{children:i.map(h=>{const m=h.definition.connector.source.configuration;return m.length===0?null:m.length===1?f.jsxs(Tn,{delayDuration:300,children:[f.jsx(In,{asChild:!0,children:f.jsxs(wn,{onSelect:()=>{d(h,m[0])},children:[f.jsx(sF,{className:"text-foreground h-4 w-4"}),h.title]})}),f.jsx(kn,{side:"right",className:"max-w-sm",children:u(m[0])})]},h.id):f.jsxs(dse,{children:[f.jsxs(use,{className:"flex items-center gap-2",children:[f.jsx(sF,{className:"text-foreground h-4 w-4"}),f.jsx("span",{children:h.title})]}),f.jsx(hse,{children:m.map((b,v)=>f.jsxs(Tn,{delayDuration:300,children:[f.jsx(In,{asChild:!0,children:f.jsxs(wn,{onSelect:()=>{d(h,b)},children:["Configuration ",v+1]})}),f.jsx(kn,{side:"right",className:"max-w-sm",children:u(b)})]},v))})]},h.id)})})]})})]})})}function jme({connector:n,connectorSpecification:e,onConfigurationChange:t,onValidationChange:i,initialConfiguration:s,loading:r=!1,isEditingExisting:o=!1}){const[a,l]=x.useState({}),c=x.useRef(!1),d=x.useRef(!1),[u,h]=x.useState({});x.useEffect(()=>{if(e){d.current=!0;const T={...s??{}};e.forEach(N=>{const I=Array.isArray(N.attributes)?N.attributes.includes("SECRET"):!1;T[N.name]===void 0&&N.default!==void 0&&(T[N.name]=N.default),o&&I&&(T[N.name]=ZK)}),l(T),c.current=!0,setTimeout(()=>{d.current=!1},0)}},[e,s,o]),x.useEffect(()=>{c.current&&s&&Object.keys(s).length>0&&(d.current=!0,l({...s}),setTimeout(()=>{d.current=!1},0))},[s]),x.useEffect(()=>{c.current&&!d.current&&Object.keys(a).length>0&&(t==null||t(a))},[a,t]);const g=(T,N)=>{l(I=>({...I,[T]:N}))},m=x.useCallback(T=>!(T==null||typeof T=="string"&&T.trim()===""||typeof T=="number"&&isNaN(T)||Array.isArray(T)&&T.length===0),[]),b=x.useCallback((T,N)=>{var M,P;if(typeof T!="object"||T===null)return m(T);if((M=N.attributes)!=null&&M.includes("OAUTH_FLOW")&&"_source_credential_id"in T)return!0;const I=(P=N.oneOf)==null?void 0:P.filter(H=>H.value===Object.keys(T)[0]);return I?I.every(H=>{var j;if((j=H.attributes)!=null&&j.includes("OAUTH_FLOW")){const V=T[H.value];if(typeof V=="object"&&V!==null){if("_source_credential_id"in V)return!0;const W=Object.entries(H.items).filter(([,U])=>U.required);if(W.length>0)return W.every(([U])=>{const B=V[U];return m(B)})}return!1}return Object.entries(H.items).every(([,V])=>H.value in T?b(T[H.value],V):!1)}):m(T[N.name])},[m]),v=x.useCallback((T,N)=>{const I=N.filter(j=>j.required&&j.oneOf),M=I.length===0?!0:I.some(j=>b(T[j.name],j)),H=N.filter(j=>j.required&&j.name!=="Fields").every(j=>m(T[j.name]));return M&&H},[m,b]),C=(T,N)=>{h(I=>({...I,[T]:N})),l(N?I=>({...I,[T]:""}):I=>({...I,[T]:ZK}))},y=T=>{const N={...a};Object.entries(T.configuration).forEach(([I,M])=>{["_id","_copiedFrom"].includes(I)||(N[I]=M)}),N._copiedFrom={dataMartId:T.dataMartId,dataMartTitle:T.dataMartTitle,configId:T.configId},l(N)};if(x.useEffect(()=>{if(e&&i){const T=v(a,e);i(T)}},[a,e,i,v]),r)return f.jsx(fre,{variant:"list"});if(!e||e.length===0)return f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No configuration found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need configuration?"})]});const L=[...e].filter(T=>{var N;return T.name!=="Fields"&&!((N=T.attributes)!=null&&N.includes("HIDE_IN_CONFIG_FORM"))}).sort((T,N)=>{const I=M=>{const P=M.default!=null&&M.default!=="";return M.required&&!P?1:M.required&&P?2:!M.required&&!P?3:4};return I(T)-I(N)}),E=L.filter(T=>{var N;return!((N=T.attributes)!=null&&N.includes("ADVANCED"))}),R=L.filter(T=>{var N;return(N=T.attributes)==null?void 0:N.includes("ADVANCED")});return f.jsx(f.Fragment,{children:f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsxs(Hv,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Configure Settings"}),f.jsx(Zat,{currentConnectorName:n.name,onCopyConfiguration:y,connectorSpecification:e})]}),E.length>0&&f.jsx(Fme,{items:E,configuration:a,onValueChange:g,onSecretEditToggle:C,secretEditing:u,isEditingExisting:o,connectorName:n.name}),R.length>0&&f.jsx(Fme,{collapsibleTitle:"Advanced Settings",items:R,configuration:a,onValueChange:g,onSecretEditToggle:C,secretEditing:u,isEditingExisting:o,connectorName:n.name})]})]})})}function Yat({connector:n,connectorFields:e,selectedField:t,connectorName:i,loading:s=!1,onFieldSelect:r}){const o=i?`Select data for ${i}`:"Select data";return s?f.jsx(fre,{variant:"list"}):!e||e.length===0?f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:i?`No nodes found for ${i}`:"No nodes found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Missing some data?"})]}):f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsxs(Hv,{title:o,children:[e.map(a=>f.jsx(BNe,{type:"radio",id:a.name,name:"selectedField",value:a.name,label:a.overview??a.name,checked:t===a.name,onChange:l=>{r(l)},tooltip:a.name&&f.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Table name:"})," ",a.destinationName??a.name]}),a.description&&f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Description:"})," ",a.description]}),a.documentation&&f.jsxs(Vc,{to:a.documentation,target:"_blank",rel:"noopener noreferrer",className:"bg-muted/16 hover:bg-muted/20 dark:bg-muted/8 dark:hover:bg-muted/16 flex items-center justify-center gap-1 rounded-sm px-2 py-1 font-semibold",children:["Read more",f.jsx($d,{className:"h-3 w-3"})]})]}),selected:t===a.name},a.name)),f.jsx(PE,{label:"Missing some data?"})]})]})}var Sg=(n=>(n.ASC="asc",n.DESC="desc",n.ORIGINAL="original",n))(Sg||{});function Hme({connector:n,connectorFields:e,selectedField:t,selectedFields:i,onFieldToggle:s}){const r=x.useRef(null),[o,a]=x.useState(""),[l,c]=x.useState(Sg.ORIGINAL),d=e==null?void 0:e.find(C=>C.name===t),u=x.useMemo(()=>(d==null?void 0:d.fields)??[],[d==null?void 0:d.fields]),h=x.useMemo(()=>(d==null?void 0:d.uniqueKeys)??[],[d==null?void 0:d.uniqueKeys]),g=x.useMemo(()=>{const C=new Map;return u.forEach((y,L)=>C.set(y.name,L)),C},[u]),m=x.useMemo(()=>{const C=u.filter(L=>L.name.toLowerCase().includes(o.toLowerCase().trim())),y=(L,E)=>{const R=h.includes(L.name),T=h.includes(E.name);if(R&&!T)return-1;if(!R&&T)return 1;if(l===Sg.ASC)return L.name.localeCompare(E.name);if(l===Sg.DESC)return E.name.localeCompare(L.name);const N=g.get(L.name)??0,I=g.get(E.name)??0;return N-I};return[...C].sort(y)},[u,o,h,l,g]),b=u.map(C=>C.name),v=i.filter(C=>b.includes(C)).length;return x.useEffect(()=>{if(h.length>0){const C=h.filter(y=>u.some(L=>L.name===y)&&!i.includes(y));C.length>0&&C.forEach(y=>{s(y,!0)})}},[t,h,u,i,s]),x.useEffect(()=>{const C=y=>{const E=(y.ctrlKey||y.metaKey)&&y.shiftKey&&y.key.toLowerCase()==="a",R=document.activeElement.tagName;if(!(R==="INPUT"||R==="TEXTAREA")&&E){y.preventDefault();const T=u.map(M=>M.name),I=T.filter(M=>!i.includes(M)).length>0;T.forEach(M=>{s(M,I)})}};return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[u,i,s]),!t||!e?f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need fields?"})]}):u.length?f.jsx(L_,{children:f.jsxs(f.Fragment,{children:[f.jsx(Ey,{connector:n}),f.jsxs("div",{className:"border-border -mt-6 mb-6 flex w-full items-center gap-2 border-b",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(FS,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 cursor-text",onClick:()=>{var C;(C=r.current)==null||C.focus()}}),f.jsx("input",{ref:r,type:"text",placeholder:"Search field",value:o,onChange:C=>{a(C.target.value)},className:"h-12 w-full rounded-none border-0 pl-9 text-sm outline-none"}),o&&f.jsx("button",{type:"button",onClick:()=>{a("")},className:"text-muted-foreground hover:text-foreground absolute top-1/2 right-0 -translate-y-1/2",children:f.jsx(ID,{className:"h-4 w-4"})})]}),f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",size:"icon","aria-label":"Sort fields",children:[l===Sg.ASC&&f.jsx(Hge,{className:"text-muted-foreground h-4 w-4"}),l===Sg.DESC&&f.jsx(jge,{className:"text-muted-foreground h-4 w-4"}),l===Sg.ORIGINAL&&f.jsx(Bge,{className:"text-muted-foreground h-4 w-4"})]})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onSelect:()=>{c(Sg.ASC)},children:[f.jsx(Hge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"A–Z"]}),f.jsxs(wn,{onSelect:()=>{c(Sg.DESC)},children:[f.jsx(jge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Z–A"]}),f.jsxs(wn,{onSelect:()=>{c(Sg.ORIGINAL)},children:[f.jsx(Bge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Original"]})]})]})]}),f.jsxs(Hv,{title:`Selected ${String(v)} of ${String(b.length)} fields for "${t}" data`,children:[m.map(C=>{const y=h.includes(C.name);return f.jsx(BNe,{type:"checkbox",id:`field-${C.name}`,name:"selectedFields",value:C.name,checked:i.includes(C.name),selected:i.includes(C.name)||y,disabled:y,onChange:L=>{s(C.name,L)},label:C.name,tooltip:f.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[y&&f.jsxs("p",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-semibold",children:"Unique key"})," ",f.jsx(nK,{className:"text-secondary h-3 w-3"})]}),f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Type:"})," ",C.type]}),C.description&&f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Description:"})," ",C.description]})]}),rightIcon:y?f.jsx(nK,{className:"text-muted-foreground/75 h-4 w-4"}):void 0},C.name)}),m.length===0&&o&&f.jsxs("div",{className:"text-muted-foreground pt-8 pb-4 text-center text-sm",children:['No fields match "',o,'"']}),f.jsx(PE,{label:"Need another field?"})]})]})}):f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need fields?"})]})}const MTe=x.createContext(void 0),OTe={triggers:[],selectedTrigger:null,isLoading:!1,error:null};function Xat(n,e){switch(e.type){case"FETCH_TRIGGERS_START":case"FETCH_TRIGGER_START":case"CREATE_TRIGGER_START":case"UPDATE_TRIGGER_START":case"DELETE_TRIGGER_START":return{...n,isLoading:!0,error:null};case"FETCH_TRIGGERS_SUCCESS":return{...n,triggers:e.payload,isLoading:!1};case"FETCH_TRIGGER_SUCCESS":return{...n,selectedTrigger:e.payload,isLoading:!1};case"CREATE_TRIGGER_SUCCESS":return{...n,triggers:[...n.triggers,e.payload],isLoading:!1};case"UPDATE_TRIGGER_SUCCESS":return{...n,triggers:n.triggers.map(t=>t.id===e.payload.id?e.payload:t),selectedTrigger:n.selectedTrigger&&n.selectedTrigger.id===e.payload.id?e.payload:n.selectedTrigger,isLoading:!1};case"DELETE_TRIGGER_SUCCESS":return{...n,triggers:n.triggers.filter(t=>t.id!==e.payload),selectedTrigger:n.selectedTrigger&&n.selectedTrigger.id===e.payload?null:n.selectedTrigger,isLoading:!1};case"FETCH_TRIGGERS_ERROR":case"FETCH_TRIGGER_ERROR":case"CREATE_TRIGGER_ERROR":case"UPDATE_TRIGGER_ERROR":case"DELETE_TRIGGER_ERROR":return{...n,isLoading:!1,error:e.payload};case"SELECT_TRIGGER":return{...n,selectedTrigger:e.payload};case"RESET":return OTe;default:return n}}class Qat extends hC{constructor(){super("/data-marts")}async getScheduledTriggers(e){return this.get(`/${e}/scheduled-triggers`)}async getScheduledTrigger(e,t){return this.get(`/${e}/scheduled-triggers/${t}`)}async createScheduledTrigger(e,t){return this.post(`/${e}/scheduled-triggers`,t)}async updateScheduledTrigger(e,t,i){return this.put(`/${e}/scheduled-triggers/${t}`,i)}async deleteScheduledTrigger(e,t){return this.delete(`/${e}/scheduled-triggers/${t}`)}}const Jx=new Qat;var ho=(n=>(n.REPORT_RUN="REPORT_RUN",n.CONNECTOR_RUN="CONNECTOR_RUN",n))(ho||{});const UL={SCHEDULED_REPORT_RUN:"scheduled-report-run-config"};class YK{mapFromDto(e){return{id:e.id,type:e.type,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,nextRun:e.nextRunTimestamp?new Date(e.nextRunTimestamp):null,lastRun:e.lastRunTimestamp?new Date(e.lastRunTimestamp):null,triggerConfig:e.triggerConfig,createdById:e.createdById,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt)}}async enhanceWithReportData(e){if(e.type!==ho.REPORT_RUN)return e;const t=e.triggerConfig;if(!t.reportId)return e;try{const i=await Om.getReportById(t.reportId),s=mw(i);return{...e,triggerConfig:{...t,report:s}}}catch(i){return console.error(`Failed to fetch report data for trigger ${e.id}:`,i),e}}async enhanceTriggersWithReportData(e){return Promise.all(e.map(t=>this.enhanceWithReportData(t)))}mapToCreateRequest(e){return{type:ho.REPORT_RUN,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,triggerConfig:e.triggerConfig}}mapToUpdateRequest(e){return{cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive}}}class Jat{mapFromDto(e){return{id:e.id,type:e.type,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,nextRun:e.nextRunTimestamp?new Date(e.nextRunTimestamp):null,lastRun:e.lastRunTimestamp?new Date(e.lastRunTimestamp):null,triggerConfig:e.triggerConfig,createdById:e.createdById,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt)}}mapToCreateRequest(e){return{type:ho.CONNECTOR_RUN,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,triggerConfig:e.triggerConfig}}mapToUpdateRequest(e){return{cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive}}}const s$={getMapper(n){switch(n){case ho.REPORT_RUN:return new YK;case ho.CONNECTOR_RUN:return new Jat;default:throw new Error(`Unknown scheduled trigger type: ${String(n)}`)}}},CT={mapFromDto(n){return s$.getMapper(n.type).mapFromDto(n)},mapFromDtoList(n){return n.map(e=>this.mapFromDto(e))},async mapFromDtoWithReportData(n,e){const t=this.mapFromDto(n);switch(t.type){case ho.REPORT_RUN:return new YK().enhanceWithReportData(t);case ho.CONNECTOR_RUN:{const i=e.definition;return{...t,triggerConfig:{...t.triggerConfig,connector:i}}}default:return t}},async mapFromDtoListWithReportData(n,e){const t=new YK,i=this.mapFromDtoList(n),s=i.filter(o=>o.type===ho.REPORT_RUN),r=await t.enhanceTriggersWithReportData(s);return i.map(o=>{switch(o.type){case ho.REPORT_RUN:return r.find(a=>a.id===o.id)??o;case ho.CONNECTOR_RUN:{const a=e.definition;return{...o,triggerConfig:{...o.triggerConfig,connector:a}}}default:return o}})},mapToCreateRequest(n){return s$.getMapper(n.type).mapToCreateRequest(n)},mapToUpdateRequest(n){return s$.getMapper(n.type).mapToUpdateRequest(n)}};function elt({children:n}){const[e,t]=x.useReducer(Xat,OTe),{dataMart:i}=og(),{fetchAvailableConnectors:s}=US();if(!i)throw new Error("Trigger provider must be used within a data mart context");const r=x.useCallback(async g=>{await s(),t({type:"FETCH_TRIGGERS_START"});try{const m=await Jx.getScheduledTriggers(g),b=await CT.mapFromDtoListWithReportData(m,i);t({type:"FETCH_TRIGGERS_SUCCESS",payload:b})}catch(m){const b=m instanceof Error?m.message:"Failed to fetch scheduled triggers";t({type:"FETCH_TRIGGERS_ERROR",payload:b}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:b})}},[i,s]),o=x.useCallback(async(g,m)=>{t({type:"FETCH_TRIGGERS_START"});try{const v=(await Jx.getScheduledTriggers(g)).filter(y=>y.type===m),C=await CT.mapFromDtoListWithReportData(v,i);t({type:"FETCH_TRIGGERS_SUCCESS",payload:C})}catch(b){const v=b instanceof Error?b.message:"Failed to fetch scheduled triggers";t({type:"FETCH_TRIGGERS_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:v})}},[i]),a=x.useCallback(async(g,m)=>{t({type:"FETCH_TRIGGER_START"});try{const b=await Jx.getScheduledTrigger(g,m),v=await CT.mapFromDtoWithReportData(b,i);t({type:"FETCH_TRIGGER_SUCCESS",payload:v})}catch(b){const v=b instanceof Error?b.message:"Failed to fetch scheduled trigger";t({type:"FETCH_TRIGGER_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"GetError",label:v})}},[i]),l=x.useCallback(async(g,m,b,v,C,y)=>{t({type:"CREATE_TRIGGER_START"});try{const L={type:m,cronExpression:b,timeZone:v,isActive:C,triggerConfig:y},E=await Jx.createScheduledTrigger(g,L),R=await CT.mapFromDtoWithReportData(E,i);return t({type:"CREATE_TRIGGER_SUCCESS",payload:R}),Vt({event:"scheduled_trigger_created",category:"ScheduledTrigger",action:"Create",label:m}),Sr.success("Trigger created"),R}catch(L){const E=L instanceof Error?L.message:"Failed to create scheduled trigger";throw t({type:"CREATE_TRIGGER_ERROR",payload:E}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"CreateError",label:E}),L}},[i]),c=x.useCallback(async(g,m,b,v,C)=>{t({type:"UPDATE_TRIGGER_START"});try{const y={cronExpression:b,timeZone:v,isActive:C},L=await Jx.updateScheduledTrigger(g,m,y),E=await CT.mapFromDtoWithReportData(L,i);t({type:"UPDATE_TRIGGER_SUCCESS",payload:E}),Vt({event:"scheduled_trigger_updated",category:"ScheduledTrigger",action:"Update",label:E.type}),Sr.success("Trigger updated")}catch(y){const L=y instanceof Error?y.message:"Failed to update scheduled trigger";throw t({type:"UPDATE_TRIGGER_ERROR",payload:L}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"UpdateError",label:L}),y}},[i]),d=x.useCallback(async(g,m)=>{t({type:"DELETE_TRIGGER_START"});try{await Jx.deleteScheduledTrigger(g,m),t({type:"DELETE_TRIGGER_SUCCESS",payload:m}),Vt({event:"scheduled_trigger_deleted",category:"ScheduledTrigger",action:"Delete",label:m}),Sr.success("Trigger deleted")}catch(b){const v=b instanceof Error?b.message:"Failed to delete scheduled trigger";throw t({type:"DELETE_TRIGGER_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"DeleteError",label:v}),b}},[]),u=x.useCallback(g=>{t({type:"SELECT_TRIGGER",payload:g})},[]),h=x.useCallback(()=>{t({type:"RESET"})},[]);return f.jsx(MTe.Provider,{value:{...e,getScheduledTriggers:r,getScheduledTriggersByType:o,getScheduledTrigger:a,createScheduledTrigger:l,updateScheduledTrigger:c,deleteScheduledTrigger:d,selectScheduledTrigger:u,reset:h},children:n})}function PTe(){const n=x.useContext(MTe);if(n===void 0)throw new Error("useScheduledTriggerContext must be used within a ScheduledTriggerProvider");return n}function tlt(n){const{getScheduledTriggers:e,getScheduledTriggersByType:t,getScheduledTrigger:i,createScheduledTrigger:s,updateScheduledTrigger:r,deleteScheduledTrigger:o,selectScheduledTrigger:a,reset:l,triggers:c,selectedTrigger:d,isLoading:u,error:h}=PTe();return x.useEffect(()=>(n?e(n):l(),()=>{l()}),[n,e,l]),{triggers:c,selectedTrigger:d,isLoading:u,error:h,getScheduledTriggers:g=>e(g),getScheduledTriggersByType:(g,m)=>t(g,m),getScheduledTrigger:(g,m)=>i(g,m),createScheduledTrigger:(g,m,b,v,C,y)=>s(g,m,b,v,C,y),updateScheduledTrigger:(g,m,b,v,C)=>r(g,m,b,v,C),deleteScheduledTrigger:(g,m)=>o(g,m),selectScheduledTrigger:a}}const ilt=_s({type:Pl(UL.SCHEDULED_REPORT_RUN),reportId:pn().min(1,"Report ID is required")}),nlt=IYe(),slt=_s({type:TH(ho),cronExpression:pn().min(1,"Cron expression is required"),timeZone:pn().min(1,"Time zone is required"),isActive:TYe(),triggerConfig:AYe([ilt,nlt])});function rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:i}){const s=Bp({resolver:pb(slt),defaultValues:{type:n?n.type:t??ho.REPORT_RUN,cronExpression:(n==null?void 0:n.cronExpression)??"",timeZone:(n==null?void 0:n.timeZone)??Intl.DateTimeFormat().resolvedOptions().timeZone,isActive:(n==null?void 0:n.isActive)??!0,triggerConfig:n?n.triggerConfig:{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}}});x.useEffect(()=>{e&&s.getValues("type")===ho.REPORT_RUN&&s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e})},[e,s]),x.useEffect(()=>{t&&(s.setValue("type",t),t===ho.REPORT_RUN?s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}):s.setValue("triggerConfig",null))},[t,e,s]);const r=a=>{s.setValue("type",a),a===ho.REPORT_RUN?s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}):s.setValue("triggerConfig",null)},o=async a=>{try{await i(a)}catch(l){console.error("Error submitting form:",l)}};return{form:s,handleTypeChange:r,handleSubmit:s.handleSubmit(o),isDirty:s.formState.isDirty}}const olt=[St.GOOGLE_SHEETS,St.EMAIL,St.SLACK,St.MS_TEAMS,St.GOOGLE_CHAT];function alt({value:n,onChange:e,disabled:t}){const{reports:i,fetchReportsByDataMartId:s}=rg(),{dataMart:r}=og();x.useEffect(()=>{r&&s(r.id)},[s,r]);const o=i.filter(a=>olt.includes(a.dataDestination.type));return f.jsxs($c,{value:n,onValueChange:e,disabled:t,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a report"})}),f.jsx(Kc,{children:o.map(a=>{const l=Nc.getInfo(a.dataDestination.type).icon;return f.jsx(fo,{value:a.id,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(l,{className:"h-4 w-4",size:16}),f.jsx("span",{children:a.title})]})},a.id)})})]})}var nB="Switch",[llt]=Ha(nB),[clt,dlt]=llt(nB),FTe=x.forwardRef((n,e)=>{const{__scopeSwitch:t,name:i,checked:s,defaultChecked:r,required:o,disabled:a,value:l="on",onCheckedChange:c,form:d,...u}=n,[h,g]=x.useState(null),m=Ui(e,L=>g(L)),b=x.useRef(!1),v=h?d||!!h.closest("form"):!0,[C,y]=zc({prop:s,defaultProp:r??!1,onChange:c,caller:nB});return f.jsxs(clt,{scope:t,checked:C,disabled:a,children:[f.jsx(ui.button,{type:"button",role:"switch","aria-checked":C,"aria-required":o,"data-state":VTe(C),"data-disabled":a?"":void 0,disabled:a,value:l,...u,ref:m,onClick:Lt(n.onClick,L=>{y(E=>!E),v&&(b.current=L.isPropagationStopped(),b.current||L.stopPropagation())})}),v&&f.jsx(BTe,{control:h,bubbles:!b.current,name:i,value:l,checked:C,required:o,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});FTe.displayName=nB;var jTe="SwitchThumb",HTe=x.forwardRef((n,e)=>{const{__scopeSwitch:t,...i}=n,s=dlt(jTe,t);return f.jsx(ui.span,{"data-state":VTe(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:e})});HTe.displayName=jTe;var ult="SwitchBubbleInput",BTe=x.forwardRef(({__scopeSwitch:n,control:e,checked:t,bubbles:i=!0,...s},r)=>{const o=x.useRef(null),a=Ui(o,r),l=ire(t),c=Xne(e);return x.useEffect(()=>{const d=o.current;if(!d)return;const u=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(u,"checked").set;if(l!==t&&g){const m=new Event("click",{bubbles:i});g.call(d,t),d.dispatchEvent(m)}},[l,t,i]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...s,tabIndex:-1,ref:a,style:{...s.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});BTe.displayName=ult;function VTe(n){return n?"checked":"unchecked"}var hlt=FTe,flt=HTe;function WTe({className:n,...e}){return f.jsx(hlt,{"data-slot":"switch",className:Le("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:data-[state=unchecked]:bg-white/16",n),...e,children:f.jsx(flt,{"data-slot":"switch-thumb",className:Le("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function glt(n){const e=n.trim().split(/\s+/);return e.length!==5?null:{minute:e[0],hour:e[1],day:e[2],month:e[3],dayOfWeek:e[4]}}function XK(n,e="UTC"){const t=glt(n);if(!t)return{type:"daily",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e};const{minute:i,hour:s,day:r,month:o,dayOfWeek:a}=t;if(i.startsWith("*/")&&s==="*"&&r==="*"&&o==="*"&&a==="*"){const u=Number.parseInt(i.substring(2));if(!isNaN(u))return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:u,timezone:e}}if(i!=="*"&&s.startsWith("*/")&&r==="*"&&o==="*"&&a==="*"){const u=Number.parseInt(s.substring(2));if(!isNaN(u)&&i==="0")return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"hours",intervalValue:u,timezone:e}}const l=Number.parseInt(i),c=Number.parseInt(s),d=!isNaN(l)&&!isNaN(c)?`${c.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:"09:00";if(!isNaN(l)&&!isNaN(c)&&r==="*"&&o==="*"&&a==="*")return{type:"daily",time:d,weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e};if(!isNaN(l)&&!isNaN(c)&&r==="*"&&o==="*"&&a!=="*"){const u=a.split(",").map(h=>Number.parseInt(h.trim())).filter(h=>!isNaN(h)&&h>=0&&h<=6);if(u.length>0)return{type:"weekly",time:d,weekdays:u,monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}if(!isNaN(l)&&!isNaN(c)&&r!=="*"&&o==="*"&&a==="*"){const u=r.split(",").map(h=>Number.parseInt(h.trim())).filter(h=>!isNaN(h)&&h>=1&&h<=31);if(u.length>0)return{type:"monthly",time:d,weekdays:[1,2,3,4,5],monthDays:u,customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}return{type:"custom",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}function zTe({options:n,selected:e,onSelectionChange:t,placeholder:i="Select items...",searchPlaceholder:s="Search...",maxDisplayItems:r=3}){const[o,a]=x.useState(!1),l=u=>{const h=e.includes(u)?e.filter(g=>g!==u):[...e,u].sort((g,m)=>g-m);t(h)},c=(u,h)=>{h.preventDefault(),h.stopPropagation(),t(e.filter(g=>g!==u))},d=()=>{if(e.length===0)return f.jsx("span",{className:"text-muted-foreground text-sm",children:i});const u=e.map(h=>n.find(g=>g.value===h)).filter(Boolean);return u.length<=r?f.jsx("div",{className:"flex flex-wrap gap-1",children:u.map(h=>f.jsxs(Ya,{variant:"secondary",className:"h-5 text-xs",children:[h.label,f.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:g=>c(h.value,g),children:f.jsx(ID,{className:"h-2 w-2"})})]},h.value))}):f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Ya,{variant:"secondary",className:"h-5 text-xs",children:[u[0].label,f.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:h=>c(u[0].value,h),children:f.jsx(ID,{className:"h-2 w-2"})})]}),u.length>1&&f.jsxs(Ya,{variant:"outline",className:"h-5 text-xs",children:["+",u.length-1]})]})};return f.jsxs(yre,{open:o,onOpenChange:a,modal:!0,children:[f.jsx(Sre,{asChild:!0,children:f.jsxs(rt,{variant:"outline",role:"combobox","aria-expanded":o,className:"h-9 min-h-9 w-full justify-between bg-transparent py-1",children:[f.jsx("div",{className:"flex-1 text-left",children:d()}),f.jsx(One,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),f.jsx(xre,{className:"max-h-[400px] w-full overflow-y-auto p-0",style:{padding:0},children:f.jsxs(mTe,{className:"h-full overflow-visible",children:[f.jsx(_Te,{placeholder:s,className:"h-8"}),f.jsxs(Aot,{className:"h-full max-h-[350px] overflow-y-auto",children:[f.jsx(bTe,{children:"No items found."}),f.jsx(vTe,{className:"h-full overflow-visible",children:n.map(u=>f.jsxs(CTe,{value:u.value.toString(),onSelect:()=>l(u.value),className:"text-sm",children:[f.jsx(Wc,{className:Le("mr-2 h-3 w-3",e.includes(u.value)?"opacity-100":"opacity-0")}),u.label]},u.value))})]})]})})]})}const UTe=[{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"},{value:0,label:"Sunday"}],m4=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}};function $Te(n,e){if(!e)return"Schedule is disabled";const t=n.time;switch(n.type){case"daily":return`Daily at ${t}`;case"weekly":return`Weekly on ${n.weekdays.map(s=>{var r;return(r=UTe.find(o=>o.value===s))==null?void 0:r.label}).join(", ")} at ${t}`;case"monthly":{const s=[...n.monthDays].sort((o,a)=>o-a).map(o=>o===1?"1st":o===2?"2nd":o===3?"3rd":`${String(o)}th`);return`Monthly on the ${s.length===1?s[0]:s.length===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(", ")}, and ${s[s.length-1]}`} at ${t}`}case"interval":return n.intervalType==="minutes"?`Every ${String(n.intervalValue)} minute${n.intervalValue!==1?"s":""}`:`Every ${String(n.intervalValue)} hour${n.intervalValue!==1?"s":""}`;case"custom":return"Custom schedule";default:return""}}function plt(n,e,t=!0){const i=XK(n,e);return $Te(i,t)}const mlt=Array.from({length:31},(n,e)=>({value:e+1,label:`${String(e+1)}${e===0?"st":e===1?"nd":e===2?"rd":"th"}`})),QK=[5,10,15,30],JK=[1,2,3,4,6,8,12],_lt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Type"}),f.jsxs($c,{value:n,onValueChange:i=>{e(i)},disabled:t,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:"daily",children:"Daily"}),f.jsx(fo,{value:"weekly",children:"Weekly"}),f.jsx(fo,{value:"monthly",children:"Monthly"}),f.jsx(fo,{value:"interval",children:"Interval"})]})]})]}),blt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Time"}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(vn,{className:"w-24",type:"time",value:n,onChange:i=>{e(i.target.value)},disabled:t})})]}),Bme=({value:n,onChange:e,disabled:t,timezones:i})=>f.jsxs("div",{className:"w-full space-y-2",children:[f.jsx(Bu,{children:"Timezone"}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(Lre,{options:i,value:n,onValueChange:e,placeholder:"Select timezone",emptyMessage:"No timezones found",disabled:t,className:"w-full"})})]}),vlt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Days of Week"}),f.jsx("div",{className:t?"pointer-events-none":"",children:f.jsx(zTe,{options:UTe,selected:n,onSelectionChange:e,placeholder:"Select days...",maxDisplayItems:3})})]}),Clt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Days of Month"}),f.jsx("div",{className:t?"pointer-events-none":"",children:f.jsx(zTe,{options:mlt,selected:n,onSelectionChange:e,placeholder:"Select days...",maxDisplayItems:4})})]}),wlt=({intervalType:n,intervalValue:e,onTypeChange:t,onValueChange:i,disabled:s})=>f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Type"}),f.jsxs($c,{value:n,onValueChange:r=>{t(r)},disabled:s,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:"minutes",children:"Minutes"}),f.jsx(fo,{value:"hours",children:"Hours"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Every"}),f.jsxs($c,{value:e.toString(),onValueChange:r=>{i(Number.parseInt(r)||1)},disabled:s,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsx(Kc,{children:(n==="minutes"?QK:JK).map(r=>f.jsxs(fo,{value:r.toString(),children:[r," ",n==="minutes"?"min":"hr"]},r))})]})]})]}),ylt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-1",children:[f.jsx(Bu,{className:"text-sm",children:"Cron Expression"}),f.jsx(vn,{value:n,onChange:i=>{e(i.target.value)},placeholder:"0 9 * * *",className:"h-9 font-mono text-sm",disabled:t}),f.jsx("p",{className:"text-muted-foreground text-xs",children:"Format: minute hour day month day-of-week"})]});function Slt({cron:n="0 9 * * *",timezone:e,enabled:t=!0,onChange:i,className:s,showPreview:r=!0,showSaveButton:o=!1}){const[a,l]=x.useState(t),[c,d]=x.useState(e??m4()),[u,h]=x.useState(!1),g=x.useMemo(()=>eQe.getTimezonesWithOffset().map(W=>({value:W.identifier,label:W.displayName,offset:W.offsetString,isDST:W.isDST})),[]),[m,b]=x.useState(()=>XK(n,c)),[v,C]=x.useState(""),[y,L]=x.useState("");x.useEffect(()=>{l(t)},[t]),x.useEffect(()=>{const W=e??m4();d(W)},[e]),x.useEffect(()=>{if(n){const W=XK(n,c);b(W)}},[n,c]);const E=W=>{const[U,B]=W.time.split(":").map(Number);switch(W.type){case"daily":return`${String(B)} ${String(U)} * * *`;case"weekly":return`${String(B)} ${String(U)} * * ${W.weekdays.join(",")}`;case"monthly":return`${String(B)} ${String(U)} ${W.monthDays.join(",")} * *`;case"interval":return W.intervalType==="minutes"?`*/${String(W.intervalValue)} * * * *`:`0 */${String(W.intervalValue)} * * *`;case"custom":return W.customCron;default:return`${String(B)} ${String(U)} * * *`}},R=x.useCallback(W=>{b(U=>{if(U.intervalType===W)return console.log("Type unchanged, skipping update"),U;const K=(W==="minutes"?QK:JK)[0];return{...U,intervalType:W,intervalValue:K}})},[]),T=x.useCallback(W=>{b(U=>(U.intervalType==="minutes"?QK:JK).includes(W)?{...U,intervalValue:W}:U)},[]),N=x.useMemo(()=>W=>$Te(W,a),[a]);x.useEffect(()=>{const W=E(m);C(W),L(N(m))},[m,a,c,N]);const I=x.useRef(""),M=x.useRef(""),P=x.useRef(!1);x.useEffect(()=>{const W=E(m);i&&(I.current!==W||M.current!==c||P.current!==a)&&(i({cron:W,timezone:c,enabled:a}),I.current=W,M.current=c,P.current=a)},[m,c,a,i]);const H=W=>{l(W)},j=W=>{d(W),b(U=>({...U,timezone:W}))},V=["daily","weekly","monthly"].includes(m.type);return f.jsxs("div",{className:s,children:[f.jsx("div",{className:"mb-4 space-y-4 pt-0",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-foreground flex items-center gap-1.5 font-medium",children:"Schedule Settings"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Bu,{htmlFor:"schedule-enabled",className:"text-sm font-normal",children:a?"Enabled":"Disabled"}),f.jsx(WTe,{id:"schedule-enabled",checked:a,onCheckedChange:H})]})]})}),f.jsxs("div",{className:"space-y-4 pt-0",children:[f.jsxs("div",{className:`space-y-4 ${a?"":"opacity-50"}`,children:[f.jsx(_lt,{value:m.type,onChange:W=>{b(U=>({...U,type:W}))},disabled:!a}),m.type!=="custom"&&m.type!=="interval"&&f.jsxs("div",{className:"flex gap-3",children:[f.jsx(blt,{value:m.time,onChange:W=>{b(U=>({...U,time:W}))},disabled:!a}),V&&f.jsx(Bme,{value:c,onChange:j,disabled:!a,timezones:g})]}),(m.type==="interval"||m.type==="custom")&&f.jsx(Bme,{value:c,onChange:j,disabled:!a,timezones:g}),m.type==="weekly"&&f.jsx(vlt,{value:m.weekdays,onChange:W=>{b(U=>({...U,weekdays:W}))},disabled:!a}),m.type==="monthly"&&f.jsx(Clt,{value:m.monthDays,onChange:W=>{b(U=>({...U,monthDays:W}))},disabled:!a}),m.type==="interval"&&f.jsx(wlt,{intervalType:m.intervalType,intervalValue:m.intervalValue,onTypeChange:R,onValueChange:T,disabled:!a}),m.type==="custom"&&f.jsx(ylt,{value:m.customCron,onChange:W=>{b(U=>({...U,customCron:W}))},disabled:!a})]}),r&&f.jsxs(f.Fragment,{children:[f.jsx(Cxe,{className:"my-3"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex cursor-pointer items-center justify-between",onClick:()=>{h(!u)},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ixe,{className:"h-4 w-4"}),f.jsx("span",{className:"text-sm font-medium",children:"Preview"})]}),u?f.jsx(TD,{className:"text-muted-foreground h-4 w-4"}):f.jsx(Pp,{className:"text-muted-foreground h-4 w-4"})]}),u&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid gap-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Status:"}),f.jsx(Ya,{variant:a?"default":"secondary",className:"text-xs",children:a?"Enabled":"Disabled"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Cron:"}),f.jsx(Ya,{variant:"secondary",className:"font-mono text-xs",children:v})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Timezone:"}),f.jsx(Ya,{variant:"outline",className:"text-xs",children:c})]}),f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Schedule:"}),f.jsx("span",{className:"flex-1 text-right text-xs",children:y})]})]}),a&&V&&c!==m4()&&f.jsxs(Dre,{className:"border-amber-200 bg-amber-50",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(kTe,{children:"Time Zone"}),f.jsxs(Rre,{children:["Schedule runs in ",c," (not your local ",m4()," ","time). Execution time may differ from expected."]})]})]})]})]}),o&&f.jsx(rt,{className:"w-full",disabled:!a,children:"Save Schedule"})]})]})}function xlt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"trigger-type-options-description-details",children:[f.jsx(is,{children:"How do I choose a type?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:[f.jsx("strong",{children:"Report Run"})," - runs a report to import data from the specified Data Storage into a Destination provider (e.g. Google Sheets document)."]}),f.jsxs("p",{className:"mb-2",children:[f.jsx("strong",{children:"Connector Run"})," - runs a connector (e.g., Facebook Ads) configured in the Data Mart to update raw data in the selected Data Storage."]})]})]})})}function Llt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"trigger-type-change-description-details",children:[f.jsx(is,{children:"How do I change the trigger type?"}),f.jsx(ns,{children:f.jsx("p",{children:"Trigger type cannot be changed after the trigger is created. If you need a different type, delete the existing trigger and create a new one with the desired type."})})]})})}function Elt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"report-change-description-details",children:[f.jsx(is,{children:"How do I change a report?"}),f.jsx(ns,{children:f.jsx("p",{children:"The report cannot be changed after the trigger is created. If you need a different report, delete the existing trigger and create a new one with the desired report."})})]})})}function Dlt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"report-select-description-details",children:[f.jsx(is,{children:"How do I choose the report?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"For a Report Run trigger, select one of the available Destinations (e.g., a Google Sheets report)."}),f.jsxs("p",{children:["You can use an existing one or create a new one on the ",f.jsx("strong",{children:"Destinations"})," tab"," ","of this Data Mart."]})]})]})})}function Rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:i,onCancel:s,onDirtyChange:r}){const[o,a]=x.useState(!1),{form:l,handleTypeChange:c,handleSubmit:d,isDirty:u}=rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:async v=>{a(!0);try{await i(v)}finally{a(!1)}}});x.useEffect(()=>{r==null||r(u)},[u,r]);const{control:h,watch:g}=l,b=g("type")===ho.REPORT_RUN;return f.jsx(CC,{...l,children:f.jsxs(gb,{onSubmit:v=>void d(v),noValidate:!1,children:[f.jsxs(wC,{children:[f.jsx(fn,{control:h,name:"type",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Choose what you want this trigger to run - a report or a connector",children:"Trigger Type"}),f.jsxs($c,{onValueChange:C=>{v.onChange(C),c(C)},defaultValue:v.value,disabled:!!t||!!n||!!g("triggerConfig.reportId"),children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select trigger type"})})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:ho.REPORT_RUN,children:"Report Run"}),f.jsx(fo,{value:ho.CONNECTOR_RUN,children:"Connector Run"})]})]}),f.jsx(Hs,{children:n?f.jsx(Llt,{}):f.jsx(xlt,{})}),f.jsx(Cn,{})]})}),b&&f.jsx(fn,{control:h,name:"triggerConfig.reportId",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select the report that will be run by this trigger",children:"Report"}),f.jsx(cn,{children:f.jsx(ODe,{children:f.jsx(alt,{value:v.value,onChange:v.onChange,disabled:!!e||!!n})})}),f.jsx(Hs,{children:n!=null&&n.triggerConfig?f.jsx(Elt,{}):f.jsx(Dlt,{})}),f.jsx(Cn,{})]})}),f.jsx(Slt,{showPreview:!1,cron:g("cronExpression"),timezone:g("timeZone"),enabled:g("isActive"),onChange:v=>{l.setValue("cronExpression",v.cron,{shouldDirty:!0}),l.setValue("timeZone",v.timezone,{shouldDirty:!0}),l.setValue("isActive",v.enabled,{shouldDirty:!0})},className:"border-border flex flex-col gap-1.5 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4"})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":n?"Save changes":"Create trigger",disabled:!u||o,children:o?n?"Saving...":"Creating...":n?"Save changes":"Create trigger"}),s&&f.jsx(rt,{variant:"outline",type:"button",onClick:s,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Nlt({cronExpression:n,timeZone:e,isEnabled:t=!0}){const i=x.useMemo(()=>plt(n,e,t),[n,e,t]);return f.jsxs("div",{children:[f.jsx("div",{children:i}),t&&f.jsx("code",{className:"text-muted-foreground mt-1 block text-xs",children:e})]})}function Tlt({trigger:n,onEditTrigger:e,onDeleteTrigger:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),a=()=>{o(!1),t(n.id)};return f.jsxs("div",{className:"text-right",onClick:l=>{l.stopPropagation()},children:[f.jsxs(Al,{open:i,onOpenChange:s,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${i?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>{e(n.id)},children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit trigger"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>{o(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete trigger"})]})]})]}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Delete Scheduled Trigger",description:"Are you sure you want to delete this scheduled trigger? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:a,variant:"destructive"})]})}function Ilt({connector:n}){const{connectors:e}=US(),t=ait(n,e);return f.jsx(f.Fragment,{children:t})}function GTe({connector:n}){return f.jsx(Ilt,{connector:n})}function klt(n){if(n.length===0)return{lastRunDate:null,lastRunStatus:null,totalRuns:0,firstRunDate:null};const e=n[0],t=n[n.length-1],i=new Date(t.createdAt);return{lastRunDate:new Date(e.createdAt),lastRunStatus:e.status,totalRuns:n.length,firstRunDate:i}}const Alt=n=>{const{connectors:e}=US();return x.useMemo(()=>e.find(t=>t.name===n),[e,n])},Mlt=nt.memo(function({connector:e,children:t}){const i=Alt(e.source.name),{dataMart:s,runs:r,getDataMartRuns:o}=og();x.useEffect(()=>{s!=null&&s.id&&o(s.id)},[s==null?void 0:s.id,o]);const a=x.useMemo(()=>i!=null&&i.logoBase64?f.jsx(VS,{base64:i.logoBase64,size:20}):null,[i==null?void 0:i.logoBase64]),l=x.useCallback(()=>{s!=null&&s.storage&&kQe(s.storage,e.storage.fullyQualifiedName)},[s==null?void 0:s.storage,e.storage.fullyQualifiedName]),c=x.useMemo(()=>klt(r),[r]),d=x.useMemo(()=>!c.lastRunDate||!c.lastRunStatus?null:{statusType:ZJe(c.lastRunStatus),statusText:XJe(c.lastRunStatus),date:c.lastRunDate},[c]),u=x.useMemo(()=>(s==null?void 0:s.storage)&&AQe(s.storage),[s]),h=x.useMemo(()=>{const g=e.source.fields.length.toString();return`${e.source.node} • ${g} fields`},[e.source.node,e.source.fields.length]);return f.jsxs(jH,{children:[f.jsx(HH,{asChild:!0,children:f.jsx("span",{children:t})}),f.jsxs(BH,{children:[f.jsxs(Tse,{children:[f.jsx(Ise,{children:a}),f.jsxs(kse,{children:[f.jsx(Ase,{children:f.jsx(GTe,{connector:e})}),f.jsx(Mse,{children:h})]})]}),f.jsxs(Ose,{children:[f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Last run status:"}),f.jsx(Fv,{children:d?f.jsx(kM,{type:d.statusType,variant:"ghost",children:d.statusText}):"Not run yet"})]}),f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Last run date:"}),f.jsx(Fv,{children:d?f.jsx(W1,{date:d.date}):"Never run"})]}),f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Total runs:"}),f.jsxs(Fv,{children:[c.totalRuns," runs",c.firstRunDate&&f.jsxs(f.Fragment,{children:[", since"," ",c.firstRunDate.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})]})]})]})]}),f.jsx(Pse,{children:f.jsxs(rt,{className:"w-full",variant:"default",onClick:l,title:"Open Storage","aria-label":"Open Storage",children:[u,f.jsx(F_,{className:"ml-1 inline h-4 w-4","aria-hidden":"true"})]})})]})]})},(n,e)=>n.connector.source.name===e.connector.source.name&&n.connector.storage.fullyQualifiedName===e.connector.storage.fullyQualifiedName&&n.connector.source.node===e.connector.source.node&&n.connector.source.fields.length===e.connector.source.fields.length);function Olt(n){const e=n.triggerConfig,t=Nc.getInfo(e.report.dataDestination.type).icon;return f.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[f.jsx(t,{className:"h-4 w-4",size:16}),e.report.title,f.jsx(qJe,{report:e.report,children:f.jsx(sc,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function Plt(n){var s;const e=n.triggerConfig,{connector:t}=e.connector,i=(s=t.info)!=null&&s.logoBase64?f.jsx(VS,{base64:t.info.logoBase64,className:"h-4 w-4",size:16}):f.jsx(j1,{className:"h-4 w-4",size:16});return f.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[i,f.jsx(GTe,{connector:t}),f.jsx(Mlt,{connector:t,children:f.jsx(sc,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function Flt({trigger:n}){switch(n.type){case ho.REPORT_RUN:return Olt(n);case ho.CONNECTOR_RUN:return Plt(n);default:return f.jsx("div",{className:"text-muted-foreground text-sm",children:"—"})}}function jlt({onEditTrigger:n,onDeleteTrigger:e}){return[{accessorKey:"type",size:150,header:"Trigger Type",cell:({row:t})=>{const s=t.getValue("type")===ho.REPORT_RUN?"Report Run":"Connector Run";return f.jsx(Ya,{variant:"outline",children:s})},meta:{title:"Trigger Type"}},{accessorKey:"triggerConfig",size:35,header:"Run Target",cell:({row:t})=>f.jsx(Flt,{trigger:t.original}),meta:{title:"Run Target"}},{accessorKey:"cronExpression",size:20,header:"Schedule",cell:({row:t})=>{const i=t.getValue("cronExpression"),s=t.original.timeZone,r=t.getValue("isActive");return f.jsx(Nlt,{cronExpression:String(i),timeZone:s,isEnabled:r})},meta:{title:"Schedule"}},{accessorKey:"nextRun",size:15,header:"Next Run",cell:({row:t})=>{const i=t.original.nextRun;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Not scheduled"})},meta:{title:"Next Run"}},{accessorKey:"lastRun",size:15,header:"Last Run",cell:({row:t})=>{const i=t.original.lastRun;return f.jsx("div",{className:"text-sm",children:i?f.jsx(W1,{date:new Date(i)}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"Never run"})})},meta:{title:"Last Run"}},{accessorKey:"isActive",size:15,header:"Trigger Status",cell:({row:t})=>{const i=t.getValue("isActive");return f.jsx(kM,{type:i?Do.SUCCESS:Do.NEUTRAL,variant:"ghost",showIcon:!1,children:i?"Enabled":"Disabled"})},meta:{title:"Trigger Status"}},{id:"actions",size:80,header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(Tlt,{trigger:t.original,onEditTrigger:n,onDeleteTrigger:e}),meta:{title:"Actions"}}]}function Hlt({table:n,onPreviousClick:e,onNextClick:t}){return f.jsxs("div",{className:"dm-card-pagination",role:"navigation","aria-label":"Table pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:e,disabled:!n.getCanPreviousPage(),"aria-label":"Go to previous page",children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:t,disabled:!n.getCanNextPage(),"aria-label":"Go to next page",children:"Next"})]})}function Tre({isOpen:n,onClose:e,dataMartId:t,preSelectedReportId:i,preSelectedType:s}){const{createScheduledTrigger:r,updateScheduledTrigger:o,selectedTrigger:a}=PTe(),[l,c]=x.useState(!1),[d,u]=x.useState(!1),h=x.useCallback(()=>{d?c(!0):e()},[d,e]),g=x.useCallback(()=>{c(!1),u(!1),e()},[e]),m=x.useCallback(E=>{u(E)},[]),b=x.useCallback(()=>{u(!1),e()},[e]),v=!!a,C=x.useMemo(()=>a?{type:a.type,cronExpression:a.cronExpression,timeZone:a.timeZone,isActive:a.isActive,triggerConfig:a.type===ho.REPORT_RUN?{type:UL.SCHEDULED_REPORT_RUN,reportId:a.triggerConfig.reportId}:null}:void 0,[a]),y=async E=>{v?await o(t,a.id,E.cronExpression,E.timeZone,E.isActive):await r(t,E.type,E.cronExpression,E.timeZone,E.isActive,E.triggerConfig),b()},L=x.useRef(!1);return x.useEffect(()=>{const E=v?"Edit":"Create",R=(a==null?void 0:a.type)??s;n&&!L.current?(Vt({event:"scheduled_trigger_config_open",category:"ScheduledTrigger",action:E,label:R}),L.current=!0):!n&&L.current&&(Vt({event:"scheduled_trigger_config_close",category:"ScheduledTrigger",action:E,label:R}),L.current=!1)},[n,v,a,s]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:E=>{E||h()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsxs(db,{children:[v?"Edit":"Create"," Scheduled Trigger"]}),f.jsx(cC,{children:"Configure automatic runs for your reports or connectors."})]}),f.jsx(Rlt,{preSelectedReportId:i,preSelectedType:s,initialData:C,onSubmit:y,onCancel:h,onDirtyChange:m})]})}),f.jsx(Ma,{open:l,onOpenChange:c,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:g,variant:"destructive"})]})}function Blt({triggers:n,dataMartId:e,onEditTrigger:t,onDeleteTrigger:i}){const[s,r]=x.useState(!1),o=x.useCallback(()=>{r(!1)},[]),a=x.useCallback(C=>{i(C)},[i]),l=x.useMemo(()=>jlt({onEditTrigger:t,onDeleteTrigger:a}),[t,a]),{sorting:c,setSorting:d,columnVisibility:u,setColumnVisibility:h}=zS({columns:l,storageKeyPrefix:"data-mart-scheduled-triggers",defaultSortingColumn:"type"}),g=pC({data:n,columns:l,getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:d,getSortedRowModel:WS(),getFilteredRowModel:HR(),state:{sorting:c,columnVisibility:u},onColumnVisibilityChange:h,enableGlobalFilter:!0,enableColumnResizing:!1}),m=x.useCallback(()=>{g.previousPage()},[g]),b=x.useCallback(()=>{g.nextPage()},[g]);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:"scheduled-triggers-table",className:"dm-card-table",role:"table","aria-label":"Scheduled Triggers",children:[f.jsx(_C,{className:"dm-card-table-header",children:g.getHeaderGroups().map(C=>f.jsx(qr,{className:"dm-card-table-header-row",children:C.headers.map(y=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",scope:"col",style:y.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:y.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(y.getSize())}%`},children:y.isPlaceholder?null:typeof y.column.columnDef.header=="function"?y.column.columnDef.header(y.getContext()):y.column.columnDef.header},y.id))},C.id))}),f.jsx(bC,{className:"dm-card-table-body",children:g.getRowModel().rows.length?g.getRowModel().rows.map((C,y)=>f.jsx(qr,{onClick:()=>{t(C.original.id)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":y+1,children:C.getVisibleCells().map((L,E)=>f.jsx(Rl,{className:`whitespace-normal ${L.column.id==="actions"?"actions-cell":""}`,role:"cell","aria-colindex":E+1,style:L.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.column.getSize())}%`},children:typeof L.column.columnDef.cell=="function"?L.column.columnDef.cell(L.getContext()):L.column.columnDef.cell},L.id))},C.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:l.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No scheduled triggers found."})})})})]})}),f.jsx(Hlt,{table:g,onPreviousClick:m,onNextClick:b}),f.jsx(Tre,{isOpen:s,onClose:o,dataMartId:e})]})}function Vlt({dataMartId:n}){const{triggers:e,deleteScheduledTrigger:t,selectScheduledTrigger:i,selectedTrigger:s}=tlt(n),[r,o]=x.useState(!1);x.useEffect(()=>{s&&o(!0)},[s]);const a=d=>{const u=e.find(h=>h.id===d);u&&i(u)},l=()=>{o(!1),i(null)},c=async d=>{try{await t(n,d)}catch(u){console.error("Error deleting trigger:",u)}};return f.jsxs(f.Fragment,{children:[f.jsx(Blt,{triggers:e,dataMartId:n,onEditTrigger:a,onDeleteTrigger:d=>void c(d)}),f.jsx(Tre,{isOpen:r,onClose:l,dataMartId:n})]})}function Ire(){return f.jsx("div",{className:"dm-card-block !gap-1.5 !py-3",children:f.jsxs("div",{className:"text-foreground flex items-start gap-1.5 text-sm",children:[f.jsx(oxe,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium",children:"Time Triggers"}),f.jsxs("p",{className:"text-muted-foreground",children:["Set up automatic runs in the ",f.jsx("span",{className:"font-medium",children:"Triggers"})," tab once you’ve saved and published this Data Mart."]})]})]})})}function _4(n){return n.startsWith('"')&&n.endsWith('"')?n:`"${n}"`}function jF(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n}function Wlt({dataStorageType:n,target:e,destinationName:t,connectorName:i,onTargetChange:s}){const r=t.replace(/[^a-zA-Z0-9_]/g,"_"),o=i.replace(/[^a-zA-Z0-9_]/g,"_").toLowerCase(),[a,l]=x.useState(""),[c,d]=x.useState(""),[u,h]=x.useState(""),[g,m]=x.useState(null),[b,v]=x.useState(null),[C,y]=x.useState(null),L=(I,M=!1)=>I.trim()?M&&I.startsWith('"')&&I.endsWith('"')?I.slice(1,-1)?null:"Quoted identifier cannot be empty":/^[A-Za-z][A-Za-z0-9_]*$/.test(I)?null:"Use letters, numbers, and underscores; start with a letter":"This field is required",E=x.useCallback((I,M,P,H,j,V)=>{let W;if(n===lt.SNOWFLAKE&&j){const B=_4(j),K=_4(M);W=`${I}.${B}.${K}`}else W=`${I}.${M}`;const U=n===lt.SNOWFLAKE?!!(I&&j&&M&&P===null&&V===null&&H===null):!!(I&&M&&P===null&&H===null);s({fullyQualifiedName:W,isValid:U})},[s,n]);x.useEffect(()=>{let I="",M="",P="";if(e!=null&&e.fullyQualifiedName){const B=e.fullyQualifiedName.match(/(?:[^."]+|"[^"]*")+/g)??[];if(n===lt.SNOWFLAKE&&B.length===3){const K=B[0],X=B[1],ne=B[2];K&&X&&ne&&(I=K,M=jF(X),P=jF(ne))}else if(B.length>=2){const K=B[0],X=B[1];K&&X&&(I=K,P=X)}}else I=`${o}_owox`,n===lt.SNOWFLAKE&&(M="PUBLIC"),P=r;const H=L(I),j=n===lt.SNOWFLAKE?L(M,!0):null,V=L(P,n===lt.SNOWFLAKE);l(I),d(M),h(P),m(H),v(j),y(V);const W=n===lt.SNOWFLAKE&&M?`${I}.${_4(M)}.${_4(P)}`:`${I}.${P}`,U=n===lt.SNOWFLAKE?!!(I&&M&&P&&H===null&&j===null&&V===null):!!(I&&P&&H===null&&V===null);((e==null?void 0:e.fullyQualifiedName)!==W||e.isValid!==U)&&E(I,P,H,V,M,j)},[e,r,o,n,E]);const R=I=>{l(I);const M=L(I);m(M),E(I,u,M,C,c,b)},T=I=>{d(I);const M=L(I,!0);v(M),E(a,u,g,C,I,M)},N=I=>{h(I);const M=L(I,n===lt.SNOWFLAKE);y(M),E(a,I,g,M,c,b)};return f.jsxs(L_,{children:[n===lt.GOOGLE_BIGQUERY&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(XEe,{}),title:"Google BigQuery",docUrl:"https://docs.owox.com/docs/storages/supported-storages/google-bigquery/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"dataset-name",tooltip:"Enter dataset name for Google BigQuery where the connector data will be stored.",children:"Dataset name"}),f.jsx(vn,{type:"text",id:"dataset-name",placeholder:"Enter dataset name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"dataset-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Dataset is auto-created on first run if it doesn’t exist"}),g&&f.jsx("p",{id:"dataset-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),f.jsx(vn,{type:"text",id:"table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),C&&f.jsx("p",{id:"table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),n===lt.AWS_ATHENA&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(QEe,{}),title:"AWS Athena",docUrl:"https://docs.owox.com/docs/storages/supported-storages/aws-athena/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"database-name",tooltip:"Enter database name for Amazon Athena where the connector data will be stored.",children:"Database name"}),f.jsx(vn,{type:"text",id:"database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"database-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn’t exist"}),g&&f.jsx("p",{id:"database-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"athena-table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),f.jsx(vn,{type:"text",id:"athena-table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"athena-table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),C&&f.jsx("p",{id:"athena-table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),n===lt.SNOWFLAKE&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(JEe,{}),title:"Snowflake",docUrl:"https://docs.owox.com/docs/storages/supported-storages/snowflake/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-database-name",tooltip:"Enter database name for Snowflake where the connector data will be stored.",children:"Database name"}),f.jsx(vn,{type:"text",id:"snowflake-database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"snowflake-database-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn't exist"}),g&&f.jsx("p",{id:"snowflake-database-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-schema-name",tooltip:"Enter schema name for Snowflake where the connector data will be stored. Identifiers will be quoted automatically to preserve case sensitivity.",children:"Schema name"}),f.jsx(vn,{type:"text",id:"snowflake-schema-name",placeholder:"PUBLIC",autoComplete:"off",className:"box-border w-full",value:c,"aria-invalid":!!b,"aria-describedby":b?"snowflake-schema-name-error":void 0,onChange:I=>{T(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Schema is auto-created on first run if it doesn't exist"}),b&&f.jsx("p",{id:"snowflake-schema-name-error",className:"text-destructive text-sm",children:b})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-table-name",tooltip:"Enter table name where the connector data will be stored. Identifiers will be quoted automatically to preserve case sensitivity.",children:"Table name"}),f.jsx(vn,{type:"text",id:"snowflake-table-name",placeholder:"my_table",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"snowflake-table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn't exist"}),C&&f.jsx("p",{id:"snowflake-table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),f.jsx(Hv,{title:"Schedule updates",children:f.jsx(Ire,{})})]})}function zlt({onSubmit:n,dataStorageType:e,configurationOnly:t=!1,existingConnector:i=null,mode:s="full",initialStep:r,preselectedConnector:o,onDirtyChange:a}){const[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,g]=x.useState(""),[m,b]=x.useState([]),[v,C]=x.useState(1),[y,L]=x.useState({}),[E,R]=x.useState(!1),[T,N]=x.useState(new Set),[I,M]=x.useState(new Set),{connectors:P,connectorSpecification:H,connectorFields:j,loading:V,loadingSpecification:W,loadingFields:U,error:B,fetchAvailableConnectors:K,fetchConnectorSpecification:X,fetchConnectorFields:ne}=US();x.useEffect(()=>{a==null||a(l)},[l,a]);const[fe,Z]=x.useState(null),ee=(t?[{id:1,title:"Configuration",description:"Set up connector parameters"}]:s==="fields-only"?[{id:1,title:"Select Fields",description:"Pick specific fields"}]:[{id:1,title:"Select Connector",description:"Choose a data source"},{id:2,title:"Configuration",description:"Set up connector parameters"},{id:3,title:"Select Nodes",description:"Choose data nodes"},{id:4,title:"Select Fields",description:"Pick specific fields"},{id:5,title:"Target Setup",description:"Configure destination"}]).length,se=x.useCallback(async Ht=>{!T.has(Ht)&&!W&&(N(oe=>new Set(oe).add(Ht)),await X(Ht))},[T,W,X]),ae=x.useCallback(async Ht=>{I.has(Ht)||(M(oe=>new Set(oe).add(Ht)),await ne(Ht))},[I,ne]);x.useEffect(()=>{if(!o||d||P.length===0)return;const Ht=P.find(oe=>oe.name===o);Ht&&(u(Ht),C(r??2),se(Ht.name),!t&&s!=="fields-only"&&ae(Ht.name))},[o,P,d,r,t,s,se,ae]),x.useEffect(()=>{if(P.length===0&&!V&&K(),i&&P.length>0&&!d){const{source:Ht,storage:oe}=i;g(Ht.node),b(Ht.fields),L(Ht.configuration[0]||{}),Z({fullyQualifiedName:oe.fullyQualifiedName,isValid:!0});const Ce=P.find(je=>je.name===Ht.name);Ce&&(u(Ce),se(Ce.name),!t&&s!=="fields-only"&&ae(Ce.name),s==="fields-only"&&ae(Ce.name))}if(t&&P.length>0&&!d&&!i){const Ht=P[0];u(Ht),se(Ht.name)}},[s,i,P,t,V,K,se,ae,d]);const Se=Ht=>{u(Ht),L({}),R(!1),c(!0),N(oe=>{const Ce=new Set(oe);return Ce.delete(Ht.name),Ce}),se(Ht.name),ae(Ht.name)},ue=Ht=>{g(Ht),b([]),c(!0)},Re=(Ht,oe)=>{b(oe?Ce=>Ce.includes(Ht)?Ce:[...Ce,Ht]:Ce=>Ce.filter(je=>je!==Ht)),c(!0)},Ve=(Ht,oe)=>{b(oe?Ce=>{const je=Ht.filter(bt=>!Ce.includes(bt));return[...Ce,...je]}:Ce=>Ce.filter(je=>!Ht.includes(je))),c(!0)},Qe=Ht=>{Z(Ht),c(!0)},dt=x.useCallback(Ht=>{L(Ht),c(!0)},[]),yt=x.useCallback(Ht=>{R(Ht)},[]);x.useEffect(()=>{H&&(H.some(oe=>oe.required&&oe.name!=="Fields")||R(!0))},[H]);const fi=()=>{v<ee&&C(v+1)},_i=()=>{v>1&&C(v-1)},Sn=()=>{if(t)return d!==null&&E;if(s==="fields-only")switch(v){case 1:return m.length>0;default:return!1}switch(v){case 1:return d!==null;case 2:return E;case 3:return h!=="";case 4:return m.length>0;case 5:return fe!==null&&fe.fullyQualifiedName!==""&&fe.isValid;default:return!1}},Es=()=>v>1,br=(Ht,oe)=>{if(!Ht)return oe;const Ce=Ht.find(je=>je.name===oe);return(Ce==null?void 0:Ce.destinationName)??oe},hs=()=>{if(t&&v===1)return H&&d?f.jsx(jme,{connector:d,connectorSpecification:H,onConfigurationChange:dt,onValidationChange:yt,initialConfiguration:y,loading:W,isEditingExisting:!!(i!=null&&i.source.configuration.length)}):null;if(s==="fields-only")switch(v){case 1:return d&&h&&j?f.jsx(Hme,{connector:d,connectorFields:j,selectedField:h,selectedFields:m,onFieldToggle:Re,onSelectAllFields:Ve}):null;default:return null}switch(v){case 1:return f.jsx(Mat,{connectors:P,selectedConnector:d,loading:V,error:B,onConnectorSelect:Se,onConnectorDoubleClick:()=>{C(Ht=>Ht<ee?Ht+1:Ht)}});case 2:return d&&H?f.jsx(jme,{connector:d,connectorSpecification:H,onConfigurationChange:dt,onValidationChange:yt,initialConfiguration:y,loading:W,isEditingExisting:!1}):null;case 3:return d&&j?f.jsx(Yat,{connectorFields:j,connector:d,selectedField:h,connectorName:d.displayName,loading:U,onFieldSelect:ue}):null;case 4:return d&&h&&j?f.jsx(Hme,{connector:d,connectorFields:j,selectedField:h,selectedFields:m,onFieldToggle:Re,onSelectAllFields:Ve}):null;case 5:return h&&j?f.jsx(Wlt,{dataStorageType:e,destinationName:br(j,h),connectorName:(d==null?void 0:d.displayName)??"",target:fe,onTargetChange:Qe}):null;default:return null}};return f.jsxs(wst,{children:[f.jsx(yst,{children:hs()}),f.jsx(Sst,{variant:"horizontal",children:f.jsx(Oat,{currentStep:v,totalSteps:ee,canGoNext:Sn(),canGoBack:Es(),isLoading:W||U,onNext:fi,onBack:_i,onFinish:()=>{t&&d?n({source:{name:d.name,configuration:[y],node:(i==null?void 0:i.source.node)??h,fields:(i==null?void 0:i.source.fields)??m},storage:(i==null?void 0:i.storage)??{fullyQualifiedName:(i==null?void 0:i.storage.fullyQualifiedName)??""}}):s==="fields-only"&&i?n({source:{...i.source,fields:m},storage:i.storage}):d&&fe&&n({source:{name:d.name,configuration:[y],node:h,fields:m},storage:{fullyQualifiedName:fe.fullyQualifiedName}}),c(!1)}})})]})}const qTe=20,KTe=20;function ZTe({vertical:n,horizontal:e}){if(window.Intercom)try{const t={};t.vertical_padding=n,t.horizontal_padding=e,Object.keys(t).length>0&&window.Intercom("update",t)}catch(t){console.warn("Failed to update Intercom padding",t)}}function Ult(n=30,e=0){ZTe({vertical:KTe+n,horizontal:qTe+e})}function eZ(){ZTe({vertical:KTe,horizontal:qTe})}function YTe({isOpen:n,onClose:e,dataStorageType:t,onSubmit:i,configurationOnly:s=!1,existingConnector:r=null,mode:o="full",initialStep:a,preselectedConnector:l}){x.useEffect(()=>(n?Ult(55):eZ(),()=>{eZ()}),[n]);const[c,d]=x.useState(!1),[u,h]=x.useState(!1),g=x.useCallback(()=>{u?d(!0):e()},[u,e]),m=x.useCallback(()=>{d(!1),h(!1),e()},[e]),b=x.useCallback(v=>{h(v)},[]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g,children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:o==="fields-only"?"Connector Fields":r!=null&&r.source.name?"Edit Connector":"Set Up Connector"}),f.jsx(cC,{children:o==="fields-only"?"Select fields for your Data Mart":r!=null&&r.source.name?"Update configuration":"Follow these steps to set it up"})]}),f.jsx(zlt,{onSubmit:v=>{i(v),e()},dataStorageType:t,configurationOnly:s||o==="configuration-only",existingConnector:r,mode:o,initialStep:a,preselectedConnector:l,onDirtyChange:b})]})}),f.jsx(Ma,{open:c,onOpenChange:d,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:m,variant:"destructive"})]})}const kre=({dataStorageType:n,onSubmit:e,children:t,configurationOnly:i=!1,existingConnector:s=null,preset:r,isOpen:o,onClose:a})=>{const[l,c]=x.useState(!1),[d,u]=x.useState(1),[h,g]=x.useState();x.useEffect(()=>{o!==void 0&&c(o)},[o]);const m=()=>{g(void 0),u(1),c(!0)},b=()=>{c(!1),a==null||a()};return x.useEffect(()=>{r&&(r==="connector"?(g(void 0),u(1),c(!0)):(g(r),u(2),c(!0)))},[r]),f.jsxs(f.Fragment,{children:[t&&f.jsx("div",{onClick:m,style:{cursor:"pointer"},children:t}),f.jsx(HD,{children:f.jsx(YTe,{isOpen:l,onClose:b,dataStorageType:n,onSubmit:e,configurationOnly:i,existingConnector:s,initialStep:d,preselectedConnector:h})})]})};function $lt({storageType:n,onSetupConnector:e,preset:t,isOpen:i,onClose:s}){return f.jsx(kre,{dataStorageType:n,onSubmit:e,configurationOnly:!1,preset:t,isOpen:i,onClose:s,children:f.jsxs(rt,{type:"button",variant:"outline",className:"flex h-24 w-full cursor-pointer items-center justify-center gap-2 border-0 shadow-none dark:border-transparent dark:bg-transparent dark:hover:bg-white/4",children:[f.jsx("div",{className:"text-foreground flex h-7 w-7 items-center justify-center rounded-sm bg-gray-200/50 transition-colors duration-200 group-hover:bg-gray-200/75 dark:bg-white/8 dark:group-hover:bg-white/10",children:f.jsx(Fne,{className:"h-4 w-4",strokeWidth:2.25})}),f.jsx("span",{children:"Setup Connector"}),f.jsx($d,{className:"h-6 w-6"})]})})}const Glt=n=>{switch(n){case lt.GOOGLE_BIGQUERY:return"Google BigQuery";case lt.AWS_ATHENA:return"AWS Athena";case lt.SNOWFLAKE:return"Snowflake";default:return n}},kL=n=>typeof n=="object"&&"connector"in n,wT=n=>{if(!kL(n))return!1;const{source:e,storage:t}=n.connector,i=!!e.name&&!!e.configuration&&e.configuration.length>0&&!!e.node&&!!e.fields&&e.fields.length>0,s=t.fullyQualifiedName.split("."),r=s.length===2||s.length===3;return i&&r};function qlt({configIndex:n,connectorDef:e,onRemoveConfiguration:t,onUpdateConfiguration:i,totalConfigurations:s,dataStorage:r}){const o=fC.getInfo(r.type),{connectors:a,fetchAvailableConnectors:l}=US();x.useEffect(()=>{l()},[l]);const c=m=>{const b=a.find(v=>v.name===m);if(b!=null&&b.logoBase64)return()=>f.jsx(VS,{base64:b.logoBase64,size:24})},d=()=>{const m=e.connector.source.node||"No node selected";return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"text-muted-foreground/75",children:"Data:"})," ",f.jsx("span",{className:"text-muted-foreground font-medium",children:m}),f.jsx("span",{className:"text-muted-foreground",children:"•"}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("span",{className:"text-muted-foreground flex items-center gap-1 font-medium",children:[f.jsx("span",{children:"Edit config"}),f.jsx($d,{className:"h-3 w-3"})]})}),f.jsx(kn,{children:"Edit connector configuration"})]})]})},u=(m,b,v)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[m,":"]})," ",f.jsx(ir,{href:v,onClick:C=>{C.stopPropagation()},children:b})]}),h=()=>{switch(r.type){case lt.GOOGLE_BIGQUERY:{const m=r.config.projectId,b=e.connector.storage.fullyQualifiedName,v=b.split(".")[0],C=b.split(".")[1],y=`https://console.cloud.google.com/bigquery?project=${m}&ws=!1m4!1m3!3m2!1s${m}!2s${v}`,L=`https://console.cloud.google.com/bigquery?project=${m}&ws=!1m4!1m3!3m2!1s${m}!2s${v}!3s${C}`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Dataset",v,y),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",C,L),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The dataset and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case lt.AWS_ATHENA:{const m=r.config.region,b=e.connector.storage.fullyQualifiedName,[v,C]=b.split("."),y=`https://console.aws.amazon.com/athena/home?region=${m}#/query-editor`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Database",v,y),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",C,y),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The database and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case lt.SNOWFLAKE:{const m=r.config.account,v=e.connector.storage.fullyQualifiedName.split("."),C=v[0],y=v[1],L=v[2],E=`https://${m}.snowflakecomputing.com`,R=`${E}/#/data/databases/${C}`,T=`${E}/#/data/databases/${C}/schemas/${y}`,N=`${E}/#/data/databases/${C}/schemas/${y}/table/${L}`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Database",C,R),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Schema",jF(y),T),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",jF(L),N),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The database, schema and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}default:return"Unknown storage type configuration"}},g=()=>s!==1;return f.jsxs("div",{className:"border-border flex w-full items-center rounded-lg border-1 p-1 dark:bg-white/2",children:[f.jsx("div",{className:"flex-grow",children:f.jsxs("div",{className:"grid grid-cols-2 items-center gap-4",children:[f.jsx(kre,{dataStorageType:r.type,onSubmit:i(n),configurationOnly:!0,existingConnector:{source:{...e.connector.source,configuration:[e.connector.source.configuration[n]]},storage:e.connector.storage},children:f.jsx(GK,{icon:c(e.connector.source.name),title:e.connector.source.name||"Connector",subtitle:d(),className:"bg-background hover:bg-muted min-h-[80px] cursor-pointer border-0 transition-colors hover:shadow-none"})}),f.jsx(GK,{title:Glt(r.type),icon:o.icon,subtitle:h(),className:"bg-background min-h-[80px] cursor-default border-0 hover:shadow-none dark:bg-white/2"})]})}),f.jsx("div",{className:"shrink-0 px-4",children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{children:f.jsx(rt,{type:"button",variant:"ghost",onClick:()=>{g()&&t(n)},disabled:!g(),children:f.jsx(Wh,{className:"h-4 w-4"})})})}),!g()&&f.jsx(kn,{children:"Remove last configuration only after adding a new one."})]})})]})}function Klt({storageType:n,onAddConfiguration:e,existingConnector:t}){return f.jsx("div",{children:f.jsx(kre,{dataStorageType:n,onSubmit:i=>{const s=i.source.configuration[0]||{};e(s)},configurationOnly:!0,existingConnector:t?{source:{...t.source,configuration:[]},storage:t.storage}:void 0,children:f.jsxs(rt,{type:"button",variant:"outline",className:"dm-card-table-add-field-btn cursor-pointer",children:[f.jsx(Gd,{className:"h-4 w-4"}),f.jsx("span",{children:"Configuration"})]})})})}function Zlt({control:n,storageType:e,preset:t,autoOpen:i=!1,saveDataMartDefinition:s}){const{dataMart:r,runDataMart:o}=Zu(),{setValue:a,getValues:l,trigger:c}=VR(),[d,u]=x.useState(!1),[h,g]=x.useState(!1);x.useEffect(()=>{i&&g(!0)},[i]);const m=(r==null?void 0:r.status)??Ll.DRAFT,b=async W=>{a("definition",W,{shouldDirty:!0,shouldTouch:!0}),await c("definition")&&s&&s()},v=async W=>{const U=W.source,B=W.storage;await b({connector:{source:U,storage:B}})},C=async W=>{if(r){if(r.status.code!==Ll.PUBLISHED){Rn.error("Manual run is only available for published data marts");return}await o({id:r.id,payload:W})}},y=W=>async U=>{const K=l().definition;if(typeof K=="object"&&kL(K)){const X=[...K.connector.source.configuration];X[W]=U.source.configuration[0]||{};const ne={connector:{...K.connector,source:{...K.connector.source,configuration:X}}};await b(ne)}},L=async W=>{const B=l().definition;if(typeof B=="object"&&kL(B)){const K={connector:{...B.connector,source:{...B.connector.source,fields:W.source.fields}}};await b(K)}u(!1)},E=W=>{C({runType:W.runType,data:W.data})},R=W=>{const U=W.connector.source.fields.length;return f.jsxs(rt,{type:"button",variant:"outline",onClick:()=>{u(!0)},className:"dm-card-table-add-field-btn cursor-pointer",children:[f.jsx(VBe,{className:"h-4 w-4"}),f.jsxs("span",{children:["Edit Fields (",String(U),")"]})]})},[T,N]=x.useState(null),[I,M]=x.useState(!1),P=W=>{N(W),M(!0)},H=async()=>{T!==null&&(await j(T),N(null),M(!1))},j=async W=>{const B=l().definition;if(kL(B)&&B.connector.source.configuration.length<=1){const K=Ere(Yt.CONNECTOR);await b(K)}if(typeof B=="object"&&kL(B)&&B.connector.source.configuration.length>1){const K={...B.connector.source,configuration:B.connector.source.configuration.filter((ne,fe)=>fe!==W)},X={connector:{...B.connector,source:K}};await b(X)}},V=async W=>{const B=l().definition;if(kL(B)){const K={...B.connector.source,configuration:[...B.connector.source.configuration,W]},X={connector:{...B.connector,source:K}};await b(X)}};return f.jsxs(f.Fragment,{children:[f.jsx(fn,{control:n,name:"definition",render:({field:W})=>f.jsxs(tn,{className:"dark:bg-white/2",children:[f.jsx(cn,{children:f.jsx("div",{className:"space-y-3",children:!wT(W.value)||m===Ll.DRAFT?f.jsx($lt,{storageType:e,onSetupConnector:U=>{v(U),g(!1)},preset:t,isOpen:h,onClose:()=>{g(!1)}}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Klt,{storageType:e,onAddConfiguration:U=>void V(U),existingConnector:wT(W.value)?{source:W.value.connector.source,storage:W.value.connector.storage}:void 0}),wT(W.value)&&R(W.value)]}),f.jsx("div",{className:"flex items-center gap-2",children:r&&r.definitionType===Yt.CONNECTOR&&f.jsx(JNe,{configuration:r.definition,onManualRun:E,children:f.jsxs(rt,{variant:"outline",children:[f.jsx(rH,{className:"h-4 w-4"}),f.jsx("span",{children:"Manual Run..."})]})})})]}),f.jsx("div",{className:"space-y-3",children:wT(W.value)&&(r!=null&&r.storage)?W.value.connector.source.configuration.map((U,B)=>{const K=W.value;return f.jsx(HD,{children:f.jsx(qlt,{configIndex:B,connectorDef:K,dataStorage:r.storage,onRemoveConfiguration:X=>{P(X)},onUpdateConfiguration:X=>y(X),dataMartStatus:typeof m=="object"?m.code:m,totalConfigurations:K.connector.source.configuration.length},B)},B)}):null})]})})}),f.jsx(Cn,{})]})}),f.jsx(HD,{children:f.jsx(YTe,{isOpen:d,onClose:()=>{u(!1)},onSubmit:W=>void L(W),dataStorageType:e,existingConnector:wT(l().definition)?{source:l().definition.connector.source,storage:l().definition.connector.storage}:void 0,mode:"fields-only"})}),f.jsx(Ma,{open:I,onOpenChange:M,title:"Delete Configuration",description:"Are you sure you want to delete this configuration? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{H()},onCancel:()=>{N(null)},variant:"destructive"})]})}function Ylt({definitionType:n,storageType:e,preset:t,saveDataMartDefinition:i}){const{control:s}=VR(),[r,o]=x.useState(!1);return x.useEffect(()=>{n===Yt.CONNECTOR&&!t?o(!0):o(!1)},[n,t]),f.jsxs("div",{className:"space-y-2",children:[n===Yt.SQL&&f.jsx(Nat,{control:s}),n===Yt.TABLE&&f.jsx(Tat,{control:s,storageType:e}),n===Yt.VIEW&&f.jsx(Iat,{control:s,storageType:e}),n===Yt.TABLE_PATTERN&&f.jsx(kat,{control:s,storageType:e}),n===Yt.CONNECTOR&&f.jsx(Zlt,{control:s,storageType:e,preset:t,autoOpen:r,saveDataMartDefinition:i})]})}function XTe(){const[n]=Uje(),e=n.get("preset");return x.useMemo(()=>{if(!e)return;const t=e.toLowerCase();return Ntt(t)},[e])}function Xlt(n,e){const[t,i]=x.useState(n);return x.useEffect(()=>{const s=setTimeout(()=>{i(n)},e);return()=>{clearTimeout(s)}},[n,e]),t}const Qlt=1e3,Jlt=[Au.SUCCESS,Au.ERROR,Au.CANCELLED];function ect(n){const[e,t]=x.useState(!1),[i,s]=x.useState(null),r=x.useRef({triggerId:null,abortController:null}),o=x.useCallback(u=>r.current.triggerId===u,[]),a=x.useCallback(u=>{s({isValid:!1,error:u instanceof Error?u.message:"Validation failed"}),t(!1)},[]),l=x.useCallback(async()=>{const{triggerId:u,abortController:h}=r.current;if(u){h==null||h.abort(),r.current={triggerId:null,abortController:null},s(null),t(!1);try{await hr.abortSqlDryRunTrigger(n,u)}catch(g){console.error("Failed to cancel trigger:",g)}}},[n]),c=x.useCallback(async(u,h)=>{for(;!h.aborted&&o(u);)try{const g=await hr.getSqlDryRunTriggerStatus(n,u);if(Jlt.includes(g)){const m=await hr.getSqlDryRunTriggerResponse(n,u);s({isValid:m.isValid,error:m.error??void 0,bytes:m.bytes}),t(!1),r.current={triggerId:null,abortController:null};return}await new Promise(m=>setTimeout(m,Qlt))}catch(g){a(g),r.current={triggerId:null,abortController:null};return}},[n,o,a]),d=x.useCallback(async u=>{await l(),t(!0),s(null);try{const{triggerId:h}=await hr.createSqlDryRunTrigger(n,u),g=new AbortController;r.current={triggerId:h,abortController:g},await c(h,g.signal)}catch(h){a(h)}},[n,l,c,a]);return x.useEffect(()=>()=>{const{triggerId:u,abortController:h}=r.current;h==null||h.abort(),u&&hr.abortSqlDryRunTrigger(n,u).catch(()=>{})},[n]),{validateSql:d,isLoading:e,result:i,cancel:l}}const tct=300;function ict({sql:n,dataMartId:e,debounceDelay:t=tct,className:i="",onValidationStateChange:s}){const r=Xlt(n.trim(),t),{validateSql:o,isLoading:a,result:l,cancel:c}=ect(e);x.useEffect(()=>{if(!r){c();const u={isLoading:!1,isValid:null,error:null,bytes:null};s==null||s(u);return}o(r)},[r,o,c,s]),x.useEffect(()=>{const u={isLoading:a,isValid:(l==null?void 0:l.isValid)??null,error:(l==null?void 0:l.error)??null,bytes:(l==null?void 0:l.bytes)??null};s==null||s(u)},[a,l,s]);const d=()=>a?f.jsxs("div",{className:"flex h-5 items-center gap-2",children:[f.jsx(NR,{className:"h-4 w-4 animate-spin"}),f.jsx("span",{className:"text-sm",children:"Validating..."})]}):l?l.isValid?f.jsxs("div",{className:"flex h-5 items-center gap-2",children:[f.jsx(zHe,{className:"h-4 w-4 text-green-600"}),f.jsx("span",{className:"text-sm font-medium text-green-600",children:"Valid SQL code"}),l.bytes!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-1 text-gray-400",children:"•"}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(j1,{className:"h-3 w-3 text-gray-600"}),f.jsx("span",{className:"text-xs text-gray-600",children:yit(l.bytes)})]})}),f.jsx(kn,{children:f.jsx("p",{className:"text-xs",children:"This is an estimated volume and may differ from the actual value"})})]})]})]}):f.jsxs("div",{className:"flex h-9 items-center gap-2",children:[f.jsx(rF,{className:"h-4 w-4 flex-shrink-0 text-red-600"}),l.error&&f.jsx("span",{className:"text-xs text-red-500",children:l.error})]}):f.jsxs("div",{className:"flex h-5 items-center gap-2 text-gray-500",children:[f.jsx(j1,{className:"h-4 w-4"}),f.jsx("span",{className:"text-sm",children:"Type a query to get started"})]});return f.jsx("div",{className:`inline-flex h-9 items-center px-3 py-2 ${i}`,children:d()})}const nct={isValid:null,isLoading:!1,error:null},sct=(n,e)=>{if(n!==Yt.SQL)return"";const t=e;return(t==null?void 0:t.sqlQuery)??""},rct=n=>Ere(n);function oct({definitionType:n,initialDefinitionType:e,setDefinitionType:t}){const{dataMart:i,updateDataMartDefinition:s,runSchemaActualization:r}=Zu(),o=XTe();if(!i)throw new Error("Data mart not found");const{definition:a,id:l,storage:{type:c}}=i,[,d]=x.useState(nct),[u,h]=x.useState(!1),g=x.useCallback(()=>{if(!n)return;const V={definitionType:n,definition:Ere(n)};return a?{definitionType:n,definition:a}:V},[n,a]),m=x.useCallback(()=>{if(!n)return;const V=Rat(n,c);return pb(V)},[n,c]),b=Bp({resolver:m(),defaultValues:g(),mode:"onChange"}),{handleSubmit:v,reset:C,watch:y,formState:{isDirty:L,isValid:E}}=b,R=y("definition"),T=sct(n,R);x.useEffect(()=>{n&&C(g())},[n,C,g]),x.useEffect(()=>{if(!n&&!e&&(o!=null&&o.definitionType)){t(o.definitionType);const V={definitionType:o.definitionType,definition:rct(o.definitionType)};C(V)}},[o,n,e,C,t]);const N=x.useCallback(V=>{d({isLoading:V.isLoading,isValid:V.isValid,error:V.error})},[]),I=x.useCallback(V=>{t(V)},[t]),M=x.useCallback(async V=>{if(n&&l)try{await s(l,V.definitionType,V.definition),h(!0),C(V)}catch(W){console.error("Failed to update data mart definition:",W)}},[l,n,s,C]);x.useEffect(()=>{u&&(h(!1),r==null||r())},[u,r]);const P=x.useCallback(V=>{V==null||V.preventDefault(),v(M)(V)},[v,M]),H=x.useCallback(()=>{C(g())},[C,g]),j=()=>n?f.jsxs("form",{onSubmit:P,className:"space-y-4",children:[f.jsx(Ylt,{definitionType:n,storageType:c,preset:o==null?void 0:o.connectorSourceTitle,saveDataMartDefinition:P}),n!==Yt.CONNECTOR&&f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(rt,{variant:"default",type:"submit",disabled:!E||!L,children:"Save"}),f.jsx(rt,{type:"button",variant:"ghost",onClick:H,disabled:!L,children:"Discard"}),n===Yt.SQL&&T&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"h-6 w-px bg-gray-300"}),f.jsx(ict,{sql:T,dataMartId:l,onValidationStateChange:N})]})]})]}):null;return f.jsx(NRe,{...b,children:f.jsxs("div",{className:"space-y-4",children:[!e&&f.jsx(yat,{initialType:n,onTypeSelect:I}),j()]})})}function act(n){switch(n){case lt.GOOGLE_BIGQUERY:return{type:"bigquery-data-mart-schema",fields:[]};case lt.AWS_ATHENA:return{type:"athena-data-mart-schema",fields:[]};case lt.SNOWFLAKE:return{type:"snowflake-data-mart-schema",fields:[]};default:throw new Error(`Unsupported storage type: ${n}`)}}function QTe(n){return n.type==="bigquery-data-mart-schema"}function JTe(n){return n.type==="athena-data-mart-schema"}function eIe(n){return n.type==="snowflake-data-mart-schema"}function Vme(n){return n!==null&&typeof n=="object"&&"mode"in n}function Wme(n){return n!==null&&typeof n=="object"&&"isPrimaryKey"in n}function zme(n){return n!==null&&typeof n=="object"&&"isPrimaryKey"in n&&!("mode"in n)}function lct(n){return n==null?"":typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):""}function r$(n){return n==null?n:JSON.parse(JSON.stringify(n))}function cct(n){const e=r$(n),[t,i]=x.useState(e),[s,r]=x.useState(!1);x.useEffect(()=>{const l=r$(n);i(l),r(!1)},[n]);const o=x.useCallback(l=>{t?QTe(t)&&l.every(Vme)?(i({...t,fields:l}),r(!0)):JTe(t)&&l.every(Wme)?(i({...t,fields:l}),r(!0)):eIe(t)&&l.every(zme)&&(i({...t,fields:l}),r(!0)):l.length>0&&(Vme(l[0])?(i({type:"bigquery-data-mart-schema",fields:l}),r(!0)):Wme(l[0])?(i({type:"athena-data-mart-schema",fields:l}),r(!0)):zme(l[0])&&(i({type:"snowflake-data-mart-schema",fields:l}),r(!0)))},[t]),a=x.useCallback(()=>{const l=r$(n);i(l),r(!1)},[n]);return{schema:t,isDirty:s,updateSchema:o,resetSchema:a,setIsDirty:r}}function dct(n,e){const t=x.useRef(!1),i=x.useRef(!1),[s,r]=x.useState("idle");return x.useEffect(()=>{n||(t.current||i.current)&&(r(e?"error":"success"),t.current=!1,i.current=!1)},[n,e]),{operationStatus:s,startSaveOperation:()=>{t.current=!0,r("idle")},startActualizeOperation:()=>{i.current=!0,r("idle")},resetOperationStatus:()=>{r("idle")}}}function uct(n){const e=x.useMemo(()=>Array.isArray(n)?Object.fromEntries(n.filter(s=>s.meta&&s.meta.hidden).map(s=>["id"in s&&s.id?s.id:"accessorKey"in s&&typeof s.accessorKey=="string"?s.accessorKey:void 0,!1]).filter(([s])=>s!==void 0)):{},[n]),[t,i]=x.useState({});return x.useEffect(()=>{i(e)},[e]),{columnVisibility:t,setColumnVisibility:i,defaultHiddenColumns:e}}function tIe(n,e){const t=n.name?n.name.toLowerCase().includes(e):!1,i=n.alias?n.alias.toLowerCase().includes(e):!1,s=n.description?n.description.toLowerCase().includes(e):!1;if(t||i||s)return!0;const r=n;return r.fields&&r.fields.length>0?r.fields.some(o=>tIe(o,e)):!1}function iIe(n,e,t=""){const i=[];return n.forEach((s,r)=>{const o=t?`${t}.${String(r)}`:String(r),a=s.name?s.name.toLowerCase().includes(e):!1,l=s.alias?s.alias.toLowerCase().includes(e):!1,c=s.description?s.description.toLowerCase().includes(e):!1;if((a||l||c)&&i.push(o),s.fields&&s.fields.length>0){const d=iIe(s.fields,e,o);d.length>0&&(i.includes(o)||i.push(o),i.push(...d))}}),i}function hct(n,e,t){const i=n.original;if(!t)return!0;const s=t.toLowerCase();return tIe(i,s)}function fct(n){const[e,t]=x.useState(""),i=x.useCallback(r=>{t(r),n.setGlobalFilter(r)},[n]),s=e.toLowerCase();return{value:e,onChange:i,searchValue:s}}function gct(n){const[e,t]=x.useState(new Set),[i,s]=x.useState(null),r=x.useRef(""),o=x.useMemo(()=>{const m=b=>b.some(v=>v.type===Ho.RECORD||v.type===Ho.STRUCT||v.fields&&m(v.fields));return m(n)},[n]),a=x.useCallback(m=>{t(b=>{const v=new Set(b);return v.has(m)?v.delete(m):v.add(m),v})},[]),l=x.useCallback(()=>{const m=[],b=(v,C="")=>{v.forEach((y,L)=>{const E=C?`${C}.${String(L)}`:String(L);(y.type===Ho.RECORD||y.type===Ho.STRUCT)&&y.fields&&y.fields.length>0&&(m.push(E),b(y.fields,E))})};b(n),t(v=>m.every(y=>v.has(y))?new Set:new Set(m))},[n]),c=x.useMemo(()=>{const m=[],b=(v,C="",y=0)=>{v.forEach((L,E)=>{const R=C?`${C}.${String(E)}`:String(E),T=L.type===Ho.RECORD||L.type===Ho.STRUCT;m.push({...L,path:R,level:y}),T&&L.fields&&e.has(R)&&b(L.fields,R,y+1)})};return b(n),m},[n,e]),d=x.useCallback(m=>{if(m!==r.current)if(r.current=m,m){i===null&&s(new Set(e));const v=iIe(n,m).filter(C=>{const y=C.split(".").map(Number);let L=n,E;for(let R=0;R<y.length;R++){if(E=L[y[R]],!E)return!1;if((E.type===Ho.RECORD||E.type===Ho.STRUCT)&&E.fields&&E.fields.length>0)return!0;R<y.length-1&&(L=E.fields??[])}return!1});t(C=>{const y=new Set(C);return v.forEach(L=>{y.add(L)}),y})}else i!==null&&(t(i),s(null))},[n,e,i]),u=x.useCallback(m=>{const b=c[m];return b.type===Ho.RECORD||b.type===Ho.STRUCT},[c]),h=x.useMemo(()=>n.map(m=>({...m,fields:void 0})),[n]),g=x.useMemo(()=>{const m=[],b=(v,C="")=>{v.forEach((y,L)=>{const E=C?`${C}.${String(L)}`:String(L);(y.type===Ho.RECORD||y.type===Ho.STRUCT)&&y.fields&&y.fields.length>0&&(m.push(E),b(y.fields,E))})};return b(n),m.length===0?!1:m.every(v=>e.has(v))},[n,e]);return{expandedRecords:e,hasRecordFields:o,toggleRecordExpansion:a,toggleAllRecords:l,flattenedFields:c,handleSearchChange:d,isRecordType:u,topLevelFields:h,allExpanded:g}}function pct(n,e,t,i){const s=x.useCallback((l,c)=>{if(t){const d=[...n],u=e[l].path;if(!u)d[l]={...d[l],...c};else{const h=u.split(".").map(Number);let g=d,m;for(let v=0;v<h.length-1;v++)m=g[h[v]],g=m.fields??[];const b=h[h.length-1];g[b]&&(g[b]={...g[b],...c})}t(d)}},[n,e,t]),r=x.useCallback(()=>{if(t){const l={name:"",type:Ho.STRING,mode:d2.NULLABLE,isPrimaryKey:!1,status:Mu.DISCONNECTED};t([...n,l])}},[n,t]),o=x.useCallback(l=>{if(t){const c=[...n],d=e[l].path;if(!d)c.splice(l,1);else{const u=d.split(".").map(Number);let h=c,g;for(let b=0;b<u.length-1;b++)g=h[u[b]],h=g.fields??[];const m=u[u.length-1];h.splice(m,1)}t(c)}},[n,e,t]),a=x.useCallback(l=>{var c,d;if(t&&i){const u=[...n],h=e[l].path,g={name:"",type:Ho.STRING,mode:d2.NULLABLE,isPrimaryKey:!1,status:Mu.DISCONNECTED};if(!h)(c=u[l]).fields??(c.fields=[]),u[l].fields.push(g);else{const m=h.split(".").map(Number);let b=u;for(let v=0;v<m.length;v++){const C=m[v];v===m.length-1?((d=b[C]).fields??(d.fields=[]),b[C].fields.push(g)):b=b[C].fields??[]}}t(u)}},[n,e,t,i]);return{updateField:s,handleAddRow:r,handleDeleteRow:o,handleAddNestedField:a}}function Are(n,e,t){return{handleDragEnd:x.useCallback(s=>{const{active:r,over:o}=s;if(!o||r.id===o.id||!e)return;if(!t){const h=Number(r.id),g=Number(o.id),m=[...n],[b]=m.splice(h,1);m.splice(g,0,b),e(m);return}const a=t.findIndex((h,g)=>(h.path??String(g))===r.id),l=t.findIndex((h,g)=>(h.path??String(g))===o.id);if(a===-1||l===-1)return;const c=t[a].path,d=t[l].path,u=[...n];if(!c&&!d){const[h]=u.splice(a,1);u.splice(l,0,h),e(u);return}if(c&&d){const h=c.split(".").map(Number),g=d.split(".").map(Number);if(h.length===g.length&&h.slice(0,-1).join(".")===g.slice(0,-1).join(".")){let m=u;for(let y=0;y<h.length-1;y++)m=m[h[y]].fields??[];const b=h[h.length-1],v=g[g.length-1],[C]=m.splice(b,1);m.splice(v,0,C),e(u)}}},[n,t,e])}}function mct(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return x.useMemo(()=>i=>{e.forEach(s=>s(i))},e)}const sB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function UR(n){const e=Object.prototype.toString.call(n);return e==="[object Window]"||e==="[object global]"}function Mre(n){return"nodeType"in n}function qd(n){var e,t;return n?UR(n)?n:Mre(n)&&(e=(t=n.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function Ore(n){const{Document:e}=qd(n);return n instanceof e}function VM(n){return UR(n)?!1:n instanceof qd(n).HTMLElement}function nIe(n){return n instanceof qd(n).SVGElement}function $R(n){return n?UR(n)?n.document:Mre(n)?Ore(n)?n:VM(n)||nIe(n)?n.ownerDocument:document:document:document}const Sp=sB?x.useLayoutEffect:x.useEffect;function Pre(n){const e=x.useRef(n);return Sp(()=>{e.current=n}),x.useCallback(function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.current==null?void 0:e.current(...i)},[])}function _ct(){const n=x.useRef(null),e=x.useCallback((i,s)=>{n.current=setInterval(i,s)},[]),t=x.useCallback(()=>{n.current!==null&&(clearInterval(n.current),n.current=null)},[]);return[e,t]}function f2(n,e){e===void 0&&(e=[n]);const t=x.useRef(n);return Sp(()=>{t.current!==n&&(t.current=n)},e),t}function WM(n,e){const t=x.useRef();return x.useMemo(()=>{const i=n(t.current);return t.current=i,i},[...e])}function HF(n){const e=Pre(n),t=x.useRef(null),i=x.useCallback(s=>{s!==t.current&&(e==null||e(s,t.current)),t.current=s},[]);return[t,i]}function tZ(n){const e=x.useRef();return x.useEffect(()=>{e.current=n},[n]),e.current}let o$={};function zM(n,e){return x.useMemo(()=>{if(e)return e;const t=o$[n]==null?0:o$[n]+1;return o$[n]=t,n+"-"+t},[n,e])}function sIe(n){return function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return i.reduce((r,o)=>{const a=Object.entries(o);for(const[l,c]of a){const d=r[l];d!=null&&(r[l]=d+n*c)}return r},{...e})}}const FE=sIe(1),BF=sIe(-1);function bct(n){return"clientX"in n&&"clientY"in n}function Fre(n){if(!n)return!1;const{KeyboardEvent:e}=qd(n.target);return e&&n instanceof e}function vct(n){if(!n)return!1;const{TouchEvent:e}=qd(n.target);return e&&n instanceof e}function iZ(n){if(vct(n)){if(n.touches&&n.touches.length){const{clientX:e,clientY:t}=n.touches[0];return{x:e,y:t}}else if(n.changedTouches&&n.changedTouches.length){const{clientX:e,clientY:t}=n.changedTouches[0];return{x:e,y:t}}}return bct(n)?{x:n.clientX,y:n.clientY}:null}const g2=Object.freeze({Translate:{toString(n){if(!n)return;const{x:e,y:t}=n;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(n){if(!n)return;const{scaleX:e,scaleY:t}=n;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(n){if(n)return[g2.Translate.toString(n),g2.Scale.toString(n)].join(" ")}},Transition:{toString(n){let{property:e,duration:t,easing:i}=n;return e+" "+t+"ms "+i}}}),Ume="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Cct(n){return n.matches(Ume)?n:n.querySelector(Ume)}const wct={display:"none"};function yct(n){let{id:e,value:t}=n;return nt.createElement("div",{id:e,style:wct},t)}function Sct(n){let{id:e,announcement:t,ariaLiveType:i="assertive"}=n;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return nt.createElement("div",{id:e,style:s,role:"status","aria-live":i,"aria-atomic":!0},t)}function xct(){const[n,e]=x.useState("");return{announce:x.useCallback(i=>{i!=null&&e(i)},[]),announcement:n}}const rIe=x.createContext(null);function Lct(n){const e=x.useContext(rIe);x.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(n)},[n,e])}function Ect(){const[n]=x.useState(()=>new Set),e=x.useCallback(i=>(n.add(i),()=>n.delete(i)),[n]);return[x.useCallback(i=>{let{type:s,event:r}=i;n.forEach(o=>{var a;return(a=o[s])==null?void 0:a.call(o,r)})},[n]),e]}const Dct={draggable:`
|
|
734
|
+
`).filter(c=>c.trim());t(i,l)}})}function Hat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s,default:r}=n,o=n.title??n.name,a=l=>{if(!l||typeof l!="string"&&typeof l!="number")return"";const c=typeof l=="string"?l:l.toString();try{const d=new Date(c);return isNaN(d.getTime())?"":d.toISOString().split("T")[0]}catch{return""}};return f.jsx(vn,{id:i,name:i,type:"date",value:e[i]||a(r)||"",placeholder:s??`Enter ${o.toLowerCase()}`,onChange:l=>{t(i,l.target.value)}})}function Bat({specification:n,configuration:e,onValueChange:t}){const{name:i,placeholder:s}=n,r=n.title??n.name;return f.jsx(vn,{id:i,name:i,type:"text",value:e[i]||"",placeholder:s??`Enter ${r.toLowerCase()}`,onChange:o=>{t(i,o.target.value)}})}function Vat({specification:n,configuration:e,onValueChange:t}){const i=n.title??n.name,{name:s,placeholder:r,default:o}=n;return f.jsx(Hp,{id:s,name:s,value:e[s]&&typeof e[s]=="object"?JSON.stringify(e[s],null,2):typeof o=="object"?JSON.stringify(o,null,2):"",placeholder:r??`Enter ${i.toLowerCase()} as JSON`,rows:6,className:"font-mono",onChange:a=>{try{const l=JSON.parse(a.target.value);t(s,l)}catch{t(s,a.target.value)}}})}function Wat({specification:n,configuration:e,onValueChange:t,isEditingExisting:i,isSecretEditing:s}){const r=n.title??n.name,o=i&&!s;return f.jsx(vn,{id:n.name,...o?{}:{name:n.name},type:o?"password":"text",autoComplete:o?"new-password":"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:o?ZK:e[n.name]||"",...o?{readOnly:!0,disabled:!0}:{},...o?{}:{placeholder:n.placeholder??`Enter ${r.toLowerCase()}`},...o?{}:{onChange:a=>{t(n.name,a.target.value)}}})}function zat({specification:n,configuration:e,onValueChange:t,specOptions:i}){const{name:s,placeholder:r,default:o}=n,a=n.title??n.name,l=i.map(c=>({value:c,label:c}));return f.jsx(Lre,{options:l,value:e[s]||o||"",onValueChange:c=>{t(s,c)},placeholder:r??`Select ${a.toLowerCase()}`,emptyMessage:"No options available",className:"w-full"})}function Uat(){const n=x.useRef(new kI),e=x.useCallback(async(s,r,o)=>await n.current.exchangeCredentials(s,{fieldPath:o,payload:r}),[]),t=x.useCallback(async(s,r)=>{try{return await n.current.checkOAuthStatus(s,r)}catch{return{valid:!1}}},[]),i=x.useCallback(async(s,r)=>await n.current.getOAuthSettings(s,r),[]);return{exchangeCredentials:e,checkStatus:t,getSettings:i}}let vT=null;function $at({appId:n,scope:e,onSuccess:t,onError:i,disabled:s=!1,children:r}){const[o,a]=x.useState(!1),[l,c]=x.useState(!1),[d,u]=x.useState(null);x.useEffect(()=>{if(window.FB){c(!0);return}if(document.getElementById("facebook-jssdk")){const v=setInterval(()=>{window.FB&&(c(!0),clearInterval(v))},100);return()=>{clearInterval(v)}}if(!n)return;if(vT&&vT!==n){console.warn("Facebook SDK already initialized with different appId");return}vT??(vT=n),window.fbAsyncInit=function(){window.FB&&vT&&(window.FB.init({appId:vT,cookie:!0,xfbml:!0,version:"v23.0"}),c(!0))};const b=document.createElement("script");b.id="facebook-jssdk",b.src="https://connect.facebook.net/en_US/sdk.js",b.async=!0,b.defer=!0,b.crossOrigin="anonymous",document.body.appendChild(b)},[n]);const h=()=>{if(!window.FB||!l){const b=new Error("Facebook SDK not loaded or not ready");u(b.message),i==null||i(b);return}a(!0),u(null),window.FB.login(b=>{var v;if(b.status==="connected"&&b.authResponse){const{accessToken:C,expiresIn:y,userID:L}=b.authResponse;(v=window.FB)==null||v.api("/me?fields=name,email",E=>{const R={accessToken:C,expiresIn:y,userID:L,userName:E.name,userEmail:E.email};t(R),a(!1)})}else{const C=new Error("User cancelled login or did not fully authorize");u(C.message),i==null||i(C),a(!1)}},{scope:e})},g=s||o||!l,m=()=>o?"Connecting...":r||(l?"Continue with Facebook":"Loading...");return f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs(rt,{type:"button",onClick:h,disabled:g,className:"flex items-center justify-center gap-2 rounded-md border-none bg-[#1877F2] px-4 py-2.5 text-sm font-semibold text-white hover:bg-[#166FE5] disabled:cursor-not-allowed disabled:opacity-60",children:[f.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:f.jsx("path",{d:"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z"})}),m()]}),d&&f.jsx("div",{className:"mt-1 text-xs text-red-600",children:d})]})}function Gat({isLoading:n,status:e,settings:t,onOAuthSuccess:i}){const s=r=>{i({accessToken:r.accessToken})};return f.jsx("div",{className:"mt-2 mb-2",children:f.jsx($at,{appId:t==null?void 0:t.vars.AppId,scope:t==null?void 0:t.vars.Scopes,onSuccess:s,disabled:n,children:e!=null&&e.user?f.jsxs(f.Fragment,{children:["Authenticated as ",f.jsx("strong",{children:e.user.name??e.user.id})]}):"Continue with Facebook"})})}function ATe({specification:n,option:e,configuration:t,onValueChange:i,connectorName:s,onSecretEditToggle:r,secretEditing:o={},isEditingExisting:a=!1}){const[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,g]=x.useState(null),[m,b]=x.useState(null),v=x.useMemo(()=>{const V=t[n.name],W=e!=null&&e.value&&V?V[e.value]:V;return W==null?void 0:W._source_credential_id},[t,n.name,e==null?void 0:e.value]),C=x.useMemo(()=>e?`${n.name}.${e.value}`:n.name,[n.name,e]),y=x.useMemo(()=>{const V=t[n.name];if(e!=null&&e.value&&V){const W=V[e.value];return W&&typeof W=="object"&&!Array.isArray(W)?W:{}}return V&&typeof V=="object"&&!Array.isArray(V)?V:{}},[t,n.name,e==null?void 0:e.value]),L=x.useMemo(()=>{const V=y;return"_source_credential_id"in V?!1:!!(e!=null&&e.items&&Object.keys(e.items).some(U=>U in V&&V[U]!==void 0&&V[U]!==""))},[y,e]),[E,R]=x.useState(L);x.useEffect(()=>{const V="_source_credential_id"in y,W=(e==null?void 0:e.items)&&Object.keys(e.items).some(U=>U in y&&y[U]!==void 0&&y[U]!=="");V&&E?R(!1):W&&!E&&R(!0)},[y,e,E]);const T=(V,W)=>{if(!(e!=null&&e.value))return;const U=t[n.name]&&typeof t[n.name]=="object"?t[n.name]:{};i(n.name,{...U,[e.value]:{...typeof U[e.value]=="object"&&U[e.value]!==null?U[e.value]:{},[V]:W}})},{checkStatus:N,getSettings:I,exchangeCredentials:M}=Uat(),P=async V=>{try{c(!0),b(null);const W=await M(s,V,C),U=t[n.name];e?i(n.name,{...U,[e.value]:{_source_credential_id:W.credentialId}}):i(n.name,{_source_credential_id:W.credentialId})}catch(W){const U=W instanceof Error?W.message:"Failed to exchange OAuth credentials";console.error("Failed to exchange OAuth credentials:",W),b(U)}finally{c(!1)}};x.useEffect(()=>{if(!v){u(null),c(!1);return}let V=!1;return(async()=>{try{c(!0);const U=await N(s,v);V||u(U)}catch(U){V||(console.error("Failed to validate credentials:",U),u({valid:!1}))}finally{V||c(!1)}})(),()=>{V=!0}},[v,s,N]),x.useEffect(()=>{(async()=>{try{const W=await I(s,C);g(W)}catch(W){console.error("Failed to fetch settings:",W),g(null)}})()},[s,C,I]);const H=!!(h!=null&&h.isEnabled);if((E||!H)&&(e!=null&&e.items))return f.jsxs("div",{className:"space-y-4",children:[Object.entries(e.items).map(([V,W])=>{const U=Array.isArray(W.attributes)?W.attributes.includes("SECRET")&&y[V]!==void 0:!1,B=o[n.name]??!1;return f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:V,required:W.required,tooltip:W.description,className:"mb-2 justify-start",children:W.title??V}),U&&a&&r&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{r(n.name,!B)},children:B?"Cancel":"Edit"})]}),Nre({specification:{...W,name:V},configuration:y,onValueChange:(K,X)=>{T(K,X)},flags:{isEditingExisting:a,isSecret:U,isSecretEditing:B},connectorName:s})]},V)}),H&&f.jsx(rt,{variant:"link",size:"sm",type:"button",onClick:()=>{i(n.name,{[e.value]:{}}),R(!1),c(!1)},className:"px-0",children:"Back to OAuth"})]});const j=(()=>{switch(s){case"FacebookMarketing":return f.jsx(Gat,{isLoading:l,status:d,settings:h,onOAuthSuccess:P});default:return null}})();return f.jsxs("div",{className:"space-y-3",children:[j,m&&f.jsx("div",{className:"text-destructive text-sm",children:m}),(e==null?void 0:e.items)&&Object.keys(e.items).length>0&&f.jsx(rt,{variant:"link",size:"sm",type:"button",onClick:()=>{i(n.name,{[e.value]:{}}),R(!0)},className:"px-0",children:"Manually"})]})}function Nre({specification:n,configuration:e,onValueChange:t,flags:i,connectorName:s}){const{requiredType:r,options:o}=n,{isSecret:a=!1,isEditingExisting:l=!1,isSecretEditing:c=!1}=i??{};if(n.attributes&&Array.isArray(n.attributes)&&n.attributes.includes("OAUTH_FLOW"))return f.jsx(ATe,{specification:n,configuration:e,onValueChange:t,connectorName:s});if(a)return f.jsx(Wat,{specification:n,configuration:e,onValueChange:t,isEditingExisting:l,isSecretEditing:c});if(o&&o.length>0)return f.jsx(zat,{specification:n,configuration:e,onValueChange:t,specOptions:o});switch(r){case mf.BOOLEAN:return f.jsx(Pat,{specification:n,configuration:e,onValueChange:t});case mf.NUMBER:return f.jsx(Fat,{specification:n,configuration:e,onValueChange:t});case mf.ARRAY:return f.jsx(jat,{specification:n,configuration:e,onValueChange:t});case mf.OBJECT:return f.jsx(Vat,{specification:n,configuration:e,onValueChange:t});case mf.DATE:return f.jsx(Hat,{specification:n,configuration:e,onValueChange:t});case mf.STRING:default:return f.jsx(Bat,{specification:n,configuration:e,onValueChange:t})}}function qat({specification:n,configuration:e,isEditingExisting:t,isSecretEditing:i,isSecret:s,onValueChange:r,onSecretEditToggle:o,connectorName:a}){return f.jsxs(iv,{children:[n.requiredType!==mf.BOOLEAN&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:n.name,required:n.required,tooltip:n.description,children:n.title??n.name}),s&&t&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{o(n.name,!i)},children:i?"Cancel":"Edit"})]}),Nre({specification:n,configuration:e,onValueChange:r,flags:{isSecret:s,isEditingExisting:t,isSecretEditing:i},connectorName:a})]},n.name)}function Kat({specification:n,configuration:e,onValueChange:t,isEditingExisting:i,isSecretEditing:s,onSecretEditToggle:r,connectorName:o}){const a=x.useMemo(()=>{var g,m;const h=e[n.name];if(h&&typeof h=="object"){const b=Object.keys(h);if(b.length>0)return b[0]}return((m=(g=n.oneOf)==null?void 0:g[0])==null?void 0:m.value)??""},[e,n.name,n.oneOf]),[l,c]=x.useState(a);if(x.useEffect(()=>{c(a)},[a]),x.useEffect(()=>{if(l){const h=e[n.name];h&&typeof h=="object"&&l in h||t(n.name,{[l]:{}})}},[l,n.name]),!n.oneOf)return null;const d=h=>{c(h)},u=(h,g,m)=>{const b=e[n.name]&&typeof e[n.name]=="object"?e[n.name]:{};t(n.name,{[h]:{...typeof b[h]=="object"&&b[h]!==null?b[h]:{},[g]:m}})};return f.jsx(xst,{label:n.title??n.name,options:n.oneOf.map(h=>({value:h.value,label:h.label})),value:l,onValueChange:d,children:n.oneOf.map(h=>{const g=h.attributes&&Array.isArray(h.attributes)&&h.attributes.includes("OAUTH_FLOW");return f.jsx(hst,{value:h.value,children:g?f.jsx(ATe,{specification:n,option:h,configuration:e,onValueChange:t,connectorName:o,onSecretEditToggle:r,secretEditing:{[n.name]:s},isEditingExisting:i}):Object.entries(h.items).map(([m,b])=>{const v=e[n.name]&&typeof e[n.name]=="object"?e[n.name]:{},C=Array.isArray(b.attributes)&&Object.keys(v)[0]===h.value?b.attributes.includes("SECRET"):!1,y=typeof e[n.name]=="object"&&e[n.name]!==null?e[n.name]:{},L=typeof y[h.value]=="object"&&y[h.value]!==null?y[h.value]:{};return f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(_u,{htmlFor:m,required:b.required,tooltip:b.description,className:"mb-2 justify-start",children:m}),C&&i&&f.jsx(rt,{variant:"ghost",size:"sm",type:"button",onClick:()=>{r(n.name,!s)},children:s?"Cancel":"Edit"})]}),Nre({specification:{...b,name:m},configuration:L,onValueChange:(E,R)=>{u(h.value,E,R)},flags:{isEditingExisting:i,isSecret:C,isSecretEditing:s},connectorName:o})]},m)})},h.value)})},n.name)}function Pme(n,e,t,i,s,r,o){return n.map(a=>{const l=Array.isArray(a.attributes)?a.attributes.includes("SECRET"):!1,c=s[a.name];return a.oneOf&&a.requiredType===mf.OBJECT?f.jsx(Kat,{specification:a,configuration:e,onValueChange:t,isEditingExisting:r,isSecretEditing:c,onSecretEditToggle:i,connectorName:o},a.name):f.jsx(qat,{specification:a,configuration:e,isEditingExisting:r,isSecret:l,isSecretEditing:c,onValueChange:t,onSecretEditToggle:i,connectorName:o},a.name)})}function Fme({collapsibleTitle:n,items:e,configuration:t,onValueChange:i,onSecretEditToggle:s,secretEditing:r,isEditingExisting:o,connectorName:a}){return n?f.jsx(HNe,{title:n,children:Pme(e,t,i,s,r,o,a)}):Pme(e,t,i,s,r,o,a)}function Zat({currentConnectorName:n,onCopyConfiguration:e,connectorSpecification:t}){const[i,s]=x.useState([]),[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(async()=>{o(!0);try{const h=await hr.getDataMartsByConnectorName(n);s(h)}catch{s([])}finally{o(!1)}},[n]);x.useEffect(()=>{a&&c()},[a,c]);const d=(h,g)=>{const m=g._id;if(!m){console.error("Configuration does not have _id field");return}e({dataMartId:h.id,dataMartTitle:h.title,configId:m,configuration:g}),l(!1)},u=h=>{const m=[],b=C=>{if(!t)return!0;const y=t.find(L=>L.name===C);return(y==null?void 0:y.required)??!1},v=(C,y,L=0,E=!0)=>{if(C.startsWith("_")||E&&L===0&&!b(C))return;let R=null;if(y==null)R="N/A";else if(typeof y=="string")R=y;else if(typeof y=="number"||typeof y=="boolean")R=String(y);else if(Array.isArray(y))R=JSON.stringify(y);else if(typeof y=="object"){m.push({key:C,value:"{",indent:L}),Object.entries(y).forEach(([T,N])=>{v(T,N,L+1,!1)}),m.push({key:"",value:"}",indent:L});return}else R=JSON.stringify(y);m.push({key:C,value:R,indent:L})};for(const[C,y]of Object.entries(h))v(C,y);return f.jsx("div",{className:"space-y-1 font-mono text-xs",children:m.map(({key:C,value:y,indent:L},E)=>f.jsxs("div",{className:"flex gap-2",style:{paddingLeft:`${String(L*12)}px`},children:[C&&f.jsxs("span",{className:"font-medium",children:[C,":"]}),f.jsx("span",{className:"text-muted-foreground truncate",title:y,children:y})]},E))})};return f.jsx(Nf,{children:f.jsxs(Al,{open:a,onOpenChange:l,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{type:"button",variant:"ghost",size:"sm",className:"cursor-pointer",children:[f.jsx("span",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Copy from…"}),f.jsx($d,{className:Le("text-foreground/75 h-3.5 w-3.5 transition-transform duration-200",a&&"rotate-90")})]})}),f.jsx(Ol,{side:"bottom",align:"end",className:"w-72",children:r?f.jsx(wn,{disabled:!0,children:"Loading…"}):i.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-4 text-center",children:[f.jsx("div",{className:"bg-muted/70 rounded-full p-3",children:f.jsx(HBe,{className:"text-muted-foreground h-6 w-6",strokeWidth:1.5})}),f.jsx("span",{className:"text-foreground text-sm font-medium",children:"No matching Data Marts"}),f.jsx("span",{className:"text-muted-foreground text-sm",children:"You can reuse configuration settings only from connector-based Data Marts that use the same source."})]}):f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsx("div",{className:"text-muted-foreground border-b p-2 text-sm",children:"Select one of your existing Data Marts to reuse its configuration settings."}),f.jsx("div",{children:i.map(h=>{const m=h.definition.connector.source.configuration;return m.length===0?null:m.length===1?f.jsxs(Tn,{delayDuration:300,children:[f.jsx(In,{asChild:!0,children:f.jsxs(wn,{onSelect:()=>{d(h,m[0])},children:[f.jsx(sF,{className:"text-foreground h-4 w-4"}),h.title]})}),f.jsx(kn,{side:"right",className:"max-w-sm",children:u(m[0])})]},h.id):f.jsxs(dse,{children:[f.jsxs(use,{className:"flex items-center gap-2",children:[f.jsx(sF,{className:"text-foreground h-4 w-4"}),f.jsx("span",{children:h.title})]}),f.jsx(hse,{children:m.map((b,v)=>f.jsxs(Tn,{delayDuration:300,children:[f.jsx(In,{asChild:!0,children:f.jsxs(wn,{onSelect:()=>{d(h,b)},children:["Configuration ",v+1]})}),f.jsx(kn,{side:"right",className:"max-w-sm",children:u(b)})]},v))})]},h.id)})})]})})]})})}function jme({connector:n,connectorSpecification:e,onConfigurationChange:t,onValidationChange:i,initialConfiguration:s,loading:r=!1,isEditingExisting:o=!1}){const[a,l]=x.useState({}),c=x.useRef(!1),d=x.useRef(!1),[u,h]=x.useState({});x.useEffect(()=>{if(e){d.current=!0;const T={...s??{}};e.forEach(N=>{const I=Array.isArray(N.attributes)?N.attributes.includes("SECRET"):!1;T[N.name]===void 0&&N.default!==void 0&&(T[N.name]=N.default),o&&I&&(T[N.name]=ZK)}),l(T),c.current=!0,setTimeout(()=>{d.current=!1},0)}},[e,s,o]),x.useEffect(()=>{c.current&&s&&Object.keys(s).length>0&&(d.current=!0,l({...s}),setTimeout(()=>{d.current=!1},0))},[s]),x.useEffect(()=>{c.current&&!d.current&&Object.keys(a).length>0&&(t==null||t(a))},[a,t]);const g=(T,N)=>{l(I=>({...I,[T]:N}))},m=x.useCallback(T=>!(T==null||typeof T=="string"&&T.trim()===""||typeof T=="number"&&isNaN(T)||Array.isArray(T)&&T.length===0),[]),b=x.useCallback((T,N)=>{var M,P;if(typeof T!="object"||T===null)return m(T);if((M=N.attributes)!=null&&M.includes("OAUTH_FLOW")&&"_source_credential_id"in T)return!0;const I=(P=N.oneOf)==null?void 0:P.filter(H=>H.value===Object.keys(T)[0]);return I?I.every(H=>{var j;if((j=H.attributes)!=null&&j.includes("OAUTH_FLOW")){const V=T[H.value];if(typeof V=="object"&&V!==null){if("_source_credential_id"in V)return!0;const W=Object.entries(H.items).filter(([,U])=>U.required);if(W.length>0)return W.every(([U])=>{const B=V[U];return m(B)})}return!1}return Object.entries(H.items).every(([,V])=>H.value in T?b(T[H.value],V):!1)}):m(T[N.name])},[m]),v=x.useCallback((T,N)=>{const I=N.filter(j=>j.required&&j.oneOf),M=I.length===0?!0:I.some(j=>b(T[j.name],j)),H=N.filter(j=>j.required&&j.name!=="Fields").every(j=>m(T[j.name]));return M&&H},[m,b]),C=(T,N)=>{h(I=>({...I,[T]:N})),l(N?I=>({...I,[T]:""}):I=>({...I,[T]:ZK}))},y=T=>{const N={...a};Object.entries(T.configuration).forEach(([I,M])=>{["_id","_copiedFrom"].includes(I)||(N[I]=M)}),N._copiedFrom={dataMartId:T.dataMartId,dataMartTitle:T.dataMartTitle,configId:T.configId},l(N)};if(x.useEffect(()=>{if(e&&i){const T=v(a,e);i(T)}},[a,e,i,v]),r)return f.jsx(fre,{variant:"list"});if(!e||e.length===0)return f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No configuration found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need configuration?"})]});const L=[...e].filter(T=>{var N;return T.name!=="Fields"&&!((N=T.attributes)!=null&&N.includes("HIDE_IN_CONFIG_FORM"))}).sort((T,N)=>{const I=M=>{const P=M.default!=null&&M.default!=="";return M.required&&!P?1:M.required&&P?2:!M.required&&!P?3:4};return I(T)-I(N)}),E=L.filter(T=>{var N;return!((N=T.attributes)!=null&&N.includes("ADVANCED"))}),R=L.filter(T=>{var N;return(N=T.attributes)==null?void 0:N.includes("ADVANCED")});return f.jsx(f.Fragment,{children:f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsxs(Hv,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Configure Settings"}),f.jsx(Zat,{currentConnectorName:n.name,onCopyConfiguration:y,connectorSpecification:e})]}),E.length>0&&f.jsx(Fme,{items:E,configuration:a,onValueChange:g,onSecretEditToggle:C,secretEditing:u,isEditingExisting:o,connectorName:n.name}),R.length>0&&f.jsx(Fme,{collapsibleTitle:"Advanced Settings",items:R,configuration:a,onValueChange:g,onSecretEditToggle:C,secretEditing:u,isEditingExisting:o,connectorName:n.name})]})]})})}function Yat({connector:n,connectorFields:e,selectedField:t,connectorName:i,loading:s=!1,onFieldSelect:r}){const o=i?`Select data for ${i}`:"Select data";return s?f.jsx(fre,{variant:"list"}):!e||e.length===0?f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:i?`No nodes found for ${i}`:"No nodes found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Missing some data?"})]}):f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsxs(Hv,{title:o,children:[e.map(a=>f.jsx(BNe,{type:"radio",id:a.name,name:"selectedField",value:a.name,label:a.overview??a.name,checked:t===a.name,onChange:l=>{r(l)},tooltip:a.name&&f.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Table name:"})," ",a.destinationName??a.name]}),a.description&&f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Description:"})," ",a.description]}),a.documentation&&f.jsxs(Vc,{to:a.documentation,target:"_blank",rel:"noopener noreferrer",className:"bg-muted/16 hover:bg-muted/20 dark:bg-muted/8 dark:hover:bg-muted/16 flex items-center justify-center gap-1 rounded-sm px-2 py-1 font-semibold",children:["Read more",f.jsx($d,{className:"h-3 w-3"})]})]}),selected:t===a.name},a.name)),f.jsx(PE,{label:"Missing some data?"})]})]})}var Sg=(n=>(n.ASC="asc",n.DESC="desc",n.ORIGINAL="original",n))(Sg||{});function Hme({connector:n,connectorFields:e,selectedField:t,selectedFields:i,onFieldToggle:s}){const r=x.useRef(null),[o,a]=x.useState(""),[l,c]=x.useState(Sg.ORIGINAL),d=e==null?void 0:e.find(C=>C.name===t),u=x.useMemo(()=>(d==null?void 0:d.fields)??[],[d==null?void 0:d.fields]),h=x.useMemo(()=>(d==null?void 0:d.uniqueKeys)??[],[d==null?void 0:d.uniqueKeys]),g=x.useMemo(()=>{const C=new Map;return u.forEach((y,L)=>C.set(y.name,L)),C},[u]),m=x.useMemo(()=>{const C=u.filter(L=>L.name.toLowerCase().includes(o.toLowerCase().trim())),y=(L,E)=>{const R=h.includes(L.name),T=h.includes(E.name);if(R&&!T)return-1;if(!R&&T)return 1;if(l===Sg.ASC)return L.name.localeCompare(E.name);if(l===Sg.DESC)return E.name.localeCompare(L.name);const N=g.get(L.name)??0,I=g.get(E.name)??0;return N-I};return[...C].sort(y)},[u,o,h,l,g]),b=u.map(C=>C.name),v=i.filter(C=>b.includes(C)).length;return x.useEffect(()=>{if(h.length>0){const C=h.filter(y=>u.some(L=>L.name===y)&&!i.includes(y));C.length>0&&C.forEach(y=>{s(y,!0)})}},[t,h,u,i,s]),x.useEffect(()=>{const C=y=>{const E=(y.ctrlKey||y.metaKey)&&y.shiftKey&&y.key.toLowerCase()==="a",R=document.activeElement.tagName;if(!(R==="INPUT"||R==="TEXTAREA")&&E){y.preventDefault();const T=u.map(M=>M.name),I=T.filter(M=>!i.includes(M)).length>0;T.forEach(M=>{s(M,I)})}};return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[u,i,s]),!t||!e?f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need fields?"})]}):u.length?f.jsx(L_,{children:f.jsxs(f.Fragment,{children:[f.jsx(Ey,{connector:n}),f.jsxs("div",{className:"border-border -mt-6 mb-6 flex w-full items-center gap-2 border-b",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(FS,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 cursor-text",onClick:()=>{var C;(C=r.current)==null||C.focus()}}),f.jsx("input",{ref:r,type:"text",placeholder:"Search field",value:o,onChange:C=>{a(C.target.value)},className:"h-12 w-full rounded-none border-0 pl-9 text-sm outline-none"}),o&&f.jsx("button",{type:"button",onClick:()=>{a("")},className:"text-muted-foreground hover:text-foreground absolute top-1/2 right-0 -translate-y-1/2",children:f.jsx(ID,{className:"h-4 w-4"})})]}),f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",size:"icon","aria-label":"Sort fields",children:[l===Sg.ASC&&f.jsx(Hge,{className:"text-muted-foreground h-4 w-4"}),l===Sg.DESC&&f.jsx(jge,{className:"text-muted-foreground h-4 w-4"}),l===Sg.ORIGINAL&&f.jsx(Bge,{className:"text-muted-foreground h-4 w-4"})]})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onSelect:()=>{c(Sg.ASC)},children:[f.jsx(Hge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"A–Z"]}),f.jsxs(wn,{onSelect:()=>{c(Sg.DESC)},children:[f.jsx(jge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Z–A"]}),f.jsxs(wn,{onSelect:()=>{c(Sg.ORIGINAL)},children:[f.jsx(Bge,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Original"]})]})]})]}),f.jsxs(Hv,{title:`Selected ${String(v)} of ${String(b.length)} fields for "${t}" data`,children:[m.map(C=>{const y=h.includes(C.name);return f.jsx(BNe,{type:"checkbox",id:`field-${C.name}`,name:"selectedFields",value:C.name,checked:i.includes(C.name),selected:i.includes(C.name)||y,disabled:y,onChange:L=>{s(C.name,L)},label:C.name,tooltip:f.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[y&&f.jsxs("p",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-semibold",children:"Unique key"})," ",f.jsx(nK,{className:"text-secondary h-3 w-3"})]}),f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Type:"})," ",C.type]}),C.description&&f.jsxs("p",{children:[f.jsx("span",{className:"font-semibold",children:"Description:"})," ",C.description]})]}),rightIcon:y?f.jsx(nK,{className:"text-muted-foreground/75 h-4 w-4"}):void 0},C.name)}),m.length===0&&o&&f.jsxs("div",{className:"text-muted-foreground pt-8 pb-4 text-center text-sm",children:['No fields match "',o,'"']}),f.jsx(PE,{label:"Need another field?"})]})]})}):f.jsxs(L_,{children:[f.jsx(Ey,{connector:n}),f.jsx(x_,{icon:f.jsx(i2,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),f.jsx(PE,{label:"Need fields?"})]})}const MTe=x.createContext(void 0),OTe={triggers:[],selectedTrigger:null,isLoading:!1,error:null};function Xat(n,e){switch(e.type){case"FETCH_TRIGGERS_START":case"FETCH_TRIGGER_START":case"CREATE_TRIGGER_START":case"UPDATE_TRIGGER_START":case"DELETE_TRIGGER_START":return{...n,isLoading:!0,error:null};case"FETCH_TRIGGERS_SUCCESS":return{...n,triggers:e.payload,isLoading:!1};case"FETCH_TRIGGER_SUCCESS":return{...n,selectedTrigger:e.payload,isLoading:!1};case"CREATE_TRIGGER_SUCCESS":return{...n,triggers:[...n.triggers,e.payload],isLoading:!1};case"UPDATE_TRIGGER_SUCCESS":return{...n,triggers:n.triggers.map(t=>t.id===e.payload.id?e.payload:t),selectedTrigger:n.selectedTrigger&&n.selectedTrigger.id===e.payload.id?e.payload:n.selectedTrigger,isLoading:!1};case"DELETE_TRIGGER_SUCCESS":return{...n,triggers:n.triggers.filter(t=>t.id!==e.payload),selectedTrigger:n.selectedTrigger&&n.selectedTrigger.id===e.payload?null:n.selectedTrigger,isLoading:!1};case"FETCH_TRIGGERS_ERROR":case"FETCH_TRIGGER_ERROR":case"CREATE_TRIGGER_ERROR":case"UPDATE_TRIGGER_ERROR":case"DELETE_TRIGGER_ERROR":return{...n,isLoading:!1,error:e.payload};case"SELECT_TRIGGER":return{...n,selectedTrigger:e.payload};case"RESET":return OTe;default:return n}}class Qat extends hC{constructor(){super("/data-marts")}async getScheduledTriggers(e){return this.get(`/${e}/scheduled-triggers`)}async getScheduledTrigger(e,t){return this.get(`/${e}/scheduled-triggers/${t}`)}async createScheduledTrigger(e,t){return this.post(`/${e}/scheduled-triggers`,t)}async updateScheduledTrigger(e,t,i){return this.put(`/${e}/scheduled-triggers/${t}`,i)}async deleteScheduledTrigger(e,t){return this.delete(`/${e}/scheduled-triggers/${t}`)}}const Jx=new Qat;var ho=(n=>(n.REPORT_RUN="REPORT_RUN",n.CONNECTOR_RUN="CONNECTOR_RUN",n))(ho||{});const UL={SCHEDULED_REPORT_RUN:"scheduled-report-run-config"};class YK{mapFromDto(e){return{id:e.id,type:e.type,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,nextRun:e.nextRunTimestamp?new Date(e.nextRunTimestamp):null,lastRun:e.lastRunTimestamp?new Date(e.lastRunTimestamp):null,triggerConfig:e.triggerConfig,createdById:e.createdById,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt)}}async enhanceWithReportData(e){if(e.type!==ho.REPORT_RUN)return e;const t=e.triggerConfig;if(!t.reportId)return e;try{const i=await Om.getReportById(t.reportId),s=mw(i);return{...e,triggerConfig:{...t,report:s}}}catch(i){return console.error(`Failed to fetch report data for trigger ${e.id}:`,i),e}}async enhanceTriggersWithReportData(e){return Promise.all(e.map(t=>this.enhanceWithReportData(t)))}mapToCreateRequest(e){return{type:ho.REPORT_RUN,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,triggerConfig:e.triggerConfig}}mapToUpdateRequest(e){return{cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive}}}class Jat{mapFromDto(e){return{id:e.id,type:e.type,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,nextRun:e.nextRunTimestamp?new Date(e.nextRunTimestamp):null,lastRun:e.lastRunTimestamp?new Date(e.lastRunTimestamp):null,triggerConfig:e.triggerConfig,createdById:e.createdById,createdAt:new Date(e.createdAt),modifiedAt:new Date(e.modifiedAt)}}mapToCreateRequest(e){return{type:ho.CONNECTOR_RUN,cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive,triggerConfig:e.triggerConfig}}mapToUpdateRequest(e){return{cronExpression:e.cronExpression,timeZone:e.timeZone,isActive:e.isActive}}}const s$={getMapper(n){switch(n){case ho.REPORT_RUN:return new YK;case ho.CONNECTOR_RUN:return new Jat;default:throw new Error(`Unknown scheduled trigger type: ${String(n)}`)}}},CT={mapFromDto(n){return s$.getMapper(n.type).mapFromDto(n)},mapFromDtoList(n){return n.map(e=>this.mapFromDto(e))},async mapFromDtoWithReportData(n,e){const t=this.mapFromDto(n);switch(t.type){case ho.REPORT_RUN:return new YK().enhanceWithReportData(t);case ho.CONNECTOR_RUN:{const i=e.definition;return{...t,triggerConfig:{...t.triggerConfig,connector:i}}}default:return t}},async mapFromDtoListWithReportData(n,e){const t=new YK,i=this.mapFromDtoList(n),s=i.filter(o=>o.type===ho.REPORT_RUN),r=await t.enhanceTriggersWithReportData(s);return i.map(o=>{switch(o.type){case ho.REPORT_RUN:return r.find(a=>a.id===o.id)??o;case ho.CONNECTOR_RUN:{const a=e.definition;return{...o,triggerConfig:{...o.triggerConfig,connector:a}}}default:return o}})},mapToCreateRequest(n){return s$.getMapper(n.type).mapToCreateRequest(n)},mapToUpdateRequest(n){return s$.getMapper(n.type).mapToUpdateRequest(n)}};function elt({children:n}){const[e,t]=x.useReducer(Xat,OTe),{dataMart:i}=og(),{fetchAvailableConnectors:s}=US();if(!i)throw new Error("Trigger provider must be used within a data mart context");const r=x.useCallback(async g=>{await s(),t({type:"FETCH_TRIGGERS_START"});try{const m=await Jx.getScheduledTriggers(g),b=await CT.mapFromDtoListWithReportData(m,i);t({type:"FETCH_TRIGGERS_SUCCESS",payload:b})}catch(m){const b=m instanceof Error?m.message:"Failed to fetch scheduled triggers";t({type:"FETCH_TRIGGERS_ERROR",payload:b}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:b})}},[i,s]),o=x.useCallback(async(g,m)=>{t({type:"FETCH_TRIGGERS_START"});try{const v=(await Jx.getScheduledTriggers(g)).filter(y=>y.type===m),C=await CT.mapFromDtoListWithReportData(v,i);t({type:"FETCH_TRIGGERS_SUCCESS",payload:C})}catch(b){const v=b instanceof Error?b.message:"Failed to fetch scheduled triggers";t({type:"FETCH_TRIGGERS_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:v})}},[i]),a=x.useCallback(async(g,m)=>{t({type:"FETCH_TRIGGER_START"});try{const b=await Jx.getScheduledTrigger(g,m),v=await CT.mapFromDtoWithReportData(b,i);t({type:"FETCH_TRIGGER_SUCCESS",payload:v})}catch(b){const v=b instanceof Error?b.message:"Failed to fetch scheduled trigger";t({type:"FETCH_TRIGGER_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"GetError",label:v})}},[i]),l=x.useCallback(async(g,m,b,v,C,y)=>{t({type:"CREATE_TRIGGER_START"});try{const L={type:m,cronExpression:b,timeZone:v,isActive:C,triggerConfig:y},E=await Jx.createScheduledTrigger(g,L),R=await CT.mapFromDtoWithReportData(E,i);return t({type:"CREATE_TRIGGER_SUCCESS",payload:R}),Vt({event:"scheduled_trigger_created",category:"ScheduledTrigger",action:"Create",label:m}),Sr.success("Trigger created"),R}catch(L){const E=L instanceof Error?L.message:"Failed to create scheduled trigger";throw t({type:"CREATE_TRIGGER_ERROR",payload:E}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"CreateError",label:E}),L}},[i]),c=x.useCallback(async(g,m,b,v,C)=>{t({type:"UPDATE_TRIGGER_START"});try{const y={cronExpression:b,timeZone:v,isActive:C},L=await Jx.updateScheduledTrigger(g,m,y),E=await CT.mapFromDtoWithReportData(L,i);t({type:"UPDATE_TRIGGER_SUCCESS",payload:E}),Vt({event:"scheduled_trigger_updated",category:"ScheduledTrigger",action:"Update",label:E.type}),Sr.success("Trigger updated")}catch(y){const L=y instanceof Error?y.message:"Failed to update scheduled trigger";throw t({type:"UPDATE_TRIGGER_ERROR",payload:L}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"UpdateError",label:L}),y}},[i]),d=x.useCallback(async(g,m)=>{t({type:"DELETE_TRIGGER_START"});try{await Jx.deleteScheduledTrigger(g,m),t({type:"DELETE_TRIGGER_SUCCESS",payload:m}),Vt({event:"scheduled_trigger_deleted",category:"ScheduledTrigger",action:"Delete",label:m}),Sr.success("Trigger deleted")}catch(b){const v=b instanceof Error?b.message:"Failed to delete scheduled trigger";throw t({type:"DELETE_TRIGGER_ERROR",payload:v}),Vt({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"DeleteError",label:v}),b}},[]),u=x.useCallback(g=>{t({type:"SELECT_TRIGGER",payload:g})},[]),h=x.useCallback(()=>{t({type:"RESET"})},[]);return f.jsx(MTe.Provider,{value:{...e,getScheduledTriggers:r,getScheduledTriggersByType:o,getScheduledTrigger:a,createScheduledTrigger:l,updateScheduledTrigger:c,deleteScheduledTrigger:d,selectScheduledTrigger:u,reset:h},children:n})}function PTe(){const n=x.useContext(MTe);if(n===void 0)throw new Error("useScheduledTriggerContext must be used within a ScheduledTriggerProvider");return n}function tlt(n){const{getScheduledTriggers:e,getScheduledTriggersByType:t,getScheduledTrigger:i,createScheduledTrigger:s,updateScheduledTrigger:r,deleteScheduledTrigger:o,selectScheduledTrigger:a,reset:l,triggers:c,selectedTrigger:d,isLoading:u,error:h}=PTe();return x.useEffect(()=>(n?e(n):l(),()=>{l()}),[n,e,l]),{triggers:c,selectedTrigger:d,isLoading:u,error:h,getScheduledTriggers:g=>e(g),getScheduledTriggersByType:(g,m)=>t(g,m),getScheduledTrigger:(g,m)=>i(g,m),createScheduledTrigger:(g,m,b,v,C,y)=>s(g,m,b,v,C,y),updateScheduledTrigger:(g,m,b,v,C)=>r(g,m,b,v,C),deleteScheduledTrigger:(g,m)=>o(g,m),selectScheduledTrigger:a}}const ilt=_s({type:Pl(UL.SCHEDULED_REPORT_RUN),reportId:pn().min(1,"Report ID is required")}),nlt=IYe(),slt=_s({type:TH(ho),cronExpression:pn().min(1,"Cron expression is required"),timeZone:pn().min(1,"Time zone is required"),isActive:TYe(),triggerConfig:AYe([ilt,nlt])});function rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:i}){const s=Bp({resolver:pb(slt),defaultValues:{type:n?n.type:t??ho.REPORT_RUN,cronExpression:(n==null?void 0:n.cronExpression)??"",timeZone:(n==null?void 0:n.timeZone)??Intl.DateTimeFormat().resolvedOptions().timeZone,isActive:(n==null?void 0:n.isActive)??!0,triggerConfig:n?n.triggerConfig:{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}}});x.useEffect(()=>{e&&s.getValues("type")===ho.REPORT_RUN&&s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e})},[e,s]),x.useEffect(()=>{t&&(s.setValue("type",t),t===ho.REPORT_RUN?s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}):s.setValue("triggerConfig",null))},[t,e,s]);const r=a=>{s.setValue("type",a),a===ho.REPORT_RUN?s.setValue("triggerConfig",{type:UL.SCHEDULED_REPORT_RUN,reportId:e??""}):s.setValue("triggerConfig",null)},o=async a=>{try{await i(a)}catch(l){console.error("Error submitting form:",l)}};return{form:s,handleTypeChange:r,handleSubmit:s.handleSubmit(o),isDirty:s.formState.isDirty}}const olt=[St.GOOGLE_SHEETS,St.EMAIL,St.SLACK,St.MS_TEAMS,St.GOOGLE_CHAT];function alt({value:n,onChange:e,disabled:t}){const{reports:i,fetchReportsByDataMartId:s}=rg(),{dataMart:r}=og();x.useEffect(()=>{r&&s(r.id)},[s,r]);const o=i.filter(a=>olt.includes(a.dataDestination.type));return f.jsxs($c,{value:n,onValueChange:e,disabled:t,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a report"})}),f.jsx(Kc,{children:o.map(a=>{const l=Nc.getInfo(a.dataDestination.type).icon;return f.jsx(fo,{value:a.id,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(l,{className:"h-4 w-4",size:16}),f.jsx("span",{children:a.title})]})},a.id)})})]})}var nB="Switch",[llt]=Ha(nB),[clt,dlt]=llt(nB),FTe=x.forwardRef((n,e)=>{const{__scopeSwitch:t,name:i,checked:s,defaultChecked:r,required:o,disabled:a,value:l="on",onCheckedChange:c,form:d,...u}=n,[h,g]=x.useState(null),m=Ui(e,L=>g(L)),b=x.useRef(!1),v=h?d||!!h.closest("form"):!0,[C,y]=zc({prop:s,defaultProp:r??!1,onChange:c,caller:nB});return f.jsxs(clt,{scope:t,checked:C,disabled:a,children:[f.jsx(ui.button,{type:"button",role:"switch","aria-checked":C,"aria-required":o,"data-state":VTe(C),"data-disabled":a?"":void 0,disabled:a,value:l,...u,ref:m,onClick:Lt(n.onClick,L=>{y(E=>!E),v&&(b.current=L.isPropagationStopped(),b.current||L.stopPropagation())})}),v&&f.jsx(BTe,{control:h,bubbles:!b.current,name:i,value:l,checked:C,required:o,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});FTe.displayName=nB;var jTe="SwitchThumb",HTe=x.forwardRef((n,e)=>{const{__scopeSwitch:t,...i}=n,s=dlt(jTe,t);return f.jsx(ui.span,{"data-state":VTe(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:e})});HTe.displayName=jTe;var ult="SwitchBubbleInput",BTe=x.forwardRef(({__scopeSwitch:n,control:e,checked:t,bubbles:i=!0,...s},r)=>{const o=x.useRef(null),a=Ui(o,r),l=ire(t),c=Xne(e);return x.useEffect(()=>{const d=o.current;if(!d)return;const u=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(u,"checked").set;if(l!==t&&g){const m=new Event("click",{bubbles:i});g.call(d,t),d.dispatchEvent(m)}},[l,t,i]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...s,tabIndex:-1,ref:a,style:{...s.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});BTe.displayName=ult;function VTe(n){return n?"checked":"unchecked"}var hlt=FTe,flt=HTe;function WTe({className:n,...e}){return f.jsx(hlt,{"data-slot":"switch",className:Le("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:data-[state=unchecked]:bg-white/16",n),...e,children:f.jsx(flt,{"data-slot":"switch-thumb",className:Le("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function glt(n){const e=n.trim().split(/\s+/);return e.length!==5?null:{minute:e[0],hour:e[1],day:e[2],month:e[3],dayOfWeek:e[4]}}function XK(n,e="UTC"){const t=glt(n);if(!t)return{type:"daily",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e};const{minute:i,hour:s,day:r,month:o,dayOfWeek:a}=t;if(i.startsWith("*/")&&s==="*"&&r==="*"&&o==="*"&&a==="*"){const u=Number.parseInt(i.substring(2));if(!isNaN(u))return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:u,timezone:e}}if(i!=="*"&&s.startsWith("*/")&&r==="*"&&o==="*"&&a==="*"){const u=Number.parseInt(s.substring(2));if(!isNaN(u)&&i==="0")return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"hours",intervalValue:u,timezone:e}}const l=Number.parseInt(i),c=Number.parseInt(s),d=!isNaN(l)&&!isNaN(c)?`${c.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:"09:00";if(!isNaN(l)&&!isNaN(c)&&r==="*"&&o==="*"&&a==="*")return{type:"daily",time:d,weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e};if(!isNaN(l)&&!isNaN(c)&&r==="*"&&o==="*"&&a!=="*"){const u=a.split(",").map(h=>Number.parseInt(h.trim())).filter(h=>!isNaN(h)&&h>=0&&h<=6);if(u.length>0)return{type:"weekly",time:d,weekdays:u,monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}if(!isNaN(l)&&!isNaN(c)&&r!=="*"&&o==="*"&&a==="*"){const u=r.split(",").map(h=>Number.parseInt(h.trim())).filter(h=>!isNaN(h)&&h>=1&&h<=31);if(u.length>0)return{type:"monthly",time:d,weekdays:[1,2,3,4,5],monthDays:u,customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}return{type:"custom",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:n,intervalType:"minutes",intervalValue:15,timezone:e}}function zTe({options:n,selected:e,onSelectionChange:t,placeholder:i="Select items...",searchPlaceholder:s="Search...",maxDisplayItems:r=3}){const[o,a]=x.useState(!1),l=u=>{const h=e.includes(u)?e.filter(g=>g!==u):[...e,u].sort((g,m)=>g-m);t(h)},c=(u,h)=>{h.preventDefault(),h.stopPropagation(),t(e.filter(g=>g!==u))},d=()=>{if(e.length===0)return f.jsx("span",{className:"text-muted-foreground text-sm",children:i});const u=e.map(h=>n.find(g=>g.value===h)).filter(Boolean);return u.length<=r?f.jsx("div",{className:"flex flex-wrap gap-1",children:u.map(h=>f.jsxs(Ya,{variant:"secondary",className:"h-5 text-xs",children:[h.label,f.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:g=>c(h.value,g),children:f.jsx(ID,{className:"h-2 w-2"})})]},h.value))}):f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Ya,{variant:"secondary",className:"h-5 text-xs",children:[u[0].label,f.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:h=>c(u[0].value,h),children:f.jsx(ID,{className:"h-2 w-2"})})]}),u.length>1&&f.jsxs(Ya,{variant:"outline",className:"h-5 text-xs",children:["+",u.length-1]})]})};return f.jsxs(yre,{open:o,onOpenChange:a,modal:!0,children:[f.jsx(Sre,{asChild:!0,children:f.jsxs(rt,{variant:"outline",role:"combobox","aria-expanded":o,className:"h-9 min-h-9 w-full justify-between bg-transparent py-1",children:[f.jsx("div",{className:"flex-1 text-left",children:d()}),f.jsx(One,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),f.jsx(xre,{className:"max-h-[400px] w-full overflow-y-auto p-0",style:{padding:0},children:f.jsxs(mTe,{className:"h-full overflow-visible",children:[f.jsx(_Te,{placeholder:s,className:"h-8"}),f.jsxs(Aot,{className:"h-full max-h-[350px] overflow-y-auto",children:[f.jsx(bTe,{children:"No items found."}),f.jsx(vTe,{className:"h-full overflow-visible",children:n.map(u=>f.jsxs(CTe,{value:u.value.toString(),onSelect:()=>l(u.value),className:"text-sm",children:[f.jsx(Wc,{className:Le("mr-2 h-3 w-3",e.includes(u.value)?"opacity-100":"opacity-0")}),u.label]},u.value))})]})]})})]})}const UTe=[{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"},{value:0,label:"Sunday"}],m4=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}};function $Te(n,e){if(!e)return"Schedule is disabled";const t=n.time;switch(n.type){case"daily":return`Daily at ${t}`;case"weekly":return`Weekly on ${n.weekdays.map(s=>{var r;return(r=UTe.find(o=>o.value===s))==null?void 0:r.label}).join(", ")} at ${t}`;case"monthly":{const s=[...n.monthDays].sort((o,a)=>o-a).map(o=>o===1?"1st":o===2?"2nd":o===3?"3rd":`${String(o)}th`);return`Monthly on the ${s.length===1?s[0]:s.length===2?`${s[0]} and ${s[1]}`:`${s.slice(0,-1).join(", ")}, and ${s[s.length-1]}`} at ${t}`}case"interval":return n.intervalType==="minutes"?`Every ${String(n.intervalValue)} minute${n.intervalValue!==1?"s":""}`:`Every ${String(n.intervalValue)} hour${n.intervalValue!==1?"s":""}`;case"custom":return"Custom schedule";default:return""}}function plt(n,e,t=!0){const i=XK(n,e);return $Te(i,t)}const mlt=Array.from({length:31},(n,e)=>({value:e+1,label:`${String(e+1)}${e===0?"st":e===1?"nd":e===2?"rd":"th"}`})),QK=[5,10,15,30],JK=[1,2,3,4,6,8,12],_lt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Type"}),f.jsxs($c,{value:n,onValueChange:i=>{e(i)},disabled:t,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:"daily",children:"Daily"}),f.jsx(fo,{value:"weekly",children:"Weekly"}),f.jsx(fo,{value:"monthly",children:"Monthly"}),f.jsx(fo,{value:"interval",children:"Interval"})]})]})]}),blt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Time"}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(vn,{className:"w-24",type:"time",value:n,onChange:i=>{e(i.target.value)},disabled:t})})]}),Bme=({value:n,onChange:e,disabled:t,timezones:i})=>f.jsxs("div",{className:"w-full space-y-2",children:[f.jsx(Bu,{children:"Timezone"}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsx(Lre,{options:i,value:n,onValueChange:e,placeholder:"Select timezone",emptyMessage:"No timezones found",disabled:t,className:"w-full"})})]}),vlt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Days of Week"}),f.jsx("div",{className:t?"pointer-events-none":"",children:f.jsx(zTe,{options:UTe,selected:n,onSelectionChange:e,placeholder:"Select days...",maxDisplayItems:3})})]}),Clt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Days of Month"}),f.jsx("div",{className:t?"pointer-events-none":"",children:f.jsx(zTe,{options:mlt,selected:n,onSelectionChange:e,placeholder:"Select days...",maxDisplayItems:4})})]}),wlt=({intervalType:n,intervalValue:e,onTypeChange:t,onValueChange:i,disabled:s})=>f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Type"}),f.jsxs($c,{value:n,onValueChange:r=>{t(r)},disabled:s,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:"minutes",children:"Minutes"}),f.jsx(fo,{value:"hours",children:"Hours"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Bu,{children:"Every"}),f.jsxs($c,{value:e.toString(),onValueChange:r=>{i(Number.parseInt(r)||1)},disabled:s,children:[f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{})}),f.jsx(Kc,{children:(n==="minutes"?QK:JK).map(r=>f.jsxs(fo,{value:r.toString(),children:[r," ",n==="minutes"?"min":"hr"]},r))})]})]})]}),ylt=({value:n,onChange:e,disabled:t})=>f.jsxs("div",{className:"space-y-1",children:[f.jsx(Bu,{className:"text-sm",children:"Cron Expression"}),f.jsx(vn,{value:n,onChange:i=>{e(i.target.value)},placeholder:"0 9 * * *",className:"h-9 font-mono text-sm",disabled:t}),f.jsx("p",{className:"text-muted-foreground text-xs",children:"Format: minute hour day month day-of-week"})]});function Slt({cron:n="0 9 * * *",timezone:e,enabled:t=!0,onChange:i,className:s,showPreview:r=!0,showSaveButton:o=!1}){const[a,l]=x.useState(t),[c,d]=x.useState(e??m4()),[u,h]=x.useState(!1),g=x.useMemo(()=>eQe.getTimezonesWithOffset().map(W=>({value:W.identifier,label:W.displayName,offset:W.offsetString,isDST:W.isDST})),[]),[m,b]=x.useState(()=>XK(n,c)),[v,C]=x.useState(""),[y,L]=x.useState("");x.useEffect(()=>{l(t)},[t]),x.useEffect(()=>{const W=e??m4();d(W)},[e]),x.useEffect(()=>{if(n){const W=XK(n,c);b(W)}},[n,c]);const E=W=>{const[U,B]=W.time.split(":").map(Number);switch(W.type){case"daily":return`${String(B)} ${String(U)} * * *`;case"weekly":return`${String(B)} ${String(U)} * * ${W.weekdays.join(",")}`;case"monthly":return`${String(B)} ${String(U)} ${W.monthDays.join(",")} * *`;case"interval":return W.intervalType==="minutes"?`*/${String(W.intervalValue)} * * * *`:`0 */${String(W.intervalValue)} * * *`;case"custom":return W.customCron;default:return`${String(B)} ${String(U)} * * *`}},R=x.useCallback(W=>{b(U=>{if(U.intervalType===W)return console.log("Type unchanged, skipping update"),U;const K=(W==="minutes"?QK:JK)[0];return{...U,intervalType:W,intervalValue:K}})},[]),T=x.useCallback(W=>{b(U=>(U.intervalType==="minutes"?QK:JK).includes(W)?{...U,intervalValue:W}:U)},[]),N=x.useMemo(()=>W=>$Te(W,a),[a]);x.useEffect(()=>{const W=E(m);C(W),L(N(m))},[m,a,c,N]);const I=x.useRef(""),M=x.useRef(""),P=x.useRef(!1);x.useEffect(()=>{const W=E(m);i&&(I.current!==W||M.current!==c||P.current!==a)&&(i({cron:W,timezone:c,enabled:a}),I.current=W,M.current=c,P.current=a)},[m,c,a,i]);const H=W=>{l(W)},j=W=>{d(W),b(U=>({...U,timezone:W}))},V=["daily","weekly","monthly"].includes(m.type);return f.jsxs("div",{className:s,children:[f.jsx("div",{className:"mb-4 space-y-4 pt-0",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-foreground flex items-center gap-1.5 font-medium",children:"Schedule Settings"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Bu,{htmlFor:"schedule-enabled",className:"text-sm font-normal",children:a?"Enabled":"Disabled"}),f.jsx(WTe,{id:"schedule-enabled",checked:a,onCheckedChange:H})]})]})}),f.jsxs("div",{className:"space-y-4 pt-0",children:[f.jsxs("div",{className:`space-y-4 ${a?"":"opacity-50"}`,children:[f.jsx(_lt,{value:m.type,onChange:W=>{b(U=>({...U,type:W}))},disabled:!a}),m.type!=="custom"&&m.type!=="interval"&&f.jsxs("div",{className:"flex gap-3",children:[f.jsx(blt,{value:m.time,onChange:W=>{b(U=>({...U,time:W}))},disabled:!a}),V&&f.jsx(Bme,{value:c,onChange:j,disabled:!a,timezones:g})]}),(m.type==="interval"||m.type==="custom")&&f.jsx(Bme,{value:c,onChange:j,disabled:!a,timezones:g}),m.type==="weekly"&&f.jsx(vlt,{value:m.weekdays,onChange:W=>{b(U=>({...U,weekdays:W}))},disabled:!a}),m.type==="monthly"&&f.jsx(Clt,{value:m.monthDays,onChange:W=>{b(U=>({...U,monthDays:W}))},disabled:!a}),m.type==="interval"&&f.jsx(wlt,{intervalType:m.intervalType,intervalValue:m.intervalValue,onTypeChange:R,onValueChange:T,disabled:!a}),m.type==="custom"&&f.jsx(ylt,{value:m.customCron,onChange:W=>{b(U=>({...U,customCron:W}))},disabled:!a})]}),r&&f.jsxs(f.Fragment,{children:[f.jsx(Cxe,{className:"my-3"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex cursor-pointer items-center justify-between",onClick:()=>{h(!u)},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ixe,{className:"h-4 w-4"}),f.jsx("span",{className:"text-sm font-medium",children:"Preview"})]}),u?f.jsx(TD,{className:"text-muted-foreground h-4 w-4"}):f.jsx(Pp,{className:"text-muted-foreground h-4 w-4"})]}),u&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid gap-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Status:"}),f.jsx(Ya,{variant:a?"default":"secondary",className:"text-xs",children:a?"Enabled":"Disabled"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Cron:"}),f.jsx(Ya,{variant:"secondary",className:"font-mono text-xs",children:v})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Timezone:"}),f.jsx(Ya,{variant:"outline",className:"text-xs",children:c})]}),f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsx("span",{className:"text-muted-foreground text-xs",children:"Schedule:"}),f.jsx("span",{className:"flex-1 text-right text-xs",children:y})]})]}),a&&V&&c!==m4()&&f.jsxs(Dre,{className:"border-amber-200 bg-amber-50",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(kTe,{children:"Time Zone"}),f.jsxs(Rre,{children:["Schedule runs in ",c," (not your local ",m4()," ","time). Execution time may differ from expected."]})]})]})]})]}),o&&f.jsx(rt,{className:"w-full",disabled:!a,children:"Save Schedule"})]})]})}function xlt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"trigger-type-options-description-details",children:[f.jsx(is,{children:"How do I choose a type?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:[f.jsx("strong",{children:"Report Run"})," - runs a report to import data from the specified Data Storage into a Destination provider (e.g. Google Sheets document)."]}),f.jsxs("p",{className:"mb-2",children:[f.jsx("strong",{children:"Connector Run"})," - runs a connector (e.g., Facebook Ads) configured in the Data Mart to update raw data in the selected Data Storage."]})]})]})})}function Llt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"trigger-type-change-description-details",children:[f.jsx(is,{children:"How do I change the trigger type?"}),f.jsx(ns,{children:f.jsx("p",{children:"Trigger type cannot be changed after the trigger is created. If you need a different type, delete the existing trigger and create a new one with the desired type."})})]})})}function Elt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"report-change-description-details",children:[f.jsx(is,{children:"How do I change a report?"}),f.jsx(ns,{children:f.jsx("p",{children:"The report cannot be changed after the trigger is created. If you need a different report, delete the existing trigger and create a new one with the desired report."})})]})})}function Dlt(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"report-select-description-details",children:[f.jsx(is,{children:"How do I choose the report?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"For a Report Run trigger, select one of the available Destinations (e.g., a Google Sheets report)."}),f.jsxs("p",{children:["You can use an existing one or create a new one on the ",f.jsx("strong",{children:"Destinations"})," tab"," ","of this Data Mart."]})]})]})})}function Rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:i,onCancel:s,onDirtyChange:r}){const[o,a]=x.useState(!1),{form:l,handleTypeChange:c,handleSubmit:d,isDirty:u}=rlt({initialData:n,preSelectedReportId:e,preSelectedType:t,onSubmit:async v=>{a(!0);try{await i(v)}finally{a(!1)}}});x.useEffect(()=>{r==null||r(u)},[u,r]);const{control:h,watch:g}=l,b=g("type")===ho.REPORT_RUN;return f.jsx(CC,{...l,children:f.jsxs(gb,{onSubmit:v=>void d(v),noValidate:!1,children:[f.jsxs(wC,{children:[f.jsx(fn,{control:h,name:"type",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Choose what you want this trigger to run - a report or a connector",children:"Trigger Type"}),f.jsxs($c,{onValueChange:C=>{v.onChange(C),c(C)},defaultValue:v.value,disabled:!!t||!!n||!!g("triggerConfig.reportId"),children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select trigger type"})})}),f.jsxs(Kc,{children:[f.jsx(fo,{value:ho.REPORT_RUN,children:"Report Run"}),f.jsx(fo,{value:ho.CONNECTOR_RUN,children:"Connector Run"})]})]}),f.jsx(Hs,{children:n?f.jsx(Llt,{}):f.jsx(xlt,{})}),f.jsx(Cn,{})]})}),b&&f.jsx(fn,{control:h,name:"triggerConfig.reportId",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select the report that will be run by this trigger",children:"Report"}),f.jsx(cn,{children:f.jsx(ODe,{children:f.jsx(alt,{value:v.value??"",onChange:v.onChange,disabled:!!e||!!n})})}),f.jsx(Hs,{children:n!=null&&n.triggerConfig?f.jsx(Elt,{}):f.jsx(Dlt,{})}),f.jsx(Cn,{})]})}),f.jsx(Slt,{showPreview:!1,cron:g("cronExpression"),timezone:g("timeZone"),enabled:g("isActive"),onChange:v=>{l.setValue("cronExpression",v.cron,{shouldDirty:!0}),l.setValue("timeZone",v.timezone,{shouldDirty:!0}),l.setValue("isActive",v.enabled,{shouldDirty:!0})},className:"border-border flex flex-col gap-1.5 rounded-md border-b bg-white px-4 py-3 transition-shadow duration-200 hover:shadow-sm dark:border-transparent dark:bg-white/4"})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":n?"Save changes":"Create trigger",disabled:!u||o,children:o?n?"Saving...":"Creating...":n?"Save changes":"Create trigger"}),s&&f.jsx(rt,{variant:"outline",type:"button",onClick:s,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Nlt({cronExpression:n,timeZone:e,isEnabled:t=!0}){const i=x.useMemo(()=>plt(n,e,t),[n,e,t]);return f.jsxs("div",{children:[f.jsx("div",{children:i}),t&&f.jsx("code",{className:"text-muted-foreground mt-1 block text-xs",children:e})]})}function Tlt({trigger:n,onEditTrigger:e,onDeleteTrigger:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),a=()=>{o(!1),t(n.id)};return f.jsxs("div",{className:"text-right",onClick:l=>{l.stopPropagation()},children:[f.jsxs(Al,{open:i,onOpenChange:s,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${i?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>{e(n.id)},children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit trigger"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>{o(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete trigger"})]})]})]}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Delete Scheduled Trigger",description:"Are you sure you want to delete this scheduled trigger? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:a,variant:"destructive"})]})}function Ilt({connector:n}){const{connectors:e}=US(),t=ait(n,e);return f.jsx(f.Fragment,{children:t})}function GTe({connector:n}){return f.jsx(Ilt,{connector:n})}function klt(n){if(n.length===0)return{lastRunDate:null,lastRunStatus:null,totalRuns:0,firstRunDate:null};const e=n[0],t=n[n.length-1],i=new Date(t.createdAt);return{lastRunDate:new Date(e.createdAt),lastRunStatus:e.status,totalRuns:n.length,firstRunDate:i}}const Alt=n=>{const{connectors:e}=US();return x.useMemo(()=>e.find(t=>t.name===n),[e,n])},Mlt=nt.memo(function({connector:e,children:t}){const i=Alt(e.source.name),{dataMart:s,runs:r,getDataMartRuns:o}=og();x.useEffect(()=>{s!=null&&s.id&&o(s.id)},[s==null?void 0:s.id,o]);const a=x.useMemo(()=>i!=null&&i.logoBase64?f.jsx(VS,{base64:i.logoBase64,size:20}):null,[i==null?void 0:i.logoBase64]),l=x.useCallback(()=>{s!=null&&s.storage&&kQe(s.storage,e.storage.fullyQualifiedName)},[s==null?void 0:s.storage,e.storage.fullyQualifiedName]),c=x.useMemo(()=>klt(r),[r]),d=x.useMemo(()=>!c.lastRunDate||!c.lastRunStatus?null:{statusType:ZJe(c.lastRunStatus),statusText:XJe(c.lastRunStatus),date:c.lastRunDate},[c]),u=x.useMemo(()=>(s==null?void 0:s.storage)&&AQe(s.storage),[s]),h=x.useMemo(()=>{const g=e.source.fields.length.toString();return`${e.source.node} • ${g} fields`},[e.source.node,e.source.fields.length]);return f.jsxs(jH,{children:[f.jsx(HH,{asChild:!0,children:f.jsx("span",{children:t})}),f.jsxs(BH,{children:[f.jsxs(Tse,{children:[f.jsx(Ise,{children:a}),f.jsxs(kse,{children:[f.jsx(Ase,{children:f.jsx(GTe,{connector:e})}),f.jsx(Mse,{children:h})]})]}),f.jsxs(Ose,{children:[f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Last run status:"}),f.jsx(Fv,{children:d?f.jsx(kM,{type:d.statusType,variant:"ghost",children:d.statusText}):"Not run yet"})]}),f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Last run date:"}),f.jsx(Fv,{children:d?f.jsx(W1,{date:d.date}):"Never run"})]}),f.jsxs(Ov,{children:[f.jsx(Pv,{children:"Total runs:"}),f.jsxs(Fv,{children:[c.totalRuns," runs",c.firstRunDate&&f.jsxs(f.Fragment,{children:[", since"," ",c.firstRunDate.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})]})]})]})]}),f.jsx(Pse,{children:f.jsxs(rt,{className:"w-full",variant:"default",onClick:l,title:"Open Storage","aria-label":"Open Storage",children:[u,f.jsx(F_,{className:"ml-1 inline h-4 w-4","aria-hidden":"true"})]})})]})]})},(n,e)=>n.connector.source.name===e.connector.source.name&&n.connector.storage.fullyQualifiedName===e.connector.storage.fullyQualifiedName&&n.connector.source.node===e.connector.source.node&&n.connector.source.fields.length===e.connector.source.fields.length);function Olt(n){const e=n.triggerConfig,t=Nc.getInfo(e.report.dataDestination.type).icon;return f.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[f.jsx(t,{className:"h-4 w-4",size:16}),e.report.title,f.jsx(qJe,{report:e.report,children:f.jsx(sc,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function Plt(n){var s;const e=n.triggerConfig,{connector:t}=e.connector,i=(s=t.info)!=null&&s.logoBase64?f.jsx(VS,{base64:t.info.logoBase64,className:"h-4 w-4",size:16}):f.jsx(j1,{className:"h-4 w-4",size:16});return f.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[i,f.jsx(GTe,{connector:t}),f.jsx(Mlt,{connector:t,children:f.jsx(sc,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function Flt({trigger:n}){switch(n.type){case ho.REPORT_RUN:return Olt(n);case ho.CONNECTOR_RUN:return Plt(n);default:return f.jsx("div",{className:"text-muted-foreground text-sm",children:"—"})}}function jlt({onEditTrigger:n,onDeleteTrigger:e}){return[{accessorKey:"type",size:150,header:"Trigger Type",cell:({row:t})=>{const s=t.getValue("type")===ho.REPORT_RUN?"Report Run":"Connector Run";return f.jsx(Ya,{variant:"outline",children:s})},meta:{title:"Trigger Type"}},{accessorKey:"triggerConfig",size:35,header:"Run Target",cell:({row:t})=>f.jsx(Flt,{trigger:t.original}),meta:{title:"Run Target"}},{accessorKey:"cronExpression",size:20,header:"Schedule",cell:({row:t})=>{const i=t.getValue("cronExpression"),s=t.original.timeZone,r=t.getValue("isActive");return f.jsx(Nlt,{cronExpression:String(i),timeZone:s,isEnabled:r})},meta:{title:"Schedule"}},{accessorKey:"nextRun",size:15,header:"Next Run",cell:({row:t})=>{const i=t.original.nextRun;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Not scheduled"})},meta:{title:"Next Run"}},{accessorKey:"lastRun",size:15,header:"Last Run",cell:({row:t})=>{const i=t.original.lastRun;return f.jsx("div",{className:"text-sm",children:i?f.jsx(W1,{date:new Date(i)}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"Never run"})})},meta:{title:"Last Run"}},{accessorKey:"isActive",size:15,header:"Trigger Status",cell:({row:t})=>{const i=t.getValue("isActive");return f.jsx(kM,{type:i?Do.SUCCESS:Do.NEUTRAL,variant:"ghost",showIcon:!1,children:i?"Enabled":"Disabled"})},meta:{title:"Trigger Status"}},{id:"actions",size:80,header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(Tlt,{trigger:t.original,onEditTrigger:n,onDeleteTrigger:e}),meta:{title:"Actions"}}]}function Hlt({table:n,onPreviousClick:e,onNextClick:t}){return f.jsxs("div",{className:"dm-card-pagination",role:"navigation","aria-label":"Table pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:e,disabled:!n.getCanPreviousPage(),"aria-label":"Go to previous page",children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:t,disabled:!n.getCanNextPage(),"aria-label":"Go to next page",children:"Next"})]})}function Tre({isOpen:n,onClose:e,dataMartId:t,preSelectedReportId:i,preSelectedType:s}){const{createScheduledTrigger:r,updateScheduledTrigger:o,selectedTrigger:a}=PTe(),[l,c]=x.useState(!1),[d,u]=x.useState(!1),h=x.useCallback(()=>{d?c(!0):e()},[d,e]),g=x.useCallback(()=>{c(!1),u(!1),e()},[e]),m=x.useCallback(E=>{u(E)},[]),b=x.useCallback(()=>{u(!1),e()},[e]),v=!!a,C=x.useMemo(()=>a?{type:a.type,cronExpression:a.cronExpression,timeZone:a.timeZone,isActive:a.isActive,triggerConfig:a.type===ho.REPORT_RUN?{type:UL.SCHEDULED_REPORT_RUN,reportId:a.triggerConfig.reportId}:null}:void 0,[a]),y=async E=>{v?await o(t,a.id,E.cronExpression,E.timeZone,E.isActive):await r(t,E.type,E.cronExpression,E.timeZone,E.isActive,E.triggerConfig),b()},L=x.useRef(!1);return x.useEffect(()=>{const E=v?"Edit":"Create",R=(a==null?void 0:a.type)??s;n&&!L.current?(Vt({event:"scheduled_trigger_config_open",category:"ScheduledTrigger",action:E,label:R}),L.current=!0):!n&&L.current&&(Vt({event:"scheduled_trigger_config_close",category:"ScheduledTrigger",action:E,label:R}),L.current=!1)},[n,v,a,s]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:E=>{E||h()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsxs(db,{children:[v?"Edit":"Create"," Scheduled Trigger"]}),f.jsx(cC,{children:"Configure automatic runs for your reports or connectors."})]}),f.jsx(Rlt,{preSelectedReportId:i,preSelectedType:s,initialData:C,onSubmit:y,onCancel:h,onDirtyChange:m})]})}),f.jsx(Ma,{open:l,onOpenChange:c,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:g,variant:"destructive"})]})}function Blt({triggers:n,dataMartId:e,onEditTrigger:t,onDeleteTrigger:i}){const[s,r]=x.useState(!1),o=x.useCallback(()=>{r(!1)},[]),a=x.useCallback(C=>{i(C)},[i]),l=x.useMemo(()=>jlt({onEditTrigger:t,onDeleteTrigger:a}),[t,a]),{sorting:c,setSorting:d,columnVisibility:u,setColumnVisibility:h}=zS({columns:l,storageKeyPrefix:"data-mart-scheduled-triggers",defaultSortingColumn:"type"}),g=pC({data:n,columns:l,getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:d,getSortedRowModel:WS(),getFilteredRowModel:HR(),state:{sorting:c,columnVisibility:u},onColumnVisibilityChange:h,enableGlobalFilter:!0,enableColumnResizing:!1}),m=x.useCallback(()=>{g.previousPage()},[g]),b=x.useCallback(()=>{g.nextPage()},[g]);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:"scheduled-triggers-table",className:"dm-card-table",role:"table","aria-label":"Scheduled Triggers",children:[f.jsx(_C,{className:"dm-card-table-header",children:g.getHeaderGroups().map(C=>f.jsx(qr,{className:"dm-card-table-header-row",children:C.headers.map(y=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",scope:"col",style:y.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:y.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(y.getSize())}%`},children:y.isPlaceholder?null:typeof y.column.columnDef.header=="function"?y.column.columnDef.header(y.getContext()):y.column.columnDef.header},y.id))},C.id))}),f.jsx(bC,{className:"dm-card-table-body",children:g.getRowModel().rows.length?g.getRowModel().rows.map((C,y)=>f.jsx(qr,{onClick:()=>{t(C.original.id)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":y+1,children:C.getVisibleCells().map((L,E)=>f.jsx(Rl,{className:`whitespace-normal ${L.column.id==="actions"?"actions-cell":""}`,role:"cell","aria-colindex":E+1,style:L.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.column.getSize())}%`},children:typeof L.column.columnDef.cell=="function"?L.column.columnDef.cell(L.getContext()):L.column.columnDef.cell},L.id))},C.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:l.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No scheduled triggers found."})})})})]})}),f.jsx(Hlt,{table:g,onPreviousClick:m,onNextClick:b}),f.jsx(Tre,{isOpen:s,onClose:o,dataMartId:e})]})}function Vlt({dataMartId:n}){const{triggers:e,deleteScheduledTrigger:t,selectScheduledTrigger:i,selectedTrigger:s}=tlt(n),[r,o]=x.useState(!1);x.useEffect(()=>{s&&o(!0)},[s]);const a=d=>{const u=e.find(h=>h.id===d);u&&i(u)},l=()=>{o(!1),i(null)},c=async d=>{try{await t(n,d)}catch(u){console.error("Error deleting trigger:",u)}};return f.jsxs(f.Fragment,{children:[f.jsx(Blt,{triggers:e,dataMartId:n,onEditTrigger:a,onDeleteTrigger:d=>void c(d)}),f.jsx(Tre,{isOpen:r,onClose:l,dataMartId:n})]})}function Ire(){return f.jsx("div",{className:"dm-card-block !gap-1.5 !py-3",children:f.jsxs("div",{className:"text-foreground flex items-start gap-1.5 text-sm",children:[f.jsx(oxe,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium",children:"Time Triggers"}),f.jsxs("p",{className:"text-muted-foreground",children:["Set up automatic runs in the ",f.jsx("span",{className:"font-medium",children:"Triggers"})," tab once you’ve saved and published this Data Mart."]})]})]})})}function _4(n){return n.startsWith('"')&&n.endsWith('"')?n:`"${n}"`}function jF(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n}function Wlt({dataStorageType:n,target:e,destinationName:t,connectorName:i,onTargetChange:s}){const r=t.replace(/[^a-zA-Z0-9_]/g,"_"),o=i.replace(/[^a-zA-Z0-9_]/g,"_").toLowerCase(),[a,l]=x.useState(""),[c,d]=x.useState(""),[u,h]=x.useState(""),[g,m]=x.useState(null),[b,v]=x.useState(null),[C,y]=x.useState(null),L=(I,M=!1)=>I.trim()?M&&I.startsWith('"')&&I.endsWith('"')?I.slice(1,-1)?null:"Quoted identifier cannot be empty":/^[A-Za-z][A-Za-z0-9_]*$/.test(I)?null:"Use letters, numbers, and underscores; start with a letter":"This field is required",E=x.useCallback((I,M,P,H,j,V)=>{let W;if(n===lt.SNOWFLAKE&&j){const B=_4(j),K=_4(M);W=`${I}.${B}.${K}`}else W=`${I}.${M}`;const U=n===lt.SNOWFLAKE?!!(I&&j&&M&&P===null&&V===null&&H===null):!!(I&&M&&P===null&&H===null);s({fullyQualifiedName:W,isValid:U})},[s,n]);x.useEffect(()=>{let I="",M="",P="";if(e!=null&&e.fullyQualifiedName){const B=e.fullyQualifiedName.match(/(?:[^."]+|"[^"]*")+/g)??[];if(n===lt.SNOWFLAKE&&B.length===3){const K=B[0],X=B[1],ne=B[2];K&&X&&ne&&(I=K,M=jF(X),P=jF(ne))}else if(B.length>=2){const K=B[0],X=B[1];K&&X&&(I=K,P=X)}}else I=`${o}_owox`,n===lt.SNOWFLAKE&&(M="PUBLIC"),P=r;const H=L(I),j=n===lt.SNOWFLAKE?L(M,!0):null,V=L(P,n===lt.SNOWFLAKE);l(I),d(M),h(P),m(H),v(j),y(V);const W=n===lt.SNOWFLAKE&&M?`${I}.${_4(M)}.${_4(P)}`:`${I}.${P}`,U=n===lt.SNOWFLAKE?!!(I&&M&&P&&H===null&&j===null&&V===null):!!(I&&P&&H===null&&V===null);((e==null?void 0:e.fullyQualifiedName)!==W||e.isValid!==U)&&E(I,P,H,V,M,j)},[e,r,o,n,E]);const R=I=>{l(I);const M=L(I);m(M),E(I,u,M,C,c,b)},T=I=>{d(I);const M=L(I,!0);v(M),E(a,u,g,C,I,M)},N=I=>{h(I);const M=L(I,n===lt.SNOWFLAKE);y(M),E(a,I,g,M,c,b)};return f.jsxs(L_,{children:[n===lt.GOOGLE_BIGQUERY&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(XEe,{}),title:"Google BigQuery",docUrl:"https://docs.owox.com/docs/storages/supported-storages/google-bigquery/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"dataset-name",tooltip:"Enter dataset name for Google BigQuery where the connector data will be stored.",children:"Dataset name"}),f.jsx(vn,{type:"text",id:"dataset-name",placeholder:"Enter dataset name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"dataset-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Dataset is auto-created on first run if it doesn’t exist"}),g&&f.jsx("p",{id:"dataset-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),f.jsx(vn,{type:"text",id:"table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),C&&f.jsx("p",{id:"table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),n===lt.AWS_ATHENA&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(QEe,{}),title:"AWS Athena",docUrl:"https://docs.owox.com/docs/storages/supported-storages/aws-athena/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"database-name",tooltip:"Enter database name for Amazon Athena where the connector data will be stored.",children:"Database name"}),f.jsx(vn,{type:"text",id:"database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"database-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn’t exist"}),g&&f.jsx("p",{id:"database-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"athena-table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),f.jsx(vn,{type:"text",id:"athena-table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"athena-table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),C&&f.jsx("p",{id:"athena-table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),n===lt.SNOWFLAKE&&f.jsxs(f.Fragment,{children:[f.jsx(x_,{icon:f.jsx(JEe,{}),title:"Snowflake",docUrl:"https://docs.owox.com/docs/storages/supported-storages/snowflake/",variant:"compact"}),f.jsxs(Hv,{title:"Choose where to store your data",children:[f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-database-name",tooltip:"Enter database name for Snowflake where the connector data will be stored.",children:"Database name"}),f.jsx(vn,{type:"text",id:"snowflake-database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:a,"aria-invalid":!!g,"aria-describedby":g?"snowflake-database-name-error":void 0,onChange:I=>{R(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn't exist"}),g&&f.jsx("p",{id:"snowflake-database-name-error",className:"text-destructive text-sm",children:g})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-schema-name",tooltip:"Enter schema name for Snowflake where the connector data will be stored. Identifiers will be quoted automatically to preserve case sensitivity.",children:"Schema name"}),f.jsx(vn,{type:"text",id:"snowflake-schema-name",placeholder:"PUBLIC",autoComplete:"off",className:"box-border w-full",value:c,"aria-invalid":!!b,"aria-describedby":b?"snowflake-schema-name-error":void 0,onChange:I=>{T(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Schema is auto-created on first run if it doesn't exist"}),b&&f.jsx("p",{id:"snowflake-schema-name-error",className:"text-destructive text-sm",children:b})]}),f.jsxs(iv,{children:[f.jsx(_u,{required:!0,htmlFor:"snowflake-table-name",tooltip:"Enter table name where the connector data will be stored. Identifiers will be quoted automatically to preserve case sensitivity.",children:"Table name"}),f.jsx(vn,{type:"text",id:"snowflake-table-name",placeholder:"my_table",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!C,"aria-describedby":C?"snowflake-table-name-error":void 0,onChange:I=>{N(I.target.value)},required:!0}),f.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn't exist"}),C&&f.jsx("p",{id:"snowflake-table-name-error",className:"text-destructive text-sm",children:C})]})]})]}),f.jsx(Hv,{title:"Schedule updates",children:f.jsx(Ire,{})})]})}function zlt({onSubmit:n,dataStorageType:e,configurationOnly:t=!1,existingConnector:i=null,mode:s="full",initialStep:r,preselectedConnector:o,onDirtyChange:a}){const[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,g]=x.useState(""),[m,b]=x.useState([]),[v,C]=x.useState(1),[y,L]=x.useState({}),[E,R]=x.useState(!1),[T,N]=x.useState(new Set),[I,M]=x.useState(new Set),{connectors:P,connectorSpecification:H,connectorFields:j,loading:V,loadingSpecification:W,loadingFields:U,error:B,fetchAvailableConnectors:K,fetchConnectorSpecification:X,fetchConnectorFields:ne}=US();x.useEffect(()=>{a==null||a(l)},[l,a]);const[fe,Z]=x.useState(null),ee=(t?[{id:1,title:"Configuration",description:"Set up connector parameters"}]:s==="fields-only"?[{id:1,title:"Select Fields",description:"Pick specific fields"}]:[{id:1,title:"Select Connector",description:"Choose a data source"},{id:2,title:"Configuration",description:"Set up connector parameters"},{id:3,title:"Select Nodes",description:"Choose data nodes"},{id:4,title:"Select Fields",description:"Pick specific fields"},{id:5,title:"Target Setup",description:"Configure destination"}]).length,se=x.useCallback(async Ht=>{!T.has(Ht)&&!W&&(N(oe=>new Set(oe).add(Ht)),await X(Ht))},[T,W,X]),ae=x.useCallback(async Ht=>{I.has(Ht)||(M(oe=>new Set(oe).add(Ht)),await ne(Ht))},[I,ne]);x.useEffect(()=>{if(!o||d||P.length===0)return;const Ht=P.find(oe=>oe.name===o);Ht&&(u(Ht),C(r??2),se(Ht.name),!t&&s!=="fields-only"&&ae(Ht.name))},[o,P,d,r,t,s,se,ae]),x.useEffect(()=>{if(P.length===0&&!V&&K(),i&&P.length>0&&!d){const{source:Ht,storage:oe}=i;g(Ht.node),b(Ht.fields),L(Ht.configuration[0]||{}),Z({fullyQualifiedName:oe.fullyQualifiedName,isValid:!0});const Ce=P.find(je=>je.name===Ht.name);Ce&&(u(Ce),se(Ce.name),!t&&s!=="fields-only"&&ae(Ce.name),s==="fields-only"&&ae(Ce.name))}if(t&&P.length>0&&!d&&!i){const Ht=P[0];u(Ht),se(Ht.name)}},[s,i,P,t,V,K,se,ae,d]);const Se=Ht=>{u(Ht),L({}),R(!1),c(!0),N(oe=>{const Ce=new Set(oe);return Ce.delete(Ht.name),Ce}),se(Ht.name),ae(Ht.name)},ue=Ht=>{g(Ht),b([]),c(!0)},Re=(Ht,oe)=>{b(oe?Ce=>Ce.includes(Ht)?Ce:[...Ce,Ht]:Ce=>Ce.filter(je=>je!==Ht)),c(!0)},Ve=(Ht,oe)=>{b(oe?Ce=>{const je=Ht.filter(bt=>!Ce.includes(bt));return[...Ce,...je]}:Ce=>Ce.filter(je=>!Ht.includes(je))),c(!0)},Qe=Ht=>{Z(Ht),c(!0)},dt=x.useCallback(Ht=>{L(Ht),c(!0)},[]),yt=x.useCallback(Ht=>{R(Ht)},[]);x.useEffect(()=>{H&&(H.some(oe=>oe.required&&oe.name!=="Fields")||R(!0))},[H]);const fi=()=>{v<ee&&C(v+1)},_i=()=>{v>1&&C(v-1)},Sn=()=>{if(t)return d!==null&&E;if(s==="fields-only")switch(v){case 1:return m.length>0;default:return!1}switch(v){case 1:return d!==null;case 2:return E;case 3:return h!=="";case 4:return m.length>0;case 5:return fe!==null&&fe.fullyQualifiedName!==""&&fe.isValid;default:return!1}},Es=()=>v>1,br=(Ht,oe)=>{if(!Ht)return oe;const Ce=Ht.find(je=>je.name===oe);return(Ce==null?void 0:Ce.destinationName)??oe},hs=()=>{if(t&&v===1)return H&&d?f.jsx(jme,{connector:d,connectorSpecification:H,onConfigurationChange:dt,onValidationChange:yt,initialConfiguration:y,loading:W,isEditingExisting:!!(i!=null&&i.source.configuration.length)}):null;if(s==="fields-only")switch(v){case 1:return d&&h&&j?f.jsx(Hme,{connector:d,connectorFields:j,selectedField:h,selectedFields:m,onFieldToggle:Re,onSelectAllFields:Ve}):null;default:return null}switch(v){case 1:return f.jsx(Mat,{connectors:P,selectedConnector:d,loading:V,error:B,onConnectorSelect:Se,onConnectorDoubleClick:()=>{C(Ht=>Ht<ee?Ht+1:Ht)}});case 2:return d&&H?f.jsx(jme,{connector:d,connectorSpecification:H,onConfigurationChange:dt,onValidationChange:yt,initialConfiguration:y,loading:W,isEditingExisting:!1}):null;case 3:return d&&j?f.jsx(Yat,{connectorFields:j,connector:d,selectedField:h,connectorName:d.displayName,loading:U,onFieldSelect:ue}):null;case 4:return d&&h&&j?f.jsx(Hme,{connector:d,connectorFields:j,selectedField:h,selectedFields:m,onFieldToggle:Re,onSelectAllFields:Ve}):null;case 5:return h&&j?f.jsx(Wlt,{dataStorageType:e,destinationName:br(j,h),connectorName:(d==null?void 0:d.displayName)??"",target:fe,onTargetChange:Qe}):null;default:return null}};return f.jsxs(wst,{children:[f.jsx(yst,{children:hs()}),f.jsx(Sst,{variant:"horizontal",children:f.jsx(Oat,{currentStep:v,totalSteps:ee,canGoNext:Sn(),canGoBack:Es(),isLoading:W||U,onNext:fi,onBack:_i,onFinish:()=>{t&&d?n({source:{name:d.name,configuration:[y],node:(i==null?void 0:i.source.node)??h,fields:(i==null?void 0:i.source.fields)??m},storage:(i==null?void 0:i.storage)??{fullyQualifiedName:(i==null?void 0:i.storage.fullyQualifiedName)??""}}):s==="fields-only"&&i?n({source:{...i.source,fields:m},storage:i.storage}):d&&fe&&n({source:{name:d.name,configuration:[y],node:h,fields:m},storage:{fullyQualifiedName:fe.fullyQualifiedName}}),c(!1)}})})]})}const qTe=20,KTe=20;function ZTe({vertical:n,horizontal:e}){if(window.Intercom)try{const t={};t.vertical_padding=n,t.horizontal_padding=e,Object.keys(t).length>0&&window.Intercom("update",t)}catch(t){console.warn("Failed to update Intercom padding",t)}}function Ult(n=30,e=0){ZTe({vertical:KTe+n,horizontal:qTe+e})}function eZ(){ZTe({vertical:KTe,horizontal:qTe})}function YTe({isOpen:n,onClose:e,dataStorageType:t,onSubmit:i,configurationOnly:s=!1,existingConnector:r=null,mode:o="full",initialStep:a,preselectedConnector:l}){x.useEffect(()=>(n?Ult(55):eZ(),()=>{eZ()}),[n]);const[c,d]=x.useState(!1),[u,h]=x.useState(!1),g=x.useCallback(()=>{u?d(!0):e()},[u,e]),m=x.useCallback(()=>{d(!1),h(!1),e()},[e]),b=x.useCallback(v=>{h(v)},[]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g,children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:o==="fields-only"?"Connector Fields":r!=null&&r.source.name?"Edit Connector":"Set Up Connector"}),f.jsx(cC,{children:o==="fields-only"?"Select fields for your Data Mart":r!=null&&r.source.name?"Update configuration":"Follow these steps to set it up"})]}),f.jsx(zlt,{onSubmit:v=>{i(v),e()},dataStorageType:t,configurationOnly:s||o==="configuration-only",existingConnector:r,mode:o,initialStep:a,preselectedConnector:l,onDirtyChange:b})]})}),f.jsx(Ma,{open:c,onOpenChange:d,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:m,variant:"destructive"})]})}const kre=({dataStorageType:n,onSubmit:e,children:t,configurationOnly:i=!1,existingConnector:s=null,preset:r,isOpen:o,onClose:a})=>{const[l,c]=x.useState(!1),[d,u]=x.useState(1),[h,g]=x.useState();x.useEffect(()=>{o!==void 0&&c(o)},[o]);const m=()=>{g(void 0),u(1),c(!0)},b=()=>{c(!1),a==null||a()};return x.useEffect(()=>{r&&(r==="connector"?(g(void 0),u(1),c(!0)):(g(r),u(2),c(!0)))},[r]),f.jsxs(f.Fragment,{children:[t&&f.jsx("div",{onClick:m,style:{cursor:"pointer"},children:t}),f.jsx(HD,{children:f.jsx(YTe,{isOpen:l,onClose:b,dataStorageType:n,onSubmit:e,configurationOnly:i,existingConnector:s,initialStep:d,preselectedConnector:h})})]})};function $lt({storageType:n,onSetupConnector:e,preset:t,isOpen:i,onClose:s}){return f.jsx(kre,{dataStorageType:n,onSubmit:e,configurationOnly:!1,preset:t,isOpen:i,onClose:s,children:f.jsxs(rt,{type:"button",variant:"outline",className:"flex h-24 w-full cursor-pointer items-center justify-center gap-2 border-0 shadow-none dark:border-transparent dark:bg-transparent dark:hover:bg-white/4",children:[f.jsx("div",{className:"text-foreground flex h-7 w-7 items-center justify-center rounded-sm bg-gray-200/50 transition-colors duration-200 group-hover:bg-gray-200/75 dark:bg-white/8 dark:group-hover:bg-white/10",children:f.jsx(Fne,{className:"h-4 w-4",strokeWidth:2.25})}),f.jsx("span",{children:"Setup Connector"}),f.jsx($d,{className:"h-6 w-6"})]})})}const Glt=n=>{switch(n){case lt.GOOGLE_BIGQUERY:return"Google BigQuery";case lt.AWS_ATHENA:return"AWS Athena";case lt.SNOWFLAKE:return"Snowflake";default:return n}},kL=n=>typeof n=="object"&&"connector"in n,wT=n=>{if(!kL(n))return!1;const{source:e,storage:t}=n.connector,i=!!e.name&&!!e.configuration&&e.configuration.length>0&&!!e.node&&!!e.fields&&e.fields.length>0,s=t.fullyQualifiedName.split("."),r=s.length===2||s.length===3;return i&&r};function qlt({configIndex:n,connectorDef:e,onRemoveConfiguration:t,onUpdateConfiguration:i,totalConfigurations:s,dataStorage:r}){const o=fC.getInfo(r.type),{connectors:a,fetchAvailableConnectors:l}=US();x.useEffect(()=>{l()},[l]);const c=m=>{const b=a.find(v=>v.name===m);if(b!=null&&b.logoBase64)return()=>f.jsx(VS,{base64:b.logoBase64,size:24})},d=()=>{const m=e.connector.source.node||"No node selected";return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"text-muted-foreground/75",children:"Data:"})," ",f.jsx("span",{className:"text-muted-foreground font-medium",children:m}),f.jsx("span",{className:"text-muted-foreground",children:"•"}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("span",{className:"text-muted-foreground flex items-center gap-1 font-medium",children:[f.jsx("span",{children:"Edit config"}),f.jsx($d,{className:"h-3 w-3"})]})}),f.jsx(kn,{children:"Edit connector configuration"})]})]})},u=(m,b,v)=>f.jsxs("span",{children:[f.jsxs("span",{className:"text-muted-foreground/75",children:[m,":"]})," ",f.jsx(ir,{href:v,onClick:C=>{C.stopPropagation()},children:b})]}),h=()=>{switch(r.type){case lt.GOOGLE_BIGQUERY:{const m=r.config.projectId,b=e.connector.storage.fullyQualifiedName,v=b.split(".")[0],C=b.split(".")[1],y=`https://console.cloud.google.com/bigquery?project=${m}&ws=!1m4!1m3!3m2!1s${m}!2s${v}`,L=`https://console.cloud.google.com/bigquery?project=${m}&ws=!1m4!1m3!3m2!1s${m}!2s${v}!3s${C}`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Dataset",v,y),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",C,L),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The dataset and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case lt.AWS_ATHENA:{const m=r.config.region,b=e.connector.storage.fullyQualifiedName,[v,C]=b.split("."),y=`https://console.aws.amazon.com/athena/home?region=${m}#/query-editor`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Database",v,y),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",C,y),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The database and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case lt.SNOWFLAKE:{const m=r.config.account,v=e.connector.storage.fullyQualifiedName.split("."),C=v[0],y=v[1],L=v[2],E=`https://${m}.snowflakecomputing.com`,R=`${E}/#/data/databases/${C}`,T=`${E}/#/data/databases/${C}/schemas/${y}`,N=`${E}/#/data/databases/${C}/schemas/${y}/table/${L}`;return f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u("Database",C,R),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Schema",jF(y),T),f.jsx("span",{className:"text-muted-foreground",children:"•"}),u("Table",jF(L),N),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(sc,{className:"h-4 w-4"})}),f.jsx(kn,{children:"The database, schema and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}default:return"Unknown storage type configuration"}},g=()=>s!==1;return f.jsxs("div",{className:"border-border flex w-full items-center rounded-lg border-1 p-1 dark:bg-white/2",children:[f.jsx("div",{className:"flex-grow",children:f.jsxs("div",{className:"grid grid-cols-2 items-center gap-4",children:[f.jsx(kre,{dataStorageType:r.type,onSubmit:i(n),configurationOnly:!0,existingConnector:{source:{...e.connector.source,configuration:[e.connector.source.configuration[n]]},storage:e.connector.storage},children:f.jsx(GK,{icon:c(e.connector.source.name),title:e.connector.source.name||"Connector",subtitle:d(),className:"bg-background hover:bg-muted min-h-[80px] cursor-pointer border-0 transition-colors hover:shadow-none"})}),f.jsx(GK,{title:Glt(r.type),icon:o.icon,subtitle:h(),className:"bg-background min-h-[80px] cursor-default border-0 hover:shadow-none dark:bg-white/2"})]})}),f.jsx("div",{className:"shrink-0 px-4",children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{children:f.jsx(rt,{type:"button",variant:"ghost",onClick:()=>{g()&&t(n)},disabled:!g(),children:f.jsx(Wh,{className:"h-4 w-4"})})})}),!g()&&f.jsx(kn,{children:"Remove last configuration only after adding a new one."})]})})]})}function Klt({storageType:n,onAddConfiguration:e,existingConnector:t}){return f.jsx("div",{children:f.jsx(kre,{dataStorageType:n,onSubmit:i=>{const s=i.source.configuration[0]||{};e(s)},configurationOnly:!0,existingConnector:t?{source:{...t.source,configuration:[]},storage:t.storage}:void 0,children:f.jsxs(rt,{type:"button",variant:"outline",className:"dm-card-table-add-field-btn cursor-pointer",children:[f.jsx(Gd,{className:"h-4 w-4"}),f.jsx("span",{children:"Configuration"})]})})})}function Zlt({control:n,storageType:e,preset:t,autoOpen:i=!1,saveDataMartDefinition:s}){const{dataMart:r,runDataMart:o}=Zu(),{setValue:a,getValues:l,trigger:c}=VR(),[d,u]=x.useState(!1),[h,g]=x.useState(!1);x.useEffect(()=>{i&&g(!0)},[i]);const m=(r==null?void 0:r.status)??Ll.DRAFT,b=async W=>{a("definition",W,{shouldDirty:!0,shouldTouch:!0}),await c("definition")&&s&&s()},v=async W=>{const U=W.source,B=W.storage;await b({connector:{source:U,storage:B}})},C=async W=>{if(r){if(r.status.code!==Ll.PUBLISHED){Rn.error("Manual run is only available for published data marts");return}await o({id:r.id,payload:W})}},y=W=>async U=>{const K=l().definition;if(typeof K=="object"&&kL(K)){const X=[...K.connector.source.configuration];X[W]=U.source.configuration[0]||{};const ne={connector:{...K.connector,source:{...K.connector.source,configuration:X}}};await b(ne)}},L=async W=>{const B=l().definition;if(typeof B=="object"&&kL(B)){const K={connector:{...B.connector,source:{...B.connector.source,fields:W.source.fields}}};await b(K)}u(!1)},E=W=>{C({runType:W.runType,data:W.data})},R=W=>{const U=W.connector.source.fields.length;return f.jsxs(rt,{type:"button",variant:"outline",onClick:()=>{u(!0)},className:"dm-card-table-add-field-btn cursor-pointer",children:[f.jsx(VBe,{className:"h-4 w-4"}),f.jsxs("span",{children:["Edit Fields (",String(U),")"]})]})},[T,N]=x.useState(null),[I,M]=x.useState(!1),P=W=>{N(W),M(!0)},H=async()=>{T!==null&&(await j(T),N(null),M(!1))},j=async W=>{const B=l().definition;if(kL(B)&&B.connector.source.configuration.length<=1){const K=Ere(Yt.CONNECTOR);await b(K)}if(typeof B=="object"&&kL(B)&&B.connector.source.configuration.length>1){const K={...B.connector.source,configuration:B.connector.source.configuration.filter((ne,fe)=>fe!==W)},X={connector:{...B.connector,source:K}};await b(X)}},V=async W=>{const B=l().definition;if(kL(B)){const K={...B.connector.source,configuration:[...B.connector.source.configuration,W]},X={connector:{...B.connector,source:K}};await b(X)}};return f.jsxs(f.Fragment,{children:[f.jsx(fn,{control:n,name:"definition",render:({field:W})=>f.jsxs(tn,{className:"dark:bg-white/2",children:[f.jsx(cn,{children:f.jsx("div",{className:"space-y-3",children:!wT(W.value)||m===Ll.DRAFT?f.jsx($lt,{storageType:e,onSetupConnector:U=>{v(U),g(!1)},preset:t,isOpen:h,onClose:()=>{g(!1)}}):f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Klt,{storageType:e,onAddConfiguration:U=>void V(U),existingConnector:wT(W.value)?{source:W.value.connector.source,storage:W.value.connector.storage}:void 0}),wT(W.value)&&R(W.value)]}),f.jsx("div",{className:"flex items-center gap-2",children:r&&r.definitionType===Yt.CONNECTOR&&f.jsx(JNe,{configuration:r.definition,onManualRun:E,children:f.jsxs(rt,{variant:"outline",children:[f.jsx(rH,{className:"h-4 w-4"}),f.jsx("span",{children:"Manual Run..."})]})})})]}),f.jsx("div",{className:"space-y-3",children:wT(W.value)&&(r!=null&&r.storage)?W.value.connector.source.configuration.map((U,B)=>{const K=W.value;return f.jsx(HD,{children:f.jsx(qlt,{configIndex:B,connectorDef:K,dataStorage:r.storage,onRemoveConfiguration:X=>{P(X)},onUpdateConfiguration:X=>y(X),dataMartStatus:typeof m=="object"?m.code:m,totalConfigurations:K.connector.source.configuration.length},B)},B)}):null})]})})}),f.jsx(Cn,{})]})}),f.jsx(HD,{children:f.jsx(YTe,{isOpen:d,onClose:()=>{u(!1)},onSubmit:W=>void L(W),dataStorageType:e,existingConnector:wT(l().definition)?{source:l().definition.connector.source,storage:l().definition.connector.storage}:void 0,mode:"fields-only"})}),f.jsx(Ma,{open:I,onOpenChange:M,title:"Delete Configuration",description:"Are you sure you want to delete this configuration? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{H()},onCancel:()=>{N(null)},variant:"destructive"})]})}function Ylt({definitionType:n,storageType:e,preset:t,saveDataMartDefinition:i}){const{control:s}=VR(),[r,o]=x.useState(!1);return x.useEffect(()=>{n===Yt.CONNECTOR&&!t?o(!0):o(!1)},[n,t]),f.jsxs("div",{className:"space-y-2",children:[n===Yt.SQL&&f.jsx(Nat,{control:s}),n===Yt.TABLE&&f.jsx(Tat,{control:s,storageType:e}),n===Yt.VIEW&&f.jsx(Iat,{control:s,storageType:e}),n===Yt.TABLE_PATTERN&&f.jsx(kat,{control:s,storageType:e}),n===Yt.CONNECTOR&&f.jsx(Zlt,{control:s,storageType:e,preset:t,autoOpen:r,saveDataMartDefinition:i})]})}function XTe(){const[n]=Uje(),e=n.get("preset");return x.useMemo(()=>{if(!e)return;const t=e.toLowerCase();return Ntt(t)},[e])}function Xlt(n,e){const[t,i]=x.useState(n);return x.useEffect(()=>{const s=setTimeout(()=>{i(n)},e);return()=>{clearTimeout(s)}},[n,e]),t}const Qlt=1e3,Jlt=[Au.SUCCESS,Au.ERROR,Au.CANCELLED];function ect(n){const[e,t]=x.useState(!1),[i,s]=x.useState(null),r=x.useRef({triggerId:null,abortController:null}),o=x.useCallback(u=>r.current.triggerId===u,[]),a=x.useCallback(u=>{s({isValid:!1,error:u instanceof Error?u.message:"Validation failed"}),t(!1)},[]),l=x.useCallback(async()=>{const{triggerId:u,abortController:h}=r.current;if(u){h==null||h.abort(),r.current={triggerId:null,abortController:null},s(null),t(!1);try{await hr.abortSqlDryRunTrigger(n,u)}catch(g){console.error("Failed to cancel trigger:",g)}}},[n]),c=x.useCallback(async(u,h)=>{for(;!h.aborted&&o(u);)try{const g=await hr.getSqlDryRunTriggerStatus(n,u);if(Jlt.includes(g)){const m=await hr.getSqlDryRunTriggerResponse(n,u);s({isValid:m.isValid,error:m.error??void 0,bytes:m.bytes}),t(!1),r.current={triggerId:null,abortController:null};return}await new Promise(m=>setTimeout(m,Qlt))}catch(g){a(g),r.current={triggerId:null,abortController:null};return}},[n,o,a]),d=x.useCallback(async u=>{await l(),t(!0),s(null);try{const{triggerId:h}=await hr.createSqlDryRunTrigger(n,u),g=new AbortController;r.current={triggerId:h,abortController:g},await c(h,g.signal)}catch(h){a(h)}},[n,l,c,a]);return x.useEffect(()=>()=>{const{triggerId:u,abortController:h}=r.current;h==null||h.abort(),u&&hr.abortSqlDryRunTrigger(n,u).catch(()=>{})},[n]),{validateSql:d,isLoading:e,result:i,cancel:l}}const tct=300;function ict({sql:n,dataMartId:e,debounceDelay:t=tct,className:i="",onValidationStateChange:s}){const r=Xlt(n.trim(),t),{validateSql:o,isLoading:a,result:l,cancel:c}=ect(e);x.useEffect(()=>{if(!r){c();const u={isLoading:!1,isValid:null,error:null,bytes:null};s==null||s(u);return}o(r)},[r,o,c,s]),x.useEffect(()=>{const u={isLoading:a,isValid:(l==null?void 0:l.isValid)??null,error:(l==null?void 0:l.error)??null,bytes:(l==null?void 0:l.bytes)??null};s==null||s(u)},[a,l,s]);const d=()=>a?f.jsxs("div",{className:"flex h-5 items-center gap-2",children:[f.jsx(NR,{className:"h-4 w-4 animate-spin"}),f.jsx("span",{className:"text-sm",children:"Validating..."})]}):l?l.isValid?f.jsxs("div",{className:"flex h-5 items-center gap-2",children:[f.jsx(zHe,{className:"h-4 w-4 text-green-600"}),f.jsx("span",{className:"text-sm font-medium text-green-600",children:"Valid SQL code"}),l.bytes!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-1 text-gray-400",children:"•"}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(j1,{className:"h-3 w-3 text-gray-600"}),f.jsx("span",{className:"text-xs text-gray-600",children:yit(l.bytes)})]})}),f.jsx(kn,{children:f.jsx("p",{className:"text-xs",children:"This is an estimated volume and may differ from the actual value"})})]})]})]}):f.jsxs("div",{className:"flex h-9 items-center gap-2",children:[f.jsx(rF,{className:"h-4 w-4 flex-shrink-0 text-red-600"}),l.error&&f.jsx("span",{className:"text-xs text-red-500",children:l.error})]}):f.jsxs("div",{className:"flex h-5 items-center gap-2 text-gray-500",children:[f.jsx(j1,{className:"h-4 w-4"}),f.jsx("span",{className:"text-sm",children:"Type a query to get started"})]});return f.jsx("div",{className:`inline-flex h-9 items-center px-3 py-2 ${i}`,children:d()})}const nct={isValid:null,isLoading:!1,error:null},sct=(n,e)=>{if(n!==Yt.SQL)return"";const t=e;return(t==null?void 0:t.sqlQuery)??""},rct=n=>Ere(n);function oct({definitionType:n,initialDefinitionType:e,setDefinitionType:t}){const{dataMart:i,updateDataMartDefinition:s,runSchemaActualization:r}=Zu(),o=XTe();if(!i)throw new Error("Data mart not found");const{definition:a,id:l,storage:{type:c}}=i,[,d]=x.useState(nct),[u,h]=x.useState(!1),g=x.useCallback(()=>{if(!n)return;const V={definitionType:n,definition:Ere(n)};return a?{definitionType:n,definition:a}:V},[n,a]),m=x.useCallback(()=>{if(!n)return;const V=Rat(n,c);return pb(V)},[n,c]),b=Bp({resolver:m(),defaultValues:g(),mode:"onChange"}),{handleSubmit:v,reset:C,watch:y,formState:{isDirty:L,isValid:E}}=b,R=y("definition"),T=sct(n,R);x.useEffect(()=>{n&&C(g())},[n,C,g]),x.useEffect(()=>{if(!n&&!e&&(o!=null&&o.definitionType)){t(o.definitionType);const V={definitionType:o.definitionType,definition:rct(o.definitionType)};C(V)}},[o,n,e,C,t]);const N=x.useCallback(V=>{d({isLoading:V.isLoading,isValid:V.isValid,error:V.error})},[]),I=x.useCallback(V=>{t(V)},[t]),M=x.useCallback(async V=>{if(n&&l)try{await s(l,V.definitionType,V.definition),h(!0),C(V)}catch(W){console.error("Failed to update data mart definition:",W)}},[l,n,s,C]);x.useEffect(()=>{u&&(h(!1),r==null||r())},[u,r]);const P=x.useCallback(V=>{V==null||V.preventDefault(),v(M)(V)},[v,M]),H=x.useCallback(()=>{C(g())},[C,g]),j=()=>n?f.jsxs("form",{onSubmit:P,className:"space-y-4",children:[f.jsx(Ylt,{definitionType:n,storageType:c,preset:o==null?void 0:o.connectorSourceTitle,saveDataMartDefinition:P}),n!==Yt.CONNECTOR&&f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(rt,{variant:"default",type:"submit",disabled:!E||!L,children:"Save"}),f.jsx(rt,{type:"button",variant:"ghost",onClick:H,disabled:!L,children:"Discard"}),n===Yt.SQL&&T&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"h-6 w-px bg-gray-300"}),f.jsx(ict,{sql:T,dataMartId:l,onValidationStateChange:N})]})]})]}):null;return f.jsx(NRe,{...b,children:f.jsxs("div",{className:"space-y-4",children:[!e&&f.jsx(yat,{initialType:n,onTypeSelect:I}),j()]})})}function act(n){switch(n){case lt.GOOGLE_BIGQUERY:return{type:"bigquery-data-mart-schema",fields:[]};case lt.AWS_ATHENA:return{type:"athena-data-mart-schema",fields:[]};case lt.SNOWFLAKE:return{type:"snowflake-data-mart-schema",fields:[]};default:throw new Error(`Unsupported storage type: ${n}`)}}function QTe(n){return n.type==="bigquery-data-mart-schema"}function JTe(n){return n.type==="athena-data-mart-schema"}function eIe(n){return n.type==="snowflake-data-mart-schema"}function Vme(n){return n!==null&&typeof n=="object"&&"mode"in n}function Wme(n){return n!==null&&typeof n=="object"&&"isPrimaryKey"in n}function zme(n){return n!==null&&typeof n=="object"&&"isPrimaryKey"in n&&!("mode"in n)}function lct(n){return n==null?"":typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):""}function r$(n){return n==null?n:JSON.parse(JSON.stringify(n))}function cct(n){const e=r$(n),[t,i]=x.useState(e),[s,r]=x.useState(!1);x.useEffect(()=>{const l=r$(n);i(l),r(!1)},[n]);const o=x.useCallback(l=>{t?QTe(t)&&l.every(Vme)?(i({...t,fields:l}),r(!0)):JTe(t)&&l.every(Wme)?(i({...t,fields:l}),r(!0)):eIe(t)&&l.every(zme)&&(i({...t,fields:l}),r(!0)):l.length>0&&(Vme(l[0])?(i({type:"bigquery-data-mart-schema",fields:l}),r(!0)):Wme(l[0])?(i({type:"athena-data-mart-schema",fields:l}),r(!0)):zme(l[0])&&(i({type:"snowflake-data-mart-schema",fields:l}),r(!0)))},[t]),a=x.useCallback(()=>{const l=r$(n);i(l),r(!1)},[n]);return{schema:t,isDirty:s,updateSchema:o,resetSchema:a,setIsDirty:r}}function dct(n,e){const t=x.useRef(!1),i=x.useRef(!1),[s,r]=x.useState("idle");return x.useEffect(()=>{n||(t.current||i.current)&&(r(e?"error":"success"),t.current=!1,i.current=!1)},[n,e]),{operationStatus:s,startSaveOperation:()=>{t.current=!0,r("idle")},startActualizeOperation:()=>{i.current=!0,r("idle")},resetOperationStatus:()=>{r("idle")}}}function uct(n){const e=x.useMemo(()=>Array.isArray(n)?Object.fromEntries(n.filter(s=>s.meta&&s.meta.hidden).map(s=>["id"in s&&s.id?s.id:"accessorKey"in s&&typeof s.accessorKey=="string"?s.accessorKey:void 0,!1]).filter(([s])=>s!==void 0)):{},[n]),[t,i]=x.useState({});return x.useEffect(()=>{i(e)},[e]),{columnVisibility:t,setColumnVisibility:i,defaultHiddenColumns:e}}function tIe(n,e){const t=n.name?n.name.toLowerCase().includes(e):!1,i=n.alias?n.alias.toLowerCase().includes(e):!1,s=n.description?n.description.toLowerCase().includes(e):!1;if(t||i||s)return!0;const r=n;return r.fields&&r.fields.length>0?r.fields.some(o=>tIe(o,e)):!1}function iIe(n,e,t=""){const i=[];return n.forEach((s,r)=>{const o=t?`${t}.${String(r)}`:String(r),a=s.name?s.name.toLowerCase().includes(e):!1,l=s.alias?s.alias.toLowerCase().includes(e):!1,c=s.description?s.description.toLowerCase().includes(e):!1;if((a||l||c)&&i.push(o),s.fields&&s.fields.length>0){const d=iIe(s.fields,e,o);d.length>0&&(i.includes(o)||i.push(o),i.push(...d))}}),i}function hct(n,e,t){const i=n.original;if(!t)return!0;const s=t.toLowerCase();return tIe(i,s)}function fct(n){const[e,t]=x.useState(""),i=x.useCallback(r=>{t(r),n.setGlobalFilter(r)},[n]),s=e.toLowerCase();return{value:e,onChange:i,searchValue:s}}function gct(n){const[e,t]=x.useState(new Set),[i,s]=x.useState(null),r=x.useRef(""),o=x.useMemo(()=>{const m=b=>b.some(v=>v.type===Ho.RECORD||v.type===Ho.STRUCT||v.fields&&m(v.fields));return m(n)},[n]),a=x.useCallback(m=>{t(b=>{const v=new Set(b);return v.has(m)?v.delete(m):v.add(m),v})},[]),l=x.useCallback(()=>{const m=[],b=(v,C="")=>{v.forEach((y,L)=>{const E=C?`${C}.${String(L)}`:String(L);(y.type===Ho.RECORD||y.type===Ho.STRUCT)&&y.fields&&y.fields.length>0&&(m.push(E),b(y.fields,E))})};b(n),t(v=>m.every(y=>v.has(y))?new Set:new Set(m))},[n]),c=x.useMemo(()=>{const m=[],b=(v,C="",y=0)=>{v.forEach((L,E)=>{const R=C?`${C}.${String(E)}`:String(E),T=L.type===Ho.RECORD||L.type===Ho.STRUCT;m.push({...L,path:R,level:y}),T&&L.fields&&e.has(R)&&b(L.fields,R,y+1)})};return b(n),m},[n,e]),d=x.useCallback(m=>{if(m!==r.current)if(r.current=m,m){i===null&&s(new Set(e));const v=iIe(n,m).filter(C=>{const y=C.split(".").map(Number);let L=n,E;for(let R=0;R<y.length;R++){if(E=L[y[R]],!E)return!1;if((E.type===Ho.RECORD||E.type===Ho.STRUCT)&&E.fields&&E.fields.length>0)return!0;R<y.length-1&&(L=E.fields??[])}return!1});t(C=>{const y=new Set(C);return v.forEach(L=>{y.add(L)}),y})}else i!==null&&(t(i),s(null))},[n,e,i]),u=x.useCallback(m=>{const b=c[m];return b.type===Ho.RECORD||b.type===Ho.STRUCT},[c]),h=x.useMemo(()=>n.map(m=>({...m,fields:void 0})),[n]),g=x.useMemo(()=>{const m=[],b=(v,C="")=>{v.forEach((y,L)=>{const E=C?`${C}.${String(L)}`:String(L);(y.type===Ho.RECORD||y.type===Ho.STRUCT)&&y.fields&&y.fields.length>0&&(m.push(E),b(y.fields,E))})};return b(n),m.length===0?!1:m.every(v=>e.has(v))},[n,e]);return{expandedRecords:e,hasRecordFields:o,toggleRecordExpansion:a,toggleAllRecords:l,flattenedFields:c,handleSearchChange:d,isRecordType:u,topLevelFields:h,allExpanded:g}}function pct(n,e,t,i){const s=x.useCallback((l,c)=>{if(t){const d=[...n],u=e[l].path;if(!u)d[l]={...d[l],...c};else{const h=u.split(".").map(Number);let g=d,m;for(let v=0;v<h.length-1;v++)m=g[h[v]],g=m.fields??[];const b=h[h.length-1];g[b]&&(g[b]={...g[b],...c})}t(d)}},[n,e,t]),r=x.useCallback(()=>{if(t){const l={name:"",type:Ho.STRING,mode:d2.NULLABLE,isPrimaryKey:!1,status:Mu.DISCONNECTED};t([...n,l])}},[n,t]),o=x.useCallback(l=>{if(t){const c=[...n],d=e[l].path;if(!d)c.splice(l,1);else{const u=d.split(".").map(Number);let h=c,g;for(let b=0;b<u.length-1;b++)g=h[u[b]],h=g.fields??[];const m=u[u.length-1];h.splice(m,1)}t(c)}},[n,e,t]),a=x.useCallback(l=>{var c,d;if(t&&i){const u=[...n],h=e[l].path,g={name:"",type:Ho.STRING,mode:d2.NULLABLE,isPrimaryKey:!1,status:Mu.DISCONNECTED};if(!h)(c=u[l]).fields??(c.fields=[]),u[l].fields.push(g);else{const m=h.split(".").map(Number);let b=u;for(let v=0;v<m.length;v++){const C=m[v];v===m.length-1?((d=b[C]).fields??(d.fields=[]),b[C].fields.push(g)):b=b[C].fields??[]}}t(u)}},[n,e,t,i]);return{updateField:s,handleAddRow:r,handleDeleteRow:o,handleAddNestedField:a}}function Are(n,e,t){return{handleDragEnd:x.useCallback(s=>{const{active:r,over:o}=s;if(!o||r.id===o.id||!e)return;if(!t){const h=Number(r.id),g=Number(o.id),m=[...n],[b]=m.splice(h,1);m.splice(g,0,b),e(m);return}const a=t.findIndex((h,g)=>(h.path??String(g))===r.id),l=t.findIndex((h,g)=>(h.path??String(g))===o.id);if(a===-1||l===-1)return;const c=t[a].path,d=t[l].path,u=[...n];if(!c&&!d){const[h]=u.splice(a,1);u.splice(l,0,h),e(u);return}if(c&&d){const h=c.split(".").map(Number),g=d.split(".").map(Number);if(h.length===g.length&&h.slice(0,-1).join(".")===g.slice(0,-1).join(".")){let m=u;for(let y=0;y<h.length-1;y++)m=m[h[y]].fields??[];const b=h[h.length-1],v=g[g.length-1],[C]=m.splice(b,1);m.splice(v,0,C),e(u)}}},[n,t,e])}}function mct(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return x.useMemo(()=>i=>{e.forEach(s=>s(i))},e)}const sB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function UR(n){const e=Object.prototype.toString.call(n);return e==="[object Window]"||e==="[object global]"}function Mre(n){return"nodeType"in n}function qd(n){var e,t;return n?UR(n)?n:Mre(n)&&(e=(t=n.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function Ore(n){const{Document:e}=qd(n);return n instanceof e}function VM(n){return UR(n)?!1:n instanceof qd(n).HTMLElement}function nIe(n){return n instanceof qd(n).SVGElement}function $R(n){return n?UR(n)?n.document:Mre(n)?Ore(n)?n:VM(n)||nIe(n)?n.ownerDocument:document:document:document}const Sp=sB?x.useLayoutEffect:x.useEffect;function Pre(n){const e=x.useRef(n);return Sp(()=>{e.current=n}),x.useCallback(function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.current==null?void 0:e.current(...i)},[])}function _ct(){const n=x.useRef(null),e=x.useCallback((i,s)=>{n.current=setInterval(i,s)},[]),t=x.useCallback(()=>{n.current!==null&&(clearInterval(n.current),n.current=null)},[]);return[e,t]}function f2(n,e){e===void 0&&(e=[n]);const t=x.useRef(n);return Sp(()=>{t.current!==n&&(t.current=n)},e),t}function WM(n,e){const t=x.useRef();return x.useMemo(()=>{const i=n(t.current);return t.current=i,i},[...e])}function HF(n){const e=Pre(n),t=x.useRef(null),i=x.useCallback(s=>{s!==t.current&&(e==null||e(s,t.current)),t.current=s},[]);return[t,i]}function tZ(n){const e=x.useRef();return x.useEffect(()=>{e.current=n},[n]),e.current}let o$={};function zM(n,e){return x.useMemo(()=>{if(e)return e;const t=o$[n]==null?0:o$[n]+1;return o$[n]=t,n+"-"+t},[n,e])}function sIe(n){return function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return i.reduce((r,o)=>{const a=Object.entries(o);for(const[l,c]of a){const d=r[l];d!=null&&(r[l]=d+n*c)}return r},{...e})}}const FE=sIe(1),BF=sIe(-1);function bct(n){return"clientX"in n&&"clientY"in n}function Fre(n){if(!n)return!1;const{KeyboardEvent:e}=qd(n.target);return e&&n instanceof e}function vct(n){if(!n)return!1;const{TouchEvent:e}=qd(n.target);return e&&n instanceof e}function iZ(n){if(vct(n)){if(n.touches&&n.touches.length){const{clientX:e,clientY:t}=n.touches[0];return{x:e,y:t}}else if(n.changedTouches&&n.changedTouches.length){const{clientX:e,clientY:t}=n.changedTouches[0];return{x:e,y:t}}}return bct(n)?{x:n.clientX,y:n.clientY}:null}const g2=Object.freeze({Translate:{toString(n){if(!n)return;const{x:e,y:t}=n;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(n){if(!n)return;const{scaleX:e,scaleY:t}=n;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(n){if(n)return[g2.Translate.toString(n),g2.Scale.toString(n)].join(" ")}},Transition:{toString(n){let{property:e,duration:t,easing:i}=n;return e+" "+t+"ms "+i}}}),Ume="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Cct(n){return n.matches(Ume)?n:n.querySelector(Ume)}const wct={display:"none"};function yct(n){let{id:e,value:t}=n;return nt.createElement("div",{id:e,style:wct},t)}function Sct(n){let{id:e,announcement:t,ariaLiveType:i="assertive"}=n;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return nt.createElement("div",{id:e,style:s,role:"status","aria-live":i,"aria-atomic":!0},t)}function xct(){const[n,e]=x.useState("");return{announce:x.useCallback(i=>{i!=null&&e(i)},[]),announcement:n}}const rIe=x.createContext(null);function Lct(n){const e=x.useContext(rIe);x.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(n)},[n,e])}function Ect(){const[n]=x.useState(()=>new Set),e=x.useCallback(i=>(n.add(i),()=>n.delete(i)),[n]);return[x.useCallback(i=>{let{type:s,event:r}=i;n.forEach(o=>{var a;return(a=o[s])==null?void 0:a.call(o,r)})},[n]),e]}const Dct={draggable:`
|
|
735
735
|
To pick up a draggable item, press the space bar.
|
|
736
736
|
While dragging, use the arrow keys to move the item.
|
|
737
737
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
738
738
|
`},Rct={onDragStart(n){let{active:e}=n;return"Picked up draggable item "+e.id+"."},onDragOver(n){let{active:e,over:t}=n;return t?"Draggable item "+e.id+" was moved over droppable area "+t.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(n){let{active:e,over:t}=n;return t?"Draggable item "+e.id+" was dropped over droppable area "+t.id:"Draggable item "+e.id+" was dropped."},onDragCancel(n){let{active:e}=n;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Nct(n){let{announcements:e=Rct,container:t,hiddenTextDescribedById:i,screenReaderInstructions:s=Dct}=n;const{announce:r,announcement:o}=xct(),a=zM("DndLiveRegion"),[l,c]=x.useState(!1);if(x.useEffect(()=>{c(!0)},[]),Lct(x.useMemo(()=>({onDragStart(u){let{active:h}=u;r(e.onDragStart({active:h}))},onDragMove(u){let{active:h,over:g}=u;e.onDragMove&&r(e.onDragMove({active:h,over:g}))},onDragOver(u){let{active:h,over:g}=u;r(e.onDragOver({active:h,over:g}))},onDragEnd(u){let{active:h,over:g}=u;r(e.onDragEnd({active:h,over:g}))},onDragCancel(u){let{active:h,over:g}=u;r(e.onDragCancel({active:h,over:g}))}}),[r,e])),!l)return null;const d=nt.createElement(nt.Fragment,null,nt.createElement(yct,{id:i,value:s.draggable}),nt.createElement(Sct,{id:a,announcement:o}));return t?Rf.createPortal(d,t):d}var Ea;(function(n){n.DragStart="dragStart",n.DragMove="dragMove",n.DragEnd="dragEnd",n.DragCancel="dragCancel",n.DragOver="dragOver",n.RegisterDroppable="registerDroppable",n.SetDroppableDisabled="setDroppableDisabled",n.UnregisterDroppable="unregisterDroppable"})(Ea||(Ea={}));function VF(){}function jre(n,e){return x.useMemo(()=>({sensor:n,options:e??{}}),[n,e])}function Hre(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return x.useMemo(()=>[...e].filter(i=>i!=null),[...e])}const Uf=Object.freeze({x:0,y:0});function Tct(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function Ict(n,e){let{data:{value:t}}=n,{data:{value:i}}=e;return t-i}function kct(n,e){let{data:{value:t}}=n,{data:{value:i}}=e;return i-t}function Act(n,e){if(!n||n.length===0)return null;const[t]=n;return t[e]}function $me(n,e,t){return e===void 0&&(e=n.left),t===void 0&&(t=n.top),{x:e+n.width*.5,y:t+n.height*.5}}const Bre=n=>{let{collisionRect:e,droppableRects:t,droppableContainers:i}=n;const s=$me(e,e.left,e.top),r=[];for(const o of i){const{id:a}=o,l=t.get(a);if(l){const c=Tct($me(l),s);r.push({id:a,data:{droppableContainer:o,value:c}})}}return r.sort(Ict)};function Mct(n,e){const t=Math.max(e.top,n.top),i=Math.max(e.left,n.left),s=Math.min(e.left+e.width,n.left+n.width),r=Math.min(e.top+e.height,n.top+n.height),o=s-i,a=r-t;if(i<s&&t<r){const l=e.width*e.height,c=n.width*n.height,d=o*a,u=d/(l+c-d);return Number(u.toFixed(4))}return 0}const Oct=n=>{let{collisionRect:e,droppableRects:t,droppableContainers:i}=n;const s=[];for(const r of i){const{id:o}=r,a=t.get(o);if(a){const l=Mct(a,e);l>0&&s.push({id:o,data:{droppableContainer:r,value:l}})}}return s.sort(kct)};function Pct(n,e,t){return{...n,scaleX:e&&t?e.width/t.width:1,scaleY:e&&t?e.height/t.height:1}}function oIe(n,e){return n&&e?{x:n.left-e.left,y:n.top-e.top}:Uf}function Fct(n){return function(t){for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];return s.reduce((o,a)=>({...o,top:o.top+n*a.y,bottom:o.bottom+n*a.y,left:o.left+n*a.x,right:o.right+n*a.x}),{...t})}}const jct=Fct(1);function Hct(n){if(n.startsWith("matrix3d(")){const e=n.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(n.startsWith("matrix(")){const e=n.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Bct(n,e,t){const i=Hct(e);if(!i)return n;const{scaleX:s,scaleY:r,x:o,y:a}=i,l=n.left-o-(1-s)*parseFloat(t),c=n.top-a-(1-r)*parseFloat(t.slice(t.indexOf(" ")+1)),d=s?n.width/s:n.width,u=r?n.height/r:n.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}const Vct={ignoreTransform:!1};function GR(n,e){e===void 0&&(e=Vct);let t=n.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:d}=qd(n).getComputedStyle(n);c&&(t=Bct(t,c,d))}const{top:i,left:s,width:r,height:o,bottom:a,right:l}=t;return{top:i,left:s,width:r,height:o,bottom:a,right:l}}function Gme(n){return GR(n,{ignoreTransform:!0})}function Wct(n){const e=n.innerWidth,t=n.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}function zct(n,e){return e===void 0&&(e=qd(n).getComputedStyle(n)),e.position==="fixed"}function Uct(n,e){e===void 0&&(e=qd(n).getComputedStyle(n));const t=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const r=e[s];return typeof r=="string"?t.test(r):!1})}function Vre(n,e){const t=[];function i(s){if(e!=null&&t.length>=e||!s)return t;if(Ore(s)&&s.scrollingElement!=null&&!t.includes(s.scrollingElement))return t.push(s.scrollingElement),t;if(!VM(s)||nIe(s)||t.includes(s))return t;const r=qd(n).getComputedStyle(s);return s!==n&&Uct(s,r)&&t.push(s),zct(s,r)?t:i(s.parentNode)}return n?i(n):t}function aIe(n){const[e]=Vre(n,1);return e??null}function a$(n){return!sB||!n?null:UR(n)?n:Mre(n)?Ore(n)||n===$R(n).scrollingElement?window:VM(n)?n:null:null}function lIe(n){return UR(n)?n.scrollX:n.scrollLeft}function cIe(n){return UR(n)?n.scrollY:n.scrollTop}function nZ(n){return{x:lIe(n),y:cIe(n)}}var Za;(function(n){n[n.Forward=1]="Forward",n[n.Backward=-1]="Backward"})(Za||(Za={}));function dIe(n){return!sB||!n?!1:n===document.scrollingElement}function uIe(n){const e={x:0,y:0},t=dIe(n)?{height:window.innerHeight,width:window.innerWidth}:{height:n.clientHeight,width:n.clientWidth},i={x:n.scrollWidth-t.width,y:n.scrollHeight-t.height},s=n.scrollTop<=e.y,r=n.scrollLeft<=e.x,o=n.scrollTop>=i.y,a=n.scrollLeft>=i.x;return{isTop:s,isLeft:r,isBottom:o,isRight:a,maxScroll:i,minScroll:e}}const $ct={x:.2,y:.2};function Gct(n,e,t,i,s){let{top:r,left:o,right:a,bottom:l}=t;i===void 0&&(i=10),s===void 0&&(s=$ct);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=uIe(n),g={x:0,y:0},m={x:0,y:0},b={height:e.height*s.y,width:e.width*s.x};return!c&&r<=e.top+b.height?(g.y=Za.Backward,m.y=i*Math.abs((e.top+b.height-r)/b.height)):!d&&l>=e.bottom-b.height&&(g.y=Za.Forward,m.y=i*Math.abs((e.bottom-b.height-l)/b.height)),!h&&a>=e.right-b.width?(g.x=Za.Forward,m.x=i*Math.abs((e.right-b.width-a)/b.width)):!u&&o<=e.left+b.width&&(g.x=Za.Backward,m.x=i*Math.abs((e.left+b.width-o)/b.width)),{direction:g,speed:m}}function qct(n){if(n===document.scrollingElement){const{innerWidth:r,innerHeight:o}=window;return{top:0,left:0,right:r,bottom:o,width:r,height:o}}const{top:e,left:t,right:i,bottom:s}=n.getBoundingClientRect();return{top:e,left:t,right:i,bottom:s,width:n.clientWidth,height:n.clientHeight}}function hIe(n){return n.reduce((e,t)=>FE(e,nZ(t)),Uf)}function Kct(n){return n.reduce((e,t)=>e+lIe(t),0)}function Zct(n){return n.reduce((e,t)=>e+cIe(t),0)}function Yct(n,e){if(e===void 0&&(e=GR),!n)return;const{top:t,left:i,bottom:s,right:r}=e(n);aIe(n)&&(s<=0||r<=0||t>=window.innerHeight||i>=window.innerWidth)&&n.scrollIntoView({block:"center",inline:"center"})}const Xct=[["x",["left","right"],Kct],["y",["top","bottom"],Zct]];let Wre=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const i=Vre(t),s=hIe(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[r,o,a]of Xct)for(const l of o)Object.defineProperty(this,l,{get:()=>{const c=a(i),d=s[r]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}};class PI{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(t=>{var i;return(i=this.target)==null?void 0:i.removeEventListener(...t)})},this.target=e}add(e,t,i){var s;(s=this.target)==null||s.addEventListener(e,t,i),this.listeners.push([e,t,i])}}function Qct(n){const{EventTarget:e}=qd(n);return n instanceof e?n:$R(n)}function l$(n,e){const t=Math.abs(n.x),i=Math.abs(n.y);return typeof e=="number"?Math.sqrt(t**2+i**2)>e:"x"in e&&"y"in e?t>e.x&&i>e.y:"x"in e?t>e.x:"y"in e?i>e.y:!1}var yh;(function(n){n.Click="click",n.DragStart="dragstart",n.Keydown="keydown",n.ContextMenu="contextmenu",n.Resize="resize",n.SelectionChange="selectionchange",n.VisibilityChange="visibilitychange"})(yh||(yh={}));function qme(n){n.preventDefault()}function Jct(n){n.stopPropagation()}var Ns;(function(n){n.Space="Space",n.Down="ArrowDown",n.Right="ArrowRight",n.Left="ArrowLeft",n.Up="ArrowUp",n.Esc="Escape",n.Enter="Enter",n.Tab="Tab"})(Ns||(Ns={}));const fIe={start:[Ns.Space,Ns.Enter],cancel:[Ns.Esc],end:[Ns.Space,Ns.Enter,Ns.Tab]},edt=(n,e)=>{let{currentCoordinates:t}=e;switch(n.code){case Ns.Right:return{...t,x:t.x+25};case Ns.Left:return{...t,x:t.x-25};case Ns.Down:return{...t,y:t.y+25};case Ns.Up:return{...t,y:t.y-25}}};class gIe{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new PI($R(t)),this.windowListeners=new PI(qd(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yh.Resize,this.handleCancel),this.windowListeners.add(yh.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yh.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:t}=this.props,i=e.node.current;i&&Yct(i),t(Uf)}handleKeyDown(e){if(Fre(e)){const{active:t,context:i,options:s}=this.props,{keyboardCodes:r=fIe,coordinateGetter:o=edt,scrollBehavior:a="smooth"}=s,{code:l}=e;if(r.end.includes(l)){this.handleEnd(e);return}if(r.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=i.current,d=c?{x:c.left,y:c.top}:Uf;this.referenceCoordinates||(this.referenceCoordinates=d);const u=o(e,{active:t,context:i.current,currentCoordinates:d});if(u){const h=BF(u,d),g={x:0,y:0},{scrollableAncestors:m}=i.current;for(const b of m){const v=e.code,{isTop:C,isRight:y,isLeft:L,isBottom:E,maxScroll:R,minScroll:T}=uIe(b),N=qct(b),I={x:Math.min(v===Ns.Right?N.right-N.width/2:N.right,Math.max(v===Ns.Right?N.left:N.left+N.width/2,u.x)),y:Math.min(v===Ns.Down?N.bottom-N.height/2:N.bottom,Math.max(v===Ns.Down?N.top:N.top+N.height/2,u.y))},M=v===Ns.Right&&!y||v===Ns.Left&&!L,P=v===Ns.Down&&!E||v===Ns.Up&&!C;if(M&&I.x!==u.x){const H=b.scrollLeft+h.x,j=v===Ns.Right&&H<=R.x||v===Ns.Left&&H>=T.x;if(j&&!h.y){b.scrollTo({left:H,behavior:a});return}j?g.x=b.scrollLeft-H:g.x=v===Ns.Right?b.scrollLeft-R.x:b.scrollLeft-T.x,g.x&&b.scrollBy({left:-g.x,behavior:a});break}else if(P&&I.y!==u.y){const H=b.scrollTop+h.y,j=v===Ns.Down&&H<=R.y||v===Ns.Up&&H>=T.y;if(j&&!h.x){b.scrollTo({top:H,behavior:a});return}j?g.y=b.scrollTop-H:g.y=v===Ns.Down?b.scrollTop-R.y:b.scrollTop-T.y,g.y&&b.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(e,FE(BF(u,this.referenceCoordinates),g))}}}handleMove(e,t){const{onMove:i}=this.props;e.preventDefault(),i(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}gIe.activators=[{eventName:"onKeyDown",handler:(n,e,t)=>{let{keyboardCodes:i=fIe,onActivation:s}=e,{active:r}=t;const{code:o}=n.nativeEvent;if(i.start.includes(o)){const a=r.activatorNode.current;return a&&n.target!==a?!1:(n.preventDefault(),s==null||s({event:n.nativeEvent}),!0)}return!1}}];function Kme(n){return!!(n&&"distance"in n)}function Zme(n){return!!(n&&"delay"in n)}class zre{constructor(e,t,i){var s;i===void 0&&(i=Qct(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:o}=r;this.props=e,this.events=t,this.document=$R(o),this.documentListeners=new PI(this.document),this.listeners=new PI(i),this.windowListeners=new PI(qd(o)),this.initialCoordinates=(s=iZ(r))!=null?s:Uf,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:i}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(yh.Resize,this.handleCancel),this.windowListeners.add(yh.DragStart,qme),this.windowListeners.add(yh.VisibilityChange,this.handleCancel),this.windowListeners.add(yh.ContextMenu,qme),this.documentListeners.add(yh.Keydown,this.handleKeydown),t){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Zme(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Kme(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:i,onPending:s}=this.props;s(i,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(yh.Click,Jct,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yh.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:i,initialCoordinates:s,props:r}=this,{onMove:o,options:{activationConstraint:a}}=r;if(!s)return;const l=(t=iZ(e))!=null?t:Uf,c=BF(s,l);if(!i&&a){if(Kme(a)){if(a.tolerance!=null&&l$(c,a.tolerance))return this.handleCancel();if(l$(c,a.distance))return this.handleStart()}if(Zme(a)&&l$(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),o(l)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Ns.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const tdt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class UM extends zre{constructor(e){const{event:t}=e,i=$R(t.target);super(e,tdt,i)}}UM.activators=[{eventName:"onPointerDown",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:i}=e;return!t.isPrimary||t.button!==0?!1:(i==null||i({event:t}),!0)}}];const idt={move:{name:"mousemove"},end:{name:"mouseup"}};var sZ;(function(n){n[n.RightClick=2]="RightClick"})(sZ||(sZ={}));class ndt extends zre{constructor(e){super(e,idt,$R(e.event.target))}}ndt.activators=[{eventName:"onMouseDown",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:i}=e;return t.button===sZ.RightClick?!1:(i==null||i({event:t}),!0)}}];const c$={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class sdt extends zre{constructor(e){super(e,c$)}static setup(){return window.addEventListener(c$.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(c$.move.name,e)};function e(){}}}sdt.activators=[{eventName:"onTouchStart",handler:(n,e)=>{let{nativeEvent:t}=n,{onActivation:i}=e;const{touches:s}=t;return s.length>1?!1:(i==null||i({event:t}),!0)}}];var FI;(function(n){n[n.Pointer=0]="Pointer",n[n.DraggableRect=1]="DraggableRect"})(FI||(FI={}));var WF;(function(n){n[n.TreeOrder=0]="TreeOrder",n[n.ReversedTreeOrder=1]="ReversedTreeOrder"})(WF||(WF={}));function rdt(n){let{acceleration:e,activator:t=FI.Pointer,canScroll:i,draggingRect:s,enabled:r,interval:o=5,order:a=WF.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:h}=n;const g=adt({delta:u,disabled:!r}),[m,b]=_ct(),v=x.useRef({x:0,y:0}),C=x.useRef({x:0,y:0}),y=x.useMemo(()=>{switch(t){case FI.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case FI.DraggableRect:return s}},[t,s,l]),L=x.useRef(null),E=x.useCallback(()=>{const T=L.current;if(!T)return;const N=v.current.x*C.current.x,I=v.current.y*C.current.y;T.scrollBy(N,I)},[]),R=x.useMemo(()=>a===WF.TreeOrder?[...c].reverse():c,[a,c]);x.useEffect(()=>{if(!r||!c.length||!y){b();return}for(const T of R){if((i==null?void 0:i(T))===!1)continue;const N=c.indexOf(T),I=d[N];if(!I)continue;const{direction:M,speed:P}=Gct(T,I,y,e,h);for(const H of["x","y"])g[H][M[H]]||(P[H]=0,M[H]=0);if(P.x>0||P.y>0){b(),L.current=T,m(E,o),v.current=P,C.current=M;return}}v.current={x:0,y:0},C.current={x:0,y:0},b()},[e,E,i,b,r,o,JSON.stringify(y),JSON.stringify(g),m,c,R,d,JSON.stringify(h)])}const odt={x:{[Za.Backward]:!1,[Za.Forward]:!1},y:{[Za.Backward]:!1,[Za.Forward]:!1}};function adt(n){let{delta:e,disabled:t}=n;const i=tZ(e);return WM(s=>{if(t||!i||!s)return odt;const r={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[Za.Backward]:s.x[Za.Backward]||r.x===-1,[Za.Forward]:s.x[Za.Forward]||r.x===1},y:{[Za.Backward]:s.y[Za.Backward]||r.y===-1,[Za.Forward]:s.y[Za.Forward]||r.y===1}}},[t,e,i])}function ldt(n,e){const t=e!=null?n.get(e):void 0,i=t?t.node.current:null;return WM(s=>{var r;return e==null?null:(r=i??s)!=null?r:null},[i,e])}function cdt(n,e){return x.useMemo(()=>n.reduce((t,i)=>{const{sensor:s}=i,r=s.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,i)}));return[...t,...r]},[]),[n,e])}var p2;(function(n){n[n.Always=0]="Always",n[n.BeforeDragging=1]="BeforeDragging",n[n.WhileDragging=2]="WhileDragging"})(p2||(p2={}));var rZ;(function(n){n.Optimized="optimized"})(rZ||(rZ={}));const Yme=new Map;function ddt(n,e){let{dragging:t,dependencies:i,config:s}=e;const[r,o]=x.useState(null),{frequency:a,measure:l,strategy:c}=s,d=x.useRef(n),u=v(),h=f2(u),g=x.useCallback(function(C){C===void 0&&(C=[]),!h.current&&o(y=>y===null?C:y.concat(C.filter(L=>!y.includes(L))))},[h]),m=x.useRef(null),b=WM(C=>{if(u&&!t)return Yme;if(!C||C===Yme||d.current!==n||r!=null){const y=new Map;for(let L of n){if(!L)continue;if(r&&r.length>0&&!r.includes(L.id)&&L.rect.current){y.set(L.id,L.rect.current);continue}const E=L.node.current,R=E?new Wre(l(E),E):null;L.rect.current=R,R&&y.set(L.id,R)}return y}return C},[n,r,t,u,l]);return x.useEffect(()=>{d.current=n},[n]),x.useEffect(()=>{u||g()},[t,u]),x.useEffect(()=>{r&&r.length>0&&o(null)},[JSON.stringify(r)]),x.useEffect(()=>{u||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{g(),m.current=null},a))},[a,u,g,...i]),{droppableRects:b,measureDroppableContainers:g,measuringScheduled:r!=null};function v(){switch(c){case p2.Always:return!1;case p2.BeforeDragging:return t;default:return!t}}}function pIe(n,e){return WM(t=>n?t||(typeof e=="function"?e(n):n):null,[e,n])}function udt(n,e){return pIe(n,e)}function hdt(n){let{callback:e,disabled:t}=n;const i=Pre(e),s=x.useMemo(()=>{if(t||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:r}=window;return new r(i)},[i,t]);return x.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function rB(n){let{callback:e,disabled:t}=n;const i=Pre(e),s=x.useMemo(()=>{if(t||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:r}=window;return new r(i)},[t]);return x.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function fdt(n){return new Wre(GR(n),n)}function Xme(n,e,t){e===void 0&&(e=fdt);const[i,s]=x.useState(null);function r(){s(l=>{if(!n)return null;if(n.isConnected===!1){var c;return(c=l??t)!=null?c:null}const d=e(n);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const o=hdt({callback(l){if(n)for(const c of l){const{type:d,target:u}=c;if(d==="childList"&&u instanceof HTMLElement&&u.contains(n)){r();break}}}}),a=rB({callback:r});return Sp(()=>{r(),n?(a==null||a.observe(n),o==null||o.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),o==null||o.disconnect())},[n]),i}function gdt(n){const e=pIe(n);return oIe(n,e)}const Qme=[];function pdt(n){const e=x.useRef(n),t=WM(i=>n?i&&i!==Qme&&n&&e.current&&n.parentNode===e.current.parentNode?i:Vre(n):Qme,[n]);return x.useEffect(()=>{e.current=n},[n]),t}function mdt(n){const[e,t]=x.useState(null),i=x.useRef(n),s=x.useCallback(r=>{const o=a$(r.target);o&&t(a=>a?(a.set(o,nZ(o)),new Map(a)):null)},[]);return x.useEffect(()=>{const r=i.current;if(n!==r){o(r);const a=n.map(l=>{const c=a$(l);return c?(c.addEventListener("scroll",s,{passive:!0}),[c,nZ(c)]):null}).filter(l=>l!=null);t(a.length?new Map(a):null),i.current=n}return()=>{o(n),o(r)};function o(a){a.forEach(l=>{const c=a$(l);c==null||c.removeEventListener("scroll",s)})}},[s,n]),x.useMemo(()=>n.length?e?Array.from(e.values()).reduce((r,o)=>FE(r,o),Uf):hIe(n):Uf,[n,e])}function Jme(n,e){e===void 0&&(e=[]);const t=x.useRef(null);return x.useEffect(()=>{t.current=null},e),x.useEffect(()=>{const i=n!==Uf;i&&!t.current&&(t.current=n),!i&&t.current&&(t.current=null)},[n]),t.current?BF(n,t.current):Uf}function _dt(n){x.useEffect(()=>{if(!sB)return;const e=n.map(t=>{let{sensor:i}=t;return i.setup==null?void 0:i.setup()});return()=>{for(const t of e)t==null||t()}},n.map(e=>{let{sensor:t}=e;return t}))}function bdt(n,e){return x.useMemo(()=>n.reduce((t,i)=>{let{eventName:s,handler:r}=i;return t[s]=o=>{r(o,e)},t},{}),[n,e])}function mIe(n){return x.useMemo(()=>n?Wct(n):null,[n])}const e_e=[];function vdt(n,e){e===void 0&&(e=GR);const[t]=n,i=mIe(t?qd(t):null),[s,r]=x.useState(e_e);function o(){r(()=>n.length?n.map(l=>dIe(l)?i:new Wre(e(l),l)):e_e)}const a=rB({callback:o});return Sp(()=>{a==null||a.disconnect(),o(),n.forEach(l=>a==null?void 0:a.observe(l))},[n]),s}function Cdt(n){if(!n)return null;if(n.children.length>1)return n;const e=n.children[0];return VM(e)?e:n}function wdt(n){let{measure:e}=n;const[t,i]=x.useState(null),s=x.useCallback(c=>{for(const{target:d}of c)if(VM(d)){i(u=>{const h=e(d);return u?{...u,width:h.width,height:h.height}:h});break}},[e]),r=rB({callback:s}),o=x.useCallback(c=>{const d=Cdt(c);r==null||r.disconnect(),d&&(r==null||r.observe(d)),i(d?e(d):null)},[e,r]),[a,l]=HF(o);return x.useMemo(()=>({nodeRef:a,rect:t,setRef:l}),[t,a,l])}const ydt=[{sensor:UM,options:{}},{sensor:gIe,options:{}}],Sdt={current:{}},a5={draggable:{measure:Gme},droppable:{measure:Gme,strategy:p2.WhileDragging,frequency:rZ.Optimized},dragOverlay:{measure:GR}};class jI extends Map{get(e){var t;return e!=null&&(t=super.get(e))!=null?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,i;return(t=(i=this.get(e))==null?void 0:i.node.current)!=null?t:void 0}}const xdt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new jI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:VF},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:a5,measureDroppableContainers:VF,windowRect:null,measuringScheduled:!1},Ldt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:VF,draggableNodes:new Map,over:null,measureDroppableContainers:VF},oB=x.createContext(Ldt),_Ie=x.createContext(xdt);function Edt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new jI}}}function Ddt(n,e){switch(e.type){case Ea.DragStart:return{...n,draggable:{...n.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ea.DragMove:return n.draggable.active==null?n:{...n,draggable:{...n.draggable,translate:{x:e.coordinates.x-n.draggable.initialCoordinates.x,y:e.coordinates.y-n.draggable.initialCoordinates.y}}};case Ea.DragEnd:case Ea.DragCancel:return{...n,draggable:{...n.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ea.RegisterDroppable:{const{element:t}=e,{id:i}=t,s=new jI(n.droppable.containers);return s.set(i,t),{...n,droppable:{...n.droppable,containers:s}}}case Ea.SetDroppableDisabled:{const{id:t,key:i,disabled:s}=e,r=n.droppable.containers.get(t);if(!r||i!==r.key)return n;const o=new jI(n.droppable.containers);return o.set(t,{...r,disabled:s}),{...n,droppable:{...n.droppable,containers:o}}}case Ea.UnregisterDroppable:{const{id:t,key:i}=e,s=n.droppable.containers.get(t);if(!s||i!==s.key)return n;const r=new jI(n.droppable.containers);return r.delete(t),{...n,droppable:{...n.droppable,containers:r}}}default:return n}}function Rdt(n){let{disabled:e}=n;const{active:t,activatorEvent:i,draggableNodes:s}=x.useContext(oB),r=tZ(i),o=tZ(t==null?void 0:t.id);return x.useEffect(()=>{if(!e&&!i&&r&&o!=null){if(!Fre(r)||document.activeElement===r.target)return;const a=s.get(o);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const u=Cct(d);if(u){u.focus();break}}})}},[i,e,s,o,r]),null}function Ndt(n,e){let{transform:t,...i}=e;return n!=null&&n.length?n.reduce((s,r)=>r({transform:s,...i}),t):t}function Tdt(n){return x.useMemo(()=>({draggable:{...a5.draggable,...n==null?void 0:n.draggable},droppable:{...a5.droppable,...n==null?void 0:n.droppable},dragOverlay:{...a5.dragOverlay,...n==null?void 0:n.dragOverlay}}),[n==null?void 0:n.draggable,n==null?void 0:n.droppable,n==null?void 0:n.dragOverlay])}function Idt(n){let{activeNode:e,measure:t,initialRect:i,config:s=!0}=n;const r=x.useRef(!1),{x:o,y:a}=typeof s=="boolean"?{x:s,y:s}:s;Sp(()=>{if(!o&&!a||!e){r.current=!1;return}if(r.current||!i)return;const c=e==null?void 0:e.node.current;if(!c||c.isConnected===!1)return;const d=t(c),u=oIe(d,i);if(o||(u.x=0),a||(u.y=0),r.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const h=aIe(c);h&&h.scrollBy({top:u.y,left:u.x})}},[e,o,a,i,t])}const bIe=x.createContext({...Uf,scaleX:1,scaleY:1});var dv;(function(n){n[n.Uninitialized=0]="Uninitialized",n[n.Initializing=1]="Initializing",n[n.Initialized=2]="Initialized"})(dv||(dv={}));const Ure=x.memo(function(e){var t,i,s,r;let{id:o,accessibility:a,autoScroll:l=!0,children:c,sensors:d=ydt,collisionDetection:u=Oct,measuring:h,modifiers:g,...m}=e;const b=x.useReducer(Ddt,void 0,Edt),[v,C]=b,[y,L]=Ect(),[E,R]=x.useState(dv.Uninitialized),T=E===dv.Initialized,{draggable:{active:N,nodes:I,translate:M},droppable:{containers:P}}=v,H=N!=null?I.get(N):null,j=x.useRef({initial:null,translated:null}),V=x.useMemo(()=>{var Ks;return N!=null?{id:N,data:(Ks=H==null?void 0:H.data)!=null?Ks:Sdt,rect:j}:null},[N,H]),W=x.useRef(null),[U,B]=x.useState(null),[K,X]=x.useState(null),ne=f2(m,Object.values(m)),fe=zM("DndDescribedBy",o),Z=x.useMemo(()=>P.getEnabled(),[P]),Y=Tdt(h),{droppableRects:ee,measureDroppableContainers:se,measuringScheduled:ae}=ddt(Z,{dragging:T,dependencies:[M.x,M.y],config:Y.droppable}),Se=ldt(I,N),ue=x.useMemo(()=>K?iZ(K):null,[K]),Re=ih(),Ve=udt(Se,Y.draggable.measure);Idt({activeNode:N!=null?I.get(N):null,config:Re.layoutShiftCompensation,initialRect:Ve,measure:Y.draggable.measure});const Qe=Xme(Se,Y.draggable.measure,Ve),dt=Xme(Se?Se.parentElement:null),yt=x.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fi=P.getNodeFor((t=yt.current.over)==null?void 0:t.id),_i=wdt({measure:Y.dragOverlay.measure}),Sn=(i=_i.nodeRef.current)!=null?i:Se,Es=T?(s=_i.rect)!=null?s:Qe:null,br=!!(_i.nodeRef.current&&_i.rect),hs=gdt(br?null:Qe),Ht=mIe(Sn?qd(Sn):null),oe=pdt(T?fi??Se:null),Ce=vdt(oe),je=Ndt(g,{transform:{x:M.x-hs.x,y:M.y-hs.y,scaleX:1,scaleY:1},activatorEvent:K,active:V,activeNodeRect:Qe,containerNodeRect:dt,draggingNodeRect:Es,over:yt.current.over,overlayNodeRect:_i.rect,scrollableAncestors:oe,scrollableAncestorRects:Ce,windowRect:Ht}),bt=ue?FE(ue,M):null,tt=mdt(oe),ct=Jme(tt),$t=Jme(tt,[Qe]),yi=FE(je,ct),xi=Es?jct(Es,je):null,Nr=V&&xi?u({active:V,collisionRect:xi,droppableRects:ee,droppableContainers:Z,pointerCoordinates:bt}):null,Wl=Act(Nr,"id"),[Tr,Qd]=x.useState(null),Ir=br?je:FE(je,$t),vs=Pct(Ir,(r=Tr==null?void 0:Tr.rect)!=null?r:null,Qe),Kr=x.useRef(null),kr=x.useCallback((Ks,Ar)=>{let{sensor:vo,options:Bn}=Ar;if(W.current==null)return;const Mr=I.get(W.current);if(!Mr)return;const ro=Ks.nativeEvent,qo=new vo({active:W.current,activeNode:Mr,event:ro,options:Bn,context:yt,onAbort(Zr){if(!I.get(Zr))return;const{onDragAbort:we}=ne.current,Te={id:Zr};we==null||we(Te),y({type:"onDragAbort",event:Te})},onPending(Zr,le,we,Te){if(!I.get(Zr))return;const{onDragPending:mt}=ne.current,Wt={id:Zr,constraint:le,initialCoordinates:we,offset:Te};mt==null||mt(Wt),y({type:"onDragPending",event:Wt})},onStart(Zr){const le=W.current;if(le==null)return;const we=I.get(le);if(!we)return;const{onDragStart:Te}=ne.current,Ye={activatorEvent:ro,active:{id:le,data:we.data,rect:j}};Rf.unstable_batchedUpdates(()=>{Te==null||Te(Ye),R(dv.Initializing),C({type:Ea.DragStart,initialCoordinates:Zr,active:le}),y({type:"onDragStart",event:Ye}),B(Kr.current),X(ro)})},onMove(Zr){C({type:Ea.DragMove,coordinates:Zr})},onEnd:Va(Ea.DragEnd),onCancel:Va(Ea.DragCancel)});Kr.current=qo;function Va(Zr){return async function(){const{active:we,collisions:Te,over:Ye,scrollAdjustedTranslate:mt}=yt.current;let Wt=null;if(we&&mt){const{cancelDrop:Gt}=ne.current;Wt={activatorEvent:ro,active:we,collisions:Te,delta:mt,over:Ye},Zr===Ea.DragEnd&&typeof Gt=="function"&&await Promise.resolve(Gt(Wt))&&(Zr=Ea.DragCancel)}W.current=null,Rf.unstable_batchedUpdates(()=>{C({type:Zr}),R(dv.Uninitialized),Qd(null),B(null),X(null),Kr.current=null;const Gt=Zr===Ea.DragEnd?"onDragEnd":"onDragCancel";if(Wt){const Ft=ne.current[Gt];Ft==null||Ft(Wt),y({type:Gt,event:Wt})}})}}},[I]),Kh=x.useCallback((Ks,Ar)=>(vo,Bn)=>{const Mr=vo.nativeEvent,ro=I.get(Bn);if(W.current!==null||!ro||Mr.dndKit||Mr.defaultPrevented)return;const qo={active:ro};Ks(vo,Ar.options,qo)===!0&&(Mr.dndKit={capturedBy:Ar.sensor},W.current=Bn,kr(vo,Ar))},[I,kr]),th=cdt(d,Kh);_dt(d),Sp(()=>{Qe&&E===dv.Initializing&&R(dv.Initialized)},[Qe,E]),x.useEffect(()=>{const{onDragMove:Ks}=ne.current,{active:Ar,activatorEvent:vo,collisions:Bn,over:Mr}=yt.current;if(!Ar||!vo)return;const ro={active:Ar,activatorEvent:vo,collisions:Bn,delta:{x:yi.x,y:yi.y},over:Mr};Rf.unstable_batchedUpdates(()=>{Ks==null||Ks(ro),y({type:"onDragMove",event:ro})})},[yi.x,yi.y]),x.useEffect(()=>{const{active:Ks,activatorEvent:Ar,collisions:vo,droppableContainers:Bn,scrollAdjustedTranslate:Mr}=yt.current;if(!Ks||W.current==null||!Ar||!Mr)return;const{onDragOver:ro}=ne.current,qo=Bn.get(Wl),Va=qo&&qo.rect.current?{id:qo.id,rect:qo.rect.current,data:qo.data,disabled:qo.disabled}:null,Zr={active:Ks,activatorEvent:Ar,collisions:vo,delta:{x:Mr.x,y:Mr.y},over:Va};Rf.unstable_batchedUpdates(()=>{Qd(Va),ro==null||ro(Zr),y({type:"onDragOver",event:Zr})})},[Wl]),Sp(()=>{yt.current={activatorEvent:K,active:V,activeNode:Se,collisionRect:xi,collisions:Nr,droppableRects:ee,draggableNodes:I,draggingNode:Sn,draggingNodeRect:Es,droppableContainers:P,over:Tr,scrollableAncestors:oe,scrollAdjustedTranslate:yi},j.current={initial:Es,translated:xi}},[V,Se,Nr,xi,I,Sn,Es,ee,P,Tr,oe,yi]),rdt({...Re,delta:M,draggingRect:xi,pointerCoordinates:bt,scrollableAncestors:oe,scrollableAncestorRects:Ce});const Jd=x.useMemo(()=>({active:V,activeNode:Se,activeNodeRect:Qe,activatorEvent:K,collisions:Nr,containerNodeRect:dt,dragOverlay:_i,draggableNodes:I,droppableContainers:P,droppableRects:ee,over:Tr,measureDroppableContainers:se,scrollableAncestors:oe,scrollableAncestorRects:Ce,measuringConfiguration:Y,measuringScheduled:ae,windowRect:Ht}),[V,Se,Qe,K,Nr,dt,_i,I,P,ee,Tr,se,oe,Ce,Y,ae,Ht]),sd=x.useMemo(()=>({activatorEvent:K,activators:th,active:V,activeNodeRect:Qe,ariaDescribedById:{draggable:fe},dispatch:C,draggableNodes:I,over:Tr,measureDroppableContainers:se}),[K,th,V,Qe,C,fe,I,Tr,se]);return nt.createElement(rIe.Provider,{value:L},nt.createElement(oB.Provider,{value:sd},nt.createElement(_Ie.Provider,{value:Jd},nt.createElement(bIe.Provider,{value:vs},c)),nt.createElement(Rdt,{disabled:(a==null?void 0:a.restoreFocus)===!1})),nt.createElement(Nct,{...a,hiddenTextDescribedById:fe}));function ih(){const Ks=(U==null?void 0:U.autoScrollEnabled)===!1,Ar=typeof l=="object"?l.enabled===!1:l===!1,vo=T&&!Ks&&!Ar;return typeof l=="object"?{...l,enabled:vo}:{enabled:vo}}}),kdt=x.createContext(null),t_e="button",Adt="Draggable";function Mdt(n){let{id:e,data:t,disabled:i=!1,attributes:s}=n;const r=zM(Adt),{activators:o,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:h}=x.useContext(oB),{role:g=t_e,roleDescription:m="draggable",tabIndex:b=0}=s??{},v=(l==null?void 0:l.id)===e,C=x.useContext(v?bIe:kdt),[y,L]=HF(),[E,R]=HF(),T=bdt(o,e),N=f2(t);Sp(()=>(u.set(e,{id:e,key:r,node:y,activatorNode:E,data:N}),()=>{const M=u.get(e);M&&M.key===r&&u.delete(e)}),[u,e]);const I=x.useMemo(()=>({role:g,tabIndex:b,"aria-disabled":i,"aria-pressed":v&&g===t_e?!0:void 0,"aria-roledescription":m,"aria-describedby":d.draggable}),[i,g,b,v,m,d.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:I,isDragging:v,listeners:i?void 0:T,node:y,over:h,setNodeRef:L,setActivatorNodeRef:R,transform:C}}function Odt(){return x.useContext(_Ie)}const Pdt="Droppable",Fdt={timeout:25};function jdt(n){let{data:e,disabled:t=!1,id:i,resizeObserverConfig:s}=n;const r=zM(Pdt),{active:o,dispatch:a,over:l,measureDroppableContainers:c}=x.useContext(oB),d=x.useRef({disabled:t}),u=x.useRef(!1),h=x.useRef(null),g=x.useRef(null),{disabled:m,updateMeasurementsFor:b,timeout:v}={...Fdt,...s},C=f2(b??i),y=x.useCallback(()=>{if(!u.current){u.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(C.current)?C.current:[C.current]),g.current=null},v)},[v]),L=rB({callback:y,disabled:m||!o}),E=x.useCallback((I,M)=>{L&&(M&&(L.unobserve(M),u.current=!1),I&&L.observe(I))},[L]),[R,T]=HF(E),N=f2(e);return x.useEffect(()=>{!L||!R.current||(L.disconnect(),u.current=!1,L.observe(R.current))},[R,L]),x.useEffect(()=>(a({type:Ea.RegisterDroppable,element:{id:i,key:r,disabled:t,node:R,rect:h,data:N}}),()=>a({type:Ea.UnregisterDroppable,key:r,id:i})),[i]),x.useEffect(()=>{t!==d.current.disabled&&(a({type:Ea.SetDroppableDisabled,id:i,key:r,disabled:t}),d.current.disabled=t)},[i,r,t,a]),{active:o,rect:h,isOver:(l==null?void 0:l.id)===i,node:R,over:l,setNodeRef:T}}function vIe(n,e,t){const i=n.slice();return i.splice(t<0?i.length+t:t,0,i.splice(e,1)[0]),i}function Hdt(n,e){return n.reduce((t,i,s)=>{const r=e.get(i);return r&&(t[s]=r),t},Array(n.length))}function b4(n){return n!==null&&n>=0}function Bdt(n,e){if(n===e)return!0;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Vdt(n){return typeof n=="boolean"?{draggable:n,droppable:n}:n}const CIe=n=>{let{rects:e,activeIndex:t,overIndex:i,index:s}=n;const r=vIe(e,i,t),o=e[s],a=r[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}},v4={scaleX:1,scaleY:1},$re=n=>{var e;let{activeIndex:t,activeNodeRect:i,index:s,rects:r,overIndex:o}=n;const a=(e=r[t])!=null?e:i;if(!a)return null;if(s===t){const c=r[o];return c?{x:0,y:t<o?c.top+c.height-(a.top+a.height):c.top-a.top,...v4}:null}const l=Wdt(r,s,t);return s>t&&s<=o?{x:0,y:-a.height-l,...v4}:s<t&&s>=o?{x:0,y:a.height+l,...v4}:{x:0,y:0,...v4}};function Wdt(n,e,t){const i=n[e],s=n[e-1],r=n[e+1];return i?t<e?s?i.top-(s.top+s.height):r?r.top-(i.top+i.height):0:r?r.top-(i.top+i.height):s?i.top-(s.top+s.height):0:0}const wIe="Sortable",yIe=nt.createContext({activeIndex:-1,containerId:wIe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:CIe,disabled:{draggable:!1,droppable:!1}});function Gre(n){let{children:e,id:t,items:i,strategy:s=CIe,disabled:r=!1}=n;const{active:o,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:d}=Odt(),u=zM(wIe,t),h=a.rect!==null,g=x.useMemo(()=>i.map(T=>typeof T=="object"&&"id"in T?T.id:T),[i]),m=o!=null,b=o?g.indexOf(o.id):-1,v=c?g.indexOf(c.id):-1,C=x.useRef(g),y=!Bdt(g,C.current),L=v!==-1&&b===-1||y,E=Vdt(r);Sp(()=>{y&&m&&d(g)},[y,g,m,d]),x.useEffect(()=>{C.current=g},[g]);const R=x.useMemo(()=>({activeIndex:b,containerId:u,disabled:E,disableTransforms:L,items:g,overIndex:v,useDragOverlay:h,sortedRects:Hdt(g,l),strategy:s}),[b,u,E.draggable,E.droppable,L,g,v,l,h,s]);return nt.createElement(yIe.Provider,{value:R},e)}const zdt=n=>{let{id:e,items:t,activeIndex:i,overIndex:s}=n;return vIe(t,i,s).indexOf(e)},Udt=n=>{let{containerId:e,isSorting:t,wasDragging:i,index:s,items:r,newIndex:o,previousItems:a,previousContainerId:l,transition:c}=n;return!c||!i||a!==r&&s===o?!1:t?!0:o!==s&&e===l},$dt={duration:200,easing:"ease"},SIe="transform",Gdt=g2.Transition.toString({property:SIe,duration:0,easing:"linear"}),qdt={roleDescription:"sortable"};function Kdt(n){let{disabled:e,index:t,node:i,rect:s}=n;const[r,o]=x.useState(null),a=x.useRef(t);return Sp(()=>{if(!e&&t!==a.current&&i.current){const l=s.current;if(l){const c=GR(i.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&o(d)}}t!==a.current&&(a.current=t)},[e,t,i,s]),x.useEffect(()=>{r&&o(null)},[r]),r}function Zdt(n){let{animateLayoutChanges:e=Udt,attributes:t,disabled:i,data:s,getNewIndex:r=zdt,id:o,strategy:a,resizeObserverConfig:l,transition:c=$dt}=n;const{items:d,containerId:u,activeIndex:h,disabled:g,disableTransforms:m,sortedRects:b,overIndex:v,useDragOverlay:C,strategy:y}=x.useContext(yIe),L=Ydt(i,g),E=d.indexOf(o),R=x.useMemo(()=>({sortable:{containerId:u,index:E,items:d},...s}),[u,s,E,d]),T=x.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:N,node:I,isOver:M,setNodeRef:P}=jdt({id:o,data:R,disabled:L.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...l}}),{active:H,activatorEvent:j,activeNodeRect:V,attributes:W,setNodeRef:U,listeners:B,isDragging:K,over:X,setActivatorNodeRef:ne,transform:fe}=Mdt({id:o,data:R,attributes:{...qdt,...t},disabled:L.draggable}),Z=mct(P,U),Y=!!H,ee=Y&&!m&&b4(h)&&b4(v),se=!C&&K,ae=se&&ee?fe:null,ue=ee?ae??(a??y)({rects:b,activeNodeRect:V,activeIndex:h,overIndex:v,index:E}):null,Re=b4(h)&&b4(v)?r({id:o,items:d,activeIndex:h,overIndex:v}):E,Ve=H==null?void 0:H.id,Qe=x.useRef({activeId:Ve,items:d,newIndex:Re,containerId:u}),dt=d!==Qe.current.items,yt=e({active:H,containerId:u,isDragging:K,isSorting:Y,id:o,index:E,items:d,newIndex:Qe.current.newIndex,previousItems:Qe.current.items,previousContainerId:Qe.current.containerId,transition:c,wasDragging:Qe.current.activeId!=null}),fi=Kdt({disabled:!yt,index:E,node:I,rect:N});return x.useEffect(()=>{Y&&Qe.current.newIndex!==Re&&(Qe.current.newIndex=Re),u!==Qe.current.containerId&&(Qe.current.containerId=u),d!==Qe.current.items&&(Qe.current.items=d)},[Y,Re,u,d]),x.useEffect(()=>{if(Ve===Qe.current.activeId)return;if(Ve&&!Qe.current.activeId){Qe.current.activeId=Ve;return}const Sn=setTimeout(()=>{Qe.current.activeId=Ve},50);return()=>clearTimeout(Sn)},[Ve]),{active:H,activeIndex:h,attributes:W,data:R,rect:N,index:E,newIndex:Re,items:d,isOver:M,isSorting:Y,isDragging:K,listeners:B,node:I,overIndex:v,over:X,setNodeRef:Z,setActivatorNodeRef:ne,setDroppableNodeRef:P,setDraggableNodeRef:U,transform:fi??ue,transition:_i()};function _i(){if(fi||dt&&Qe.current.newIndex===E)return Gdt;if(!(se&&!Fre(j)||!c)&&(Y||yt))return g2.Transition.toString({...c,property:SIe})}}function Ydt(n,e){var t,i;return typeof n=="boolean"?{draggable:n,droppable:!1}:{draggable:(t=n==null?void 0:n.draggable)!=null?t:e.draggable,droppable:(i=n==null?void 0:n.droppable)!=null?i:e.droppable}}Ns.Down,Ns.Right,Ns.Up,Ns.Left;function jE({value:n,placeholder:e="",onValueChange:t,minRows:i=1,isBold:s=!1,className:r,saveButtonText:o="Save",cancelButtonText:a="Discard"}){const[l,c]=x.useState(!1),[d,u]=x.useState(n),h=x.useRef(null),g=y=>{u(y.target.value)},m=()=>{t&&d!==n&&t(d.trim()),c(!1)},b=()=>{u(n),c(!1)},v=y=>{y.key==="Enter"&&!y.shiftKey?(i===1||y.ctrlKey)&&(y.preventDefault(),m()):y.key==="Escape"&&(y.preventDefault(),b())},C=y=>{c(y),y?(u(n),setTimeout(()=>{h.current&&h.current.focus()},0)):b()};return f.jsxs(yre,{open:l,onOpenChange:C,children:[f.jsx(Sre,{asChild:!0,children:f.jsx("div",{className:Le("cursor-edit w-full min-w-[100px]",!n&&"text-gray-400",s&&"font-medium",r),children:n||e})}),f.jsxs(xre,{className:"w-auto max-w-[600px] min-w-[300px] p-2",align:"start",children:[f.jsx(Hp,{ref:h,value:d,onChange:g,onKeyDown:v,className:"min-h-[24px] resize-y",style:{minHeight:String(Math.max(i*24,24))+"px"},rows:i}),f.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:b,className:"h-7 cursor-pointer px-2 text-xs",children:a}),f.jsx(rt,{size:"sm",onClick:m,className:"h-7 cursor-pointer px-2 text-xs",children:o})]})]})]})}function Xdt({isAllExpanded:n,onToggle:e}){return f.jsx(rt,{variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer p-0",onClick:e,title:n?"Collapse all items":"Expand all items",children:n?f.jsx(HHe,{className:"h-4 w-4"}):f.jsx(One,{className:"h-4 w-4"})})}function Qdt({isExpanded:n,onToggle:e,ariaLabel:t}){return f.jsx(rt,{variant:"ghost",size:"icon",className:"h-5 w-5 cursor-pointer p-0",onClick:e,"aria-label":t??(n?"Collapse":"Expand"),children:n?f.jsx(Pp,{className:"h-4 w-4"}):f.jsx($d,{className:"h-4 w-4"})})}function Jdt({className:n="",...e}){return f.jsx("div",{...e,className:`flex cursor-grab items-center justify-center opacity-0 group-hover:opacity-100 active:cursor-grabbing ${n}`,children:f.jsx(JSe,{className:"h-4 w-4 text-gray-400"})})}function qre({id:n,children:e}){const{attributes:t,listeners:i,setNodeRef:s,transform:r,transition:o,isDragging:a}=Zdt({id:n}),l={transform:g2.Transform.toString(r),transition:o,opacity:a?.75:1},c=x.Children.toArray(e),d=[f.jsx(Rl,{className:"bg-background dark:bg-muted",style:{width:20,position:"sticky",left:0,zIndex:2,paddingTop:8,paddingBottom:8,paddingLeft:4,paddingRight:0},children:f.jsx(Jdt,{...t,...i})},"drag-handle-cell"),...c.slice(1)];return f.jsx(qr,{ref:s,style:l,className:"group",children:d})}function xIe({row:n,onDeleteRow:e,onAddNestedField:t,isRecordType:i}){const[s,r]=x.useState(!1),o=()=>{e&&e(n.index),r(!1)},a=i&&t&&i(n.index),l=!!e,c=a&&l;return f.jsxs("div",{className:"px-3 text-right",children:[f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100","aria-label":"Row actions",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[a&&f.jsxs(wn,{className:"cursor-pointer",onClick:()=>{t(n.index)},children:[f.jsx(Gd,{className:"mr-2 h-4 w-4"}),"Add nested field"]}),c&&f.jsx(Vd,{}),l&&f.jsxs(wn,{onClick:()=>{r(!0)},children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete field"})]})]})]}),f.jsx(Ma,{open:s,onOpenChange:r,title:"Delete field",description:"Are you sure you want to delete this field?",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:o,variant:"destructive"})]})}function eut({mode:n,onModeChange:e}){const t=Object.values(d2),i=s=>{e&&e(s)};return f.jsxs($c,{value:n,onValueChange:i,children:[f.jsx(qc,{className:"h-90 cursor-pointer",size:"sm",children:f.jsx(Gc,{placeholder:"Select field mode"})}),f.jsx(Kc,{className:"max-h-[300px]",children:t.map(s=>f.jsx(fo,{value:s,children:s},s))})]})}var aB="Checkbox",[tut]=Ha(aB),[iut,Kre]=tut(aB);function nut(n){const{__scopeCheckbox:e,checked:t,children:i,defaultChecked:s,disabled:r,form:o,name:a,onCheckedChange:l,required:c,value:d="on",internal_do_not_use_render:u}=n,[h,g]=zc({prop:t,defaultProp:s??!1,onChange:l,caller:aB}),[m,b]=x.useState(null),[v,C]=x.useState(null),y=x.useRef(!1),L=m?!!o||!!m.closest("form"):!0,E={checked:h,disabled:r,setChecked:g,control:m,setControl:b,name:a,form:o,value:d,hasConsumerStoppedPropagationRef:y,required:c,defaultChecked:l1(s)?!1:s,isFormControl:L,bubbleInput:v,setBubbleInput:C};return f.jsx(iut,{scope:e,...E,children:sut(u)?u(E):i})}var LIe="CheckboxTrigger",EIe=x.forwardRef(({__scopeCheckbox:n,onKeyDown:e,onClick:t,...i},s)=>{const{control:r,value:o,disabled:a,checked:l,required:c,setControl:d,setChecked:u,hasConsumerStoppedPropagationRef:h,isFormControl:g,bubbleInput:m}=Kre(LIe,n),b=Ui(s,d),v=x.useRef(l);return x.useEffect(()=>{const C=r==null?void 0:r.form;if(C){const y=()=>u(v.current);return C.addEventListener("reset",y),()=>C.removeEventListener("reset",y)}},[r,u]),f.jsx(ui.button,{type:"button",role:"checkbox","aria-checked":l1(l)?"mixed":l,"aria-required":c,"data-state":kIe(l),"data-disabled":a?"":void 0,disabled:a,value:o,...i,ref:b,onKeyDown:Lt(e,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:Lt(t,C=>{u(y=>l1(y)?!0:!y),m&&g&&(h.current=C.isPropagationStopped(),h.current||C.stopPropagation())})})});EIe.displayName=LIe;var DIe=x.forwardRef((n,e)=>{const{__scopeCheckbox:t,name:i,checked:s,defaultChecked:r,required:o,disabled:a,value:l,onCheckedChange:c,form:d,...u}=n;return f.jsx(nut,{__scopeCheckbox:t,checked:s,defaultChecked:r,disabled:a,required:o,onCheckedChange:c,name:i,form:d,value:l,internal_do_not_use_render:({isFormControl:h})=>f.jsxs(f.Fragment,{children:[f.jsx(EIe,{...u,ref:e,__scopeCheckbox:t}),h&&f.jsx(IIe,{__scopeCheckbox:t})]})})});DIe.displayName=aB;var RIe="CheckboxIndicator",NIe=x.forwardRef((n,e)=>{const{__scopeCheckbox:t,forceMount:i,...s}=n,r=Kre(RIe,t);return f.jsx(kl,{present:i||l1(r.checked)||r.checked===!0,children:f.jsx(ui.span,{"data-state":kIe(r.checked),"data-disabled":r.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...n.style}})})});NIe.displayName=RIe;var TIe="CheckboxBubbleInput",IIe=x.forwardRef(({__scopeCheckbox:n,...e},t)=>{const{control:i,hasConsumerStoppedPropagationRef:s,checked:r,defaultChecked:o,required:a,disabled:l,name:c,value:d,form:u,bubbleInput:h,setBubbleInput:g}=Kre(TIe,n),m=Ui(t,g),b=ire(r),v=Xne(i);x.useEffect(()=>{const y=h;if(!y)return;const L=window.HTMLInputElement.prototype,R=Object.getOwnPropertyDescriptor(L,"checked").set,T=!s.current;if(b!==r&&R){const N=new Event("click",{bubbles:T});y.indeterminate=l1(r),R.call(y,l1(r)?!1:r),y.dispatchEvent(N)}},[h,b,r,s]);const C=x.useRef(l1(r)?!1:r);return f.jsx(ui.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??C.current,required:a,disabled:l,name:c,value:d,form:u,...e,tabIndex:-1,ref:m,style:{...e.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});IIe.displayName=TIe;function sut(n){return typeof n=="function"}function l1(n){return n==="indeterminate"}function kIe(n){return l1(n)?"indeterminate":n?"checked":"unchecked"}function rut({className:n,...e}){return f.jsx(DIe,{"data-slot":"checkbox",className:Le("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",n),...e,children:f.jsx(NIe,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5"})})})}function AIe({isPrimaryKey:n,onPrimaryKeyChange:e}){const t=!!n,i=s=>{e&&e(s)};return f.jsx(rut,{className:"cursor-pointer",checked:t,onCheckedChange:i,"aria-label":"Primary Key"})}const i_e={[Mu.CONNECTED]:{icon:sH,color:"text-green-500",label:"Connected",description:"Field is connected to the data source"},[Mu.CONNECTED_WITH_DEFINITION_MISMATCH]:{icon:oH,color:"text-orange-500",label:"Connected with issues",description:"Field is connected but has definition mismatches"},[Mu.DISCONNECTED]:{icon:OBe,color:"text-red-500",label:"Disconnected",description:"Field is not connected to the data source"}};function MIe({status:n}){if(!(n in i_e))return null;const e=i_e[n],{icon:t,color:i,label:s,description:r}=e,o=`schema-field-status-tooltip-${n}`;return f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(t,{className:Le("h-5 w-5",i),role:"img","aria-label":s,"aria-describedby":o,tabIndex:0})}),f.jsxs(kn,{id:o,side:"bottom",role:"tooltip",children:[f.jsx("div",{className:"text-xs font-medium",children:s}),f.jsx("div",{className:"mt-1 max-w-xs text-xs break-words whitespace-normal",children:r})]})]})})}function Zre({type:n,storageType:e,onTypeChange:t}){const i=e===lt.GOOGLE_BIGQUERY?Object.values(Ho):e===lt.AWS_ATHENA?Object.values(Gse):Object.values(qse),s=r=>{t&&(e===lt.GOOGLE_BIGQUERY||lt.AWS_ATHENA,t(r))};return f.jsxs($c,{value:n,onValueChange:s,children:[f.jsx(qc,{className:"cursor-pointer",size:"sm",children:f.jsx(Gc,{placeholder:"Select field type"})}),f.jsx(Kc,{className:"max-h-[300px]",children:i.map(r=>f.jsx(fo,{value:r,children:r},r))})]})}function out({table:n}){return f.jsx("div",{className:"px-3 text-right",children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn","aria-label":"Toggle columns",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:n.getAllColumns().filter(e=>e.getCanHide()&&e.id!=="actions").map(e=>f.jsx(wn,{className:"capitalize",children:f.jsxs("label",{className:"flex items-center space-x-2",children:[f.jsx("button",{type:"button",role:"checkbox","aria-checked":e.getIsVisible(),"data-state":e.getIsVisible()?"checked":"unchecked","aria-label":`Toggle column ${e.columnDef.meta?e.columnDef.meta.title??e.id:e.id}`,className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:()=>{e.toggleVisibility(!e.getIsVisible())},children:e.getIsVisible()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),f.jsx("span",{children:e.columnDef.meta?e.columnDef.meta.title??e.id:e.id})]})},e.id))})]})})}function aut({id:n,placeholder:e="Search",value:t,onChange:i,debounceTime:s=500,className:r,"aria-label":o}){const[a,l]=x.useState(t),c=x.useRef(!0);x.useEffect(()=>{(t===""||c.current)&&(l(t),c.current=!1)},[t]);const d=x.useCallback(u=>{const h=u.target.value;l(h);const g=setTimeout(()=>{i(h)},s);return()=>{clearTimeout(g)}},[i,s]);return f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon","aria-hidden":"true"}),f.jsx(vn,{id:n,placeholder:e,value:a,onChange:d,className:r??"dm-card-toolbar-search-input","aria-label":o??e})]})}function lut({searchInputId:n,onAddField:e,filterValue:t,onFilterChange:i,statusCounts:s,disabled:r=!1}){return f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsx("div",{className:"dm-card-toolbar-left",children:f.jsx(aut,{id:n,placeholder:"Search fields",value:t,onChange:i,className:"dm-card-toolbar-search-input","aria-label":"Search fields"})}),f.jsxs("div",{className:"dm-card-toolbar-right",children:[s&&f.jsx("div",{className:"mr-3 flex items-center gap-3",children:Object.entries(s).map(([o,a])=>a===0?null:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(MIe,{status:o}),f.jsx("span",{className:"text-sm font-medium text-gray-500",children:a})]},o))}),f.jsxs(rt,{variant:"outline",className:"dm-card-table-add-field-btn cursor-pointer",onClick:e,disabled:r,"aria-label":"Add new field",children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"Add Field"]})]})]})}const cut={dragHandle:{left:0,zIndex:1},status:{left:20,zIndex:1},name:{left:56,zIndex:1},actions:{right:0,zIndex:1}};function n_e(n,e={}){const t=cut[n];return t?{...e,position:"sticky",zIndex:t.zIndex,...t.left!==void 0&&{left:t.left},...t.right!==void 0&&{right:t.right}}:e}function dut({fields:n,columns:e,onAddRow:t,fieldsForStatusCount:i,onSearchChange:s,dragContext:r,dragContextProps:o,rowComponent:a=qr,getRowId:l}){const{isSchemaActualizationLoading:c}=Zu(),d=e,u=r,h=a,{columnVisibility:g,setColumnVisibility:m}=uct(d),b=pC({data:n,columns:d,getCoreRowModel:gC(),getFilteredRowModel:HR(),columnResizeMode:"onChange",enableColumnResizing:!0,state:{columnVisibility:g},onColumnVisibilityChange:m,enableGlobalFilter:!0,globalFilterFn:hct,defaultColumn:{enableResizing:!0,size:0,minSize:0}}),{value:v,onChange:C,searchValue:y}=fct(b),L=x.useRef("");x.useEffect(()=>{s&&y!==L.current&&(L.current=y,s(y))},[y,s]);const E=x.useMemo(()=>{const N={[Mu.CONNECTED]:0,[Mu.CONNECTED_WITH_DEFINITION_MISMATCH]:0,[Mu.DISCONNECTED]:0};return(i??n).forEach(M=>{M.status in N&&N[M.status]++}),N},[n,i]);return f.jsxs("div",{className:"space-y-4",children:[t&&f.jsx(lut,{table:b,searchInputId:"schema-fields-search-input",onAddField:t,filterValue:v,onFilterChange:C,statusCounts:E,disabled:c}),f.jsx("div",{className:"dm-card-table-wrap mb-0",children:f.jsxs(mC,{id:"schema-fields-table",className:"w-full table-auto",role:"table",children:[f.jsx(_C,{className:"dm-card-table-header",children:b.getHeaderGroups().map(N=>f.jsx(qr,{className:"dm-card-table-header-row",children:N.headers.map(I=>f.jsx(vC,{className:"bg-secondary dark:bg-background",style:n_e(I.column.id,{width:I.getSize()!==0?I.getSize():void 0,whiteSpace:"nowrap",cursor:"default"}),children:I.isPlaceholder?null:typeof I.column.columnDef.header=="function"?I.column.columnDef.header(I.getContext()):I.column.columnDef.header},I.id))},N.id))}),f.jsx(bC,{className:"dm-card-table-body",children:b.getRowModel().rows.length?f.jsx(u,{...o,children:b.getRowModel().rows.map(N=>f.jsx(h,{id:l?l(N):N.index,row:N,children:N.getVisibleCells().map(I=>f.jsx(Rl,{className:"bg-background dark:bg-muted",style:n_e(I.column.id,{width:I.column.getSize()!==0?I.column.getSize():void 0,whiteSpace:"pre",paddingTop:8,paddingBottom:8}),children:I.column.columnDef.cell&&typeof I.column.columnDef.cell=="function"?I.column.columnDef.cell(I.getContext()):null},I.id))},N.id))}):f.jsx(qr,{children:f.jsx(Rl,{colSpan:d.length,className:"text-center text-gray-400",style:{whiteSpace:"nowrap"},children:"Output schema has no configured fields"})})})]})}),t&&f.jsxs(rt,{variant:"outline",className:"dm-card-table-add-field-btn bg-background dark:bg-muted w-full cursor-pointer rounded-t-none border-0",onClick:t,disabled:c,"aria-label":"Add new field",children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"Add Field"]})]})}function Yre({fields:n,onFieldsChange:e,onAddRow:t,createNewField:i,renderTypeCell:s,additionalColumns:r=[],fieldsForStatusCount:o,onSearchChange:a,nameColumnHeader:l,nameColumnCell:c,primaryKeyColumnCell:d,aliasColumnCell:u,descriptionColumnCell:h,actionsColumnCell:g,dragContext:m,dragContextProps:b,rowComponent:v,getRowId:C}){const y=x.useCallback((N,I)=>{if(e){const M=[...n];M[N]={...M[N],...I},e(M)}},[n,e]),L=x.useCallback(()=>{if(e){const N=i();e([...n,N])}},[n,e,i]),E=x.useCallback(N=>{if(e){const I=[...n];I.splice(N,1),e(I)}},[n,e]),R=x.useMemo(()=>[{id:"dragHandle",header:"",size:24,enableHiding:!1},{accessorKey:"status",header:"",size:36,cell:({row:N})=>f.jsx(MIe,{status:N.getValue("status")}),enableHiding:!1},{accessorKey:"name",header:l??(()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"Name"}),f.jsx(kn,{children:"Field name in the output schema"})]})),size:80,cell:({row:N})=>c?c({row:N,updateField:y}):f.jsx(jE,{value:lct(N.getValue("name")),onValueChange:I=>{y(N.index,{name:I})},placeholder:"Field name is required",isBold:!0}),enableHiding:!1},{accessorKey:"isPrimaryKey",header:()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"PK"}),f.jsx(kn,{children:"Is field must be considered as a part of the output Primary Key"})]}),size:36,cell:({row:N})=>d?d({row:N,updateField:y}):f.jsx(AIe,{isPrimaryKey:N.getValue("isPrimaryKey"),onPrimaryKeyChange:I=>{y(N.index,{isPrimaryKey:I})}}),enableHiding:!1},{accessorKey:"alias",header:()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"Alias"}),f.jsx(kn,{children:"Alternative name for the field"})]}),size:80,cell:({row:N})=>u?u({row:N,updateField:y}):f.jsx(jE,{value:N.getValue("alias"),onValueChange:I=>{y(N.index,{alias:I})},placeholder:"-"})},{accessorKey:"description",header:()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"Description"}),f.jsx(kn,{children:"Detailed information about the field"})]}),cell:({row:N})=>h?h({row:N,updateField:y}):f.jsx(jE,{value:N.getValue("description"),onValueChange:I=>{y(N.index,{description:I})},minRows:5,placeholder:"-"})},{id:"actions",header:({table:N})=>f.jsx(out,{table:N}),cell:({row:N,table:I})=>g?g({row:N,table:I}):f.jsx(xIe,{row:N,onDeleteRow:e?E:void 0}),size:40,enableResizing:!1,enableHiding:!1}],[y,E,e,l,c,d,u,h,g]),T=x.useMemo(()=>{const I={accessorKey:"type",header:()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default pl-[12px]",children:"Type"}),f.jsx(kn,{children:"Data type of the field"})]}),size:80,cell:P=>s({row:P.row,updateField:y}),enableHiding:!1},M=[...R];if(M.splice(3,0,I),r.length>0){const P=[...r];P.sort((H,j)=>{const V=H.columnIndex??1/0,W=j.columnIndex??1/0;return V-W}),P.forEach(H=>{if(H.columnIndex!==void 0){const j=Math.min(Math.max(0,H.columnIndex),M.length);M.splice(j,0,H)}else M.splice(M.length-1,0,H)})}return M},[R,s,y,r]);return f.jsx(dut,{fields:n,columns:T,onFieldsChange:e,onAddRow:t??(e?L:void 0),fieldsForStatusCount:o,onSearchChange:a,dragContext:m,dragContextProps:b,rowComponent:v,getRowId:C})}function uut({fields:n,onFieldsChange:e}){const{expandedRecords:t,hasRecordFields:i,toggleRecordExpansion:s,toggleAllRecords:r,flattenedFields:o,handleSearchChange:a,isRecordType:l,topLevelFields:c,allExpanded:d}=gct(n),{updateField:u,handleDeleteRow:h,handleAddNestedField:g,handleAddRow:m}=pct(n,o,e,H=>H),b=x.useCallback(()=>({name:"",type:Ho.STRING,mode:d2.NULLABLE,isPrimaryKey:!1,status:Mu.DISCONNECTED}),[]),v=x.useCallback(({row:H})=>f.jsx(Zre,{type:H.getValue("type"),storageType:lt.GOOGLE_BIGQUERY,onTypeChange:j=>{u(H.index,{type:j})}}),[u]),C=x.useMemo(()=>[{accessorKey:"mode",header:()=>f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default pl-[12px]",children:"Mode"}),f.jsx(kn,{style:{whiteSpace:"pre"},children:`BigQuery Field mode:
|
|
739
739
|
NULLABLE - field can be NULL
|
|
740
740
|
REQUIRED - field cant be NULL
|
|
741
|
-
REPEATED - field is an Array of Type`})]}),size:80,cell:({row:H})=>f.jsx(eut,{mode:H.getValue("mode"),onModeChange:j=>{u(H.index,{mode:j})}}),columnIndex:4}],[u]),y=x.useCallback(()=>f.jsxs("div",{className:"flex items-center",children:[i&&f.jsx(Xdt,{isAllExpanded:d,onToggle:r}),f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"Name"}),f.jsx(kn,{children:"Field name in the output schema"})]})]}),[i,d,r]),L=x.useCallback(({row:H})=>{const j=o[H.index],W=(j.type===Ho.RECORD||j.type===Ho.STRUCT)&&j.fields&&j.fields.length>0,U=j.path??"",B=j.level??0,K=t.has(U);return f.jsxs("div",{className:"flex items-center",children:[B>0&&f.jsx("div",{style:{width:`${String(B*16-(W?4:0))}px`},className:"flex-shrink-0"}),W?f.jsx(Qdt,{isExpanded:K,onToggle:()=>{s(U)},ariaLabel:K?"Collapse nested fields":"Expand nested fields"}):i&&f.jsx("div",{className:"w-5"}),f.jsx(jE,{value:H.getValue("name"),onValueChange:X=>{u(H.index,{name:X})},placeholder:"Field name is required",isBold:!0})]})},[o,t,i,s,u]),E=x.useCallback(({row:H})=>{const j=o[H.index],V=j.type===Ho.RECORD||j.type===Ho.STRUCT;return(j.level??0)===0&&!V?f.jsx(AIe,{isPrimaryKey:H.getValue("isPrimaryKey"),onPrimaryKeyChange:U=>{u(H.index,{isPrimaryKey:U})}}):f.jsx("div",{})},[o,u]),R=x.useCallback(({row:H})=>f.jsx(jE,{value:H.getValue("description"),onValueChange:j=>{u(H.index,{description:j})},minRows:5,placeholder:"-"}),[u]),T=x.useCallback(({row:H})=>f.jsx(jE,{value:H.getValue("alias"),onValueChange:j=>{u(H.index,{alias:j})},placeholder:"-"}),[u]),N=x.useCallback(({row:H})=>f.jsx(xIe,{row:H,onDeleteRow:e?h:void 0,onAddNestedField:e?g:void 0,isRecordType:l}),[e,h,g,l]),{handleDragEnd:I}=Are(n,e,o),M=x.useCallback(H=>{const j=o[H.index];return j.path??String(o.indexOf(j))},[o]),P=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:P,collisionDetection:Bre,onDragEnd:I,children:f.jsx(Yre,{fields:o,onFieldsChange:e,onAddRow:m,createNewField:b,renderTypeCell:v,additionalColumns:C,fieldsForStatusCount:c,onSearchChange:a,nameColumnHeader:y,nameColumnCell:L,primaryKeyColumnCell:E,aliasColumnCell:T,descriptionColumnCell:R,actionsColumnCell:N,dragContext:Gre,dragContextProps:{items:o.map(H=>H.path??String(o.indexOf(H))),strategy:$re},rowComponent:qre,getRowId:M})})}function hut({fields:n,onFieldsChange:e}){const t=x.useCallback(()=>({name:"",type:Gse.STRING,isPrimaryKey:!1,status:Mu.DISCONNECTED}),[]),i=x.useCallback(({row:o,updateField:a})=>f.jsx(Zre,{type:o.getValue("type"),storageType:lt.AWS_ATHENA,onTypeChange:l=>{a(o.index,{type:l})}}),[]),{handleDragEnd:s}=Are(n,e),r=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:r,collisionDetection:Bre,onDragEnd:s,children:f.jsx(Yre,{fields:n,onFieldsChange:e,createNewField:t,renderTypeCell:i,dragContext:Gre,dragContextProps:{items:n.map((o,a)=>a),strategy:$re},rowComponent:qre})})}function fut({fields:n,onFieldsChange:e}){const t=x.useCallback(()=>({name:"",type:qse.VARCHAR,isPrimaryKey:!1,status:Mu.DISCONNECTED}),[]),i=x.useCallback(({row:o,updateField:a})=>f.jsx(Zre,{type:o.getValue("type"),storageType:lt.SNOWFLAKE,onTypeChange:l=>{a(o.index,{type:l})}}),[]),{handleDragEnd:s}=Are(n,e),r=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:r,collisionDetection:Bre,onDragEnd:s,children:f.jsx(Yre,{fields:n,onFieldsChange:e,createNewField:t,renderTypeCell:i,dragContext:Gre,dragContextProps:{items:n.map((o,a)=>a),strategy:$re},rowComponent:qre})})}function gut({schema:n,storageType:e,onFieldsChange:t}){const i=x.useMemo(()=>{if(!n){const s=act(e);return t(s.fields),s}return n},[n,e,t]);return QTe(i)?f.jsx(uut,{fields:i.fields,onFieldsChange:t}):JTe(i)?f.jsx(hut,{fields:i.fields,onFieldsChange:t}):eIe(i)?f.jsx(fut,{fields:i.fields,onFieldsChange:t}):f.jsx("div",{className:"p-4 text-center",children:f.jsx("p",{children:"Unsupported schema type"})})}function put({definitionType:n}){const{dataMart:e,updateDataMartSchema:t,isLoading:i,error:s,runSchemaActualization:r,isSchemaActualizationLoading:o}=Zu(),{id:a="",schema:l}=e??{},{schema:c,isDirty:d,updateSchema:u,resetSchema:h}=cct(l),{operationStatus:g,startSaveOperation:m}=dct(i,s);x.useEffect(()=>{g==="success"&&h()},[g,h]);const b=x.useCallback(E=>{u(E)},[u]),v=x.useCallback(()=>{a&&c&&(m(),t(a,c).then(()=>{r==null||r()}))},[a,c,m,t,r]),C=x.useCallback(()=>{r==null||r()},[r]),y=x.useCallback(()=>{h()},[h]),L=i||o;return e?f.jsxs("div",{className:"space-y-4",children:[f.jsx(gut,{schema:c,storageType:e.storage.type,onFieldsChange:b}),f.jsxs("div",{className:"align-items-center mt-8 flex justify-between",children:[f.jsxs("div",{className:"flex space-x-4",children:[f.jsx(rt,{variant:"default",onClick:v,disabled:!d||L,children:"Save"}),f.jsx(rt,{type:"button",variant:"ghost",onClick:y,disabled:!d||L,children:"Discard"})]}),f.jsx(rt,{type:"button",variant:"outline",onClick:C,disabled:!n||L,children:"Refresh schema"})]})]}):f.jsx("div",{children:"Error: Data mart not found"})}function mut(){const n=Dne(),{id:e,projectId:t}=n;return e?t?f.jsx("div",{className:"dm-page",children:f.jsx(LRe,{children:f.jsx(Qst,{id:e})})}):f.jsx("div",{className:"dm-page-header",children:"Project ID is required"}):f.jsx("div",{className:"dm-page-header",children:"Data Mart ID is required"})}function _ut({className:n,...e}){return f.jsx("div",{"data-slot":"card",className:Le("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",n),...e})}function but({className:n,...e}){return f.jsx("div",{"data-slot":"card-header",className:Le("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",n),...e})}function vut({className:n,...e}){return f.jsx("div",{"data-slot":"card-title",className:Le("leading-none font-semibold",n),...e})}function Cut({className:n,...e}){return f.jsx("div",{"data-slot":"card-description",className:Le("text-muted-foreground text-sm",n),...e})}function wut({className:n,...e}){return f.jsx("div",{"data-slot":"card-content",className:Le("px-6",n),...e})}function yut({className:n,...e}){return f.jsx("div",{"data-slot":"card-footer",className:Le("flex items-center px-6 [.border-t]:pt-6",n),...e})}const Xre=x.createContext({isCollapsed:!1,collapsible:!1,handleCollapse:()=>{throw new Error("CollapsibleCardContext: handleCollapse not implemented")}});function hp({icon:n,tooltip:e,subtitle:t,children:i}){const{isCollapsed:s}=x.useContext(Xre);return f.jsxs("div",{className:"flex items-center gap-2 self-center",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"text-foreground flex h-7 w-7 items-center justify-center rounded-sm bg-gray-200/50 transition-colors duration-200 group-hover:bg-gray-200/75 dark:bg-white/8 dark:group-hover:bg-white/10",children:f.jsx(n,{size:18})}),f.jsx(vut,{className:"text-md text-foreground leading-none font-medium",children:i})]}),t&&f.jsx(Cut,{className:Le("text-md text-muted-foreground/50",!s&&"hidden"),children:t}),e&&f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{className:"pointer-events-none ml-2 flex items-center opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",children:[f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors"}),f.jsx("span",{className:"sr-only",children:e})]})}),f.jsx(kn,{children:f.jsx("p",{children:e})})]})})]})}hp.displayName="CollapsibleCardHeaderTitle";function $M({children:n,className:e}){const t=i=>{i.stopPropagation()};return f.jsx("div",{className:Le("flex items-center gap-2 self-center",e),onClick:t,children:n})}$M.displayName="CollapsibleCardHeaderActions";function fp({children:n}){const{collapsible:e,isCollapsed:t,handleCollapse:i}=x.useContext(Xre);let s,r;return x.Children.forEach(n,o=>{if(x.isValidElement(o))switch(o.type){case hp:s=o;break;case $M:r=o;break}}),f.jsxs(but,{className:Le("group flex items-start justify-between gap-4 px-4 py-4",e&&"cursor-pointer"),onClick:e?i:void 0,children:[s,f.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&f.jsx("div",{className:Le("flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 hover:bg-gray-200/50 dark:hover:bg-white/4"),children:f.jsx("div",{className:Le("transform transition-transform duration-200",t?"rotate-0":"rotate-180"),children:f.jsx(Pp,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})})]})]})}fp.displayName="CollapsibleCardHeader";function gp({children:n}){return f.jsx(wut,{className:"px-4 pt-1",children:n})}gp.displayName="CollapsibleCardContent";function E_({left:n,right:e}){return f.jsxs(yut,{className:"flex items-center gap-2 px-4 py-4",children:[f.jsx("div",{className:"flex flex-grow items-center gap-2",children:n}),e&&f.jsx("div",{className:"flex items-center",children:e})]})}E_.displayName="CollapsibleCardFooter";const s_e="collapsed-card-";function c1({children:n,className:e,variant:t="default",collapsible:i=!1,defaultCollapsed:s=!1,onCollapsedChange:r,name:o}){const a=o?np.get(`${s_e}${o}`,"boolean")??s:s,[l,c]=x.useState(a);x.useEffect(()=>{o&&np.set(`${s_e}${o}`,l)},[l,o]);const d=()=>{const b=!l;c(b),r==null||r(b)};let u,h,g;x.Children.forEach(n,b=>{if(x.isValidElement(b))switch(b.type){case fp:u=b;break;case gp:h=b;break;case E_:g=b;break}});const m={default:"rounded-md p-0 gap-0 bg-muted/50 dark:bg-white/4 border-0 border-b border-gray-200 dark:border-white/8 shadow-none",dense:"rounded-md p-0 gap-0 bg-muted/50 dark:bg-white/4 border-0 border-b border-gray-200 dark:border-white/8 shadow-none text-sm",flat:"rounded-md p-0 gap-0 border-0 border-b-0 shadow-none"};return f.jsx(Xre.Provider,{value:{isCollapsed:l,collapsible:i,handleCollapse:d},children:f.jsxs(_ut,{className:Le(m[t],e),children:[u,f.jsx("div",{className:Le("grid transition-all duration-200",l?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:f.jsxs("div",{className:"overflow-hidden",children:[h,g]})})]})})}function Sut(){const{dataMart:n,updateDataMartStorage:e}=og(),t=(n==null?void 0:n.definitionType)??null,[i,s]=x.useState(t);return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs(c1,{collapsible:!0,name:"data-storage",children:[f.jsx(fp,{children:f.jsx(hp,{icon:j1,tooltip:"Configure where your data will be stored",children:"Storage"})}),f.jsx(gp,{children:(n==null?void 0:n.storage)&&f.jsx(wat,{dataStorage:n.storage,onDataStorageChange:e})}),f.jsx(E_,{})]}),f.jsxs(c1,{collapsible:!0,name:"input-source",children:[f.jsx(fp,{children:f.jsx(hp,{icon:Pne,tooltip:"Configure how to extract data from your data warehouse",children:"Input Source"})}),f.jsx(gp,{children:n&&f.jsx(oct,{definitionType:i,initialDefinitionType:t,setDefinitionType:s})}),f.jsx(E_,{})]}),f.jsxs(c1,{collapsible:!0,name:"output-schema",children:[f.jsx(fp,{children:f.jsx(hp,{icon:KHe,tooltip:"Configure your data mart output schema",children:"Output Schema"})}),f.jsx(gp,{children:n&&f.jsx(put,{definitionType:i})}),f.jsx(E_,{})]})]})}function xut({row:n,onDeleteSuccess:e,onEditReport:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),[a,l]=x.useState(!1),{deleteReport:c,fetchReportsByDataMartId:d,runReport:u}=rg(),h=`actions-menu-${n.original.id}`,g=x.useCallback(async()=>{try{await c(n.original.id),await d(n.original.dataMart.id),e==null||e(),l(!1)}catch(C){console.error("Failed to delete Google Sheet:",C)}},[c,d,e,n.original.id,n.original.dataMart.id]),m=x.useCallback(()=>{t==null||t(n.original),o(!1)},[t,n.original]),b=x.useCallback(async()=>{try{s(!0),await u(n.original.id)}catch(C){console.error("Failed to run report:",C)}finally{s(!1)}},[u,n.original.id]),v=x.useCallback(()=>{l(!0),o(!1)},[]);return f.jsxs("div",{className:"text-right",onClick:C=>{C.stopPropagation()},children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":`Actions for report: ${n.original.title}`,"aria-haspopup":"true","aria-expanded":r,"aria-controls":h,children:[f.jsx("span",{className:"sr-only",children:"Open menu"}),f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon","aria-hidden":"true"})]})}),f.jsxs(Ol,{id:h,align:"end",role:"menu",children:[f.jsxs(wn,{onClick:C=>{C.stopPropagation(),m()},role:"menuitem",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit report"]}),VH(n.original.destinationConfig)&&f.jsxs(f.Fragment,{children:[f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),b()},disabled:i,role:"menuitem","aria-label":i?"Running report...":`Run report: ${n.original.title}`,children:[f.jsx(rH,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),i?"Running...":"Run report"]}),f.jsx(wn,{asChild:!0,children:f.jsxs("a",{href:Ese(n.original.destinationConfig.spreadsheetId,n.original.destinationConfig.sheetId),target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:C=>{C.stopPropagation()},children:[f.jsx(lBe,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Open document"]})})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),v()},role:"menuitem","aria-label":`Delete report: ${n.original.title}`,children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete report"})]})]})]}),f.jsx(Ma,{open:a,onOpenChange:l,title:"Delete Report",description:`Are you sure you want to delete "${n.original.title}"? This action cannot be undone.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{g()},variant:"destructive"})]})}const Lut={[Fr.SUCCESS]:{icon:sH,color:"text-green-500",label:"Success"},[Fr.ERROR]:{icon:rF,color:"text-red-500",label:"Fail"},[Fr.RUNNING]:{icon:NR,color:"text-primary animate-spin",label:"In progress"},[Fr.CANCELLED]:{icon:rF,color:"text-gray-500",label:"Cancelled"}};function OIe({status:n,error:e}){if(!n)return null;const t=Lut[n],{icon:i,color:s,label:r}=t,o=`status-tooltip-${n}-${e?"error":"normal"}`,a=()=>n===Fr.ERROR&&e?`${r}: ${e}`:r;return f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(i,{className:Le("h-5 w-5",s),role:"img","aria-label":a(),"aria-describedby":o,tabIndex:0})}),f.jsxs(kn,{id:o,side:"bottom",role:"tooltip",children:[f.jsx("div",{className:"text-xs",children:r}),n===Fr.ERROR&&e&&f.jsx("div",{className:"mt-1 max-w-xs text-xs break-words whitespace-normal",children:e})]})]})})}var Bv=(n=>(n.TITLE="title",n.LAST_RUN_DATE="lastRunDate",n.LAST_RUN_STATUS="lastRunStatus",n))(Bv||{});const Eut={[Bv.TITLE]:"Title",[Bv.LAST_RUN_DATE]:"Last Run Date",[Bv.LAST_RUN_STATUS]:"Last Run Status"},r_e=n=>{switch(n){case"right":return"text-right";case"center":return"text-center";default:return"text-left"}},Dut=({onDeleteSuccess:n,onEditReport:e}={})=>[{accessorKey:Bv.TITLE,header:({column:t})=>f.jsx(La,{column:t,children:Eut[Bv.TITLE]}),cell:({row:t})=>t.original.title,enableColumnFilter:!0,size:50},{accessorKey:Bv.LAST_RUN_DATE,header:({column:t})=>f.jsx(La,{column:t,children:"Last Run Date"}),cell:({row:t})=>{const i=t.original.lastRunDate;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Never run"})},size:25},{accessorKey:Bv.LAST_RUN_STATUS,header:({column:t})=>f.jsx(La,{column:t,children:"Last Run Status"}),cell:({row:t})=>t.original.lastRunStatus?f.jsx(OIe,{status:t.original.lastRunStatus,error:t.original.lastRunError}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"—"}),size:25},{id:"actions",header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(xut,{row:t,onDeleteSuccess:n,onEditReport:e}),size:80}];function Rut({destination:n,onEditReport:e}){const{reports:t,setPollingConfig:i}=rg(),s=x.useMemo(()=>t.filter(h=>h.dataDestination.type===St.GOOGLE_SHEETS&&h.dataDestination.id===n.id),[t,n.id]);x.useEffect(()=>{i({initialPollingIntervalMs:2e3,initialPollCount:3,regularPollingIntervalMs:5e3})},[i]);const r=x.useMemo(()=>Dut({onDeleteSuccess:()=>{},onEditReport:e}),[e]),{sorting:o,setSorting:a,columnVisibility:l,setColumnVisibility:c}=zS({columns:r,storageKeyPrefix:`data-mart-google-sheets-reports-${n.id}`,defaultSortingColumn:"lastRunDate"}),d=pC({data:s,columns:r,getCoreRowModel:gC(),onSortingChange:a,getSortedRowModel:WS(),state:{sorting:o,columnVisibility:l},onColumnVisibilityChange:c}),u=`google-sheets-reports-table-${n.id}`;return f.jsx("div",{className:"w-full",children:f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:u,className:"dm-card-table",role:"table","aria-label":`${n.title} reports`,children:[f.jsx(_C,{className:"dm-card-table-header",children:d.getHeaderGroups().map(h=>f.jsx(qr,{className:"dm-card-table-header-row",children:h.headers.map(g=>f.jsx(vC,{className:r_e(g.column.columnDef._align),style:g.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(g.column.getSize())}%`},scope:"col",children:g.isPlaceholder?null:typeof g.column.columnDef.header=="function"?g.column.columnDef.header(g.getContext()):g.column.columnDef.header},g.id))},h.id))}),f.jsx(bC,{className:"dm-card-table-body",children:d.getRowModel().rows.length?d.getRowModel().rows.map((h,g)=>f.jsx(qr,{onClick:()=>{const m=t.find(b=>b.id===h.original.id);m&&e(m)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":g+1,children:h.getVisibleCells().map((m,b)=>f.jsx(Rl,{className:`px-6 whitespace-normal ${r_e(m.column.columnDef._align)}`,style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},role:"cell","aria-colindex":b+1,children:typeof m.column.columnDef.cell=="function"?m.column.columnDef.cell(m.getContext()):m.column.columnDef.cell},m.id))},h.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:r.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No reports for this destination"})})})})]})})})}function Nut({row:n,onDeleteSuccess:e,onEditReport:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),[a,l]=x.useState(!1),{deleteReport:c,fetchReportsByDataMartId:d,runReport:u}=rg(),h=`actions-menu-${n.original.id}`,g=x.useCallback(async()=>{try{await c(n.original.id),await d(n.original.dataMart.id),e==null||e(),l(!1)}catch(C){console.error("Failed to delete report:",C)}},[c,d,e,n.original.id,n.original.dataMart.id]),m=x.useCallback(()=>{t==null||t(n.original),o(!1)},[t,n.original]),b=x.useCallback(async()=>{try{s(!0),await u(n.original.id)}catch(C){console.error("Failed to run report:",C)}finally{s(!1)}},[u,n.original.id]),v=x.useCallback(()=>{l(!0),o(!1)},[]);return f.jsxs("div",{className:"text-right",onClick:C=>{C.stopPropagation()},children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":`Actions for report: ${n.original.title}`,"aria-haspopup":"true","aria-expanded":r,"aria-controls":h,children:[f.jsx("span",{className:"sr-only",children:"Open menu"}),f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon","aria-hidden":"true"})]})}),f.jsxs(Ol,{id:h,align:"end",role:"menu",children:[f.jsxs(wn,{onClick:C=>{C.stopPropagation(),m()},role:"menuitem",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit report"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),b()},disabled:i,role:"menuitem","aria-label":i?"Running report...":`Run report: ${n.original.title}`,children:[f.jsx(rH,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),i?"Running...":"Run report"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),v()},role:"menuitem","aria-label":`Delete report: ${n.original.title}`,children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete report"})]})]})]}),f.jsx(Ma,{open:a,onOpenChange:l,title:"Delete Report",description:`Are you sure you want to delete "${n.original.title}"? This action cannot be undone.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{g()},variant:"destructive"})]})}function d$({column:n,children:e,label:t}){const i=n.getIsSorted(),s=x.useCallback(()=>{n.toggleSorting(n.getIsSorted()==="asc")},[n]),r=()=>i==="asc"?"sorted ascending":i==="desc"?"sorted descending":"not sorted",o=()=>i==="asc"?"ascending":i==="desc"?"descending":"none",a=t??(typeof e=="string"?e:"Column");return f.jsxs(rt,{variant:"ghost",onClick:s,className:"group dm-card-table-header-row-btn","aria-label":`${a} - ${r()}. Click to sort.`,"aria-sort":o(),children:[e,f.jsxs("span",{className:"flex h-4 w-4 items-center justify-center","aria-hidden":"true",children:[i==="asc"&&f.jsx(TD,{className:"text-foreground h-4 w-4"}),i==="desc"&&f.jsx(Pp,{className:"text-foreground h-4 w-4"}),!i&&f.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:f.jsx(TD,{className:"text-muted-foreground h-4 w-4"})})]})]})}var Vv=(n=>(n.TITLE="title",n.LAST_RUN_DATE="lastRunDate",n.LAST_RUN_STATUS="lastRunStatus",n))(Vv||{});const PIe={[Vv.TITLE]:"Title",[Vv.LAST_RUN_DATE]:"Last Run Date",[Vv.LAST_RUN_STATUS]:"Last Run Status"};function Tut({table:n}){return f.jsx("div",{className:"px-4 text-right",children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn","aria-label":"Toggle columns",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:n.getAllColumns().filter(e=>e.getCanHide()&&e.id!=="actions").map(e=>{const t=PIe[e.id]||e.id;return f.jsx(wn,{className:"capitalize",children:f.jsxs("label",{className:"flex items-center space-x-2",children:[f.jsx("button",{type:"button",role:"checkbox","aria-checked":e.getIsVisible(),"data-state":e.getIsVisible()?"checked":"unchecked","aria-label":`Toggle column ${e.id}`,className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:()=>{e.toggleVisibility(!e.getIsVisible())},children:e.getIsVisible()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),f.jsx("span",{children:t})]})},e.id)})})]})})}const o_e=n=>{switch(n){case"right":return"text-right";case"center":return"text-center";default:return"text-left"}},Iut=({onDeleteSuccess:n,onEditReport:e}={})=>[{accessorKey:Vv.TITLE,header:({column:t})=>f.jsx(d$,{column:t,children:PIe[Vv.TITLE]}),cell:({row:t})=>t.original.title,enableColumnFilter:!0,size:50},{accessorKey:Vv.LAST_RUN_DATE,header:({column:t})=>f.jsx(d$,{column:t,children:"Last Run Date"}),cell:({row:t})=>{const i=t.original.lastRunDate;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Never run"})},size:25},{accessorKey:Vv.LAST_RUN_STATUS,header:({column:t})=>f.jsx(d$,{column:t,children:"Last Run Status"}),cell:({row:t})=>t.original.lastRunStatus?f.jsx(OIe,{status:t.original.lastRunStatus,error:t.original.lastRunError}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"—"}),size:25},{id:"actions",header:({table:t})=>f.jsx(Tut,{table:t}),cell:({row:t})=>f.jsx(Nut,{row:t,onDeleteSuccess:n,onEditReport:e}),size:80}];function kut({destinationType:n,destination:e,onEditReport:t}){const{reports:i,setPollingConfig:s}=rg(),r=x.useMemo(()=>i.filter(g=>g.dataDestination.type===n&&g.dataDestination.id===e.id),[i,e.id,n]);x.useEffect(()=>{s({initialPollingIntervalMs:2e3,initialPollCount:3,regularPollingIntervalMs:5e3})},[s]);const o=x.useMemo(()=>Iut({onDeleteSuccess:()=>{},onEditReport:t}),[t]),{sorting:a,setSorting:l,columnVisibility:c,setColumnVisibility:d}=zS({columns:o,storageKeyPrefix:`data-mart-email-reports-${e.id}`,defaultSortingColumn:"lastRunDate"}),u=pC({data:r,columns:o,getCoreRowModel:gC(),onSortingChange:l,getSortedRowModel:WS(),state:{sorting:a,columnVisibility:c},onColumnVisibilityChange:d}),h=`email-reports-table-${e.id}`;return f.jsx("div",{className:"w-full",children:f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:h,className:"dm-card-table",role:"table","aria-label":`${e.title} reports`,children:[f.jsx(_C,{className:"dm-card-table-header",children:u.getHeaderGroups().map(g=>f.jsx(qr,{className:"dm-card-table-header-row",children:g.headers.map(m=>f.jsx(vC,{className:o_e(m.column.columnDef._align),style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},scope:"col",children:m.isPlaceholder?null:typeof m.column.columnDef.header=="function"?m.column.columnDef.header(m.getContext()):m.column.columnDef.header},m.id))},g.id))}),f.jsx(bC,{className:"dm-card-table-body",children:u.getRowModel().rows.length?u.getRowModel().rows.map((g,m)=>f.jsx(qr,{onClick:()=>{const b=i.find(v=>v.id===g.original.id);b&&t(b)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":m+1,children:g.getVisibleCells().map((b,v)=>f.jsx(Rl,{className:`px-6 whitespace-normal ${o_e(b.column.columnDef._align)}`,style:b.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(b.column.getSize())}%`},role:"cell","aria-colindex":v+1,children:typeof b.column.columnDef.cell=="function"?b.column.columnDef.cell(b.getContext()):b.column.columnDef.cell},b.id))},g.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:o.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No reports for this destination"})})})})]})})})}function Aut({children:n,className:e,...t}){return f.jsx("div",{className:Le("group flex items-start justify-center gap-3 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-xs dark:border-0 dark:bg-white/2",e),...t,children:n})}function Mut({children:n,className:e,...t}){return f.jsx("div",{className:Le("flex flex-grow flex-col gap-1 py-4",e),...t,children:n})}function Out({children:n,className:e,...t}){return f.jsx("div",{className:Le("text-md font-medium",e),...t,children:n})}function Put({children:n,className:e,...t}){return f.jsx("div",{className:Le("text-muted-foreground text-sm",e),...t,children:n})}function Fut({checked:n,disabled:e,loading:t,onCheckedChange:i,tooltipTextSwitchOn:s,tooltipTextSwitchOff:r,tooltipTextSwitchDisabled:o}){const a=e?o??"Disabled":n?s:r;return f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{className:"flex items-center justify-center py-5 pl-6",onClick:l=>l.stopPropagation(),children:t?f.jsx(NR,{className:"text-muted-foreground h-5 w-5 animate-spin"}):f.jsx(WTe,{checked:n,disabled:e,onCheckedChange:i})})}),f.jsx(kn,{children:a})]})}function jut({icon:n,className:e,...t}){return f.jsx("div",{className:Le("flex flex-shrink-0 items-center justify-center self-center p-4",e),...t,children:f.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 group-hover:bg-gray-200/50 dark:group-hover:bg-white/4",children:n??f.jsx($d,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})})}function Hut(n){const{dataMart:e}=Zu(),{reports:t,createReport:i,deleteReport:s,fetchReportsByDataMartId:r}=rg(),[o,a]=x.useState(!1),l=x.useMemo(()=>t.find(g=>g.dataDestination.type===St.LOOKER_STUDIO&&g.dataDestination.id===n.id),[t,n.id]),c=x.useMemo(()=>(e==null?void 0:e.status.code)===Ll.PUBLISHED,[e==null?void 0:e.status.code]),d=x.useMemo(()=>!!l,[l]),u=x.useMemo(()=>d?"Available in Looker Studio":"Not available in Looker Studio",[d]),h=x.useCallback(async g=>{if(!(!e||!c)){a(!0);try{if(g){const m={title:`Looker Studio Report - ${n.title}`,dataMartId:e.id,dataDestinationId:n.id,destinationConfig:{type:nl.LOOKER_STUDIO_CONFIG,cacheLifetime:300}};await i(m),await r(e.id)}else l&&(await s(l.id),await r(e.id))}catch(m){console.error("Failed to toggle Looker Studio report:",m)}finally{a(!1)}}},[e,c,n,l,i,s,r]);return{existingReport:l,isLoading:o,isEnabled:c,isChecked:d,dynamicTitle:u,handleSwitchChange:h}}function But({destination:n,onEditReport:e,...t}){const{existingReport:i,isLoading:s,isEnabled:r,isChecked:o,dynamicTitle:a,handleSwitchChange:l}=Hut(n),c=x.useCallback(()=>{i&&e(i)},[i,e]);return f.jsxs(Aut,{className:i?"cursor-pointer dark:hover:bg-white/5":"",onClick:i?c:void 0,...t,children:[f.jsx(Fut,{checked:o,disabled:!r,loading:s,onCheckedChange:d=>void l(d),tooltipTextSwitchOn:"Switch off to remove access",tooltipTextSwitchOff:"Switch on to enable access",tooltipTextSwitchDisabled:"Publish the Data Mart first to enable access in Looker Studio"}),f.jsxs(Mut,{children:[f.jsx(Out,{children:a}),f.jsx(Put,{children:o&&i?f.jsx(f.Fragment,{children:i.lastRunDate?f.jsxs(f.Fragment,{children:["Last fetched"," ",i.lastRunStatus===Fr.SUCCESS&&"successfully ",f.jsx(W1,{date:new Date(i.lastRunDate)}),i.lastRunStatus===Fr.ERROR&&" but failed with error",i.lastRunError&&f.jsx("div",{className:"mt-1 text-red-600 dark:text-red-400",children:i.lastRunError})]}):"Waiting for Looker Studio to fetch data"}):"Switch on to enable access"})]}),o&&i&&f.jsx(jut,{})]})}function Vut(){const{scope:n}=hb();return f.jsx("div",{className:"dm-card",children:f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(Mne,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Google Sheets, Looker Studio… and friends!"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"To send your Data Mart's data to your favorite tools, create a Destination first."}),f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:n("/data-destinations"),className:"flex items-center gap-1",children:["Go to Destinations",f.jsx($d,{className:"h-4 w-4"})]})})]})})}function Wut(){const[n,e]=x.useState(!1),[t,i]=x.useState(xr.CREATE),[s,r]=x.useState(null);return{isOpen:n,mode:t,editingReport:s,handleAddReport:()=>{i(xr.CREATE),r(null),e(!0),Vt({event:"report_open",category:"Report",action:"CreateReport",label:"ReportForm"})},handleEditReport:c=>{i(xr.EDIT),r(c),e(!0),Vt({event:"report_open",category:"Report",action:"EditReport",label:c.dataDestination.type})},handleCloseModal:()=>{e(!1),r(null),Vt({event:"report_close",category:"Report",action:t===xr.EDIT?"Edit":"Create",label:"ReportForm"})}}}const zut=[St.GOOGLE_SHEETS,St.EMAIL,St.SLACK,St.MS_TEAMS,St.GOOGLE_CHAT];function Uut({destination:n,dataMartStatus:e}){const{destinationInfo:t,isVisible:i}=RJe(n),{isOpen:s,mode:r,editingReport:o,handleAddReport:a,handleEditReport:l,handleCloseModal:c}=Wut();return i?f.jsxs(f.Fragment,{children:[f.jsxs(c1,{name:n.id,collapsible:!0,defaultCollapsed:!1,children:[f.jsxs(fp,{children:[f.jsx(hp,{icon:t.icon,children:n.title}),f.jsx($M,{children:zut.includes(n.type)&&f.jsx($ut,{dataMartStatus:e,onAddReport:a})})]}),f.jsx(gp,{children:f.jsx(bht,{destination:n,onEditReport:l})}),f.jsx(E_,{})]}),f.jsx(_ht,{destination:n,isOpen:s,onClose:c,mode:r,initialReport:o})]}):null}function $ut({dataMartStatus:n,onAddReport:e}){const t=(n==null?void 0:n.code)===Ll.DRAFT;return f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{children:f.jsxs(rt,{onClick:e,variant:"outline",size:"sm","aria-label":"Add new report",disabled:t,children:[f.jsx(Gd,{className:"h-4 w-4"}),"Add Report"]})})}),t&&f.jsx(kn,{children:f.jsx("p",{children:"To create a report, publish the Data Mart first"})})]})}function Gut({elementId:n,isOpen:e,delay:t=100,selectText:i=!1}){x.useEffect(()=>{{const s=setTimeout(()=>{const r=document.getElementById(n);if(r){const o=r;o.focus(),i&&o.value?o.select():o.value&&o.setSelectionRange(o.value.length,o.value.length)}},t);return()=>{clearTimeout(s)}}},[e,n,t,i])}const qut=_s({title:pn().min(1,"Title is required"),documentUrl:pn().refine(ADe,"Enter a valid Google Sheets URL"),dataDestinationId:pn().min(1,"Destination is required")});function Kut({initialReport:n,mode:e,dataMartId:t,onSuccess:i,preSelectedDestination:s}){const[r,o]=x.useState(null),[a,l]=x.useState(!1),{updateReport:c,createReport:d,error:u,clearError:h}=rg();x.useEffect(()=>{a&&u&&(o(u),l(!1))},[u,a]);const g=Bp({resolver:pb(qut),defaultValues:{title:(n==null?void 0:n.title)??"",documentUrl:n!=null&&n.destinationConfig&&VH(n.destinationConfig)?`https://docs.google.com/spreadsheets/d/${n.destinationConfig.spreadsheetId}/edit#gid=${n.destinationConfig.sheetId}`:"",dataDestinationId:(n==null?void 0:n.dataDestination.id)??(s==null?void 0:s.id)??""},mode:"onTouched"}),{register:m,handleSubmit:b,formState:v,reset:C}=g,{errors:y,isDirty:L}=v,E=x.useCallback(async R=>{try{o(null),h(),l(!0);const{spreadsheetId:T,sheetId:N}=rJe(R.documentUrl);if(!T){o("Invalid Google Sheets URL");return}let I;if(e===xr.CREATE)I=await d({title:R.title,dataMartId:t,dataDestinationId:R.dataDestinationId,destinationConfig:{type:nl.GOOGLE_SHEETS_CONFIG,spreadsheetId:T,sheetId:N}});else{if(!n){o("Initial report is required for edit mode");return}I=await c(n.id,{title:R.title,dataDestinationId:R.dataDestinationId,destinationConfig:{type:nl.GOOGLE_SHEETS_CONFIG,spreadsheetId:T,sheetId:N}})}if(!I||u){o(u??"An error occurred while submitting the form");return}i==null||i()}catch(T){console.error("Error submitting form:",T),o("An error occurred while submitting the form")}},[e,n,t,d,c,i,h,u]);return{form:g,register:m,handleSubmit:b,errors:y,isDirty:L,reset:C,formError:r,isSubmitting:a,setFormError:o,getValues:g.getValues,onSubmit:E}}function Zut(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a correct document link?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the correct Google Sheets document URL with a Sheet ID (GID), follow these steps:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open your Google Sheets document and select the specific ",f.jsx("strong",{children:"sheet tab"})," ","where the data should be inserted."]}),f.jsxs("li",{children:["Share the document with the service account email and grant it ",f.jsx("strong",{children:"Editor"})," ","access."]}),f.jsxs("li",{children:["While the correct sheet is selected, copy the URL from your browser's address bar — it should include the ",f.jsx("code",{className:"text-sm font-semibold",children:"gid"})," of that sheet."]}),f.jsx("li",{children:"Paste this URL into the field above."})]})]})]})})}function u$(n){return"serviceAccount"in n}function FIe({value:n,children:e,doNotTruncateContent:t}){const[i,s]=x.useState(!1),r=async()=>{n&&(await navigator.clipboard.writeText(n),s(!0),setTimeout(()=>s(!1),2e3))};return f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:o=>o.key==="Enter"&&r(),className:Le("flex cursor-pointer items-center justify-between gap-2 select-none","text-muted-foreground border-input rounded-md border px-3 py-1.5 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors"),children:[f.jsx("span",{className:t?"w-[95%]":"truncate",children:e||n||"No data"}),i?f.jsx(Wc,{className:"h-4 w-4 text-green-500"}):f.jsx(t2,{className:"h-4 w-4"})]})}),f.jsx(kn,{children:f.jsx("p",{children:i?"Copied!":"Click to copy"})})]})})}const Yut=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="google-sheets-edit-form",c="google-sheets-title-input",d="google-sheets-document-url-input",u="google-sheets-data-destination-select",{dataMart:h}=Zu(),{scope:g}=hb(),{dataDestinations:m,fetchDataDestinations:b,loading:v}=MM(),[C,y]=x.useState([]);x.useEffect(()=>{h&&b()},[h,b]),x.useEffect(()=>{if(m.length>0){const H=m.filter(j=>j.type===St.GOOGLE_SHEETS);y(H)}},[m]),Gut({elementId:c,isOpen:!0,delay:150});const{isDirty:L,reset:E,form:R,isSubmitting:T,formError:N,onSubmit:I}=Kut({initialReport:n,mode:e,dataMartId:(h==null?void 0:h.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});x.useEffect(()=>{i&&i(N)},[N,i]),x.useEffect(()=>{if(e===xr.EDIT&&n&&VH(n.destinationConfig))E({title:n.title,documentUrl:Ese(n.destinationConfig.spreadsheetId,n.destinationConfig.sheetId),dataDestinationId:n.dataDestination.id});else if(e===xr.CREATE){const H=(o==null?void 0:o.id)??"";E({title:"",documentUrl:"",dataDestinationId:H})}},[n,e,E,o]),x.useEffect(()=>{t==null||t(L)},[L,t]);const M=R.watch("documentUrl"),P=M&&ADe(M.trim());return f.jsx(CC,{...R,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:H=>void R.handleSubmit(I)(H),children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:R.control,name:"title",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a title that reflects the report`s purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{id:c,placeholder:"Enter a report title",...H})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:R.control,name:"dataDestinationId",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select one of your existing destinations",children:"Destination"}),f.jsxs($c,{onValueChange:H.onChange,value:H.value,disabled:v||C.length===0,children:[f.jsx(cn,{children:f.jsx(qc,{id:u,className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{className:"truncate",placeholder:"Select a destination",children:H.value&&C.length>0&&(()=>{const j=C.find(V=>V.id===H.value);if(j){const W=Nc.getInfo(j.type).icon;return f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(W,{className:"flex-shrink-0",size:18}),f.jsx("div",{className:"flex min-w-0 flex-col",children:f.jsx("span",{className:"truncate",children:j.title})})]})}return null})()})})}),f.jsx(Kc,{children:C.map(j=>{const W=Nc.getInfo(j.type).icon;return f.jsx(fo,{value:j.id,children:f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(W,{className:"flex-shrink-0",size:18}),f.jsxs("div",{className:"flex min-w-0 flex-col",children:[f.jsx("span",{className:"truncate",children:j.title}),f.jsx("span",{className:"text-muted-foreground truncate text-xs",children:(u$(j.credentials)&&HU(j.credentials.serviceAccount))??"No email found"})]})]})},j.id)})})]}),C.length===0&&!v&&f.jsxs(Dre,{className:"mt-2",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(kTe,{children:"No destinations available"}),f.jsxs(Rre,{children:["You need to create a Destination before you can create a report."," ",f.jsx(Vc,{to:g("/data-destinations"),className:"font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",children:"Go to Destinations"})]})]}),H.value&&C.length>0&&(()=>{const j=C.find(V=>V.id===H.value);return j?f.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[f.jsx(Ji,{children:"Service Account Email"}),f.jsx(FIe,{value:u$(j.credentials)?HU(j.credentials.serviceAccount)??"No email found":"",children:u$(j.credentials)?HU(j.credentials.serviceAccount):"No email found"})]}):null})(),f.jsx(Cn,{})]})}),f.jsx(fn,{control:R.control,name:"documentUrl",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"The link must include the Sheet ID to insert data into the correct tab",children:"Document Link with Sheet ID (GID)"}),f.jsx(cn,{children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(vn,{id:d,placeholder:"Document URL",className:"flex-1",...H}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",className:`flex-shrink-0 rounded-md p-2 transition-all duration-200 ${P?"text-blue-600 hover:bg-blue-50 hover:text-blue-700 dark:text-blue-400 dark:hover:bg-blue-950/20 dark:hover:text-blue-300":"text-muted-foreground/30 cursor-not-allowed"}`,onClick:()=>{P&&window.open(M.trim(),"_blank","noopener,noreferrer")},disabled:!P,"aria-label":P?"Open document in new tab":"Document link is not valid",children:f.jsx(F_,{className:"h-4 w-4","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:P?"Open document in new tab":"Enter a valid URL to enable link"})]})]})}),f.jsx(Hs,{children:f.jsx(Zut,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Automate Report Runs",children:f.jsx(Ire,{})})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":e===xr.CREATE?"Create new report":"Save changes to report",disabled:!L||T,children:T?e===xr.CREATE?"Creating...":"Saving...":e===xr.CREATE?"Create new report":"Save changes to report"}),r&&f.jsx(rt,{variant:"outline",type:"button",onClick:r,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})});function Xut({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:i===xr.CREATE?"Create new report":"Edit report"}),f.jsx(cC,{children:i===xr.CREATE?"Fill in the details to create a new Google Sheets report":"Update details of an existing Google Sheets report"})]}),f.jsx(AM,{children:f.jsx(Yut,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const Qut=_s({cacheLifetime:NYe().min(300,"Cache time must be at least 5 minutes (300 seconds)")});function Jut({initialReport:n,dataMartId:e,onSuccess:t,preSelectedDestination:i}){const[s,r]=x.useState(null),{createReport:o,updateReport:a}=rg(),l=Bp({resolver:pb(Qut),defaultValues:{cacheLifetime:n!=null&&n.destinationConfig&&UDe(n.destinationConfig)?n.destinationConfig.cacheLifetime:300},mode:"onTouched"});return{form:l,onSubmit:async d=>{try{r(null);const{cacheLifetime:u}=d,h={type:nl.LOOKER_STUDIO_CONFIG,cacheLifetime:u};n?await a(n.id,{title:"Looker Studio Report",dataDestinationId:n.dataDestination.id,destinationConfig:h}):await o({title:"Looker Studio Report",dataMartId:e,dataDestinationId:(i==null?void 0:i.id)??"",destinationConfig:h}),t==null||t()}catch(u){console.error("Error submitting form:",u),r("Failed to save report. Please try again.")}},formError:s,isSubmitting:l.formState.isSubmitting,isDirty:l.formState.isDirty,reset:l.reset}}function eht(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"cache-lifetime-details",children:[f.jsx(is,{children:"What is the Cache Lifetime for Looker Studio?"}),f.jsx(ns,{children:f.jsx("p",{className:"mb-2",children:"Cache Lifetime - defines the period during which results from previous query executions are served from storage-side cache, eliminating the need to re-execute the query"})})]})})}const tht=[{value:300,label:"5 minutes"},{value:600,label:"10 minutes"},{value:900,label:"15 minutes"},{value:1800,label:"30 minutes"},{value:3600,label:"1 hour"},{value:7200,label:"2 hours"},{value:14400,label:"4 hours"},{value:28800,label:"8 hours"},{value:43200,label:"12 hours"}],iht=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="looker-studio-edit-form",{dataMart:c}=Zu(),{isDirty:d,reset:u,form:h,isSubmitting:g,formError:m,onSubmit:b}=Jut({initialReport:n,dataMartId:(c==null?void 0:c.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});return x.useEffect(()=>{i&&i(m)},[m,i]),x.useEffect(()=>{e===xr.EDIT&&n&&UDe(n.destinationConfig)?u({cacheLifetime:n.destinationConfig.cacheLifetime}):e===xr.CREATE&&u({cacheLifetime:300})},[n,e,u]),x.useEffect(()=>{t==null||t(d)},[d,t]),f.jsx(CC,{...h,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:v=>void h.handleSubmit(b)(v),children:[f.jsx(wC,{children:f.jsx(tc,{title:"Cache Configuration",children:f.jsx(fn,{control:h.control,name:"cacheLifetime",render:({field:v})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Period during which query results are served from storage-side cache, avoiding re-execution",children:"Cache Lifetime"}),f.jsxs($c,{onValueChange:C=>{v.onChange(parseInt(C,10))},value:v.value.toString(),defaultValue:"300",children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select cache time"})})}),f.jsx(Kc,{children:tht.map(C=>f.jsx(fo,{value:C.value.toString(),children:C.label},C.value))})]}),f.jsx(Cn,{}),f.jsx(Hs,{children:f.jsx(eht,{})})]})})})}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":e===xr.CREATE?"Create":"Save changes",disabled:!d||g,children:g?e===xr.CREATE?"Creating...":"Saving...":e===xr.CREATE?"Create":"Save changes"}),r&&f.jsx(rt,{variant:"outline",type:"button",onClick:r,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})});function nht({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:(s==null?void 0:s.title)??"Looker Studio"}),f.jsx(cC,{children:i===xr.CREATE?"Set up Data Mart as a data source":"Update connection details"})]}),f.jsx(AM,{children:f.jsx(iht,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const a_e=({destination:n})=>{const t=Nc.getInfo(n.type).icon;return f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(t,{className:"flex-shrink-0",size:18}),f.jsx("div",{className:"flex min-w-0 flex-col",children:f.jsx("span",{className:"truncate",children:n.title})})]})};function sht(n){return"to"in n}const rht=({destination:n})=>{if(!n)return null;const e=n.credentials,t=sht(e)&&e.to.length?e.to.join(", "):"";return f.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[f.jsx(Ji,{children:"Recipients of this report"}),f.jsx(FIe,{doNotTruncateContent:!0,value:t,children:t||"No recipients found"})]})};var ay=(n=>(n.ALWAYS="ALWAYS",n.RESULT_IS_EMPTY="RESULT_IS_EMPTY",n.RESULT_IS_NOT_EMPTY="RESULT_IS_NOT_EMPTY",n))(ay||{});const oht=_s({title:pn().min(1,"Title is required"),dataDestinationId:pn().min(1,"Destination is required"),reportCondition:TH(ay),subject:pn().min(1,"Subject is required"),messageTemplate:pn().min(1,"Message body is required")});function aht({initialReport:n,mode:e,dataMartId:t,onSuccess:i,preSelectedDestination:s}){const[r,o]=x.useState(null),[a,l]=x.useState(!1),{updateReport:c,createReport:d,error:u,clearError:h}=rg();x.useEffect(()=>{a&&u&&(o(u),l(!1))},[u,a]);const g=Bp({resolver:pb(oht),defaultValues:{title:(n==null?void 0:n.title)??"",dataDestinationId:(n==null?void 0:n.dataDestination.id)??(s==null?void 0:s.id)??"",reportCondition:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.reportCondition:ay.ALWAYS,subject:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.subject:"",messageTemplate:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.messageTemplate:""},mode:"onTouched"}),{handleSubmit:m,formState:b,reset:v}=g,{isDirty:C,errors:y}=b,L=x.useCallback(async E=>{try{o(null),h(),l(!0);let R;const T={type:nl.EMAIL_CONFIG,reportCondition:E.reportCondition,subject:E.subject,messageTemplate:E.messageTemplate};if(e===xr.CREATE)R=await d({title:E.title,dataMartId:t,dataDestinationId:E.dataDestinationId,destinationConfig:T});else{if(!n){o("Initial report is required for edit mode");return}R=await c(n.id,{title:E.title,dataDestinationId:E.dataDestinationId,destinationConfig:T})}if(!R||u){o(u??"An error occurred while submitting the form");return}i==null||i()}catch(R){console.error("Error submitting form:",R),o("An error occurred while submitting the form")}},[e,n,t,d,c,i,h,u]);return{form:g,handleSubmit:m,errors:y,isDirty:C,reset:v,formError:r,isSubmitting:a,setFormError:o,onSubmit:L}}function lht({value:n,onChange:e,onBlur:t,height:i=240,theme:s="light",options:r,className:o,placeholder:a="Start writing your message…"}){const l=c=>{t&&c.onDidBlurEditorText(t)};return f.jsx(vre,{language:"markdown",height:i,value:n,onChange:c=>{e(c??"")},onMount:l,theme:s,options:{wordWrap:"on",minimap:{enabled:!1},lineNumbers:"off",folding:!1,scrollBeyondLastLine:!1,automaticLayout:!0,placeholder:a,...r},className:o})}const cht=()=>f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(bl,{className:"h-6 w-3/4"}),f.jsx(bl,{className:"h-4 w-1/2"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(bl,{className:"h-4 w-full"}),f.jsx(bl,{className:"h-4 w-5/6"}),f.jsx(bl,{className:"h-4 w-4/5"}),f.jsx(bl,{className:"h-4 w-3/4"})]})]});function jIe({html:n,loading:e=!1,error:t=null,height:i=240,className:s,emptyState:r=f.jsx("div",{className:"text-muted-foreground text-sm",children:"Nothing to preview"})}){let o="#fff",a="#000";if(typeof window<"u"){const l=getComputedStyle(document.documentElement),c=l.getPropertyValue("--background").trim(),d=l.getPropertyValue("--foreground").trim();c&&(o=c),d&&(a=d)}return f.jsxs("div",{className:`bg-background overflow-auto p-4 ${s??""}`,style:{height:i},children:[e&&f.jsx(cht,{}),!e&&t&&f.jsxs("div",{className:"text-destructive text-sm",children:["Error: ",t]}),!e&&!t&&!n&&r,!e&&!t&&!!n&&f.jsx("iframe",{title:"Markdown preview",sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:`<!doctype html><html lang='en' style="background:${o};color:${a}"><head><meta charset='utf-8'/><base target='_blank'></head><body>${n}</body></html>`,className:"h-full w-full border-0"})]})}function dht({value:n,onChange:e}){return f.jsx(ore,{value:n,onValueChange:t=>{e(t)},children:f.jsxs(are,{children:[f.jsx(u2,{value:"markdown",children:"Markdown"}),f.jsx(u2,{value:"preview",children:"Preview"})]})})}function uht({markdown:n,enabled:e=!0,debounceMs:t=300,toHtml:i}){const[s,r]=x.useState(""),[o,a]=x.useState(!1),[l,c]=x.useState(null),d=x.useRef(null);return x.useEffect(()=>{var m;if(!e)return;const u=n;if(!u.trim()){r(""),c(null),a(!1);return}const h=new AbortController;(m=d.current)==null||m.abort(),d.current=h,a(!0),c(null);const g=setTimeout(()=>{i(u,h.signal).then(b=>{r(b)}).catch(b=>{if(h.signal.aborted)return;const v=b instanceof Error?b.message:"Failed to load preview";c(v)}).finally(()=>{h.signal.aborted||a(!1)})},t);return()=>{clearTimeout(g),h.abort()}},[n,e,t,i]),{html:s,loading:o,error:l}}function hht(n,e){return Rd.post("/markdown/parse-to-html",{markdown:n},{headers:{"Content-Type":"application/json"},responseType:"text",signal:e}).then(t=>t.data)}function HIe(n){const e=x.useCallback(hht,[]);return uht({...n,toHtml:e})}function fht(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"message-details",children:[f.jsx(is,{children:"How can I format my message?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"You can format your message using Markdown — a simple text formatting syntax that lets you add structure and style without using complex editors."}),f.jsxs("p",{className:"mb-2",children:["For example:",f.jsx("br",{}),"**bold text** → ",f.jsx("b",{children:"bold text"}),f.jsx("br",{}),"*italic text* → ",f.jsx("i",{children:"italic text"}),f.jsx("br",{}),"- list item → • list item"]}),f.jsxs("p",{children:["Use the Preview tab to see how your message will look after formatting.",f.jsx("br",{}),"If you’re new to Markdown, learn more from this"," ",f.jsx(ir,{className:"underline",href:"https://www.markdownguide.org/basic-syntax/",children:"quick guide"})]})]})]})})}function ght(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"sending-condition-details",children:[f.jsx(is,{children:"What are Data Mart Run results?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A Data Mart Run result is the outcome of processing your Data Mart — for example, running an SQL query that retrieves data for your report."}),f.jsx("p",{children:"Before sending a report, OWOX automatically runs the Data Mart and checks its result. Depending on your settings, the report can be sent always, only if the result is not empty, or only if it’s empty."})]})]})})}const pht=[St.EMAIL,St.SLACK,St.GOOGLE_CHAT,St.MS_TEAMS],BIe=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="email-report-edit-form",{dataMart:c}=Zu(),{dataDestinations:d,fetchDataDestinations:u,loading:h}=MM(),[g,m]=x.useState([]);x.useEffect(()=>{c&&u()},[c,u]),x.useEffect(()=>{if(d.length>0){const B=o!=null&&o.type?[o.type]:pht,K=d.filter(X=>B.includes(X.type));m(K)}},[d,o==null?void 0:o.type]);const{isDirty:b,reset:v,form:C,isSubmitting:y,formError:L,onSubmit:E}=aht({initialReport:n,mode:e,dataMartId:(c==null?void 0:c.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});x.useEffect(()=>{i&&i(L)},[L,i]),x.useEffect(()=>{if(!(e===xr.EDIT&&n)){if(e===xr.CREATE){const B=(o==null?void 0:o.id)??"";v({title:"",dataDestinationId:B,reportCondition:ay.ALWAYS,subject:"",messageTemplate:""})}}},[n,e,v,o]),x.useEffect(()=>{t==null||t(b)},[b,t]);const R=x.useMemo(()=>[{value:ay.ALWAYS,label:"Send always"},{value:ay.RESULT_IS_EMPTY,label:"Send only when result is empty"},{value:ay.RESULT_IS_NOT_EMPTY,label:"Send only when result is not empty"}],[]),{resolvedTheme:T}=AH(),N=T==="dark"?"vs-dark":"light",[I,M]=x.useState("markdown"),P=C.watch("messageTemplate"),{html:H,loading:j,error:V}=HIe({markdown:P,enabled:I==="preview"}),W=C.watch("dataDestinationId"),U=x.useMemo(()=>W&&g.length>0?g.find(B=>B.id===W)??null:null,[W,g]);return f.jsx(CC,{...C,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:B=>{C.handleSubmit(E)(B)},children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:C.control,name:"title",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a title that reflects the report`s purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter a report title",...B})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:C.control,name:"dataDestinationId",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select one of your existing destinations",children:"Destination"}),f.jsxs($c,{onValueChange:B.onChange,value:B.value,disabled:h||g.length===0,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{className:"truncate",placeholder:"Select a destination",children:U&&f.jsx(a_e,{destination:U})})})}),f.jsx(Kc,{children:g.map(K=>f.jsx(fo,{value:K.id,children:f.jsx(a_e,{destination:K})},K.id))})]}),f.jsx(rht,{destination:U}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Template",children:[f.jsx(fn,{control:C.control,name:"subject",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a short, clear subject line for your report",children:"Subject"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter a message title",...B})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:C.control,name:"messageTemplate",render:({field:B})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx(Ji,{tooltip:"Write your report message in Markdown and check the final format in Preview",children:"Message"}),f.jsx(dht,{value:I,onChange:M})]}),f.jsx(cn,{children:f.jsx("div",{className:"overflow-hidden rounded-md border",children:I==="markdown"?f.jsx(lht,{value:B.value,onChange:K=>{B.onChange(K)},onBlur:B.onBlur,height:240,theme:N}):f.jsx(jIe,{html:H,loading:j,error:V,height:240})})}),f.jsx(Hs,{children:f.jsx(fht,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Sending conditions",children:f.jsx(fn,{control:C.control,name:"reportCondition",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Define when the report should be sent based on your Data Mart’s execution result",children:"Data Mart Run results"}),f.jsxs($c,{onValueChange:B.onChange,value:B.value,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{})})}),f.jsx(Kc,{children:R.map(K=>f.jsx(fo,{value:K.value,children:K.label},K.value))})]}),f.jsx(Hs,{children:f.jsx(ght,{})}),f.jsx(Cn,{})]})})}),f.jsx(tc,{title:"Automate Report Runs",children:f.jsx(Ire,{})})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",disabled:y,children:e===xr.CREATE?"Create new report":"Save changes to report"}),f.jsx(rt,{variant:"outline",type:"button",onClick:r,disabled:y,children:"Cancel"})]})]})})});BIe.displayName="EmailReportEditForm";function mht({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:(s==null?void 0:s.title)??"Report"}),f.jsx(cC,{children:i===xr.CREATE?"Fill in the details to create a new report":"Update details of an existing report"})]}),f.jsx(AM,{children:f.jsx(BIe,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}function _ht({destination:n,isOpen:e,onClose:t,mode:i,initialReport:s}){switch(n.type){case St.GOOGLE_SHEETS:return f.jsx(Xut,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});case St.LOOKER_STUDIO:return f.jsx(nht,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});case St.EMAIL:case St.SLACK:case St.GOOGLE_CHAT:case St.MS_TEAMS:return f.jsx(mht,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});default:return null}}function bht({destination:n,onEditReport:e}){switch(n.type){case St.GOOGLE_SHEETS:return f.jsx(Rut,{destination:n,onEditReport:e});case St.EMAIL:case St.SLACK:case St.GOOGLE_CHAT:case St.MS_TEAMS:return f.jsx(kut,{destinationType:n.type,destination:n,onEditReport:e});case St.LOOKER_STUDIO:return f.jsx(But,{destination:n,onEditReport:e});default:return null}}function VIe(){return f.jsx("div",{className:"flex flex-col gap-4",children:f.jsx("div",{className:"space-y-2 pb-4",children:Array.from({length:3}).map((n,e)=>f.jsx("div",{className:"border-border rounded-lg border p-4",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(bl,{className:"h-4 w-4 rounded-full"}),f.jsx(bl,{className:"h-4 w-40"}),f.jsx(bl,{className:"h-3 w-32"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(bl,{className:"h-6 w-16 rounded-full"}),f.jsx(bl,{className:"h-4 w-4"})]})]})},e))})})}function Qre({enabled:n,intervalMs:e=5e3,onlyWhenVisible:t=!0,onTick:i}){const s=x.useRef(i);s.current=i;const r=x.useRef(null);x.useEffect(()=>{var l;if(!n)return;(l=r.current)==null||l.abort(),r.current=new AbortController;const o=()=>{if(!t||document.visibilityState==="visible"){const c=new AbortController;s.current(c.signal)}};o();const a=window.setInterval(o,e);return()=>{var c;window.clearInterval(a),(c=r.current)==null||c.abort()}},[n,e,t])}function vht({enabled:n=!0,intervalMs:e=5e3}={}){const{dataMart:t}=Zu(),{fetchReportsByDataMartId:i}=rg(),s=t==null?void 0:t.id;x.useEffect(()=>{s&&i(s)},[s,i]),Qre({enabled:!!s&&n,intervalMs:e,onTick:()=>{s&&i(s,{silent:!0})}})}function Cht(){const{dataMart:n}=Zu(),{dataDestinations:e,isLoading:t}=NJe();return vht({enabled:!0,intervalMs:5e3}),n?f.jsx("div",{className:"flex flex-col gap-4",children:t?f.jsx(VIe,{}):e.length===0?f.jsx(Vut,{}):e.map(i=>f.jsx(Uut,{destination:i,dataMartStatus:n.status},i.id))}):null}function wht(){return f.jsx(AM,{children:f.jsx(ODe,{children:f.jsx(Cht,{})})})}function l_e(){return f.jsxs(c1,{children:[f.jsx(fp,{children:f.jsx(hp,{icon:SHe,tooltip:"Description of the Data Mart",children:"Description"})}),f.jsx(gp,{children:f.jsx(ert,{})}),f.jsx(E_,{})]})}function yht(){const{dataMart:n}=og(),[e,t]=x.useState(!1),i=x.useCallback(()=>{t(!0)},[]),s=x.useCallback(()=>{t(!1)},[]);return f.jsxs(c1,{children:[f.jsxs(fp,{children:[f.jsx(hp,{icon:oxe,tooltip:"Time triggers allow you to schedule Data Mart runs at specific times",children:"Time triggers"}),f.jsx($M,{children:f.jsxs(rt,{variant:"outline",onClick:i,"aria-label":"Add new trigger",children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"Add Trigger"]})})]}),f.jsx(gp,{children:f.jsx(HD,{children:f.jsx(elt,{children:n&&f.jsxs(f.Fragment,{children:[f.jsx(Vlt,{dataMartId:n.id}),f.jsx(Tre,{isOpen:e,onClose:s,dataMartId:n.id})]})})})}),f.jsx(E_,{})]})}const Sht={list:[],listLoadingStatus:an.IDLE,activeInsight:null,activeInsightLoadingStatus:an.IDLE,executionStatus:an.IDLE,executionTriggerId:null,error:null};var Vi=(n=>(n.FETCH_INSIGHTS_START="FETCH_INSIGHTS_START",n.FETCH_INSIGHTS_SUCCESS="FETCH_INSIGHTS_SUCCESS",n.FETCH_INSIGHTS_ERROR="FETCH_INSIGHTS_ERROR",n.GET_INSIGHT_START="GET_INSIGHT_START",n.GET_INSIGHT_SUCCESS="GET_INSIGHT_SUCCESS",n.GET_INSIGHT_ERROR="GET_INSIGHT_ERROR",n.CREATE_INSIGHT_START="CREATE_INSIGHT_START",n.CREATE_INSIGHT_SUCCESS="CREATE_INSIGHT_SUCCESS",n.CREATE_INSIGHT_ERROR="CREATE_INSIGHT_ERROR",n.UPDATE_INSIGHT_START="UPDATE_INSIGHT_START",n.UPDATE_INSIGHT_SUCCESS="UPDATE_INSIGHT_SUCCESS",n.UPDATE_INSIGHT_ERROR="UPDATE_INSIGHT_ERROR",n.DELETE_INSIGHT_START="DELETE_INSIGHT_START",n.DELETE_INSIGHT_SUCCESS="DELETE_INSIGHT_SUCCESS",n.DELETE_INSIGHT_ERROR="DELETE_INSIGHT_ERROR",n.RUN_INSIGHT_START="RUN_INSIGHT_START",n.RUN_INSIGHT_START_ERROR="RUN_INSIGHT_START_ERROR",n.RUN_INSIGHT_STARTED="RUN_INSIGHT_STARTED",n.RUN_INSIGHT_SUCCESS="RUN_INSIGHT_SUCCESS",n.RUN_INSIGHT_ERROR="RUN_INSIGHT_ERROR",n.CLEAR_ERROR="CLEAR_ERROR",n))(Vi||{});class xht extends hC{constructor(){super("/data-marts")}async getInsights(e){return this.get(`/${e}/insights`)}async getInsightById(e,t){return await this.get(`/${e}/insights/${t}`)}async createInsight(e,t){return this.post(`/${e}/insights`,t)}async updateInsight(e,t,i){return this.put(`/${e}/insights/${t}`,i)}async updateInsightTitle(e,t,i){return this.put(`/${e}/insights/${t}/title`,i)}async deleteInsight(e,t){return this.delete(`/${e}/insights/${t}`)}async startInsightExecution(e,t){return this.post(`/${e}/insights/${t}/run-triggers`,{})}async checkInsightExecutionStatus(e,t,i,s){return this.get(`/${e}/insights/${i}/run-triggers/${t}/status`,null,s)}async getInsightRunTriggers(e,t,i){return this.get(`/${e}/insights/${t}/run-triggers/`,null,i)}}const Tm=new xht,cI=n=>({id:n.id,title:n.title,template:n.template??null,output:n.output??null,outputUpdatedAt:n.outputUpdatedAt?new Date(n.outputUpdatedAt):null,lastRun:n.lastManualDataMartRun?{status:n.lastManualDataMartRun.status,id:n.lastManualDataMartRun.id}:null,createdById:n.createdById,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt)}),Lht=n=>n.data.map(cI),Eht=n=>({title:n.title,template:n.template??null}),Dht=n=>({title:n.title,template:n.template??null}),WIe=x.createContext(void 0);function zIe(){const n=x.useContext(WIe);if(!n)throw new Error("useInsightsContext must be used within InsightsProvider");return n}function Jre(){const{state:n,dispatch:e}=zIe(),{dataMart:t}=og();if(!t)throw new Error("useInsights must be used within a DataMart context");const i=x.useCallback(async()=>{e({type:Vi.FETCH_INSIGHTS_START});try{const g=await Tm.getInsights(t.id),m=Lht(g);e({type:Vi.FETCH_INSIGHTS_SUCCESS,payload:m})}catch(g){throw e({type:Vi.FETCH_INSIGHTS_ERROR,payload:ys(g)}),g}},[t.id,e]),s=x.useCallback(async g=>{e({type:Vi.GET_INSIGHT_START});try{const m=await Tm.getInsightById(t.id,g),b=cI(m);return e({type:Vi.GET_INSIGHT_SUCCESS,payload:b}),b}catch(m){throw e({type:Vi.GET_INSIGHT_ERROR,payload:ys(m)}),m}},[t.id,e]),r=x.useCallback(async g=>{e({type:Vi.CREATE_INSIGHT_START});try{const m=Eht(g),b=await Tm.createInsight(t.id,m),v=cI(b);return e({type:Vi.CREATE_INSIGHT_SUCCESS,payload:v}),Vt({event:"insight_created",category:"Insights",action:"Create",label:v.id}),Rn.success("Insight created"),v}catch(m){return e({type:Vi.CREATE_INSIGHT_ERROR,payload:ys(m)}),null}},[t.id,e]),o=x.useCallback(async(g,m)=>{e({type:Vi.UPDATE_INSIGHT_START});try{const b=Dht(m),v=await Tm.updateInsight(t.id,g,b),C=cI(v);return e({type:Vi.UPDATE_INSIGHT_SUCCESS,payload:C}),Vt({event:"insight_updated",category:"Insights",action:"Update",label:C.id}),Rn.success("Insight updated"),C}catch(b){return e({type:Vi.UPDATE_INSIGHT_ERROR,payload:ys(b)}),null}},[t.id,e]),a=x.useCallback(async g=>{e({type:Vi.DELETE_INSIGHT_START});try{await Tm.deleteInsight(t.id,g),e({type:Vi.DELETE_INSIGHT_SUCCESS,payload:g}),Vt({event:"insight_deleted",category:"Insights",action:"Delete",label:g}),Rn.success("Insight deleted")}catch(m){throw e({type:Vi.DELETE_INSIGHT_ERROR,payload:ys(m)}),m}},[t.id,e]),l=x.useCallback(async(g,m)=>{e({type:Vi.UPDATE_INSIGHT_START});try{const b=await Tm.updateInsightTitle(t.id,g,{title:m}),v=cI(b),C=n.list.find(L=>L.id===g)??n.activeInsight,y=C?{...v,template:C.template}:v;return e({type:Vi.UPDATE_INSIGHT_SUCCESS,payload:y}),Vt({event:"insight_title_updated",category:"Insights",action:"Update title",label:y.id}),Rn.success("Title updated"),y}catch(b){return e({type:Vi.UPDATE_INSIGHT_ERROR,payload:ys(b)}),null}},[t.id,e,n.activeInsight,n.list]),c=x.useCallback(async g=>{e({type:Vi.RUN_INSIGHT_START});try{const m=await Tm.startInsightExecution(t.id,g);e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:m.triggerId}})}catch(m){e({type:Vi.RUN_INSIGHT_ERROR,payload:ys(m)})}},[e,t.id]),d=x.useCallback(()=>{e({type:Vi.RUN_INSIGHT_SUCCESS,payload:{triggerId:""}})},[e]),u=x.useCallback(g=>{e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:g}})},[e]),h=x.useCallback(async()=>{const g=n.activeInsight;if(!(!g||!t.id)&&!n.executionTriggerId&&!(!g.lastRun||JJe(g.lastRun.status)))try{const b=(await Tm.getInsightRunTriggers(t.id,g.id,{skipLoadingIndicator:!0})).data.sort((v,C)=>new Date(C.modifiedAt).getTime()-new Date(v.modifiedAt).getTime()).find(v=>!eet(v.status));b!=null&&b.id&&(e({type:Vi.RUN_INSIGHT_START}),e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:b.id}}))}catch(m){e({type:Vi.RUN_INSIGHT_ERROR,payload:ys(m)})}},[n.activeInsight,n.executionTriggerId,t.id,e]);return{insights:n.list,activeInsight:n.activeInsight,listLoading:n.listLoadingStatus===an.LOADING,insightLoading:n.activeInsightLoadingStatus===an.LOADING,isRunning:n.executionStatus===an.LOADING,triggerId:n.executionTriggerId,error:n.error,fetchInsights:i,getInsight:s,createInsight:r,updateInsight:o,updateInsightTitle:l,deleteInsight:a,runInsight:c,setTriggerId:u,resetTriggerId:d,ensureActiveRunPolling:h}}function Rht(){const{state:n}=zIe(),e=x.useMemo(()=>n.list,[n.list]),t=x.useMemo(()=>n.listLoadingStatus===an.LOADING,[n.listLoadingStatus]),i=x.useMemo(()=>n.listLoadingStatus===an.LOADED||n.listLoadingStatus===an.ERROR,[n.listLoadingStatus]),s=x.useMemo(()=>n.error,[n.error]),r=x.useMemo(()=>e.length>0,[e.length]);return{insights:e,isLoading:t,isLoaded:i,error:s,hasInsights:r}}function Nht(n,e){var t,i;switch(e.type){case Vi.FETCH_INSIGHTS_START:return{...n,listLoadingStatus:an.LOADING,error:null};case Vi.GET_INSIGHT_START:return{...n,activeInsightLoadingStatus:an.LOADING,error:null};case Vi.CREATE_INSIGHT_START:return{...n,activeInsightLoadingStatus:an.LOADING,error:null};case Vi.UPDATE_INSIGHT_START:return{...n,error:null};case Vi.DELETE_INSIGHT_START:return{...n,listLoadingStatus:an.LOADING,error:null};case Vi.FETCH_INSIGHTS_SUCCESS:return{...n,list:e.payload,listLoadingStatus:an.LOADED,error:null};case Vi.GET_INSIGHT_SUCCESS:return{...n,activeInsight:e.payload,activeInsightLoadingStatus:an.LOADED,error:null};case Vi.CREATE_INSIGHT_SUCCESS:return{...n,list:[...n.list,e.payload],listLoadingStatus:an.LOADED,activeInsightLoadingStatus:an.LOADED,error:null};case Vi.UPDATE_INSIGHT_SUCCESS:return{...n,list:n.list.map(s=>s.id===e.payload.id?e.payload:s),activeInsight:((t=n.activeInsight)==null?void 0:t.id)===e.payload.id?e.payload:n.activeInsight,listLoadingStatus:an.LOADED,error:null};case Vi.DELETE_INSIGHT_SUCCESS:return{...n,list:n.list.filter(s=>s.id!==e.payload),activeInsight:((i=n.activeInsight)==null?void 0:i.id)===e.payload?null:n.activeInsight,listLoadingStatus:an.LOADED,error:null};case Vi.FETCH_INSIGHTS_ERROR:return{...n,listLoadingStatus:an.ERROR,error:e.payload};case Vi.GET_INSIGHT_ERROR:return{...n,activeInsightLoadingStatus:an.ERROR,error:e.payload};case Vi.CREATE_INSIGHT_ERROR:return{...n,listLoadingStatus:an.ERROR,activeInsightLoadingStatus:an.ERROR,error:e.payload};case Vi.UPDATE_INSIGHT_ERROR:case Vi.DELETE_INSIGHT_ERROR:return{...n,listLoadingStatus:an.ERROR,error:e.payload};case Vi.RUN_INSIGHT_START:return{...n,executionStatus:an.LOADING,error:null};case Vi.RUN_INSIGHT_STARTED:return{...n,executionTriggerId:e.payload.triggerId,error:null};case Vi.RUN_INSIGHT_SUCCESS:return{...n,executionStatus:an.LOADED,executionTriggerId:null,error:null};case Vi.CLEAR_ERROR:return{...n,error:null};default:return n}}function UIe({children:n,initialState:e}){const[t,i]=x.useReducer(Nht,e??Sht);return f.jsx(WIe.Provider,{value:{state:t,dispatch:i},children:n})}function Tht(){return f.jsx(UIe,{children:f.jsx(Tne,{})})}function Iht({status:n}){switch(n){case $r.RUNNING:return f.jsx(Ya,{variant:"secondary",className:"text-primary bg-primary/10",children:"Running"});case $r.SUCCESS:return f.jsx(Ya,{variant:"secondary",className:"bg-green-50 text-green-600 dark:bg-green-950 dark:text-green-400",children:"Success"});case $r.FAILED:return f.jsx(Ya,{variant:"secondary",className:"bg-red-50 text-red-600 dark:bg-red-950 dark:text-red-400",children:"Failed"});case $r.CANCELLED:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Cancelled"});case $r.INTERRUPTED:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Interrupted"});case $r.PENDING:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Pending"});default:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Unknown"})}}var Tc=(n=>(n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.SYSTEM="SYSTEM",n))(Tc||{}),hf=(n=>(n.STRUCTURED="structured",n.RAW="raw",n.CONFIGURATION="configuration",n))(hf||{});const c_e=(n,e,t=!1)=>{var o,a,l,c;const i=n.split(`
|
|
741
|
+
REPEATED - field is an Array of Type`})]}),size:80,cell:({row:H})=>f.jsx(eut,{mode:H.getValue("mode"),onModeChange:j=>{u(H.index,{mode:j})}}),columnIndex:4}],[u]),y=x.useCallback(()=>f.jsxs("div",{className:"flex items-center",children:[i&&f.jsx(Xdt,{isAllExpanded:d,onToggle:r}),f.jsxs(Tn,{children:[f.jsx(In,{className:"cursor-default",children:"Name"}),f.jsx(kn,{children:"Field name in the output schema"})]})]}),[i,d,r]),L=x.useCallback(({row:H})=>{const j=o[H.index],W=(j.type===Ho.RECORD||j.type===Ho.STRUCT)&&j.fields&&j.fields.length>0,U=j.path??"",B=j.level??0,K=t.has(U);return f.jsxs("div",{className:"flex items-center",children:[B>0&&f.jsx("div",{style:{width:`${String(B*16-(W?4:0))}px`},className:"flex-shrink-0"}),W?f.jsx(Qdt,{isExpanded:K,onToggle:()=>{s(U)},ariaLabel:K?"Collapse nested fields":"Expand nested fields"}):i&&f.jsx("div",{className:"w-5"}),f.jsx(jE,{value:H.getValue("name"),onValueChange:X=>{u(H.index,{name:X})},placeholder:"Field name is required",isBold:!0})]})},[o,t,i,s,u]),E=x.useCallback(({row:H})=>{const j=o[H.index],V=j.type===Ho.RECORD||j.type===Ho.STRUCT;return(j.level??0)===0&&!V?f.jsx(AIe,{isPrimaryKey:H.getValue("isPrimaryKey"),onPrimaryKeyChange:U=>{u(H.index,{isPrimaryKey:U})}}):f.jsx("div",{})},[o,u]),R=x.useCallback(({row:H})=>f.jsx(jE,{value:H.getValue("description"),onValueChange:j=>{u(H.index,{description:j})},minRows:5,placeholder:"-"}),[u]),T=x.useCallback(({row:H})=>f.jsx(jE,{value:H.getValue("alias"),onValueChange:j=>{u(H.index,{alias:j})},placeholder:"-"}),[u]),N=x.useCallback(({row:H})=>f.jsx(xIe,{row:H,onDeleteRow:e?h:void 0,onAddNestedField:e?g:void 0,isRecordType:l}),[e,h,g,l]),{handleDragEnd:I}=Are(n,e,o),M=x.useCallback(H=>{const j=o[H.index];return j.path??String(o.indexOf(j))},[o]),P=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:P,collisionDetection:Bre,onDragEnd:I,children:f.jsx(Yre,{fields:o,onFieldsChange:e,onAddRow:m,createNewField:b,renderTypeCell:v,additionalColumns:C,fieldsForStatusCount:c,onSearchChange:a,nameColumnHeader:y,nameColumnCell:L,primaryKeyColumnCell:E,aliasColumnCell:T,descriptionColumnCell:R,actionsColumnCell:N,dragContext:Gre,dragContextProps:{items:o.map(H=>H.path??String(o.indexOf(H))),strategy:$re},rowComponent:qre,getRowId:M})})}function hut({fields:n,onFieldsChange:e}){const t=x.useCallback(()=>({name:"",type:Gse.STRING,isPrimaryKey:!1,status:Mu.DISCONNECTED}),[]),i=x.useCallback(({row:o,updateField:a})=>f.jsx(Zre,{type:o.getValue("type"),storageType:lt.AWS_ATHENA,onTypeChange:l=>{a(o.index,{type:l})}}),[]),{handleDragEnd:s}=Are(n,e),r=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:r,collisionDetection:Bre,onDragEnd:s,children:f.jsx(Yre,{fields:n,onFieldsChange:e,createNewField:t,renderTypeCell:i,dragContext:Gre,dragContextProps:{items:n.map((o,a)=>a),strategy:$re},rowComponent:qre})})}function fut({fields:n,onFieldsChange:e}){const t=x.useCallback(()=>({name:"",type:qse.VARCHAR,isPrimaryKey:!1,status:Mu.DISCONNECTED}),[]),i=x.useCallback(({row:o,updateField:a})=>f.jsx(Zre,{type:o.getValue("type"),storageType:lt.SNOWFLAKE,onTypeChange:l=>{a(o.index,{type:l})}}),[]),{handleDragEnd:s}=Are(n,e),r=Hre(jre(UM,{activationConstraint:{distance:5}}));return f.jsx(Ure,{sensors:r,collisionDetection:Bre,onDragEnd:s,children:f.jsx(Yre,{fields:n,onFieldsChange:e,createNewField:t,renderTypeCell:i,dragContext:Gre,dragContextProps:{items:n.map((o,a)=>a),strategy:$re},rowComponent:qre})})}function gut({schema:n,storageType:e,onFieldsChange:t}){const i=x.useMemo(()=>{if(!n){const s=act(e);return t(s.fields),s}return n},[n,e,t]);return QTe(i)?f.jsx(uut,{fields:i.fields,onFieldsChange:t}):JTe(i)?f.jsx(hut,{fields:i.fields,onFieldsChange:t}):eIe(i)?f.jsx(fut,{fields:i.fields,onFieldsChange:t}):f.jsx("div",{className:"p-4 text-center",children:f.jsx("p",{children:"Unsupported schema type"})})}function put({definitionType:n}){const{dataMart:e,updateDataMartSchema:t,isLoading:i,error:s,runSchemaActualization:r,isSchemaActualizationLoading:o}=Zu(),{id:a="",schema:l}=e??{},{schema:c,isDirty:d,updateSchema:u,resetSchema:h}=cct(l),{operationStatus:g,startSaveOperation:m}=dct(i,s);x.useEffect(()=>{g==="success"&&h()},[g,h]);const b=x.useCallback(E=>{u(E)},[u]),v=x.useCallback(()=>{a&&c&&(m(),t(a,c).then(()=>{r==null||r()}))},[a,c,m,t,r]),C=x.useCallback(()=>{r==null||r()},[r]),y=x.useCallback(()=>{h()},[h]),L=i||o;return e?f.jsxs("div",{className:"space-y-4",children:[f.jsx(gut,{schema:c,storageType:e.storage.type,onFieldsChange:b}),f.jsxs("div",{className:"align-items-center mt-8 flex justify-between",children:[f.jsxs("div",{className:"flex space-x-4",children:[f.jsx(rt,{variant:"default",onClick:v,disabled:!d||L,children:"Save"}),f.jsx(rt,{type:"button",variant:"ghost",onClick:y,disabled:!d||L,children:"Discard"})]}),f.jsx(rt,{type:"button",variant:"outline",onClick:C,disabled:!n||L,children:"Refresh schema"})]})]}):f.jsx("div",{children:"Error: Data mart not found"})}function mut(){const n=Dne(),{id:e,projectId:t}=n;return e?t?f.jsx("div",{className:"dm-page",children:f.jsx(LRe,{children:f.jsx(Qst,{id:e})})}):f.jsx("div",{className:"dm-page-header",children:"Project ID is required"}):f.jsx("div",{className:"dm-page-header",children:"Data Mart ID is required"})}function _ut({className:n,...e}){return f.jsx("div",{"data-slot":"card",className:Le("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",n),...e})}function but({className:n,...e}){return f.jsx("div",{"data-slot":"card-header",className:Le("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",n),...e})}function vut({className:n,...e}){return f.jsx("div",{"data-slot":"card-title",className:Le("leading-none font-semibold",n),...e})}function Cut({className:n,...e}){return f.jsx("div",{"data-slot":"card-description",className:Le("text-muted-foreground text-sm",n),...e})}function wut({className:n,...e}){return f.jsx("div",{"data-slot":"card-content",className:Le("px-6",n),...e})}function yut({className:n,...e}){return f.jsx("div",{"data-slot":"card-footer",className:Le("flex items-center px-6 [.border-t]:pt-6",n),...e})}const Xre=x.createContext({isCollapsed:!1,collapsible:!1,handleCollapse:()=>{throw new Error("CollapsibleCardContext: handleCollapse not implemented")}});function hp({icon:n,tooltip:e,subtitle:t,children:i}){const{isCollapsed:s}=x.useContext(Xre);return f.jsxs("div",{className:"flex items-center gap-2 self-center",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"text-foreground flex h-7 w-7 items-center justify-center rounded-sm bg-gray-200/50 transition-colors duration-200 group-hover:bg-gray-200/75 dark:bg-white/8 dark:group-hover:bg-white/10",children:f.jsx(n,{size:18})}),f.jsx(vut,{className:"text-md text-foreground leading-none font-medium",children:i})]}),t&&f.jsx(Cut,{className:Le("text-md text-muted-foreground/50",!s&&"hidden"),children:t}),e&&f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{className:"pointer-events-none ml-2 flex items-center opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",children:[f.jsx(sc,{className:"text-muted-foreground/50 hover:text-muted-foreground size-4 shrink-0 transition-colors"}),f.jsx("span",{className:"sr-only",children:e})]})}),f.jsx(kn,{children:f.jsx("p",{children:e})})]})})]})}hp.displayName="CollapsibleCardHeaderTitle";function $M({children:n,className:e}){const t=i=>{i.stopPropagation()};return f.jsx("div",{className:Le("flex items-center gap-2 self-center",e),onClick:t,children:n})}$M.displayName="CollapsibleCardHeaderActions";function fp({children:n}){const{collapsible:e,isCollapsed:t,handleCollapse:i}=x.useContext(Xre);let s,r;return x.Children.forEach(n,o=>{if(x.isValidElement(o))switch(o.type){case hp:s=o;break;case $M:r=o;break}}),f.jsxs(but,{className:Le("group flex items-start justify-between gap-4 px-4 py-4",e&&"cursor-pointer"),onClick:e?i:void 0,children:[s,f.jsxs("div",{className:"flex items-center gap-2",children:[r,e&&f.jsx("div",{className:Le("flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 hover:bg-gray-200/50 dark:hover:bg-white/4"),children:f.jsx("div",{className:Le("transform transition-transform duration-200",t?"rotate-0":"rotate-180"),children:f.jsx(Pp,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})})]})]})}fp.displayName="CollapsibleCardHeader";function gp({children:n}){return f.jsx(wut,{className:"px-4 pt-1",children:n})}gp.displayName="CollapsibleCardContent";function E_({left:n,right:e}){return f.jsxs(yut,{className:"flex items-center gap-2 px-4 py-4",children:[f.jsx("div",{className:"flex flex-grow items-center gap-2",children:n}),e&&f.jsx("div",{className:"flex items-center",children:e})]})}E_.displayName="CollapsibleCardFooter";const s_e="collapsed-card-";function c1({children:n,className:e,variant:t="default",collapsible:i=!1,defaultCollapsed:s=!1,onCollapsedChange:r,name:o}){const a=o?np.get(`${s_e}${o}`,"boolean")??s:s,[l,c]=x.useState(a);x.useEffect(()=>{o&&np.set(`${s_e}${o}`,l)},[l,o]);const d=()=>{const b=!l;c(b),r==null||r(b)};let u,h,g;x.Children.forEach(n,b=>{if(x.isValidElement(b))switch(b.type){case fp:u=b;break;case gp:h=b;break;case E_:g=b;break}});const m={default:"rounded-md p-0 gap-0 bg-muted/50 dark:bg-white/4 border-0 border-b border-gray-200 dark:border-white/8 shadow-none",dense:"rounded-md p-0 gap-0 bg-muted/50 dark:bg-white/4 border-0 border-b border-gray-200 dark:border-white/8 shadow-none text-sm",flat:"rounded-md p-0 gap-0 border-0 border-b-0 shadow-none"};return f.jsx(Xre.Provider,{value:{isCollapsed:l,collapsible:i,handleCollapse:d},children:f.jsxs(_ut,{className:Le(m[t],e),children:[u,f.jsx("div",{className:Le("grid transition-all duration-200",l?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:f.jsxs("div",{className:"overflow-hidden",children:[h,g]})})]})})}function Sut(){const{dataMart:n,updateDataMartStorage:e}=og(),t=(n==null?void 0:n.definitionType)??null,[i,s]=x.useState(t);return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs(c1,{collapsible:!0,name:"data-storage",children:[f.jsx(fp,{children:f.jsx(hp,{icon:j1,tooltip:"Configure where your data will be stored",children:"Storage"})}),f.jsx(gp,{children:(n==null?void 0:n.storage)&&f.jsx(wat,{dataStorage:n.storage,onDataStorageChange:e})}),f.jsx(E_,{})]}),f.jsxs(c1,{collapsible:!0,name:"input-source",children:[f.jsx(fp,{children:f.jsx(hp,{icon:Pne,tooltip:"Configure how to extract data from your data warehouse",children:"Input Source"})}),f.jsx(gp,{children:n&&f.jsx(oct,{definitionType:i,initialDefinitionType:t,setDefinitionType:s})}),f.jsx(E_,{})]}),f.jsxs(c1,{collapsible:!0,name:"output-schema",children:[f.jsx(fp,{children:f.jsx(hp,{icon:KHe,tooltip:"Configure your data mart output schema",children:"Output Schema"})}),f.jsx(gp,{children:n&&f.jsx(put,{definitionType:i})}),f.jsx(E_,{})]})]})}function xut({row:n,onDeleteSuccess:e,onEditReport:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),[a,l]=x.useState(!1),{deleteReport:c,fetchReportsByDataMartId:d,runReport:u}=rg(),h=`actions-menu-${n.original.id}`,g=x.useCallback(async()=>{try{await c(n.original.id),await d(n.original.dataMart.id),e==null||e(),l(!1)}catch(C){console.error("Failed to delete Google Sheet:",C)}},[c,d,e,n.original.id,n.original.dataMart.id]),m=x.useCallback(()=>{t==null||t(n.original),o(!1)},[t,n.original]),b=x.useCallback(async()=>{try{s(!0),await u(n.original.id)}catch(C){console.error("Failed to run report:",C)}finally{s(!1)}},[u,n.original.id]),v=x.useCallback(()=>{l(!0),o(!1)},[]);return f.jsxs("div",{className:"text-right",onClick:C=>{C.stopPropagation()},children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":`Actions for report: ${n.original.title}`,"aria-haspopup":"true","aria-expanded":r,"aria-controls":h,children:[f.jsx("span",{className:"sr-only",children:"Open menu"}),f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon","aria-hidden":"true"})]})}),f.jsxs(Ol,{id:h,align:"end",role:"menu",children:[f.jsxs(wn,{onClick:C=>{C.stopPropagation(),m()},role:"menuitem",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit report"]}),VH(n.original.destinationConfig)&&f.jsxs(f.Fragment,{children:[f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),b()},disabled:i,role:"menuitem","aria-label":i?"Running report...":`Run report: ${n.original.title}`,children:[f.jsx(rH,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),i?"Running...":"Run report"]}),f.jsx(wn,{asChild:!0,children:f.jsxs("a",{href:Ese(n.original.destinationConfig.spreadsheetId,n.original.destinationConfig.sheetId),target:"_blank",rel:"noopener noreferrer",role:"menuitem",onClick:C=>{C.stopPropagation()},children:[f.jsx(lBe,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Open document"]})})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),v()},role:"menuitem","aria-label":`Delete report: ${n.original.title}`,children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete report"})]})]})]}),f.jsx(Ma,{open:a,onOpenChange:l,title:"Delete Report",description:`Are you sure you want to delete "${n.original.title}"? This action cannot be undone.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{g()},variant:"destructive"})]})}const Lut={[Fr.SUCCESS]:{icon:sH,color:"text-green-500",label:"Success"},[Fr.ERROR]:{icon:rF,color:"text-red-500",label:"Fail"},[Fr.RUNNING]:{icon:NR,color:"text-primary animate-spin",label:"In progress"},[Fr.CANCELLED]:{icon:rF,color:"text-gray-500",label:"Cancelled"}};function OIe({status:n,error:e}){if(!n)return null;const t=Lut[n],{icon:i,color:s,label:r}=t,o=`status-tooltip-${n}-${e?"error":"normal"}`,a=()=>n===Fr.ERROR&&e?`${r}: ${e}`:r;return f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(i,{className:Le("h-5 w-5",s),role:"img","aria-label":a(),"aria-describedby":o,tabIndex:0})}),f.jsxs(kn,{id:o,side:"bottom",role:"tooltip",children:[f.jsx("div",{className:"text-xs",children:r}),n===Fr.ERROR&&e&&f.jsx("div",{className:"mt-1 max-w-xs text-xs break-words whitespace-normal",children:e})]})]})})}var Bv=(n=>(n.TITLE="title",n.LAST_RUN_DATE="lastRunDate",n.LAST_RUN_STATUS="lastRunStatus",n))(Bv||{});const Eut={[Bv.TITLE]:"Title",[Bv.LAST_RUN_DATE]:"Last Run Date",[Bv.LAST_RUN_STATUS]:"Last Run Status"},r_e=n=>{switch(n){case"right":return"text-right";case"center":return"text-center";default:return"text-left"}},Dut=({onDeleteSuccess:n,onEditReport:e}={})=>[{accessorKey:Bv.TITLE,header:({column:t})=>f.jsx(La,{column:t,children:Eut[Bv.TITLE]}),cell:({row:t})=>t.original.title,enableColumnFilter:!0,size:50},{accessorKey:Bv.LAST_RUN_DATE,header:({column:t})=>f.jsx(La,{column:t,children:"Last Run Date"}),cell:({row:t})=>{const i=t.original.lastRunDate;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Never run"})},size:25},{accessorKey:Bv.LAST_RUN_STATUS,header:({column:t})=>f.jsx(La,{column:t,children:"Last Run Status"}),cell:({row:t})=>t.original.lastRunStatus?f.jsx(OIe,{status:t.original.lastRunStatus,error:t.original.lastRunError}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"—"}),size:25},{id:"actions",header:({table:t})=>f.jsx(BR,{table:t}),cell:({row:t})=>f.jsx(xut,{row:t,onDeleteSuccess:n,onEditReport:e}),size:80}];function Rut({destination:n,onEditReport:e}){const{reports:t,setPollingConfig:i}=rg(),s=x.useMemo(()=>t.filter(h=>h.dataDestination.type===St.GOOGLE_SHEETS&&h.dataDestination.id===n.id),[t,n.id]);x.useEffect(()=>{i({initialPollingIntervalMs:2e3,initialPollCount:3,regularPollingIntervalMs:5e3})},[i]);const r=x.useMemo(()=>Dut({onDeleteSuccess:()=>{},onEditReport:e}),[e]),{sorting:o,setSorting:a,columnVisibility:l,setColumnVisibility:c}=zS({columns:r,storageKeyPrefix:`data-mart-google-sheets-reports-${n.id}`,defaultSortingColumn:"lastRunDate"}),d=pC({data:s,columns:r,getCoreRowModel:gC(),onSortingChange:a,getSortedRowModel:WS(),state:{sorting:o,columnVisibility:l},onColumnVisibilityChange:c}),u=`google-sheets-reports-table-${n.id}`;return f.jsx("div",{className:"w-full",children:f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:u,className:"dm-card-table",role:"table","aria-label":`${n.title} reports`,children:[f.jsx(_C,{className:"dm-card-table-header",children:d.getHeaderGroups().map(h=>f.jsx(qr,{className:"dm-card-table-header-row",children:h.headers.map(g=>f.jsx(vC,{className:r_e(g.column.columnDef._align),style:g.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(g.column.getSize())}%`},scope:"col",children:g.isPlaceholder?null:typeof g.column.columnDef.header=="function"?g.column.columnDef.header(g.getContext()):g.column.columnDef.header},g.id))},h.id))}),f.jsx(bC,{className:"dm-card-table-body",children:d.getRowModel().rows.length?d.getRowModel().rows.map((h,g)=>f.jsx(qr,{onClick:()=>{const m=t.find(b=>b.id===h.original.id);m&&e(m)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":g+1,children:h.getVisibleCells().map((m,b)=>f.jsx(Rl,{className:`px-6 whitespace-normal ${r_e(m.column.columnDef._align)}`,style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},role:"cell","aria-colindex":b+1,children:typeof m.column.columnDef.cell=="function"?m.column.columnDef.cell(m.getContext()):m.column.columnDef.cell},m.id))},h.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:r.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No reports for this destination"})})})})]})})})}function Nut({row:n,onDeleteSuccess:e,onEditReport:t}){const[i,s]=x.useState(!1),[r,o]=x.useState(!1),[a,l]=x.useState(!1),{deleteReport:c,fetchReportsByDataMartId:d,runReport:u}=rg(),h=`actions-menu-${n.original.id}`,g=x.useCallback(async()=>{try{await c(n.original.id),await d(n.original.dataMart.id),e==null||e(),l(!1)}catch(C){console.error("Failed to delete report:",C)}},[c,d,e,n.original.id,n.original.dataMart.id]),m=x.useCallback(()=>{t==null||t(n.original),o(!1)},[t,n.original]),b=x.useCallback(async()=>{try{s(!0),await u(n.original.id)}catch(C){console.error("Failed to run report:",C)}finally{s(!1)}},[u,n.original.id]),v=x.useCallback(()=>{l(!0),o(!1)},[]);return f.jsxs("div",{className:"text-right",onClick:C=>{C.stopPropagation()},children:[f.jsxs(Al,{open:r,onOpenChange:o,children:[f.jsx(Ml,{asChild:!0,children:f.jsxs(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${r?"opacity-100":"group-hover:opacity-100"}`,"aria-label":`Actions for report: ${n.original.title}`,"aria-haspopup":"true","aria-expanded":r,"aria-controls":h,children:[f.jsx("span",{className:"sr-only",children:"Open menu"}),f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon","aria-hidden":"true"})]})}),f.jsxs(Ol,{id:h,align:"end",role:"menu",children:[f.jsxs(wn,{onClick:C=>{C.stopPropagation(),m()},role:"menuitem",children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit report"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),b()},disabled:i,role:"menuitem","aria-label":i?"Running report...":`Run report: ${n.original.title}`,children:[f.jsx(rH,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),i?"Running...":"Run report"]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:C=>{C.stopPropagation(),v()},role:"menuitem","aria-label":`Delete report: ${n.original.title}`,children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete report"})]})]})]}),f.jsx(Ma,{open:a,onOpenChange:l,title:"Delete Report",description:`Are you sure you want to delete "${n.original.title}"? This action cannot be undone.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{g()},variant:"destructive"})]})}function d$({column:n,children:e,label:t}){const i=n.getIsSorted(),s=x.useCallback(()=>{n.toggleSorting(n.getIsSorted()==="asc")},[n]),r=()=>i==="asc"?"sorted ascending":i==="desc"?"sorted descending":"not sorted",o=()=>i==="asc"?"ascending":i==="desc"?"descending":"none",a=t??(typeof e=="string"?e:"Column");return f.jsxs(rt,{variant:"ghost",onClick:s,className:"group dm-card-table-header-row-btn","aria-label":`${a} - ${r()}. Click to sort.`,"aria-sort":o(),children:[e,f.jsxs("span",{className:"flex h-4 w-4 items-center justify-center","aria-hidden":"true",children:[i==="asc"&&f.jsx(TD,{className:"text-foreground h-4 w-4"}),i==="desc"&&f.jsx(Pp,{className:"text-foreground h-4 w-4"}),!i&&f.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:f.jsx(TD,{className:"text-muted-foreground h-4 w-4"})})]})]})}var Vv=(n=>(n.TITLE="title",n.LAST_RUN_DATE="lastRunDate",n.LAST_RUN_STATUS="lastRunStatus",n))(Vv||{});const PIe={[Vv.TITLE]:"Title",[Vv.LAST_RUN_DATE]:"Last Run Date",[Vv.LAST_RUN_STATUS]:"Last Run Status"};function Tut({table:n}){return f.jsx("div",{className:"px-4 text-right",children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn","aria-label":"Toggle columns",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:n.getAllColumns().filter(e=>e.getCanHide()&&e.id!=="actions").map(e=>{const t=PIe[e.id]||e.id;return f.jsx(wn,{className:"capitalize",children:f.jsxs("label",{className:"flex items-center space-x-2",children:[f.jsx("button",{type:"button",role:"checkbox","aria-checked":e.getIsVisible(),"data-state":e.getIsVisible()?"checked":"unchecked","aria-label":`Toggle column ${e.id}`,className:"peer border-input data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border bg-white shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white/8",onClick:()=>{e.toggleVisibility(!e.getIsVisible())},children:e.getIsVisible()&&f.jsx("span",{"data-state":"checked","data-slot":"checkbox-indicator",className:"pointer-events-none flex items-center justify-center text-current transition-none",children:f.jsx(Wc,{className:"size-3.5 text-white"})})}),f.jsx("span",{children:t})]})},e.id)})})]})})}const o_e=n=>{switch(n){case"right":return"text-right";case"center":return"text-center";default:return"text-left"}},Iut=({onDeleteSuccess:n,onEditReport:e}={})=>[{accessorKey:Vv.TITLE,header:({column:t})=>f.jsx(d$,{column:t,children:PIe[Vv.TITLE]}),cell:({row:t})=>t.original.title,enableColumnFilter:!0,size:50},{accessorKey:Vv.LAST_RUN_DATE,header:({column:t})=>f.jsx(d$,{column:t,children:"Last Run Date"}),cell:({row:t})=>{const i=t.original.lastRunDate;return f.jsx("div",{className:"text-muted-foreground text-sm",children:i?f.jsx(W1,{date:new Date(i)}):"Never run"})},size:25},{accessorKey:Vv.LAST_RUN_STATUS,header:({column:t})=>f.jsx(d$,{column:t,children:"Last Run Status"}),cell:({row:t})=>t.original.lastRunStatus?f.jsx(OIe,{status:t.original.lastRunStatus,error:t.original.lastRunError}):f.jsx("span",{className:"text-muted-foreground text-sm",children:"—"}),size:25},{id:"actions",header:({table:t})=>f.jsx(Tut,{table:t}),cell:({row:t})=>f.jsx(Nut,{row:t,onDeleteSuccess:n,onEditReport:e}),size:80}];function kut({destinationType:n,destination:e,onEditReport:t}){const{reports:i,setPollingConfig:s}=rg(),r=x.useMemo(()=>i.filter(g=>g.dataDestination.type===n&&g.dataDestination.id===e.id),[i,e.id,n]);x.useEffect(()=>{s({initialPollingIntervalMs:2e3,initialPollCount:3,regularPollingIntervalMs:5e3})},[s]);const o=x.useMemo(()=>Iut({onDeleteSuccess:()=>{},onEditReport:t}),[t]),{sorting:a,setSorting:l,columnVisibility:c,setColumnVisibility:d}=zS({columns:o,storageKeyPrefix:`data-mart-email-reports-${e.id}`,defaultSortingColumn:"lastRunDate"}),u=pC({data:r,columns:o,getCoreRowModel:gC(),onSortingChange:l,getSortedRowModel:WS(),state:{sorting:a,columnVisibility:c},onColumnVisibilityChange:d}),h=`email-reports-table-${e.id}`;return f.jsx("div",{className:"w-full",children:f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:h,className:"dm-card-table",role:"table","aria-label":`${e.title} reports`,children:[f.jsx(_C,{className:"dm-card-table-header",children:u.getHeaderGroups().map(g=>f.jsx(qr,{className:"dm-card-table-header-row",children:g.headers.map(m=>f.jsx(vC,{className:o_e(m.column.columnDef._align),style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},scope:"col",children:m.isPlaceholder?null:typeof m.column.columnDef.header=="function"?m.column.columnDef.header(m.getContext()):m.column.columnDef.header},m.id))},g.id))}),f.jsx(bC,{className:"dm-card-table-body",children:u.getRowModel().rows.length?u.getRowModel().rows.map((g,m)=>f.jsx(qr,{onClick:()=>{const b=i.find(v=>v.id===g.original.id);b&&t(b)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":m+1,children:g.getVisibleCells().map((b,v)=>f.jsx(Rl,{className:`px-6 whitespace-normal ${o_e(b.column.columnDef._align)}`,style:b.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(b.column.getSize())}%`},role:"cell","aria-colindex":v+1,children:typeof b.column.columnDef.cell=="function"?b.column.columnDef.cell(b.getContext()):b.column.columnDef.cell},b.id))},g.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:o.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No reports for this destination"})})})})]})})})}function Aut({children:n,className:e,...t}){return f.jsx("div",{className:Le("group flex items-start justify-center gap-3 rounded-md border-b border-gray-200 bg-white transition-shadow duration-200 hover:shadow-xs dark:border-0 dark:bg-white/2",e),...t,children:n})}function Mut({children:n,className:e,...t}){return f.jsx("div",{className:Le("flex flex-grow flex-col gap-1 py-4",e),...t,children:n})}function Out({children:n,className:e,...t}){return f.jsx("div",{className:Le("text-md font-medium",e),...t,children:n})}function Put({children:n,className:e,...t}){return f.jsx("div",{className:Le("text-muted-foreground text-sm",e),...t,children:n})}function Fut({checked:n,disabled:e,loading:t,onCheckedChange:i,tooltipTextSwitchOn:s,tooltipTextSwitchOff:r,tooltipTextSwitchDisabled:o}){const a=e?o??"Disabled":n?s:r;return f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{className:"flex items-center justify-center py-5 pl-6",onClick:l=>l.stopPropagation(),children:t?f.jsx(NR,{className:"text-muted-foreground h-5 w-5 animate-spin"}):f.jsx(WTe,{checked:n,disabled:e,onCheckedChange:i})})}),f.jsx(kn,{children:a})]})}function jut({icon:n,className:e,...t}){return f.jsx("div",{className:Le("flex flex-shrink-0 items-center justify-center self-center p-4",e),...t,children:f.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200 group-hover:bg-gray-200/50 dark:group-hover:bg-white/4",children:n??f.jsx($d,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})})}function Hut(n){const{dataMart:e}=Zu(),{reports:t,createReport:i,deleteReport:s,fetchReportsByDataMartId:r}=rg(),[o,a]=x.useState(!1),l=x.useMemo(()=>t.find(g=>g.dataDestination.type===St.LOOKER_STUDIO&&g.dataDestination.id===n.id),[t,n.id]),c=x.useMemo(()=>(e==null?void 0:e.status.code)===Ll.PUBLISHED,[e==null?void 0:e.status.code]),d=x.useMemo(()=>!!l,[l]),u=x.useMemo(()=>d?"Available in Looker Studio":"Not available in Looker Studio",[d]),h=x.useCallback(async g=>{if(!(!e||!c)){a(!0);try{if(g){const m={title:`Looker Studio Report - ${n.title}`,dataMartId:e.id,dataDestinationId:n.id,destinationConfig:{type:nl.LOOKER_STUDIO_CONFIG,cacheLifetime:300}};await i(m),await r(e.id)}else l&&(await s(l.id),await r(e.id))}catch(m){console.error("Failed to toggle Looker Studio report:",m)}finally{a(!1)}}},[e,c,n,l,i,s,r]);return{existingReport:l,isLoading:o,isEnabled:c,isChecked:d,dynamicTitle:u,handleSwitchChange:h}}function But({destination:n,onEditReport:e,...t}){const{existingReport:i,isLoading:s,isEnabled:r,isChecked:o,dynamicTitle:a,handleSwitchChange:l}=Hut(n),c=x.useCallback(()=>{i&&e(i)},[i,e]);return f.jsxs(Aut,{className:i?"cursor-pointer dark:hover:bg-white/5":"",onClick:i?c:void 0,...t,children:[f.jsx(Fut,{checked:o,disabled:!r,loading:s,onCheckedChange:d=>void l(d),tooltipTextSwitchOn:"Switch off to remove access",tooltipTextSwitchOff:"Switch on to enable access",tooltipTextSwitchDisabled:"Publish the Data Mart first to enable access in Looker Studio"}),f.jsxs(Mut,{children:[f.jsx(Out,{children:a}),f.jsx(Put,{children:o&&i?f.jsx(f.Fragment,{children:i.lastRunDate?f.jsxs(f.Fragment,{children:["Last fetched"," ",i.lastRunStatus===Fr.SUCCESS&&"successfully ",f.jsx(W1,{date:new Date(i.lastRunDate)}),i.lastRunStatus===Fr.ERROR&&" but failed with error",i.lastRunError&&f.jsx("div",{className:"mt-1 text-red-600 dark:text-red-400",children:i.lastRunError})]}):"Waiting for Looker Studio to fetch data"}):"Switch on to enable access"})]}),o&&i&&f.jsx(jut,{})]})}function Vut(){const{scope:n}=hb();return f.jsx("div",{className:"dm-card",children:f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(Mne,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Google Sheets, Looker Studio… and friends!"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"To send your Data Mart's data to your favorite tools, create a Destination first."}),f.jsx(rt,{variant:"outline",asChild:!0,children:f.jsxs(Vc,{to:n("/data-destinations"),className:"flex items-center gap-1",children:["Go to Destinations",f.jsx($d,{className:"h-4 w-4"})]})})]})})}function Wut(){const[n,e]=x.useState(!1),[t,i]=x.useState(xr.CREATE),[s,r]=x.useState(null);return{isOpen:n,mode:t,editingReport:s,handleAddReport:()=>{i(xr.CREATE),r(null),e(!0),Vt({event:"report_open",category:"Report",action:"CreateReport",label:"ReportForm"})},handleEditReport:c=>{i(xr.EDIT),r(c),e(!0),Vt({event:"report_open",category:"Report",action:"EditReport",label:c.dataDestination.type})},handleCloseModal:()=>{e(!1),r(null),Vt({event:"report_close",category:"Report",action:t===xr.EDIT?"Edit":"Create",label:"ReportForm"})}}}const zut=[St.GOOGLE_SHEETS,St.EMAIL,St.SLACK,St.MS_TEAMS,St.GOOGLE_CHAT];function Uut({destination:n,dataMartStatus:e}){const{destinationInfo:t,isVisible:i}=RJe(n),{isOpen:s,mode:r,editingReport:o,handleAddReport:a,handleEditReport:l,handleCloseModal:c}=Wut();return i?f.jsxs(f.Fragment,{children:[f.jsxs(c1,{name:n.id,collapsible:!0,defaultCollapsed:!1,children:[f.jsxs(fp,{children:[f.jsx(hp,{icon:t.icon,children:n.title}),f.jsx($M,{children:zut.includes(n.type)&&f.jsx($ut,{dataMartStatus:e,onAddReport:a})})]}),f.jsx(gp,{children:f.jsx(bht,{destination:n,onEditReport:l})}),f.jsx(E_,{})]}),f.jsx(_ht,{destination:n,isOpen:s,onClose:c,mode:r,initialReport:o})]}):null}function $ut({dataMartStatus:n,onAddReport:e}){const t=(n==null?void 0:n.code)===Ll.DRAFT;return f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("span",{children:f.jsxs(rt,{onClick:e,variant:"outline",size:"sm","aria-label":"Add new report",disabled:t,children:[f.jsx(Gd,{className:"h-4 w-4"}),"Add Report"]})})}),t&&f.jsx(kn,{children:f.jsx("p",{children:"To create a report, publish the Data Mart first"})})]})}function Gut({elementId:n,isOpen:e,delay:t=100,selectText:i=!1}){x.useEffect(()=>{{const s=setTimeout(()=>{const r=document.getElementById(n);if(r){const o=r;o.focus(),i&&o.value?o.select():o.value&&o.setSelectionRange(o.value.length,o.value.length)}},t);return()=>{clearTimeout(s)}}},[e,n,t,i])}const qut=_s({title:pn().min(1,"Title is required"),documentUrl:pn().refine(ADe,"Enter a valid Google Sheets URL"),dataDestinationId:pn().min(1,"Destination is required")});function Kut({initialReport:n,mode:e,dataMartId:t,onSuccess:i,preSelectedDestination:s}){const[r,o]=x.useState(null),[a,l]=x.useState(!1),{updateReport:c,createReport:d,error:u,clearError:h}=rg();x.useEffect(()=>{a&&u&&(o(u),l(!1))},[u,a]);const g=Bp({resolver:pb(qut),defaultValues:{title:(n==null?void 0:n.title)??"",documentUrl:n!=null&&n.destinationConfig&&VH(n.destinationConfig)?`https://docs.google.com/spreadsheets/d/${n.destinationConfig.spreadsheetId}/edit#gid=${n.destinationConfig.sheetId}`:"",dataDestinationId:(n==null?void 0:n.dataDestination.id)??(s==null?void 0:s.id)??""},mode:"onTouched"}),{register:m,handleSubmit:b,formState:v,reset:C}=g,{errors:y,isDirty:L}=v,E=x.useCallback(async R=>{try{o(null),h(),l(!0);const{spreadsheetId:T,sheetId:N}=rJe(R.documentUrl);if(!T){o("Invalid Google Sheets URL");return}let I;if(e===xr.CREATE)I=await d({title:R.title,dataMartId:t,dataDestinationId:R.dataDestinationId,destinationConfig:{type:nl.GOOGLE_SHEETS_CONFIG,spreadsheetId:T,sheetId:N}});else{if(!n){o("Initial report is required for edit mode");return}I=await c(n.id,{title:R.title,dataDestinationId:R.dataDestinationId,destinationConfig:{type:nl.GOOGLE_SHEETS_CONFIG,spreadsheetId:T,sheetId:N}})}if(!I||u){o(u??"An error occurred while submitting the form");return}i==null||i()}catch(T){console.error("Error submitting form:",T),o("An error occurred while submitting the form")}},[e,n,t,d,c,i,h,u]);return{form:g,register:m,handleSubmit:b,errors:y,isDirty:L,reset:C,formError:r,isSubmitting:a,setFormError:o,getValues:g.getValues,onSubmit:E}}function Zut(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a correct document link?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the correct Google Sheets document URL with a Sheet ID (GID), follow these steps:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Open your Google Sheets document and select the specific ",f.jsx("strong",{children:"sheet tab"})," ","where the data should be inserted."]}),f.jsxs("li",{children:["Share the document with the service account email and grant it ",f.jsx("strong",{children:"Editor"})," ","access."]}),f.jsxs("li",{children:["While the correct sheet is selected, copy the URL from your browser's address bar — it should include the ",f.jsx("code",{className:"text-sm font-semibold",children:"gid"})," of that sheet."]}),f.jsx("li",{children:"Paste this URL into the field above."})]})]})]})})}function u$(n){return"serviceAccount"in n}function FIe({value:n,children:e,doNotTruncateContent:t}){const[i,s]=x.useState(!1),r=async()=>{n&&(await navigator.clipboard.writeText(n),s(!0),setTimeout(()=>s(!1),2e3))};return f.jsx(Nf,{children:f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsxs("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:o=>o.key==="Enter"&&r(),className:Le("flex cursor-pointer items-center justify-between gap-2 select-none","text-muted-foreground border-input rounded-md border px-3 py-1.5 text-sm","hover:bg-accent hover:text-accent-foreground transition-colors"),children:[f.jsx("span",{className:t?"w-[95%]":"truncate",children:e||n||"No data"}),i?f.jsx(Wc,{className:"h-4 w-4 text-green-500"}):f.jsx(t2,{className:"h-4 w-4"})]})}),f.jsx(kn,{children:f.jsx("p",{children:i?"Copied!":"Click to copy"})})]})})}const Yut=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="google-sheets-edit-form",c="google-sheets-title-input",d="google-sheets-document-url-input",u="google-sheets-data-destination-select",{dataMart:h}=Zu(),{scope:g}=hb(),{dataDestinations:m,fetchDataDestinations:b,loading:v}=MM(),[C,y]=x.useState([]);x.useEffect(()=>{h&&b()},[h,b]),x.useEffect(()=>{if(m.length>0){const H=m.filter(j=>j.type===St.GOOGLE_SHEETS);y(H)}},[m]),Gut({elementId:c,isOpen:!0,delay:150});const{isDirty:L,reset:E,form:R,isSubmitting:T,formError:N,onSubmit:I}=Kut({initialReport:n,mode:e,dataMartId:(h==null?void 0:h.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});x.useEffect(()=>{i&&i(N)},[N,i]),x.useEffect(()=>{if(e===xr.EDIT&&n&&VH(n.destinationConfig))E({title:n.title,documentUrl:Ese(n.destinationConfig.spreadsheetId,n.destinationConfig.sheetId),dataDestinationId:n.dataDestination.id});else if(e===xr.CREATE){const H=(o==null?void 0:o.id)??"";E({title:"",documentUrl:"",dataDestinationId:H})}},[n,e,E,o]),x.useEffect(()=>{t==null||t(L)},[L,t]);const M=R.watch("documentUrl"),P=M&&ADe(M.trim());return f.jsx(CC,{...R,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:H=>void R.handleSubmit(I)(H),children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:R.control,name:"title",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a title that reflects the report`s purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{id:c,placeholder:"Enter a report title",...H})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:R.control,name:"dataDestinationId",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select one of your existing destinations",children:"Destination"}),f.jsxs($c,{onValueChange:H.onChange,value:H.value,disabled:v||C.length===0,children:[f.jsx(cn,{children:f.jsx(qc,{id:u,className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{className:"truncate",placeholder:"Select a destination",children:H.value&&C.length>0&&(()=>{const j=C.find(V=>V.id===H.value);if(j){const W=Nc.getInfo(j.type).icon;return f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(W,{className:"flex-shrink-0",size:18}),f.jsx("div",{className:"flex min-w-0 flex-col",children:f.jsx("span",{className:"truncate",children:j.title})})]})}return null})()})})}),f.jsx(Kc,{children:C.map(j=>{const W=Nc.getInfo(j.type).icon;return f.jsx(fo,{value:j.id,children:f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(W,{className:"flex-shrink-0",size:18}),f.jsxs("div",{className:"flex min-w-0 flex-col",children:[f.jsx("span",{className:"truncate",children:j.title}),f.jsx("span",{className:"text-muted-foreground truncate text-xs",children:(u$(j.credentials)&&HU(j.credentials.serviceAccount))??"No email found"})]})]})},j.id)})})]}),C.length===0&&!v&&f.jsxs(Dre,{className:"mt-2",children:[f.jsx(fM,{className:"h-4 w-4"}),f.jsx(kTe,{children:"No destinations available"}),f.jsxs(Rre,{children:["You need to create a Destination before you can create a report."," ",f.jsx(Vc,{to:g("/data-destinations"),className:"font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300",children:"Go to Destinations"})]})]}),H.value&&C.length>0&&(()=>{const j=C.find(V=>V.id===H.value);return j?f.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[f.jsx(Ji,{children:"Service Account Email"}),f.jsx(FIe,{value:u$(j.credentials)?HU(j.credentials.serviceAccount)??"No email found":"",children:u$(j.credentials)?HU(j.credentials.serviceAccount):"No email found"})]}):null})(),f.jsx(Cn,{})]})}),f.jsx(fn,{control:R.control,name:"documentUrl",render:({field:H})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"The link must include the Sheet ID to insert data into the correct tab",children:"Document Link with Sheet ID (GID)"}),f.jsx(cn,{children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(vn,{id:d,placeholder:"Document URL",className:"flex-1",...H}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("button",{type:"button",className:`flex-shrink-0 rounded-md p-2 transition-all duration-200 ${P?"text-blue-600 hover:bg-blue-50 hover:text-blue-700 dark:text-blue-400 dark:hover:bg-blue-950/20 dark:hover:text-blue-300":"text-muted-foreground/30 cursor-not-allowed"}`,onClick:()=>{P&&window.open(M.trim(),"_blank","noopener,noreferrer")},disabled:!P,"aria-label":P?"Open document in new tab":"Document link is not valid",children:f.jsx(F_,{className:"h-4 w-4","aria-hidden":"true"})})}),f.jsx(kn,{side:"top",align:"center",role:"tooltip",children:P?"Open document in new tab":"Enter a valid URL to enable link"})]})]})}),f.jsx(Hs,{children:f.jsx(Zut,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Automate Report Runs",children:f.jsx(Ire,{})})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":e===xr.CREATE?"Create new report":"Save changes to report",disabled:!L||T,children:T?e===xr.CREATE?"Creating...":"Saving...":e===xr.CREATE?"Create new report":"Save changes to report"}),r&&f.jsx(rt,{variant:"outline",type:"button",onClick:r,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})});function Xut({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:i===xr.CREATE?"Create new report":"Edit report"}),f.jsx(cC,{children:i===xr.CREATE?"Fill in the details to create a new Google Sheets report":"Update details of an existing Google Sheets report"})]}),f.jsx(AM,{children:f.jsx(Yut,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const Qut=_s({cacheLifetime:NYe().min(300,"Cache time must be at least 5 minutes (300 seconds)")});function Jut({initialReport:n,dataMartId:e,onSuccess:t,preSelectedDestination:i}){const[s,r]=x.useState(null),{createReport:o,updateReport:a}=rg(),l=Bp({resolver:pb(Qut),defaultValues:{cacheLifetime:n!=null&&n.destinationConfig&&UDe(n.destinationConfig)?n.destinationConfig.cacheLifetime:300},mode:"onTouched"});return{form:l,onSubmit:async d=>{try{r(null);const{cacheLifetime:u}=d,h={type:nl.LOOKER_STUDIO_CONFIG,cacheLifetime:u};n?await a(n.id,{title:"Looker Studio Report",dataDestinationId:n.dataDestination.id,destinationConfig:h}):await o({title:"Looker Studio Report",dataMartId:e,dataDestinationId:(i==null?void 0:i.id)??"",destinationConfig:h}),t==null||t()}catch(u){console.error("Error submitting form:",u),r("Failed to save report. Please try again.")}},formError:s,isSubmitting:l.formState.isSubmitting,isDirty:l.formState.isDirty,reset:l.reset}}function eht(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"cache-lifetime-details",children:[f.jsx(is,{children:"What is the Cache Lifetime for Looker Studio?"}),f.jsx(ns,{children:f.jsx("p",{className:"mb-2",children:"Cache Lifetime - defines the period during which results from previous query executions are served from storage-side cache, eliminating the need to re-execute the query"})})]})})}const tht=[{value:300,label:"5 minutes"},{value:600,label:"10 minutes"},{value:900,label:"15 minutes"},{value:1800,label:"30 minutes"},{value:3600,label:"1 hour"},{value:7200,label:"2 hours"},{value:14400,label:"4 hours"},{value:28800,label:"8 hours"},{value:43200,label:"12 hours"}],iht=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="looker-studio-edit-form",{dataMart:c}=Zu(),{isDirty:d,reset:u,form:h,isSubmitting:g,formError:m,onSubmit:b}=Jut({initialReport:n,dataMartId:(c==null?void 0:c.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});return x.useEffect(()=>{i&&i(m)},[m,i]),x.useEffect(()=>{e===xr.EDIT&&n&&UDe(n.destinationConfig)?u({cacheLifetime:n.destinationConfig.cacheLifetime}):e===xr.CREATE&&u({cacheLifetime:300})},[n,e,u]),x.useEffect(()=>{t==null||t(d)},[d,t]),f.jsx(CC,{...h,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:v=>void h.handleSubmit(b)(v),children:[f.jsx(wC,{children:f.jsx(tc,{title:"Cache Configuration",children:f.jsx(fn,{control:h.control,name:"cacheLifetime",render:({field:v})=>{var C;return f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Period during which query results are served from storage-side cache, avoiding re-execution",children:"Cache Lifetime"}),f.jsxs($c,{onValueChange:y=>{v.onChange(parseInt(y,10))},value:((C=v.value)==null?void 0:C.toString())??"300",defaultValue:"300",children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select cache time"})})}),f.jsx(Kc,{children:tht.map(y=>f.jsx(fo,{value:y.value.toString(),children:y.label},y.value))})]}),f.jsx(Cn,{}),f.jsx(Hs,{children:f.jsx(eht,{})})]})}})})}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",className:"w-full","aria-label":e===xr.CREATE?"Create":"Save changes",disabled:!d||g,children:g?e===xr.CREATE?"Creating...":"Saving...":e===xr.CREATE?"Create":"Save changes"}),r&&f.jsx(rt,{variant:"outline",type:"button",onClick:r,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})});function nht({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:(s==null?void 0:s.title)??"Looker Studio"}),f.jsx(cC,{children:i===xr.CREATE?"Set up Data Mart as a data source":"Update connection details"})]}),f.jsx(AM,{children:f.jsx(iht,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}const a_e=({destination:n})=>{const t=Nc.getInfo(n.type).icon;return f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[f.jsx(t,{className:"flex-shrink-0",size:18}),f.jsx("div",{className:"flex min-w-0 flex-col",children:f.jsx("span",{className:"truncate",children:n.title})})]})};function sht(n){return"to"in n}const rht=({destination:n})=>{if(!n)return null;const e=n.credentials,t=sht(e)&&e.to.length?e.to.join(", "):"";return f.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[f.jsx(Ji,{children:"Recipients of this report"}),f.jsx(FIe,{doNotTruncateContent:!0,value:t,children:t||"No recipients found"})]})};var ay=(n=>(n.ALWAYS="ALWAYS",n.RESULT_IS_EMPTY="RESULT_IS_EMPTY",n.RESULT_IS_NOT_EMPTY="RESULT_IS_NOT_EMPTY",n))(ay||{});const oht=_s({title:pn().min(1,"Title is required"),dataDestinationId:pn().min(1,"Destination is required"),reportCondition:TH(ay),subject:pn().min(1,"Subject is required"),messageTemplate:pn().min(1,"Message body is required")});function aht({initialReport:n,mode:e,dataMartId:t,onSuccess:i,preSelectedDestination:s}){const[r,o]=x.useState(null),[a,l]=x.useState(!1),{updateReport:c,createReport:d,error:u,clearError:h}=rg();x.useEffect(()=>{a&&u&&(o(u),l(!1))},[u,a]);const g=Bp({resolver:pb(oht),defaultValues:{title:(n==null?void 0:n.title)??"",dataDestinationId:(n==null?void 0:n.dataDestination.id)??(s==null?void 0:s.id)??"",reportCondition:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.reportCondition:ay.ALWAYS,subject:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.subject:"",messageTemplate:n!=null&&n.destinationConfig&&VU(n.destinationConfig)?n.destinationConfig.messageTemplate:""},mode:"onTouched"}),{handleSubmit:m,formState:b,reset:v}=g,{isDirty:C,errors:y}=b,L=x.useCallback(async E=>{try{o(null),h(),l(!0);let R;const T={type:nl.EMAIL_CONFIG,reportCondition:E.reportCondition,subject:E.subject,messageTemplate:E.messageTemplate};if(e===xr.CREATE)R=await d({title:E.title,dataMartId:t,dataDestinationId:E.dataDestinationId,destinationConfig:T});else{if(!n){o("Initial report is required for edit mode");return}R=await c(n.id,{title:E.title,dataDestinationId:E.dataDestinationId,destinationConfig:T})}if(!R||u){o(u??"An error occurred while submitting the form");return}i==null||i()}catch(R){console.error("Error submitting form:",R),o("An error occurred while submitting the form")}},[e,n,t,d,c,i,h,u]);return{form:g,handleSubmit:m,errors:y,isDirty:C,reset:v,formError:r,isSubmitting:a,setFormError:o,onSubmit:L}}function lht({value:n,onChange:e,onBlur:t,height:i=240,theme:s="light",options:r,className:o,placeholder:a="Start writing your message…"}){const l=c=>{t&&c.onDidBlurEditorText(t)};return f.jsx(vre,{language:"markdown",height:i,value:n,onChange:c=>{e(c??"")},onMount:l,theme:s,options:{wordWrap:"on",minimap:{enabled:!1},lineNumbers:"off",folding:!1,scrollBeyondLastLine:!1,automaticLayout:!0,placeholder:a,...r},className:o})}const cht=()=>f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(bl,{className:"h-6 w-3/4"}),f.jsx(bl,{className:"h-4 w-1/2"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(bl,{className:"h-4 w-full"}),f.jsx(bl,{className:"h-4 w-5/6"}),f.jsx(bl,{className:"h-4 w-4/5"}),f.jsx(bl,{className:"h-4 w-3/4"})]})]});function jIe({html:n,loading:e=!1,error:t=null,height:i=240,className:s,emptyState:r=f.jsx("div",{className:"text-muted-foreground text-sm",children:"Nothing to preview"})}){let o="#fff",a="#000";if(typeof window<"u"){const l=getComputedStyle(document.documentElement),c=l.getPropertyValue("--background").trim(),d=l.getPropertyValue("--foreground").trim();c&&(o=c),d&&(a=d)}return f.jsxs("div",{className:`bg-background overflow-auto p-4 ${s??""}`,style:{height:i},children:[e&&f.jsx(cht,{}),!e&&t&&f.jsxs("div",{className:"text-destructive text-sm",children:["Error: ",t]}),!e&&!t&&!n&&r,!e&&!t&&!!n&&f.jsx("iframe",{title:"Markdown preview",sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:`<!doctype html><html lang='en' style="background:${o};color:${a}"><head><meta charset='utf-8'/><base target='_blank'></head><body>${n}</body></html>`,className:"h-full w-full border-0"})]})}function dht({value:n,onChange:e}){return f.jsx(ore,{value:n,onValueChange:t=>{e(t)},children:f.jsxs(are,{children:[f.jsx(u2,{value:"markdown",children:"Markdown"}),f.jsx(u2,{value:"preview",children:"Preview"})]})})}function uht({markdown:n,enabled:e=!0,debounceMs:t=300,toHtml:i}){const[s,r]=x.useState(""),[o,a]=x.useState(!1),[l,c]=x.useState(null),d=x.useRef(null);return x.useEffect(()=>{var m;if(!e)return;const u=n;if(!u.trim()){r(""),c(null),a(!1);return}const h=new AbortController;(m=d.current)==null||m.abort(),d.current=h,a(!0),c(null);const g=setTimeout(()=>{i(u,h.signal).then(b=>{r(b)}).catch(b=>{if(h.signal.aborted)return;const v=b instanceof Error?b.message:"Failed to load preview";c(v)}).finally(()=>{h.signal.aborted||a(!1)})},t);return()=>{clearTimeout(g),h.abort()}},[n,e,t,i]),{html:s,loading:o,error:l}}function hht(n,e){return Rd.post("/markdown/parse-to-html",{markdown:n},{headers:{"Content-Type":"application/json"},responseType:"text",signal:e}).then(t=>t.data)}function HIe(n){const e=x.useCallback(hht,[]);return uht({...n,toHtml:e})}function fht(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"message-details",children:[f.jsx(is,{children:"How can I format my message?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"You can format your message using Markdown — a simple text formatting syntax that lets you add structure and style without using complex editors."}),f.jsxs("p",{className:"mb-2",children:["For example:",f.jsx("br",{}),"**bold text** → ",f.jsx("b",{children:"bold text"}),f.jsx("br",{}),"*italic text* → ",f.jsx("i",{children:"italic text"}),f.jsx("br",{}),"- list item → • list item"]}),f.jsxs("p",{children:["Use the Preview tab to see how your message will look after formatting.",f.jsx("br",{}),"If you’re new to Markdown, learn more from this"," ",f.jsx(ir,{className:"underline",href:"https://www.markdownguide.org/basic-syntax/",children:"quick guide"})]})]})]})})}function ght(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"sending-condition-details",children:[f.jsx(is,{children:"What are Data Mart Run results?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"A Data Mart Run result is the outcome of processing your Data Mart — for example, running an SQL query that retrieves data for your report."}),f.jsx("p",{children:"Before sending a report, OWOX automatically runs the Data Mart and checks its result. Depending on your settings, the report can be sent always, only if the result is not empty, or only if it’s empty."})]})]})})}const pht=[St.EMAIL,St.SLACK,St.GOOGLE_CHAT,St.MS_TEAMS],BIe=x.forwardRef(({initialReport:n,mode:e=xr.EDIT,onDirtyChange:t,onFormErrorChange:i,onSubmit:s,onCancel:r,preSelectedDestination:o},a)=>{const l="email-report-edit-form",{dataMart:c}=Zu(),{dataDestinations:d,fetchDataDestinations:u,loading:h}=MM(),[g,m]=x.useState([]);x.useEffect(()=>{c&&u()},[c,u]),x.useEffect(()=>{if(d.length>0){const B=o!=null&&o.type?[o.type]:pht,K=d.filter(X=>B.includes(X.type));m(K)}},[d,o==null?void 0:o.type]);const{isDirty:b,reset:v,form:C,isSubmitting:y,formError:L,onSubmit:E}=aht({initialReport:n,mode:e,dataMartId:(c==null?void 0:c.id)??"",onSuccess:()=>{s==null||s()},preSelectedDestination:o});x.useEffect(()=>{i&&i(L)},[L,i]),x.useEffect(()=>{if(!(e===xr.EDIT&&n)){if(e===xr.CREATE){const B=(o==null?void 0:o.id)??"";v({title:"",dataDestinationId:B,reportCondition:ay.ALWAYS,subject:"",messageTemplate:""})}}},[n,e,v,o]),x.useEffect(()=>{t==null||t(b)},[b,t]);const R=x.useMemo(()=>[{value:ay.ALWAYS,label:"Send always"},{value:ay.RESULT_IS_EMPTY,label:"Send only when result is empty"},{value:ay.RESULT_IS_NOT_EMPTY,label:"Send only when result is not empty"}],[]),{resolvedTheme:T}=AH(),N=T==="dark"?"vs-dark":"light",[I,M]=x.useState("markdown"),P=C.watch("messageTemplate"),{html:H,loading:j,error:V}=HIe({markdown:P,enabled:I==="preview"}),W=C.watch("dataDestinationId"),U=x.useMemo(()=>W&&g.length>0?g.find(B=>B.id===W)??null:null,[W,g]);return f.jsx(CC,{...C,children:f.jsxs(gb,{id:l,ref:a,noValidate:!0,onSubmit:B=>{C.handleSubmit(E)(B)},children:[f.jsxs(wC,{children:[f.jsxs(tc,{title:"General",children:[f.jsx(fn,{control:C.control,name:"title",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a title that reflects the report`s purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter a report title",...B})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:C.control,name:"dataDestinationId",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select one of your existing destinations",children:"Destination"}),f.jsxs($c,{onValueChange:B.onChange,value:B.value,disabled:h||g.length===0,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{className:"truncate",placeholder:"Select a destination",children:U&&f.jsx(a_e,{destination:U})})})}),f.jsx(Kc,{children:g.map(K=>f.jsx(fo,{value:K.id,children:f.jsx(a_e,{destination:K})},K.id))})]}),f.jsx(rht,{destination:U}),f.jsx(Cn,{})]})})]}),f.jsxs(tc,{title:"Template",children:[f.jsx(fn,{control:C.control,name:"subject",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Add a short, clear subject line for your report",children:"Subject"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter a message title",...B})}),f.jsx(Cn,{})]})}),f.jsx(fn,{control:C.control,name:"messageTemplate",render:({field:B})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx(Ji,{tooltip:"Write your report message in Markdown and check the final format in Preview",children:"Message"}),f.jsx(dht,{value:I,onChange:M})]}),f.jsx(cn,{children:f.jsx("div",{className:"overflow-hidden rounded-md border",children:I==="markdown"?f.jsx(lht,{value:B.value??"",onChange:K=>{B.onChange(K)},onBlur:B.onBlur,height:240,theme:N}):f.jsx(jIe,{html:H,loading:j,error:V,height:240})})}),f.jsx(Hs,{children:f.jsx(fht,{})}),f.jsx(Cn,{})]})})]}),f.jsx(tc,{title:"Sending conditions",children:f.jsx(fn,{control:C.control,name:"reportCondition",render:({field:B})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Define when the report should be sent based on your Data Mart’s execution result",children:"Data Mart Run results"}),f.jsxs($c,{onValueChange:B.onChange,value:B.value,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full max-w-full overflow-hidden",children:f.jsx(Gc,{})})}),f.jsx(Kc,{children:R.map(K=>f.jsx(fo,{value:K.value,children:K.label},K.value))})]}),f.jsx(Hs,{children:f.jsx(ght,{})}),f.jsx(Cn,{})]})})}),f.jsx(tc,{title:"Automate Report Runs",children:f.jsx(Ire,{})})]}),f.jsxs(yC,{children:[f.jsx(rt,{variant:"default",type:"submit",disabled:y,children:e===xr.CREATE?"Create new report":"Save changes to report"}),f.jsx(rt,{variant:"outline",type:"button",onClick:r,disabled:y,children:"Cancel"})]})]})})});BIe.displayName="EmailReportEditForm";function mht({isOpen:n,onClose:e,initialReport:t,mode:i,preSelectedDestination:s}){const[r,o]=x.useState(!1),[a,l]=x.useState(!1),c=x.useCallback(()=>{a?o(!0):e()},[a,e]),d=x.useCallback(()=>{o(!1),l(!1),e()},[e]),u=x.useCallback(g=>{l(g)},[]),h=x.useCallback(()=>{l(!1),e()},[e]);return f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:g=>{g||c()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:(s==null?void 0:s.title)??"Report"}),f.jsx(cC,{children:i===xr.CREATE?"Fill in the details to create a new report":"Update details of an existing report"})]}),f.jsx(AM,{children:f.jsx(BIe,{initialReport:t,mode:i,onDirtyChange:u,onSubmit:h,onCancel:c,preSelectedDestination:s})})]})}),f.jsx(Ma,{open:r,onOpenChange:o,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:d,variant:"destructive"})]})}function _ht({destination:n,isOpen:e,onClose:t,mode:i,initialReport:s}){switch(n.type){case St.GOOGLE_SHEETS:return f.jsx(Xut,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});case St.LOOKER_STUDIO:return f.jsx(nht,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});case St.EMAIL:case St.SLACK:case St.GOOGLE_CHAT:case St.MS_TEAMS:return f.jsx(mht,{isOpen:e,onClose:t,mode:i,preSelectedDestination:n,initialReport:s??void 0});default:return null}}function bht({destination:n,onEditReport:e}){switch(n.type){case St.GOOGLE_SHEETS:return f.jsx(Rut,{destination:n,onEditReport:e});case St.EMAIL:case St.SLACK:case St.GOOGLE_CHAT:case St.MS_TEAMS:return f.jsx(kut,{destinationType:n.type,destination:n,onEditReport:e});case St.LOOKER_STUDIO:return f.jsx(But,{destination:n,onEditReport:e});default:return null}}function VIe(){return f.jsx("div",{className:"flex flex-col gap-4",children:f.jsx("div",{className:"space-y-2 pb-4",children:Array.from({length:3}).map((n,e)=>f.jsx("div",{className:"border-border rounded-lg border p-4",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(bl,{className:"h-4 w-4 rounded-full"}),f.jsx(bl,{className:"h-4 w-40"}),f.jsx(bl,{className:"h-3 w-32"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(bl,{className:"h-6 w-16 rounded-full"}),f.jsx(bl,{className:"h-4 w-4"})]})]})},e))})})}function Qre({enabled:n,intervalMs:e=5e3,onlyWhenVisible:t=!0,onTick:i}){const s=x.useRef(i);s.current=i;const r=x.useRef(null);x.useEffect(()=>{var l;if(!n)return;(l=r.current)==null||l.abort(),r.current=new AbortController;const o=()=>{if(!t||document.visibilityState==="visible"){const c=new AbortController;s.current(c.signal)}};o();const a=window.setInterval(o,e);return()=>{var c;window.clearInterval(a),(c=r.current)==null||c.abort()}},[n,e,t])}function vht({enabled:n=!0,intervalMs:e=5e3}={}){const{dataMart:t}=Zu(),{fetchReportsByDataMartId:i}=rg(),s=t==null?void 0:t.id;x.useEffect(()=>{s&&i(s)},[s,i]),Qre({enabled:!!s&&n,intervalMs:e,onTick:()=>{s&&i(s,{silent:!0})}})}function Cht(){const{dataMart:n}=Zu(),{dataDestinations:e,isLoading:t}=NJe();return vht({enabled:!0,intervalMs:5e3}),n?f.jsx("div",{className:"flex flex-col gap-4",children:t?f.jsx(VIe,{}):e.length===0?f.jsx(Vut,{}):e.map(i=>f.jsx(Uut,{destination:i,dataMartStatus:n.status},i.id))}):null}function wht(){return f.jsx(AM,{children:f.jsx(ODe,{children:f.jsx(Cht,{})})})}function l_e(){return f.jsxs(c1,{children:[f.jsx(fp,{children:f.jsx(hp,{icon:SHe,tooltip:"Description of the Data Mart",children:"Description"})}),f.jsx(gp,{children:f.jsx(ert,{})}),f.jsx(E_,{})]})}function yht(){const{dataMart:n}=og(),[e,t]=x.useState(!1),i=x.useCallback(()=>{t(!0)},[]),s=x.useCallback(()=>{t(!1)},[]);return f.jsxs(c1,{children:[f.jsxs(fp,{children:[f.jsx(hp,{icon:oxe,tooltip:"Time triggers allow you to schedule Data Mart runs at specific times",children:"Time triggers"}),f.jsx($M,{children:f.jsxs(rt,{variant:"outline",onClick:i,"aria-label":"Add new trigger",children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"Add Trigger"]})})]}),f.jsx(gp,{children:f.jsx(HD,{children:f.jsx(elt,{children:n&&f.jsxs(f.Fragment,{children:[f.jsx(Vlt,{dataMartId:n.id}),f.jsx(Tre,{isOpen:e,onClose:s,dataMartId:n.id})]})})})}),f.jsx(E_,{})]})}const Sht={list:[],listLoadingStatus:an.IDLE,activeInsight:null,activeInsightLoadingStatus:an.IDLE,executionStatus:an.IDLE,executionTriggerId:null,error:null};var Vi=(n=>(n.FETCH_INSIGHTS_START="FETCH_INSIGHTS_START",n.FETCH_INSIGHTS_SUCCESS="FETCH_INSIGHTS_SUCCESS",n.FETCH_INSIGHTS_ERROR="FETCH_INSIGHTS_ERROR",n.GET_INSIGHT_START="GET_INSIGHT_START",n.GET_INSIGHT_SUCCESS="GET_INSIGHT_SUCCESS",n.GET_INSIGHT_ERROR="GET_INSIGHT_ERROR",n.CREATE_INSIGHT_START="CREATE_INSIGHT_START",n.CREATE_INSIGHT_SUCCESS="CREATE_INSIGHT_SUCCESS",n.CREATE_INSIGHT_ERROR="CREATE_INSIGHT_ERROR",n.UPDATE_INSIGHT_START="UPDATE_INSIGHT_START",n.UPDATE_INSIGHT_SUCCESS="UPDATE_INSIGHT_SUCCESS",n.UPDATE_INSIGHT_ERROR="UPDATE_INSIGHT_ERROR",n.DELETE_INSIGHT_START="DELETE_INSIGHT_START",n.DELETE_INSIGHT_SUCCESS="DELETE_INSIGHT_SUCCESS",n.DELETE_INSIGHT_ERROR="DELETE_INSIGHT_ERROR",n.RUN_INSIGHT_START="RUN_INSIGHT_START",n.RUN_INSIGHT_START_ERROR="RUN_INSIGHT_START_ERROR",n.RUN_INSIGHT_STARTED="RUN_INSIGHT_STARTED",n.RUN_INSIGHT_SUCCESS="RUN_INSIGHT_SUCCESS",n.RUN_INSIGHT_ERROR="RUN_INSIGHT_ERROR",n.CLEAR_ERROR="CLEAR_ERROR",n))(Vi||{});class xht extends hC{constructor(){super("/data-marts")}async getInsights(e){return this.get(`/${e}/insights`)}async getInsightById(e,t){return await this.get(`/${e}/insights/${t}`)}async createInsight(e,t){return this.post(`/${e}/insights`,t)}async updateInsight(e,t,i){return this.put(`/${e}/insights/${t}`,i)}async updateInsightTitle(e,t,i){return this.put(`/${e}/insights/${t}/title`,i)}async deleteInsight(e,t){return this.delete(`/${e}/insights/${t}`)}async startInsightExecution(e,t){return this.post(`/${e}/insights/${t}/run-triggers`,{})}async checkInsightExecutionStatus(e,t,i,s){return this.get(`/${e}/insights/${i}/run-triggers/${t}/status`,null,s)}async getInsightRunTriggers(e,t,i){return this.get(`/${e}/insights/${t}/run-triggers/`,null,i)}}const Tm=new xht,cI=n=>({id:n.id,title:n.title,template:n.template??null,output:n.output??null,outputUpdatedAt:n.outputUpdatedAt?new Date(n.outputUpdatedAt):null,lastRun:n.lastManualDataMartRun?{status:n.lastManualDataMartRun.status,id:n.lastManualDataMartRun.id}:null,createdById:n.createdById,createdAt:new Date(n.createdAt),modifiedAt:new Date(n.modifiedAt)}),Lht=n=>n.data.map(cI),Eht=n=>({title:n.title,template:n.template??null}),Dht=n=>({title:n.title,template:n.template??null}),WIe=x.createContext(void 0);function zIe(){const n=x.useContext(WIe);if(!n)throw new Error("useInsightsContext must be used within InsightsProvider");return n}function Jre(){const{state:n,dispatch:e}=zIe(),{dataMart:t}=og();if(!t)throw new Error("useInsights must be used within a DataMart context");const i=x.useCallback(async()=>{e({type:Vi.FETCH_INSIGHTS_START});try{const g=await Tm.getInsights(t.id),m=Lht(g);e({type:Vi.FETCH_INSIGHTS_SUCCESS,payload:m})}catch(g){throw e({type:Vi.FETCH_INSIGHTS_ERROR,payload:ys(g)}),g}},[t.id,e]),s=x.useCallback(async g=>{e({type:Vi.GET_INSIGHT_START});try{const m=await Tm.getInsightById(t.id,g),b=cI(m);return e({type:Vi.GET_INSIGHT_SUCCESS,payload:b}),b}catch(m){throw e({type:Vi.GET_INSIGHT_ERROR,payload:ys(m)}),m}},[t.id,e]),r=x.useCallback(async g=>{e({type:Vi.CREATE_INSIGHT_START});try{const m=Eht(g),b=await Tm.createInsight(t.id,m),v=cI(b);return e({type:Vi.CREATE_INSIGHT_SUCCESS,payload:v}),Vt({event:"insight_created",category:"Insights",action:"Create",label:v.id}),Rn.success("Insight created"),v}catch(m){return e({type:Vi.CREATE_INSIGHT_ERROR,payload:ys(m)}),null}},[t.id,e]),o=x.useCallback(async(g,m)=>{e({type:Vi.UPDATE_INSIGHT_START});try{const b=Dht(m),v=await Tm.updateInsight(t.id,g,b),C=cI(v);return e({type:Vi.UPDATE_INSIGHT_SUCCESS,payload:C}),Vt({event:"insight_updated",category:"Insights",action:"Update",label:C.id}),Rn.success("Insight updated"),C}catch(b){return e({type:Vi.UPDATE_INSIGHT_ERROR,payload:ys(b)}),null}},[t.id,e]),a=x.useCallback(async g=>{e({type:Vi.DELETE_INSIGHT_START});try{await Tm.deleteInsight(t.id,g),e({type:Vi.DELETE_INSIGHT_SUCCESS,payload:g}),Vt({event:"insight_deleted",category:"Insights",action:"Delete",label:g}),Rn.success("Insight deleted")}catch(m){throw e({type:Vi.DELETE_INSIGHT_ERROR,payload:ys(m)}),m}},[t.id,e]),l=x.useCallback(async(g,m)=>{e({type:Vi.UPDATE_INSIGHT_START});try{const b=await Tm.updateInsightTitle(t.id,g,{title:m}),v=cI(b),C=n.list.find(L=>L.id===g)??n.activeInsight,y=C?{...v,template:C.template}:v;return e({type:Vi.UPDATE_INSIGHT_SUCCESS,payload:y}),Vt({event:"insight_title_updated",category:"Insights",action:"Update title",label:y.id}),Rn.success("Title updated"),y}catch(b){return e({type:Vi.UPDATE_INSIGHT_ERROR,payload:ys(b)}),null}},[t.id,e,n.activeInsight,n.list]),c=x.useCallback(async g=>{e({type:Vi.RUN_INSIGHT_START});try{const m=await Tm.startInsightExecution(t.id,g);e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:m.triggerId}})}catch(m){e({type:Vi.RUN_INSIGHT_ERROR,payload:ys(m)})}},[e,t.id]),d=x.useCallback(()=>{e({type:Vi.RUN_INSIGHT_SUCCESS,payload:{triggerId:""}})},[e]),u=x.useCallback(g=>{e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:g}})},[e]),h=x.useCallback(async()=>{const g=n.activeInsight;if(!(!g||!t.id)&&!n.executionTriggerId&&!(!g.lastRun||JJe(g.lastRun.status)))try{const b=(await Tm.getInsightRunTriggers(t.id,g.id,{skipLoadingIndicator:!0})).data.sort((v,C)=>new Date(C.modifiedAt).getTime()-new Date(v.modifiedAt).getTime()).find(v=>!eet(v.status));b!=null&&b.id&&(e({type:Vi.RUN_INSIGHT_START}),e({type:Vi.RUN_INSIGHT_STARTED,payload:{triggerId:b.id}}))}catch(m){e({type:Vi.RUN_INSIGHT_ERROR,payload:ys(m)})}},[n.activeInsight,n.executionTriggerId,t.id,e]);return{insights:n.list,activeInsight:n.activeInsight,listLoading:n.listLoadingStatus===an.LOADING,insightLoading:n.activeInsightLoadingStatus===an.LOADING,isRunning:n.executionStatus===an.LOADING,triggerId:n.executionTriggerId,error:n.error,fetchInsights:i,getInsight:s,createInsight:r,updateInsight:o,updateInsightTitle:l,deleteInsight:a,runInsight:c,setTriggerId:u,resetTriggerId:d,ensureActiveRunPolling:h}}function Rht(){const{state:n}=zIe(),e=x.useMemo(()=>n.list,[n.list]),t=x.useMemo(()=>n.listLoadingStatus===an.LOADING,[n.listLoadingStatus]),i=x.useMemo(()=>n.listLoadingStatus===an.LOADED||n.listLoadingStatus===an.ERROR,[n.listLoadingStatus]),s=x.useMemo(()=>n.error,[n.error]),r=x.useMemo(()=>e.length>0,[e.length]);return{insights:e,isLoading:t,isLoaded:i,error:s,hasInsights:r}}function Nht(n,e){var t,i;switch(e.type){case Vi.FETCH_INSIGHTS_START:return{...n,listLoadingStatus:an.LOADING,error:null};case Vi.GET_INSIGHT_START:return{...n,activeInsightLoadingStatus:an.LOADING,error:null};case Vi.CREATE_INSIGHT_START:return{...n,activeInsightLoadingStatus:an.LOADING,error:null};case Vi.UPDATE_INSIGHT_START:return{...n,error:null};case Vi.DELETE_INSIGHT_START:return{...n,listLoadingStatus:an.LOADING,error:null};case Vi.FETCH_INSIGHTS_SUCCESS:return{...n,list:e.payload,listLoadingStatus:an.LOADED,error:null};case Vi.GET_INSIGHT_SUCCESS:return{...n,activeInsight:e.payload,activeInsightLoadingStatus:an.LOADED,error:null};case Vi.CREATE_INSIGHT_SUCCESS:return{...n,list:[...n.list,e.payload],listLoadingStatus:an.LOADED,activeInsightLoadingStatus:an.LOADED,error:null};case Vi.UPDATE_INSIGHT_SUCCESS:return{...n,list:n.list.map(s=>s.id===e.payload.id?e.payload:s),activeInsight:((t=n.activeInsight)==null?void 0:t.id)===e.payload.id?e.payload:n.activeInsight,listLoadingStatus:an.LOADED,error:null};case Vi.DELETE_INSIGHT_SUCCESS:return{...n,list:n.list.filter(s=>s.id!==e.payload),activeInsight:((i=n.activeInsight)==null?void 0:i.id)===e.payload?null:n.activeInsight,listLoadingStatus:an.LOADED,error:null};case Vi.FETCH_INSIGHTS_ERROR:return{...n,listLoadingStatus:an.ERROR,error:e.payload};case Vi.GET_INSIGHT_ERROR:return{...n,activeInsightLoadingStatus:an.ERROR,error:e.payload};case Vi.CREATE_INSIGHT_ERROR:return{...n,listLoadingStatus:an.ERROR,activeInsightLoadingStatus:an.ERROR,error:e.payload};case Vi.UPDATE_INSIGHT_ERROR:case Vi.DELETE_INSIGHT_ERROR:return{...n,listLoadingStatus:an.ERROR,error:e.payload};case Vi.RUN_INSIGHT_START:return{...n,executionStatus:an.LOADING,error:null};case Vi.RUN_INSIGHT_STARTED:return{...n,executionTriggerId:e.payload.triggerId,error:null};case Vi.RUN_INSIGHT_SUCCESS:return{...n,executionStatus:an.LOADED,executionTriggerId:null,error:null};case Vi.CLEAR_ERROR:return{...n,error:null};default:return n}}function UIe({children:n,initialState:e}){const[t,i]=x.useReducer(Nht,e??Sht);return f.jsx(WIe.Provider,{value:{state:t,dispatch:i},children:n})}function Tht(){return f.jsx(UIe,{children:f.jsx(Tne,{})})}function Iht({status:n}){switch(n){case $r.RUNNING:return f.jsx(Ya,{variant:"secondary",className:"text-primary bg-primary/10",children:"Running"});case $r.SUCCESS:return f.jsx(Ya,{variant:"secondary",className:"bg-green-50 text-green-600 dark:bg-green-950 dark:text-green-400",children:"Success"});case $r.FAILED:return f.jsx(Ya,{variant:"secondary",className:"bg-red-50 text-red-600 dark:bg-red-950 dark:text-red-400",children:"Failed"});case $r.CANCELLED:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Cancelled"});case $r.INTERRUPTED:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Interrupted"});case $r.PENDING:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Pending"});default:return f.jsx(Ya,{variant:"secondary",className:"bg-gray-50 text-gray-500 dark:bg-gray-950 dark:text-gray-400",children:"Unknown"})}}var Tc=(n=>(n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.SYSTEM="SYSTEM",n))(Tc||{}),hf=(n=>(n.STRUCTURED="structured",n.RAW="raw",n.CONFIGURATION="configuration",n))(hf||{});const c_e=(n,e,t=!1)=>{var o,a,l,c;const i=n.split(`
|
|
742
742
|
`).filter(d=>d.trim()!=="");if(i.length>=3){const d=i[0],u=i[1],h=i.slice(2).join(`
|
|
743
743
|
`);if(d.includes("T")&&d.includes("Z")){const g=h$(h);return{id:`log-${e.toString()}`,timestamp:Xx(d),level:t?Tc.ERROR:Tc.INFO,message:g.message,metadata:{at:(o=g.metadata)!=null&&o.at?Xx(g.metadata.at):Xx(d),type:((a=g.metadata)==null?void 0:a.type)??(u!=="unknown"?u:null)}}}}const s=/^\[(.*?)\]\s*\[(.*?)\]\s*(.*)$/.exec(n);if(s){const d=h$(s[3]);return{id:`log-${e.toString()}`,timestamp:Xx(s[1]),level:t?Tc.ERROR:s[2],message:d.message,metadata:(l=d.metadata)!=null&&l.at?{...d.metadata,at:Xx(d.metadata.at)}:d.metadata}}const r=h$(n);return{id:`log-${e.toString()}`,timestamp:"N/A",level:t?Tc.ERROR:Tc.INFO,message:r.message,metadata:(c=r.metadata)!=null&&c.at?{...r.metadata,at:Xx(r.metadata.at)}:r.metadata}},h$=n=>{try{const e=JSON.parse(n);if(typeof e=="object"){const t={},i={...e};"type"in i&&(t.type=i.type,delete i.type),"at"in i&&(t.at=i.at,delete i.at);const s=Object.keys(i);if(s.length===1){const r=s[0],o=i[r];return{message:typeof o=="string"?o:JSON.stringify(o),metadata:Object.keys(t).length>0?t:void 0}}return{message:JSON.stringify(i,null,2),metadata:Object.keys(t).length>0?t:void 0}}}catch{}return{message:n}},$Ie=n=>{var e;return(e=n.metadata)!=null&&e.type?n.metadata.type:n.level},kht=(n,e)=>{var r,o;let t="",i="";switch(n.type){case Kl.CONNECTOR:t=e??"",i="connector";break;case Kl.LOOKER_STUDIO:t="Looker Studio data fetching",i="report";break;case Kl.GOOGLE_SHEETS_EXPORT:case Kl.EMAIL:case Kl.SLACK:case Kl.MS_TEAMS:case Kl.GOOGLE_CHAT:t=((r=n.reportDefinition)==null?void 0:r.title)??"",i="report";break;case Kl.INSIGHT:t=((o=n.insightDefinition)==null?void 0:o.title)??"",i="insight";break}return[Sit(`${n.triggerType} ${i} run`.trim()),t]},Aht=n=>{const e=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download=`datamart-run-${n.id.slice(0,8)}-logs.json`,i.click(),URL.revokeObjectURL(t)},Mht=n=>{const e=n.startedAt??n.createdAt;return zH(e.toISOString())},Oht=n=>{const e=d_e(n.startedAt),t=d_e(n.finishedAt);let i="";return n.startedAt&&n.finishedAt&&(i=wit(n.startedAt,n.finishedAt)),{startedAt:e,finishedAt:t,duration:i}},d_e=n=>n?zH(n.toISOString()):"N/A";function Pht({logViewType:n,setLogViewType:e,searchTerm:t,setSearchTerm:i,run:s,cancelDataMartRun:r,dataMartId:o}){const a=d=>{d.stopPropagation()},l=async d=>{if(d.stopPropagation(),o)try{await r(o,s.id),Sr.success("Data mart run cancelled successfully")}catch(u){Sr.error(u instanceof Error?u.message:"Failed to cancel data mart run")}},c=d=>`px-3 py-2 text-sm font-medium transition-colors rounded-none ${d?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-accent"}`;return f.jsxs("div",{className:"bg-background border-border flex items-center justify-between rounded-lg border p-3",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsxs("div",{className:"bg-background border-border flex items-center rounded-lg border",children:[f.jsx("button",{onClick:d=>{d.stopPropagation(),e(hf.STRUCTURED)},className:`${c(n===hf.STRUCTURED)} rounded-l-lg`,children:"Structured"}),f.jsx("button",{onClick:d=>{d.stopPropagation(),e(hf.RAW)},className:`${c(n===hf.RAW)} rounded-none`,children:"Raw"}),f.jsx("button",{onClick:d=>{d.stopPropagation(),e(hf.CONFIGURATION)},className:`${c(n===hf.CONFIGURATION)} rounded-r-lg`,children:"Configuration"})]}),n!==hf.CONFIGURATION&&f.jsxs("div",{className:"relative",children:[f.jsx(FS,{className:"text-muted-foreground absolute top-2.5 left-2 h-4 w-4"}),f.jsx(vn,{type:"text",placeholder:"Search logs...",value:t,onChange:d=>{i(d.target.value)},onClick:a,className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus:ring-ring rounded-md border py-2 pr-4 pl-8 text-xs focus:border-transparent focus:ring-2 focus:outline-none"})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[s.status===$r.RUNNING&&f.jsxs(rt,{variant:"destructive",size:"sm",onClick:d=>void l(d),children:[f.jsx(ID,{className:"h-4 w-4"}),"Cancel"]}),f.jsxs(rt,{variant:"outline",size:"sm",onClick:d=>{d.stopPropagation(),Aht(s)},className:"flex items-center gap-2",children:[f.jsx(eBe,{className:"h-4 w-4"}),"JSON"]})]})]})}function Fht(n){switch(n){case Tc.INFO:return f.jsx(sc,{className:"h-3 w-3 text-blue-500"});case Tc.WARNING:return f.jsx(oH,{className:"h-3 w-3 text-yellow-500"});case Tc.ERROR:return f.jsx(rF,{className:"h-3 w-3 text-red-500"});case Tc.SYSTEM:return f.jsx(fM,{className:"text-muted-foreground h-3 w-3"});default:return f.jsx(sc,{className:"text-muted-foreground h-3 w-3"})}}function jht(n){switch(n){case Tc.INFO:return"text-blue-600 dark:text-blue-400";case Tc.WARNING:return"text-yellow-600 dark:text-yellow-400";case Tc.ERROR:return"text-red-600 dark:text-red-400";case Tc.SYSTEM:return"text-muted-foreground";default:return"text-muted-foreground"}}function Hht(n){return n===bDe.SCHEDULED?f.jsx(THe,{size:18}):f.jsx(sxe,{size:18})}function Bht({logs:n}){const e=i=>{i.stopPropagation()},t=i=>{var s;return(s=i.metadata)!=null&&s.at?i.metadata.at:i.timestamp};return n.length===0?f.jsx("div",{className:"bg-background border-border rounded-lg border",children:f.jsx("div",{className:"text-muted-foreground p-8 text-center text-sm",children:"No logs found"})}):f.jsx("div",{className:"bg-background border-border rounded-lg border",children:f.jsx("div",{className:"max-h-96 overflow-y-auto",children:n.map((i,s)=>f.jsxs("div",{className:`border-border hover:bg-accent/30 flex items-start gap-3 border-b p-3 text-xs ${s===n.length-1?"border-b-0":""}`,onClick:e,children:[f.jsx("div",{className:"text-muted-foreground flex-shrink-0 font-mono text-xs",children:t(i)}),f.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center gap-2",children:[Fht(i.level),f.jsx("span",{className:`text-xs font-medium ${jht(i.level)}`,children:$Ie(i)})]}),f.jsx("div",{className:`min-w-0 flex-1 text-xs break-words ${i.level===Tc.ERROR?"text-red-700 dark:text-red-300":"text-foreground"}`,children:i.message.includes(`
|
|
744
744
|
`)?f.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap",children:i.message}):f.jsx("span",{children:i.message})})]},i.id))})})}var zF=(n=>(n.ERROR="error",n.DEFAULT="default",n))(zF||{});function UF({text:n,section:e,variant:t="default",copiedSection:i,onCopy:s,iconOnly:r=!1}){const o=t==="error",a=i===e,l="flex items-center gap-1 px-2 py-1 text-xs rounded transition-colors cursor-pointer",c=o?"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/40":"text-foreground hover:bg-muted";return f.jsx("button",{onClick:d=>{s(n,e),d.stopPropagation()},className:`${l} ${c}`,title:`Copy ${e} to clipboard`,children:r?f.jsx(f.Fragment,{children:a?f.jsx(Wc,{className:"h-3 w-3"}):f.jsx(t2,{className:"h-3 w-3"})}):a?f.jsxs(f.Fragment,{children:[f.jsx(Wc,{className:"h-3 w-3"}),"Copied"]}):f.jsxs(f.Fragment,{children:[f.jsx(t2,{className:"h-3 w-3"}),"Copy"]})})}function eoe(){const[n,e]=x.useState(null),t=async(s,r)=>{try{await navigator.clipboard.writeText(s),e(r),setTimeout(()=>{e(null)},2e3)}catch(o){console.error("Failed to copy text: ",o)}};return{copiedSection:n,copyToClipboard:t,handleCopy:(s,r)=>{t(s,r)}}}function Vht({logs:n,errors:e}){const{copiedSection:t,handleCopy:i}=eoe(),s=r=>{r.stopPropagation()};return f.jsxs("div",{className:"border-border space-y-4 rounded-lg border p-4",onClick:s,children:[e.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[f.jsxs("h4",{className:"flex items-center gap-2 text-sm font-medium text-red-600 dark:text-red-400",children:[f.jsx(fM,{className:"h-4 w-4 text-red-500"}),"Error Output:"]}),f.jsx(UF,{text:e.join(`
|
|
745
745
|
`),section:"errors",variant:zF.ERROR,copiedSection:t,onCopy:i})]}),f.jsx("div",{className:"max-h-96 overflow-y-auto rounded-md bg-red-50 p-3 font-mono text-xs dark:border-red-800 dark:bg-red-950/40",children:e.map((r,o)=>f.jsx("div",{className:"mb-1 leading-relaxed text-red-700 dark:text-red-300",children:r},o))})]}),n.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[f.jsxs("h4",{className:"text-foreground flex items-center gap-2 text-sm font-medium",children:[f.jsx(sc,{className:"h-4 w-4 text-blue-500"}),"Standard Output:"]}),f.jsx(UF,{text:n.join(`
|
|
746
|
-
`),section:"logs",variant:zF.DEFAULT,copiedSection:t,onCopy:i})]}),f.jsx("div",{className:"bg-muted max-h-96 overflow-y-auto rounded-md p-3 font-mono text-xs dark:bg-white/3",children:n.map((r,o)=>f.jsx("div",{className:"mb-1 leading-relaxed",children:r},o))})]})]})}function Wht({definitionRun:n,reportDefinition:e,insightDefinition:t}){const{copiedSection:i,handleCopy:s}=eoe(),r=o=>{o.stopPropagation()};return f.jsx("div",{className:"border-border rounded-lg border",onClick:r,children:n!=null?f.jsxs("div",{className:"p-4",children:[f.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[f.jsx("h4",{className:"text-foreground text-sm font-medium",children:"Configuration:"}),f.jsx(UF,{text:JSON.stringify(n,null,2),section:"configuration",variant:zF.DEFAULT,copiedSection:i,onCopy:s})]}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(n,null,2)}),e&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{className:"text-foreground mt-3 mb-3 text-sm font-medium",children:"Report definition:"}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(e,null,2)})]}),t&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{className:"text-foreground mt-3 mb-3 text-sm font-medium",children:"Insight definition:"}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(t,null,2)})]})]}):f.jsx("div",{className:"text-muted-foreground p-8 text-center",children:"No configuration data available for this run"})})}const mm=18;function zht({type:n,base64Icon:e}){switch(n){case Kl.CONNECTOR:return e?f.jsx(VS,{base64:e,size:mm}):f.jsx(j1,{size:mm});case Kl.GOOGLE_SHEETS_EXPORT:{const t=Nc.getInfo(St.GOOGLE_SHEETS).icon;return f.jsx(t,{size:mm})}case Kl.LOOKER_STUDIO:{const t=Nc.getInfo(St.LOOKER_STUDIO).icon;return f.jsx(t,{size:mm})}case Kl.EMAIL:{const t=Nc.getInfo(St.EMAIL).icon;return f.jsx(t,{size:mm})}case Kl.SLACK:{const t=Nc.getInfo(St.SLACK).icon;return f.jsx(t,{size:mm})}case Kl.MS_TEAMS:{const t=Nc.getInfo(St.MS_TEAMS).icon;return f.jsx(t,{size:mm})}case Kl.GOOGLE_CHAT:{const t=Nc.getInfo(St.GOOGLE_CHAT).icon;return f.jsx(t,{size:mm})}default:return f.jsx(j1,{size:mm})}}function Uht({run:n,isExpanded:e,onToggle:t,logViewType:i,setLogViewType:s,searchTerm:r,setSearchTerm:o,cancelDataMartRun:a,dataMartId:l,dataMartConnectorInfo:c}){const{copiedSection:d,handleCopy:u}=eoe(),h=x.useMemo(()=>{if(n.logs.length===0&&n.errors.length===0)return[];const y=n.logs.map((R,T)=>c_e(R,T)),L=n.errors.map((R,T)=>c_e(R,n.logs.length+T,!0));return[...y,...L].filter(R=>{const T=$Ie(R);return r===""||R.message.toLowerCase().includes(r.toLowerCase())||T.toLowerCase().includes(r.toLowerCase())})},[n.logs,n.errors,r]),g=x.useCallback(()=>i===hf.STRUCTURED?f.jsx(Bht,{logs:h}):i===hf.RAW?f.jsx(Vht,{logs:n.logs,errors:n.errors}):f.jsx(Wht,{definitionRun:n.definitionRun,reportDefinition:n.reportDefinition,insightDefinition:n.insightDefinition}),[i,h,n.logs,n.errors,n.definitionRun,n.reportDefinition,n.insightDefinition]),m=Mht(n),b=Oht(n),[v,C]=kht(n,c==null?void 0:c.displayName);return f.jsxs("div",{className:"dm-card-block",children:[f.jsxs("div",{className:"flex cursor-pointer items-center justify-between",onClick:()=>{t(n.id)},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{children:f.jsx(zht,{type:n.type,base64Icon:c==null?void 0:c.logoBase64})}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{className:"text-foreground align-center mr-12 flex items-center font-mono text-sm font-medium",children:m})}),f.jsx(kn,{children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{children:["Started At: ",b.startedAt]}),f.jsxs("div",{children:["Finished At: ",b.finishedAt]}),b.duration&&f.jsxs("div",{children:["Duration: ",b.duration]})]})})]}),f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[Hht(n.triggerType),f.jsxs("span",{className:"inline-flex items-center",children:[v,n.createdByUser&&f.jsxs(f.Fragment,{children:[" by ",f.jsx(mRe,{userProjection:n.createdByUser})]}),C&&f.jsxs(f.Fragment,{children:[" • ",C]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Iht,{status:n.status}),f.jsx($d,{className:`text-muted-foreground h-4 w-4 transition-transform ${e?"rotate-90":""}`})]})]}),e&&f.jsxs("div",{className:"border-border bg-muted/30 space-y-4 border-t p-4",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsxs("h3",{className:"text-foreground mr-2 font-medium",children:["Run ID: ",n.id]}),f.jsx(UF,{text:n.id,section:"run-id",onCopy:u,copiedSection:d,iconOnly:!0})]}),f.jsx(Pht,{logViewType:i,setLogViewType:s,searchTerm:r,setSearchTerm:o,run:n,cancelDataMartRun:a,dataMartId:l}),g()]})]})}function $ht(){const{dataMart:e,getDataMartRuns:t,loadMoreDataMartRuns:i,cancelDataMartRun:s,runs:r=[],isLoading:o}=Zu(),[a,l]=x.useState(!1),[c,d]=x.useState(!0),[u,h]=x.useState(0),[g,m]=x.useState(null),[b,v]=x.useState(hf.STRUCTURED),[C,y]=x.useState(""),L=x.useCallback(async()=>{if(!(e!=null&&e.id))return;const N=await t(e.id,20,0);h(N.length),d(N.length===20)},[e==null?void 0:e.id,t,20]),E=x.useCallback(async()=>{if(!(e!=null&&e.id)||a)return;l(!0);const N=await i(e.id,u,20);h(I=>I+N.length),d(N.length===20),l(!1)},[e==null?void 0:e.id,i,u,a,20]);x.useEffect(()=>{e!=null&&e.id&&L()},[e==null?void 0:e.id,L]);const R=x.useMemo(()=>(e==null?void 0:e.definitionType)===Yt.CONNECTOR&&e.definition&&"connector"in e.definition?e.definition.connector.info??null:null,[e]),T=N=>{m(g===N?null:N)};return o?f.jsx(VIe,{}):f.jsx("div",{className:"flex flex-col gap-4 pb-4",children:r.length===0?f.jsx("div",{className:"text-muted-foreground py-8 text-center",children:"No runs found for this Data Mart"}):f.jsxs("div",{className:"space-y-2",children:[r.map(N=>f.jsx(Uht,{run:N,isExpanded:g===N.id,onToggle:T,logViewType:b,setLogViewType:v,searchTerm:C,setSearchTerm:y,cancelDataMartRun:s,dataMartId:e==null?void 0:e.id,dataMartConnectorInfo:R},N.id)),c&&f.jsx("div",{className:"flex justify-center pt-4",children:f.jsx(OE,{variant:"outline",size:"sm",onClick:()=>void E(),disabled:a,className:"flex items-center gap-2",children:a?f.jsxs(f.Fragment,{children:[f.jsx(qBe,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):"Load More"})})]})})}const Ght=5e3,qht=20;function Kht(){const{dataMart:n,getDataMartRuns:e}=og();return Qre({enabled:!!(n!=null&&n.id),intervalMs:Ght,onTick:()=>{n!=null&&n.id&&e(n.id,qht,0,{silent:!0})}}),f.jsx("div",{className:"flex flex-col gap-4",children:f.jsxs(c1,{collapsible:!1,name:"run-history",children:[f.jsx(fp,{children:f.jsx(hp,{icon:mBe,tooltip:"View all Data Mart execution runs with detailed logs and errors",children:"Run History"})}),f.jsx(gp,{children:f.jsx($ht,{})})]})})}function Zht(){const n=XTe(),{navigate:e}=hb(),t=i=>{const s=n?`/data-marts/${i.id}/data-setup?preset=${n.key}`:`/data-marts/${i.id}/data-setup`;e(s)};return f.jsx("div",{className:"flex h-full w-full items-center justify-center",children:f.jsx("div",{className:"m-auto w-lg",children:f.jsxs("div",{className:"bg-muted/50 dark:bg-sidebar rounded-xl border-b border-gray-200 p-12 pt-8 dark:border-gray-700/50",children:[f.jsx("h2",{className:"mb-4 text-xl font-medium",children:"Create Data Mart"}),f.jsx(sre,{children:f.jsx(LRe,{children:f.jsx(rst,{initialData:{title:(n==null?void 0:n.datamartTitle)??"New Data Mart"},onSuccess:t})})})]})})})}function GIe({isOpen:n,onClose:e,id:t}){const{getDataStorageById:i,currentDataStorage:s,loading:r,clearCurrentDataStorage:o}=ZH();x.useEffect(()=>(n&&t&&i(t),()=>{n||o()}),[n,t,i,o]);const a=()=>{o(),e()};return f.jsx(Vse,{open:n,onOpenChange:l=>{l||a()},children:f.jsxs(Wse,{children:[f.jsxs(zse,{children:[f.jsx(Use,{children:"Storage Details"}),f.jsx($se,{children:"View detailed information about this storage."})]}),f.jsx("div",{className:"py-4",children:f.jsx(EQe,{dataStorage:s,isLoading:r})})]})})}const Yht=({id:n,onViewDetails:e,onEdit:t,onDelete:i})=>{const[s,r]=x.useState(!1);return f.jsx("div",{className:"text-right",children:f.jsxs(Al,{open:s,onOpenChange:r,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${s?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>e==null?void 0:e(n),children:[f.jsx(QSe,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"View details"})]}),f.jsxs(wn,{onClick:()=>void(t==null?void 0:t(n)),children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>i==null?void 0:i(n),children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]})})},Xht=({onViewDetails:n,onEdit:e,onDelete:t}={})=>[{accessorKey:"title",size:50,header:({column:i})=>f.jsx(La,{column:i,children:"Title"}),cell:({row:i})=>{const s=i.getValue("title");return f.jsx("div",{children:s})}},{accessorKey:"type",size:30,header:({column:i})=>f.jsx(La,{column:i,children:"Type"}),cell:({row:i})=>{const s=i.getValue("type"),{displayName:r,icon:o}=fC.getInfo(s);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),r]})}},{accessorKey:"createdAt",size:20,sortDescFirst:!0,header:({column:i})=>f.jsx(La,{column:i,children:"Created at"}),cell:({row:i})=>{const s=i.getValue("createdAt"),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(s);return f.jsx("div",{className:"text-muted-foreground",children:r})}},{id:"actions",size:80,header:({table:i})=>f.jsx(BR,{table:i}),cell:({row:i})=>f.jsx(Yht,{id:i.original.id,onViewDetails:n,onEdit:e,onDelete:t})}];function Qht({onOpenTypeDialog:n}){return f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(XHe,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Create your first Storage"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"A Storage combines your data warehouse and access credentials — both required to start building Data Marts."}),f.jsxs(rt,{variant:"outline",onClick:n,children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Storage"]})]})}function Jht({columns:n,data:e,onEdit:t,onOpenTypeDialog:i}){var C;const{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:n,storageKeyPrefix:"data-storage-list"}),[l,c]=x.useState([]),[d,u]=x.useState({}),[h,g]=x.useState(!1),[m]=x.useState(null),b=pC({data:e,columns:[...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),onColumnFiltersChange:c,getFilteredRowModel:HR(),onColumnVisibilityChange:a,onRowSelectionChange:u,state:{sorting:s,columnFilters:l,columnVisibility:o,rowSelection:d},enableRowSelection:!0}),v=(y,L)=>{L.target instanceof HTMLElement&&(L.target.closest('[role="checkbox"]')||L.target.closest(".actions-cell")||L.target.closest('[role="menuitem"]'))||t==null||t(y)};return e.length?f.jsxs("div",{children:[m&&f.jsx(GIe,{isOpen:h,onClose:()=>{g(!1)},id:m.id}),f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsx("div",{className:"dm-card-toolbar-left",children:f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(C=b.getColumn("title"))==null?void 0:C.getFilterValue(),onChange:y=>{var L;return(L=b.getColumn("title"))==null?void 0:L.setFilterValue(y.target.value)},className:"dm-card-toolbar-search-input"})]})}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",onClick:()=>{i==null||i()},children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Storage"]})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Storages table",children:[f.jsx(_C,{className:"dm-card-table-header",children:b.getHeaderGroups().map(y=>f.jsx(qr,{className:"dm-card-table-header-row",children:y.headers.map(L=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.getSize())}%`},children:L.isPlaceholder?null:jD(L.column.columnDef.header,L.getContext())},L.id))},y.id))}),f.jsx(bC,{className:"dm-card-table-body",children:b.getRowModel().rows.length?b.getRowModel().rows.map(y=>f.jsx(qr,{"data-state":y.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:L=>{const E=y.original.id;v(E,L)},children:y.getVisibleCells().map(L=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${L.column.id==="actions"?"actions-cell":""} ${L.column.id==="createdAt"?"whitespace-nowrap":""}`,style:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.column.getSize())}%`},children:jD(L.column.columnDef.cell,L.getContext())},L.id))},y.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{b.previousPage()},disabled:!b.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{b.nextPage()},disabled:!b.getCanNextPage(),children:"Next"})]})]})]}):f.jsx("div",{className:"dm-card",children:f.jsx(Qht,{onOpenTypeDialog:i})})}const eft=({initialTypeDialogOpen:n=!1,onTypeDialogClose:e})=>{const[t,i]=x.useState(n),{dataStorages:s,currentDataStorage:r,clearCurrentDataStorage:o,fetchDataStorages:a,getDataStorageById:l,deleteDataStorage:c,createDataStorage:d}=ZH();x.useEffect(()=>{a()},[a]),x.useEffect(()=>{i(n)},[n]);const u=()=>{i(!1),e==null||e()},[h,g]=x.useState(!1),[m,b]=x.useState(!1),[v,C]=x.useState(null),[y,L]=x.useState(!1),[E,R]=x.useState(null),T=async B=>{try{const K=await d(B);u(),K!=null&&K.id&&(await l(K.id),g(!0))}catch(K){console.error("Failed to create storage:",K)}},N=B=>{R(B),L(!0)},I=()=>{L(!1),R(null)},M=async B=>{await l(B),g(!0)},P=B=>{C(B),b(!0)},H=async()=>{if(v)try{await c(v),await a()}catch(B){console.error("Failed to delete storage:",B)}finally{b(!1),C(null)}},j=async()=>{try{g(!1),await a()}catch(B){console.error("Failed to save storage:",B)}},V=()=>{g(!1),o()},W=s.map(B=>({id:B.id,title:B.title,type:B.type,createdAt:B.createdAt,modifiedAt:B.modifiedAt})),U=Xht({onViewDetails:N,onEdit:M,onDelete:P});return f.jsxs("div",{children:[f.jsx(Jht,{columns:U,data:W,onEdit:M,onOpenTypeDialog:()=>{i(!0)}}),f.jsx(GIe,{isOpen:y,onClose:I,id:E??""}),f.jsx(yNe,{isOpen:t,onClose:u,onSelect:T}),f.jsx(ITe,{isOpen:h,onClose:V,dataStorage:r,onSaveSuccess:()=>void j()}),f.jsx(Ma,{open:m,onOpenChange:b,title:"Delete Storage",description:"Are you sure you want to delete this storage? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{H()},onCancel:()=>{C(null)},variant:"destructive"})]})},tft=()=>{const[n,e]=x.useState(!1);return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Storages"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(sre,{children:f.jsx(eft,{initialTypeDialogOpen:n,onTypeDialogClose:()=>{e(!1)}})})})]})};function ift({onOpenTypeDialog:n}){return f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(Mne,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Create your first Destination"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"A Destination combines your reporting tool and access credentials — both needed to deliver data from Data Marts to your reports and dashboards."}),f.jsxs(rt,{variant:"outline",onClick:n,children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Destination"]})]})}function nft({columns:n,data:e,onEdit:t,onOpenTypeDialog:i}){var m;const{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:n,storageKeyPrefix:"data-destination-list"}),[l,c]=x.useState([]),[d,u]=x.useState({}),h=pC({data:e,columns:[...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),onColumnFiltersChange:c,getFilteredRowModel:HR(),onColumnVisibilityChange:a,onRowSelectionChange:u,state:{sorting:s,columnFilters:l,columnVisibility:o,rowSelection:d},enableRowSelection:!0}),g=(b,v)=>{v.target instanceof HTMLElement&&(v.target.closest('[role="checkbox"]')||v.target.closest(".actions-cell")||v.target.closest('[role="menuitem"]'))||t==null||t(b)};return e.length?f.jsx("div",{children:f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsx("div",{className:"dm-card-toolbar-left",children:f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(m=h.getColumn("title"))==null?void 0:m.getFilterValue(),onChange:b=>{var v;return(v=h.getColumn("title"))==null?void 0:v.setFilterValue(b.target.value)},className:"dm-card-toolbar-search-input"})]})}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",onClick:()=>{i==null||i()},children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Destination"]})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Destinations table",children:[f.jsx(_C,{className:"dm-card-table-header",children:h.getHeaderGroups().map(b=>f.jsx(qr,{className:"dm-card-table-header-row",children:b.headers.map(v=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:v.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(v.getSize())}%`},children:v.isPlaceholder?null:jD(v.column.columnDef.header,v.getContext())},v.id))},b.id))}),f.jsx(bC,{className:"dm-card-table-body",children:h.getRowModel().rows.length?h.getRowModel().rows.map(b=>f.jsx(qr,{"data-state":b.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:v=>{const C=b.original.id;g(C,v)},children:b.getVisibleCells().map(v=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${v.column.id==="actions"?"actions-cell":""} ${v.column.id==="createdAt"?"whitespace-nowrap":""}`,style:v.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(v.column.getSize())}%`},children:jD(v.column.columnDef.cell,v.getContext())},v.id))},b.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{h.previousPage()},disabled:!h.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{h.nextPage()},disabled:!h.getCanNextPage(),children:"Next"})]})]})}):f.jsx("div",{className:"dm-card",children:f.jsx(ift,{onOpenTypeDialog:i})})}function toe(n){return"destinationSecretKey"in n}const sft=({id:n,type:e,credentials:t,onEdit:i,onDelete:s,onRotateSecretKey:r})=>{const[o,a]=x.useState(!1),l=()=>{if(t&&toe(t)){const u=Rse(t);navigator.clipboard.writeText(u),Rn.success("JSON Config copied to clipboard")}},c=e===St.LOOKER_STUDIO,d=t&&"destinationSecretKey"in t&&t.destinationSecretKey;return f.jsx(f.Fragment,{children:f.jsx("div",{className:"text-right",children:f.jsxs(Al,{open:o,onOpenChange:a,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${o?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>void(i==null?void 0:i(n)),children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]}),c&&d&&f.jsxs(f.Fragment,{children:[f.jsx(Vd,{}),f.jsxs(wn,{onClick:l,children:[f.jsx(t2,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Copy JSON Config"})]}),f.jsxs(wn,{onClick:()=>{r==null||r(n)},children:[f.jsx(nK,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Rotate Secret Key"})]})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>s==null?void 0:s(n),children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]})})})},rft=({onEdit:n,onDelete:e,onRotateSecretKey:t}={})=>[{accessorKey:"title",size:50,header:({column:i})=>f.jsx(La,{column:i,children:"Title"}),cell:({row:i})=>{const s=i.getValue("title");return f.jsx("div",{className:"overflow-hidden text-ellipsis",children:s})}},{accessorKey:"type",size:30,header:({column:i})=>f.jsx(La,{column:i,children:"Type"}),cell:({row:i})=>{const s=i.getValue("type"),{displayName:r,icon:o}=Nc.getInfo(s);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),r]})}},{accessorKey:"createdAt",size:20,sortDescFirst:!0,header:({column:i})=>f.jsx(La,{column:i,children:"Created at"}),cell:({row:i})=>{const s=i.getValue("createdAt"),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(s);return f.jsx("div",{className:"text-muted-foreground",children:r})}},{id:"actions",size:80,header:({table:i})=>f.jsx(BR,{table:i}),cell:({row:i})=>f.jsx(sft,{id:i.original.id,type:i.original.type,credentials:i.original.credentials,onEdit:n,onDelete:e,onRotateSecretKey:t})}];function oft(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a Service Account JSON key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the JSON key, you'll need to create or use an existing service account in Google Cloud."}),f.jsx("p",{className:"mb-2",children:"Here's what to do:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Go to"," ",f.jsx(ir,{href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"})," ","."]}),f.jsxs("li",{children:["Open ",f.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),f.jsx("li",{children:"Create a new service account or select an existing one."}),f.jsxs("li",{children:["Open the Service Accounts page, go to the ",f.jsx("strong",{children:"Keys"})," tab, click"," ",f.jsx("strong",{children:"Add key"}),", and select ",f.jsx("strong",{children:"Create new key"}),"."]}),f.jsxs("li",{children:["Choose ",f.jsx("strong",{children:"JSON"})," format and click ",f.jsx("strong",{children:"Create"}),"."]}),f.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function aft({form:n}){const[e,t]=x.useState(!1),i=()=>{t(!0),n.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{t(!1),n.resetField("credentials.serviceAccount")},r=n.watch("credentials.serviceAccount"),o=r?xRe(r):null;return f.jsx(fn,{control:n.control,name:"credentials.serviceAccount",render:({field:a})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{tooltip:"Paste a JSON key from a service account that has access to the selected destination provider",children:"Service Account"}),!e&&r&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:i,type:"button",children:"Edit"}),e&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),f.jsx(cn,{children:!e&&o?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(ir,{href:o.url,children:o.email})}),f.jsx(kn,{children:f.jsx("p",{children:"View in Google Cloud Console"})})]}):f.jsx(Hp,{...a,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),f.jsx(Hs,{children:f.jsx(oft,{})}),f.jsx(Cn,{})]})})}function lft(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"json-config-details",children:[f.jsx(is,{children:"What is the JSON Config for Looker Studio?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The JSON Config contains the necessary credentials and configuration for connecting to Looker Studio."}),f.jsxs("ul",{className:"list-inside space-y-2 text-sm",children:[f.jsx("li",{children:"You need to copy this JSON config to use it in the Looker Studio Connector."}),f.jsx("li",{children:"If you need to rotate a previous secret key, you can use the corresponding function in the menu on the destinations list."})]})]})]})})}function cft({form:n}){const e=n.getValues("credentials"),t=x.useMemo(()=>e&&toe(e)?e:{deploymentUrl:"",destinationId:"",destinationSecretKey:""},[e]),i=x.useMemo(()=>Rse(t),[t]);return f.jsx(f.Fragment,{children:t.destinationSecretKey&&f.jsx(fn,{control:n.control,name:"credentials.destinationSecretKey",render:()=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"JSON Config"}),f.jsx(cn,{children:f.jsx(eDe,{value:i,displayOnly:!0,keysToMask:["destinationSecretKey"],className:"bg-muted overflow-auto rounded-md text-sm",showCopyButton:!0})}),f.jsx(Cn,{}),f.jsx(Hs,{children:f.jsx(lft,{})})]})})})}const qIe="credentials.to",dft=/[,;\n]/,uft=", ",KIe="Enter emails separated by comma, semicolon or newline",hft="Emails list";function u_e(n){const e=new Set,t=[];for(const i of n.split(dft)){const s=i.trim();if(!s)continue;const r=s.toLowerCase();e.has(r)||(e.add(r),t.push(s))}return t}function f$(n){return n.join(uft)}function h_e(n,e){n.setValue(qIe,e,{shouldDirty:!0,shouldTouch:!0})}function fft({field:n,form:e}){const t=Array.isArray(n.value)?f$(n.value):"",[i,s]=x.useState(t),[r,o]=x.useState(!1),a=Array.isArray(n.value)?f$(n.value):"";x.useEffect(()=>{r||s(a)},[a,r]);const l=u=>{const h=u.target.value;s(h),h_e(e,u_e(h))},c=()=>{o(!0)},d=u=>{o(!1),n.onBlur();const h=u_e(u.target.value);h_e(e,h),s(f$(h))};return f.jsx(Hp,{name:n.name,ref:n.ref,onFocus:c,onBlur:d,value:i,onChange:l,className:"min-h-[150px] font-mono",rows:8,placeholder:KIe})}function C4({form:n,emailsFieldTitle:e=hft}){return f.jsx(fn,{control:n.control,name:qIe,render:({field:t})=>f.jsxs(tn,{children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsx(Ji,{tooltip:KIe,children:e})}),f.jsx(cn,{children:f.jsx(fft,{field:t,form:n})}),f.jsx(Cn,{})]})})}function gft(){return f.jsxs(ts,{value:"sheets-api-details",children:[f.jsx(is,{children:"How do I enable the Google Sheets API?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send data to Google Sheets, you need to enable the"," ",f.jsx(ir,{href:"https://console.cloud.google.com/apis/library/sheets.googleapis.com",children:"Google Sheets API"})," ","in your Google Cloud project."]}),f.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),f.jsxs("li",{children:["If the API isn't enabled yet, click ",f.jsx("strong",{children:"Enable"}),"."]}),f.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})}function pft(){return f.jsxs(ts,{value:"looker-studio-details",children:[f.jsx(is,{children:"How do I connect to Looker Studio?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send data to Looker Studio, you need to provide a deployment URL that the"," ",f.jsx(ir,{className:"p-0",href:"https://datastudio.google.com/datasources/create?connectorId=AKfycbz6kcYn3qGuG0jVNFjcDnkXvVDiz4hewKdAFjOm-_d4VkKVcBidPjqZO991AvGL3FtM4A",children:"Looker Studio connector"})," ","will use to access your data."]}),f.jsx("p",{className:"mb-2",children:"Make sure the deployment URL is accessible from the internet and properly secured."}),f.jsx(ir,{className:"p-0",href:"https://docs.owox.com/docs/destinations/supported-destinations/looker-studio/?utm_source=owox_data_marts&utm_medium=destination_enity&utm_campaign=tooltip",children:"Learn more"})]})]})}function mft(){return f.jsxs(ts,{value:"odata-details",children:[f.jsx(is,{children:"How do I use OData?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"OData (Open Data Protocol) is an ISO/IEC approved, OASIS standard that defines a set of best practices for building and consuming RESTful APIs."}),f.jsx("p",{className:"mb-2",children:"This feature is coming soon."})]})]})}function _ft(){return f.jsxs(ts,{value:"email-details",children:[f.jsx(is,{children:"How do I start sending Email?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports by email, first configure the ",f.jsx("strong",{children:"Email"})," destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Email block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected addresses as formatted text."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/email/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-email",children:"OWOX documentation"}),"."]})]})]})}function bft(){return f.jsxs(ts,{value:"slack-details",children:[f.jsx(is,{children:"How do I start sending to Slack?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Slack, first configure the ",f.jsx("strong",{children:"Slack"})," destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Slack block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected channel as a message."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/slack/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-slack",children:"OWOX documentation"}),"."]})]})]})}function vft(){return f.jsxs(ts,{value:"msteams-details",children:[f.jsx(is,{children:"How do I start sending to Microsoft Teams?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Microsoft Teams, first configure the ",f.jsx("strong",{children:"Microsoft Teams"})," ","destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Microsoft Teams block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected channel as a message."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/microsoft-teams/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-microsoft-teams",children:"OWOX documentation"}),"."]})]})]})}function Cft(){return f.jsxs(ts,{value:"googlechat-details",children:[f.jsx(is,{children:"How do I start sending to Google Chat?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Google Chat, first configure the ",f.jsx("strong",{children:"Google Chat"})," ","destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Google Chat block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the connected space as chat messages."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/google-chat/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-google-chat",children:"OWOX documentation"}),"."]})]})]})}const wft={[St.GOOGLE_SHEETS]:gft,[St.LOOKER_STUDIO]:pft,[St.ODATA]:mft,[St.EMAIL]:_ft,[St.SLACK]:bft,[St.MS_TEAMS]:vft,[St.GOOGLE_CHAT]:Cft};function yft({destinationType:n}){const e=wft[n];return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsx(e,{})})}function Sft({form:n,initialData:e}){const{flags:t}=EM();return f.jsx(fn,{control:n.control,name:"type",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select the destination to send your data",children:"Destination Type"}),f.jsxs($c,{onValueChange:i.onChange,defaultValue:i.value,disabled:!!e,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a destination type"})})}),f.jsx(Kc,{children:f.jsx(KH,{children:Nc.getAllTypes().map(({type:s,displayName:r,icon:o,status:a})=>{const l=a===uf.COMING_SOON,c=a===uf.CLOUD_ONLY&&xit(t);return f.jsx(f.Fragment,{children:c?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsx(fo,{value:s,disabled:!0,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(o,{size:18}),r,f.jsx(Ya,{variant:"secondary",children:"Cloud & Enterprise"})]})},s)})}),f.jsxs(kn,{side:"left",align:"start",className:"w-[220px]",children:["Available only in"," ",f.jsxs(Vc,{className:"inline-flex items-center gap-1 underline",target:"_blank",to:"https://docs.owox.com/docs/editions/owox-cloud-editions/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=unavailable_select_item_tooltip",children:["Cloud edition",f.jsx(F_,{className:"h-3 w-3"})]})," ","or with"," ",f.jsxs(Vc,{className:"inline-flex items-center gap-1 underline",target:"_blank",to:"https://docs.owox.com/docs/editions/self-managed-editions/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=unavailable_select_item_tooltip",children:["an Enterprise plan",f.jsx(F_,{className:"h-3 w-3"})]}),"."]})]}):f.jsx(fo,{value:s,disabled:l,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(o,{size:18}),r,l&&f.jsx(Ya,{variant:"outline",children:a})]})},s)})})})})]}),f.jsx(Hs,{children:f.jsx(yft,{destinationType:i.value})}),f.jsx(Cn,{})]})})}function xft({initialData:n,onSubmit:e,onCancel:t,onDirtyChange:i}){const s=Bp({resolver:pb(yJe),defaultValues:n??{title:"New Destination",type:St.GOOGLE_SHEETS},mode:"onTouched"}),r=s.watch("type");x.useEffect(()=>{i==null||i(s.formState.isDirty)},[s.formState.isDirty,i]);const o=async a=>{const{dirtyFields:l}=s.formState,c=SRe(a);return l.credentials||delete c.credentials,e(c)};return f.jsx(CC,{...s,children:f.jsxs(gb,{onSubmit:a=>{s.handleSubmit(o)(a)},children:[f.jsxs(wC,{children:[f.jsx(fn,{control:s.control,name:"title",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Name the destination to clarify its purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter title",...a})}),f.jsx(Cn,{})]})}),f.jsx(Sft,{form:s,initialData:n}),r===St.GOOGLE_SHEETS&&f.jsx(aft,{form:s}),r===St.LOOKER_STUDIO&&f.jsx(cft,{form:s}),r===St.EMAIL&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter user emails list"}),r===St.SLACK&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Slack channel emails list"}),r===St.MS_TEAMS&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Microsoft Teams channel emails list"}),r===St.GOOGLE_CHAT&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Google Chat channel emails list"})]}),f.jsxs(yC,{children:[f.jsxs(rt,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!s.formState.isDirty||s.formState.isSubmitting,children:[s.formState.isSubmitting&&f.jsx(NR,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]}),f.jsx(rt,{variant:"outline",type:"button",onClick:t,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Lft({isOpen:n,onClose:e,dataDestination:t,onSaveSuccess:i}){const{updateDataDestination:s,createDataDestination:r}=MM(),[o,a]=x.useState(!1),[l,c]=x.useState(!1),d=x.useCallback(()=>{l?a(!0):e()},[l,e]),u=x.useCallback(()=>{a(!1),c(!1),e()},[e]),h=x.useCallback(b=>{c(b)},[]),g=async b=>{const v=FDe.getMapper(b.type);if(t){const C=v.mapToUpdateRequest(b),y=await s(t.id,C);y&&i(y)}else{const C=v.mapToCreateRequest(b),y=await r(C);y&&i(y)}e()},m=x.useRef(!1);return x.useEffect(()=>{const b=t?"Edit":"Create";n&&!m.current?(Vt({event:"data_destination_config_open",category:"DataDestination",action:b,label:t==null?void 0:t.type}),m.current=!0):!n&&m.current&&(Vt({event:"data_destination_config_close",category:"DataDestination",action:b,label:t==null?void 0:t.type}),m.current=!1)},[n,t]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:b=>{b||d()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:"Configure destination"}),f.jsx(cC,{children:"Customize settings for your destination"})]}),f.jsx(xft,{initialData:t??void 0,onSubmit:g,onCancel:d,onDirtyChange:h})]})}),f.jsx(Ma,{open:o,onOpenChange:a,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:u,variant:"destructive"})]})}const Eft=({isCreateSheetInitiallyOpen:n=!1,onCreateSheetClose:e})=>{const{dataDestinations:t,currentDataDestination:i,clearCurrentDataDestination:s,fetchDataDestinations:r,getDataDestinationById:o,deleteDataDestination:a,rotateSecretKey:l}=MM(),c=x.useCallback(()=>{s(),u(!0),e==null||e()},[s,e]),[d,u]=x.useState(!1),[h,g]=x.useState(!1),[m,b]=x.useState(!1),[v,C]=x.useState(null),[y,L]=x.useState(null);x.useEffect(()=>{r()},[r]),x.useEffect(()=>{n&&c()},[n,c]);const E=async V=>{await o(V),u(!0)},R=V=>{C(V),g(!0)},T=V=>{L(V),b(!0)},N=async()=>{if(y)try{const V=await l(y);if(toe(V.credentials)){Rn.success("New JSON Config copied to clipboard");const W=Rse(V.credentials);navigator.clipboard.writeText(W)}await r()}catch(V){console.error("Failed to rotate secret key:",V)}finally{b(!1),L(null)}},I=async()=>{if(v)try{await a(v),await r()}catch(V){console.error("Failed to delete destination:",V)}finally{g(!1),C(null)}},M=async()=>{try{u(!1),await r()}catch(V){console.error("Failed to save destination:",V)}},P=()=>{u(!1),s()},H=t.map(V=>({id:V.id,title:V.title,type:V.type,createdAt:V.createdAt,modifiedAt:V.modifiedAt,credentials:V.credentials})),j=rft({onEdit:E,onDelete:R,onRotateSecretKey:T});return f.jsxs("div",{children:[f.jsx(nft,{columns:j,data:H,onEdit:E,onDelete:R,onRotateSecretKey:T,onOpenTypeDialog:c}),f.jsx(Lft,{isOpen:d,onClose:P,dataDestination:i,onSaveSuccess:()=>void M()}),f.jsx(Ma,{open:h,onOpenChange:g,title:"Delete Destination",description:"Are you sure you want to delete this destination? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{I()},onCancel:()=>{C(null)},variant:"destructive"}),f.jsx(Ma,{open:m,onOpenChange:b,title:"Rotate Secret Key",description:"Rotating the secret key will invalidate the previous key",confirmLabel:"Rotate Key",cancelLabel:"Cancel",onConfirm:()=>void N(),onCancel:()=>{b(!1)},variant:"destructive",children:f.jsxs("div",{className:"text-sm",children:[f.jsx("p",{className:"mb-2",children:"After rotation, you will need to:"}),f.jsxs("ol",{className:"mb-2 list-decimal pl-5",children:[f.jsx("li",{children:"The new JSON Config will be automatically copied to your clipboard"}),f.jsx("li",{children:"Go to your Looker Studio Connector"}),f.jsx("li",{children:"Update the configuration with the new JSON Config"}),f.jsx("li",{children:"Save the changes to restore access to your data marts"})]}),f.jsx("p",{className:"font-semibold",children:"Are you sure you want to rotate the secret key?"})]})})]})},Dft=()=>{const[n,e]=x.useState(!1);return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Destinations"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(AM,{children:f.jsx(Eft,{isCreateSheetInitiallyOpen:n,onCreateSheetClose:()=>{e(!1)}})})})]})};function l5({className:n,...e}){return f.jsx("div",{"data-slot":"empty",className:Le("flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12",n),...e})}function c5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-header",className:Le("flex max-w-sm flex-col items-center gap-2 text-center",n),...e})}const Rft=RR("flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6"}},defaultVariants:{variant:"default"}});function d5({className:n,variant:e="default",...t}){return f.jsx("div",{"data-slot":"empty-icon","data-variant":e,className:Le(Rft({variant:e,className:n})),...t})}function u5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-title",className:Le("text-lg font-medium tracking-tight",n),...e})}function h5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-description",className:Le("text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",n),...e})}function Nft({className:n,...e}){return f.jsx("div",{"data-slot":"empty-content",className:Le("flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance",n),...e})}const Tft=()=>{const n=PS(),{createInsight:e,insightLoading:t}=Jre(),i=()=>{(async()=>{const s=await e({title:"Untitled insight"});s&&n(s.id)})()};return f.jsxs(l5,{children:[f.jsxs(c5,{children:[f.jsx(d5,{variant:"icon",children:f.jsx(nxe,{})}),f.jsx(u5,{children:"No Insights Yet"}),f.jsx(h5,{children:"You haven't created any insights yet. Get started by creating your first insight."})]}),f.jsx(Nft,{children:f.jsx("div",{className:"flex gap-2",children:f.jsx(rt,{onClick:i,disabled:t,children:"Create Insight"})})}),f.jsx(rt,{variant:"link",asChild:!0,className:"text-muted-foreground",size:"sm",children:f.jsxs("a",{href:"#",children:["Learn More ",f.jsx(_He,{})]})})]})},Ift=({onDelete:n}={})=>[{accessorKey:"title",size:50,header:({column:e})=>f.jsx(La,{column:e,children:"Title"}),cell:({row:e})=>{const t=e.getValue("title");return f.jsx("div",{className:"overflow-hidden text-ellipsis",children:t})},meta:{title:"Title"}},{accessorKey:"lastUpdated",size:50,sortDescFirst:!0,header:({column:e})=>f.jsx(La,{column:e,children:"Last updated"}),cell:({row:e})=>{const t=e.getValue("lastUpdated"),i=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t);return f.jsx("div",{className:"text-muted-foreground",children:i})},meta:{title:"Last updated"}},{id:"actions",size:80,header:({table:e})=>f.jsx(BR,{table:e}),cell:({row:e})=>f.jsx("div",{className:"actions-cell text-right",onClick:t=>{t.stopPropagation()},children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn opacity-0 transition-opacity group-hover:opacity-100","aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:f.jsxs(wn,{className:"text-destructive",onClick:()=>n==null?void 0:n(e.original.id),children:[f.jsx(Wh,{className:"mr-2 h-4 w-4 text-red-600"}),f.jsx("span",{className:"text-red-600",children:"Delete insight"})]})})]})}),meta:{title:"Actions"}}];function kft({items:n,onRowClick:e,onDelete:t}){const i=x.useMemo(()=>Ift({onDelete:t}),[t]),{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:i,storageKeyPrefix:"data-mart-insights",defaultSortingColumn:"lastUpdated"}),l=pC({data:n,columns:i,getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),getFilteredRowModel:HR(),state:{sorting:s,columnVisibility:o},onColumnVisibilityChange:a,enableGlobalFilter:!0,enableColumnResizing:!1}),c=x.useCallback(()=>{l.previousPage()},[l]),d=x.useCallback(()=>{l.nextPage()},[l]);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:"insights-table",className:"dm-card-table",role:"table","aria-label":"Insights",children:[f.jsx(_C,{className:"dm-card-table-header",children:l.getHeaderGroups().map(h=>f.jsx(qr,{className:"dm-card-table-header-row",children:h.headers.map(g=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",scope:"col",style:g.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(g.getSize())}%`},children:g.isPlaceholder?null:typeof g.column.columnDef.header=="function"?g.column.columnDef.header(g.getContext()):g.column.columnDef.header},g.id))},h.id))}),f.jsx(bC,{className:"dm-card-table-body",children:l.getRowModel().rows.length?l.getRowModel().rows.map((h,g)=>f.jsx(qr,{onClick:()=>{e(h.original.id)},className:"dm-card-table-body-row group cursor-pointer",role:"row","aria-rowindex":g+1,children:h.getVisibleCells().map((m,b)=>f.jsx(Rl,{className:`whitespace-normal ${m.column.id==="actions"?"actions-cell":""}`,role:"cell","aria-colindex":b+1,style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},children:typeof m.column.columnDef.cell=="function"?m.column.columnDef.cell(m.getContext()):m.column.columnDef.cell},m.id))},h.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:i.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No insights found."})})})})]})}),f.jsxs("div",{className:"dm-card-pagination",role:"navigation","aria-label":"Table pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:c,disabled:!l.getCanPreviousPage(),"aria-label":"Go to previous page",children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:d,disabled:!l.getCanNextPage(),"aria-label":"Go to next page",children:"Next"})]})]})}function Aft(){const n=PS(),{fetchInsights:e,deleteInsight:t,createInsight:i,insightLoading:s}=Jre(),{insights:r,isLoading:o,error:a,hasInsights:l}=Rht(),[c,d]=x.useState(null);x.useEffect(()=>{e()},[e]);const u=m=>{n(m)},h=()=>{(async()=>{const m=await i({title:"Untitled insight"});m&&n(m.id)})()},g=()=>{(async()=>{if(c)try{await t(c)}finally{d(null)}})()};return f.jsxs(c1,{children:[f.jsxs(fp,{children:[f.jsx(hp,{tooltip:"Manage and review your insights",icon:nxe,children:"Insights"}),f.jsx($M,{children:f.jsxs(rt,{variant:"outline","aria-label":"Add new insight",disabled:s,onClick:h,children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"New insight"]})})]}),f.jsxs(gp,{children:[o&&!l?f.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading insights…"}):a?f.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load insights"}):l?f.jsx(kft,{items:r.map(m=>({id:m.id,title:m.title,lastUpdated:m.modifiedAt})),onRowClick:u,onDelete:m=>{d(m)}}):f.jsx(Tft,{}),f.jsx(Ma,{open:!!c,onOpenChange:m=>{m||d(null)},title:"Delete Insight",description:"Are you sure you want to delete this insight? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:g})]}),f.jsx(E_,{})]})}function Mft(){return f.jsx(UIe,{children:f.jsx(Aft,{})})}const lB=x.createContext(null);lB.displayName="PanelGroupContext";const Eo={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ioe=10,Dy=x.useLayoutEffect,f_e=Qj.useId,Oft=typeof f_e=="function"?f_e:()=>null;let Pft=0;function noe(n=null){const e=Oft(),t=x.useRef(n||e||null);return t.current===null&&(t.current=""+Pft++),n??t.current}function ZIe({children:n,className:e="",collapsedSize:t,collapsible:i,defaultSize:s,forwardedRef:r,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:g,tagName:m="div",...b}){const v=x.useContext(lB);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:C,expandPanel:y,getPanelSize:L,getPanelStyle:E,groupId:R,isPanelCollapsed:T,reevaluatePanelConstraints:N,registerPanel:I,resizePanel:M,unregisterPanel:P}=v,H=noe(o),j=x.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:t,collapsible:i,defaultSize:s,maxSize:a,minSize:l},id:H,idIsFromProps:o!==void 0,order:h});x.useRef({didLogMissingDefaultSizeWarning:!1}),Dy(()=>{const{callbacks:W,constraints:U}=j.current,B={...U};j.current.id=H,j.current.idIsFromProps=o!==void 0,j.current.order=h,W.onCollapse=c,W.onExpand=d,W.onResize=u,U.collapsedSize=t,U.collapsible=i,U.defaultSize=s,U.maxSize=a,U.minSize=l,(B.collapsedSize!==U.collapsedSize||B.collapsible!==U.collapsible||B.maxSize!==U.maxSize||B.minSize!==U.minSize)&&N(j.current,B)}),Dy(()=>{const W=j.current;return I(W),()=>{P(W)}},[h,H,I,P]),x.useImperativeHandle(r,()=>({collapse:()=>{C(j.current)},expand:W=>{y(j.current,W)},getId(){return H},getSize(){return L(j.current)},isCollapsed(){return T(j.current)},isExpanded(){return!T(j.current)},resize:W=>{M(j.current,W)}}),[C,y,L,T,H,M]);const V=E(j.current,s);return x.createElement(m,{...b,children:n,className:e,id:H,style:{...V,...g},[Eo.groupId]:R,[Eo.panel]:"",[Eo.panelCollapsible]:i||void 0,[Eo.panelId]:H,[Eo.panelSize]:parseFloat(""+V.flexGrow).toFixed(1)})}const YIe=x.forwardRef((n,e)=>x.createElement(ZIe,{...n,forwardedRef:e}));ZIe.displayName="Panel";YIe.displayName="forwardRef(Panel)";let oZ=null,f5=-1,xv=null;function Fft(n,e,t){const i=(e&tke)!==0,s=(e&ike)!==0,r=(e&nke)!==0,o=(e&ske)!==0;if(e){if(i)return r?"se-resize":o?"ne-resize":"e-resize";if(s)return r?"sw-resize":o?"nw-resize":"w-resize";if(r)return"s-resize";if(o)return"n-resize"}switch(n){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function jft(){xv!==null&&(document.head.removeChild(xv),oZ=null,xv=null,f5=-1)}function g$(n,e,t){var i,s;const r=Fft(n,e);if(oZ!==r){if(oZ=r,xv===null&&(xv=document.createElement("style"),document.head.appendChild(xv)),f5>=0){var o;(o=xv.sheet)===null||o===void 0||o.removeRule(f5)}f5=(i=(s=xv.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${r} !important;}`))!==null&&i!==void 0?i:-1}}function XIe(n){return n.type==="keydown"}function QIe(n){return n.type.startsWith("pointer")}function JIe(n){return n.type.startsWith("mouse")}function cB(n){if(QIe(n)){if(n.isPrimary)return{x:n.clientX,y:n.clientY}}else if(JIe(n))return{x:n.clientX,y:n.clientY};return{x:1/0,y:1/0}}function Hft(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Bft(n,e,t){return n.x<e.x+e.width&&n.x+n.width>e.x&&n.y<e.y+e.height&&n.y+n.height>e.y}function Vft(n,e){if(n===e)throw new Error("Cannot compare node with itself");const t={a:m_e(n),b:m_e(e)};let i;for(;t.a.at(-1)===t.b.at(-1);)n=t.a.pop(),e=t.b.pop(),i=n;bn(i,"Stacking order can only be calculated for elements with a common ancestor");const s={a:p_e(g_e(t.a)),b:p_e(g_e(t.b))};if(s.a===s.b){const r=i.childNodes,o={a:t.a.at(-1),b:t.b.at(-1)};let a=r.length;for(;a--;){const l=r[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(s.a-s.b)}const Wft=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function zft(n){var e;const t=getComputedStyle((e=eke(n))!==null&&e!==void 0?e:n).display;return t==="flex"||t==="inline-flex"}function Uft(n){const e=getComputedStyle(n);return!!(e.position==="fixed"||e.zIndex!=="auto"&&(e.position!=="static"||zft(n))||+e.opacity<1||"transform"in e&&e.transform!=="none"||"webkitTransform"in e&&e.webkitTransform!=="none"||"mixBlendMode"in e&&e.mixBlendMode!=="normal"||"filter"in e&&e.filter!=="none"||"webkitFilter"in e&&e.webkitFilter!=="none"||"isolation"in e&&e.isolation==="isolate"||Wft.test(e.willChange)||e.webkitOverflowScrolling==="touch")}function g_e(n){let e=n.length;for(;e--;){const t=n[e];if(bn(t,"Missing node"),Uft(t))return t}return null}function p_e(n){return n&&Number(getComputedStyle(n).zIndex)||0}function m_e(n){const e=[];for(;n;)e.push(n),n=eke(n);return e}function eke(n){const{parentNode:e}=n;return e&&e instanceof ShadowRoot?e.host:e}const tke=1,ike=2,nke=4,ske=8,$ft=Hft()==="coarse";let Of=[],HE=!1,Lv=new Map,dB=new Map;const m2=new Set;function Gft(n,e,t,i,s){var r;const{ownerDocument:o}=e,a={direction:t,element:e,hitAreaMargins:i,setResizeHandlerState:s},l=(r=Lv.get(o))!==null&&r!==void 0?r:0;return Lv.set(o,l+1),m2.add(a),$F(),function(){var d;dB.delete(n),m2.delete(a);const u=(d=Lv.get(o))!==null&&d!==void 0?d:1;if(Lv.set(o,u-1),$F(),u===1&&Lv.delete(o),Of.includes(a)){const h=Of.indexOf(a);h>=0&&Of.splice(h,1),uB(),s("up",!0,null)}}}function qft(n){const{target:e}=n,{x:t,y:i}=cB(n);HE=!0,soe({target:e,x:t,y:i}),$F(),Of.length>0&&(GF("down",n),uB(),n.preventDefault(),rke(e)||n.stopImmediatePropagation())}function p$(n){const{x:e,y:t}=cB(n);if(HE&&n.type!=="pointerleave"&&n.buttons===0&&(HE=!1,GF("up",n)),!HE){const{target:i}=n;soe({target:i,x:e,y:t})}GF("move",n),uB(),Of.length>0&&n.preventDefault()}function m$(n){const{target:e}=n,{x:t,y:i}=cB(n);dB.clear(),HE=!1,Of.length>0&&(n.preventDefault(),rke(e)||n.stopImmediatePropagation()),GF("up",n),soe({target:e,x:t,y:i}),uB(),$F()}function rke(n){let e=n;for(;e;){if(e.hasAttribute(Eo.resizeHandle))return!0;e=e.parentElement}return!1}function soe({target:n,x:e,y:t}){Of.splice(0);let i=null;(n instanceof HTMLElement||n instanceof SVGElement)&&(i=n),m2.forEach(s=>{const{element:r,hitAreaMargins:o}=s,a=r.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=a,h=$ft?o.coarse:o.fine;if(e>=c-h&&e<=d+h&&t>=u-h&&t<=l+h){if(i!==null&&document.contains(i)&&r!==i&&!r.contains(i)&&!i.contains(r)&&Vft(i,r)>0){let m=i,b=!1;for(;m&&!m.contains(r);){if(Bft(m.getBoundingClientRect(),a)){b=!0;break}m=m.parentElement}if(b)return}Of.push(s)}})}function _$(n,e){dB.set(n,e)}function uB(){let n=!1,e=!1;Of.forEach(i=>{const{direction:s}=i;s==="horizontal"?n=!0:e=!0});let t=0;dB.forEach(i=>{t|=i}),n&&e?g$("intersection",t):n?g$("horizontal",t):e?g$("vertical",t):jft()}let b$;function $F(){var n;(n=b$)===null||n===void 0||n.abort(),b$=new AbortController;const e={capture:!0,signal:b$.signal};m2.size&&(HE?(Of.length>0&&Lv.forEach((t,i)=>{const{body:s}=i;t>0&&(s.addEventListener("contextmenu",m$,e),s.addEventListener("pointerleave",p$,e),s.addEventListener("pointermove",p$,e))}),Lv.forEach((t,i)=>{const{body:s}=i;s.addEventListener("pointerup",m$,e),s.addEventListener("pointercancel",m$,e)})):Lv.forEach((t,i)=>{const{body:s}=i;t>0&&(s.addEventListener("pointerdown",qft,e),s.addEventListener("pointermove",p$,e))}))}function GF(n,e){m2.forEach(t=>{const{setResizeHandlerState:i}=t,s=Of.includes(t);i(n,s,e)})}function Kft(){const[n,e]=x.useState(0);return x.useCallback(()=>e(t=>t+1),[])}function bn(n,e){if(!n)throw console.error(e),Error(e)}function Q0(n,e,t=ioe){return n.toFixed(t)===e.toFixed(t)?0:n>e?1:-1}function e_(n,e,t=ioe){return Q0(n,e,t)===0}function fu(n,e,t){return Q0(n,e,t)===0}function Zft(n,e,t){if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++){const s=n[i],r=e[i];if(!fu(s,r,t))return!1}return!0}function $L({panelConstraints:n,panelIndex:e,size:t}){const i=n[e];bn(i!=null,`Panel constraints not found for index ${e}`);let{collapsedSize:s=0,collapsible:r,maxSize:o=100,minSize:a=0}=i;if(Q0(t,a)<0)if(r){const l=(s+a)/2;Q0(t,l)<0?t=s:t=a}else t=a;return t=Math.min(o,t),t=parseFloat(t.toFixed(ioe)),t}function dI({delta:n,initialLayout:e,panelConstraints:t,pivotIndices:i,prevLayout:s,trigger:r}){if(fu(n,0))return e;const o=[...e],[a,l]=i;bn(a!=null,"Invalid first pivot index"),bn(l!=null,"Invalid second pivot index");let c=0;if(r==="keyboard"){{const u=n<0?l:a,h=t[u];bn(h,`Panel constraints not found for index ${u}`);const{collapsedSize:g=0,collapsible:m,minSize:b=0}=h;if(m){const v=e[u];if(bn(v!=null,`Previous layout not found for panel index ${u}`),fu(v,g)){const C=b-v;Q0(C,Math.abs(n))>0&&(n=n<0?0-C:C)}}}{const u=n<0?a:l,h=t[u];bn(h,`No panel constraints found for index ${u}`);const{collapsedSize:g=0,collapsible:m,minSize:b=0}=h;if(m){const v=e[u];if(bn(v!=null,`Previous layout not found for panel index ${u}`),fu(v,b)){const C=v-g;Q0(C,Math.abs(n))>0&&(n=n<0?0-C:C)}}}}{const u=n<0?1:-1;let h=n<0?l:a,g=0;for(;;){const b=e[h];bn(b!=null,`Previous layout not found for panel index ${h}`);const C=$L({panelConstraints:t,panelIndex:h,size:100})-b;if(g+=C,h+=u,h<0||h>=t.length)break}const m=Math.min(Math.abs(n),Math.abs(g));n=n<0?0-m:m}{let h=n<0?a:l;for(;h>=0&&h<t.length;){const g=Math.abs(n)-Math.abs(c),m=e[h];bn(m!=null,`Previous layout not found for panel index ${h}`);const b=m-g,v=$L({panelConstraints:t,panelIndex:h,size:b});if(!fu(m,v)&&(c+=m-v,o[h]=v,c.toFixed(3).localeCompare(Math.abs(n).toFixed(3),void 0,{numeric:!0})>=0))break;n<0?h--:h++}}if(Zft(s,o))return s;{const u=n<0?l:a,h=e[u];bn(h!=null,`Previous layout not found for panel index ${u}`);const g=h+c,m=$L({panelConstraints:t,panelIndex:u,size:g});if(o[u]=m,!fu(m,g)){let b=g-m,C=n<0?l:a;for(;C>=0&&C<t.length;){const y=o[C];bn(y!=null,`Previous layout not found for panel index ${C}`);const L=y+b,E=$L({panelConstraints:t,panelIndex:C,size:L});if(fu(y,E)||(b-=E-y,o[C]=E),fu(b,0))break;n>0?C--:C++}}}const d=o.reduce((u,h)=>h+u,0);return fu(d,100)?o:s}function Yft({layout:n,panelsArray:e,pivotIndices:t}){let i=0,s=100,r=0,o=0;const a=t[0];bn(a!=null,"No pivot index found"),e.forEach((u,h)=>{const{constraints:g}=u,{maxSize:m=100,minSize:b=0}=g;h===a?(i=b,s=m):(r+=b,o+=m)});const l=Math.min(s,100-r),c=Math.max(i,100-o),d=n[a];return{valueMax:l,valueMin:c,valueNow:d}}function _2(n,e=document){return Array.from(e.querySelectorAll(`[${Eo.resizeHandleId}][data-panel-group-id="${n}"]`))}function oke(n,e,t=document){const s=_2(n,t).findIndex(r=>r.getAttribute(Eo.resizeHandleId)===e);return s??null}function ake(n,e,t){const i=oke(n,e,t);return i!=null?[i,i+1]:[-1,-1]}function Xft(n){return n instanceof HTMLElement?!0:typeof n=="object"&&n!==null&&"tagName"in n&&"getAttribute"in n}function lke(n,e=document){if(Xft(e)&&e.dataset.panelGroupId==n)return e;const t=e.querySelector(`[data-panel-group][data-panel-group-id="${n}"]`);return t||null}function hB(n,e=document){const t=e.querySelector(`[${Eo.resizeHandleId}="${n}"]`);return t||null}function Qft(n,e,t,i=document){var s,r,o,a;const l=hB(e,i),c=_2(n,i),d=l?c.indexOf(l):-1,u=(s=(r=t[d])===null||r===void 0?void 0:r.id)!==null&&s!==void 0?s:null,h=(o=(a=t[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[u,h]}function Jft({committedValuesRef:n,eagerValuesRef:e,groupId:t,layout:i,panelDataArray:s,panelGroupElement:r,setLayout:o}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Dy(()=>{if(!r)return;const a=_2(t,r);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:d,valueNow:u}=Yft({layout:i,panelsArray:s,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const g=s[l];bn(g,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",g.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",u!=null?""+Math.round(u):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[t,i,s,r]),x.useEffect(()=>{if(!r)return;const a=e.current;bn(a,"Eager values not found");const{panelDataArray:l}=a,c=lke(t,r);bn(c!=null,`No group found for id "${t}"`);const d=_2(t,r);bn(d,`No resize handles found for group id "${t}"`);const u=d.map(h=>{const g=h.getAttribute(Eo.resizeHandleId);bn(g,"Resize handle element has no handle id attribute");const[m,b]=Qft(t,g,l,r);if(m==null||b==null)return()=>{};const v=C=>{if(!C.defaultPrevented)switch(C.key){case"Enter":{C.preventDefault();const y=l.findIndex(L=>L.id===m);if(y>=0){const L=l[y];bn(L,`No panel data found for index ${y}`);const E=i[y],{collapsedSize:R=0,collapsible:T,minSize:N=0}=L.constraints;if(E!=null&&T){const I=dI({delta:fu(E,R)?N-R:R-E,initialLayout:i,panelConstraints:l.map(M=>M.constraints),pivotIndices:ake(t,g,r),prevLayout:i,trigger:"keyboard"});i!==I&&o(I)}}break}}};return h.addEventListener("keydown",v),()=>{h.removeEventListener("keydown",v)}});return()=>{u.forEach(h=>h())}},[r,n,e,t,i,s,o])}function __e(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function cke(n,e){const t=n==="horizontal",{x:i,y:s}=cB(e);return t?i:s}function egt(n,e,t,i,s){const r=t==="horizontal",o=hB(e,s);bn(o,`No resize handle element found for id "${e}"`);const a=o.getAttribute(Eo.groupId);bn(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=i;const c=cke(t,n),d=lke(a,s);bn(d,`No group element found for id "${a}"`);const u=d.getBoundingClientRect(),h=r?u.width:u.height;return(c-l)/h*100}function tgt(n,e,t,i,s,r){if(XIe(n)){const o=t==="horizontal";let a=0;n.shiftKey?a=100:s!=null?a=s:a=10;let l=0;switch(n.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return i==null?0:egt(n,e,t,i,r)}function igt({panelDataArray:n}){const e=Array(n.length),t=n.map(r=>r.constraints);let i=0,s=100;for(let r=0;r<n.length;r++){const o=t[r];bn(o,`Panel constraints not found for index ${r}`);const{defaultSize:a}=o;a!=null&&(i++,e[r]=a,s-=a)}for(let r=0;r<n.length;r++){const o=t[r];bn(o,`Panel constraints not found for index ${r}`);const{defaultSize:a}=o;if(a!=null)continue;const l=n.length-i,c=s/l;i++,e[r]=c,s-=c}return e}function eL(n,e,t){e.forEach((i,s)=>{const r=n[s];bn(r,`Panel data not found for index ${s}`);const{callbacks:o,constraints:a,id:l}=r,{collapsedSize:c=0,collapsible:d}=a,u=t[l];if(u==null||i!==u){t[l]=i;const{onCollapse:h,onExpand:g,onResize:m}=o;m&&m(i,u),d&&(h||g)&&(g&&(u==null||e_(u,c))&&!e_(i,c)&&g(),h&&(u==null||!e_(u,c))&&e_(i,c)&&h())}})}function w4(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t])return!1;return!0}function ngt({defaultSize:n,dragState:e,layout:t,panelData:i,panelIndex:s,precision:r=3}){const o=t[s];let a;return o==null?a=n!=null?n.toFixed(r):"1":i.length===1?a="1":a=o.toFixed(r),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:e!==null?"none":void 0}}function sgt(n,e=10){let t=null;return(...s)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{n(...s)},e)}}function b_e(n){try{if(typeof localStorage<"u")n.getItem=e=>localStorage.getItem(e),n.setItem=(e,t)=>{localStorage.setItem(e,t)};else throw new Error("localStorage not supported in this environment")}catch(e){console.error(e),n.getItem=()=>null,n.setItem=()=>{}}}function dke(n){return`react-resizable-panels:${n}`}function uke(n){return n.map(e=>{const{constraints:t,id:i,idIsFromProps:s,order:r}=e;return s?i:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((e,t)=>e.localeCompare(t)).join(",")}function hke(n,e){try{const t=dke(n),i=e.getItem(t);if(i){const s=JSON.parse(i);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function rgt(n,e,t){var i,s;const r=(i=hke(n,t))!==null&&i!==void 0?i:{},o=uke(e);return(s=r[o])!==null&&s!==void 0?s:null}function ogt(n,e,t,i,s){var r;const o=dke(n),a=uke(e),l=(r=hke(n,s))!==null&&r!==void 0?r:{};l[a]={expandToSizes:Object.fromEntries(t.entries()),layout:i};try{s.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function v_e({layout:n,panelConstraints:e}){const t=[...n],i=t.reduce((r,o)=>r+o,0);if(t.length!==e.length)throw Error(`Invalid ${e.length} panel layout: ${t.map(r=>`${r}%`).join(", ")}`);if(!fu(i,100)&&t.length>0)for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=100/i*o;t[r]=a}let s=0;for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=$L({panelConstraints:e,panelIndex:r,size:o});o!=a&&(s+=o-a,t[r]=a)}if(!fu(s,0))for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=o+s,l=$L({panelConstraints:e,panelIndex:r,size:a});if(o!==l&&(s-=l-o,t[r]=l,fu(s,0)))break}return t}const agt=100,uI={getItem:n=>(b_e(uI),uI.getItem(n)),setItem:(n,e)=>{b_e(uI),uI.setItem(n,e)}},C_e={};function fke({autoSaveId:n=null,children:e,className:t="",direction:i,forwardedRef:s,id:r=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=uI,style:c,tagName:d="div",...u}){const h=noe(r),g=x.useRef(null),[m,b]=x.useState(null),[v,C]=x.useState([]),y=Kft(),L=x.useRef({}),E=x.useRef(new Map),R=x.useRef(0),T=x.useRef({autoSaveId:n,direction:i,dragState:m,id:h,keyboardResizeBy:a,onLayout:o,storage:l}),N=x.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(s,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:ee}=N.current;return ee},setLayout:ee=>{const{onLayout:se}=T.current,{layout:ae,panelDataArray:Se}=N.current,ue=v_e({layout:ee,panelConstraints:Se.map(Re=>Re.constraints)});__e(ae,ue)||(C(ue),N.current.layout=ue,se&&se(ue),eL(Se,ue,L.current))}}),[]),Dy(()=>{T.current.autoSaveId=n,T.current.direction=i,T.current.dragState=m,T.current.id=h,T.current.onLayout=o,T.current.storage=l}),Jft({committedValuesRef:T,eagerValuesRef:N,groupId:h,layout:v,panelDataArray:N.current.panelDataArray,setLayout:C,panelGroupElement:g.current}),x.useEffect(()=>{const{panelDataArray:ee}=N.current;if(n){if(v.length===0||v.length!==ee.length)return;let se=C_e[n];se==null&&(se=sgt(ogt,agt),C_e[n]=se);const ae=[...ee],Se=new Map(E.current);se(n,ae,Se,v,l)}},[n,v,l]),x.useEffect(()=>{});const I=x.useCallback(ee=>{const{onLayout:se}=T.current,{layout:ae,panelDataArray:Se}=N.current;if(ee.constraints.collapsible){const ue=Se.map(dt=>dt.constraints),{collapsedSize:Re=0,panelSize:Ve,pivotIndices:Qe}=JC(Se,ee,ae);if(bn(Ve!=null,`Panel size not found for panel "${ee.id}"`),!e_(Ve,Re)){E.current.set(ee.id,Ve);const yt=AL(Se,ee)===Se.length-1?Ve-Re:Re-Ve,fi=dI({delta:yt,initialLayout:ae,panelConstraints:ue,pivotIndices:Qe,prevLayout:ae,trigger:"imperative-api"});w4(ae,fi)||(C(fi),N.current.layout=fi,se&&se(fi),eL(Se,fi,L.current))}}},[]),M=x.useCallback((ee,se)=>{const{onLayout:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current;if(ee.constraints.collapsible){const Re=ue.map(_i=>_i.constraints),{collapsedSize:Ve=0,panelSize:Qe=0,minSize:dt=0,pivotIndices:yt}=JC(ue,ee,Se),fi=se??dt;if(e_(Qe,Ve)){const _i=E.current.get(ee.id),Sn=_i!=null&&_i>=fi?_i:fi,br=AL(ue,ee)===ue.length-1?Qe-Sn:Sn-Qe,hs=dI({delta:br,initialLayout:Se,panelConstraints:Re,pivotIndices:yt,prevLayout:Se,trigger:"imperative-api"});w4(Se,hs)||(C(hs),N.current.layout=hs,ae&&ae(hs),eL(ue,hs,L.current))}}},[]),P=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{panelSize:Se}=JC(ae,ee,se);return bn(Se!=null,`Panel size not found for panel "${ee.id}"`),Se},[]),H=x.useCallback((ee,se)=>{const{panelDataArray:ae}=N.current,Se=AL(ae,ee);return ngt({defaultSize:se,dragState:m,layout:v,panelData:ae,panelIndex:Se})},[m,v]),j=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{collapsedSize:Se=0,collapsible:ue,panelSize:Re}=JC(ae,ee,se);return bn(Re!=null,`Panel size not found for panel "${ee.id}"`),ue===!0&&e_(Re,Se)},[]),V=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{collapsedSize:Se=0,collapsible:ue,panelSize:Re}=JC(ae,ee,se);return bn(Re!=null,`Panel size not found for panel "${ee.id}"`),!ue||Q0(Re,Se)>0},[]),W=x.useCallback(ee=>{const{panelDataArray:se}=N.current;se.push(ee),se.sort((ae,Se)=>{const ue=ae.order,Re=Se.order;return ue==null&&Re==null?0:ue==null?-1:Re==null?1:ue-Re}),N.current.panelDataArrayChanged=!0,y()},[y]);Dy(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:ee,onLayout:se,storage:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current;let Re=null;if(ee){const Qe=rgt(ee,ue,ae);Qe&&(E.current=new Map(Object.entries(Qe.expandToSizes)),Re=Qe.layout)}Re==null&&(Re=igt({panelDataArray:ue}));const Ve=v_e({layout:Re,panelConstraints:ue.map(Qe=>Qe.constraints)});__e(Se,Ve)||(C(Ve),N.current.layout=Ve,se&&se(Ve),eL(ue,Ve,L.current))}}),Dy(()=>{const ee=N.current;return()=>{ee.layout=[]}},[]);const U=x.useCallback(ee=>{let se=!1;const ae=g.current;return ae&&window.getComputedStyle(ae,null).getPropertyValue("direction")==="rtl"&&(se=!0),function(ue){ue.preventDefault();const Re=g.current;if(!Re)return()=>null;const{direction:Ve,dragState:Qe,id:dt,keyboardResizeBy:yt,onLayout:fi}=T.current,{layout:_i,panelDataArray:Sn}=N.current,{initialLayout:Es}=Qe??{},br=ake(dt,ee,Re);let hs=tgt(ue,ee,Ve,Qe,yt,Re);const Ht=Ve==="horizontal";Ht&&se&&(hs=-hs);const oe=Sn.map(bt=>bt.constraints),Ce=dI({delta:hs,initialLayout:Es??_i,panelConstraints:oe,pivotIndices:br,prevLayout:_i,trigger:XIe(ue)?"keyboard":"mouse-or-touch"}),je=!w4(_i,Ce);(QIe(ue)||JIe(ue))&&R.current!=hs&&(R.current=hs,!je&&hs!==0?Ht?_$(ee,hs<0?tke:ike):_$(ee,hs<0?nke:ske):_$(ee,0)),je&&(C(Ce),N.current.layout=Ce,fi&&fi(Ce),eL(Sn,Ce,L.current))}},[]),B=x.useCallback((ee,se)=>{const{onLayout:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current,Re=ue.map(_i=>_i.constraints),{panelSize:Ve,pivotIndices:Qe}=JC(ue,ee,Se);bn(Ve!=null,`Panel size not found for panel "${ee.id}"`);const yt=AL(ue,ee)===ue.length-1?Ve-se:se-Ve,fi=dI({delta:yt,initialLayout:Se,panelConstraints:Re,pivotIndices:Qe,prevLayout:Se,trigger:"imperative-api"});w4(Se,fi)||(C(fi),N.current.layout=fi,ae&&ae(fi),eL(ue,fi,L.current))},[]),K=x.useCallback((ee,se)=>{const{layout:ae,panelDataArray:Se}=N.current,{collapsedSize:ue=0,collapsible:Re}=se,{collapsedSize:Ve=0,collapsible:Qe,maxSize:dt=100,minSize:yt=0}=ee.constraints,{panelSize:fi}=JC(Se,ee,ae);fi!=null&&(Re&&Qe&&e_(fi,ue)?e_(ue,Ve)||B(ee,Ve):fi<yt?B(ee,yt):fi>dt&&B(ee,dt))},[B]),X=x.useCallback((ee,se)=>{const{direction:ae}=T.current,{layout:Se}=N.current;if(!g.current)return;const ue=hB(ee,g.current);bn(ue,`Drag handle element not found for id "${ee}"`);const Re=cke(ae,se);b({dragHandleId:ee,dragHandleRect:ue.getBoundingClientRect(),initialCursorPosition:Re,initialLayout:Se})},[]),ne=x.useCallback(()=>{b(null)},[]),fe=x.useCallback(ee=>{const{panelDataArray:se}=N.current,ae=AL(se,ee);ae>=0&&(se.splice(ae,1),delete L.current[ee.id],N.current.panelDataArrayChanged=!0,y())},[y]),Z=x.useMemo(()=>({collapsePanel:I,direction:i,dragState:m,expandPanel:M,getPanelSize:P,getPanelStyle:H,groupId:h,isPanelCollapsed:j,isPanelExpanded:V,reevaluatePanelConstraints:K,registerPanel:W,registerResizeHandle:U,resizePanel:B,startDragging:X,stopDragging:ne,unregisterPanel:fe,panelGroupElement:g.current}),[I,m,i,M,P,H,h,j,V,K,W,U,B,X,ne,fe]),Y={display:"flex",flexDirection:i==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(lB.Provider,{value:Z},x.createElement(d,{...u,children:e,className:t,id:r,ref:g,style:{...Y,...c},[Eo.group]:"",[Eo.groupDirection]:i,[Eo.groupId]:h}))}const gke=x.forwardRef((n,e)=>x.createElement(fke,{...n,forwardedRef:e}));fke.displayName="PanelGroup";gke.displayName="forwardRef(PanelGroup)";function AL(n,e){return n.findIndex(t=>t===e||t.id===e.id)}function JC(n,e,t){const i=AL(n,e),r=i===n.length-1?[i-1,i]:[i,i+1],o=t[i];return{...e.constraints,panelSize:o,pivotIndices:r}}function lgt({disabled:n,handleId:e,resizeHandler:t,panelGroupElement:i}){x.useEffect(()=>{if(n||t==null||i==null)return;const s=hB(e,i);if(s==null)return;const r=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),t(o);break}case"F6":{o.preventDefault();const a=s.getAttribute(Eo.groupId);bn(a,`No group element found for id "${a}"`);const l=_2(a,i),c=oke(a,e,i);bn(c!==null,`No resize element found for id "${e}"`);const d=o.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return s.addEventListener("keydown",r),()=>{s.removeEventListener("keydown",r)}},[i,n,e,t])}function pke({children:n=null,className:e="",disabled:t=!1,hitAreaMargins:i,id:s,onBlur:r,onClick:o,onDragging:a,onFocus:l,onPointerDown:c,onPointerUp:d,style:u={},tabIndex:h=0,tagName:g="div",...m}){var b,v;const C=x.useRef(null),y=x.useRef({onClick:o,onDragging:a,onPointerDown:c,onPointerUp:d});x.useEffect(()=>{y.current.onClick=o,y.current.onDragging=a,y.current.onPointerDown=c,y.current.onPointerUp=d});const L=x.useContext(lB);if(L===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:R,registerResizeHandle:T,startDragging:N,stopDragging:I,panelGroupElement:M}=L,P=noe(s),[H,j]=x.useState("inactive"),[V,W]=x.useState(!1),[U,B]=x.useState(null),K=x.useRef({state:H});Dy(()=>{K.current.state=H}),x.useEffect(()=>{if(t)B(null);else{const Z=T(P);B(()=>Z)}},[t,P,T]);const X=(b=i==null?void 0:i.coarse)!==null&&b!==void 0?b:15,ne=(v=i==null?void 0:i.fine)!==null&&v!==void 0?v:5;x.useEffect(()=>{if(t||U==null)return;const Z=C.current;bn(Z,"Element ref not attached");let Y=!1;return Gft(P,Z,E,{coarse:X,fine:ne},(se,ae,Se)=>{if(!ae){j("inactive");return}switch(se){case"down":{j("drag"),Y=!1,bn(Se,'Expected event to be defined for "down" action'),N(P,Se);const{onDragging:ue,onPointerDown:Re}=y.current;ue==null||ue(!0),Re==null||Re();break}case"move":{const{state:ue}=K.current;Y=!0,ue!=="drag"&&j("hover"),bn(Se,'Expected event to be defined for "move" action'),U(Se);break}case"up":{j("hover"),I();const{onClick:ue,onDragging:Re,onPointerUp:Ve}=y.current;Re==null||Re(!1),Ve==null||Ve(),Y||ue==null||ue();break}}})},[X,E,t,ne,T,P,U,N,I]),lgt({disabled:t,handleId:P,resizeHandler:U,panelGroupElement:M});const fe={touchAction:"none",userSelect:"none"};return x.createElement(g,{...m,children:n,className:e,id:s,onBlur:()=>{W(!1),r==null||r()},onFocus:()=>{W(!0),l==null||l()},ref:C,role:"separator",style:{...fe,...u},tabIndex:h,[Eo.groupDirection]:E,[Eo.groupId]:R,[Eo.resizeHandle]:"",[Eo.resizeHandleActive]:H==="drag"?"pointer":V?"keyboard":void 0,[Eo.resizeHandleEnabled]:!t,[Eo.resizeHandleId]:P,[Eo.resizeHandleState]:H})}pke.displayName="PanelResizeHandle";function cgt({className:n,...e}){return f.jsx(gke,{"data-slot":"resizable-panel-group",className:Le("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",n),...e})}function w_e({...n}){return f.jsx(YIe,{"data-slot":"resizable-panel",...n})}function dgt({withHandle:n,className:e,...t}){return f.jsx(pke,{"data-slot":"resizable-handle",className:Le("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",e),...t,children:n&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(JSe,{className:"size-2.5"})})})}function ugt({storageKey:n,left:e,right:t,initialRatio:i=.5,minWidth:s=240,className:r}){const o=x.useMemo(()=>{const h=np.get(n);if(h!==null){const g=Number(h);if(!Number.isNaN(g))return v$(g,.1,.9)}return v$(i,.1,.9)},[n,i]),a=Math.round(o*100),l=100-a,d=Math.min(45,Math.max(5,Math.round(s/1200*100)));function u(h){const g=h[0],m=v$(g/100,.1,.9);np.set(n,m)}return f.jsxs(cgt,{direction:"horizontal",onLayout:u,className:Le("relative flex h-full w-full items-stretch overflow-hidden",r),children:[f.jsx(w_e,{defaultSize:a,minSize:d,className:"overflow-auto",children:e}),f.jsx(dgt,{withHandle:!0}),f.jsx(w_e,{defaultSize:l,minSize:d,className:"overflow-auto",children:t})]})}function v$(n,e,t){return Math.max(e,Math.min(t,n))}const hgt="modulepreload",fgt=function(n){return"/"+n},y_e={},pt=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let o=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};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"));s=o(t.map(c=>{if(c=fgt(c),c in y_e)return;y_e[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":hgt,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};function mke(){return globalThis._VSCODE_NLS_MESSAGES}function roe(){return globalThis._VSCODE_NLS_LANGUAGE}const ggt=roe()==="pseudo"||typeof document<"u"&&document.location&&typeof document.location.hash=="string"&&document.location.hash.indexOf("pseudo=true")>=0;function qF(n,e){let t;return e.length===0?t=n:t=n.replace(/\{(\d+)\}/g,(i,s)=>{const r=s[0],o=e[r];let a=i;return typeof o=="string"?a=o:(typeof o=="number"||typeof o=="boolean"||o===void 0||o===null)&&(a=String(o)),a}),ggt&&(t="["+t.replace(/[aouei]/g,"$&$&")+"]"),t}function S(n,e,...t){return qF(typeof n=="number"?_ke(n,e):e,t)}function _ke(n,e){var i;const t=(i=mke())==null?void 0:i[n];if(typeof t!="string"){if(typeof e=="string")return e;throw new Error(`!!! NLS MISSING: ${n} !!!`)}return t}function ce(n,e,...t){let i;typeof n=="number"?i=_ke(n,e):i=e;const s=qF(i,t);return{value:s,original:e===i?s:qF(e,t)}}function pgt(n,e){const t=n;typeof t.vscodeWindowId!="number"&&Object.defineProperty(t,"vscodeWindowId",{get:()=>e})}const dn=window,f7=class f7{constructor(){this.mapWindowIdToZoomFactor=new Map}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}getWindowId(e){return e.vscodeWindowId}};f7.INSTANCE=new f7;let aZ=f7;function bke(n,e,t){typeof e=="string"&&(e=n.matchMedia(e)),e.addEventListener("change",t)}function lZ(n){return aZ.INSTANCE.getZoomFactor(n)}const qR=navigator.userAgent,lc=qR.indexOf("Firefox")>=0,fB=qR.indexOf("AppleWebKit")>=0,GM=qR.indexOf("Chrome")>=0,J0=!GM&&qR.indexOf("Safari")>=0,vke=!GM&&!J0&&fB;qR.indexOf("Electron/")>=0;const S_e=qR.indexOf("Android")>=0;let C$=!1;if(typeof dn.matchMedia=="function"){const n=dn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=dn.matchMedia("(display-mode: fullscreen)");C$=n.matches,bke(dn,n,({matches:t})=>{C$&&e.matches||(C$=t)})}function ooe(){return globalThis.MonacoEnvironment}class mgt{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?VD.isErrorNoTelemetry(e)?new VD(e.message+`
|
|
746
|
+
`),section:"logs",variant:zF.DEFAULT,copiedSection:t,onCopy:i})]}),f.jsx("div",{className:"bg-muted max-h-96 overflow-y-auto rounded-md p-3 font-mono text-xs dark:bg-white/3",children:n.map((r,o)=>f.jsx("div",{className:"mb-1 leading-relaxed",children:r},o))})]})]})}function Wht({definitionRun:n,reportDefinition:e,insightDefinition:t}){const{copiedSection:i,handleCopy:s}=eoe(),r=o=>{o.stopPropagation()};return f.jsx("div",{className:"border-border rounded-lg border",onClick:r,children:n!=null?f.jsxs("div",{className:"p-4",children:[f.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[f.jsx("h4",{className:"text-foreground text-sm font-medium",children:"Configuration:"}),f.jsx(UF,{text:JSON.stringify(n,null,2),section:"configuration",variant:zF.DEFAULT,copiedSection:i,onCopy:s})]}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(n,null,2)}),e&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{className:"text-foreground mt-3 mb-3 text-sm font-medium",children:"Report definition:"}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(e,null,2)})]}),t&&f.jsxs(f.Fragment,{children:[f.jsx("h4",{className:"text-foreground mt-3 mb-3 text-sm font-medium",children:"Insight definition:"}),f.jsx("pre",{className:"bg-muted text-foreground overflow-x-auto rounded p-3 font-mono text-xs whitespace-pre-wrap dark:bg-white/3",children:JSON.stringify(t,null,2)})]})]}):f.jsx("div",{className:"text-muted-foreground p-8 text-center",children:"No configuration data available for this run"})})}const mm=18;function zht({type:n,base64Icon:e}){switch(n){case Kl.CONNECTOR:return e?f.jsx(VS,{base64:e,size:mm}):f.jsx(j1,{size:mm});case Kl.GOOGLE_SHEETS_EXPORT:{const t=Nc.getInfo(St.GOOGLE_SHEETS).icon;return f.jsx(t,{size:mm})}case Kl.LOOKER_STUDIO:{const t=Nc.getInfo(St.LOOKER_STUDIO).icon;return f.jsx(t,{size:mm})}case Kl.EMAIL:{const t=Nc.getInfo(St.EMAIL).icon;return f.jsx(t,{size:mm})}case Kl.SLACK:{const t=Nc.getInfo(St.SLACK).icon;return f.jsx(t,{size:mm})}case Kl.MS_TEAMS:{const t=Nc.getInfo(St.MS_TEAMS).icon;return f.jsx(t,{size:mm})}case Kl.GOOGLE_CHAT:{const t=Nc.getInfo(St.GOOGLE_CHAT).icon;return f.jsx(t,{size:mm})}default:return f.jsx(j1,{size:mm})}}function Uht({run:n,isExpanded:e,onToggle:t,logViewType:i,setLogViewType:s,searchTerm:r,setSearchTerm:o,cancelDataMartRun:a,dataMartId:l,dataMartConnectorInfo:c}){const{copiedSection:d,handleCopy:u}=eoe(),h=x.useMemo(()=>{if(n.logs.length===0&&n.errors.length===0)return[];const y=n.logs.map((R,T)=>c_e(R,T)),L=n.errors.map((R,T)=>c_e(R,n.logs.length+T,!0));return[...y,...L].filter(R=>{const T=$Ie(R);return r===""||R.message.toLowerCase().includes(r.toLowerCase())||T.toLowerCase().includes(r.toLowerCase())})},[n.logs,n.errors,r]),g=x.useCallback(()=>i===hf.STRUCTURED?f.jsx(Bht,{logs:h}):i===hf.RAW?f.jsx(Vht,{logs:n.logs,errors:n.errors}):f.jsx(Wht,{definitionRun:n.definitionRun,reportDefinition:n.reportDefinition,insightDefinition:n.insightDefinition}),[i,h,n.logs,n.errors,n.definitionRun,n.reportDefinition,n.insightDefinition]),m=Mht(n),b=Oht(n),[v,C]=kht(n,c==null?void 0:c.displayName);return f.jsxs("div",{className:"dm-card-block",children:[f.jsxs("div",{className:"flex cursor-pointer items-center justify-between",onClick:()=>{t(n.id)},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{children:f.jsx(zht,{type:n.type,base64Icon:c==null?void 0:c.logoBase64})}),f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{className:"text-foreground align-center mr-12 flex items-center font-mono text-sm font-medium",children:m})}),f.jsx(kn,{children:f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{children:["Started At: ",b.startedAt]}),f.jsxs("div",{children:["Finished At: ",b.finishedAt]}),b.duration&&f.jsxs("div",{children:["Duration: ",b.duration]})]})})]}),f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[Hht(n.triggerType),f.jsxs("span",{className:"inline-flex items-center",children:[v,n.createdByUser&&f.jsxs(f.Fragment,{children:[" by ",f.jsx(mRe,{userProjection:n.createdByUser})]}),C&&f.jsxs(f.Fragment,{children:[" • ",C]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Iht,{status:n.status}),f.jsx($d,{className:`text-muted-foreground h-4 w-4 transition-transform ${e?"rotate-90":""}`})]})]}),e&&f.jsxs("div",{className:"border-border bg-muted/30 space-y-4 border-t p-4",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsxs("h3",{className:"text-foreground mr-2 font-medium",children:["Run ID: ",n.id]}),f.jsx(UF,{text:n.id,section:"run-id",onCopy:u,copiedSection:d,iconOnly:!0})]}),f.jsx(Pht,{logViewType:i,setLogViewType:s,searchTerm:r,setSearchTerm:o,run:n,cancelDataMartRun:a,dataMartId:l}),g()]})]})}function $ht(){const{dataMart:e,getDataMartRuns:t,loadMoreDataMartRuns:i,cancelDataMartRun:s,runs:r=[],isLoading:o}=Zu(),[a,l]=x.useState(!1),[c,d]=x.useState(!0),[u,h]=x.useState(0),[g,m]=x.useState(null),[b,v]=x.useState(hf.STRUCTURED),[C,y]=x.useState(""),L=x.useCallback(async()=>{if(!(e!=null&&e.id))return;const N=await t(e.id,20,0);h(N.length),d(N.length===20)},[e==null?void 0:e.id,t,20]),E=x.useCallback(async()=>{if(!(e!=null&&e.id)||a)return;l(!0);const N=await i(e.id,u,20);h(I=>I+N.length),d(N.length===20),l(!1)},[e==null?void 0:e.id,i,u,a,20]);x.useEffect(()=>{e!=null&&e.id&&L()},[e==null?void 0:e.id,L]);const R=x.useMemo(()=>(e==null?void 0:e.definitionType)===Yt.CONNECTOR&&e.definition&&"connector"in e.definition?e.definition.connector.info??null:null,[e]),T=N=>{m(g===N?null:N)};return o?f.jsx(VIe,{}):f.jsx("div",{className:"flex flex-col gap-4 pb-4",children:r.length===0?f.jsx("div",{className:"text-muted-foreground py-8 text-center",children:"No runs found for this Data Mart"}):f.jsxs("div",{className:"space-y-2",children:[r.map(N=>f.jsx(Uht,{run:N,isExpanded:g===N.id,onToggle:T,logViewType:b,setLogViewType:v,searchTerm:C,setSearchTerm:y,cancelDataMartRun:s,dataMartId:e==null?void 0:e.id,dataMartConnectorInfo:R},N.id)),c&&f.jsx("div",{className:"flex justify-center pt-4",children:f.jsx(OE,{variant:"outline",size:"sm",onClick:()=>void E(),disabled:a,className:"flex items-center gap-2",children:a?f.jsxs(f.Fragment,{children:[f.jsx(qBe,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):"Load More"})})]})})}const Ght=5e3,qht=20;function Kht(){const{dataMart:n,getDataMartRuns:e}=og();return Qre({enabled:!!(n!=null&&n.id),intervalMs:Ght,onTick:()=>{n!=null&&n.id&&e(n.id,qht,0,{silent:!0})}}),f.jsx("div",{className:"flex flex-col gap-4",children:f.jsxs(c1,{collapsible:!1,name:"run-history",children:[f.jsx(fp,{children:f.jsx(hp,{icon:mBe,tooltip:"View all Data Mart execution runs with detailed logs and errors",children:"Run History"})}),f.jsx(gp,{children:f.jsx($ht,{})})]})})}function Zht(){const n=XTe(),{navigate:e}=hb(),t=i=>{const s=n?`/data-marts/${i.id}/data-setup?preset=${n.key}`:`/data-marts/${i.id}/data-setup`;e(s)};return f.jsx("div",{className:"flex h-full w-full items-center justify-center",children:f.jsx("div",{className:"m-auto w-lg",children:f.jsxs("div",{className:"bg-muted/50 dark:bg-sidebar rounded-xl border-b border-gray-200 p-12 pt-8 dark:border-gray-700/50",children:[f.jsx("h2",{className:"mb-4 text-xl font-medium",children:"Create Data Mart"}),f.jsx(sre,{children:f.jsx(LRe,{children:f.jsx(rst,{initialData:{title:(n==null?void 0:n.datamartTitle)??"New Data Mart"},onSuccess:t})})})]})})})}function GIe({isOpen:n,onClose:e,id:t}){const{getDataStorageById:i,currentDataStorage:s,loading:r,clearCurrentDataStorage:o}=ZH();x.useEffect(()=>(n&&t&&i(t),()=>{n||o()}),[n,t,i,o]);const a=()=>{o(),e()};return f.jsx(Vse,{open:n,onOpenChange:l=>{l||a()},children:f.jsxs(Wse,{children:[f.jsxs(zse,{children:[f.jsx(Use,{children:"Storage Details"}),f.jsx($se,{children:"View detailed information about this storage."})]}),f.jsx("div",{className:"py-4",children:f.jsx(EQe,{dataStorage:s,isLoading:r})})]})})}const Yht=({id:n,onViewDetails:e,onEdit:t,onDelete:i})=>{const[s,r]=x.useState(!1);return f.jsx("div",{className:"text-right",children:f.jsxs(Al,{open:s,onOpenChange:r,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${s?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>e==null?void 0:e(n),children:[f.jsx(QSe,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"View details"})]}),f.jsxs(wn,{onClick:()=>void(t==null?void 0:t(n)),children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>i==null?void 0:i(n),children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]})})},Xht=({onViewDetails:n,onEdit:e,onDelete:t}={})=>[{accessorKey:"title",size:50,header:({column:i})=>f.jsx(La,{column:i,children:"Title"}),cell:({row:i})=>{const s=i.getValue("title");return f.jsx("div",{children:s})}},{accessorKey:"type",size:30,header:({column:i})=>f.jsx(La,{column:i,children:"Type"}),cell:({row:i})=>{const s=i.getValue("type"),{displayName:r,icon:o}=fC.getInfo(s);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),r]})}},{accessorKey:"createdAt",size:20,sortDescFirst:!0,header:({column:i})=>f.jsx(La,{column:i,children:"Created at"}),cell:({row:i})=>{const s=i.getValue("createdAt"),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(s);return f.jsx("div",{className:"text-muted-foreground",children:r})}},{id:"actions",size:80,header:({table:i})=>f.jsx(BR,{table:i}),cell:({row:i})=>f.jsx(Yht,{id:i.original.id,onViewDetails:n,onEdit:e,onDelete:t})}];function Qht({onOpenTypeDialog:n}){return f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(XHe,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Create your first Storage"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"A Storage combines your data warehouse and access credentials — both required to start building Data Marts."}),f.jsxs(rt,{variant:"outline",onClick:n,children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Storage"]})]})}function Jht({columns:n,data:e,onEdit:t,onOpenTypeDialog:i}){var C;const{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:n,storageKeyPrefix:"data-storage-list"}),[l,c]=x.useState([]),[d,u]=x.useState({}),[h,g]=x.useState(!1),[m]=x.useState(null),b=pC({data:e,columns:[...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),onColumnFiltersChange:c,getFilteredRowModel:HR(),onColumnVisibilityChange:a,onRowSelectionChange:u,state:{sorting:s,columnFilters:l,columnVisibility:o,rowSelection:d},enableRowSelection:!0}),v=(y,L)=>{L.target instanceof HTMLElement&&(L.target.closest('[role="checkbox"]')||L.target.closest(".actions-cell")||L.target.closest('[role="menuitem"]'))||t==null||t(y)};return e.length?f.jsxs("div",{children:[m&&f.jsx(GIe,{isOpen:h,onClose:()=>{g(!1)},id:m.id}),f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsx("div",{className:"dm-card-toolbar-left",children:f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(C=b.getColumn("title"))==null?void 0:C.getFilterValue(),onChange:y=>{var L;return(L=b.getColumn("title"))==null?void 0:L.setFilterValue(y.target.value)},className:"dm-card-toolbar-search-input"})]})}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",onClick:()=>{i==null||i()},children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Storage"]})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Storages table",children:[f.jsx(_C,{className:"dm-card-table-header",children:b.getHeaderGroups().map(y=>f.jsx(qr,{className:"dm-card-table-header-row",children:y.headers.map(L=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.getSize())}%`},children:L.isPlaceholder?null:jD(L.column.columnDef.header,L.getContext())},L.id))},y.id))}),f.jsx(bC,{className:"dm-card-table-body",children:b.getRowModel().rows.length?b.getRowModel().rows.map(y=>f.jsx(qr,{"data-state":y.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:L=>{const E=y.original.id;v(E,L)},children:y.getVisibleCells().map(L=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${L.column.id==="actions"?"actions-cell":""} ${L.column.id==="createdAt"?"whitespace-nowrap":""}`,style:L.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(L.column.getSize())}%`},children:jD(L.column.columnDef.cell,L.getContext())},L.id))},y.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{b.previousPage()},disabled:!b.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{b.nextPage()},disabled:!b.getCanNextPage(),children:"Next"})]})]})]}):f.jsx("div",{className:"dm-card",children:f.jsx(Qht,{onOpenTypeDialog:i})})}const eft=({initialTypeDialogOpen:n=!1,onTypeDialogClose:e})=>{const[t,i]=x.useState(n),{dataStorages:s,currentDataStorage:r,clearCurrentDataStorage:o,fetchDataStorages:a,getDataStorageById:l,deleteDataStorage:c,createDataStorage:d}=ZH();x.useEffect(()=>{a()},[a]),x.useEffect(()=>{i(n)},[n]);const u=()=>{i(!1),e==null||e()},[h,g]=x.useState(!1),[m,b]=x.useState(!1),[v,C]=x.useState(null),[y,L]=x.useState(!1),[E,R]=x.useState(null),T=async B=>{try{const K=await d(B);u(),K!=null&&K.id&&(await l(K.id),g(!0))}catch(K){console.error("Failed to create storage:",K)}},N=B=>{R(B),L(!0)},I=()=>{L(!1),R(null)},M=async B=>{await l(B),g(!0)},P=B=>{C(B),b(!0)},H=async()=>{if(v)try{await c(v),await a()}catch(B){console.error("Failed to delete storage:",B)}finally{b(!1),C(null)}},j=async()=>{try{g(!1),await a()}catch(B){console.error("Failed to save storage:",B)}},V=()=>{g(!1),o()},W=s.map(B=>({id:B.id,title:B.title,type:B.type,createdAt:B.createdAt,modifiedAt:B.modifiedAt})),U=Xht({onViewDetails:N,onEdit:M,onDelete:P});return f.jsxs("div",{children:[f.jsx(Jht,{columns:U,data:W,onEdit:M,onOpenTypeDialog:()=>{i(!0)}}),f.jsx(GIe,{isOpen:y,onClose:I,id:E??""}),f.jsx(yNe,{isOpen:t,onClose:u,onSelect:T}),f.jsx(ITe,{isOpen:h,onClose:V,dataStorage:r,onSaveSuccess:()=>void j()}),f.jsx(Ma,{open:m,onOpenChange:b,title:"Delete Storage",description:"Are you sure you want to delete this storage? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{H()},onCancel:()=>{C(null)},variant:"destructive"})]})},tft=()=>{const[n,e]=x.useState(!1);return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Storages"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(sre,{children:f.jsx(eft,{initialTypeDialogOpen:n,onTypeDialogClose:()=>{e(!1)}})})})]})};function ift({onOpenTypeDialog:n}){return f.jsxs("div",{className:"dm-empty-state",children:[f.jsx(Mne,{className:"dm-empty-state-ico",strokeWidth:1}),f.jsx("h2",{className:"dm-empty-state-title",children:"Create your first Destination"}),f.jsx("p",{className:"dm-empty-state-subtitle",children:"A Destination combines your reporting tool and access credentials — both needed to deliver data from Data Marts to your reports and dashboards."}),f.jsxs(rt,{variant:"outline",onClick:n,children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Destination"]})]})}function nft({columns:n,data:e,onEdit:t,onOpenTypeDialog:i}){var m;const{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:n,storageKeyPrefix:"data-destination-list"}),[l,c]=x.useState([]),[d,u]=x.useState({}),h=pC({data:e,columns:[...n],getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),onColumnFiltersChange:c,getFilteredRowModel:HR(),onColumnVisibilityChange:a,onRowSelectionChange:u,state:{sorting:s,columnFilters:l,columnVisibility:o,rowSelection:d},enableRowSelection:!0}),g=(b,v)=>{v.target instanceof HTMLElement&&(v.target.closest('[role="checkbox"]')||v.target.closest(".actions-cell")||v.target.closest('[role="menuitem"]'))||t==null||t(b)};return e.length?f.jsx("div",{children:f.jsxs("div",{className:"dm-card",children:[f.jsxs("div",{className:"dm-card-toolbar",children:[f.jsx("div",{className:"dm-card-toolbar-left",children:f.jsxs("div",{className:"dm-card-toolbar-search",children:[f.jsx(FS,{className:"dm-card-toolbar-search-icon"}),f.jsx(vn,{placeholder:"Search by title",value:(m=h.getColumn("title"))==null?void 0:m.getFilterValue(),onChange:b=>{var v;return(v=h.getColumn("title"))==null?void 0:v.setFilterValue(b.target.value)},className:"dm-card-toolbar-search-input"})]})}),f.jsx("div",{className:"dm-card-toolbar-right",children:f.jsxs(rt,{variant:"outline",className:"dm-card-toolbar-btn-primary",onClick:()=>{i==null||i()},children:[f.jsx(Gd,{className:"h-4 w-4"}),"New Destination"]})})]}),f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{className:"dm-card-table",role:"table","aria-label":"Destinations table",children:[f.jsx(_C,{className:"dm-card-table-header",children:h.getHeaderGroups().map(b=>f.jsx(qr,{className:"dm-card-table-header-row",children:b.headers.map(v=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",style:v.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(v.getSize())}%`},children:v.isPlaceholder?null:jD(v.column.columnDef.header,v.getContext())},v.id))},b.id))}),f.jsx(bC,{className:"dm-card-table-body",children:h.getRowModel().rows.length?h.getRowModel().rows.map(b=>f.jsx(qr,{"data-state":b.getIsSelected()&&"selected",className:"dm-card-table-body-row group",onClick:v=>{const C=b.original.id;g(C,v)},children:b.getVisibleCells().map(v=>f.jsx(Rl,{className:`[&:has([role=checkbox])]pr-0 px-6 whitespace-normal [&>[role=checkbox]]:translate-y-[2px] ${v.column.id==="actions"?"actions-cell":""} ${v.column.id==="createdAt"?"whitespace-nowrap":""}`,style:v.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(v.column.getSize())}%`},children:jD(v.column.columnDef.cell,v.getContext())},v.id))},b.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:n.length+1,className:"dm-card-table-body-row-empty",children:"No results"})})})]})}),f.jsxs("div",{className:"dm-card-pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{h.previousPage()},disabled:!h.getCanPreviousPage(),children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:()=>{h.nextPage()},disabled:!h.getCanNextPage(),children:"Next"})]})]})}):f.jsx("div",{className:"dm-card",children:f.jsx(ift,{onOpenTypeDialog:i})})}function toe(n){return"destinationSecretKey"in n}const sft=({id:n,type:e,credentials:t,onEdit:i,onDelete:s,onRotateSecretKey:r})=>{const[o,a]=x.useState(!1),l=()=>{if(t&&toe(t)){const u=Rse(t);navigator.clipboard.writeText(u),Rn.success("JSON Config copied to clipboard")}},c=e===St.LOOKER_STUDIO,d=t&&"destinationSecretKey"in t&&t.destinationSecretKey;return f.jsx(f.Fragment,{children:f.jsx("div",{className:"text-right",children:f.jsxs(Al,{open:o,onOpenChange:a,children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:`dm-card-table-body-row-actionbtn opacity-0 transition-opacity ${o?"opacity-100":"group-hover:opacity-100"}`,"aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsxs(Ol,{align:"end",children:[f.jsxs(wn,{onClick:()=>void(i==null?void 0:i(n)),children:[f.jsx(TR,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Edit"})]}),c&&d&&f.jsxs(f.Fragment,{children:[f.jsx(Vd,{}),f.jsxs(wn,{onClick:l,children:[f.jsx(t2,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Copy JSON Config"})]}),f.jsxs(wn,{onClick:()=>{r==null||r(n)},children:[f.jsx(nK,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),f.jsx("span",{children:"Rotate Secret Key"})]})]}),f.jsx(Vd,{}),f.jsxs(wn,{onClick:()=>s==null?void 0:s(n),children:[f.jsx(Wh,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),f.jsx("span",{className:"text-red-600",children:"Delete"})]})]})]})})})},rft=({onEdit:n,onDelete:e,onRotateSecretKey:t}={})=>[{accessorKey:"title",size:50,header:({column:i})=>f.jsx(La,{column:i,children:"Title"}),cell:({row:i})=>{const s=i.getValue("title");return f.jsx("div",{className:"overflow-hidden text-ellipsis",children:s})}},{accessorKey:"type",size:30,header:({column:i})=>f.jsx(La,{column:i,children:"Type"}),cell:({row:i})=>{const s=i.getValue("type"),{displayName:r,icon:o}=Nc.getInfo(s);return f.jsxs("div",{className:"text-muted-foreground flex items-center gap-2",children:[f.jsx(o,{size:18}),r]})}},{accessorKey:"createdAt",size:20,sortDescFirst:!0,header:({column:i})=>f.jsx(La,{column:i,children:"Created at"}),cell:({row:i})=>{const s=i.getValue("createdAt"),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(s);return f.jsx("div",{className:"text-muted-foreground",children:r})}},{id:"actions",size:80,header:({table:i})=>f.jsx(BR,{table:i}),cell:({row:i})=>f.jsx(sft,{id:i.original.id,type:i.original.type,credentials:i.original.credentials,onEdit:n,onDelete:e,onRotateSecretKey:t})}];function oft(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"service-account-details",children:[f.jsx(is,{children:"How do I get a Service Account JSON key?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"To get the JSON key, you'll need to create or use an existing service account in Google Cloud."}),f.jsx("p",{className:"mb-2",children:"Here's what to do:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsxs("li",{children:["Go to"," ",f.jsx(ir,{href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"})," ","."]}),f.jsxs("li",{children:["Open ",f.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),f.jsx("li",{children:"Create a new service account or select an existing one."}),f.jsxs("li",{children:["Open the Service Accounts page, go to the ",f.jsx("strong",{children:"Keys"})," tab, click"," ",f.jsx("strong",{children:"Add key"}),", and select ",f.jsx("strong",{children:"Create new key"}),"."]}),f.jsxs("li",{children:["Choose ",f.jsx("strong",{children:"JSON"})," format and click ",f.jsx("strong",{children:"Create"}),"."]}),f.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function aft({form:n}){const[e,t]=x.useState(!1),i=()=>{t(!0),n.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{t(!1),n.resetField("credentials.serviceAccount")},r=n.watch("credentials.serviceAccount"),o=r?xRe(r):null;return f.jsx(fn,{control:n.control,name:"credentials.serviceAccount",render:({field:a})=>f.jsxs(tn,{children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Ji,{tooltip:"Paste a JSON key from a service account that has access to the selected destination provider",children:"Service Account"}),!e&&r&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:i,type:"button",children:"Edit"}),e&&f.jsx(rt,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),f.jsx(cn,{children:!e&&o?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx(ir,{href:o.url,children:o.email})}),f.jsx(kn,{children:f.jsx("p",{children:"View in Google Cloud Console"})})]}):f.jsx(Hp,{...a,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),f.jsx(Hs,{children:f.jsx(oft,{})}),f.jsx(Cn,{})]})})}function lft(){return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsxs(ts,{value:"json-config-details",children:[f.jsx(is,{children:"What is the JSON Config for Looker Studio?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"The JSON Config contains the necessary credentials and configuration for connecting to Looker Studio."}),f.jsxs("ul",{className:"list-inside space-y-2 text-sm",children:[f.jsx("li",{children:"You need to copy this JSON config to use it in the Looker Studio Connector."}),f.jsx("li",{children:"If you need to rotate a previous secret key, you can use the corresponding function in the menu on the destinations list."})]})]})]})})}function cft({form:n}){const e=n.getValues("credentials"),t=x.useMemo(()=>e&&toe(e)?e:{deploymentUrl:"",destinationId:"",destinationSecretKey:""},[e]),i=x.useMemo(()=>Rse(t),[t]);return f.jsx(f.Fragment,{children:t.destinationSecretKey&&f.jsx(fn,{control:n.control,name:"credentials.destinationSecretKey",render:()=>f.jsxs(tn,{children:[f.jsx(Ji,{children:"JSON Config"}),f.jsx(cn,{children:f.jsx(eDe,{value:i,displayOnly:!0,keysToMask:["destinationSecretKey"],className:"bg-muted overflow-auto rounded-md text-sm",showCopyButton:!0})}),f.jsx(Cn,{}),f.jsx(Hs,{children:f.jsx(lft,{})})]})})})}const qIe="credentials.to",dft=/[,;\n]/,uft=", ",KIe="Enter emails separated by comma, semicolon or newline",hft="Emails list";function u_e(n){const e=new Set,t=[];for(const i of n.split(dft)){const s=i.trim();if(!s)continue;const r=s.toLowerCase();e.has(r)||(e.add(r),t.push(s))}return t}function f$(n){return n.join(uft)}function h_e(n,e){n.setValue(qIe,e,{shouldDirty:!0,shouldTouch:!0})}function fft({field:n,form:e}){const t=Array.isArray(n.value)?f$(n.value):"",[i,s]=x.useState(t),[r,o]=x.useState(!1),a=Array.isArray(n.value)?f$(n.value):"";x.useEffect(()=>{r||s(a)},[a,r]);const l=u=>{const h=u.target.value;s(h),h_e(e,u_e(h))},c=()=>{o(!0)},d=u=>{o(!1),n.onBlur();const h=u_e(u.target.value);h_e(e,h),s(f$(h))};return f.jsx(Hp,{name:n.name,ref:n.ref,onFocus:c,onBlur:d,value:i,onChange:l,className:"min-h-[150px] font-mono",rows:8,placeholder:KIe})}function C4({form:n,emailsFieldTitle:e=hft}){return f.jsx(fn,{control:n.control,name:qIe,render:({field:t})=>f.jsxs(tn,{children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsx(Ji,{tooltip:KIe,children:e})}),f.jsx(cn,{children:f.jsx(fft,{field:t,form:n})}),f.jsx(Cn,{})]})})}function gft(){return f.jsxs(ts,{value:"sheets-api-details",children:[f.jsx(is,{children:"How do I enable the Google Sheets API?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send data to Google Sheets, you need to enable the"," ",f.jsx(ir,{href:"https://console.cloud.google.com/apis/library/sheets.googleapis.com",children:"Google Sheets API"})," ","in your Google Cloud project."]}),f.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),f.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[f.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),f.jsxs("li",{children:["If the API isn't enabled yet, click ",f.jsx("strong",{children:"Enable"}),"."]}),f.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})}function pft(){return f.jsxs(ts,{value:"looker-studio-details",children:[f.jsx(is,{children:"How do I connect to Looker Studio?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send data to Looker Studio, you need to provide a deployment URL that the"," ",f.jsx(ir,{className:"p-0",href:"https://datastudio.google.com/datasources/create?connectorId=AKfycbz6kcYn3qGuG0jVNFjcDnkXvVDiz4hewKdAFjOm-_d4VkKVcBidPjqZO991AvGL3FtM4A",children:"Looker Studio connector"})," ","will use to access your data."]}),f.jsx("p",{className:"mb-2",children:"Make sure the deployment URL is accessible from the internet and properly secured."}),f.jsx(ir,{className:"p-0",href:"https://docs.owox.com/docs/destinations/supported-destinations/looker-studio/?utm_source=owox_data_marts&utm_medium=destination_enity&utm_campaign=tooltip",children:"Learn more"})]})]})}function mft(){return f.jsxs(ts,{value:"odata-details",children:[f.jsx(is,{children:"How do I use OData?"}),f.jsxs(ns,{children:[f.jsx("p",{className:"mb-2",children:"OData (Open Data Protocol) is an ISO/IEC approved, OASIS standard that defines a set of best practices for building and consuming RESTful APIs."}),f.jsx("p",{className:"mb-2",children:"This feature is coming soon."})]})]})}function _ft(){return f.jsxs(ts,{value:"email-details",children:[f.jsx(is,{children:"How do I start sending Email?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports by email, first configure the ",f.jsx("strong",{children:"Email"})," destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Email block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected addresses as formatted text."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/email/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-email",children:"OWOX documentation"}),"."]})]})]})}function bft(){return f.jsxs(ts,{value:"slack-details",children:[f.jsx(is,{children:"How do I start sending to Slack?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Slack, first configure the ",f.jsx("strong",{children:"Slack"})," destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Slack block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected channel as a message."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/slack/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-slack",children:"OWOX documentation"}),"."]})]})]})}function vft(){return f.jsxs(ts,{value:"msteams-details",children:[f.jsx(is,{children:"How do I start sending to Microsoft Teams?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Microsoft Teams, first configure the ",f.jsx("strong",{children:"Microsoft Teams"})," ","destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Microsoft Teams block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the selected channel as a message."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/microsoft-teams/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-microsoft-teams",children:"OWOX documentation"}),"."]})]})]})}function Cft(){return f.jsxs(ts,{value:"googlechat-details",children:[f.jsx(is,{children:"How do I start sending to Google Chat?"}),f.jsxs(ns,{children:[f.jsxs("p",{className:"mb-2",children:["To send reports to Google Chat, first configure the ",f.jsx("strong",{children:"Google Chat"})," ","destination in this form (add a title and specify recipient addresses). Then, go to your Data Mart page, open the ",f.jsx("strong",{children:"Destinations"})," tab, and create a report in the Google Chat block."]}),f.jsx("p",{className:"mb-2",children:"In the report settings, add a subject and message, and set the delivery conditions. The generated report will be delivered by OWOX Data Marts to the connected space as chat messages."}),f.jsxs("p",{className:"mb-2",children:["For more details, read the"," ",f.jsx(ir,{className:"underline",href:"https://docs.owox.com/docs/destinations/supported-destinations/google-chat/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=tooltip-google-chat",children:"OWOX documentation"}),"."]})]})]})}const wft={[St.GOOGLE_SHEETS]:gft,[St.LOOKER_STUDIO]:pft,[St.ODATA]:mft,[St.EMAIL]:_ft,[St.SLACK]:bft,[St.MS_TEAMS]:vft,[St.GOOGLE_CHAT]:Cft};function yft({destinationType:n}){const e=wft[n];return f.jsx(sr,{variant:"common",type:"single",collapsible:!0,children:f.jsx(e,{})})}function Sft({form:n,initialData:e}){const{flags:t}=EM();return f.jsx(fn,{control:n.control,name:"type",render:({field:i})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Select the destination to send your data",children:"Destination Type"}),f.jsxs($c,{onValueChange:i.onChange,defaultValue:i.value,disabled:!!e,children:[f.jsx(cn,{children:f.jsx(qc,{className:"w-full",children:f.jsx(Gc,{placeholder:"Select a destination type"})})}),f.jsx(Kc,{children:f.jsx(KH,{children:Nc.getAllTypes().map(({type:s,displayName:r,icon:o,status:a})=>{const l=a===uf.COMING_SOON,c=a===uf.CLOUD_ONLY&&xit(t);return f.jsx(f.Fragment,{children:c?f.jsxs(Tn,{children:[f.jsx(In,{asChild:!0,children:f.jsx("div",{children:f.jsx(fo,{value:s,disabled:!0,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(o,{size:18}),r,f.jsx(Ya,{variant:"secondary",children:"Cloud & Enterprise"})]})},s)})}),f.jsxs(kn,{side:"left",align:"start",className:"w-[220px]",children:["Available only in"," ",f.jsxs(Vc,{className:"inline-flex items-center gap-1 underline",target:"_blank",to:"https://docs.owox.com/docs/editions/owox-cloud-editions/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=unavailable_select_item_tooltip",children:["Cloud edition",f.jsx(F_,{className:"h-3 w-3"})]})," ","or with"," ",f.jsxs(Vc,{className:"inline-flex items-center gap-1 underline",target:"_blank",to:"https://docs.owox.com/docs/editions/self-managed-editions/?utm_source=owox_data_marts&utm_medium=destination_entity&utm_campaign=unavailable_select_item_tooltip",children:["an Enterprise plan",f.jsx(F_,{className:"h-3 w-3"})]}),"."]})]}):f.jsx(fo,{value:s,disabled:l,children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(o,{size:18}),r,l&&f.jsx(Ya,{variant:"outline",children:a})]})},s)})})})})]}),i.value&&f.jsx(Hs,{children:f.jsx(yft,{destinationType:i.value})}),f.jsx(Cn,{})]})})}function xft({initialData:n,onSubmit:e,onCancel:t,onDirtyChange:i}){const s=Bp({resolver:pb(yJe),defaultValues:n??{title:"New Destination",type:St.GOOGLE_SHEETS},mode:"onTouched"}),r=s.watch("type");x.useEffect(()=>{i==null||i(s.formState.isDirty)},[s.formState.isDirty,i]);const o=async a=>{const{dirtyFields:l}=s.formState,c=SRe(a);return l.credentials||delete c.credentials,e(c)};return f.jsx(CC,{...s,children:f.jsxs(gb,{onSubmit:a=>{s.handleSubmit(o)(a)},children:[f.jsxs(wC,{children:[f.jsx(fn,{control:s.control,name:"title",render:({field:a})=>f.jsxs(tn,{children:[f.jsx(Ji,{tooltip:"Name the destination to clarify its purpose",children:"Title"}),f.jsx(cn,{children:f.jsx(vn,{placeholder:"Enter title",...a})}),f.jsx(Cn,{})]})}),f.jsx(Sft,{form:s,initialData:n}),r===St.GOOGLE_SHEETS&&f.jsx(aft,{form:s}),r===St.LOOKER_STUDIO&&f.jsx(cft,{form:s}),r===St.EMAIL&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter user emails list"}),r===St.SLACK&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Slack channel emails list"}),r===St.MS_TEAMS&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Microsoft Teams channel emails list"}),r===St.GOOGLE_CHAT&&f.jsx(C4,{form:s,emailsFieldTitle:"Enter Google Chat channel emails list"})]}),f.jsxs(yC,{children:[f.jsxs(rt,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!s.formState.isDirty||s.formState.isSubmitting,children:[s.formState.isSubmitting&&f.jsx(NR,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]}),f.jsx(rt,{variant:"outline",type:"button",onClick:t,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Lft({isOpen:n,onClose:e,dataDestination:t,onSaveSuccess:i}){const{updateDataDestination:s,createDataDestination:r}=MM(),[o,a]=x.useState(!1),[l,c]=x.useState(!1),d=x.useCallback(()=>{l?a(!0):e()},[l,e]),u=x.useCallback(()=>{a(!1),c(!1),e()},[e]),h=x.useCallback(b=>{c(b)},[]),g=async b=>{const v=FDe.getMapper(b.type);if(t){const C=v.mapToUpdateRequest(b),y=await s(t.id,C);y&&i(y)}else{const C=v.mapToCreateRequest(b),y=await r(C);y&&i(y)}e()},m=x.useRef(!1);return x.useEffect(()=>{const b=t?"Edit":"Create";n&&!m.current?(Vt({event:"data_destination_config_open",category:"DataDestination",action:b,label:t==null?void 0:t.type}),m.current=!0):!n&&m.current&&(Vt({event:"data_destination_config_close",category:"DataDestination",action:b,label:t==null?void 0:t.type}),m.current=!1)},[n,t]),f.jsxs(f.Fragment,{children:[f.jsx(ab,{open:n,onOpenChange:b=>{b||d()},children:f.jsxs(lb,{children:[f.jsxs(cb,{children:[f.jsx(db,{children:"Configure destination"}),f.jsx(cC,{children:"Customize settings for your destination"})]}),f.jsx(xft,{initialData:t??void 0,onSubmit:g,onCancel:d,onDirtyChange:h})]})}),f.jsx(Ma,{open:o,onOpenChange:a,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:u,variant:"destructive"})]})}const Eft=({isCreateSheetInitiallyOpen:n=!1,onCreateSheetClose:e})=>{const{dataDestinations:t,currentDataDestination:i,clearCurrentDataDestination:s,fetchDataDestinations:r,getDataDestinationById:o,deleteDataDestination:a,rotateSecretKey:l}=MM(),c=x.useCallback(()=>{s(),u(!0),e==null||e()},[s,e]),[d,u]=x.useState(!1),[h,g]=x.useState(!1),[m,b]=x.useState(!1),[v,C]=x.useState(null),[y,L]=x.useState(null);x.useEffect(()=>{r()},[r]),x.useEffect(()=>{n&&c()},[n,c]);const E=async V=>{await o(V),u(!0)},R=V=>{C(V),g(!0)},T=V=>{L(V),b(!0)},N=async()=>{if(y)try{const V=await l(y);if(toe(V.credentials)){Rn.success("New JSON Config copied to clipboard");const W=Rse(V.credentials);navigator.clipboard.writeText(W)}await r()}catch(V){console.error("Failed to rotate secret key:",V)}finally{b(!1),L(null)}},I=async()=>{if(v)try{await a(v),await r()}catch(V){console.error("Failed to delete destination:",V)}finally{g(!1),C(null)}},M=async()=>{try{u(!1),await r()}catch(V){console.error("Failed to save destination:",V)}},P=()=>{u(!1),s()},H=t.map(V=>({id:V.id,title:V.title,type:V.type,createdAt:V.createdAt,modifiedAt:V.modifiedAt,credentials:V.credentials})),j=rft({onEdit:E,onDelete:R,onRotateSecretKey:T});return f.jsxs("div",{children:[f.jsx(nft,{columns:j,data:H,onEdit:E,onDelete:R,onRotateSecretKey:T,onOpenTypeDialog:c}),f.jsx(Lft,{isOpen:d,onClose:P,dataDestination:i,onSaveSuccess:()=>void M()}),f.jsx(Ma,{open:h,onOpenChange:g,title:"Delete Destination",description:"Are you sure you want to delete this destination? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{I()},onCancel:()=>{C(null)},variant:"destructive"}),f.jsx(Ma,{open:m,onOpenChange:b,title:"Rotate Secret Key",description:"Rotating the secret key will invalidate the previous key",confirmLabel:"Rotate Key",cancelLabel:"Cancel",onConfirm:()=>void N(),onCancel:()=>{b(!1)},variant:"destructive",children:f.jsxs("div",{className:"text-sm",children:[f.jsx("p",{className:"mb-2",children:"After rotation, you will need to:"}),f.jsxs("ol",{className:"mb-2 list-decimal pl-5",children:[f.jsx("li",{children:"The new JSON Config will be automatically copied to your clipboard"}),f.jsx("li",{children:"Go to your Looker Studio Connector"}),f.jsx("li",{children:"Update the configuration with the new JSON Config"}),f.jsx("li",{children:"Save the changes to restore access to your data marts"})]}),f.jsx("p",{className:"font-semibold",children:"Are you sure you want to rotate the secret key?"})]})})]})},Dft=()=>{const[n,e]=x.useState(!1);return f.jsxs("div",{className:"dm-page",children:[f.jsx("header",{className:"dm-page-header",children:f.jsx("h1",{className:"dm-page-header-title",children:"Destinations"})}),f.jsx("div",{className:"dm-page-content",children:f.jsx(AM,{children:f.jsx(Eft,{isCreateSheetInitiallyOpen:n,onCreateSheetClose:()=>{e(!1)}})})})]})};function l5({className:n,...e}){return f.jsx("div",{"data-slot":"empty",className:Le("flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12",n),...e})}function c5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-header",className:Le("flex max-w-sm flex-col items-center gap-2 text-center",n),...e})}const Rft=RR("flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6"}},defaultVariants:{variant:"default"}});function d5({className:n,variant:e="default",...t}){return f.jsx("div",{"data-slot":"empty-icon","data-variant":e,className:Le(Rft({variant:e,className:n})),...t})}function u5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-title",className:Le("text-lg font-medium tracking-tight",n),...e})}function h5({className:n,...e}){return f.jsx("div",{"data-slot":"empty-description",className:Le("text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",n),...e})}function Nft({className:n,...e}){return f.jsx("div",{"data-slot":"empty-content",className:Le("flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance",n),...e})}const Tft=()=>{const n=PS(),{createInsight:e,insightLoading:t}=Jre(),i=()=>{(async()=>{const s=await e({title:"Untitled insight"});s&&n(s.id)})()};return f.jsxs(l5,{children:[f.jsxs(c5,{children:[f.jsx(d5,{variant:"icon",children:f.jsx(nxe,{})}),f.jsx(u5,{children:"No Insights Yet"}),f.jsx(h5,{children:"You haven't created any insights yet. Get started by creating your first insight."})]}),f.jsx(Nft,{children:f.jsx("div",{className:"flex gap-2",children:f.jsx(rt,{onClick:i,disabled:t,children:"Create Insight"})})}),f.jsx(rt,{variant:"link",asChild:!0,className:"text-muted-foreground",size:"sm",children:f.jsxs("a",{href:"#",children:["Learn More ",f.jsx(_He,{})]})})]})},Ift=({onDelete:n}={})=>[{accessorKey:"title",size:50,header:({column:e})=>f.jsx(La,{column:e,children:"Title"}),cell:({row:e})=>{const t=e.getValue("title");return f.jsx("div",{className:"overflow-hidden text-ellipsis",children:t})},meta:{title:"Title"}},{accessorKey:"lastUpdated",size:50,sortDescFirst:!0,header:({column:e})=>f.jsx(La,{column:e,children:"Last updated"}),cell:({row:e})=>{const t=e.getValue("lastUpdated"),i=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t);return f.jsx("div",{className:"text-muted-foreground",children:i})},meta:{title:"Last updated"}},{id:"actions",size:80,header:({table:e})=>f.jsx(BR,{table:e}),cell:({row:e})=>f.jsx("div",{className:"actions-cell text-right",onClick:t=>{t.stopPropagation()},children:f.jsxs(Al,{children:[f.jsx(Ml,{asChild:!0,children:f.jsx(rt,{variant:"ghost",className:"dm-card-table-body-row-actionbtn opacity-0 transition-opacity group-hover:opacity-100","aria-label":"Open menu",children:f.jsx(ig,{className:"dm-card-table-body-row-actionbtn-icon"})})}),f.jsx(Ol,{align:"end",children:f.jsxs(wn,{className:"text-destructive",onClick:()=>n==null?void 0:n(e.original.id),children:[f.jsx(Wh,{className:"mr-2 h-4 w-4 text-red-600"}),f.jsx("span",{className:"text-red-600",children:"Delete insight"})]})})]})}),meta:{title:"Actions"}}];function kft({items:n,onRowClick:e,onDelete:t}){const i=x.useMemo(()=>Ift({onDelete:t}),[t]),{sorting:s,setSorting:r,columnVisibility:o,setColumnVisibility:a}=zS({columns:i,storageKeyPrefix:"data-mart-insights",defaultSortingColumn:"lastUpdated"}),l=pC({data:n,columns:i,getCoreRowModel:gC(),getPaginationRowModel:OM(),onSortingChange:r,getSortedRowModel:WS(),getFilteredRowModel:HR(),state:{sorting:s,columnVisibility:o},onColumnVisibilityChange:a,enableGlobalFilter:!0,enableColumnResizing:!1}),c=x.useCallback(()=>{l.previousPage()},[l]),d=x.useCallback(()=>{l.nextPage()},[l]);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"dm-card-table-wrap",children:f.jsxs(mC,{id:"insights-table",className:"dm-card-table",role:"table","aria-label":"Insights",children:[f.jsx(_C,{className:"dm-card-table-header",children:l.getHeaderGroups().map(h=>f.jsx(qr,{className:"dm-card-table-header-row",children:h.headers.map(g=>f.jsx(vC,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",scope:"col",style:g.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(g.getSize())}%`},children:g.isPlaceholder?null:typeof g.column.columnDef.header=="function"?g.column.columnDef.header(g.getContext()):g.column.columnDef.header},g.id))},h.id))}),f.jsx(bC,{className:"dm-card-table-body",children:l.getRowModel().rows.length?l.getRowModel().rows.map((h,g)=>f.jsx(qr,{onClick:()=>{e(h.original.id)},className:"dm-card-table-body-row group cursor-pointer",role:"row","aria-rowindex":g+1,children:h.getVisibleCells().map((m,b)=>f.jsx(Rl,{className:`whitespace-normal ${m.column.id==="actions"?"actions-cell":""}`,role:"cell","aria-colindex":b+1,style:m.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(m.column.getSize())}%`},children:typeof m.column.columnDef.cell=="function"?m.column.columnDef.cell(m.getContext()):m.column.columnDef.cell},m.id))},h.id)):f.jsx(qr,{children:f.jsx(Rl,{colSpan:i.length,className:"dm-card-table-body-row-empty",role:"cell",children:f.jsx("span",{role:"status","aria-live":"polite",children:"No insights found."})})})})]})}),f.jsxs("div",{className:"dm-card-pagination",role:"navigation","aria-label":"Table pagination",children:[f.jsx(rt,{variant:"outline",size:"sm",onClick:c,disabled:!l.getCanPreviousPage(),"aria-label":"Go to previous page",children:"Previous"}),f.jsx(rt,{variant:"outline",size:"sm",onClick:d,disabled:!l.getCanNextPage(),"aria-label":"Go to next page",children:"Next"})]})]})}function Aft(){const n=PS(),{fetchInsights:e,deleteInsight:t,createInsight:i,insightLoading:s}=Jre(),{insights:r,isLoading:o,error:a,hasInsights:l}=Rht(),[c,d]=x.useState(null);x.useEffect(()=>{e()},[e]);const u=m=>{n(m)},h=()=>{(async()=>{const m=await i({title:"Untitled insight"});m&&n(m.id)})()},g=()=>{(async()=>{if(c)try{await t(c)}finally{d(null)}})()};return f.jsxs(c1,{children:[f.jsxs(fp,{children:[f.jsx(hp,{tooltip:"Manage and review your insights",icon:nxe,children:"Insights"}),f.jsx($M,{children:f.jsxs(rt,{variant:"outline","aria-label":"Add new insight",disabled:s,onClick:h,children:[f.jsx(Gd,{className:"h-4 w-4","aria-hidden":"true"}),"New insight"]})})]}),f.jsxs(gp,{children:[o&&!l?f.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading insights…"}):a?f.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load insights"}):l?f.jsx(kft,{items:r.map(m=>({id:m.id,title:m.title,lastUpdated:m.modifiedAt})),onRowClick:u,onDelete:m=>{d(m)}}):f.jsx(Tft,{}),f.jsx(Ma,{open:!!c,onOpenChange:m=>{m||d(null)},title:"Delete Insight",description:"Are you sure you want to delete this insight? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:g})]}),f.jsx(E_,{})]})}function Mft(){return f.jsx(UIe,{children:f.jsx(Aft,{})})}const lB=x.createContext(null);lB.displayName="PanelGroupContext";const Eo={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ioe=10,Dy=x.useLayoutEffect,f_e=Qj.useId,Oft=typeof f_e=="function"?f_e:()=>null;let Pft=0;function noe(n=null){const e=Oft(),t=x.useRef(n||e||null);return t.current===null&&(t.current=""+Pft++),n??t.current}function ZIe({children:n,className:e="",collapsedSize:t,collapsible:i,defaultSize:s,forwardedRef:r,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:g,tagName:m="div",...b}){const v=x.useContext(lB);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:C,expandPanel:y,getPanelSize:L,getPanelStyle:E,groupId:R,isPanelCollapsed:T,reevaluatePanelConstraints:N,registerPanel:I,resizePanel:M,unregisterPanel:P}=v,H=noe(o),j=x.useRef({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:t,collapsible:i,defaultSize:s,maxSize:a,minSize:l},id:H,idIsFromProps:o!==void 0,order:h});x.useRef({didLogMissingDefaultSizeWarning:!1}),Dy(()=>{const{callbacks:W,constraints:U}=j.current,B={...U};j.current.id=H,j.current.idIsFromProps=o!==void 0,j.current.order=h,W.onCollapse=c,W.onExpand=d,W.onResize=u,U.collapsedSize=t,U.collapsible=i,U.defaultSize=s,U.maxSize=a,U.minSize=l,(B.collapsedSize!==U.collapsedSize||B.collapsible!==U.collapsible||B.maxSize!==U.maxSize||B.minSize!==U.minSize)&&N(j.current,B)}),Dy(()=>{const W=j.current;return I(W),()=>{P(W)}},[h,H,I,P]),x.useImperativeHandle(r,()=>({collapse:()=>{C(j.current)},expand:W=>{y(j.current,W)},getId(){return H},getSize(){return L(j.current)},isCollapsed(){return T(j.current)},isExpanded(){return!T(j.current)},resize:W=>{M(j.current,W)}}),[C,y,L,T,H,M]);const V=E(j.current,s);return x.createElement(m,{...b,children:n,className:e,id:H,style:{...V,...g},[Eo.groupId]:R,[Eo.panel]:"",[Eo.panelCollapsible]:i||void 0,[Eo.panelId]:H,[Eo.panelSize]:parseFloat(""+V.flexGrow).toFixed(1)})}const YIe=x.forwardRef((n,e)=>x.createElement(ZIe,{...n,forwardedRef:e}));ZIe.displayName="Panel";YIe.displayName="forwardRef(Panel)";let oZ=null,f5=-1,xv=null;function Fft(n,e,t){const i=(e&tke)!==0,s=(e&ike)!==0,r=(e&nke)!==0,o=(e&ske)!==0;if(e){if(i)return r?"se-resize":o?"ne-resize":"e-resize";if(s)return r?"sw-resize":o?"nw-resize":"w-resize";if(r)return"s-resize";if(o)return"n-resize"}switch(n){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function jft(){xv!==null&&(document.head.removeChild(xv),oZ=null,xv=null,f5=-1)}function g$(n,e,t){var i,s;const r=Fft(n,e);if(oZ!==r){if(oZ=r,xv===null&&(xv=document.createElement("style"),document.head.appendChild(xv)),f5>=0){var o;(o=xv.sheet)===null||o===void 0||o.removeRule(f5)}f5=(i=(s=xv.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${r} !important;}`))!==null&&i!==void 0?i:-1}}function XIe(n){return n.type==="keydown"}function QIe(n){return n.type.startsWith("pointer")}function JIe(n){return n.type.startsWith("mouse")}function cB(n){if(QIe(n)){if(n.isPrimary)return{x:n.clientX,y:n.clientY}}else if(JIe(n))return{x:n.clientX,y:n.clientY};return{x:1/0,y:1/0}}function Hft(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Bft(n,e,t){return n.x<e.x+e.width&&n.x+n.width>e.x&&n.y<e.y+e.height&&n.y+n.height>e.y}function Vft(n,e){if(n===e)throw new Error("Cannot compare node with itself");const t={a:m_e(n),b:m_e(e)};let i;for(;t.a.at(-1)===t.b.at(-1);)n=t.a.pop(),e=t.b.pop(),i=n;bn(i,"Stacking order can only be calculated for elements with a common ancestor");const s={a:p_e(g_e(t.a)),b:p_e(g_e(t.b))};if(s.a===s.b){const r=i.childNodes,o={a:t.a.at(-1),b:t.b.at(-1)};let a=r.length;for(;a--;){const l=r[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(s.a-s.b)}const Wft=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function zft(n){var e;const t=getComputedStyle((e=eke(n))!==null&&e!==void 0?e:n).display;return t==="flex"||t==="inline-flex"}function Uft(n){const e=getComputedStyle(n);return!!(e.position==="fixed"||e.zIndex!=="auto"&&(e.position!=="static"||zft(n))||+e.opacity<1||"transform"in e&&e.transform!=="none"||"webkitTransform"in e&&e.webkitTransform!=="none"||"mixBlendMode"in e&&e.mixBlendMode!=="normal"||"filter"in e&&e.filter!=="none"||"webkitFilter"in e&&e.webkitFilter!=="none"||"isolation"in e&&e.isolation==="isolate"||Wft.test(e.willChange)||e.webkitOverflowScrolling==="touch")}function g_e(n){let e=n.length;for(;e--;){const t=n[e];if(bn(t,"Missing node"),Uft(t))return t}return null}function p_e(n){return n&&Number(getComputedStyle(n).zIndex)||0}function m_e(n){const e=[];for(;n;)e.push(n),n=eke(n);return e}function eke(n){const{parentNode:e}=n;return e&&e instanceof ShadowRoot?e.host:e}const tke=1,ike=2,nke=4,ske=8,$ft=Hft()==="coarse";let Of=[],HE=!1,Lv=new Map,dB=new Map;const m2=new Set;function Gft(n,e,t,i,s){var r;const{ownerDocument:o}=e,a={direction:t,element:e,hitAreaMargins:i,setResizeHandlerState:s},l=(r=Lv.get(o))!==null&&r!==void 0?r:0;return Lv.set(o,l+1),m2.add(a),$F(),function(){var d;dB.delete(n),m2.delete(a);const u=(d=Lv.get(o))!==null&&d!==void 0?d:1;if(Lv.set(o,u-1),$F(),u===1&&Lv.delete(o),Of.includes(a)){const h=Of.indexOf(a);h>=0&&Of.splice(h,1),uB(),s("up",!0,null)}}}function qft(n){const{target:e}=n,{x:t,y:i}=cB(n);HE=!0,soe({target:e,x:t,y:i}),$F(),Of.length>0&&(GF("down",n),uB(),n.preventDefault(),rke(e)||n.stopImmediatePropagation())}function p$(n){const{x:e,y:t}=cB(n);if(HE&&n.type!=="pointerleave"&&n.buttons===0&&(HE=!1,GF("up",n)),!HE){const{target:i}=n;soe({target:i,x:e,y:t})}GF("move",n),uB(),Of.length>0&&n.preventDefault()}function m$(n){const{target:e}=n,{x:t,y:i}=cB(n);dB.clear(),HE=!1,Of.length>0&&(n.preventDefault(),rke(e)||n.stopImmediatePropagation()),GF("up",n),soe({target:e,x:t,y:i}),uB(),$F()}function rke(n){let e=n;for(;e;){if(e.hasAttribute(Eo.resizeHandle))return!0;e=e.parentElement}return!1}function soe({target:n,x:e,y:t}){Of.splice(0);let i=null;(n instanceof HTMLElement||n instanceof SVGElement)&&(i=n),m2.forEach(s=>{const{element:r,hitAreaMargins:o}=s,a=r.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=a,h=$ft?o.coarse:o.fine;if(e>=c-h&&e<=d+h&&t>=u-h&&t<=l+h){if(i!==null&&document.contains(i)&&r!==i&&!r.contains(i)&&!i.contains(r)&&Vft(i,r)>0){let m=i,b=!1;for(;m&&!m.contains(r);){if(Bft(m.getBoundingClientRect(),a)){b=!0;break}m=m.parentElement}if(b)return}Of.push(s)}})}function _$(n,e){dB.set(n,e)}function uB(){let n=!1,e=!1;Of.forEach(i=>{const{direction:s}=i;s==="horizontal"?n=!0:e=!0});let t=0;dB.forEach(i=>{t|=i}),n&&e?g$("intersection",t):n?g$("horizontal",t):e?g$("vertical",t):jft()}let b$;function $F(){var n;(n=b$)===null||n===void 0||n.abort(),b$=new AbortController;const e={capture:!0,signal:b$.signal};m2.size&&(HE?(Of.length>0&&Lv.forEach((t,i)=>{const{body:s}=i;t>0&&(s.addEventListener("contextmenu",m$,e),s.addEventListener("pointerleave",p$,e),s.addEventListener("pointermove",p$,e))}),Lv.forEach((t,i)=>{const{body:s}=i;s.addEventListener("pointerup",m$,e),s.addEventListener("pointercancel",m$,e)})):Lv.forEach((t,i)=>{const{body:s}=i;t>0&&(s.addEventListener("pointerdown",qft,e),s.addEventListener("pointermove",p$,e))}))}function GF(n,e){m2.forEach(t=>{const{setResizeHandlerState:i}=t,s=Of.includes(t);i(n,s,e)})}function Kft(){const[n,e]=x.useState(0);return x.useCallback(()=>e(t=>t+1),[])}function bn(n,e){if(!n)throw console.error(e),Error(e)}function Q0(n,e,t=ioe){return n.toFixed(t)===e.toFixed(t)?0:n>e?1:-1}function e_(n,e,t=ioe){return Q0(n,e,t)===0}function fu(n,e,t){return Q0(n,e,t)===0}function Zft(n,e,t){if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++){const s=n[i],r=e[i];if(!fu(s,r,t))return!1}return!0}function $L({panelConstraints:n,panelIndex:e,size:t}){const i=n[e];bn(i!=null,`Panel constraints not found for index ${e}`);let{collapsedSize:s=0,collapsible:r,maxSize:o=100,minSize:a=0}=i;if(Q0(t,a)<0)if(r){const l=(s+a)/2;Q0(t,l)<0?t=s:t=a}else t=a;return t=Math.min(o,t),t=parseFloat(t.toFixed(ioe)),t}function dI({delta:n,initialLayout:e,panelConstraints:t,pivotIndices:i,prevLayout:s,trigger:r}){if(fu(n,0))return e;const o=[...e],[a,l]=i;bn(a!=null,"Invalid first pivot index"),bn(l!=null,"Invalid second pivot index");let c=0;if(r==="keyboard"){{const u=n<0?l:a,h=t[u];bn(h,`Panel constraints not found for index ${u}`);const{collapsedSize:g=0,collapsible:m,minSize:b=0}=h;if(m){const v=e[u];if(bn(v!=null,`Previous layout not found for panel index ${u}`),fu(v,g)){const C=b-v;Q0(C,Math.abs(n))>0&&(n=n<0?0-C:C)}}}{const u=n<0?a:l,h=t[u];bn(h,`No panel constraints found for index ${u}`);const{collapsedSize:g=0,collapsible:m,minSize:b=0}=h;if(m){const v=e[u];if(bn(v!=null,`Previous layout not found for panel index ${u}`),fu(v,b)){const C=v-g;Q0(C,Math.abs(n))>0&&(n=n<0?0-C:C)}}}}{const u=n<0?1:-1;let h=n<0?l:a,g=0;for(;;){const b=e[h];bn(b!=null,`Previous layout not found for panel index ${h}`);const C=$L({panelConstraints:t,panelIndex:h,size:100})-b;if(g+=C,h+=u,h<0||h>=t.length)break}const m=Math.min(Math.abs(n),Math.abs(g));n=n<0?0-m:m}{let h=n<0?a:l;for(;h>=0&&h<t.length;){const g=Math.abs(n)-Math.abs(c),m=e[h];bn(m!=null,`Previous layout not found for panel index ${h}`);const b=m-g,v=$L({panelConstraints:t,panelIndex:h,size:b});if(!fu(m,v)&&(c+=m-v,o[h]=v,c.toFixed(3).localeCompare(Math.abs(n).toFixed(3),void 0,{numeric:!0})>=0))break;n<0?h--:h++}}if(Zft(s,o))return s;{const u=n<0?l:a,h=e[u];bn(h!=null,`Previous layout not found for panel index ${u}`);const g=h+c,m=$L({panelConstraints:t,panelIndex:u,size:g});if(o[u]=m,!fu(m,g)){let b=g-m,C=n<0?l:a;for(;C>=0&&C<t.length;){const y=o[C];bn(y!=null,`Previous layout not found for panel index ${C}`);const L=y+b,E=$L({panelConstraints:t,panelIndex:C,size:L});if(fu(y,E)||(b-=E-y,o[C]=E),fu(b,0))break;n>0?C--:C++}}}const d=o.reduce((u,h)=>h+u,0);return fu(d,100)?o:s}function Yft({layout:n,panelsArray:e,pivotIndices:t}){let i=0,s=100,r=0,o=0;const a=t[0];bn(a!=null,"No pivot index found"),e.forEach((u,h)=>{const{constraints:g}=u,{maxSize:m=100,minSize:b=0}=g;h===a?(i=b,s=m):(r+=b,o+=m)});const l=Math.min(s,100-r),c=Math.max(i,100-o),d=n[a];return{valueMax:l,valueMin:c,valueNow:d}}function _2(n,e=document){return Array.from(e.querySelectorAll(`[${Eo.resizeHandleId}][data-panel-group-id="${n}"]`))}function oke(n,e,t=document){const s=_2(n,t).findIndex(r=>r.getAttribute(Eo.resizeHandleId)===e);return s??null}function ake(n,e,t){const i=oke(n,e,t);return i!=null?[i,i+1]:[-1,-1]}function Xft(n){return n instanceof HTMLElement?!0:typeof n=="object"&&n!==null&&"tagName"in n&&"getAttribute"in n}function lke(n,e=document){if(Xft(e)&&e.dataset.panelGroupId==n)return e;const t=e.querySelector(`[data-panel-group][data-panel-group-id="${n}"]`);return t||null}function hB(n,e=document){const t=e.querySelector(`[${Eo.resizeHandleId}="${n}"]`);return t||null}function Qft(n,e,t,i=document){var s,r,o,a;const l=hB(e,i),c=_2(n,i),d=l?c.indexOf(l):-1,u=(s=(r=t[d])===null||r===void 0?void 0:r.id)!==null&&s!==void 0?s:null,h=(o=(a=t[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[u,h]}function Jft({committedValuesRef:n,eagerValuesRef:e,groupId:t,layout:i,panelDataArray:s,panelGroupElement:r,setLayout:o}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Dy(()=>{if(!r)return;const a=_2(t,r);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:d,valueNow:u}=Yft({layout:i,panelsArray:s,pivotIndices:[l,l+1]}),h=a[l];if(h!=null){const g=s[l];bn(g,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",g.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",u!=null?""+Math.round(u):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[t,i,s,r]),x.useEffect(()=>{if(!r)return;const a=e.current;bn(a,"Eager values not found");const{panelDataArray:l}=a,c=lke(t,r);bn(c!=null,`No group found for id "${t}"`);const d=_2(t,r);bn(d,`No resize handles found for group id "${t}"`);const u=d.map(h=>{const g=h.getAttribute(Eo.resizeHandleId);bn(g,"Resize handle element has no handle id attribute");const[m,b]=Qft(t,g,l,r);if(m==null||b==null)return()=>{};const v=C=>{if(!C.defaultPrevented)switch(C.key){case"Enter":{C.preventDefault();const y=l.findIndex(L=>L.id===m);if(y>=0){const L=l[y];bn(L,`No panel data found for index ${y}`);const E=i[y],{collapsedSize:R=0,collapsible:T,minSize:N=0}=L.constraints;if(E!=null&&T){const I=dI({delta:fu(E,R)?N-R:R-E,initialLayout:i,panelConstraints:l.map(M=>M.constraints),pivotIndices:ake(t,g,r),prevLayout:i,trigger:"keyboard"});i!==I&&o(I)}}break}}};return h.addEventListener("keydown",v),()=>{h.removeEventListener("keydown",v)}});return()=>{u.forEach(h=>h())}},[r,n,e,t,i,s,o])}function __e(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function cke(n,e){const t=n==="horizontal",{x:i,y:s}=cB(e);return t?i:s}function egt(n,e,t,i,s){const r=t==="horizontal",o=hB(e,s);bn(o,`No resize handle element found for id "${e}"`);const a=o.getAttribute(Eo.groupId);bn(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=i;const c=cke(t,n),d=lke(a,s);bn(d,`No group element found for id "${a}"`);const u=d.getBoundingClientRect(),h=r?u.width:u.height;return(c-l)/h*100}function tgt(n,e,t,i,s,r){if(XIe(n)){const o=t==="horizontal";let a=0;n.shiftKey?a=100:s!=null?a=s:a=10;let l=0;switch(n.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return i==null?0:egt(n,e,t,i,r)}function igt({panelDataArray:n}){const e=Array(n.length),t=n.map(r=>r.constraints);let i=0,s=100;for(let r=0;r<n.length;r++){const o=t[r];bn(o,`Panel constraints not found for index ${r}`);const{defaultSize:a}=o;a!=null&&(i++,e[r]=a,s-=a)}for(let r=0;r<n.length;r++){const o=t[r];bn(o,`Panel constraints not found for index ${r}`);const{defaultSize:a}=o;if(a!=null)continue;const l=n.length-i,c=s/l;i++,e[r]=c,s-=c}return e}function eL(n,e,t){e.forEach((i,s)=>{const r=n[s];bn(r,`Panel data not found for index ${s}`);const{callbacks:o,constraints:a,id:l}=r,{collapsedSize:c=0,collapsible:d}=a,u=t[l];if(u==null||i!==u){t[l]=i;const{onCollapse:h,onExpand:g,onResize:m}=o;m&&m(i,u),d&&(h||g)&&(g&&(u==null||e_(u,c))&&!e_(i,c)&&g(),h&&(u==null||!e_(u,c))&&e_(i,c)&&h())}})}function w4(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t])return!1;return!0}function ngt({defaultSize:n,dragState:e,layout:t,panelData:i,panelIndex:s,precision:r=3}){const o=t[s];let a;return o==null?a=n!=null?n.toFixed(r):"1":i.length===1?a="1":a=o.toFixed(r),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:e!==null?"none":void 0}}function sgt(n,e=10){let t=null;return(...s)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{n(...s)},e)}}function b_e(n){try{if(typeof localStorage<"u")n.getItem=e=>localStorage.getItem(e),n.setItem=(e,t)=>{localStorage.setItem(e,t)};else throw new Error("localStorage not supported in this environment")}catch(e){console.error(e),n.getItem=()=>null,n.setItem=()=>{}}}function dke(n){return`react-resizable-panels:${n}`}function uke(n){return n.map(e=>{const{constraints:t,id:i,idIsFromProps:s,order:r}=e;return s?i:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((e,t)=>e.localeCompare(t)).join(",")}function hke(n,e){try{const t=dke(n),i=e.getItem(t);if(i){const s=JSON.parse(i);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function rgt(n,e,t){var i,s;const r=(i=hke(n,t))!==null&&i!==void 0?i:{},o=uke(e);return(s=r[o])!==null&&s!==void 0?s:null}function ogt(n,e,t,i,s){var r;const o=dke(n),a=uke(e),l=(r=hke(n,s))!==null&&r!==void 0?r:{};l[a]={expandToSizes:Object.fromEntries(t.entries()),layout:i};try{s.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function v_e({layout:n,panelConstraints:e}){const t=[...n],i=t.reduce((r,o)=>r+o,0);if(t.length!==e.length)throw Error(`Invalid ${e.length} panel layout: ${t.map(r=>`${r}%`).join(", ")}`);if(!fu(i,100)&&t.length>0)for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=100/i*o;t[r]=a}let s=0;for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=$L({panelConstraints:e,panelIndex:r,size:o});o!=a&&(s+=o-a,t[r]=a)}if(!fu(s,0))for(let r=0;r<e.length;r++){const o=t[r];bn(o!=null,`No layout data found for index ${r}`);const a=o+s,l=$L({panelConstraints:e,panelIndex:r,size:a});if(o!==l&&(s-=l-o,t[r]=l,fu(s,0)))break}return t}const agt=100,uI={getItem:n=>(b_e(uI),uI.getItem(n)),setItem:(n,e)=>{b_e(uI),uI.setItem(n,e)}},C_e={};function fke({autoSaveId:n=null,children:e,className:t="",direction:i,forwardedRef:s,id:r=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=uI,style:c,tagName:d="div",...u}){const h=noe(r),g=x.useRef(null),[m,b]=x.useState(null),[v,C]=x.useState([]),y=Kft(),L=x.useRef({}),E=x.useRef(new Map),R=x.useRef(0),T=x.useRef({autoSaveId:n,direction:i,dragState:m,id:h,keyboardResizeBy:a,onLayout:o,storage:l}),N=x.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(s,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:ee}=N.current;return ee},setLayout:ee=>{const{onLayout:se}=T.current,{layout:ae,panelDataArray:Se}=N.current,ue=v_e({layout:ee,panelConstraints:Se.map(Re=>Re.constraints)});__e(ae,ue)||(C(ue),N.current.layout=ue,se&&se(ue),eL(Se,ue,L.current))}}),[]),Dy(()=>{T.current.autoSaveId=n,T.current.direction=i,T.current.dragState=m,T.current.id=h,T.current.onLayout=o,T.current.storage=l}),Jft({committedValuesRef:T,eagerValuesRef:N,groupId:h,layout:v,panelDataArray:N.current.panelDataArray,setLayout:C,panelGroupElement:g.current}),x.useEffect(()=>{const{panelDataArray:ee}=N.current;if(n){if(v.length===0||v.length!==ee.length)return;let se=C_e[n];se==null&&(se=sgt(ogt,agt),C_e[n]=se);const ae=[...ee],Se=new Map(E.current);se(n,ae,Se,v,l)}},[n,v,l]),x.useEffect(()=>{});const I=x.useCallback(ee=>{const{onLayout:se}=T.current,{layout:ae,panelDataArray:Se}=N.current;if(ee.constraints.collapsible){const ue=Se.map(dt=>dt.constraints),{collapsedSize:Re=0,panelSize:Ve,pivotIndices:Qe}=JC(Se,ee,ae);if(bn(Ve!=null,`Panel size not found for panel "${ee.id}"`),!e_(Ve,Re)){E.current.set(ee.id,Ve);const yt=AL(Se,ee)===Se.length-1?Ve-Re:Re-Ve,fi=dI({delta:yt,initialLayout:ae,panelConstraints:ue,pivotIndices:Qe,prevLayout:ae,trigger:"imperative-api"});w4(ae,fi)||(C(fi),N.current.layout=fi,se&&se(fi),eL(Se,fi,L.current))}}},[]),M=x.useCallback((ee,se)=>{const{onLayout:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current;if(ee.constraints.collapsible){const Re=ue.map(_i=>_i.constraints),{collapsedSize:Ve=0,panelSize:Qe=0,minSize:dt=0,pivotIndices:yt}=JC(ue,ee,Se),fi=se??dt;if(e_(Qe,Ve)){const _i=E.current.get(ee.id),Sn=_i!=null&&_i>=fi?_i:fi,br=AL(ue,ee)===ue.length-1?Qe-Sn:Sn-Qe,hs=dI({delta:br,initialLayout:Se,panelConstraints:Re,pivotIndices:yt,prevLayout:Se,trigger:"imperative-api"});w4(Se,hs)||(C(hs),N.current.layout=hs,ae&&ae(hs),eL(ue,hs,L.current))}}},[]),P=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{panelSize:Se}=JC(ae,ee,se);return bn(Se!=null,`Panel size not found for panel "${ee.id}"`),Se},[]),H=x.useCallback((ee,se)=>{const{panelDataArray:ae}=N.current,Se=AL(ae,ee);return ngt({defaultSize:se,dragState:m,layout:v,panelData:ae,panelIndex:Se})},[m,v]),j=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{collapsedSize:Se=0,collapsible:ue,panelSize:Re}=JC(ae,ee,se);return bn(Re!=null,`Panel size not found for panel "${ee.id}"`),ue===!0&&e_(Re,Se)},[]),V=x.useCallback(ee=>{const{layout:se,panelDataArray:ae}=N.current,{collapsedSize:Se=0,collapsible:ue,panelSize:Re}=JC(ae,ee,se);return bn(Re!=null,`Panel size not found for panel "${ee.id}"`),!ue||Q0(Re,Se)>0},[]),W=x.useCallback(ee=>{const{panelDataArray:se}=N.current;se.push(ee),se.sort((ae,Se)=>{const ue=ae.order,Re=Se.order;return ue==null&&Re==null?0:ue==null?-1:Re==null?1:ue-Re}),N.current.panelDataArrayChanged=!0,y()},[y]);Dy(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:ee,onLayout:se,storage:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current;let Re=null;if(ee){const Qe=rgt(ee,ue,ae);Qe&&(E.current=new Map(Object.entries(Qe.expandToSizes)),Re=Qe.layout)}Re==null&&(Re=igt({panelDataArray:ue}));const Ve=v_e({layout:Re,panelConstraints:ue.map(Qe=>Qe.constraints)});__e(Se,Ve)||(C(Ve),N.current.layout=Ve,se&&se(Ve),eL(ue,Ve,L.current))}}),Dy(()=>{const ee=N.current;return()=>{ee.layout=[]}},[]);const U=x.useCallback(ee=>{let se=!1;const ae=g.current;return ae&&window.getComputedStyle(ae,null).getPropertyValue("direction")==="rtl"&&(se=!0),function(ue){ue.preventDefault();const Re=g.current;if(!Re)return()=>null;const{direction:Ve,dragState:Qe,id:dt,keyboardResizeBy:yt,onLayout:fi}=T.current,{layout:_i,panelDataArray:Sn}=N.current,{initialLayout:Es}=Qe??{},br=ake(dt,ee,Re);let hs=tgt(ue,ee,Ve,Qe,yt,Re);const Ht=Ve==="horizontal";Ht&&se&&(hs=-hs);const oe=Sn.map(bt=>bt.constraints),Ce=dI({delta:hs,initialLayout:Es??_i,panelConstraints:oe,pivotIndices:br,prevLayout:_i,trigger:XIe(ue)?"keyboard":"mouse-or-touch"}),je=!w4(_i,Ce);(QIe(ue)||JIe(ue))&&R.current!=hs&&(R.current=hs,!je&&hs!==0?Ht?_$(ee,hs<0?tke:ike):_$(ee,hs<0?nke:ske):_$(ee,0)),je&&(C(Ce),N.current.layout=Ce,fi&&fi(Ce),eL(Sn,Ce,L.current))}},[]),B=x.useCallback((ee,se)=>{const{onLayout:ae}=T.current,{layout:Se,panelDataArray:ue}=N.current,Re=ue.map(_i=>_i.constraints),{panelSize:Ve,pivotIndices:Qe}=JC(ue,ee,Se);bn(Ve!=null,`Panel size not found for panel "${ee.id}"`);const yt=AL(ue,ee)===ue.length-1?Ve-se:se-Ve,fi=dI({delta:yt,initialLayout:Se,panelConstraints:Re,pivotIndices:Qe,prevLayout:Se,trigger:"imperative-api"});w4(Se,fi)||(C(fi),N.current.layout=fi,ae&&ae(fi),eL(ue,fi,L.current))},[]),K=x.useCallback((ee,se)=>{const{layout:ae,panelDataArray:Se}=N.current,{collapsedSize:ue=0,collapsible:Re}=se,{collapsedSize:Ve=0,collapsible:Qe,maxSize:dt=100,minSize:yt=0}=ee.constraints,{panelSize:fi}=JC(Se,ee,ae);fi!=null&&(Re&&Qe&&e_(fi,ue)?e_(ue,Ve)||B(ee,Ve):fi<yt?B(ee,yt):fi>dt&&B(ee,dt))},[B]),X=x.useCallback((ee,se)=>{const{direction:ae}=T.current,{layout:Se}=N.current;if(!g.current)return;const ue=hB(ee,g.current);bn(ue,`Drag handle element not found for id "${ee}"`);const Re=cke(ae,se);b({dragHandleId:ee,dragHandleRect:ue.getBoundingClientRect(),initialCursorPosition:Re,initialLayout:Se})},[]),ne=x.useCallback(()=>{b(null)},[]),fe=x.useCallback(ee=>{const{panelDataArray:se}=N.current,ae=AL(se,ee);ae>=0&&(se.splice(ae,1),delete L.current[ee.id],N.current.panelDataArrayChanged=!0,y())},[y]),Z=x.useMemo(()=>({collapsePanel:I,direction:i,dragState:m,expandPanel:M,getPanelSize:P,getPanelStyle:H,groupId:h,isPanelCollapsed:j,isPanelExpanded:V,reevaluatePanelConstraints:K,registerPanel:W,registerResizeHandle:U,resizePanel:B,startDragging:X,stopDragging:ne,unregisterPanel:fe,panelGroupElement:g.current}),[I,m,i,M,P,H,h,j,V,K,W,U,B,X,ne,fe]),Y={display:"flex",flexDirection:i==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(lB.Provider,{value:Z},x.createElement(d,{...u,children:e,className:t,id:r,ref:g,style:{...Y,...c},[Eo.group]:"",[Eo.groupDirection]:i,[Eo.groupId]:h}))}const gke=x.forwardRef((n,e)=>x.createElement(fke,{...n,forwardedRef:e}));fke.displayName="PanelGroup";gke.displayName="forwardRef(PanelGroup)";function AL(n,e){return n.findIndex(t=>t===e||t.id===e.id)}function JC(n,e,t){const i=AL(n,e),r=i===n.length-1?[i-1,i]:[i,i+1],o=t[i];return{...e.constraints,panelSize:o,pivotIndices:r}}function lgt({disabled:n,handleId:e,resizeHandler:t,panelGroupElement:i}){x.useEffect(()=>{if(n||t==null||i==null)return;const s=hB(e,i);if(s==null)return;const r=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),t(o);break}case"F6":{o.preventDefault();const a=s.getAttribute(Eo.groupId);bn(a,`No group element found for id "${a}"`);const l=_2(a,i),c=oke(a,e,i);bn(c!==null,`No resize element found for id "${e}"`);const d=o.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return s.addEventListener("keydown",r),()=>{s.removeEventListener("keydown",r)}},[i,n,e,t])}function pke({children:n=null,className:e="",disabled:t=!1,hitAreaMargins:i,id:s,onBlur:r,onClick:o,onDragging:a,onFocus:l,onPointerDown:c,onPointerUp:d,style:u={},tabIndex:h=0,tagName:g="div",...m}){var b,v;const C=x.useRef(null),y=x.useRef({onClick:o,onDragging:a,onPointerDown:c,onPointerUp:d});x.useEffect(()=>{y.current.onClick=o,y.current.onDragging=a,y.current.onPointerDown=c,y.current.onPointerUp=d});const L=x.useContext(lB);if(L===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:R,registerResizeHandle:T,startDragging:N,stopDragging:I,panelGroupElement:M}=L,P=noe(s),[H,j]=x.useState("inactive"),[V,W]=x.useState(!1),[U,B]=x.useState(null),K=x.useRef({state:H});Dy(()=>{K.current.state=H}),x.useEffect(()=>{if(t)B(null);else{const Z=T(P);B(()=>Z)}},[t,P,T]);const X=(b=i==null?void 0:i.coarse)!==null&&b!==void 0?b:15,ne=(v=i==null?void 0:i.fine)!==null&&v!==void 0?v:5;x.useEffect(()=>{if(t||U==null)return;const Z=C.current;bn(Z,"Element ref not attached");let Y=!1;return Gft(P,Z,E,{coarse:X,fine:ne},(se,ae,Se)=>{if(!ae){j("inactive");return}switch(se){case"down":{j("drag"),Y=!1,bn(Se,'Expected event to be defined for "down" action'),N(P,Se);const{onDragging:ue,onPointerDown:Re}=y.current;ue==null||ue(!0),Re==null||Re();break}case"move":{const{state:ue}=K.current;Y=!0,ue!=="drag"&&j("hover"),bn(Se,'Expected event to be defined for "move" action'),U(Se);break}case"up":{j("hover"),I();const{onClick:ue,onDragging:Re,onPointerUp:Ve}=y.current;Re==null||Re(!1),Ve==null||Ve(),Y||ue==null||ue();break}}})},[X,E,t,ne,T,P,U,N,I]),lgt({disabled:t,handleId:P,resizeHandler:U,panelGroupElement:M});const fe={touchAction:"none",userSelect:"none"};return x.createElement(g,{...m,children:n,className:e,id:s,onBlur:()=>{W(!1),r==null||r()},onFocus:()=>{W(!0),l==null||l()},ref:C,role:"separator",style:{...fe,...u},tabIndex:h,[Eo.groupDirection]:E,[Eo.groupId]:R,[Eo.resizeHandle]:"",[Eo.resizeHandleActive]:H==="drag"?"pointer":V?"keyboard":void 0,[Eo.resizeHandleEnabled]:!t,[Eo.resizeHandleId]:P,[Eo.resizeHandleState]:H})}pke.displayName="PanelResizeHandle";function cgt({className:n,...e}){return f.jsx(gke,{"data-slot":"resizable-panel-group",className:Le("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",n),...e})}function w_e({...n}){return f.jsx(YIe,{"data-slot":"resizable-panel",...n})}function dgt({withHandle:n,className:e,...t}){return f.jsx(pke,{"data-slot":"resizable-handle",className:Le("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",e),...t,children:n&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(JSe,{className:"size-2.5"})})})}function ugt({storageKey:n,left:e,right:t,initialRatio:i=.5,minWidth:s=240,className:r}){const o=x.useMemo(()=>{const h=np.get(n);if(h!==null){const g=Number(h);if(!Number.isNaN(g))return v$(g,.1,.9)}return v$(i,.1,.9)},[n,i]),a=Math.round(o*100),l=100-a,d=Math.min(45,Math.max(5,Math.round(s/1200*100)));function u(h){const g=h[0],m=v$(g/100,.1,.9);np.set(n,m)}return f.jsxs(cgt,{direction:"horizontal",onLayout:u,className:Le("relative flex h-full w-full items-stretch overflow-hidden",r),children:[f.jsx(w_e,{defaultSize:a,minSize:d,className:"overflow-auto",children:e}),f.jsx(dgt,{withHandle:!0}),f.jsx(w_e,{defaultSize:l,minSize:d,className:"overflow-auto",children:t})]})}function v$(n,e,t){return Math.max(e,Math.min(t,n))}const hgt="modulepreload",fgt=function(n){return"/"+n},y_e={},pt=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let o=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};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"));s=o(t.map(c=>{if(c=fgt(c),c in y_e)return;y_e[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":hgt,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};function mke(){return globalThis._VSCODE_NLS_MESSAGES}function roe(){return globalThis._VSCODE_NLS_LANGUAGE}const ggt=roe()==="pseudo"||typeof document<"u"&&document.location&&typeof document.location.hash=="string"&&document.location.hash.indexOf("pseudo=true")>=0;function qF(n,e){let t;return e.length===0?t=n:t=n.replace(/\{(\d+)\}/g,(i,s)=>{const r=s[0],o=e[r];let a=i;return typeof o=="string"?a=o:(typeof o=="number"||typeof o=="boolean"||o===void 0||o===null)&&(a=String(o)),a}),ggt&&(t="["+t.replace(/[aouei]/g,"$&$&")+"]"),t}function S(n,e,...t){return qF(typeof n=="number"?_ke(n,e):e,t)}function _ke(n,e){var i;const t=(i=mke())==null?void 0:i[n];if(typeof t!="string"){if(typeof e=="string")return e;throw new Error(`!!! NLS MISSING: ${n} !!!`)}return t}function ce(n,e,...t){let i;typeof n=="number"?i=_ke(n,e):i=e;const s=qF(i,t);return{value:s,original:e===i?s:qF(e,t)}}function pgt(n,e){const t=n;typeof t.vscodeWindowId!="number"&&Object.defineProperty(t,"vscodeWindowId",{get:()=>e})}const dn=window,f7=class f7{constructor(){this.mapWindowIdToZoomFactor=new Map}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}getWindowId(e){return e.vscodeWindowId}};f7.INSTANCE=new f7;let aZ=f7;function bke(n,e,t){typeof e=="string"&&(e=n.matchMedia(e)),e.addEventListener("change",t)}function lZ(n){return aZ.INSTANCE.getZoomFactor(n)}const qR=navigator.userAgent,lc=qR.indexOf("Firefox")>=0,fB=qR.indexOf("AppleWebKit")>=0,GM=qR.indexOf("Chrome")>=0,J0=!GM&&qR.indexOf("Safari")>=0,vke=!GM&&!J0&&fB;qR.indexOf("Electron/")>=0;const S_e=qR.indexOf("Android")>=0;let C$=!1;if(typeof dn.matchMedia=="function"){const n=dn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=dn.matchMedia("(display-mode: fullscreen)");C$=n.matches,bke(dn,n,({matches:t})=>{C$&&e.matches||(C$=t)})}function ooe(){return globalThis.MonacoEnvironment}class mgt{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?VD.isErrorNoTelemetry(e)?new VD(e.message+`
|
|
747
747
|
|
|
748
748
|
`+e.stack):new Error(e.message+`
|
|
749
749
|
|
|
@@ -1645,7 +1645,7 @@ ${e.toString()}`}}class l7{constructor(e=new dN,t=!1,i,s=uWt){this._services=e,t
|
|
|
1645
1645
|
`:`\r
|
|
1646
1646
|
`}};rne=Kp([Er(0,Ut)],rne);class SWt{publicLog2(){}}const Xk=class Xk{constructor(){const e=ut.from({scheme:Xk.SCHEME,authority:"model",path:"/"});this.workspace={id:DPe,folders:[new Hkt({uri:e,name:"",index:0})]}}getWorkspace(){return this.workspace}getWorkspaceFolder(e){return e&&e.scheme===Xk.SCHEME?this.workspace.folders[0]:null}};Xk.SCHEME="inmemory";let one=Xk;function d7(n,e,t){if(!e||!(n instanceof c7))return;const i=[];Object.keys(e).forEach(s=>{n2t(s)&&i.push([`editor.${s}`,e[s]]),t&&s2t(s)&&i.push([`diffEditor.${s}`,e[s]])}),i.length>0&&n.updateValues(i)}let ane=class{constructor(e){this._modelService=e}hasPreviewHandler(){return!1}async apply(e,t){const i=Array.isArray(e)?e:vle.convert(e),s=new Map;for(const a of i){if(!(a instanceof m1))throw new Error("bad edit - only text edits are supported");const l=this._modelService.getModel(a.resource);if(!l)throw new Error("bad edit - model not found");if(typeof a.versionId=="number"&&l.getVersionId()!==a.versionId)throw new Error("bad state - model changed in the meantime");let c=s.get(l);c||(c=[],s.set(l,c)),c.push(Ws.replaceMove(F.lift(a.textEdit.range),a.textEdit.text))}let r=0,o=0;for(const[a,l]of s)a.pushStackElement(),a.pushEditOperations([],l,()=>[]),a.pushStackElement(),o+=1,r+=l.length;return{ariaSummary:sS(Jee.bulkEditServiceSummary,r,o),isApplied:r>0}}};ane=Kp([Er(0,xs)],ane);class xWt{getUriLabel(e,t){return e.scheme==="file"?e.fsPath:e.path}getUriBasenameLabel(e){return $u(e)}}let lne=class extends BBt{constructor(e,t){super(e),this._codeEditorService=t}showContextView(e,t,i){if(!t){const s=this._codeEditorService.getFocusedCodeEditor()||this._codeEditorService.getActiveCodeEditor();s&&(t=s.getContainerDomNode())}return super.showContextView(e,t,i)}};lne=Kp([Er(0,$p),Er(1,Ni)],lne);class LWt{constructor(){this._neverEmitter=new te,this.onDidChangeTrust=this._neverEmitter.event}isWorkspaceTrusted(){return!0}}class EWt extends Sie{constructor(){super()}}class DWt extends mWt{constructor(){super(new A_t)}}let cne=class extends Eie{constructor(e,t,i,s,r,o){super(e,t,i,s,r,o),this.configure({blockMouse:!1})}};cne=Kp([Er(0,Ba),Er(1,qs),Er(2,Cb),Er(3,Mi),Er(4,Yu),Er(5,Dt)],cne);const RWt={esmModuleLocation:void 0,label:"editorWorkerService"};let dne=class extends uie{constructor(e,t,i,s,r){super(RWt,e,t,i,s,r)}};dne=Kp([Er(0,xs),Er(1,VV),Er(2,qn),Er(3,Ls),Er(4,Xe)],dne);class NWt{async playSignal(e,t){}}hi(qn,DWt,0);hi(Ut,c7,0);hi(VV,sne,0);hi(w5e,rne,0);hi(ib,one,0);hi(NS,xWt,0);hi(Ba,SWt,0);hi(MO,wWt,0);hi(Nle,CWt,0);hi(qs,ine,0);hi(Gp,Gw,0);hi(Gs,EWt,0);hi(Xd,kHt,0);hi(xs,kie,0);hi(Joe,Iie,0);hi(Dt,Jie,0);hi(eOe,vWt,0);hi(eb,tne,0);hi(ll,yIt,0);hi(mc,dne,0);hi(yO,ane,0);hi(A5e,LWt,0);hi(al,ene,0);hi($o,Zie,0);hi(eh,TOt,0);hi(Kn,nne,0);hi(Mi,LR,0);hi(Fa,qie,0);hi(Cb,lne,0);hi(wb,Tie,0);hi(ed,Xie,0);hi(Yd,cne,0);hi(Yu,AX,0);hi(bb,NWt,0);hi(jae,_Wt,0);hi(R2e,F_t,0);hi(bce,G3t,0);var kt;(function(n){const e=new dN;for(const[l,c]of pbe())e.set(l,c);const t=new l7(e,!0);e.set(st,t);function i(l){s||o({});const c=e.get(l);if(!c)throw new Error("Missing service "+l);return c instanceof Wg?t.invokeFunction(d=>d.get(l)):c}n.get=i;let s=!1;const r=new te;function o(l){if(s)return t;s=!0;for(const[d,u]of pbe())e.get(d)||e.set(d,u);for(const d in l)if(l.hasOwnProperty(d)){const u=ei(d);e.get(u)instanceof Wg&&e.set(u,l[d])}const c=H2t();for(const d of c)try{t.createInstance(d)}catch(u){It(u)}return r.fire(),t}n.initialize=o;function a(l){if(s)return l();const c=new ge,d=c.add(r.event(()=>{d.dispose(),c.add(l())}));return c}n.withServices=a})(kt||(kt={}));var TWt=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},$0e=function(n,e){return function(t,i){e(t,i,n)}},J5,V0;let une=(V0=class{constructor(e,t){this._configurationService=e,this._languageService=t}async renderCodeBlock(e,t,i){var d;const s=Qf(i.context)?i.context:void 0;let r;e?r=this._languageService.getLanguageIdByLanguageName(e):s&&(r=(d=s.getModel())==null?void 0:d.getLanguageId()),r||(r=Hd);const o=await jEt(this._languageService,t,r),a=J5._ttpTokenizer?J5._ttpTokenizer.createHTML(o)??o:o,l=document.createElement("span");l.innerHTML=a;const c=l.querySelector(".monaco-tokenized-source");return $s(c)?(Io(c,this.getFontInfo(s)),l):document.createElement("span")}getFontInfo(e){return e?e.getOption(59):m1t({fontFamily:this._configurationService.getValue("editor").fontFamily},1)}},J5=V0,V0._ttpTokenizer=zp("tokenizeToString",{createHTML(e){return e}}),V0);une=J5=TWt([$0e(0,Ut),$0e(1,Gs)],une);var Yce=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},Fn=function(n,e){return function(t,i){e(t,i,n)}};let IWt=0,G0e=!1;function kWt(n){if(!n){if(G0e)return;G0e=!0}Qmt(n||dn.document.body)}let u7=class extends fS{constructor(e,t,i,s,r,o,a,l,c,d,u,h,g,m){const b={...t};b.ariaLabel=b.ariaLabel||Xee.editorViewAccessibleLabel,super(e,b,{},i,s,r,o,c,d,u,h,g),l instanceof LR?this._standaloneKeybindingService=l:this._standaloneKeybindingService=null,kWt(b.ariaContainerElement),xDt((v,C)=>i.createInstance(lR,v,{instantHover:C},{})),MNt(a),m.setDefaultCodeBlockRenderer(i.createInstance(une))}addCommand(e,t,i){if(!this._standaloneKeybindingService)return console.warn("Cannot add command because the editor is configured with an unrecognized KeybindingService"),null;const s="DYNAMIC_"+ ++IWt,r=ve.deserialize(i);return this._standaloneKeybindingService.addDynamicKeybinding(s,e,t,r),s}createContextKey(e,t){return this._contextKeyService.createKey(e,t)}addAction(e){if(typeof e.id!="string"||typeof e.label!="string"||typeof e.run!="function")throw new Error("Invalid action descriptor, `id`, `label` and `run` are required properties!");if(!this._standaloneKeybindingService)return console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"),ie.None;const t=e.id,i=e.label,s=ve.and(ve.equals("editorId",this.getId()),ve.deserialize(e.precondition)),r=e.keybindings,o=ve.and(s,ve.deserialize(e.keybindingContext)),a=e.contextMenuGroupId||null,l=e.contextMenuOrder||0,c=(g,...m)=>Promise.resolve(e.run(this,...m)),d=new ge,u=this.getId()+":"+t;if(d.add(wi.registerCommand(u,c)),a){const g={command:{id:u,title:i},when:s,group:a,order:l};d.add(No.appendMenuItem(Je.EditorContext,g))}if(Array.isArray(r))for(const g of r)d.add(this._standaloneKeybindingService.addDynamicKeybinding(u,g,c,o));const h=new xMe(u,i,i,void 0,s,(...g)=>Promise.resolve(e.run(this,...g)),this._contextKeyService);return this._actions.set(t,h),d.add(et(()=>{this._actions.delete(t)})),d}_triggerCommand(e,t){if(this._codeEditorService instanceof Q6)try{this._codeEditorService.setActiveCodeEditor(this),super._triggerCommand(e,t)}finally{this._codeEditorService.setActiveCodeEditor(null)}else super._triggerCommand(e,t)}};u7=Yce([Fn(2,st),Fn(3,Ni),Fn(4,Kn),Fn(5,Dt),Fn(6,Hl),Fn(7,Mi),Fn(8,Os),Fn(9,qs),Fn(10,$o),Fn(11,Ls),Fn(12,Xe),Fn(13,qh)],u7);let hne=class extends u7{constructor(e,t,i,s,r,o,a,l,c,d,u,h,g,m,b,v,C){const y={...t};d7(u,y,!1);const L=c.registerEditorContainer(e);typeof y.theme=="string"&&c.setTheme(y.theme),typeof y.autoDetectHighContrast<"u"&&c.setAutoDetectHighContrast(!!y.autoDetectHighContrast);const E=y.model;delete y.model,super(e,y,i,s,r,o,a,l,c,d,h,b,v,C),this._configurationService=u,this._standaloneThemeService=c,this._register(L);let R;if(typeof E>"u"){const T=m.getLanguageIdByMimeType(y.language)||y.language||Hd;R=LFe(g,m,y.value||"",T,void 0),this._ownsModel=!0}else R=E,this._ownsModel=!1;if(this._attachModel(R),R){const T={oldModelUrl:null,newModelUrl:R.uri};this._onDidChangeModel.fire(T)}}dispose(){super.dispose()}updateOptions(e){d7(this._configurationService,e,!1),typeof e.theme=="string"&&this._standaloneThemeService.setTheme(e.theme),typeof e.autoDetectHighContrast<"u"&&this._standaloneThemeService.setAutoDetectHighContrast(!!e.autoDetectHighContrast),super.updateOptions(e)}_postDetachModelCleanup(e){super._postDetachModelCleanup(e),e&&this._ownsModel&&(e.dispose(),this._ownsModel=!1)}};hne=Yce([Fn(2,st),Fn(3,Ni),Fn(4,Kn),Fn(5,Dt),Fn(6,Hl),Fn(7,Mi),Fn(8,Xd),Fn(9,qs),Fn(10,Ut),Fn(11,$o),Fn(12,xs),Fn(13,Gs),Fn(14,Ls),Fn(15,Xe),Fn(16,qh)],hne);let fne=class extends Tp{constructor(e,t,i,s,r,o,a,l,c,d,u,h){const g={...t};d7(l,g,!0);const m=o.registerEditorContainer(e);typeof g.theme=="string"&&o.setTheme(g.theme),typeof g.autoDetectHighContrast<"u"&&o.setAutoDetectHighContrast(!!g.autoDetectHighContrast),super(e,g,{},s,i,r,h,d),this._configurationService=l,this._standaloneThemeService=o,this._register(m)}dispose(){super.dispose()}updateOptions(e){d7(this._configurationService,e,!0),typeof e.theme=="string"&&this._standaloneThemeService.setTheme(e.theme),typeof e.autoDetectHighContrast<"u"&&this._standaloneThemeService.setAutoDetectHighContrast(!!e.autoDetectHighContrast),super.updateOptions(e)}_createInnerEditor(e,t,i){return e.createInstance(u7,t,i)}getOriginalEditor(){return super.getOriginalEditor()}getModifiedEditor(){return super.getModifiedEditor()}addCommand(e,t,i){return this.getModifiedEditor().addCommand(e,t,i)}createContextKey(e,t){return this.getModifiedEditor().createContextKey(e,t)}addAction(e){return this.getModifiedEditor().addAction(e)}};fne=Yce([Fn(2,st),Fn(3,Dt),Fn(4,Ni),Fn(5,Xd),Fn(6,qs),Fn(7,Ut),Fn(8,Yd),Fn(9,eb),Fn(10,ed),Fn(11,bb)],fne);function LFe(n,e,t,i,s){if(t=t||"",!i){const r=t.indexOf(`
|
|
1647
1647
|
`);let o=t;return r!==-1&&(o=t.substring(0,r)),q0e(n,t,e.createByFilepathOrFirstLine(s||null,o),s)}return q0e(n,t,e.createById(i),s)}function q0e(n,e,t,i){return n.createModel(e,t,i)}G("multiDiffEditor.headerBackground",{dark:"#262626",light:"tab.inactiveBackground",hcDark:"tab.inactiveBackground",hcLight:"tab.inactiveBackground"},S(142,"The background color of the diff editor's header"));G("multiDiffEditor.background",pr,S(143,"The background color of the multi file diff editor"));G("multiDiffEditor.border",{dark:"sideBarSectionHeader.border",light:"#cccccc",hcDark:"sideBarSectionHeader.border",hcLight:"#cccccc"},S(144,"The border color of the multi file diff editor"));var AWt=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},K0e=function(n,e){return function(t,i){e(t,i,n)}};class MWt{constructor(e,t){this.viewModel=e,this.deltaScrollVertical=t}getId(){return this.viewModel}}let gne=class extends ie{constructor(e,t,i,s,r){super(),this._container=e,this._overflowWidgetsDomNode=t,this._workbenchUIElementFactory=i,this._instantiationService=s,this._viewModel=Et(this,void 0),this._collapsed=me(this,l=>{var c;return(c=this._viewModel.read(l))==null?void 0:c.collapsed.read(l)}),this._editorContentHeight=Et(this,500),this.contentHeight=me(this,l=>(this._collapsed.read(l)?0:this._editorContentHeight.read(l))+this._outerEditorHeight),this._modifiedContentWidth=Et(this,0),this._modifiedWidth=Et(this,0),this._originalContentWidth=Et(this,0),this._originalWidth=Et(this,0),this.maxScroll=me(this,l=>{const c=this._modifiedContentWidth.read(l)-this._modifiedWidth.read(l),d=this._originalContentWidth.read(l)-this._originalWidth.read(l);return c>d?{maxScroll:c,width:this._modifiedWidth.read(l)}:{maxScroll:d,width:this._originalWidth.read(l)}}),this._elements=Di("div.multiDiffEntry",[Di("div.header@header",[Di("div.header-content",[Di("div.collapse-button@collapseButton"),Di("div.file-path",[Di("div.title.modified.show-file-icons@primaryPath",[]),Di("div.status.deleted@status",["R"]),Di("div.title.original.show-file-icons@secondaryPath",[])]),Di("div.actions@actions")])]),Di("div.editorParent",[Di("div.editorContainer@editor")])]),this.editor=this._register(this._instantiationService.createInstance(Tp,this._elements.editor,{overflowWidgetsDomNode:this._overflowWidgetsDomNode,fixedOverflowWidgets:!0},{})),this.isModifedFocused=Ss(this.editor.getModifiedEditor()).isFocused,this.isOriginalFocused=Ss(this.editor.getOriginalEditor()).isFocused,this.isFocused=me(this,l=>this.isModifedFocused.read(l)||this.isOriginalFocused.read(l)),this._resourceLabel=this._workbenchUIElementFactory.createResourceLabel?this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.primaryPath)):void 0,this._resourceLabel2=this._workbenchUIElementFactory.createResourceLabel?this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.secondaryPath)):void 0,this._dataStore=this._register(new ge),this._headerHeight=40,this._lastScrollTop=-1,this._isSettingScrollTop=!1;const o=new L9(this._elements.collapseButton,{});this._register(Ct(l=>{o.element.className="",o.icon=this._collapsed.read(l)?ye.chevronRight:ye.chevronDown})),this._register(o.onDidClick(()=>{var l;(l=this._viewModel.get())==null||l.collapsed.set(!this._collapsed.get(),void 0)})),this._register(Ct(l=>{this._elements.editor.style.display=this._collapsed.read(l)?"none":"block"})),this._register(this.editor.getModifiedEditor().onDidLayoutChange(l=>{const c=this.editor.getModifiedEditor().getLayoutInfo().contentWidth;this._modifiedWidth.set(c,void 0)})),this._register(this.editor.getOriginalEditor().onDidLayoutChange(l=>{const c=this.editor.getOriginalEditor().getLayoutInfo().contentWidth;this._originalWidth.set(c,void 0)})),this._register(this.editor.onDidContentSizeChange(l=>{hI(c=>{this._editorContentHeight.set(l.contentHeight,c),this._modifiedContentWidth.set(this.editor.getModifiedEditor().getContentWidth(),c),this._originalContentWidth.set(this.editor.getOriginalEditor().getContentWidth(),c)})})),this._register(this.editor.getOriginalEditor().onDidScrollChange(l=>{if(this._isSettingScrollTop||!l.scrollTopChanged||!this._data)return;const c=l.scrollTop-this._lastScrollTop;this._data.deltaScrollVertical(c)})),this._register(Ct(l=>{var d;const c=(d=this._viewModel.read(l))==null?void 0:d.isActive.read(l);this._elements.root.classList.toggle("active",c)})),this._container.appendChild(this._elements.root),this._outerEditorHeight=this._headerHeight,this._contextKeyService=this._register(r.createScoped(this._elements.actions));const a=this._register(this._instantiationService.createChild(new dN([Dt,this._contextKeyService])));this._register(a.createInstance(pA,this._elements.actions,Je.MultiDiffEditorFileToolbar,{actionRunner:this._register(new fPe(()=>{var l,c;return((l=this._viewModel.get())==null?void 0:l.modifiedUri)??((c=this._viewModel.get())==null?void 0:c.originalUri)})),menuOptions:{shouldForwardArgs:!0},toolbarOptions:{primaryGroup:l=>l.startsWith("navigation")},actionViewItemProvider:(l,c)=>_le(a,l,c)}))}setScrollLeft(e){this._modifiedContentWidth.get()-this._modifiedWidth.get()>this._originalContentWidth.get()-this._originalWidth.get()?this.editor.getModifiedEditor().setScrollLeft(e):this.editor.getOriginalEditor().setScrollLeft(e)}setData(e){this._data=e;function t(s){return{...s,scrollBeyondLastLine:!1,hideUnchangedRegions:{enabled:!0},scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1,useShadows:!1},renderOverviewRuler:!1,fixedOverflowWidgets:!0,overviewRulerBorder:!1}}if(!e){hI(s=>{this._viewModel.set(void 0,s),this.editor.setDiffModel(null,s),this._dataStore.clear()});return}const i=e.viewModel.documentDiffItem;if(hI(s=>{var c,d;(c=this._resourceLabel)==null||c.setUri(e.viewModel.modifiedUri??e.viewModel.originalUri,{strikethrough:e.viewModel.modifiedUri===void 0});let r=!1,o=!1,a=!1,l="";e.viewModel.modifiedUri&&e.viewModel.originalUri&&e.viewModel.modifiedUri.path!==e.viewModel.originalUri.path?(l="R",r=!0):e.viewModel.modifiedUri?e.viewModel.originalUri||(l="A",a=!0):(l="D",o=!0),this._elements.status.classList.toggle("renamed",r),this._elements.status.classList.toggle("deleted",o),this._elements.status.classList.toggle("added",a),this._elements.status.innerText=l,(d=this._resourceLabel2)==null||d.setUri(r?e.viewModel.originalUri:void 0,{strikethrough:!0}),this._dataStore.clear(),this._viewModel.set(e.viewModel,s),this.editor.setDiffModel(e.viewModel.diffEditorViewModelRef,s),this.editor.updateOptions(t(i.options??{}))}),i.onOptionsDidChange&&this._dataStore.add(i.onOptionsDidChange(()=>{this.editor.updateOptions(t(i.options??{}))})),e.viewModel.isAlive.recomputeInitiallyAndOnChange(this._dataStore,s=>{s||this.setData(void 0)}),e.viewModel.documentDiffItem.contextKeys)for(const[s,r]of Object.entries(e.viewModel.documentDiffItem.contextKeys))this._contextKeyService.createKey(s,r)}render(e,t,i,s){this._elements.root.style.visibility="visible",this._elements.root.style.top=`${e.start}px`,this._elements.root.style.height=`${e.length}px`,this._elements.root.style.width=`${t}px`,this._elements.root.style.position="absolute";const r=e.length-this._headerHeight,o=Math.max(0,Math.min(s.start-e.start,r));this._elements.header.style.transform=`translateY(${o}px)`,hI(a=>{this.editor.layout({width:t-16-2,height:e.length-this._outerEditorHeight})});try{this._isSettingScrollTop=!0,this._lastScrollTop=i,this.editor.getOriginalEditor().setScrollTop(i)}finally{this._isSettingScrollTop=!1}this._elements.header.classList.toggle("shadow",o>0||i>0),this._elements.header.classList.toggle("collapsed",o===r)}hide(){this._elements.root.style.top="-100000px",this._elements.root.style.visibility="hidden"}};gne=AWt([K0e(3,st),K0e(4,Dt)],gne);class OWt{constructor(e){this._create=e,this._unused=new Set,this._used=new Set,this._itemData=new Map}getUnusedObj(e){let t;if(this._unused.size===0)t=this._create(e),this._itemData.set(t,e);else{const i=[...this._unused.values()];t=i.find(s=>this._itemData.get(s).getId()===e.getId())??i[0],this._unused.delete(t),this._itemData.set(t,e),t.setData(e)}return this._used.add(t),{object:t,dispose:()=>{this._used.delete(t),this._unused.size>5?t.dispose():this._unused.add(t)}}}dispose(){for(const e of this._used)e.dispose();for(const e of this._unused)e.dispose();this._used.clear(),this._unused.clear()}}var PWt=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},Z0e=function(n,e){return function(t,i){e(t,i,n)}};let pne=class extends ie{constructor(e,t,i,s,r,o){super(),this._element=e,this._dimension=t,this._viewModel=i,this._workbenchUIElementFactory=s,this._parentContextKeyService=r,this._parentInstantiationService=o,this._scrollableElements=Di("div.scrollContent",[Di("div@content",{style:{overflow:"hidden"}}),Di("div.monaco-editor@overflowWidgetsDomNode",{})]),this._scrollable=this._register(new lN({forceIntegerValues:!1,scheduleAtNextAnimationFrame:c=>dc(ot(this._element),c),smoothScrollDuration:100})),this._scrollableElement=this._register(new QB(this._scrollableElements.root,{vertical:1,horizontal:1,useShadows:!1},this._scrollable)),this._elements=Di("div.monaco-component.multiDiffEditor",{},[Di("div",{},[this._scrollableElement.getDomNode()]),Di("div.placeholder@placeholder",{},[Di("div")])]),this._sizeObserver=this._register(new qOe(this._element,void 0)),this._objectPool=this._register(new OWt(c=>{const d=this._instantiationService.createInstance(gne,this._scrollableElements.content,this._scrollableElements.overflowWidgetsDomNode,this._workbenchUIElementFactory);return d.setData(c),d})),this.scrollTop=Wi(this,this._scrollableElement.onScroll,()=>this._scrollableElement.getScrollPosition().scrollTop),this.scrollLeft=Wi(this,this._scrollableElement.onScroll,()=>this._scrollableElement.getScrollPosition().scrollLeft),this._viewItemsInfo=me(this,c=>{const d=this._viewModel.read(c);if(!d)return{items:[],getItem:m=>{throw new ft}};const u=d.items.read(c),h=new Map;return{items:u.map(m=>{var C;const b=c.store.add(new jWt(m,this._objectPool,this.scrollLeft,y=>{this._scrollableElement.setScrollPosition({scrollTop:this._scrollableElement.getScrollPosition().scrollTop+y})})),v=(C=this._lastDocStates)==null?void 0:C[b.getKey()];return v&&jn(y=>{b.setViewState(v,y)}),h.set(m,b),b}),getItem:m=>h.get(m)}}),this._viewItems=this._viewItemsInfo.map(this,c=>c.items),this._spaceBetweenPx=0,this._totalHeight=this._viewItems.map(this,(c,d)=>c.reduce((u,h)=>u+h.contentHeight.read(d)+this._spaceBetweenPx,0)),this.activeControl=me(this,c=>{var h,g;const d=(h=this._viewModel.read(c))==null?void 0:h.activeDiffItem.read(c);return d?(g=this._viewItemsInfo.read(c).getItem(d).template.read(c))==null?void 0:g.editor:void 0}),this._contextKeyService=this._register(this._parentContextKeyService.createScoped(this._element)),this._instantiationService=this._register(this._parentInstantiationService.createChild(new dN([Dt,this._contextKeyService]))),this._contextKeyService.createKey(q.inMultiDiffEditor.key,!0),this._lastDocStates={},this._register(Aa((c,d)=>{const u=this._viewModel.read(c);if(u&&u.contextKeys)for(const[h,g]of Object.entries(u.contextKeys)){const m=this._contextKeyService.createKey(h,void 0);m.set(g),d.add(et(()=>m.reset()))}}));const a=this._parentContextKeyService.createKey(q.multiDiffEditorAllCollapsed.key,!1);this._register(Ct(c=>{const d=this._viewModel.read(c);if(d){const u=d.items.read(c).every(h=>h.collapsed.read(c));a.set(u)}})),this._register(Ct(c=>{const d=this._dimension.read(c);this._sizeObserver.observe(d)}));const l=me(c=>{if(this._viewItems.read(c).length>0)return;const u=this._viewModel.read(c);return!u||u.isLoading.read(c)?S(145,"Loading..."):S(146,"No Changed Files")});this._register(Ct(c=>{const d=l.read(c);this._elements.placeholder.innerText=d??"",this._elements.placeholder.classList.toggle("visible",!!d)})),this._scrollableElements.content.style.position="relative",this._register(Ct(c=>{const d=this._sizeObserver.height.read(c);this._scrollableElements.root.style.height=`${d}px`;const u=this._totalHeight.read(c);this._scrollableElements.content.style.height=`${u}px`;const h=this._sizeObserver.width.read(c);let g=h;const m=this._viewItems.read(c),b=bae(m,fa(v=>v.maxScroll.read(c).maxScroll,Fc));if(b){const v=b.maxScroll.read(c);g=h+v.maxScroll}this._scrollableElement.setScrollDimensions({width:h,height:d,scrollHeight:u,scrollWidth:g})})),e.replaceChildren(this._elements.root),this._register(et(()=>{e.replaceChildren()})),this._register(Ct(c=>{const d=this._viewModel.read(c);if(d&&!d.isLoading.read(c)){if(d.items.read(c).length===0||d.activeDiffItem.read(c))return;this.goToNextChange()}})),this._register(this._register(Ct(c=>{hI(d=>{this.render(c)})})))}reveal(e,t){var c;const i=this._viewItems.get(),s=i.findIndex(d=>{var u,h,g,m;return((u=d.viewModel.originalUri)==null?void 0:u.toString())===((h=e.original)==null?void 0:h.toString())&&((g=d.viewModel.modifiedUri)==null?void 0:g.toString())===((m=e.modified)==null?void 0:m.toString())});if(s===-1)throw new ft("Resource not found in diff editor");const r=i[s];this._viewModel.get().activeDiffItem.setCache(r.viewModel,void 0);let o=0;for(let d=0;d<s;d++)o+=i[d].contentHeight.get()+this._spaceBetweenPx;this._scrollableElement.setScrollPosition({scrollTop:o});const a=(c=r.template.get())==null?void 0:c.editor,l="original"in e?a==null?void 0:a.getOriginalEditor():a==null?void 0:a.getModifiedEditor();l&&(t!=null&&t.range)&&(l.revealRangeInCenter(t.range),FWt(l,t.range))}goToNextChange(){this._navigateToChange("next")}_navigateToChange(e){var l,c,d,u,h;const t=this._viewItems.get();if(t.length===0)return;const i=(l=this._viewModel.get())==null?void 0:l.activeDiffItem.get(),s=i?t.findIndex(g=>g.viewModel===i):-1;if(s===-1){this._goToFile(0,"first");return}const r=t[s];r.viewModel.collapsed.get()&&r.viewModel.collapsed.set(!1,void 0);const o=(c=r.template.get())==null?void 0:c.editor;if((u=(d=o==null?void 0:o.getDiffComputationResult())==null?void 0:d.changes2)!=null&&u.length){const g=((h=o.getModifiedEditor().getPosition())==null?void 0:h.lineNumber)||1,m=o.getDiffComputationResult().changes2;if(e==="next"?m.some(v=>v.modified.startLineNumber>g):m.some(v=>v.modified.endLineNumberExclusive<=g)){o.goToDiff(e);return}}const a=(s+(e==="next"?1:-1)+t.length)%t.length;this._goToFile(a,e==="next"?"first":"last")}_goToFile(e,t){var r,o,a;const i=this._viewItems.get()[e];i.viewModel.collapsed.get()&&i.viewModel.collapsed.set(!1,void 0),this.reveal({original:i.viewModel.originalUri,modified:i.viewModel.modifiedUri});const s=(r=i.template.get())==null?void 0:r.editor;if((a=(o=s==null?void 0:s.getDiffComputationResult())==null?void 0:o.changes2)!=null&&a.length)if(t==="first")s.revealFirstDiff();else{const l=s.getDiffComputationResult().changes2.at(-1),c=s.getModifiedEditor();c.setPosition({lineNumber:l.modified.startLineNumber,column:1}),c.revealLineInCenter(l.modified.startLineNumber)}s==null||s.focus()}render(e){const t=this.scrollTop.read(e);let i=0,s=0,r=0;const o=this._sizeObserver.height.read(e),a=it.ofStartAndLength(t,o),l=this._sizeObserver.width.read(e);for(const c of this._viewItems.read(e)){const d=c.contentHeight.read(e),u=Math.min(d,o),h=it.ofStartAndLength(s,u),g=it.ofStartAndLength(r,d);if(g.isBefore(a))i-=d-u,c.hide();else if(g.isAfter(a))c.hide();else{const m=Math.max(0,Math.min(a.start-g.start,d-u));i-=m;const b=it.ofStartAndLength(t+i,o);c.render(h,m,l,b)}s+=u+this._spaceBetweenPx,r+=d+this._spaceBetweenPx}this._scrollableElements.content.style.transform=`translateY(${-(t+i)}px)`}};pne=PWt([Z0e(4,Dt),Z0e(5,st)],pne);function FWt(n,e){const t=n.getModel(),i=n.createDecorationsCollection([{range:e,options:{description:"symbol-navigate-action-highlight",className:"symbolHighlight"}}]);setTimeout(()=>{n.getModel()===t&&i.clear()},350)}class jWt extends ie{constructor(e,t,i,s){super(),this.viewModel=e,this._objectPool=t,this._scrollLeft=i,this._deltaScrollVertical=s,this._templateRef=this._register(Moe(this,void 0)),this.contentHeight=me(this,r=>{var o,a;return((a=(o=this._templateRef.read(r))==null?void 0:o.object.contentHeight)==null?void 0:a.read(r))??this.viewModel.lastTemplateData.read(r).contentHeight}),this.maxScroll=me(this,r=>{var o;return((o=this._templateRef.read(r))==null?void 0:o.object.maxScroll.read(r))??{maxScroll:0,scrollWidth:0}}),this.template=me(this,r=>{var o;return(o=this._templateRef.read(r))==null?void 0:o.object}),this._isHidden=Et(this,!1),this._isFocused=me(this,r=>{var o;return((o=this.template.read(r))==null?void 0:o.isFocused.read(r))??!1}),this.viewModel.setIsFocused(this._isFocused,void 0),this._register(Ct(r=>{var a;const o=this._scrollLeft.read(r);(a=this._templateRef.read(r))==null||a.object.setScrollLeft(o)})),this._register(Ct(r=>{const o=this._templateRef.read(r);!o||!this._isHidden.read(r)||o.object.isFocused.read(r)||this._clear()}))}dispose(){this._clear(),super.dispose()}toString(){var e;return`VirtualViewItem(${(e=this.viewModel.documentDiffItem.modified)==null?void 0:e.uri.toString()})`}getKey(){return this.viewModel.getKey()}setViewState(e,t){var o;this.viewModel.collapsed.set(e.collapsed,t),this._updateTemplateData(t);const i=this.viewModel.lastTemplateData.get(),s=(o=e.selections)==null?void 0:o.map(qe.liftSelection);this.viewModel.lastTemplateData.set({...i,selections:s},t);const r=this._templateRef.get();r&&s&&r.object.editor.setSelections(s)}_updateTemplateData(e){const t=this._templateRef.get();t&&this.viewModel.lastTemplateData.set({contentHeight:t.object.contentHeight.get(),selections:t.object.editor.getSelections()??void 0},e)}_clear(){const e=this._templateRef.get();e&&jn(t=>{this._updateTemplateData(t),e.object.hide(),this._templateRef.set(void 0,t)})}hide(){this._isHidden.set(!0,void 0)}render(e,t,i,s){this._isHidden.set(!1,void 0);let r=this._templateRef.get();if(!r){r=this._objectPool.getUnusedObj(new MWt(this.viewModel,this._deltaScrollVertical)),this._templateRef.set(r,void 0);const o=this.viewModel.lastTemplateData.get().selections;o&&r.object.editor.setSelections(o)}r.object.render(e,i,t,s)}}var HWt=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},BWt=function(n,e){return function(t,i){e(t,i,n)}};let mne=class extends ie{constructor(e,t,i){super(),this._element=e,this._workbenchUIElementFactory=t,this._instantiationService=i,this._dimension=Et(this,void 0),this._viewModel=Et(this,void 0),this._widgetImpl=me(this,s=>s.store.add(this._instantiationService.createInstance(km(pne),this._element,this._dimension,this._viewModel,this._workbenchUIElementFactory))),this._register($D(this._widgetImpl))}};mne=HWt([BWt(2,st)],mne);function VWt(n,e,t){return kt.initialize(t||{}).createInstance(hne,n,e)}function WWt(n){return kt.get(Ni).onCodeEditorAdd(t=>{n(t)})}function zWt(n){return kt.get(Ni).onDiffEditorAdd(t=>{n(t)})}function UWt(){return kt.get(Ni).listCodeEditors()}function $Wt(){return kt.get(Ni).listDiffEditors()}function GWt(n,e,t){return kt.initialize(t||{}).createInstance(fne,n,e)}function qWt(n,e){const t=kt.initialize(e||{});return new mne(n,{},t)}function KWt(n){if(typeof n.id!="string"||typeof n.run!="function")throw new Error("Invalid command descriptor, `id` and `run` are required properties!");return wi.registerCommand(n.id,n.run)}function ZWt(n){if(typeof n.id!="string"||typeof n.label!="string"||typeof n.run!="function")throw new Error("Invalid action descriptor, `id`, `label` and `run` are required properties!");const e=ve.deserialize(n.precondition),t=(s,...r)=>so.runEditorCommand(s,r,e,(o,a,l)=>Promise.resolve(n.run(a,...l))),i=new ge;if(i.add(wi.registerCommand(n.id,t)),n.contextMenuGroupId){const s={command:{id:n.id,title:n.label},when:e,group:n.contextMenuGroupId,order:n.contextMenuOrder||0};i.add(No.appendMenuItem(Je.EditorContext,s))}if(Array.isArray(n.keybindings)){const s=kt.get(Mi);if(!(s instanceof LR))console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService");else{const r=ve.and(e,ve.deserialize(n.keybindingContext));i.add(s.addDynamicKeybindings(n.keybindings.map(o=>({keybinding:o,command:n.id,when:r}))))}}return i}function YWt(n){return EFe([n])}function EFe(n){const e=kt.get(Mi);return e instanceof LR?e.addDynamicKeybindings(n.map(t=>({keybinding:t.keybinding,command:t.command,commandArgs:t.commandArgs,when:ve.deserialize(t.when)}))):(console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"),ie.None)}function XWt(n,e,t){const i=kt.get(Gs),s=i.getLanguageIdByMimeType(e)||e;return LFe(kt.get(xs),i,n,s,t)}function QWt(n,e){const t=kt.get(Gs),i=t.getLanguageIdByMimeType(e)||e||Hd;n.setLanguage(t.createById(i))}function JWt(n,e,t){n&&kt.get(Gp).changeOne(e,n.uri,t)}function ezt(n){kt.get(Gp).changeAll(n,[])}function tzt(n){return kt.get(Gp).read(n)}function izt(n){return kt.get(Gp).onMarkerChanged(n)}function nzt(n){return kt.get(xs).getModel(n)}function szt(){return kt.get(xs).getModels()}function rzt(n){return kt.get(xs).onModelAdded(n)}function ozt(n){return kt.get(xs).onModelRemoved(n)}function azt(n){return kt.get(xs).onModelLanguageChanged(t=>{n({model:t.model,oldLanguage:t.oldLanguageId})})}function lzt(n){return gBt(kt.get(xs),n)}function czt(n,e){const t=kt.get(Gs),i=kt.get(Xd);return $ce.colorizeElement(i,t,n,e).then(()=>{i.registerEditorContainer(n)})}function dzt(n,e,t){const i=kt.get(Gs);return kt.get(Xd).registerEditorContainer(dn.document.body),$ce.colorize(i,n,e,t)}function uzt(n,e,t=4){return kt.get(Xd).registerEditorContainer(dn.document.body),$ce.colorizeModelLine(n,e,t)}function hzt(n){const e=Vs.get(n);return e||{getInitialState:()=>rR,tokenize:(t,i,s)=>Fae(n,s)}}function fzt(n,e){Vs.getOrCreate(e);const t=hzt(e),i=Xc(n),s=[];let r=t.getInitialState();for(let o=0,a=i.length;o<a;o++){const l=i[o],c=t.tokenize(l,!0,r);s[o]=c.tokens,r=c.endState}return s}function gzt(n,e){kt.get(Xd).defineTheme(n,e)}function pzt(n){kt.get(Xd).setTheme(n)}function mzt(){JZ.clearAllFontInfos()}function _zt(n,e){return wi.registerCommand({id:n,handler:e})}function bzt(n){return kt.get(wb).registerOpener({async open(t){return typeof t=="string"&&(t=ut.parse(t)),n.open(t)}})}function vzt(n){return kt.get(Ni).registerCodeEditorOpenHandler(async(t,i,s)=>{var a;if(!i)return null;const r=(a=t.options)==null?void 0:a.selection;let o;return r&&typeof r.endLineNumber=="number"&&typeof r.endColumn=="number"?o=r:r&&(o={lineNumber:r.startLineNumber,column:r.startColumn}),await n.openCodeEditor(i,t.resource,o)?i:null})}function Czt(){return{create:VWt,getEditors:UWt,getDiffEditors:$Wt,onDidCreateEditor:WWt,onDidCreateDiffEditor:zWt,createDiffEditor:GWt,addCommand:KWt,addEditorAction:ZWt,addKeybindingRule:YWt,addKeybindingRules:EFe,createModel:XWt,setModelLanguage:QWt,setModelMarkers:JWt,getModelMarkers:tzt,removeAllMarkers:ezt,onDidChangeMarkers:izt,getModels:szt,getModel:nzt,onDidCreateModel:rzt,onWillDisposeModel:ozt,onDidChangeModelLanguage:azt,createWebWorker:lzt,colorizeElement:czt,colorize:dzt,colorizeModelLine:uzt,tokenize:fzt,defineTheme:gzt,setTheme:pzt,remeasureFonts:mzt,registerCommand:_zt,registerLinkOpener:bzt,registerEditorOpener:vzt,AccessibilitySupport:hte,ContentWidgetPositionPreference:bte,CursorChangeReason:vte,DefaultEndOfLine:Cte,EditorAutoIndentStrategy:yte,EditorOption:Ste,EndOfLinePreference:xte,EndOfLineSequence:Lte,MinimapPosition:Fte,MinimapSectionHeaderStyle:jte,MouseTargetType:Hte,OverlayWidgetPositionPreference:Wte,OverviewRulerLane:zte,GlyphMarginLane:Ete,RenderLineNumbersType:Gte,RenderMinimap:qte,ScrollbarVisibility:Zte,ScrollType:Kte,TextEditorCursorBlinkingStyle:iie,TextEditorCursorStyle:nie,TrackedRangeStickiness:sie,WrappingIndent:rie,InjectedTextCursorStops:Nte,PositionAffinity:$te,ShowLightbulbIconMode:Xte,TextDirection:tie,ConfigurationChangedEvent:rAe,BareFontInfo:aS,FontInfo:y8,TextModelResolvedOptions:S5,FindMatch:k2,ApplyUpdateResult:zI,EditorZoom:Du,createMultiFileDiffEditor:qWt,EditorType:hO,EditorOptions:Qa}}function wzt(n,e){if(!e||!Array.isArray(e))return!1;for(const t of e)if(!n(t))return!1;return!0}function $3(n,e){return typeof n=="boolean"?n:e}function Y0e(n,e){return typeof n=="string"?n:e}function yzt(n){const e={};for(const t of n)e[t]=!0;return e}function X0e(n,e=!1){e&&(n=n.map(function(i){return i.toLowerCase()}));const t=yzt(n);return e?function(i){return t[i.toLowerCase()]!==void 0&&t.hasOwnProperty(i.toLowerCase())}:function(i){return t[i]!==void 0&&t.hasOwnProperty(i)}}function _ne(n,e,t){e=e.replace(/@@/g,"");let i=0,s;do s=!1,e=e.replace(/@(\w+)/g,function(o,a){s=!0;let l="";if(typeof n[a]=="string")l=n[a];else if(n[a]&&n[a]instanceof RegExp)l=n[a].source;else throw n[a]===void 0?os(n,"language definition does not contain attribute '"+a+"', used at: "+e):os(n,"attribute reference '"+a+"' must be a string, used at: "+e);return Uw(l)?"":"(?:"+l+")"}),i++;while(s&&i<5);e=e.replace(/\x01/g,"@");const r=(n.ignoreCase?"i":"")+(n.unicode?"u":"");if(t&&e.match(/\$[sS](\d\d?)/g)){let a=null,l=null;return c=>(l&&a===c||(a=c,l=new RegExp(vBt(n,e,c),r)),l)}return new RegExp(e,r)}function Szt(n,e,t,i){if(i<0)return n;if(i<e.length)return e[i];if(i>=100){i=i-100;const s=t.split(".");if(s.unshift(t),i<s.length)return s[i]}return null}function xzt(n,e,t,i){let s=-1,r=t,o=t.match(/^\$(([sS]?)(\d\d?)|#)(.*)$/);o&&(o[3]&&(s=parseInt(o[3]),o[2]&&(s=s+100)),r=o[4]);let a="~",l=r;!r||r.length===0?(a="!=",l=""):/^\w*$/.test(l)?a="==":(o=r.match(/^(@|!@|~|!~|==|!=)(.*)$/),o&&(a=o[1],l=o[2]));let c;if((a==="~"||a==="!~")&&/^(\w|\|)*$/.test(l)){const d=X0e(l.split("|"),n.ignoreCase);c=function(u){return a==="~"?d(u):!d(u)}}else if(a==="@"||a==="!@"){const d=n[l];if(!d)throw os(n,"the @ match target '"+l+"' is not defined, in rule: "+e);if(!wzt(function(h){return typeof h=="string"},d))throw os(n,"the @ match target '"+l+"' must be an array of strings, in rule: "+e);const u=X0e(d,n.ignoreCase);c=function(h){return a==="@"?u(h):!u(h)}}else if(a==="~"||a==="!~")if(l.indexOf("$")<0){const d=_ne(n,"^"+l+"$",!1);c=function(u){return a==="~"?d.test(u):!d.test(u)}}else c=function(d,u,h,g){return _ne(n,"^"+kv(n,l,u,h,g)+"$",!1).test(d)};else if(l.indexOf("$")<0){const d=P_(n,l);c=function(u){return a==="=="?u===d:u!==d}}else{const d=P_(n,l);c=function(u,h,g,m,b){const v=kv(n,d,h,g,m);return a==="=="?u===v:u!==v}}return s===-1?{name:t,value:i,test:function(d,u,h,g){return c(d,d,u,h,g)}}:{name:t,value:i,test:function(d,u,h,g){const m=Szt(d,u,h,s);return c(m||"",d,u,h,g)}}}function bne(n,e,t){if(t){if(typeof t=="string")return t;if(t.token||t.token===""){if(typeof t.token!="string")throw os(n,"a 'token' attribute must be of type string, in rule: "+e);{const i={token:t.token};if(t.token.indexOf("$")>=0&&(i.tokenSubst=!0),typeof t.bracket=="string")if(t.bracket==="@open")i.bracket=1;else if(t.bracket==="@close")i.bracket=-1;else throw os(n,"a 'bracket' attribute must be either '@open' or '@close', in rule: "+e);if(t.next){if(typeof t.next!="string")throw os(n,"the next state must be a string value in rule: "+e);{let s=t.next;if(!/^(@pop|@push|@popall)$/.test(s)&&(s[0]==="@"&&(s=s.substr(1)),s.indexOf("$")<0&&!CBt(n,kv(n,s,"",[],""))))throw os(n,"the next state '"+t.next+"' is not defined in rule: "+e);i.next=s}}return typeof t.goBack=="number"&&(i.goBack=t.goBack),typeof t.switchTo=="string"&&(i.switchTo=t.switchTo),typeof t.log=="string"&&(i.log=t.log),typeof t.nextEmbedded=="string"&&(i.nextEmbedded=t.nextEmbedded,n.usesEmbedded=!0),i}}else if(Array.isArray(t)){const i=[];for(let s=0,r=t.length;s<r;s++)i[s]=bne(n,e,t[s]);return{group:i}}else if(t.cases){const i=[];let s=!1;for(const o in t.cases)if(t.cases.hasOwnProperty(o)){const a=bne(n,e,t.cases[o]);o==="@default"||o==="@"||o===""?i.push({test:void 0,value:a,name:o}):o==="@eos"?i.push({test:function(l,c,d,u){return u},value:a,name:o}):i.push(xzt(n,e,o,a)),s||(s=!po(a)&&(a.hasEmbeddedEndInCases||["@pop","@popall"].includes(a.nextEmbedded||"")))}const r=n.defaultToken;return{hasEmbeddedEndInCases:s,test:function(o,a,l,c){for(const d of i)if(!d.test||d.test(o,a,l,c))return d.value;return r}}}else throw os(n,"an action must be a string, an object with a 'token' or 'cases' attribute, or an array of actions; in rule: "+e)}else return{token:""}}class Lzt{constructor(e){this.regex=new RegExp(""),this.action={token:""},this.matchOnlyAtLineStart=!1,this.name="",this.name=e}setRegex(e,t){let i;if(typeof t=="string")i=t;else if(t instanceof RegExp)i=t.source;else throw os(e,"rules must start with a match string or regular expression: "+this.name);this.matchOnlyAtLineStart=i.length>0&&i[0]==="^",this.name=this.name+": "+i,this.regex=_ne(e,"^(?:"+(this.matchOnlyAtLineStart?i.substr(1):i)+")",!0)}setAction(e,t){this.action=bne(e,this.name,t)}resolveRegex(e){return this.regex instanceof RegExp?this.regex:this.regex(e)}}function DFe(n,e){if(!e||typeof e!="object")throw new Error("Monarch: expecting a language definition object");const t={languageId:n,includeLF:$3(e.includeLF,!1),noThrow:!1,maxStack:100,start:typeof e.start=="string"?e.start:null,ignoreCase:$3(e.ignoreCase,!1),unicode:$3(e.unicode,!1),tokenPostfix:Y0e(e.tokenPostfix,"."+n),defaultToken:Y0e(e.defaultToken,"source"),usesEmbedded:!1,stateNames:{},tokenizer:{},brackets:[]},i=e;i.languageId=n,i.includeLF=t.includeLF,i.ignoreCase=t.ignoreCase,i.unicode=t.unicode,i.noThrow=t.noThrow,i.usesEmbedded=t.usesEmbedded,i.stateNames=e.tokenizer,i.defaultToken=t.defaultToken;function s(o,a,l){for(const c of l){let d=c.include;if(d){if(typeof d!="string")throw os(t,"an 'include' attribute must be a string at: "+o);if(d[0]==="@"&&(d=d.substr(1)),!e.tokenizer[d])throw os(t,"include target '"+d+"' is not defined at: "+o);s(o+"."+d,a,e.tokenizer[d])}else{const u=new Lzt(o);if(Array.isArray(c)&&c.length>=1&&c.length<=3)if(u.setRegex(i,c[0]),c.length>=3)if(typeof c[1]=="string")u.setAction(i,{token:c[1],next:c[2]});else if(typeof c[1]=="object"){const h=c[1];h.next=c[2],u.setAction(i,h)}else throw os(t,"a next state as the last element of a rule can only be given if the action is either an object or a string, at: "+o);else u.setAction(i,c[1]);else{if(!c.regex)throw os(t,"a rule must either be an array, or an object with a 'regex' or 'include' field at: "+o);c.name&&typeof c.name=="string"&&(u.name=c.name),c.matchOnlyAtStart&&(u.matchOnlyAtLineStart=$3(c.matchOnlyAtLineStart,!1)),u.setRegex(i,c.regex),u.setAction(i,c.action)}a.push(u)}}}if(!e.tokenizer||typeof e.tokenizer!="object")throw os(t,"a language definition must define the 'tokenizer' attribute as an object");t.tokenizer=[];for(const o in e.tokenizer)if(e.tokenizer.hasOwnProperty(o)){t.start||(t.start=o);const a=e.tokenizer[o];t.tokenizer[o]=new Array,s("tokenizer."+o,t.tokenizer[o],a)}if(t.usesEmbedded=i.usesEmbedded,e.brackets){if(!Array.isArray(e.brackets))throw os(t,"the 'brackets' attribute must be defined as an array")}else e.brackets=[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"},{open:"<",close:">",token:"delimiter.angle"}];const r=[];for(const o of e.brackets){let a=o;if(a&&Array.isArray(a)&&a.length===3&&(a={token:a[2],open:a[0],close:a[1]}),a.open===a.close)throw os(t,"open and close brackets in a 'brackets' attribute must be different: "+a.open+`
|
|
1648
|
-
hint: use the 'bracket' attribute if matching on equal brackets is required.`);if(typeof a.open=="string"&&typeof a.token=="string"&&typeof a.close=="string")r.push({token:a.token+t.tokenPostfix,open:P_(t,a.open),close:P_(t,a.close)});else throw os(t,"every element in the 'brackets' array must be a '{open,close,token}' object or array")}return t.brackets=r,t.noThrow=!0,t}function Ezt(n){qD.registerLanguage(n)}function Dzt(){let n=[];return n=n.concat(qD.getLanguages()),n}function Rzt(n){return kt.get(Gs).languageIdCodec.encodeLanguageId(n)}function Nzt(n,e){return kt.withServices(()=>{const i=kt.get(Gs).onDidRequestRichLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function Tzt(n,e){return kt.withServices(()=>{const i=kt.get(Gs).onDidRequestBasicLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function Izt(n,e){if(!kt.get(Gs).isRegisteredLanguageId(n))throw new Error(`Cannot set configuration for unknown language ${n}`);return kt.get(Ls).register(n,e,100)}class kzt{constructor(e,t){this._languageId=e,this._actual=t}dispose(){}getInitialState(){return this._actual.getInitialState()}tokenize(e,t,i){if(typeof this._actual.tokenize=="function")return lM.adaptTokenize(this._languageId,this._actual,e,i);throw new Error("Not supported!")}tokenizeEncoded(e,t,i){const s=this._actual.tokenizeEncoded(e,i);return new iV(s.tokens,s.endState)}}class lM{constructor(e,t,i,s){this._languageId=e,this._actual=t,this._languageService=i,this._standaloneThemeService=s}dispose(){}getInitialState(){return this._actual.getInitialState()}static _toClassicTokens(e,t){const i=[];let s=0;for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=a.startIndex;r===0?l=0:l<s&&(l=s),i[r]=new G2(l,a.scopes,t),s=l}return i}static adaptTokenize(e,t,i,s){const r=t.tokenize(i,s),o=lM._toClassicTokens(r.tokens,e);let a;return r.endState.equals(s)?a=s:a=r.endState,new vae(o,a)}tokenize(e,t,i){return lM.adaptTokenize(this._languageId,this._actual,e,i)}_toBinaryTokens(e,t){const i=e.encodeLanguageId(this._languageId),s=this._standaloneThemeService.getColorTheme().tokenTheme,r=[];let o=0,a=0;for(let c=0,d=t.length;c<d;c++){const u=t[c],h=s.match(i,u.scopes)|1024;if(o>0&&r[o-1]===h)continue;let g=u.startIndex;c===0?g=0:g<a&&(g=a),r[o++]=g,r[o++]=h,a=g}const l=new Uint32Array(o);for(let c=0;c<o;c++)l[c]=r[c];return l}tokenizeEncoded(e,t,i){const s=this._actual.tokenize(e,i),r=this._toBinaryTokens(this._languageService.languageIdCodec,s.tokens);let o;return s.endState.equals(i)?o=i:o=s.endState,new iV(r,o)}}function Azt(n){return typeof n.getInitialState=="function"}function Mzt(n){return"tokenizeEncoded"in n}function RFe(n){return n&&typeof n.then=="function"}function Ozt(n){const e=kt.get(Xd);if(n){const t=[null];for(let i=1,s=n.length;i<s;i++)t[i]=pe.fromHex(n[i]);e.setColorMapOverride(t)}else e.setColorMapOverride(null)}function NFe(n,e){return Mzt(e)?new kzt(n,e):new lM(n,e,kt.get(Gs),kt.get(Xd))}function Xce(n,e){const t=new k0t(async()=>{const i=await Promise.resolve(e.create());return i?Azt(i)?NFe(n,i):new tM(kt.get(Gs),kt.get(Xd),n,DFe(n,i),kt.get(Ut)):null});return Vs.registerFactory(n,t)}function Pzt(n,e){if(!kt.get(Gs).isRegisteredLanguageId(n))throw new Error(`Cannot set tokens provider for unknown language ${n}`);return RFe(e)?Xce(n,{create:()=>e}):Vs.register(n,NFe(n,e))}function Fzt(n,e){const t=i=>new tM(kt.get(Gs),kt.get(Xd),n,DFe(n,i),kt.get(Ut));return RFe(e)?Xce(n,{create:()=>e}):Vs.register(n,t(e))}function jzt(n,e){return kt.get(Xe).referenceProvider.register(n,e)}function Hzt(n,e){return kt.get(Xe).renameProvider.register(n,e)}function Bzt(n,e){return kt.get(Xe).newSymbolNamesProvider.register(n,e)}function Vzt(n,e){return kt.get(Xe).signatureHelpProvider.register(n,e)}function Wzt(n,e){return kt.get(Xe).hoverProvider.register(n,{provideHover:async(i,s,r,o)=>{const a=i.getWordAtPosition(s);return Promise.resolve(e.provideHover(i,s,r,o)).then(l=>{if(l)return!l.range&&a&&(l.range=new F(s.lineNumber,a.startColumn,s.lineNumber,a.endColumn)),l.range||(l.range=new F(s.lineNumber,s.column,s.lineNumber,s.column)),l})}})}function zzt(n,e){return kt.get(Xe).documentSymbolProvider.register(n,e)}function Uzt(n,e){return kt.get(Xe).documentHighlightProvider.register(n,e)}function $zt(n,e){return kt.get(Xe).linkedEditingRangeProvider.register(n,e)}function Gzt(n,e){return kt.get(Xe).definitionProvider.register(n,e)}function qzt(n,e){return kt.get(Xe).implementationProvider.register(n,e)}function Kzt(n,e){return kt.get(Xe).typeDefinitionProvider.register(n,e)}function Zzt(n,e){return kt.get(Xe).codeLensProvider.register(n,e)}function Yzt(n,e,t){return kt.get(Xe).codeActionProvider.register(n,{providedCodeActionKinds:t==null?void 0:t.providedCodeActionKinds,documentation:t==null?void 0:t.documentation,provideCodeActions:(s,r,o,a)=>{const c=kt.get(Gp).read({resource:s.uri}).filter(d=>F.areIntersectingOrTouching(d,r));return e.provideCodeActions(s,r,{markers:c,only:o.only,trigger:o.trigger},a)},resolveCodeAction:e.resolveCodeAction})}function Xzt(n,e){return kt.get(Xe).documentFormattingEditProvider.register(n,e)}function Qzt(n,e){return kt.get(Xe).documentRangeFormattingEditProvider.register(n,e)}function Jzt(n,e){return kt.get(Xe).onTypeFormattingEditProvider.register(n,e)}function eUt(n,e){return kt.get(Xe).linkProvider.register(n,e)}function tUt(n,e){return kt.get(Xe).completionProvider.register(n,e)}function iUt(n,e){return kt.get(Xe).colorProvider.register(n,e)}function nUt(n,e){return kt.get(Xe).foldingRangeProvider.register(n,e)}function sUt(n,e){return kt.get(Xe).declarationProvider.register(n,e)}function rUt(n,e){return kt.get(Xe).selectionRangeProvider.register(n,e)}function oUt(n,e){return kt.get(Xe).documentSemanticTokensProvider.register(n,e)}function aUt(n,e){return kt.get(Xe).documentRangeSemanticTokensProvider.register(n,e)}function lUt(n,e){return kt.get(Xe).inlineCompletionsProvider.register(n,e)}function cUt(n,e){return kt.get(Xe).inlayHintsProvider.register(n,e)}function dUt(){return{register:Ezt,getLanguages:Dzt,onLanguage:Nzt,onLanguageEncountered:Tzt,getEncodedLanguageId:Rzt,setLanguageConfiguration:Izt,setColorMap:Ozt,registerTokensProviderFactory:Xce,setTokensProvider:Pzt,setMonarchTokensProvider:Fzt,registerReferenceProvider:jzt,registerRenameProvider:Hzt,registerNewSymbolNameProvider:Bzt,registerCompletionItemProvider:tUt,registerSignatureHelpProvider:Vzt,registerHoverProvider:Wzt,registerDocumentSymbolProvider:zzt,registerDocumentHighlightProvider:Uzt,registerLinkedEditingRangeProvider:$zt,registerDefinitionProvider:Gzt,registerImplementationProvider:qzt,registerTypeDefinitionProvider:Kzt,registerCodeLensProvider:Zzt,registerCodeActionProvider:Yzt,registerDocumentFormattingEditProvider:Xzt,registerDocumentRangeFormattingEditProvider:Qzt,registerOnTypeFormattingEditProvider:Jzt,registerLinkProvider:eUt,registerColorProvider:iUt,registerFoldingRangeProvider:nUt,registerDeclarationProvider:sUt,registerSelectionRangeProvider:rUt,registerDocumentSemanticTokensProvider:oUt,registerDocumentRangeSemanticTokensProvider:aUt,registerInlineCompletionsProvider:lUt,registerInlayHintsProvider:cUt,DocumentHighlightKind:wte,CompletionItemKind:pte,CompletionItemTag:mte,CompletionItemInsertTextRule:gte,SymbolKind:Jte,SymbolTag:eie,IndentAction:Rte,CompletionTriggerKind:_te,SignatureHelpTriggerKind:Qte,InlayHintKind:Tte,InlineCompletionTriggerKind:Ate,CodeActionTriggerType:fte,NewSymbolNameTag:Bte,NewSymbolNameTriggerKind:Vte,PartialAcceptTriggerKind:Ute,HoverVerbosityAction:Dte,InlineCompletionEndOfLifeReasonKind:Ite,InlineCompletionHintStyle:kte,FoldingRangeKind:ex,SelectedSuggestionInfo:cMe,EditDeltaInfo:sA}}Qa.wrappingIndent.defaultValue=0;Qa.glyphMargin.defaultValue=!1;Qa.autoIndent.defaultValue=3;Qa.overviewRulerLanes.defaultValue=2;AA.setFormatterSelector((n,e,t)=>Promise.resolve(n[0]));const Vl=iFe();Vl.editor=Czt();Vl.languages=dUt();const uUt=Vl.CancellationTokenSource,ER=Vl.Emitter,hUt=Vl.KeyCode,fUt=Vl.KeyMod,gUt=Vl.Position,pUt=Vl.Range,mUt=Vl.Selection,_Ut=Vl.SelectionDirection,m_=Vl.MarkerSeverity,vne=Vl.MarkerTag,bUt=Vl.Uri,vUt=Vl.Token,TFe=Vl.editor,Nt=Vl.languages,Wq=ooe(),gD=globalThis;(Wq!=null&&Wq.globalAPI||typeof gD.define=="function"&&gD.define.amd)&&(gD.monaco=Vl);typeof gD.require<"u"&&typeof gD.require.config=="function"&&gD.require.config({ignoreDuplicateModules:["vscode-languageserver-types","vscode-languageserver-types/main","vscode-languageserver-textdocument","vscode-languageserver-textdocument/main","vscode-nls","vscode-nls/vscode-nls","jsonc-parser","jsonc-parser/main","vscode-uri","vscode-uri/index","vs/basic-languages/typescript/typescript"]});const CUt=Object.freeze(Object.defineProperty({__proto__:null,CancellationTokenSource:uUt,Emitter:ER,KeyCode:hUt,KeyMod:fUt,MarkerSeverity:m_,MarkerTag:vne,Position:gUt,Range:pUt,Selection:mUt,SelectionDirection:_Ut,Token:vUt,Uri:bUt,editor:TFe,languages:Nt},Symbol.toStringTag,{value:"Module"}));let Qce=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this.options}get options(){return this._options}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setDiagnosticsOptions(e){this.setOptions(e)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Jce={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"},data:{useDefaultDataProvider:!0},format:{newlineBetweenSelectors:!0,newlineBetweenRules:!0,spaceAroundSelectorSeparator:!1,braceStyle:"collapse",maxPreserveNewLines:void 0,preserveNewLines:!0}},ede={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0,documentFormattingEdits:!0,documentRangeFormattingEdits:!0},IFe=new Qce("css",Jce,ede),kFe=new Qce("scss",Jce,ede),AFe=new Qce("less",Jce,ede);function tde(){return pt(()=>import("./cssMode-SV3LkZxl.js"),__vite__mapDeps([0,1]))}Nt.onLanguage("less",()=>{tde().then(n=>n.setupMode(AFe))});Nt.onLanguage("scss",()=>{tde().then(n=>n.setupMode(kFe))});Nt.onLanguage("css",()=>{tde().then(n=>n.setupMode(IFe))});const wUt=Object.freeze(Object.defineProperty({__proto__:null,cssDefaults:IFe,lessDefaults:AFe,scssDefaults:kFe},Symbol.toStringTag,{value:"Module"}));let yUt=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get options(){return this._options}get modeConfiguration(){return this._modeConfiguration}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const SUt={tabSize:4,insertSpaces:!1,wrapLineLength:120,unformatted:'default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var',contentUnformatted:"pre",indentInnerHtml:!1,preserveNewLines:!0,maxPreserveNewLines:void 0,indentHandlebars:!1,endWithNewline:!1,extraLiners:"head, body, /html",wrapAttributes:"auto"},YV={format:SUt,suggest:{},data:{useDefaultDataProvider:!0}};function XV(n){return{completionItems:!0,hovers:!0,documentSymbols:!0,links:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,selectionRanges:!0,diagnostics:n===kk,documentFormattingEdits:n===kk,documentRangeFormattingEdits:n===kk}}const kk="html",Q0e="handlebars",J0e="razor",MFe=QV(kk,YV,XV(kk)),xUt=MFe.defaults,OFe=QV(Q0e,YV,XV(Q0e)),LUt=OFe.defaults,PFe=QV(J0e,YV,XV(J0e)),EUt=PFe.defaults;function DUt(){return pt(()=>import("./htmlMode-Dg66JQT7.js"),__vite__mapDeps([2,1]))}function QV(n,e=YV,t=XV(n)){const i=new yUt(n,e,t);let s;const r=Nt.onLanguage(n,async()=>{s=(await DUt()).setupMode(i)});return{defaults:i,dispose(){r.dispose(),s==null||s.dispose(),s=void 0}}}const RUt=Object.freeze(Object.defineProperty({__proto__:null,handlebarDefaults:LUt,handlebarLanguageService:OFe,htmlDefaults:xUt,htmlLanguageService:MFe,razorDefaults:EUt,razorLanguageService:PFe,registerHTMLLanguageService:QV},Symbol.toStringTag,{value:"Module"}));let NUt=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const TUt={validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:"warning",schemaValidation:"warning",comments:"error",trailingCommas:"error"},IUt={documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0},FFe=new NUt("json",TUt,IUt),kUt=()=>jFe().then(n=>n.getWorker());function jFe(){return pt(()=>import("./jsonMode-BYOLXHGD.js"),__vite__mapDeps([3,1]))}Nt.register({id:"json",extensions:[".json",".bowerrc",".jshintrc",".jscsrc",".eslintrc",".babelrc",".har"],aliases:["JSON","json"],mimetypes:["application/json"]});Nt.onLanguage("json",()=>{jFe().then(n=>n.setupMode(FFe))});const AUt=Object.freeze(Object.defineProperty({__proto__:null,getWorker:kUt,jsonDefaults:FFe},Symbol.toStringTag,{value:"Module"})),MUt="5.9.3";var HFe=(n=>(n[n.None=0]="None",n[n.CommonJS=1]="CommonJS",n[n.AMD=2]="AMD",n[n.UMD=3]="UMD",n[n.System=4]="System",n[n.ES2015=5]="ES2015",n[n.ESNext=99]="ESNext",n))(HFe||{}),BFe=(n=>(n[n.None=0]="None",n[n.Preserve=1]="Preserve",n[n.React=2]="React",n[n.ReactNative=3]="ReactNative",n[n.ReactJSX=4]="ReactJSX",n[n.ReactJSXDev=5]="ReactJSXDev",n))(BFe||{}),VFe=(n=>(n[n.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",n[n.LineFeed=1]="LineFeed",n))(VFe||{}),WFe=(n=>(n[n.ES3=0]="ES3",n[n.ES5=1]="ES5",n[n.ES2015=2]="ES2015",n[n.ES2016=3]="ES2016",n[n.ES2017=4]="ES2017",n[n.ES2018=5]="ES2018",n[n.ES2019=6]="ES2019",n[n.ES2020=7]="ES2020",n[n.ESNext=99]="ESNext",n[n.JSON=100]="JSON",n[n.Latest=99]="Latest",n))(WFe||{}),zFe=(n=>(n[n.Classic=1]="Classic",n[n.NodeJs=2]="NodeJs",n))(zFe||{});class UFe{constructor(e,t,i,s,r){this._onDidChange=new ER,this._onDidExtraLibsChange=new ER,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(i),this.setInlayHintsOptions(s),this.setModeConfiguration(r),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let i;if(typeof t>"u"?i=`ts:extralib-${Math.random().toString(36).substring(2,15)}`:i=t,this._extraLibs[i]&&this._extraLibs[i].content===e)return{dispose:()=>{}};let s=1;return this._removedExtraLibs[i]&&(s=this._removedExtraLibs[i]+1),this._extraLibs[i]&&(s=this._extraLibs[i].version+1),this._extraLibs[i]={content:e,version:s},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let r=this._extraLibs[i];r&&r.version===s&&(delete this._extraLibs[i],this._removedExtraLibs[i]=s,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(const t in this._extraLibs)this._removedExtraLibs[t]=this._extraLibs[t].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(const t of e){const i=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,s=t.content;let r=1;this._removedExtraLibs[i]&&(r=this._removedExtraLibs[i]+1),this._extraLibs[i]={content:s,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}}const OUt=MUt,$Fe={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},GFe=new UFe({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},$Fe),qFe=new UFe({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},$Fe),PUt=()=>JV().then(n=>n.getTypeScriptWorker()),FUt=()=>JV().then(n=>n.getJavaScriptWorker());function JV(){return pt(()=>import("./tsMode-BH2YA4LN.js"),[])}Nt.onLanguage("typescript",()=>JV().then(n=>n.setupTypeScript(GFe)));Nt.onLanguage("javascript",()=>JV().then(n=>n.setupJavaScript(qFe)));const jUt=Object.freeze(Object.defineProperty({__proto__:null,JsxEmit:BFe,ModuleKind:HFe,ModuleResolutionKind:zFe,NewLineKind:VFe,ScriptTarget:WFe,getJavaScriptWorker:FUt,getTypeScriptWorker:PUt,javascriptDefaults:qFe,typescriptDefaults:GFe,typescriptVersion:OUt},Symbol.toStringTag,{value:"Module"})),KFe={},zq={};class ide{static getOrCreate(e){return zq[e]||(zq[e]=new ide(e)),zq[e]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((t,i)=>{this._lazyLoadPromiseResolve=t,this._lazyLoadPromiseReject=i})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,KFe[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}}function vt(n){const e=n.id;KFe[e]=n,Nt.register(n);const t=ide.getOrCreate(e);Nt.registerTokensProviderFactory(e,{create:async()=>(await t.load()).language}),Nt.onLanguageEncountered(e,async()=>{const i=await t.load();Nt.setLanguageConfiguration(e,i.conf)})}vt({id:"abap",extensions:[".abap"],aliases:["abap","ABAP"],loader:()=>pt(()=>import("./abap-DLDM7-KI.js"),[])});vt({id:"apex",extensions:[".cls"],aliases:["Apex","apex"],mimetypes:["text/x-apex-source","text/x-apex"],loader:()=>pt(()=>import("./apex-DNDY2TF8.js"),[])});vt({id:"azcli",extensions:[".azcli"],aliases:["Azure CLI","azcli"],loader:()=>pt(()=>import("./azcli-Y6nb8tq_.js"),[])});vt({id:"bat",extensions:[".bat",".cmd"],aliases:["Batch","bat"],loader:()=>pt(()=>import("./bat-BwHxbl9M.js"),[])});vt({id:"bicep",extensions:[".bicep"],aliases:["Bicep"],loader:()=>pt(()=>import("./bicep-CFznDFnq.js"),[])});vt({id:"cameligo",extensions:[".mligo"],aliases:["Cameligo"],loader:()=>pt(()=>import("./cameligo-Bf6VGUru.js"),[])});vt({id:"clojure",extensions:[".clj",".cljs",".cljc",".edn"],aliases:["clojure","Clojure"],loader:()=>pt(()=>import("./clojure-Dnu-v4kV.js"),[])});vt({id:"coffeescript",extensions:[".coffee"],aliases:["CoffeeScript","coffeescript","coffee"],mimetypes:["text/x-coffeescript","text/coffeescript"],loader:()=>pt(()=>import("./coffee-Bd8akH9Z.js"),[])});vt({id:"c",extensions:[".c",".h"],aliases:["C","c"],loader:()=>pt(()=>import("./cpp-BbWJElDN.js"),[])});vt({id:"cpp",extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],aliases:["C++","Cpp","cpp"],loader:()=>pt(()=>import("./cpp-BbWJElDN.js"),[])});vt({id:"csharp",extensions:[".cs",".csx",".cake"],aliases:["C#","csharp"],loader:()=>pt(()=>import("./csharp-Co3qMtFm.js"),[])});vt({id:"csp",extensions:[".csp"],aliases:["CSP","csp"],loader:()=>pt(()=>import("./csp-D-4FJmMZ.js"),[])});vt({id:"css",extensions:[".css"],aliases:["CSS","css"],mimetypes:["text/css"],loader:()=>pt(()=>import("./css-DdJfP1eB.js"),[])});vt({id:"cypher",extensions:[".cypher",".cyp"],aliases:["Cypher","OpenCypher"],loader:()=>pt(()=>import("./cypher-cTPe9QuQ.js"),[])});vt({id:"dart",extensions:[".dart"],aliases:["Dart","dart"],mimetypes:["text/x-dart-source","text/x-dart"],loader:()=>pt(()=>import("./dart-BOtBlQCF.js"),[])});vt({id:"dockerfile",extensions:[".dockerfile"],filenames:["Dockerfile"],aliases:["Dockerfile"],loader:()=>pt(()=>import("./dockerfile-BG73LgW2.js"),[])});vt({id:"ecl",extensions:[".ecl"],aliases:["ECL","Ecl","ecl"],loader:()=>pt(()=>import("./ecl-BEgZUVRK.js"),[])});vt({id:"elixir",extensions:[".ex",".exs"],aliases:["Elixir","elixir","ex"],loader:()=>pt(()=>import("./elixir-BkW5O-1t.js"),[])});vt({id:"flow9",extensions:[".flow"],aliases:["Flow9","Flow","flow9","flow"],loader:()=>pt(()=>import("./flow9-BeJ5waoc.js"),[])});vt({id:"fsharp",extensions:[".fs",".fsi",".ml",".mli",".fsx",".fsscript"],aliases:["F#","FSharp","fsharp"],loader:()=>pt(()=>import("./fsharp-PahG7c26.js"),[])});vt({id:"freemarker2",extensions:[".ftl",".ftlh",".ftlx"],aliases:["FreeMarker2","Apache FreeMarker2"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagAutoInterpolationDollar)});vt({id:"freemarker2.tag-angle.interpolation-dollar",aliases:["FreeMarker2 (Angle/Dollar)","Apache FreeMarker2 (Angle/Dollar)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagAngleInterpolationDollar)});vt({id:"freemarker2.tag-bracket.interpolation-dollar",aliases:["FreeMarker2 (Bracket/Dollar)","Apache FreeMarker2 (Bracket/Dollar)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagBracketInterpolationDollar)});vt({id:"freemarker2.tag-angle.interpolation-bracket",aliases:["FreeMarker2 (Angle/Bracket)","Apache FreeMarker2 (Angle/Bracket)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagAngleInterpolationBracket)});vt({id:"freemarker2.tag-bracket.interpolation-bracket",aliases:["FreeMarker2 (Bracket/Bracket)","Apache FreeMarker2 (Bracket/Bracket)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagBracketInterpolationBracket)});vt({id:"freemarker2.tag-auto.interpolation-dollar",aliases:["FreeMarker2 (Auto/Dollar)","Apache FreeMarker2 (Auto/Dollar)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagAutoInterpolationDollar)});vt({id:"freemarker2.tag-auto.interpolation-bracket",aliases:["FreeMarker2 (Auto/Bracket)","Apache FreeMarker2 (Auto/Bracket)"],loader:()=>pt(()=>import("./freemarker2-CxFgQ1qv.js"),[]).then(n=>n.TagAutoInterpolationBracket)});vt({id:"go",extensions:[".go"],aliases:["Go"],loader:()=>pt(()=>import("./go-acbASCJo.js"),[])});vt({id:"graphql",extensions:[".graphql",".gql"],aliases:["GraphQL","graphql","gql"],mimetypes:["application/graphql"],loader:()=>pt(()=>import("./graphql-BxJiqAUM.js"),[])});vt({id:"handlebars",extensions:[".handlebars",".hbs"],aliases:["Handlebars","handlebars","hbs"],mimetypes:["text/x-handlebars-template"],loader:()=>pt(()=>import("./handlebars-BGKxT387.js"),[])});vt({id:"hcl",extensions:[".tf",".tfvars",".hcl"],aliases:["Terraform","tf","HCL","hcl"],loader:()=>pt(()=>import("./hcl-DtV1sZF8.js"),[])});vt({id:"html",extensions:[".html",".htm",".shtml",".xhtml",".mdoc",".jsp",".asp",".aspx",".jshtm"],aliases:["HTML","htm","html","xhtml"],mimetypes:["text/html","text/x-jshtm","text/template","text/ng-template"],loader:()=>pt(()=>import("./html-Dy2rlxNJ.js"),[])});vt({id:"ini",extensions:[".ini",".properties",".gitconfig"],filenames:["config",".gitattributes",".gitconfig",".editorconfig"],aliases:["Ini","ini"],loader:()=>pt(()=>import("./ini-Kd9XrMLS.js"),[])});vt({id:"java",extensions:[".java",".jav"],aliases:["Java","java"],mimetypes:["text/x-java-source","text/x-java"],loader:()=>pt(()=>import("./java-CXBNlu9o.js"),[])});vt({id:"javascript",extensions:[".js",".es6",".jsx",".mjs",".cjs"],firstLine:"^#!.*\\bnode",filenames:["jakefile"],aliases:["JavaScript","javascript","js"],mimetypes:["text/javascript"],loader:()=>pt(()=>import("./javascript-CJzMD2IB.js"),__vite__mapDeps([4,5]))});vt({id:"julia",extensions:[".jl"],aliases:["julia","Julia"],loader:()=>pt(()=>import("./julia-cl7-CwDS.js"),[])});vt({id:"kotlin",extensions:[".kt",".kts"],aliases:["Kotlin","kotlin"],mimetypes:["text/x-kotlin-source","text/x-kotlin"],loader:()=>pt(()=>import("./kotlin-s7OhZKlX.js"),[])});vt({id:"less",extensions:[".less"],aliases:["Less","less"],mimetypes:["text/x-less","text/less"],loader:()=>pt(()=>import("./less-9HpZscsL.js"),[])});vt({id:"lexon",extensions:[".lex"],aliases:["Lexon"],loader:()=>pt(()=>import("./lexon-OrD6JF1K.js"),[])});vt({id:"lua",extensions:[".lua"],aliases:["Lua","lua"],loader:()=>pt(()=>import("./lua-Cyyb5UIc.js"),[])});vt({id:"liquid",extensions:[".liquid",".html.liquid"],aliases:["Liquid","liquid"],mimetypes:["application/liquid"],loader:()=>pt(()=>import("./liquid-B6hlZhnN.js"),[])});vt({id:"m3",extensions:[".m3",".i3",".mg",".ig"],aliases:["Modula-3","Modula3","modula3","m3"],loader:()=>pt(()=>import("./m3-B8OfTtLu.js"),[])});vt({id:"markdown",extensions:[".md",".markdown",".mdown",".mkdn",".mkd",".mdwn",".mdtxt",".mdtext"],aliases:["Markdown","markdown"],loader:()=>pt(()=>import("./markdown-BFxVWTOG.js"),[])});vt({id:"mdx",extensions:[".mdx"],aliases:["MDX","mdx"],loader:()=>pt(()=>import("./mdx-Ct4CZHnS.js"),[])});vt({id:"mips",extensions:[".s"],aliases:["MIPS","MIPS-V"],mimetypes:["text/x-mips","text/mips","text/plaintext"],loader:()=>pt(()=>import("./mips-CiqrrVzr.js"),[])});vt({id:"msdax",extensions:[".dax",".msdax"],aliases:["DAX","MSDAX"],loader:()=>pt(()=>import("./msdax-DmeGPVcC.js"),[])});vt({id:"mysql",extensions:[],aliases:["MySQL","mysql"],loader:()=>pt(()=>import("./mysql-C_tMU-Nz.js"),[])});vt({id:"objective-c",extensions:[".m"],aliases:["Objective-C"],loader:()=>pt(()=>import("./objective-c-BDtDVThU.js"),[])});vt({id:"pascal",extensions:[".pas",".p",".pp"],aliases:["Pascal","pas"],mimetypes:["text/x-pascal-source","text/x-pascal"],loader:()=>pt(()=>import("./pascal-vHIfCaH5.js"),[])});vt({id:"pascaligo",extensions:[".ligo"],aliases:["Pascaligo","ligo"],loader:()=>pt(()=>import("./pascaligo-DtZ0uQbO.js"),[])});vt({id:"perl",extensions:[".pl",".pm"],aliases:["Perl","pl"],loader:()=>pt(()=>import("./perl-Ub6l9XKa.js"),[])});vt({id:"pgsql",extensions:[],aliases:["PostgreSQL","postgres","pg","postgre"],loader:()=>pt(()=>import("./pgsql-BlNEE0v7.js"),[])});vt({id:"php",extensions:[".php",".php4",".php5",".phtml",".ctp"],aliases:["PHP","php"],mimetypes:["application/x-php"],loader:()=>pt(()=>import("./php-BBUBE1dy.js"),[])});vt({id:"pla",extensions:[".pla"],loader:()=>pt(()=>import("./pla-DSh2-awV.js"),[])});vt({id:"postiats",extensions:[".dats",".sats",".hats"],aliases:["ATS","ATS/Postiats"],loader:()=>pt(()=>import("./postiats-CocnycG-.js"),[])});vt({id:"powerquery",extensions:[".pq",".pqm"],aliases:["PQ","M","Power Query","Power Query M"],loader:()=>pt(()=>import("./powerquery-tScXyioY.js"),[])});vt({id:"powershell",extensions:[".ps1",".psm1",".psd1"],aliases:["PowerShell","powershell","ps","ps1"],loader:()=>pt(()=>import("./powershell-COWaemsV.js"),[])});vt({id:"proto",extensions:[".proto"],aliases:["protobuf","Protocol Buffers"],loader:()=>pt(()=>import("./protobuf-Brw8urJB.js"),[])});vt({id:"pug",extensions:[".jade",".pug"],aliases:["Pug","Jade","jade"],loader:()=>pt(()=>import("./pug-8SOpv6rk.js"),[])});vt({id:"python",extensions:[".py",".rpy",".pyw",".cpy",".gyp",".gypi"],aliases:["Python","py"],firstLine:"^#!/.*\\bpython[0-9.-]*\\b",loader:()=>pt(()=>import("./python-Dv7zLVcI.js"),[])});vt({id:"qsharp",extensions:[".qs"],aliases:["Q#","qsharp"],loader:()=>pt(()=>import("./qsharp-Bw9ernYp.js"),[])});vt({id:"r",extensions:[".r",".rhistory",".rmd",".rprofile",".rt"],aliases:["R","r"],loader:()=>pt(()=>import("./r-j7ic8hl3.js"),[])});vt({id:"razor",extensions:[".cshtml"],aliases:["Razor","razor"],mimetypes:["text/x-cshtml"],loader:()=>pt(()=>import("./razor-VFna7_Vy.js"),[])});vt({id:"redis",extensions:[".redis"],aliases:["redis"],loader:()=>pt(()=>import("./redis-Bu5POkcn.js"),[])});vt({id:"redshift",extensions:[],aliases:["Redshift","redshift"],loader:()=>pt(()=>import("./redshift-Bs9aos_-.js"),[])});vt({id:"restructuredtext",extensions:[".rst"],aliases:["reStructuredText","restructuredtext"],loader:()=>pt(()=>import("./restructuredtext-CqXO7rUv.js"),[])});vt({id:"ruby",extensions:[".rb",".rbx",".rjs",".gemspec",".pp"],filenames:["rakefile","Gemfile"],aliases:["Ruby","rb"],loader:()=>pt(()=>import("./ruby-zBfavPgS.js"),[])});vt({id:"rust",extensions:[".rs",".rlib"],aliases:["Rust","rust"],loader:()=>pt(()=>import("./rust-BzKRNQWT.js"),[])});vt({id:"sb",extensions:[".sb"],aliases:["Small Basic","sb"],loader:()=>pt(()=>import("./sb-BBc9UKZt.js"),[])});vt({id:"scala",extensions:[".scala",".sc",".sbt"],aliases:["Scala","scala","SBT","Sbt","sbt","Dotty","dotty"],mimetypes:["text/x-scala-source","text/x-scala","text/x-sbt","text/x-dotty"],loader:()=>pt(()=>import("./scala-D9hQfWCl.js"),[])});vt({id:"scheme",extensions:[".scm",".ss",".sch",".rkt"],aliases:["scheme","Scheme"],loader:()=>pt(()=>import("./scheme-BPhDTwHR.js"),[])});vt({id:"scss",extensions:[".scss"],aliases:["Sass","sass","scss"],mimetypes:["text/x-scss","text/scss"],loader:()=>pt(()=>import("./scss-CBJaRo0y.js"),[])});vt({id:"shell",extensions:[".sh",".bash"],aliases:["Shell","sh"],loader:()=>pt(()=>import("./shell-DiJ1NA_G.js"),[])});vt({id:"sol",extensions:[".sol"],aliases:["sol","solidity","Solidity"],loader:()=>pt(()=>import("./solidity-Db0IVjzk.js"),[])});vt({id:"aes",extensions:[".aes"],aliases:["aes","sophia","Sophia"],loader:()=>pt(()=>import("./sophia-CnS9iZB_.js"),[])});vt({id:"sparql",extensions:[".rq"],aliases:["sparql","SPARQL"],loader:()=>pt(()=>import("./sparql-CJmd_6j2.js"),[])});vt({id:"sql",extensions:[".sql"],aliases:["SQL"],loader:()=>pt(()=>import("./sql-ClhHkBeG.js"),[])});vt({id:"st",extensions:[".st",".iecst",".iecplc",".lc3lib",".TcPOU",".TcDUT",".TcGVL",".TcIO"],aliases:["StructuredText","scl","stl"],loader:()=>pt(()=>import("./st-CHwy0fLd.js"),[])});vt({id:"swift",aliases:["Swift","swift"],extensions:[".swift"],mimetypes:["text/swift"],loader:()=>pt(()=>import("./swift-Bqt4WxQ4.js"),[])});vt({id:"systemverilog",extensions:[".sv",".svh"],aliases:["SV","sv","SystemVerilog","systemverilog"],loader:()=>pt(()=>import("./systemverilog-Bs9z6M-B.js"),[])});vt({id:"verilog",extensions:[".v",".vh"],aliases:["V","v","Verilog","verilog"],loader:()=>pt(()=>import("./systemverilog-Bs9z6M-B.js"),[])});vt({id:"tcl",extensions:[".tcl"],aliases:["tcl","Tcl","tcltk","TclTk","tcl/tk","Tcl/Tk"],loader:()=>pt(()=>import("./tcl-Dm6ycUr_.js"),[])});vt({id:"twig",extensions:[".twig"],aliases:["Twig","twig"],mimetypes:["text/x-twig"],loader:()=>pt(()=>import("./twig-Csy3S7wG.js"),[])});vt({id:"typescript",extensions:[".ts",".tsx",".cts",".mts"],aliases:["TypeScript","ts","typescript"],mimetypes:["text/typescript"],loader:()=>pt(()=>import("./typescript-x36q2fbo.js"),[])});vt({id:"typespec",extensions:[".tsp"],aliases:["TypeSpec"],loader:()=>pt(()=>import("./typespec-Btyra-wh.js"),[])});vt({id:"vb",extensions:[".vb"],aliases:["Visual Basic","vb"],loader:()=>pt(()=>import("./vb-Db0cS2oM.js"),[])});vt({id:"wgsl",extensions:[".wgsl"],aliases:["WebGPU Shading Language","WGSL","wgsl"],loader:()=>pt(()=>import("./wgsl-BTesnYfV.js"),[])});vt({id:"xml",extensions:[".xml",".xsd",".dtd",".ascx",".csproj",".config",".props",".targets",".wxi",".wxl",".wxs",".xaml",".svg",".svgz",".opf",".xslt",".xsl"],firstLine:"(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)",aliases:["XML","xml"],mimetypes:["text/xml","application/xml","application/xaml+xml","application/xml-dtd"],loader:()=>pt(()=>import("./xml-Dx8dIreF.js"),[])});vt({id:"yaml",extensions:[".yaml",".yml"],aliases:["YAML","yaml","YML","yml"],mimetypes:["application/x-yaml","text/x-yaml"],loader:()=>pt(()=>import("./yaml-CqG7IK-x.js"),[])});var HUt=Object.defineProperty,BUt=(n,e,t)=>e in n?HUt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pi=(n,e,t)=>BUt(n,typeof e!="symbol"?e+"":e,t),G3,eSe,q3,Uq,K3;function VUt(n){return n.method!==void 0}var tSe;(function(n){function e(t){return t}n.create=e})(tSe||(tSe={}));var Rh;(function(n){n.parseError=-32700,n.invalidRequest=-32600,n.methodNotFound=-32601,n.invalidParams=-32602,n.internalError=-32603;function e(r){return-32099<=r&&r<=-32e3}n.isServerError=e;function t(r){if(!e(r))throw new Error("Invalid range for a server error.");return r}n.serverError=t,n.unexpectedServerError=-32e3;function i(r){return!0}n.isApplicationError=i;function s(r){return r}n.applicationError=s,n.genericApplicationError=-320100})(Rh||(Rh={}));var ZFe=class{constructor(){pi(this,"listeners",new Set),pi(this,"event",n=>(this.listeners.add(n),{dispose:()=>{this.listeners.delete(n)}}))}fire(n){this.listeners.forEach(e=>e(n))}},WUt=class{constructor(n){pi(this,"_value"),pi(this,"eventEmitter"),this._value=n,this.eventEmitter=new ZFe}get value(){return this._value}set value(n){this._value!==n&&(this._value=n,this.eventEmitter.fire(n))}get onChange(){return this.eventEmitter.event}};function zUt(n,e){const t=setTimeout(e,n);return{dispose:()=>clearTimeout(t)}}function $q(n,e,t){return n instanceof Set?(n.add(e),{dispose:()=>n.delete(e)}):(n.set(e,t),{dispose:()=>n.delete(e)})}var UUt=class{constructor(){pi(this,"_state","none"),pi(this,"promise"),pi(this,"resolve",()=>{}),pi(this,"reject",()=>{}),this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}get state(){return this._state}};G3=class{constructor(){pi(this,"_unprocessedMessages",[]),pi(this,"_messageListener"),pi(this,"id",G3.id++),pi(this,"_state",new WUt({state:"open"})),pi(this,"state",this._state)}setListener(n){if(this._messageListener=n,!!n)for(;this._unprocessedMessages.length>0&&this._messageListener!==void 0;){const e=this._unprocessedMessages.shift();this._messageListener(e)}}send(n){return this._sendImpl(n)}_dispatchReceivedMessage(n){this._unprocessedMessages.length===0&&this._messageListener?this._messageListener(n):this._unprocessedMessages.push(n)}_onConnectionClosed(){this._state.value={state:"closed",error:void 0}}log(n){return new $Ut(this,n??new GUt)}},pi(G3,"id",0);var $Ut=class{constructor(n,e){pi(this,"baseStream"),pi(this,"logger"),this.baseStream=n,this.logger=e}get state(){return this.baseStream.state}setListener(n){if(n===void 0){this.baseStream.setListener(void 0);return}this.baseStream.setListener(e=>{this.logger.log(this.baseStream,"incoming",e),n(e)})}send(n){return this.logger.log(this.baseStream,"outgoing",n),this.baseStream.send(n)}toString(){return`StreamLogger/${this.baseStream.toString()}`}},GUt=class{log(n,e,t){console.log(`${e==="incoming"?"<-":"->"} [${n.toString()}] ${JSON.stringify(t)}`)}},qUt=class YFe{constructor(e){pi(this,"connect"),this.connect=e}mapContext(e){return new YFe(t=>this.connect(t?KUt(t,e):void 0))}};function KUt(n,e){return{handleNotification:(t,i)=>n.handleNotification(t,e(i)),handleRequest:(t,i,s)=>n.handleRequest(t,i,e(s))}}var ZUt=class XFe{constructor(e,t,i){pi(this,"_stream"),pi(this,"_listener"),pi(this,"_logger"),pi(this,"_unprocessedResponses",new Map),pi(this,"_lastUsedRequestId",0),this._stream=e,this._listener=t,this._logger=i,this._stream.setListener(s=>{VUt(s)?s.id===void 0?this._processNotification(s):this._processRequest(s):this._processResponse(s)})}static createChannel(e,t){let i=!1;return new qUt(s=>{if(i)throw new Error(`A channel to the stream ${e} was already constructed!`);return i=!0,new XFe(e,s,t)})}get state(){return this._stream.state}async _processNotification(e){if(e.id!==void 0)throw new Error;if(!this._listener){this._logger&&this._logger.debug({text:"Notification ignored",message:e});return}try{await this._listener.handleNotification({method:e.method,params:e.params||null})}catch(t){this._logger&&this._logger.warn({text:`Exception was thrown while handling notification: ${t}`,exception:t,message:e})}}async _processRequest(e){if(e.id===void 0)throw new Error;let t;if(this._listener)try{t=await this._listener.handleRequest({method:e.method,params:e.params||null},e.id)}catch(s){this._logger&&this._logger.warn({text:`Exception was thrown while handling request: ${s}`,message:e,exception:s}),t={error:{code:Rh.internalError,message:"An unexpected exception was thrown.",data:void 0}}}else this._logger&&this._logger.debug({text:"Received request even though not listening for requests",message:e}),t={error:{code:Rh.methodNotFound,message:"This endpoint does not listen for requests or notifications.",data:void 0}};let i;"result"in t?i={jsonrpc:"2.0",id:e.id,result:t.result}:i={jsonrpc:"2.0",id:e.id,error:t.error},await this._stream.send(i)}_processResponse(e){const t=""+e.id,i=this._unprocessedResponses.get(t);if(!i){this._logger&&this._logger.debug({text:"Got an unexpected response message",message:e});return}this._unprocessedResponses.delete(t),i(e)}_newRequestId(){return this._lastUsedRequestId++}sendRequest(e,t,i){const s={jsonrpc:"2.0",id:this._newRequestId(),method:e.method,params:e.params||void 0};return i&&i(s.id),new Promise((r,o)=>{const a=""+s.id;this._unprocessedResponses.set(a,l=>{"result"in l?r({result:l.result}):(l.error||o(new Error("Response had neither 'result' nor 'error' field set.")),r({error:l.error}))}),this._stream.send(s).then(void 0,l=>{this._unprocessedResponses.delete(a),o(l)})})}sendNotification(e,t){const i={jsonrpc:"2.0",id:void 0,method:e.method,params:e.params||void 0};return this._stream.send(i)}toString(){return"StreamChannel/"+this._stream.toString()}},pD;(function(n){function e(){return{deserializeFromJson:s=>({hasErrors:!1,value:s}),serializeToJson:s=>s}}n.sAny=e;function t(){return{deserializeFromJson:s=>({hasErrors:!1,value:{}}),serializeToJson:s=>({})}}n.sEmptyObject=t;function i(){return{deserializeFromJson:s=>({hasErrors:!1,value:void 0}),serializeToJson:s=>null}}n.sVoidFromNull=i})(pD||(pD={}));const QFe=Symbol("OptionalMethodNotFound");var JFe=class{contextualize(n){return new YUt(this,n)}},YUt=class extends JFe{constructor(n,e){super(),pi(this,"underylingTypedChannel"),pi(this,"converters"),this.underylingTypedChannel=n,this.converters=e}async request(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.request(n,e,i)}async notify(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.notify(n,e,i)}registerNotificationHandler(n,e){return this.underylingTypedChannel.registerNotificationHandler(n,async(t,i)=>await e(t,await this.converters.getNewContext(i)))}registerRequestHandler(n,e){return this.underylingTypedChannel.registerRequestHandler(n,async(t,i,s)=>await e(t,i,await this.converters.getNewContext(s)))}},iSe=class e8e extends JFe{constructor(e,t={}){super(),pi(this,"channelCtor"),pi(this,"_requestSender"),pi(this,"_handler",new Map),pi(this,"_unknownNotificationHandler",new Set),pi(this,"_timeout"),pi(this,"sendExceptionDetails",!1),pi(this,"_logger"),pi(this,"listeningDeferred",new UUt),pi(this,"onListening",this.listeningDeferred.promise),pi(this,"_requestDidErrorEventEmitter",new ZFe),pi(this,"onRequestDidError",this._requestDidErrorEventEmitter.event),this.channelCtor=e,this._logger=t.logger,this.sendExceptionDetails=!!t.sendExceptionDetails,this._timeout=zUt(1e3,()=>{this._requestSender||console.warn(`"${this.startListen.name}" has not been called within 1 second after construction of this channel. Did you forget to call it?`,this)})}static fromTransport(e,t={}){return new e8e(ZUt.createChannel(e,t.logger),t)}startListen(){if(this._requestSender)throw new Error(`"${this.startListen.name}" can be called only once, but it already has been called.`);this._timeout&&(this._timeout.dispose(),this._timeout=void 0),this._requestSender=this.channelCtor.connect({handleRequest:(e,t,i)=>this.handleRequest(e,t,i),handleNotification:(e,t)=>this.handleNotification(e,t)}),this.listeningDeferred.resolve()}checkChannel(e){if(!e)throw new Error(`"${this.startListen.name}" must be called before any messages can be sent or received.`);return!0}async handleRequest(e,t,i){const s=this._handler.get(e.method);if(!s)return this._logger&&this._logger.debug({text:`No request handler for "${e.method}".`,data:{requestObject:e}}),{error:{code:Rh.methodNotFound,message:`No request handler for "${e.method}".`,data:{method:e.method}}};if(s.kind!="request"){const o=`"${e.method}" is registered as notification, but was sent as request.`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e}}),{error:{code:Rh.invalidRequest,message:o,data:{method:e.method}}}}const r=s.requestType.paramsSerializer.deserializeFromJson(e.params);if(r.hasErrors){const o=`Got invalid params: ${r.errorMessage}`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e,errorMessage:r.errorMessage}}),{error:{code:Rh.invalidParams,message:o,data:{errors:r.errorMessage}}}}else{const o=r.value;let a;try{const l=await s.handler(o,t,i);if("error"in l||"errorMessage"in l){const c=l.error?s.requestType.errorSerializer.serializeToJson(l.error):void 0;a={error:{code:l.errorCode||Rh.genericApplicationError,message:l.errorMessage||"An error was returned",data:c}}}else a={result:s.requestType.resultSerializer.serializeToJson(l.ok)}}catch(l){l instanceof sSe?a={error:{code:l.code,message:l.message}}:(this._logger&&this._logger.warn({text:`An exception was thrown while handling a request: ${l}.`,exception:l,data:{requestObject:e}}),a={error:{code:Rh.unexpectedServerError,message:this.sendExceptionDetails?`An exception was thrown while handling a request: ${l}.`:"Server has thrown an unexpected exception"}})}return a}}async handleNotification(e,t){const i=this._handler.get(e.method);if(!i){for(const o of this._unknownNotificationHandler)o(e);this._unknownNotificationHandler.size===0&&this._logger&&this._logger.debug({text:`Unhandled notification "${e.method}"`,data:{requestObject:e}});return}if(i.kind!="notification"){this._logger&&this._logger.debug({text:`"${e.method}" is registered as request, but was sent as notification.`,data:{requestObject:e}});return}const s=i.notificationType.paramsSerializer.deserializeFromJson(e.params);if(s.hasErrors){this._logger&&this._logger.debug({text:`Got invalid params: ${s}`,data:{requestObject:e,errorMessage:s.errorMessage}});return}const r=s.value;for(const o of i.handlers)try{o(r,t)}catch(a){this._logger&&this._logger.warn({text:`An exception was thrown while handling a notification: ${a}.`,exception:a,data:{requestObject:e}})}}registerUnknownNotificationHandler(e){return $q(this._unknownNotificationHandler,e)}registerRequestHandler(e,t){if(this._handler.get(e.method))throw new Error(`Handler with method "${e.method}" already registered.`);return $q(this._handler,e.method,{kind:"request",requestType:e,handler:t})}registerNotificationHandler(e,t){let i=this._handler.get(e.method);if(!i)i={kind:"notification",notificationType:e,handlers:new Set},this._handler.set(e.method,i);else{if(i.kind!=="notification")throw new Error(`Method "${e.method}" was already registered as request handler.`);if(i.notificationType!==e)throw new Error(`Method "${e.method}" was registered for a different type.`)}return $q(i.handlers,t)}getRegisteredTypes(){const e=[];for(const t of this._handler.values())t.kind==="notification"?e.push(t.notificationType):t.kind==="request"&&e.push(t.requestType);return e}async request(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error("Impossible");const s=e.paramsSerializer.serializeToJson(t);nSe(s);const r=await this._requestSender.sendRequest({method:e.method,params:s},i);if("error"in r){if(e.isOptional&&r.error.code===Rh.methodNotFound)return QFe;let o;if(r.error.data!==void 0){const l=e.errorSerializer.deserializeFromJson(r.error.data);if(l.hasErrors)throw new Error(l.errorMessage);o=l.value}else o=void 0;const a=new sSe(r.error.message,o,r.error.code);throw this._requestDidErrorEventEmitter.fire({error:a}),a}else{const o=e.resultSerializer.deserializeFromJson(r.result);if(o.hasErrors)throw new Error("Could not deserialize response: "+o.errorMessage+`
|
|
1648
|
+
hint: use the 'bracket' attribute if matching on equal brackets is required.`);if(typeof a.open=="string"&&typeof a.token=="string"&&typeof a.close=="string")r.push({token:a.token+t.tokenPostfix,open:P_(t,a.open),close:P_(t,a.close)});else throw os(t,"every element in the 'brackets' array must be a '{open,close,token}' object or array")}return t.brackets=r,t.noThrow=!0,t}function Ezt(n){qD.registerLanguage(n)}function Dzt(){let n=[];return n=n.concat(qD.getLanguages()),n}function Rzt(n){return kt.get(Gs).languageIdCodec.encodeLanguageId(n)}function Nzt(n,e){return kt.withServices(()=>{const i=kt.get(Gs).onDidRequestRichLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function Tzt(n,e){return kt.withServices(()=>{const i=kt.get(Gs).onDidRequestBasicLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function Izt(n,e){if(!kt.get(Gs).isRegisteredLanguageId(n))throw new Error(`Cannot set configuration for unknown language ${n}`);return kt.get(Ls).register(n,e,100)}class kzt{constructor(e,t){this._languageId=e,this._actual=t}dispose(){}getInitialState(){return this._actual.getInitialState()}tokenize(e,t,i){if(typeof this._actual.tokenize=="function")return lM.adaptTokenize(this._languageId,this._actual,e,i);throw new Error("Not supported!")}tokenizeEncoded(e,t,i){const s=this._actual.tokenizeEncoded(e,i);return new iV(s.tokens,s.endState)}}class lM{constructor(e,t,i,s){this._languageId=e,this._actual=t,this._languageService=i,this._standaloneThemeService=s}dispose(){}getInitialState(){return this._actual.getInitialState()}static _toClassicTokens(e,t){const i=[];let s=0;for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=a.startIndex;r===0?l=0:l<s&&(l=s),i[r]=new G2(l,a.scopes,t),s=l}return i}static adaptTokenize(e,t,i,s){const r=t.tokenize(i,s),o=lM._toClassicTokens(r.tokens,e);let a;return r.endState.equals(s)?a=s:a=r.endState,new vae(o,a)}tokenize(e,t,i){return lM.adaptTokenize(this._languageId,this._actual,e,i)}_toBinaryTokens(e,t){const i=e.encodeLanguageId(this._languageId),s=this._standaloneThemeService.getColorTheme().tokenTheme,r=[];let o=0,a=0;for(let c=0,d=t.length;c<d;c++){const u=t[c],h=s.match(i,u.scopes)|1024;if(o>0&&r[o-1]===h)continue;let g=u.startIndex;c===0?g=0:g<a&&(g=a),r[o++]=g,r[o++]=h,a=g}const l=new Uint32Array(o);for(let c=0;c<o;c++)l[c]=r[c];return l}tokenizeEncoded(e,t,i){const s=this._actual.tokenize(e,i),r=this._toBinaryTokens(this._languageService.languageIdCodec,s.tokens);let o;return s.endState.equals(i)?o=i:o=s.endState,new iV(r,o)}}function Azt(n){return typeof n.getInitialState=="function"}function Mzt(n){return"tokenizeEncoded"in n}function RFe(n){return n&&typeof n.then=="function"}function Ozt(n){const e=kt.get(Xd);if(n){const t=[null];for(let i=1,s=n.length;i<s;i++)t[i]=pe.fromHex(n[i]);e.setColorMapOverride(t)}else e.setColorMapOverride(null)}function NFe(n,e){return Mzt(e)?new kzt(n,e):new lM(n,e,kt.get(Gs),kt.get(Xd))}function Xce(n,e){const t=new k0t(async()=>{const i=await Promise.resolve(e.create());return i?Azt(i)?NFe(n,i):new tM(kt.get(Gs),kt.get(Xd),n,DFe(n,i),kt.get(Ut)):null});return Vs.registerFactory(n,t)}function Pzt(n,e){if(!kt.get(Gs).isRegisteredLanguageId(n))throw new Error(`Cannot set tokens provider for unknown language ${n}`);return RFe(e)?Xce(n,{create:()=>e}):Vs.register(n,NFe(n,e))}function Fzt(n,e){const t=i=>new tM(kt.get(Gs),kt.get(Xd),n,DFe(n,i),kt.get(Ut));return RFe(e)?Xce(n,{create:()=>e}):Vs.register(n,t(e))}function jzt(n,e){return kt.get(Xe).referenceProvider.register(n,e)}function Hzt(n,e){return kt.get(Xe).renameProvider.register(n,e)}function Bzt(n,e){return kt.get(Xe).newSymbolNamesProvider.register(n,e)}function Vzt(n,e){return kt.get(Xe).signatureHelpProvider.register(n,e)}function Wzt(n,e){return kt.get(Xe).hoverProvider.register(n,{provideHover:async(i,s,r,o)=>{const a=i.getWordAtPosition(s);return Promise.resolve(e.provideHover(i,s,r,o)).then(l=>{if(l)return!l.range&&a&&(l.range=new F(s.lineNumber,a.startColumn,s.lineNumber,a.endColumn)),l.range||(l.range=new F(s.lineNumber,s.column,s.lineNumber,s.column)),l})}})}function zzt(n,e){return kt.get(Xe).documentSymbolProvider.register(n,e)}function Uzt(n,e){return kt.get(Xe).documentHighlightProvider.register(n,e)}function $zt(n,e){return kt.get(Xe).linkedEditingRangeProvider.register(n,e)}function Gzt(n,e){return kt.get(Xe).definitionProvider.register(n,e)}function qzt(n,e){return kt.get(Xe).implementationProvider.register(n,e)}function Kzt(n,e){return kt.get(Xe).typeDefinitionProvider.register(n,e)}function Zzt(n,e){return kt.get(Xe).codeLensProvider.register(n,e)}function Yzt(n,e,t){return kt.get(Xe).codeActionProvider.register(n,{providedCodeActionKinds:t==null?void 0:t.providedCodeActionKinds,documentation:t==null?void 0:t.documentation,provideCodeActions:(s,r,o,a)=>{const c=kt.get(Gp).read({resource:s.uri}).filter(d=>F.areIntersectingOrTouching(d,r));return e.provideCodeActions(s,r,{markers:c,only:o.only,trigger:o.trigger},a)},resolveCodeAction:e.resolveCodeAction})}function Xzt(n,e){return kt.get(Xe).documentFormattingEditProvider.register(n,e)}function Qzt(n,e){return kt.get(Xe).documentRangeFormattingEditProvider.register(n,e)}function Jzt(n,e){return kt.get(Xe).onTypeFormattingEditProvider.register(n,e)}function eUt(n,e){return kt.get(Xe).linkProvider.register(n,e)}function tUt(n,e){return kt.get(Xe).completionProvider.register(n,e)}function iUt(n,e){return kt.get(Xe).colorProvider.register(n,e)}function nUt(n,e){return kt.get(Xe).foldingRangeProvider.register(n,e)}function sUt(n,e){return kt.get(Xe).declarationProvider.register(n,e)}function rUt(n,e){return kt.get(Xe).selectionRangeProvider.register(n,e)}function oUt(n,e){return kt.get(Xe).documentSemanticTokensProvider.register(n,e)}function aUt(n,e){return kt.get(Xe).documentRangeSemanticTokensProvider.register(n,e)}function lUt(n,e){return kt.get(Xe).inlineCompletionsProvider.register(n,e)}function cUt(n,e){return kt.get(Xe).inlayHintsProvider.register(n,e)}function dUt(){return{register:Ezt,getLanguages:Dzt,onLanguage:Nzt,onLanguageEncountered:Tzt,getEncodedLanguageId:Rzt,setLanguageConfiguration:Izt,setColorMap:Ozt,registerTokensProviderFactory:Xce,setTokensProvider:Pzt,setMonarchTokensProvider:Fzt,registerReferenceProvider:jzt,registerRenameProvider:Hzt,registerNewSymbolNameProvider:Bzt,registerCompletionItemProvider:tUt,registerSignatureHelpProvider:Vzt,registerHoverProvider:Wzt,registerDocumentSymbolProvider:zzt,registerDocumentHighlightProvider:Uzt,registerLinkedEditingRangeProvider:$zt,registerDefinitionProvider:Gzt,registerImplementationProvider:qzt,registerTypeDefinitionProvider:Kzt,registerCodeLensProvider:Zzt,registerCodeActionProvider:Yzt,registerDocumentFormattingEditProvider:Xzt,registerDocumentRangeFormattingEditProvider:Qzt,registerOnTypeFormattingEditProvider:Jzt,registerLinkProvider:eUt,registerColorProvider:iUt,registerFoldingRangeProvider:nUt,registerDeclarationProvider:sUt,registerSelectionRangeProvider:rUt,registerDocumentSemanticTokensProvider:oUt,registerDocumentRangeSemanticTokensProvider:aUt,registerInlineCompletionsProvider:lUt,registerInlayHintsProvider:cUt,DocumentHighlightKind:wte,CompletionItemKind:pte,CompletionItemTag:mte,CompletionItemInsertTextRule:gte,SymbolKind:Jte,SymbolTag:eie,IndentAction:Rte,CompletionTriggerKind:_te,SignatureHelpTriggerKind:Qte,InlayHintKind:Tte,InlineCompletionTriggerKind:Ate,CodeActionTriggerType:fte,NewSymbolNameTag:Bte,NewSymbolNameTriggerKind:Vte,PartialAcceptTriggerKind:Ute,HoverVerbosityAction:Dte,InlineCompletionEndOfLifeReasonKind:Ite,InlineCompletionHintStyle:kte,FoldingRangeKind:ex,SelectedSuggestionInfo:cMe,EditDeltaInfo:sA}}Qa.wrappingIndent.defaultValue=0;Qa.glyphMargin.defaultValue=!1;Qa.autoIndent.defaultValue=3;Qa.overviewRulerLanes.defaultValue=2;AA.setFormatterSelector((n,e,t)=>Promise.resolve(n[0]));const Vl=iFe();Vl.editor=Czt();Vl.languages=dUt();const uUt=Vl.CancellationTokenSource,ER=Vl.Emitter,hUt=Vl.KeyCode,fUt=Vl.KeyMod,gUt=Vl.Position,pUt=Vl.Range,mUt=Vl.Selection,_Ut=Vl.SelectionDirection,m_=Vl.MarkerSeverity,vne=Vl.MarkerTag,bUt=Vl.Uri,vUt=Vl.Token,TFe=Vl.editor,Nt=Vl.languages,Wq=ooe(),gD=globalThis;(Wq!=null&&Wq.globalAPI||typeof gD.define=="function"&&gD.define.amd)&&(gD.monaco=Vl);typeof gD.require<"u"&&typeof gD.require.config=="function"&&gD.require.config({ignoreDuplicateModules:["vscode-languageserver-types","vscode-languageserver-types/main","vscode-languageserver-textdocument","vscode-languageserver-textdocument/main","vscode-nls","vscode-nls/vscode-nls","jsonc-parser","jsonc-parser/main","vscode-uri","vscode-uri/index","vs/basic-languages/typescript/typescript"]});const CUt=Object.freeze(Object.defineProperty({__proto__:null,CancellationTokenSource:uUt,Emitter:ER,KeyCode:hUt,KeyMod:fUt,MarkerSeverity:m_,MarkerTag:vne,Position:gUt,Range:pUt,Selection:mUt,SelectionDirection:_Ut,Token:vUt,Uri:bUt,editor:TFe,languages:Nt},Symbol.toStringTag,{value:"Module"}));let Qce=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this.options}get options(){return this._options}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setDiagnosticsOptions(e){this.setOptions(e)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Jce={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"},data:{useDefaultDataProvider:!0},format:{newlineBetweenSelectors:!0,newlineBetweenRules:!0,spaceAroundSelectorSeparator:!1,braceStyle:"collapse",maxPreserveNewLines:void 0,preserveNewLines:!0}},ede={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0,documentFormattingEdits:!0,documentRangeFormattingEdits:!0},IFe=new Qce("css",Jce,ede),kFe=new Qce("scss",Jce,ede),AFe=new Qce("less",Jce,ede);function tde(){return pt(()=>import("./cssMode-B0NUF229.js"),__vite__mapDeps([0,1]))}Nt.onLanguage("less",()=>{tde().then(n=>n.setupMode(AFe))});Nt.onLanguage("scss",()=>{tde().then(n=>n.setupMode(kFe))});Nt.onLanguage("css",()=>{tde().then(n=>n.setupMode(IFe))});const wUt=Object.freeze(Object.defineProperty({__proto__:null,cssDefaults:IFe,lessDefaults:AFe,scssDefaults:kFe},Symbol.toStringTag,{value:"Module"}));let yUt=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get options(){return this._options}get modeConfiguration(){return this._modeConfiguration}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const SUt={tabSize:4,insertSpaces:!1,wrapLineLength:120,unformatted:'default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var',contentUnformatted:"pre",indentInnerHtml:!1,preserveNewLines:!0,maxPreserveNewLines:void 0,indentHandlebars:!1,endWithNewline:!1,extraLiners:"head, body, /html",wrapAttributes:"auto"},YV={format:SUt,suggest:{},data:{useDefaultDataProvider:!0}};function XV(n){return{completionItems:!0,hovers:!0,documentSymbols:!0,links:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,selectionRanges:!0,diagnostics:n===kk,documentFormattingEdits:n===kk,documentRangeFormattingEdits:n===kk}}const kk="html",Q0e="handlebars",J0e="razor",MFe=QV(kk,YV,XV(kk)),xUt=MFe.defaults,OFe=QV(Q0e,YV,XV(Q0e)),LUt=OFe.defaults,PFe=QV(J0e,YV,XV(J0e)),EUt=PFe.defaults;function DUt(){return pt(()=>import("./htmlMode-StGZiG_r.js"),__vite__mapDeps([2,1]))}function QV(n,e=YV,t=XV(n)){const i=new yUt(n,e,t);let s;const r=Nt.onLanguage(n,async()=>{s=(await DUt()).setupMode(i)});return{defaults:i,dispose(){r.dispose(),s==null||s.dispose(),s=void 0}}}const RUt=Object.freeze(Object.defineProperty({__proto__:null,handlebarDefaults:LUt,handlebarLanguageService:OFe,htmlDefaults:xUt,htmlLanguageService:MFe,razorDefaults:EUt,razorLanguageService:PFe,registerHTMLLanguageService:QV},Symbol.toStringTag,{value:"Module"}));let NUt=class{constructor(e,t,i){this._onDidChange=new ER,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const TUt={validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:"warning",schemaValidation:"warning",comments:"error",trailingCommas:"error"},IUt={documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0},FFe=new NUt("json",TUt,IUt),kUt=()=>jFe().then(n=>n.getWorker());function jFe(){return pt(()=>import("./jsonMode-zPJy-dyb.js"),__vite__mapDeps([3,1]))}Nt.register({id:"json",extensions:[".json",".bowerrc",".jshintrc",".jscsrc",".eslintrc",".babelrc",".har"],aliases:["JSON","json"],mimetypes:["application/json"]});Nt.onLanguage("json",()=>{jFe().then(n=>n.setupMode(FFe))});const AUt=Object.freeze(Object.defineProperty({__proto__:null,getWorker:kUt,jsonDefaults:FFe},Symbol.toStringTag,{value:"Module"})),MUt="5.9.3";var HFe=(n=>(n[n.None=0]="None",n[n.CommonJS=1]="CommonJS",n[n.AMD=2]="AMD",n[n.UMD=3]="UMD",n[n.System=4]="System",n[n.ES2015=5]="ES2015",n[n.ESNext=99]="ESNext",n))(HFe||{}),BFe=(n=>(n[n.None=0]="None",n[n.Preserve=1]="Preserve",n[n.React=2]="React",n[n.ReactNative=3]="ReactNative",n[n.ReactJSX=4]="ReactJSX",n[n.ReactJSXDev=5]="ReactJSXDev",n))(BFe||{}),VFe=(n=>(n[n.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",n[n.LineFeed=1]="LineFeed",n))(VFe||{}),WFe=(n=>(n[n.ES3=0]="ES3",n[n.ES5=1]="ES5",n[n.ES2015=2]="ES2015",n[n.ES2016=3]="ES2016",n[n.ES2017=4]="ES2017",n[n.ES2018=5]="ES2018",n[n.ES2019=6]="ES2019",n[n.ES2020=7]="ES2020",n[n.ESNext=99]="ESNext",n[n.JSON=100]="JSON",n[n.Latest=99]="Latest",n))(WFe||{}),zFe=(n=>(n[n.Classic=1]="Classic",n[n.NodeJs=2]="NodeJs",n))(zFe||{});class UFe{constructor(e,t,i,s,r){this._onDidChange=new ER,this._onDidExtraLibsChange=new ER,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(i),this.setInlayHintsOptions(s),this.setModeConfiguration(r),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let i;if(typeof t>"u"?i=`ts:extralib-${Math.random().toString(36).substring(2,15)}`:i=t,this._extraLibs[i]&&this._extraLibs[i].content===e)return{dispose:()=>{}};let s=1;return this._removedExtraLibs[i]&&(s=this._removedExtraLibs[i]+1),this._extraLibs[i]&&(s=this._extraLibs[i].version+1),this._extraLibs[i]={content:e,version:s},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let r=this._extraLibs[i];r&&r.version===s&&(delete this._extraLibs[i],this._removedExtraLibs[i]=s,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(const t in this._extraLibs)this._removedExtraLibs[t]=this._extraLibs[t].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(const t of e){const i=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,s=t.content;let r=1;this._removedExtraLibs[i]&&(r=this._removedExtraLibs[i]+1),this._extraLibs[i]={content:s,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}}const OUt=MUt,$Fe={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},GFe=new UFe({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},$Fe),qFe=new UFe({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},$Fe),PUt=()=>JV().then(n=>n.getTypeScriptWorker()),FUt=()=>JV().then(n=>n.getJavaScriptWorker());function JV(){return pt(()=>import("./tsMode-EHFp3iGo.js"),[])}Nt.onLanguage("typescript",()=>JV().then(n=>n.setupTypeScript(GFe)));Nt.onLanguage("javascript",()=>JV().then(n=>n.setupJavaScript(qFe)));const jUt=Object.freeze(Object.defineProperty({__proto__:null,JsxEmit:BFe,ModuleKind:HFe,ModuleResolutionKind:zFe,NewLineKind:VFe,ScriptTarget:WFe,getJavaScriptWorker:FUt,getTypeScriptWorker:PUt,javascriptDefaults:qFe,typescriptDefaults:GFe,typescriptVersion:OUt},Symbol.toStringTag,{value:"Module"})),KFe={},zq={};class ide{static getOrCreate(e){return zq[e]||(zq[e]=new ide(e)),zq[e]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((t,i)=>{this._lazyLoadPromiseResolve=t,this._lazyLoadPromiseReject=i})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,KFe[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}}function vt(n){const e=n.id;KFe[e]=n,Nt.register(n);const t=ide.getOrCreate(e);Nt.registerTokensProviderFactory(e,{create:async()=>(await t.load()).language}),Nt.onLanguageEncountered(e,async()=>{const i=await t.load();Nt.setLanguageConfiguration(e,i.conf)})}vt({id:"abap",extensions:[".abap"],aliases:["abap","ABAP"],loader:()=>pt(()=>import("./abap-DLDM7-KI.js"),[])});vt({id:"apex",extensions:[".cls"],aliases:["Apex","apex"],mimetypes:["text/x-apex-source","text/x-apex"],loader:()=>pt(()=>import("./apex-DNDY2TF8.js"),[])});vt({id:"azcli",extensions:[".azcli"],aliases:["Azure CLI","azcli"],loader:()=>pt(()=>import("./azcli-Y6nb8tq_.js"),[])});vt({id:"bat",extensions:[".bat",".cmd"],aliases:["Batch","bat"],loader:()=>pt(()=>import("./bat-BwHxbl9M.js"),[])});vt({id:"bicep",extensions:[".bicep"],aliases:["Bicep"],loader:()=>pt(()=>import("./bicep-CFznDFnq.js"),[])});vt({id:"cameligo",extensions:[".mligo"],aliases:["Cameligo"],loader:()=>pt(()=>import("./cameligo-Bf6VGUru.js"),[])});vt({id:"clojure",extensions:[".clj",".cljs",".cljc",".edn"],aliases:["clojure","Clojure"],loader:()=>pt(()=>import("./clojure-Dnu-v4kV.js"),[])});vt({id:"coffeescript",extensions:[".coffee"],aliases:["CoffeeScript","coffeescript","coffee"],mimetypes:["text/x-coffeescript","text/coffeescript"],loader:()=>pt(()=>import("./coffee-Bd8akH9Z.js"),[])});vt({id:"c",extensions:[".c",".h"],aliases:["C","c"],loader:()=>pt(()=>import("./cpp-BbWJElDN.js"),[])});vt({id:"cpp",extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],aliases:["C++","Cpp","cpp"],loader:()=>pt(()=>import("./cpp-BbWJElDN.js"),[])});vt({id:"csharp",extensions:[".cs",".csx",".cake"],aliases:["C#","csharp"],loader:()=>pt(()=>import("./csharp-Co3qMtFm.js"),[])});vt({id:"csp",extensions:[".csp"],aliases:["CSP","csp"],loader:()=>pt(()=>import("./csp-D-4FJmMZ.js"),[])});vt({id:"css",extensions:[".css"],aliases:["CSS","css"],mimetypes:["text/css"],loader:()=>pt(()=>import("./css-DdJfP1eB.js"),[])});vt({id:"cypher",extensions:[".cypher",".cyp"],aliases:["Cypher","OpenCypher"],loader:()=>pt(()=>import("./cypher-cTPe9QuQ.js"),[])});vt({id:"dart",extensions:[".dart"],aliases:["Dart","dart"],mimetypes:["text/x-dart-source","text/x-dart"],loader:()=>pt(()=>import("./dart-BOtBlQCF.js"),[])});vt({id:"dockerfile",extensions:[".dockerfile"],filenames:["Dockerfile"],aliases:["Dockerfile"],loader:()=>pt(()=>import("./dockerfile-BG73LgW2.js"),[])});vt({id:"ecl",extensions:[".ecl"],aliases:["ECL","Ecl","ecl"],loader:()=>pt(()=>import("./ecl-BEgZUVRK.js"),[])});vt({id:"elixir",extensions:[".ex",".exs"],aliases:["Elixir","elixir","ex"],loader:()=>pt(()=>import("./elixir-BkW5O-1t.js"),[])});vt({id:"flow9",extensions:[".flow"],aliases:["Flow9","Flow","flow9","flow"],loader:()=>pt(()=>import("./flow9-BeJ5waoc.js"),[])});vt({id:"fsharp",extensions:[".fs",".fsi",".ml",".mli",".fsx",".fsscript"],aliases:["F#","FSharp","fsharp"],loader:()=>pt(()=>import("./fsharp-PahG7c26.js"),[])});vt({id:"freemarker2",extensions:[".ftl",".ftlh",".ftlx"],aliases:["FreeMarker2","Apache FreeMarker2"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagAutoInterpolationDollar)});vt({id:"freemarker2.tag-angle.interpolation-dollar",aliases:["FreeMarker2 (Angle/Dollar)","Apache FreeMarker2 (Angle/Dollar)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagAngleInterpolationDollar)});vt({id:"freemarker2.tag-bracket.interpolation-dollar",aliases:["FreeMarker2 (Bracket/Dollar)","Apache FreeMarker2 (Bracket/Dollar)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagBracketInterpolationDollar)});vt({id:"freemarker2.tag-angle.interpolation-bracket",aliases:["FreeMarker2 (Angle/Bracket)","Apache FreeMarker2 (Angle/Bracket)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagAngleInterpolationBracket)});vt({id:"freemarker2.tag-bracket.interpolation-bracket",aliases:["FreeMarker2 (Bracket/Bracket)","Apache FreeMarker2 (Bracket/Bracket)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagBracketInterpolationBracket)});vt({id:"freemarker2.tag-auto.interpolation-dollar",aliases:["FreeMarker2 (Auto/Dollar)","Apache FreeMarker2 (Auto/Dollar)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagAutoInterpolationDollar)});vt({id:"freemarker2.tag-auto.interpolation-bracket",aliases:["FreeMarker2 (Auto/Bracket)","Apache FreeMarker2 (Auto/Bracket)"],loader:()=>pt(()=>import("./freemarker2-Cbvq0A5z.js"),[]).then(n=>n.TagAutoInterpolationBracket)});vt({id:"go",extensions:[".go"],aliases:["Go"],loader:()=>pt(()=>import("./go-acbASCJo.js"),[])});vt({id:"graphql",extensions:[".graphql",".gql"],aliases:["GraphQL","graphql","gql"],mimetypes:["application/graphql"],loader:()=>pt(()=>import("./graphql-BxJiqAUM.js"),[])});vt({id:"handlebars",extensions:[".handlebars",".hbs"],aliases:["Handlebars","handlebars","hbs"],mimetypes:["text/x-handlebars-template"],loader:()=>pt(()=>import("./handlebars-D5arQ79o.js"),[])});vt({id:"hcl",extensions:[".tf",".tfvars",".hcl"],aliases:["Terraform","tf","HCL","hcl"],loader:()=>pt(()=>import("./hcl-DtV1sZF8.js"),[])});vt({id:"html",extensions:[".html",".htm",".shtml",".xhtml",".mdoc",".jsp",".asp",".aspx",".jshtm"],aliases:["HTML","htm","html","xhtml"],mimetypes:["text/html","text/x-jshtm","text/template","text/ng-template"],loader:()=>pt(()=>import("./html-CZ2H75FG.js"),[])});vt({id:"ini",extensions:[".ini",".properties",".gitconfig"],filenames:["config",".gitattributes",".gitconfig",".editorconfig"],aliases:["Ini","ini"],loader:()=>pt(()=>import("./ini-Kd9XrMLS.js"),[])});vt({id:"java",extensions:[".java",".jav"],aliases:["Java","java"],mimetypes:["text/x-java-source","text/x-java"],loader:()=>pt(()=>import("./java-CXBNlu9o.js"),[])});vt({id:"javascript",extensions:[".js",".es6",".jsx",".mjs",".cjs"],firstLine:"^#!.*\\bnode",filenames:["jakefile"],aliases:["JavaScript","javascript","js"],mimetypes:["text/javascript"],loader:()=>pt(()=>import("./javascript-Dm8DVvch.js"),__vite__mapDeps([4,5]))});vt({id:"julia",extensions:[".jl"],aliases:["julia","Julia"],loader:()=>pt(()=>import("./julia-cl7-CwDS.js"),[])});vt({id:"kotlin",extensions:[".kt",".kts"],aliases:["Kotlin","kotlin"],mimetypes:["text/x-kotlin-source","text/x-kotlin"],loader:()=>pt(()=>import("./kotlin-s7OhZKlX.js"),[])});vt({id:"less",extensions:[".less"],aliases:["Less","less"],mimetypes:["text/x-less","text/less"],loader:()=>pt(()=>import("./less-9HpZscsL.js"),[])});vt({id:"lexon",extensions:[".lex"],aliases:["Lexon"],loader:()=>pt(()=>import("./lexon-OrD6JF1K.js"),[])});vt({id:"lua",extensions:[".lua"],aliases:["Lua","lua"],loader:()=>pt(()=>import("./lua-Cyyb5UIc.js"),[])});vt({id:"liquid",extensions:[".liquid",".html.liquid"],aliases:["Liquid","liquid"],mimetypes:["application/liquid"],loader:()=>pt(()=>import("./liquid-Y04yjT3Q.js"),[])});vt({id:"m3",extensions:[".m3",".i3",".mg",".ig"],aliases:["Modula-3","Modula3","modula3","m3"],loader:()=>pt(()=>import("./m3-B8OfTtLu.js"),[])});vt({id:"markdown",extensions:[".md",".markdown",".mdown",".mkdn",".mkd",".mdwn",".mdtxt",".mdtext"],aliases:["Markdown","markdown"],loader:()=>pt(()=>import("./markdown-BFxVWTOG.js"),[])});vt({id:"mdx",extensions:[".mdx"],aliases:["MDX","mdx"],loader:()=>pt(()=>import("./mdx-CihRvnyN.js"),[])});vt({id:"mips",extensions:[".s"],aliases:["MIPS","MIPS-V"],mimetypes:["text/x-mips","text/mips","text/plaintext"],loader:()=>pt(()=>import("./mips-CiqrrVzr.js"),[])});vt({id:"msdax",extensions:[".dax",".msdax"],aliases:["DAX","MSDAX"],loader:()=>pt(()=>import("./msdax-DmeGPVcC.js"),[])});vt({id:"mysql",extensions:[],aliases:["MySQL","mysql"],loader:()=>pt(()=>import("./mysql-C_tMU-Nz.js"),[])});vt({id:"objective-c",extensions:[".m"],aliases:["Objective-C"],loader:()=>pt(()=>import("./objective-c-BDtDVThU.js"),[])});vt({id:"pascal",extensions:[".pas",".p",".pp"],aliases:["Pascal","pas"],mimetypes:["text/x-pascal-source","text/x-pascal"],loader:()=>pt(()=>import("./pascal-vHIfCaH5.js"),[])});vt({id:"pascaligo",extensions:[".ligo"],aliases:["Pascaligo","ligo"],loader:()=>pt(()=>import("./pascaligo-DtZ0uQbO.js"),[])});vt({id:"perl",extensions:[".pl",".pm"],aliases:["Perl","pl"],loader:()=>pt(()=>import("./perl-Ub6l9XKa.js"),[])});vt({id:"pgsql",extensions:[],aliases:["PostgreSQL","postgres","pg","postgre"],loader:()=>pt(()=>import("./pgsql-BlNEE0v7.js"),[])});vt({id:"php",extensions:[".php",".php4",".php5",".phtml",".ctp"],aliases:["PHP","php"],mimetypes:["application/x-php"],loader:()=>pt(()=>import("./php-BBUBE1dy.js"),[])});vt({id:"pla",extensions:[".pla"],loader:()=>pt(()=>import("./pla-DSh2-awV.js"),[])});vt({id:"postiats",extensions:[".dats",".sats",".hats"],aliases:["ATS","ATS/Postiats"],loader:()=>pt(()=>import("./postiats-CocnycG-.js"),[])});vt({id:"powerquery",extensions:[".pq",".pqm"],aliases:["PQ","M","Power Query","Power Query M"],loader:()=>pt(()=>import("./powerquery-tScXyioY.js"),[])});vt({id:"powershell",extensions:[".ps1",".psm1",".psd1"],aliases:["PowerShell","powershell","ps","ps1"],loader:()=>pt(()=>import("./powershell-COWaemsV.js"),[])});vt({id:"proto",extensions:[".proto"],aliases:["protobuf","Protocol Buffers"],loader:()=>pt(()=>import("./protobuf-Brw8urJB.js"),[])});vt({id:"pug",extensions:[".jade",".pug"],aliases:["Pug","Jade","jade"],loader:()=>pt(()=>import("./pug-8SOpv6rk.js"),[])});vt({id:"python",extensions:[".py",".rpy",".pyw",".cpy",".gyp",".gypi"],aliases:["Python","py"],firstLine:"^#!/.*\\bpython[0-9.-]*\\b",loader:()=>pt(()=>import("./python-B-EbuC3t.js"),[])});vt({id:"qsharp",extensions:[".qs"],aliases:["Q#","qsharp"],loader:()=>pt(()=>import("./qsharp-Bw9ernYp.js"),[])});vt({id:"r",extensions:[".r",".rhistory",".rmd",".rprofile",".rt"],aliases:["R","r"],loader:()=>pt(()=>import("./r-j7ic8hl3.js"),[])});vt({id:"razor",extensions:[".cshtml"],aliases:["Razor","razor"],mimetypes:["text/x-cshtml"],loader:()=>pt(()=>import("./razor-Br_9PE1M.js"),[])});vt({id:"redis",extensions:[".redis"],aliases:["redis"],loader:()=>pt(()=>import("./redis-Bu5POkcn.js"),[])});vt({id:"redshift",extensions:[],aliases:["Redshift","redshift"],loader:()=>pt(()=>import("./redshift-Bs9aos_-.js"),[])});vt({id:"restructuredtext",extensions:[".rst"],aliases:["reStructuredText","restructuredtext"],loader:()=>pt(()=>import("./restructuredtext-CqXO7rUv.js"),[])});vt({id:"ruby",extensions:[".rb",".rbx",".rjs",".gemspec",".pp"],filenames:["rakefile","Gemfile"],aliases:["Ruby","rb"],loader:()=>pt(()=>import("./ruby-zBfavPgS.js"),[])});vt({id:"rust",extensions:[".rs",".rlib"],aliases:["Rust","rust"],loader:()=>pt(()=>import("./rust-BzKRNQWT.js"),[])});vt({id:"sb",extensions:[".sb"],aliases:["Small Basic","sb"],loader:()=>pt(()=>import("./sb-BBc9UKZt.js"),[])});vt({id:"scala",extensions:[".scala",".sc",".sbt"],aliases:["Scala","scala","SBT","Sbt","sbt","Dotty","dotty"],mimetypes:["text/x-scala-source","text/x-scala","text/x-sbt","text/x-dotty"],loader:()=>pt(()=>import("./scala-D9hQfWCl.js"),[])});vt({id:"scheme",extensions:[".scm",".ss",".sch",".rkt"],aliases:["scheme","Scheme"],loader:()=>pt(()=>import("./scheme-BPhDTwHR.js"),[])});vt({id:"scss",extensions:[".scss"],aliases:["Sass","sass","scss"],mimetypes:["text/x-scss","text/scss"],loader:()=>pt(()=>import("./scss-CBJaRo0y.js"),[])});vt({id:"shell",extensions:[".sh",".bash"],aliases:["Shell","sh"],loader:()=>pt(()=>import("./shell-DiJ1NA_G.js"),[])});vt({id:"sol",extensions:[".sol"],aliases:["sol","solidity","Solidity"],loader:()=>pt(()=>import("./solidity-Db0IVjzk.js"),[])});vt({id:"aes",extensions:[".aes"],aliases:["aes","sophia","Sophia"],loader:()=>pt(()=>import("./sophia-CnS9iZB_.js"),[])});vt({id:"sparql",extensions:[".rq"],aliases:["sparql","SPARQL"],loader:()=>pt(()=>import("./sparql-CJmd_6j2.js"),[])});vt({id:"sql",extensions:[".sql"],aliases:["SQL"],loader:()=>pt(()=>import("./sql-ClhHkBeG.js"),[])});vt({id:"st",extensions:[".st",".iecst",".iecplc",".lc3lib",".TcPOU",".TcDUT",".TcGVL",".TcIO"],aliases:["StructuredText","scl","stl"],loader:()=>pt(()=>import("./st-CHwy0fLd.js"),[])});vt({id:"swift",aliases:["Swift","swift"],extensions:[".swift"],mimetypes:["text/swift"],loader:()=>pt(()=>import("./swift-Bqt4WxQ4.js"),[])});vt({id:"systemverilog",extensions:[".sv",".svh"],aliases:["SV","sv","SystemVerilog","systemverilog"],loader:()=>pt(()=>import("./systemverilog-Bs9z6M-B.js"),[])});vt({id:"verilog",extensions:[".v",".vh"],aliases:["V","v","Verilog","verilog"],loader:()=>pt(()=>import("./systemverilog-Bs9z6M-B.js"),[])});vt({id:"tcl",extensions:[".tcl"],aliases:["tcl","Tcl","tcltk","TclTk","tcl/tk","Tcl/Tk"],loader:()=>pt(()=>import("./tcl-Dm6ycUr_.js"),[])});vt({id:"twig",extensions:[".twig"],aliases:["Twig","twig"],mimetypes:["text/x-twig"],loader:()=>pt(()=>import("./twig-Csy3S7wG.js"),[])});vt({id:"typescript",extensions:[".ts",".tsx",".cts",".mts"],aliases:["TypeScript","ts","typescript"],mimetypes:["text/typescript"],loader:()=>pt(()=>import("./typescript-DG4B7a6p.js"),[])});vt({id:"typespec",extensions:[".tsp"],aliases:["TypeSpec"],loader:()=>pt(()=>import("./typespec-Btyra-wh.js"),[])});vt({id:"vb",extensions:[".vb"],aliases:["Visual Basic","vb"],loader:()=>pt(()=>import("./vb-Db0cS2oM.js"),[])});vt({id:"wgsl",extensions:[".wgsl"],aliases:["WebGPU Shading Language","WGSL","wgsl"],loader:()=>pt(()=>import("./wgsl-BTesnYfV.js"),[])});vt({id:"xml",extensions:[".xml",".xsd",".dtd",".ascx",".csproj",".config",".props",".targets",".wxi",".wxl",".wxs",".xaml",".svg",".svgz",".opf",".xslt",".xsl"],firstLine:"(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)",aliases:["XML","xml"],mimetypes:["text/xml","application/xml","application/xaml+xml","application/xml-dtd"],loader:()=>pt(()=>import("./xml-BnPiM_Gl.js"),[])});vt({id:"yaml",extensions:[".yaml",".yml"],aliases:["YAML","yaml","YML","yml"],mimetypes:["application/x-yaml","text/x-yaml"],loader:()=>pt(()=>import("./yaml-CGLjecYr.js"),[])});var HUt=Object.defineProperty,BUt=(n,e,t)=>e in n?HUt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,pi=(n,e,t)=>BUt(n,typeof e!="symbol"?e+"":e,t),G3,eSe,q3,Uq,K3;function VUt(n){return n.method!==void 0}var tSe;(function(n){function e(t){return t}n.create=e})(tSe||(tSe={}));var Rh;(function(n){n.parseError=-32700,n.invalidRequest=-32600,n.methodNotFound=-32601,n.invalidParams=-32602,n.internalError=-32603;function e(r){return-32099<=r&&r<=-32e3}n.isServerError=e;function t(r){if(!e(r))throw new Error("Invalid range for a server error.");return r}n.serverError=t,n.unexpectedServerError=-32e3;function i(r){return!0}n.isApplicationError=i;function s(r){return r}n.applicationError=s,n.genericApplicationError=-320100})(Rh||(Rh={}));var ZFe=class{constructor(){pi(this,"listeners",new Set),pi(this,"event",n=>(this.listeners.add(n),{dispose:()=>{this.listeners.delete(n)}}))}fire(n){this.listeners.forEach(e=>e(n))}},WUt=class{constructor(n){pi(this,"_value"),pi(this,"eventEmitter"),this._value=n,this.eventEmitter=new ZFe}get value(){return this._value}set value(n){this._value!==n&&(this._value=n,this.eventEmitter.fire(n))}get onChange(){return this.eventEmitter.event}};function zUt(n,e){const t=setTimeout(e,n);return{dispose:()=>clearTimeout(t)}}function $q(n,e,t){return n instanceof Set?(n.add(e),{dispose:()=>n.delete(e)}):(n.set(e,t),{dispose:()=>n.delete(e)})}var UUt=class{constructor(){pi(this,"_state","none"),pi(this,"promise"),pi(this,"resolve",()=>{}),pi(this,"reject",()=>{}),this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}get state(){return this._state}};G3=class{constructor(){pi(this,"_unprocessedMessages",[]),pi(this,"_messageListener"),pi(this,"id",G3.id++),pi(this,"_state",new WUt({state:"open"})),pi(this,"state",this._state)}setListener(n){if(this._messageListener=n,!!n)for(;this._unprocessedMessages.length>0&&this._messageListener!==void 0;){const e=this._unprocessedMessages.shift();this._messageListener(e)}}send(n){return this._sendImpl(n)}_dispatchReceivedMessage(n){this._unprocessedMessages.length===0&&this._messageListener?this._messageListener(n):this._unprocessedMessages.push(n)}_onConnectionClosed(){this._state.value={state:"closed",error:void 0}}log(n){return new $Ut(this,n??new GUt)}},pi(G3,"id",0);var $Ut=class{constructor(n,e){pi(this,"baseStream"),pi(this,"logger"),this.baseStream=n,this.logger=e}get state(){return this.baseStream.state}setListener(n){if(n===void 0){this.baseStream.setListener(void 0);return}this.baseStream.setListener(e=>{this.logger.log(this.baseStream,"incoming",e),n(e)})}send(n){return this.logger.log(this.baseStream,"outgoing",n),this.baseStream.send(n)}toString(){return`StreamLogger/${this.baseStream.toString()}`}},GUt=class{log(n,e,t){console.log(`${e==="incoming"?"<-":"->"} [${n.toString()}] ${JSON.stringify(t)}`)}},qUt=class YFe{constructor(e){pi(this,"connect"),this.connect=e}mapContext(e){return new YFe(t=>this.connect(t?KUt(t,e):void 0))}};function KUt(n,e){return{handleNotification:(t,i)=>n.handleNotification(t,e(i)),handleRequest:(t,i,s)=>n.handleRequest(t,i,e(s))}}var ZUt=class XFe{constructor(e,t,i){pi(this,"_stream"),pi(this,"_listener"),pi(this,"_logger"),pi(this,"_unprocessedResponses",new Map),pi(this,"_lastUsedRequestId",0),this._stream=e,this._listener=t,this._logger=i,this._stream.setListener(s=>{VUt(s)?s.id===void 0?this._processNotification(s):this._processRequest(s):this._processResponse(s)})}static createChannel(e,t){let i=!1;return new qUt(s=>{if(i)throw new Error(`A channel to the stream ${e} was already constructed!`);return i=!0,new XFe(e,s,t)})}get state(){return this._stream.state}async _processNotification(e){if(e.id!==void 0)throw new Error;if(!this._listener){this._logger&&this._logger.debug({text:"Notification ignored",message:e});return}try{await this._listener.handleNotification({method:e.method,params:e.params||null})}catch(t){this._logger&&this._logger.warn({text:`Exception was thrown while handling notification: ${t}`,exception:t,message:e})}}async _processRequest(e){if(e.id===void 0)throw new Error;let t;if(this._listener)try{t=await this._listener.handleRequest({method:e.method,params:e.params||null},e.id)}catch(s){this._logger&&this._logger.warn({text:`Exception was thrown while handling request: ${s}`,message:e,exception:s}),t={error:{code:Rh.internalError,message:"An unexpected exception was thrown.",data:void 0}}}else this._logger&&this._logger.debug({text:"Received request even though not listening for requests",message:e}),t={error:{code:Rh.methodNotFound,message:"This endpoint does not listen for requests or notifications.",data:void 0}};let i;"result"in t?i={jsonrpc:"2.0",id:e.id,result:t.result}:i={jsonrpc:"2.0",id:e.id,error:t.error},await this._stream.send(i)}_processResponse(e){const t=""+e.id,i=this._unprocessedResponses.get(t);if(!i){this._logger&&this._logger.debug({text:"Got an unexpected response message",message:e});return}this._unprocessedResponses.delete(t),i(e)}_newRequestId(){return this._lastUsedRequestId++}sendRequest(e,t,i){const s={jsonrpc:"2.0",id:this._newRequestId(),method:e.method,params:e.params||void 0};return i&&i(s.id),new Promise((r,o)=>{const a=""+s.id;this._unprocessedResponses.set(a,l=>{"result"in l?r({result:l.result}):(l.error||o(new Error("Response had neither 'result' nor 'error' field set.")),r({error:l.error}))}),this._stream.send(s).then(void 0,l=>{this._unprocessedResponses.delete(a),o(l)})})}sendNotification(e,t){const i={jsonrpc:"2.0",id:void 0,method:e.method,params:e.params||void 0};return this._stream.send(i)}toString(){return"StreamChannel/"+this._stream.toString()}},pD;(function(n){function e(){return{deserializeFromJson:s=>({hasErrors:!1,value:s}),serializeToJson:s=>s}}n.sAny=e;function t(){return{deserializeFromJson:s=>({hasErrors:!1,value:{}}),serializeToJson:s=>({})}}n.sEmptyObject=t;function i(){return{deserializeFromJson:s=>({hasErrors:!1,value:void 0}),serializeToJson:s=>null}}n.sVoidFromNull=i})(pD||(pD={}));const QFe=Symbol("OptionalMethodNotFound");var JFe=class{contextualize(n){return new YUt(this,n)}},YUt=class extends JFe{constructor(n,e){super(),pi(this,"underylingTypedChannel"),pi(this,"converters"),this.underylingTypedChannel=n,this.converters=e}async request(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.request(n,e,i)}async notify(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.notify(n,e,i)}registerNotificationHandler(n,e){return this.underylingTypedChannel.registerNotificationHandler(n,async(t,i)=>await e(t,await this.converters.getNewContext(i)))}registerRequestHandler(n,e){return this.underylingTypedChannel.registerRequestHandler(n,async(t,i,s)=>await e(t,i,await this.converters.getNewContext(s)))}},iSe=class e8e extends JFe{constructor(e,t={}){super(),pi(this,"channelCtor"),pi(this,"_requestSender"),pi(this,"_handler",new Map),pi(this,"_unknownNotificationHandler",new Set),pi(this,"_timeout"),pi(this,"sendExceptionDetails",!1),pi(this,"_logger"),pi(this,"listeningDeferred",new UUt),pi(this,"onListening",this.listeningDeferred.promise),pi(this,"_requestDidErrorEventEmitter",new ZFe),pi(this,"onRequestDidError",this._requestDidErrorEventEmitter.event),this.channelCtor=e,this._logger=t.logger,this.sendExceptionDetails=!!t.sendExceptionDetails,this._timeout=zUt(1e3,()=>{this._requestSender||console.warn(`"${this.startListen.name}" has not been called within 1 second after construction of this channel. Did you forget to call it?`,this)})}static fromTransport(e,t={}){return new e8e(ZUt.createChannel(e,t.logger),t)}startListen(){if(this._requestSender)throw new Error(`"${this.startListen.name}" can be called only once, but it already has been called.`);this._timeout&&(this._timeout.dispose(),this._timeout=void 0),this._requestSender=this.channelCtor.connect({handleRequest:(e,t,i)=>this.handleRequest(e,t,i),handleNotification:(e,t)=>this.handleNotification(e,t)}),this.listeningDeferred.resolve()}checkChannel(e){if(!e)throw new Error(`"${this.startListen.name}" must be called before any messages can be sent or received.`);return!0}async handleRequest(e,t,i){const s=this._handler.get(e.method);if(!s)return this._logger&&this._logger.debug({text:`No request handler for "${e.method}".`,data:{requestObject:e}}),{error:{code:Rh.methodNotFound,message:`No request handler for "${e.method}".`,data:{method:e.method}}};if(s.kind!="request"){const o=`"${e.method}" is registered as notification, but was sent as request.`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e}}),{error:{code:Rh.invalidRequest,message:o,data:{method:e.method}}}}const r=s.requestType.paramsSerializer.deserializeFromJson(e.params);if(r.hasErrors){const o=`Got invalid params: ${r.errorMessage}`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e,errorMessage:r.errorMessage}}),{error:{code:Rh.invalidParams,message:o,data:{errors:r.errorMessage}}}}else{const o=r.value;let a;try{const l=await s.handler(o,t,i);if("error"in l||"errorMessage"in l){const c=l.error?s.requestType.errorSerializer.serializeToJson(l.error):void 0;a={error:{code:l.errorCode||Rh.genericApplicationError,message:l.errorMessage||"An error was returned",data:c}}}else a={result:s.requestType.resultSerializer.serializeToJson(l.ok)}}catch(l){l instanceof sSe?a={error:{code:l.code,message:l.message}}:(this._logger&&this._logger.warn({text:`An exception was thrown while handling a request: ${l}.`,exception:l,data:{requestObject:e}}),a={error:{code:Rh.unexpectedServerError,message:this.sendExceptionDetails?`An exception was thrown while handling a request: ${l}.`:"Server has thrown an unexpected exception"}})}return a}}async handleNotification(e,t){const i=this._handler.get(e.method);if(!i){for(const o of this._unknownNotificationHandler)o(e);this._unknownNotificationHandler.size===0&&this._logger&&this._logger.debug({text:`Unhandled notification "${e.method}"`,data:{requestObject:e}});return}if(i.kind!="notification"){this._logger&&this._logger.debug({text:`"${e.method}" is registered as request, but was sent as notification.`,data:{requestObject:e}});return}const s=i.notificationType.paramsSerializer.deserializeFromJson(e.params);if(s.hasErrors){this._logger&&this._logger.debug({text:`Got invalid params: ${s}`,data:{requestObject:e,errorMessage:s.errorMessage}});return}const r=s.value;for(const o of i.handlers)try{o(r,t)}catch(a){this._logger&&this._logger.warn({text:`An exception was thrown while handling a notification: ${a}.`,exception:a,data:{requestObject:e}})}}registerUnknownNotificationHandler(e){return $q(this._unknownNotificationHandler,e)}registerRequestHandler(e,t){if(this._handler.get(e.method))throw new Error(`Handler with method "${e.method}" already registered.`);return $q(this._handler,e.method,{kind:"request",requestType:e,handler:t})}registerNotificationHandler(e,t){let i=this._handler.get(e.method);if(!i)i={kind:"notification",notificationType:e,handlers:new Set},this._handler.set(e.method,i);else{if(i.kind!=="notification")throw new Error(`Method "${e.method}" was already registered as request handler.`);if(i.notificationType!==e)throw new Error(`Method "${e.method}" was registered for a different type.`)}return $q(i.handlers,t)}getRegisteredTypes(){const e=[];for(const t of this._handler.values())t.kind==="notification"?e.push(t.notificationType):t.kind==="request"&&e.push(t.requestType);return e}async request(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error("Impossible");const s=e.paramsSerializer.serializeToJson(t);nSe(s);const r=await this._requestSender.sendRequest({method:e.method,params:s},i);if("error"in r){if(e.isOptional&&r.error.code===Rh.methodNotFound)return QFe;let o;if(r.error.data!==void 0){const l=e.errorSerializer.deserializeFromJson(r.error.data);if(l.hasErrors)throw new Error(l.errorMessage);o=l.value}else o=void 0;const a=new sSe(r.error.message,o,r.error.code);throw this._requestDidErrorEventEmitter.fire({error:a}),a}else{const o=e.resultSerializer.deserializeFromJson(r.result);if(o.hasErrors)throw new Error("Could not deserialize response: "+o.errorMessage+`
|
|
1649
1649
|
|
|
1650
1650
|
${JSON.stringify(r,null,2)}`);return o.value}}async notify(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error;const s=e.paramsSerializer.serializeToJson(t);nSe(s),this._requestSender.sendNotification({method:e.method,params:s},i)}};function nSe(n){if(n!==null&&Array.isArray(n)&&typeof n!="object")throw new Error("Invalid value! Only null, array and object is allowed.")}var sSe=class t8e extends Error{constructor(e,t,i=Rh.genericApplicationError){super(e),pi(this,"data"),pi(this,"code"),this.data=t,this.code=i,Object.setPrototypeOf(this,t8e.prototype)}},XUt=class Cne{constructor(e,t,i,s,r=!1){pi(this,"method"),pi(this,"paramsSerializer"),pi(this,"resultSerializer"),pi(this,"errorSerializer"),pi(this,"isOptional"),pi(this,"kind","request"),this.method=e,this.paramsSerializer=t,this.resultSerializer=i,this.errorSerializer=s,this.isOptional=r}withMethod(e){return new Cne(e,this.paramsSerializer,this.resultSerializer,this.errorSerializer)}optional(){return new Cne(this.method,this.paramsSerializer,this.resultSerializer,this.errorSerializer,!0)}},QUt=class i8e{constructor(e,t){pi(this,"method"),pi(this,"paramsSerializer"),pi(this,"kind","notification"),this.method=e,this.paramsSerializer=t}withMethod(e){return new i8e(e,this.paramsSerializer)}};function Kt(n){return new XUt((n||{}).method,pD.sAny(),pD.sAny(),pD.sAny())}function dr(n){return new QUt((n||{}).method,pD.sAny())}const JUt=Symbol();var rSe=(eSe=JUt,q3=class{constructor(n){pi(this,"error"),pi(this,eSe),this.error=n}},pi(q3,"factory",n=>new q3(n)),q3);function e$t(n){const e=oSe(n.server),t=oSe(n.client);return new t$t(n.tags||[],e,t)}function oSe(n){const e={};for(const[t,i]of Object.entries(n)){const s=i.method?i.method:t;e[t]=i.withMethod(s)}return e}var t$t=class n8e{constructor(e=[],t,i){pi(this,"tags"),pi(this,"server"),pi(this,"client"),this.tags=e,this.server=t,this.client=i}_onlyDesignTime(){return new Error("This property is not meant to be accessed at runtime")}get TContractObject(){throw this._onlyDesignTime()}get TClientInterface(){throw this._onlyDesignTime()}get TServerInterface(){throw this._onlyDesignTime()}get TClientHandler(){throw this._onlyDesignTime()}get TServerHandler(){throw this._onlyDesignTime()}get TTags(){throw this._onlyDesignTime()}getInterface(e,t,i,s){const r=this.buildCounterpart(e,i),o=this.registerHandlers(e,t,s,r);return{counterpart:r,dispose:()=>o.dispose()}}buildCounterpart(e,t){const i={};for(const[s,r]of Object.entries(t)){let o;r.kind==="request"?r.isOptional?o=async(a,l)=>{a===void 0&&(a={});try{return await e.request(r,a,l)}catch(c){if(c&&c.code===Rh.methodNotFound)return QFe;throw c}}:o=(a,l)=>(a===void 0&&(a={}),e.request(r,a,l)):o=(a,l)=>(a===void 0&&(a={}),e.notify(r,a,l)),i[s]=o}return i}registerHandlers(e,t,i,s){const r=[];for(const[o,a]of Object.entries(t))if(a.kind==="request"){let l=i[o];if(!l)continue;const c=this.createRequestHandler(s,l);r.push(e.registerRequestHandler(a,c))}else{const l=i[o];l&&r.push(e.registerNotificationHandler(a,(c,d)=>{l(c,{context:d,counterpart:s})}))}return{dispose:()=>r.forEach(o=>o.dispose())}}createRequestHandler(e,t){return async(i,s,r)=>{const o=await t(i,{context:r,counterpart:e,newErr:rSe.factory,requestId:s});return o instanceof rSe?o.error:{ok:o}}}static getServerFromStream(e,t,i,s){const r=iSe.fromTransport(t,i),{server:o}=e.getServer(r,s);return r.startListen(),{channel:r,server:o}}static registerServerToStream(e,t,i,s){const r=iSe.fromTransport(t,i),{client:o}=e.registerServer(r,s);return r.startListen(),{channel:r,client:o}}getServer(e,t){const{counterpart:i,dispose:s}=this.getInterface(e,this.client,this.server,t);return{server:i,dispose:s}}registerServer(e,t){const{counterpart:i,dispose:s}=this.getInterface(e,this.server,this.client,t);return{client:i,dispose:s}}withContext(){return new n8e(this.tags,this.server,this.client)}};let Gq=(function(n){return n.Comment="comment",n.Imports="imports",n.Region="region",n})({}),Or=(function(n){return n[n.File=1]="File",n[n.Module=2]="Module",n[n.Namespace=3]="Namespace",n[n.Package=4]="Package",n[n.Class=5]="Class",n[n.Method=6]="Method",n[n.Property=7]="Property",n[n.Field=8]="Field",n[n.Constructor=9]="Constructor",n[n.Enum=10]="Enum",n[n.Interface=11]="Interface",n[n.Function=12]="Function",n[n.Variable=13]="Variable",n[n.Constant=14]="Constant",n[n.String=15]="String",n[n.Number=16]="Number",n[n.Boolean=17]="Boolean",n[n.Array=18]="Array",n[n.Object=19]="Object",n[n.Key=20]="Key",n[n.Null=21]="Null",n[n.EnumMember=22]="EnumMember",n[n.Struct=23]="Struct",n[n.Event=24]="Event",n[n.Operator=25]="Operator",n[n.TypeParameter=26]="TypeParameter",n})({}),i$t=(function(n){return n[n.Deprecated=1]="Deprecated",n})({}),aSe=(function(n){return n[n.Type=1]="Type",n[n.Parameter=2]="Parameter",n})({}),Wr=(function(n){return n[n.Text=1]="Text",n[n.Method=2]="Method",n[n.Function=3]="Function",n[n.Constructor=4]="Constructor",n[n.Field=5]="Field",n[n.Variable=6]="Variable",n[n.Class=7]="Class",n[n.Interface=8]="Interface",n[n.Module=9]="Module",n[n.Property=10]="Property",n[n.Unit=11]="Unit",n[n.Value=12]="Value",n[n.Enum=13]="Enum",n[n.Keyword=14]="Keyword",n[n.Snippet=15]="Snippet",n[n.Color=16]="Color",n[n.File=17]="File",n[n.Reference=18]="Reference",n[n.Folder=19]="Folder",n[n.EnumMember=20]="EnumMember",n[n.Constant=21]="Constant",n[n.Struct=22]="Struct",n[n.Event=23]="Event",n[n.Operator=24]="Operator",n[n.TypeParameter=25]="TypeParameter",n})({}),n$t=(function(n){return n[n.Deprecated=1]="Deprecated",n})({}),s$t=(function(n){return n[n.PlainText=1]="PlainText",n[n.Snippet=2]="Snippet",n})({}),qq=(function(n){return n[n.Text=1]="Text",n[n.Read=2]="Read",n[n.Write=3]="Write",n})({}),o1=(function(n){return n[n.Error=1]="Error",n[n.Warning=2]="Warning",n[n.Information=3]="Information",n[n.Hint=4]="Hint",n})({}),lSe=(function(n){return n[n.Unnecessary=1]="Unnecessary",n[n.Deprecated=2]="Deprecated",n})({}),Kq=(function(n){return n[n.Invoked=1]="Invoked",n[n.TriggerCharacter=2]="TriggerCharacter",n[n.TriggerForIncompleteCompletions=3]="TriggerForIncompleteCompletions",n})({}),Zq=(function(n){return n[n.Invoked=1]="Invoked",n[n.TriggerCharacter=2]="TriggerCharacter",n[n.ContentChange=3]="ContentChange",n})({}),cSe=(function(n){return n[n.Invoked=1]="Invoked",n[n.Automatic=2]="Automatic",n})({});var Oi=class{constructor(n){this.method=n}};const r$t={textDocumentImplementation:new Oi("textDocument/implementation"),textDocumentTypeDefinition:new Oi("textDocument/typeDefinition"),textDocumentDocumentColor:new Oi("textDocument/documentColor"),textDocumentColorPresentation:new Oi("textDocument/colorPresentation"),textDocumentFoldingRange:new Oi("textDocument/foldingRange"),textDocumentDeclaration:new Oi("textDocument/declaration"),textDocumentSelectionRange:new Oi("textDocument/selectionRange"),textDocumentPrepareCallHierarchy:new Oi("textDocument/prepareCallHierarchy"),textDocumentSemanticTokensFull:new Oi("textDocument/semanticTokens/full"),textDocumentSemanticTokensFullDelta:new Oi("textDocument/semanticTokens/full/delta"),textDocumentLinkedEditingRange:new Oi("textDocument/linkedEditingRange"),workspaceWillCreateFiles:new Oi("workspace/willCreateFiles"),workspaceWillRenameFiles:new Oi("workspace/willRenameFiles"),workspaceWillDeleteFiles:new Oi("workspace/willDeleteFiles"),textDocumentMoniker:new Oi("textDocument/moniker"),textDocumentPrepareTypeHierarchy:new Oi("textDocument/prepareTypeHierarchy"),textDocumentInlineValue:new Oi("textDocument/inlineValue"),textDocumentInlayHint:new Oi("textDocument/inlayHint"),textDocumentDiagnostic:new Oi("textDocument/diagnostic"),textDocumentInlineCompletion:new Oi("textDocument/inlineCompletion"),textDocumentWillSaveWaitUntil:new Oi("textDocument/willSaveWaitUntil"),textDocumentCompletion:new Oi("textDocument/completion"),textDocumentHover:new Oi("textDocument/hover"),textDocumentSignatureHelp:new Oi("textDocument/signatureHelp"),textDocumentDefinition:new Oi("textDocument/definition"),textDocumentReferences:new Oi("textDocument/references"),textDocumentDocumentHighlight:new Oi("textDocument/documentHighlight"),textDocumentDocumentSymbol:new Oi("textDocument/documentSymbol"),textDocumentCodeAction:new Oi("textDocument/codeAction"),workspaceSymbol:new Oi("workspace/symbol"),textDocumentCodeLens:new Oi("textDocument/codeLens"),textDocumentDocumentLink:new Oi("textDocument/documentLink"),textDocumentFormatting:new Oi("textDocument/formatting"),textDocumentRangeFormatting:new Oi("textDocument/rangeFormatting"),textDocumentRangesFormatting:new Oi("textDocument/rangesFormatting"),textDocumentOnTypeFormatting:new Oi("textDocument/onTypeFormatting"),textDocumentRename:new Oi("textDocument/rename"),workspaceExecuteCommand:new Oi("workspace/executeCommand"),workspaceDidCreateFiles:new Oi("workspace/didCreateFiles"),workspaceDidRenameFiles:new Oi("workspace/didRenameFiles"),workspaceDidDeleteFiles:new Oi("workspace/didDeleteFiles"),workspaceDidChangeConfiguration:new Oi("workspace/didChangeConfiguration"),textDocumentDidOpen:new Oi("textDocument/didOpen"),textDocumentDidChange:new Oi("textDocument/didChange"),textDocumentDidClose:new Oi("textDocument/didClose"),textDocumentDidSave:new Oi("textDocument/didSave"),textDocumentWillSave:new Oi("textDocument/willSave"),workspaceDidChangeWatchedFiles:new Oi("workspace/didChangeWatchedFiles")};e$t({server:{textDocumentImplementation:Kt({method:"textDocument/implementation"}),textDocumentTypeDefinition:Kt({method:"textDocument/typeDefinition"}),textDocumentDocumentColor:Kt({method:"textDocument/documentColor"}),textDocumentColorPresentation:Kt({method:"textDocument/colorPresentation"}),textDocumentFoldingRange:Kt({method:"textDocument/foldingRange"}),textDocumentDeclaration:Kt({method:"textDocument/declaration"}),textDocumentSelectionRange:Kt({method:"textDocument/selectionRange"}),textDocumentPrepareCallHierarchy:Kt({method:"textDocument/prepareCallHierarchy"}),callHierarchyIncomingCalls:Kt({method:"callHierarchy/incomingCalls"}),callHierarchyOutgoingCalls:Kt({method:"callHierarchy/outgoingCalls"}),textDocumentSemanticTokensFull:Kt({method:"textDocument/semanticTokens/full"}),textDocumentSemanticTokensFullDelta:Kt({method:"textDocument/semanticTokens/full/delta"}),textDocumentSemanticTokensRange:Kt({method:"textDocument/semanticTokens/range"}),textDocumentLinkedEditingRange:Kt({method:"textDocument/linkedEditingRange"}),workspaceWillCreateFiles:Kt({method:"workspace/willCreateFiles"}),workspaceWillRenameFiles:Kt({method:"workspace/willRenameFiles"}),workspaceWillDeleteFiles:Kt({method:"workspace/willDeleteFiles"}),textDocumentMoniker:Kt({method:"textDocument/moniker"}),textDocumentPrepareTypeHierarchy:Kt({method:"textDocument/prepareTypeHierarchy"}),typeHierarchySupertypes:Kt({method:"typeHierarchy/supertypes"}),typeHierarchySubtypes:Kt({method:"typeHierarchy/subtypes"}),textDocumentInlineValue:Kt({method:"textDocument/inlineValue"}),textDocumentInlayHint:Kt({method:"textDocument/inlayHint"}),inlayHintResolve:Kt({method:"inlayHint/resolve"}),textDocumentDiagnostic:Kt({method:"textDocument/diagnostic"}),workspaceDiagnostic:Kt({method:"workspace/diagnostic"}),textDocumentInlineCompletion:Kt({method:"textDocument/inlineCompletion"}),initialize:Kt({method:"initialize"}),shutdown:Kt({method:"shutdown"}),textDocumentWillSaveWaitUntil:Kt({method:"textDocument/willSaveWaitUntil"}),textDocumentCompletion:Kt({method:"textDocument/completion"}),completionItemResolve:Kt({method:"completionItem/resolve"}),textDocumentHover:Kt({method:"textDocument/hover"}),textDocumentSignatureHelp:Kt({method:"textDocument/signatureHelp"}),textDocumentDefinition:Kt({method:"textDocument/definition"}),textDocumentReferences:Kt({method:"textDocument/references"}),textDocumentDocumentHighlight:Kt({method:"textDocument/documentHighlight"}),textDocumentDocumentSymbol:Kt({method:"textDocument/documentSymbol"}),textDocumentCodeAction:Kt({method:"textDocument/codeAction"}),codeActionResolve:Kt({method:"codeAction/resolve"}),workspaceSymbol:Kt({method:"workspace/symbol"}),workspaceSymbolResolve:Kt({method:"workspaceSymbol/resolve"}),textDocumentCodeLens:Kt({method:"textDocument/codeLens"}),codeLensResolve:Kt({method:"codeLens/resolve"}),textDocumentDocumentLink:Kt({method:"textDocument/documentLink"}),documentLinkResolve:Kt({method:"documentLink/resolve"}),textDocumentFormatting:Kt({method:"textDocument/formatting"}),textDocumentRangeFormatting:Kt({method:"textDocument/rangeFormatting"}),textDocumentRangesFormatting:Kt({method:"textDocument/rangesFormatting"}),textDocumentOnTypeFormatting:Kt({method:"textDocument/onTypeFormatting"}),textDocumentRename:Kt({method:"textDocument/rename"}),textDocumentPrepareRename:Kt({method:"textDocument/prepareRename"}),workspaceExecuteCommand:Kt({method:"workspace/executeCommand"}),workspaceDidChangeWorkspaceFolders:dr({method:"workspace/didChangeWorkspaceFolders"}),windowWorkDoneProgressCancel:dr({method:"window/workDoneProgress/cancel"}),workspaceDidCreateFiles:dr({method:"workspace/didCreateFiles"}),workspaceDidRenameFiles:dr({method:"workspace/didRenameFiles"}),workspaceDidDeleteFiles:dr({method:"workspace/didDeleteFiles"}),notebookDocumentDidOpen:dr({method:"notebookDocument/didOpen"}),notebookDocumentDidChange:dr({method:"notebookDocument/didChange"}),notebookDocumentDidSave:dr({method:"notebookDocument/didSave"}),notebookDocumentDidClose:dr({method:"notebookDocument/didClose"}),initialized:dr({method:"initialized"}),exit:dr({method:"exit"}),workspaceDidChangeConfiguration:dr({method:"workspace/didChangeConfiguration"}),textDocumentDidOpen:dr({method:"textDocument/didOpen"}),textDocumentDidChange:dr({method:"textDocument/didChange"}),textDocumentDidClose:dr({method:"textDocument/didClose"}),textDocumentDidSave:dr({method:"textDocument/didSave"}),textDocumentWillSave:dr({method:"textDocument/willSave"}),workspaceDidChangeWatchedFiles:dr({method:"workspace/didChangeWatchedFiles"}),setTrace:dr({method:"$/setTrace"}),cancelRequest:dr({method:"$/cancelRequest"}),progress:dr({method:"$/progress"})},client:{workspaceWorkspaceFolders:Kt({method:"workspace/workspaceFolders"}).optional(),workspaceConfiguration:Kt({method:"workspace/configuration"}).optional(),workspaceFoldingRangeRefresh:Kt({method:"workspace/foldingRange/refresh"}).optional(),windowWorkDoneProgressCreate:Kt({method:"window/workDoneProgress/create"}).optional(),workspaceSemanticTokensRefresh:Kt({method:"workspace/semanticTokens/refresh"}).optional(),windowShowDocument:Kt({method:"window/showDocument"}).optional(),workspaceInlineValueRefresh:Kt({method:"workspace/inlineValue/refresh"}).optional(),workspaceInlayHintRefresh:Kt({method:"workspace/inlayHint/refresh"}).optional(),workspaceDiagnosticRefresh:Kt({method:"workspace/diagnostic/refresh"}).optional(),clientRegisterCapability:Kt({method:"client/registerCapability"}).optional(),clientUnregisterCapability:Kt({method:"client/unregisterCapability"}).optional(),windowShowMessageRequest:Kt({method:"window/showMessageRequest"}).optional(),workspaceCodeLensRefresh:Kt({method:"workspace/codeLens/refresh"}).optional(),workspaceApplyEdit:Kt({method:"workspace/applyEdit"}).optional(),windowShowMessage:dr({method:"window/showMessage"}),windowLogMessage:dr({method:"window/logMessage"}),telemetryEvent:dr({method:"telemetry/event"}),textDocumentPublishDiagnostics:dr({method:"textDocument/publishDiagnostics"}),logTrace:dr({method:"$/logTrace"}),cancelRequest:dr({method:"$/cancelRequest"}),progress:dr({method:"$/progress"})}});Uq=class{constructor(){pi(this,"_store",new o$t)}dispose(){this._store.dispose()}_register(n){if(n===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(n)}},pi(Uq,"None",Object.freeze({dispose(){}}));var o$t=(K3=class{constructor(){pi(this,"_toDispose",new Set),pi(this,"_isDisposed",!1)}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}clear(){if(this._toDispose.size!==0)try{for(const n of this._toDispose)n.dispose()}finally{this._toDispose.clear()}}add(n){if(!n)return n;if(n===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?K3.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(n),n}},pi(K3,"DISABLE_DISPOSED_WARNING",!1),K3);Nt.CodeActionTriggerType.Invoke,cSe.Invoked,Nt.CodeActionTriggerType.Auto,cSe.Automatic;Wr.Text,Nt.CompletionItemKind.Text,Wr.Method,Nt.CompletionItemKind.Method,Wr.Function,Nt.CompletionItemKind.Function,Wr.Constructor,Nt.CompletionItemKind.Constructor,Wr.Field,Nt.CompletionItemKind.Field,Wr.Variable,Nt.CompletionItemKind.Variable,Wr.Class,Nt.CompletionItemKind.Class,Wr.Interface,Nt.CompletionItemKind.Interface,Wr.Module,Nt.CompletionItemKind.Module,Wr.Property,Nt.CompletionItemKind.Property,Wr.Unit,Nt.CompletionItemKind.Unit,Wr.Value,Nt.CompletionItemKind.Value,Wr.Enum,Nt.CompletionItemKind.Enum,Wr.Keyword,Nt.CompletionItemKind.Keyword,Wr.Snippet,Nt.CompletionItemKind.Snippet,Wr.Color,Nt.CompletionItemKind.Color,Wr.File,Nt.CompletionItemKind.File,Wr.Reference,Nt.CompletionItemKind.Reference,Wr.Folder,Nt.CompletionItemKind.Folder,Wr.EnumMember,Nt.CompletionItemKind.EnumMember,Wr.Constant,Nt.CompletionItemKind.Constant,Wr.Struct,Nt.CompletionItemKind.Struct,Wr.Event,Nt.CompletionItemKind.Event,Wr.Operator,Nt.CompletionItemKind.Operator,Wr.TypeParameter,Nt.CompletionItemKind.TypeParameter;n$t.Deprecated,Nt.CompletionItemTag.Deprecated;Nt.CompletionTriggerKind.Invoke,Kq.Invoked,Nt.CompletionTriggerKind.TriggerCharacter,Kq.TriggerCharacter,Nt.CompletionTriggerKind.TriggerForIncompleteCompletions,Kq.TriggerForIncompleteCompletions;s$t.Snippet,Nt.CompletionItemInsertTextRule.InsertAsSnippet;Or.File,Nt.SymbolKind.File,Or.Module,Nt.SymbolKind.Module,Or.Namespace,Nt.SymbolKind.Namespace,Or.Package,Nt.SymbolKind.Package,Or.Class,Nt.SymbolKind.Class,Or.Method,Nt.SymbolKind.Method,Or.Property,Nt.SymbolKind.Property,Or.Field,Nt.SymbolKind.Field,Or.Constructor,Nt.SymbolKind.Constructor,Or.Enum,Nt.SymbolKind.Enum,Or.Interface,Nt.SymbolKind.Interface,Or.Function,Nt.SymbolKind.Function,Or.Variable,Nt.SymbolKind.Variable,Or.Constant,Nt.SymbolKind.Constant,Or.String,Nt.SymbolKind.String,Or.Number,Nt.SymbolKind.Number,Or.Boolean,Nt.SymbolKind.Boolean,Or.Array,Nt.SymbolKind.Array,Or.Object,Nt.SymbolKind.Object,Or.Key,Nt.SymbolKind.Key,Or.Null,Nt.SymbolKind.Null,Or.EnumMember,Nt.SymbolKind.EnumMember,Or.Struct,Nt.SymbolKind.Struct,Or.Event,Nt.SymbolKind.Event,Or.Operator,Nt.SymbolKind.Operator,Or.TypeParameter,Nt.SymbolKind.TypeParameter;i$t.Deprecated,Nt.SymbolTag.Deprecated;qq.Text,Nt.DocumentHighlightKind.Text,qq.Read,Nt.DocumentHighlightKind.Read,qq.Write,Nt.DocumentHighlightKind.Write;Gq.Comment,Nt.FoldingRangeKind.Comment,Gq.Imports,Nt.FoldingRangeKind.Imports,Gq.Region,Nt.FoldingRangeKind.Region;m_.Error,o1.Error,m_.Warning,o1.Warning,m_.Info,o1.Information,m_.Hint,o1.Hint;o1.Error,m_.Error,o1.Warning,m_.Warning,o1.Information,m_.Info,o1.Hint,m_.Hint;lSe.Unnecessary,vne.Unnecessary,lSe.Deprecated,vne.Deprecated;Nt.SignatureHelpTriggerKind.Invoke,Zq.Invoked,Nt.SignatureHelpTriggerKind.TriggerCharacter,Zq.TriggerCharacter,Nt.SignatureHelpTriggerKind.ContentChange,Zq.ContentChange;aSe.Type,Nt.InlayHintKind.Type,aSe.Parameter,Nt.InlayHintKind.Parameter;new Map([...Object.values(r$t)].map(n=>[n.method,n]));function a$t(n,e){var i;const t=globalThis.MonacoEnvironment;if(t!=null&&t.createTrustedTypesPolicy)try{return t.createTrustedTypesPolicy(n,e)}catch(s){console.error(s);return}try{return(i=globalThis.trustedTypes)==null?void 0:i.createPolicy(n,e)}catch(s){console.error(s);return}}let h7;typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope"&&globalThis.workerttPolicy!==void 0?h7=globalThis.workerttPolicy:h7=a$t("defaultWorkerFactory",{createScriptURL:n=>n});function l$t(n){const e=n.label,t=globalThis.MonacoEnvironment;if(t){if(typeof t.getWorker=="function")return t.getWorker("workerMain.js",e);if(typeof t.getWorkerUrl=="function"){const i=t.getWorkerUrl("workerMain.js",e);return new Worker(h7?h7.createScriptURL(i):i,{name:e,type:"module"})}}if(n.createWorker)return n.createWorker();throw new Error("You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker")}function LYt(n){const e=Promise.resolve(l$t({label:n.label??"monaco-editor-worker",moduleId:n.moduleId,createWorker:n.createWorker})).then(t=>(t.postMessage("ignore"),t.postMessage(n.createData),t));return TFe.createWebWorker({worker:e,host:n.host,keepIdleModels:n.keepIdleModels})}function s8e(){return CUt}const Yq=globalThis.MonacoEnvironment;Yq!=null&&Yq.globalAPI&&(globalThis.monaco=s8e());const eW=s8e();eW.languages.css=wUt;eW.languages.html=RUt;eW.languages.typescript=jUt;eW.languages.json=AUt;const c$t=[{label:"prompt",insertText:`{{#prompt}}
|
|
1651
1651
|
$0
|