@owox/web 0.18.0-next-20260127111051 → 0.18.0-next-20260127120603

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.
@@ -825,9 +825,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
825
825
  monaco.config({ paths: { vs: '...' } })
826
826
 
827
827
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
828
- `},_N=aoe(loe)(F6),coe={config:ooe},uoe=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(s){return n.reduceRight(function(i,c){return c(i)},s)}};function H6(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],H6(e[n],t[n]))}),RN(RN({},e),t)}var doe={type:"cancelation",msg:"operation is manually canceled"};function $1(e){var t=!1,n=new Promise(function(r,s){e.then(function(i){return t?s(doe):r(i)}),e.catch(s)});return n.cancel=function(){return t=!0},n}var foe=["monaco"],hoe=noe.create({config:roe,isInitialized:!1,resolve:null,reject:null,monaco:null}),$6=Use(hoe,2),sm=$6[0],my=$6[1];function moe(e){var t=coe.config(e),n=t.monaco,r=Lse(t,foe);my(function(s){return{config:H6(s.config,r),monaco:n}})}function poe(){var e=sm(function(t){var n=t.monaco,r=t.isInitialized,s=t.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!e.isInitialized){if(my({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),$1(V1);if(window.monaco&&window.monaco.editor)return V6(window.monaco),e.resolve(window.monaco),$1(V1);uoe(goe,yoe)(voe)}return $1(V1)}function goe(e){return document.body.appendChild(e)}function xoe(e){var t=document.createElement("script");return e&&(t.src=e),t}function yoe(e){var t=sm(function(r){var s=r.config,i=r.reject;return{config:s,reject:i}}),n=xoe("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function voe(){var e=sm(function(n){var r=n.config,s=n.resolve,i=n.reject;return{config:r,resolve:s,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){var r=n.m||n;V6(r),e.resolve(r)},function(n){e.reject(n)})}function V6(e){sm().monaco||my({monaco:e})}function boe(){return sm(function(e){var t=e.monaco;return t})}var V1=new Promise(function(e,t){return my({resolve:e,reject:t})}),G6={config:moe,init:poe,__getMonacoInstance:boe},Soe={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},G1=Soe,Coe={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Eoe=Coe;function woe({children:e}){return re.createElement("div",{style:Eoe.container},e)}var Roe=woe,joe=Roe;function Toe({width:e,height:t,isEditorReady:n,loading:r,_ref:s,className:i,wrapperProps:c}){return re.createElement("section",{style:{...G1.wrapper,width:e,height:t},...c},!n&&re.createElement(joe,null,r),re.createElement("div",{ref:s,style:{...G1.fullWidth,...!n&&G1.hide},className:i}))}var _oe=Toe,B6=h.memo(_oe);function Noe(e){h.useEffect(e,[])}var q6=Noe;function Aoe(e,t,n=!0){let r=h.useRef(!0);h.useEffect(r.current||!n?()=>{r.current=!1}:e,t)}var Za=Aoe;function Qf(){}function qu(e,t,n,r){return Doe(e,r)||Ooe(e,t,n,r)}function Doe(e,t){return e.editor.getModel(K6(e,t))}function Ooe(e,t,n,r){return e.editor.createModel(t,n,r?K6(e,r):void 0)}function K6(e,t){return e.Uri.parse(t)}function Ioe({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:s,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:u=!1,keepCurrentModifiedModel:f=!1,theme:m="light",loading:x="Loading...",options:g={},height:y="100%",width:v="100%",className:S,wrapperProps:C={},beforeMount:E=Qf,onMount:j=Qf}){let[R,T]=h.useState(!1),[N,D]=h.useState(!0),O=h.useRef(null),_=h.useRef(null),M=h.useRef(null),$=h.useRef(j),L=h.useRef(E),k=h.useRef(!1);q6(()=>{let F=G6.init();return F.then(I=>(_.current=I)&&D(!1)).catch(I=>(I==null?void 0:I.type)!=="cancelation"&&console.error("Monaco initialization: error:",I)),()=>O.current?q():F.cancel()}),Za(()=>{if(O.current&&_.current){let F=O.current.getOriginalEditor(),I=qu(_.current,e||"",r||n||"text",i||"");I!==F.getModel()&&F.setModel(I)}},[i],R),Za(()=>{if(O.current&&_.current){let F=O.current.getModifiedEditor(),I=qu(_.current,t||"",s||n||"text",c||"");I!==F.getModel()&&F.setModel(I)}},[c],R),Za(()=>{let F=O.current.getModifiedEditor();F.getOption(_.current.editor.EditorOption.readOnly)?F.setValue(t||""):t!==F.getValue()&&(F.executeEdits("",[{range:F.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),F.pushUndoStop())},[t],R),Za(()=>{var F,I;(I=(F=O.current)==null?void 0:F.getModel())==null||I.original.setValue(e||"")},[e],R),Za(()=>{let{original:F,modified:I}=O.current.getModel();_.current.editor.setModelLanguage(F,r||n||"text"),_.current.editor.setModelLanguage(I,s||n||"text")},[n,r,s],R),Za(()=>{var F;(F=_.current)==null||F.editor.setTheme(m)},[m],R),Za(()=>{var F;(F=O.current)==null||F.updateOptions(g)},[g],R);let B=h.useCallback(()=>{var G;if(!_.current)return;L.current(_.current);let F=qu(_.current,e||"",r||n||"text",i||""),I=qu(_.current,t||"",s||n||"text",c||"");(G=O.current)==null||G.setModel({original:F,modified:I})},[n,t,s,e,r,i,c]),K=h.useCallback(()=>{var F;!k.current&&M.current&&(O.current=_.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...g}),B(),(F=_.current)==null||F.editor.setTheme(m),T(!0),k.current=!0)},[g,m,B]);h.useEffect(()=>{R&&$.current(O.current,_.current)},[R]),h.useEffect(()=>{!N&&!R&&K()},[N,R,K]);function q(){var I,G,H,ee;let F=(I=O.current)==null?void 0:I.getModel();u||((G=F==null?void 0:F.original)==null||G.dispose()),f||((H=F==null?void 0:F.modified)==null||H.dispose()),(ee=O.current)==null||ee.dispose()}return re.createElement(B6,{width:v,height:y,isEditorReady:R,loading:x,_ref:M,className:S,wrapperProps:C})}var Moe=Ioe;h.memo(Moe);function koe(e){let t=h.useRef();return h.useEffect(()=>{t.current=e},[e]),t.current}var Loe=koe,Kp=new Map;function Poe({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:s,path:i,theme:c="light",line:u,loading:f="Loading...",options:m={},overrideServices:x={},saveViewState:g=!0,keepCurrentModel:y=!1,width:v="100%",height:S="100%",className:C,wrapperProps:E={},beforeMount:j=Qf,onMount:R=Qf,onChange:T,onValidate:N=Qf}){let[D,O]=h.useState(!1),[_,M]=h.useState(!0),$=h.useRef(null),L=h.useRef(null),k=h.useRef(null),B=h.useRef(R),K=h.useRef(j),q=h.useRef(),F=h.useRef(r),I=Loe(i),G=h.useRef(!1),H=h.useRef(!1);q6(()=>{let U=G6.init();return U.then(V=>($.current=V)&&M(!1)).catch(V=>(V==null?void 0:V.type)!=="cancelation"&&console.error("Monaco initialization: error:",V)),()=>L.current?fe():U.cancel()}),Za(()=>{var V,z,W,X;let U=qu($.current,e||r||"",t||s||"",i||n||"");U!==((V=L.current)==null?void 0:V.getModel())&&(g&&Kp.set(I,(z=L.current)==null?void 0:z.saveViewState()),(W=L.current)==null||W.setModel(U),g&&((X=L.current)==null||X.restoreViewState(Kp.get(i))))},[i],D),Za(()=>{var U;(U=L.current)==null||U.updateOptions(m)},[m],D),Za(()=>{!L.current||r===void 0||(L.current.getOption($.current.editor.EditorOption.readOnly)?L.current.setValue(r):r!==L.current.getValue()&&(H.current=!0,L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),L.current.pushUndoStop(),H.current=!1))},[r],D),Za(()=>{var V,z;let U=(V=L.current)==null?void 0:V.getModel();U&&s&&((z=$.current)==null||z.editor.setModelLanguage(U,s))},[s],D),Za(()=>{var U;u!==void 0&&((U=L.current)==null||U.revealLine(u))},[u],D),Za(()=>{var U;(U=$.current)==null||U.editor.setTheme(c)},[c],D);let ee=h.useCallback(()=>{var U;if(!(!k.current||!$.current)&&!G.current){K.current($.current);let V=i||n,z=qu($.current,r||e||"",t||s||"",V||"");L.current=(U=$.current)==null?void 0:U.editor.create(k.current,{model:z,automaticLayout:!0,...m},x),g&&L.current.restoreViewState(Kp.get(V)),$.current.editor.setTheme(c),u!==void 0&&L.current.revealLine(u),O(!0),G.current=!0}},[e,t,n,r,s,i,m,x,g,c,u]);h.useEffect(()=>{D&&B.current(L.current,$.current)},[D]),h.useEffect(()=>{!_&&!D&&ee()},[_,D,ee]),F.current=r,h.useEffect(()=>{var U,V;D&&T&&((U=q.current)==null||U.dispose(),q.current=(V=L.current)==null?void 0:V.onDidChangeModelContent(z=>{H.current||T(L.current.getValue(),z)}))},[D,T]),h.useEffect(()=>{if(D){let U=$.current.editor.onDidChangeMarkers(V=>{var W;let z=(W=L.current.getModel())==null?void 0:W.uri;if(z&&V.find(X=>X.path===z.path)){let X=$.current.editor.getModelMarkers({resource:z});N==null||N(X)}});return()=>{U==null||U.dispose()}}return()=>{}},[D,N]);function fe(){var U,V;(U=q.current)==null||U.dispose(),y?g&&Kp.set(i,L.current.saveViewState()):(V=L.current.getModel())==null||V.dispose(),L.current.dispose()}return re.createElement(B6,{width:v,height:S,isEditorReady:D,loading:f,_ref:k,className:C,wrapperProps:E})}var Uoe=Poe,W6=h.memo(Uoe);function zoe({initialValue:e,onChange:t}){const[n,r]=h.useState((e==null?void 0:e.sqlQuery)??""),{resolvedTheme:s}=Yh();h.useEffect(()=>{e!=null&&e.sqlQuery&&e.sqlQuery!==n&&r(e.sqlQuery)},[e,n]);function i(c){c!==void 0&&(r(c),t({sqlQuery:c}))}return a.jsx("div",{className:"shadow-xs",children:a.jsx(W6,{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-200/4",height:"30vh",language:"sql",value:n,onChange:i,theme:s==="dark"?"vs-dark":"light",options:{selectOnLineNumbers:!0,hideCursorInOverviewRuler:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,overviewRulerBorder:!1}})})}function mS({icon:e,title:t,subtitle:n,rightContent:r,onClick:s,className:i}){const c=e;return a.jsxs("div",{className:se("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",i),onClick:s,children:[a.jsxs("div",{className:"flex flex-grow items-start justify-center gap-3 px-6 py-5",children:[e&&a.jsx("div",{className:"flex items-center justify-center",children:a.jsx(c,{className:"h-6 w-6"})}),a.jsxs("div",{className:"flex flex-grow flex-col gap-1",children:[a.jsx("div",{className:"text-md font-medium",children:t}),n&&a.jsx("div",{className:"text-muted-foreground/60 text-sm",children:n})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2 p-4",children:[r,s&&a.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:a.jsx(va,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})]})]})}var NN=1,Foe=.9,Hoe=.8,$oe=.17,B1=.1,q1=.999,Voe=.9999,Goe=.99,Boe=/[\\\/_+.#"@\[\(\{&]/,qoe=/[\\\/_+.#"@\[\(\{&]/g,Koe=/[\s-]/,Z6=/[\s-]/g;function pS(e,t,n,r,s,i,c){if(i===t.length)return s===e.length?NN:Goe;var u=`${s},${i}`;if(c[u]!==void 0)return c[u];for(var f=r.charAt(i),m=n.indexOf(f,s),x=0,g,y,v,S;m>=0;)g=pS(e,t,n,r,m+1,i+1,c),g>x&&(m===s?g*=NN:Boe.test(e.charAt(m-1))?(g*=Hoe,v=e.slice(s,m-1).match(qoe),v&&s>0&&(g*=Math.pow(q1,v.length))):Koe.test(e.charAt(m-1))?(g*=Foe,S=e.slice(s,m-1).match(Z6),S&&s>0&&(g*=Math.pow(q1,S.length))):(g*=$oe,s>0&&(g*=Math.pow(q1,m-s))),e.charAt(m)!==t.charAt(i)&&(g*=Voe)),(g<B1&&n.charAt(m-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(m-1)!==r.charAt(i))&&(y=pS(e,t,n,r,m+1,i+2,c),y*B1>g&&(g=y*B1)),g>x&&(x=g),m=n.indexOf(f,m+1);return c[u]=x,x}function AN(e){return e.toLowerCase().replace(Z6," ")}function Woe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,pS(e,t,AN(e),AN(t),0,0,{})}var Mf='[cmdk-group=""]',K1='[cmdk-group-items=""]',Zoe='[cmdk-group-heading=""]',Y6='[cmdk-item=""]',DN=`${Y6}:not([aria-disabled="true"])`,gS="cmdk-item-select",Hu="data-value",Yoe=(e,t,n)=>Woe(e,t,n),X6=h.createContext(void 0),om=()=>h.useContext(X6),Q6=h.createContext(void 0),AE=()=>h.useContext(Q6),J6=h.createContext(void 0),eM=h.forwardRef((e,t)=>{let n=$u(()=>{var V,z;return{search:"",value:(z=(V=e.value)!=null?V:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$u(()=>new Set),s=$u(()=>new Map),i=$u(()=>new Map),c=$u(()=>new Set),u=tM(e),{label:f,children:m,value:x,onValueChange:g,filter:y,shouldFilter:v,loop:S,disablePointerSelection:C=!1,vimBindings:E=!0,...j}=e,R=ar(),T=ar(),N=ar(),D=h.useRef(null),O=iie();Ic(()=>{if(x!==void 0){let V=x.trim();n.current.value=V,_.emit()}},[x]),Ic(()=>{O(6,K)},[]);let _=h.useMemo(()=>({subscribe:V=>(c.current.add(V),()=>c.current.delete(V)),snapshot:()=>n.current,setState:(V,z,W)=>{var X,oe,J,de;if(!Object.is(n.current[V],z)){if(n.current[V]=z,V==="search")B(),L(),O(1,k);else if(V==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ye=document.getElementById(N);ye?ye.focus():(X=document.getElementById(R))==null||X.focus()}if(O(7,()=>{var ye;n.current.selectedItemId=(ye=q())==null?void 0:ye.id,_.emit()}),W||O(5,K),((oe=u.current)==null?void 0:oe.value)!==void 0){let ye=z??"";(de=(J=u.current).onValueChange)==null||de.call(J,ye);return}}_.emit()}},emit:()=>{c.current.forEach(V=>V())}}),[]),M=h.useMemo(()=>({value:(V,z,W)=>{var X;z!==((X=i.current.get(V))==null?void 0:X.value)&&(i.current.set(V,{value:z,keywords:W}),n.current.filtered.items.set(V,$(z,W)),O(2,()=>{L(),_.emit()}))},item:(V,z)=>(r.current.add(V),z&&(s.current.has(z)?s.current.get(z).add(V):s.current.set(z,new Set([V]))),O(3,()=>{B(),L(),n.current.value||k(),_.emit()}),()=>{i.current.delete(V),r.current.delete(V),n.current.filtered.items.delete(V);let W=q();O(4,()=>{B(),(W==null?void 0:W.getAttribute("id"))===V&&k(),_.emit()})}),group:V=>(s.current.has(V)||s.current.set(V,new Set),()=>{i.current.delete(V),s.current.delete(V)}),filter:()=>u.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>u.current.disablePointerSelection,listId:R,inputId:N,labelId:T,listInnerRef:D}),[]);function $(V,z){var W,X;let oe=(X=(W=u.current)==null?void 0:W.filter)!=null?X:Yoe;return V?oe(V,n.current.search,z):0}function L(){if(!n.current.search||u.current.shouldFilter===!1)return;let V=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(X=>{let oe=s.current.get(X),J=0;oe.forEach(de=>{let ye=V.get(de);J=Math.max(ye,J)}),z.push([X,J])});let W=D.current;F().sort((X,oe)=>{var J,de;let ye=X.getAttribute("id"),Se=oe.getAttribute("id");return((J=V.get(Se))!=null?J:0)-((de=V.get(ye))!=null?de:0)}).forEach(X=>{let oe=X.closest(K1);oe?oe.appendChild(X.parentElement===oe?X:X.closest(`${K1} > *`)):W.appendChild(X.parentElement===W?X:X.closest(`${K1} > *`))}),z.sort((X,oe)=>oe[1]-X[1]).forEach(X=>{var oe;let J=(oe=D.current)==null?void 0:oe.querySelector(`${Mf}[${Hu}="${encodeURIComponent(X[0])}"]`);J==null||J.parentElement.appendChild(J)})}function k(){let V=F().find(W=>W.getAttribute("aria-disabled")!=="true"),z=V==null?void 0:V.getAttribute(Hu);_.setState("value",z||void 0)}function B(){var V,z,W,X;if(!n.current.search||u.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let J of r.current){let de=(z=(V=i.current.get(J))==null?void 0:V.value)!=null?z:"",ye=(X=(W=i.current.get(J))==null?void 0:W.keywords)!=null?X:[],Se=$(de,ye);n.current.filtered.items.set(J,Se),Se>0&&oe++}for(let[J,de]of s.current)for(let ye of de)if(n.current.filtered.items.get(ye)>0){n.current.filtered.groups.add(J);break}n.current.filtered.count=oe}function K(){var V,z,W;let X=q();X&&(((V=X.parentElement)==null?void 0:V.firstChild)===X&&((W=(z=X.closest(Mf))==null?void 0:z.querySelector(Zoe))==null||W.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function q(){var V;return(V=D.current)==null?void 0:V.querySelector(`${Y6}[aria-selected="true"]`)}function F(){var V;return Array.from(((V=D.current)==null?void 0:V.querySelectorAll(DN))||[])}function I(V){let z=F()[V];z&&_.setState("value",z.getAttribute(Hu))}function G(V){var z;let W=q(),X=F(),oe=X.findIndex(de=>de===W),J=X[oe+V];(z=u.current)!=null&&z.loop&&(J=oe+V<0?X[X.length-1]:oe+V===X.length?X[0]:X[oe+V]),J&&_.setState("value",J.getAttribute(Hu))}function H(V){let z=q(),W=z==null?void 0:z.closest(Mf),X;for(;W&&!X;)W=V>0?sie(W,Mf):oie(W,Mf),X=W==null?void 0:W.querySelector(DN);X?_.setState("value",X.getAttribute(Hu)):G(V)}let ee=()=>I(F().length-1),fe=V=>{V.preventDefault(),V.metaKey?ee():V.altKey?H(1):G(1)},U=V=>{V.preventDefault(),V.metaKey?I(0):V.altKey?H(-1):G(-1)};return h.createElement(tt.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:V=>{var z;(z=j.onKeyDown)==null||z.call(j,V);let W=V.nativeEvent.isComposing||V.keyCode===229;if(!(V.defaultPrevented||W))switch(V.key){case"n":case"j":{E&&V.ctrlKey&&fe(V);break}case"ArrowDown":{fe(V);break}case"p":case"k":{E&&V.ctrlKey&&U(V);break}case"ArrowUp":{U(V);break}case"Home":{V.preventDefault(),I(0);break}case"End":{V.preventDefault(),ee();break}case"Enter":{V.preventDefault();let X=q();if(X){let oe=new Event(gS);X.dispatchEvent(oe)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:cie},f),py(e,V=>h.createElement(Q6.Provider,{value:_},h.createElement(X6.Provider,{value:M},V))))}),Xoe=h.forwardRef((e,t)=>{var n,r;let s=ar(),i=h.useRef(null),c=h.useContext(J6),u=om(),f=tM(e),m=(r=(n=f.current)==null?void 0:n.forceMount)!=null?r:c==null?void 0:c.forceMount;Ic(()=>{if(!m)return u.item(s,c==null?void 0:c.id)},[m]);let x=nM(s,i,[e.value,e.children,i],e.keywords),g=AE(),y=El(O=>O.value&&O.value===x.current),v=El(O=>m||u.filter()===!1?!0:O.search?O.filtered.items.get(s)>0:!0);h.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(gS,S),()=>O.removeEventListener(gS,S)},[v,e.onSelect,e.disabled]);function S(){var O,_;C(),(_=(O=f.current).onSelect)==null||_.call(O,x.current)}function C(){g.setState("value",x.current,!0)}if(!v)return null;let{disabled:E,value:j,onSelect:R,forceMount:T,keywords:N,...D}=e;return h.createElement(tt.div,{ref:ra(i,t),...D,id:s,"cmdk-item":"",role:"option","aria-disabled":!!E,"aria-selected":!!y,"data-disabled":!!E,"data-selected":!!y,onPointerMove:E||u.getDisablePointerSelection()?void 0:C,onClick:E?void 0:S},e.children)}),Qoe=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...i}=e,c=ar(),u=h.useRef(null),f=h.useRef(null),m=ar(),x=om(),g=El(v=>s||x.filter()===!1?!0:v.search?v.filtered.groups.has(c):!0);Ic(()=>x.group(c),[]),nM(c,u,[e.value,e.heading,f]);let y=h.useMemo(()=>({id:c,forceMount:s}),[s]);return h.createElement(tt.div,{ref:ra(u,t),...i,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},n&&h.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:m},n),py(e,v=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},h.createElement(J6.Provider,{value:y},v))))}),Joe=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=h.useRef(null),i=El(c=>!c.search);return!n&&!i?null:h.createElement(tt.div,{ref:ra(s,t),...r,"cmdk-separator":"",role:"separator"})}),eie=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,i=AE(),c=El(m=>m.search),u=El(m=>m.selectedItemId),f=om();return h.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),h.createElement(tt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":u,id:f.inputId,type:"text",value:s?e.value:c,onChange:m=>{s||i.setState("search",m.target.value),n==null||n(m.target.value)}})}),tie=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,i=h.useRef(null),c=h.useRef(null),u=El(m=>m.selectedItemId),f=om();return h.useEffect(()=>{if(c.current&&i.current){let m=c.current,x=i.current,g,y=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let v=m.offsetHeight;x.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(m),()=>{cancelAnimationFrame(g),y.unobserve(m)}}},[]),h.createElement(tt.div,{ref:ra(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":u,"aria-label":r,id:f.listId},py(e,m=>h.createElement("div",{ref:ra(c,f.listInnerRef),"cmdk-list-sizer":""},m)))}),nie=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:c,...u}=e;return h.createElement(xx,{open:n,onOpenChange:r},h.createElement(yx,{container:c},h.createElement(vx,{"cmdk-overlay":"",className:s}),h.createElement(bx,{"aria-label":e.label,"cmdk-dialog":"",className:i},h.createElement(eM,{ref:t,...u}))))}),rie=h.forwardRef((e,t)=>El(n=>n.filtered.count===0)?h.createElement(tt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),aie=h.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...i}=e;return h.createElement(tt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},py(e,c=>h.createElement("div",{"aria-hidden":!0},c)))}),Nd=Object.assign(eM,{List:tie,Item:Xoe,Input:eie,Group:Qoe,Separator:Joe,Dialog:nie,Empty:rie,Loading:aie});function sie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function oie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tM(e){let t=h.useRef(e);return Ic(()=>{t.current=e}),t}var Ic=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $u(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function El(e){let t=AE(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function nM(e,t,n,r=[]){let s=h.useRef(),i=om();return Ic(()=>{var c;let u=(()=>{var m;for(let x of n){if(typeof x=="string")return x.trim();if(typeof x=="object"&&"current"in x)return x.current?(m=x.current.textContent)==null?void 0:m.trim():s.current}})(),f=r.map(m=>m.trim());i.value(e,u,f),(c=t.current)==null||c.setAttribute(Hu,u),s.current=u}),s}var iie=()=>{let[e,t]=h.useState(),n=$u(()=>new Map);return Ic(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function lie(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function py({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(lie(t),{ref:t.ref},n(t.props.children)):n(t)}var cie={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function DE({className:e,...t}){return a.jsx(Nd,{"data-slot":"command",className:se("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function OE({className:e,...t}){return a.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[a.jsx(zc,{className:"size-4 shrink-0 opacity-50"}),a.jsx(Nd.Input,{"data-slot":"command-input",className:se("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",e),...t})]})}function rM({className:e,...t}){return a.jsx(Nd.List,{"data-slot":"command-list",className:se("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function aM({...e}){return a.jsx(Nd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function sM({className:e,...t}){return a.jsx(Nd.Group,{"data-slot":"command-group",className:se("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",e),...t})}function IE({className:e,...t}){return a.jsx(Nd.Item,{"data-slot":"command-item",className:se("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",e),...t})}function uie(e){const t=die(e),n=h.forwardRef((r,s)=>{const{children:i,...c}=r,u=h.Children.toArray(i),f=u.find(hie);if(f){const m=f.props.children,x=u.map(g=>g===f?h.Children.count(m)>1?h.Children.only(null):h.isValidElement(m)?m.props.children:null:g);return a.jsx(t,{...c,ref:s,children:h.isValidElement(m)?h.cloneElement(m,void 0,x):null})}return a.jsx(t,{...c,ref:s,children:i})});return n.displayName=`${e}.Slot`,n}function die(e){const t=h.forwardRef((n,r)=>{const{children:s,...i}=n;if(h.isValidElement(s)){const c=pie(s),u=mie(i,s.props);return s.type!==h.Fragment&&(u.ref=r?ra(r,c):c),h.cloneElement(s,u)}return h.Children.count(s)>1?h.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fie=Symbol("radix.slottable");function hie(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fie}function mie(e,t){const n={...t};for(const r in t){const s=e[r],i=t[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...u)=>{const f=i(...u);return s(...u),f}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...e,...n}}function pie(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gy="Popover",[oM]=Nr(gy,[Oo]),im=Oo(),[gie,Hl]=oM(gy),iM=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:c=!1}=e,u=im(t),f=h.useRef(null),[m,x]=h.useState(!1),[g,y]=xa({prop:r,defaultProp:s??!1,onChange:i,caller:gy});return a.jsx(Sd,{...u,children:a.jsx(gie,{scope:t,contentId:ar(),triggerRef:f,open:g,onOpenChange:y,onOpenToggle:h.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:m,onCustomAnchorAdd:h.useCallback(()=>x(!0),[]),onCustomAnchorRemove:h.useCallback(()=>x(!1),[]),modal:c,children:n})})};iM.displayName=gy;var lM="PopoverAnchor",xie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(lM,n),i=im(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:u}=s;return h.useEffect(()=>(c(),()=>u()),[c,u]),a.jsx(Cd,{...i,...r,ref:t})});xie.displayName=lM;var cM="PopoverTrigger",uM=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(cM,n),i=im(n),c=wt(t,s.triggerRef),u=a.jsx(tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":pM(s.open),...r,ref:c,onClick:Me(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?u:a.jsx(Cd,{asChild:!0,...i,children:u})});uM.displayName=cM;var ME="PopoverPortal",[yie,vie]=oM(ME,{forceMount:void 0}),dM=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,i=Hl(ME,t);return a.jsx(yie,{scope:t,forceMount:n,children:a.jsx(Yr,{present:n||i.open,children:a.jsx(Hc,{asChild:!0,container:s,children:r})})})};dM.displayName=ME;var md="PopoverContent",fM=h.forwardRef((e,t)=>{const n=vie(md,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,i=Hl(md,e.__scopePopover);return a.jsx(Yr,{present:r||i.open,children:i.modal?a.jsx(Sie,{...s,ref:t}):a.jsx(Cie,{...s,ref:t})})});fM.displayName=md;var bie=uie("PopoverContent.RemoveScroll"),Sie=h.forwardRef((e,t)=>{const n=Hl(md,e.__scopePopover),r=h.useRef(null),s=wt(t,r),i=h.useRef(!1);return h.useEffect(()=>{const c=r.current;if(c)return px(c)},[]),a.jsx(Mh,{as:bie,allowPinchZoom:!0,children:a.jsx(hM,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,c=>{var u;c.preventDefault(),i.current||(u=n.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;i.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),Cie=h.forwardRef((e,t)=>{const n=Hl(md,e.__scopePopover),r=h.useRef(!1),s=h.useRef(!1);return a.jsx(hM,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var c,u;(c=e.onCloseAutoFocus)==null||c.call(e,i),i.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var f,m;(f=e.onInteractOutside)==null||f.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const c=i.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),hM=h.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:x,...g}=e,y=Hl(md,n),v=im(n);return hx(),a.jsx(Ih,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(Fc,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:x,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onDismiss:()=>y.onOpenChange(!1),children:a.jsx(Lh,{"data-state":pM(y.open),role:"dialog",id:y.contentId,...v,...g,ref:t,style:{...g.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)"}})})})}),mM="PopoverClose",Eie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(mM,n);return a.jsx(tt.button,{type:"button",...r,ref:t,onClick:Me(e.onClick,()=>s.onOpenChange(!1))})});Eie.displayName=mM;var wie="PopoverArrow",Rie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=im(n);return a.jsx(Ph,{...s,...r,ref:t})});Rie.displayName=wie;function pM(e){return e?"open":"closed"}var jie=iM,Tie=uM,_ie=dM,Nie=fM;function kE({...e}){return a.jsx(jie,{"data-slot":"popover",...e})}function LE({...e}){return a.jsx(Tie,{"data-slot":"popover-trigger",...e})}function PE({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(_ie,{children:a.jsx(Nie,{"data-slot":"popover-content",align:t,sideOffset:n,className:se("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",e),...r})})}function UE({options:e,value:t,onValueChange:n,placeholder:r="Select an option",emptyMessage:s="No results found.",className:i,disabled:c=!1}){const[u,f]=h.useState(!1),[m,x]=h.useState(""),g=h.useMemo(()=>{const S={};return e.forEach(C=>{const E=C.group??"";Object.prototype.hasOwnProperty.call(S,E)||(S[E]=[]),S[E].push(C)}),S},[e]),y=e.find(S=>S.value===t),v=h.useCallback(S=>{n(S),requestAnimationFrame(()=>{x(""),f(!1)})},[n]);return a.jsxs(kE,{open:u,onOpenChange:f,modal:!0,children:[a.jsx(LE,{asChild:!0,children:a.jsxs(we,{variant:"outline",role:"combobox","aria-expanded":u,className:se("w-full justify-between",!t&&"text-muted-foreground",i),disabled:c,children:[y?y.label:r,a.jsx(WS,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsx(PE,{className:"max-h-[300px] min-w-[300px] overflow-auto p-0",align:"start",sideOffset:5,children:a.jsxs(DE,{children:[a.jsx(OE,{placeholder:`Search ${r.toLowerCase()}...`,value:m,onValueChange:x}),a.jsx(aM,{children:s}),Object.entries(g).map(([S,C])=>a.jsx(sM,{heading:S,children:C.map(E=>a.jsxs(IE,{value:E.value,onSelect:()=>{v(E.value)},keywords:[E.label],children:[a.jsx(Ia,{className:se("mr-2 h-4 w-4",t===E.value?"opacity-100":"opacity-0")}),E.label]},E.value))},S||"default"))]})})]})}function Aie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"service-account-details",children:[a.jsx(Dt,{children:"How do I get a Service Account JSON key?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's what to do:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Go to"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"}),"."]}),a.jsxs("li",{children:["Open ",a.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),a.jsx("li",{children:"Create a new service account or select an existing one."}),a.jsxs("li",{children:["Assign the ",a.jsx("strong",{children:"bigquery.dataEditor"})," and ",a.jsx("strong",{children:"bigquery.jobUser"})," ","roles to this service account to allow read, write, and create access to your project resources."]}),a.jsxs("li",{children:["Open the Service Accounts page, go to the ",a.jsx("strong",{children:"Keys"})," tab, click"," ",a.jsx("strong",{children:"Add key"}),", and select ",a.jsx("strong",{children:"Create new key"}),"."]}),a.jsxs("li",{children:["Choose ",a.jsx("strong",{children:"JSON"})," format and click ",a.jsx("strong",{children:"Create"}),"."]}),a.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function Die(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"project-id-details",children:[a.jsx(Dt,{children:"How do I find my Project ID?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"This is the ID of your Google Cloud project. BigQuery usage costs will be charged to this project."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your billing project ID:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/",children:"Google Cloud Console"})," ","and sign in with your Google account."]}),a.jsx("li",{children:'Click the project selector dropdown at the top of the page (it shows the current project name or "Select a project").'}),a.jsxs("li",{children:["Find your project in the list. The ",a.jsx("strong",{children:"Project ID"})," is shown in the ID column."]}),a.jsx("li",{children:"If you don't see your project, use the search box to find it by name or ID."})]})]})]})})}function Oie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"gbq-location-details",children:[a.jsx(Dt,{children:"How do I find my dataset location?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to check your dataset location:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/bigquery",children:"Google Cloud Console BigQuery page"}),"."]}),a.jsx("li",{children:"In the left panel, expand your project and find your datasets."}),a.jsxs("li",{children:["Click each dataset name to open its details. The ",a.jsx("strong",{children:"Data location"})," field shows the region where that dataset is stored (for example,"," ",a.jsx("code",{className:"text-sm font-semibold",children:"US"}),","," ",a.jsx("code",{className:"text-sm font-semibold",children:"EU"}),","," ",a.jsx("code",{className:"text-sm font-semibold",children:"asia-northeast1"}),")."]}),a.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."}),a.jsx("li",{children:"Put this location value in the field above."})]})]})]})})}const Iie=({form:e})=>{const[t,n]=h.useState(!1);if(e.watch("type")!==xe.GOOGLE_BIGQUERY)return null;const r=()=>{n(!0),e.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{n(!1),e.resetField("credentials.serviceAccount")},i=e.watch("credentials.serviceAccount"),c=i?m5(i):null;return a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.projectId",render:({field:u})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the ID of your Google Cloud project where BigQuery usage will be billed",children:"Project ID"}),a.jsx(vt,{children:a.jsx(gt,{...u,placeholder:"Enter a Project Id"})}),a.jsx(on,{children:a.jsx(Die,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.location",render:({field:u})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Choose the same region where your BigQuery data is stored to ensure queries work correctly",children:"Location"}),a.jsx(vt,{children:a.jsx(UE,{options:FQ,value:u.value,onValueChange:u.onChange,placeholder:"Select a location",emptyMessage:"No locations found",className:"w-full"})}),a.jsx(on,{children:a.jsx(Oie,{})}),a.jsx(jt,{})]})})]}),a.jsx(zr,{title:"Authentication",children:a.jsx(Et,{control:e.control,name:"credentials.serviceAccount",render:({field:u})=>a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{tooltip:"Paste a JSON key from a service account that has access to the selected storage provider",children:"Service Account"}),!t&&i&&a.jsx(we,{variant:"ghost",size:"sm",onClick:r,type:"button",children:"Edit"}),t&&a.jsx(we,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),a.jsx(vt,{children:!t&&c?a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Kt,{href:c.url,children:c.email})}),a.jsx(ot,{children:a.jsx("p",{children:"View in Google Cloud Console"})})]}):a.jsx(Io,{...u,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),a.jsx(on,{children:a.jsx(Aie,{})}),a.jsx(jt,{})]})})})]})};function Mie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-region-details",children:[a.jsx(Dt,{children:"How do I find my Athena region?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your Athena region:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"}),"."]}),a.jsx("li",{children:"Look at the top right corner of the console. The selected region is shown in the region selector dropdown."}),a.jsx("li",{children:"Make sure to copy and paste the same region here in the form to avoid connection or query errors."})]})]})]})})}function kie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-output-bucket-details",children:[a.jsx(Dt,{children:"How do I find a bucket?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["Athena saves query results in an ",a.jsx("strong",{children:"S3 bucket"}),". You need to specify the bucket used for query output."]}),a.jsx("p",{className:"mb-2",children:"Here's how to find or create an S3 bucket for Athena output:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/s3/",children:"the AWS S3 console"}),"."]}),a.jsx("li",{children:"Look for an existing bucket used for Athena query results, or create a new one."}),a.jsx("li",{children:"If creating a new bucket, make sure it is in the same region as your Athena service."}),a.jsx("li",{children:"Enter the bucket name in this form field."})]})]})]})})}function Lie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-access-key-id-details",children:[a.jsx(Dt,{children:"How do I get my AWS Access Key ID?"}),a.jsxs(Ot,{children:[a.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."}),a.jsxs("p",{className:"mb-4 text-sm",children:["Learn more about how to create a user in AWS ",a.jsx(Kt,{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"}),"."]}),a.jsx(JS,{className:"my-4"}),a.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS credentials needed to connect and authenticate."}),a.jsx("p",{className:"mb-2",children:"Here's how to find or create an Access Key ID:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),a.jsxs("li",{children:["Under ",a.jsx("strong",{children:"Access keys"}),", find your existing keys or create a new access key."]}),a.jsx("li",{children:"When you create a new key, download and securely store the Access Key ID and Secret Access Key."})]})]})]})})}function Pie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-secret-access-key-details",children:[a.jsx(Dt,{children:"How do I get my AWS Secret Access Key?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to get your Secret Access Key:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),a.jsxs("li",{children:["Under ",a.jsx("strong",{children:"Access keys"}),", create a new access key if you don't have one or lost the secret key."]}),a.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 Uie=({form:e})=>{const[t,n]=h.useState("");return h.useEffect(()=>{const r=e.getValues("credentials.accessKeyId");if(r){const s="_".repeat(r.length);n(s),e.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[e]),e.watch("type")!==xe.AWS_ATHENA?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.region",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the AWS region where your Athena service is active",children:"Region"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter a region"})}),a.jsx(on,{children:a.jsx(Mie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.outputBucket",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Specify the S3 bucket where Athena query results will be stored",children:"Output Bucket"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an output bucket"})}),a.jsx(on,{children:a.jsx(kie,{})}),a.jsx(jt,{})]})})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.accessKeyId",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an access key id"})}),a.jsx(on,{children:a.jsx(Lie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.secretAccessKey",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),a.jsx(vt,{children:a.jsx(gt,{...r,type:"password",placeholder:t||"Enter a secret access key"})}),a.jsx(on,{children:a.jsx(Pie,{})}),a.jsx(jt,{})]})})]})]})};function zie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-account-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake account identifier?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["To find the region and locator for your account, see"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/admin-account-identifier#finding-the-region-and-locator-for-an-account",children:"Snowflake documentation"}),"."]}),a.jsxs("ol",{className:"list-inside list-decimal space-y-3 text-sm",children:[a.jsx("li",{children:"Open the account selector and review the list of accounts that you previously signed in to."}),a.jsxs("li",{children:["Select ",a.jsx("strong",{children:"View account details"}),"."]}),a.jsxs("li",{children:["The ",a.jsx("strong",{children:"Account Details"})," dialog displays information about the account, including the account identifier and the account URL."]}),a.jsxs("li",{children:["Copy part of your account identifier from the ",a.jsx("strong",{children:"Account locator"})," field."]}),a.jsx("li",{children:"Find the region in the account selector (e.g. Europe West4 (Netherlands))."}),a.jsxs("li",{children:["Compare the found region with the ",a.jsx("strong",{children:"Account Identifier Region"})," in"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/admin-account-identifier#non-vps-account-locator-formats-by-cloud-platform-and-region",children:"Snowflake documentation"})," ","for locator formats by cloud platform and region."]}),a.jsxs("li",{children:["Create the account identifier by combining the locator and the region like this:"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"locator.region"}),a.jsxs("div",{className:"mt-2",children:["Examples:",a.jsxs("ul",{className:"mt-1 ml-4 space-y-1",children:[a.jsx("li",{children:a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.ap-northeast-3.aws"})}),a.jsx("li",{children:a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.north-europe.azure"})})]})]})]})]}),a.jsxs("div",{className:"mt-4 text-sm",children:["More details in"," ",a.jsx(Kt,{className:"underline",href:"https://docs.owox.com/docs/storages/supported-storages/snowflake/",children:"OWOX Snowflake documentation"}),"."]})]})]})})}function Fie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-warehouse-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake warehouse?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"A warehouse in Snowflake is a cluster of compute resources that executes queries and performs data loading operations."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your warehouse:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsx("li",{children:'Log in to your Snowflake account and navigate to the "Warehouses" section in the left sidebar.'}),a.jsx("li",{children:`You'll see a list of available warehouses. Common default names include "COMPUTE_WH" or "PROD_WH".`}),a.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."}),a.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 Hie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-auth-method-details",children:[a.jsx(Dt,{children:"Which authentication method should I choose?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Snowflake supports two authentication methods for programmatic access:"}),a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsxs("div",{children:[a.jsx("strong",{className:"font-medium",children:"Username & Password:"}),a.jsx("p",{className:"mt-1",children:"The simplest method using your Snowflake username and password. Suitable for development and testing environments."})]}),a.jsxs("div",{children:[a.jsx("strong",{className:"font-medium",children:"Key Pair Authentication:"}),a.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."}),a.jsxs("p",{className:"mt-1",children:["Learn more about"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"key pair authentication"}),"."]})]})]})]})]})})}function $ie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-username-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake username?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Your Snowflake username is the login identifier for your Snowflake account."}),a.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"Use the same username you use to log in to the Snowflake web interface."}),a.jsx("li",{children:"Snowflake usernames are case-insensitive and are typically in uppercase by default."}),a.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."}),a.jsx("li",{children:"You can view all users in your account by running: SHOW USERS; (requires appropriate privileges)"})]})]})]})})}function Vie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-password-details",children:[a.jsx(Dt,{children:"How do I manage my Snowflake password?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Use the password associated with your Snowflake user account for authentication."}),a.jsx("p",{className:"mb-2",children:"Important security considerations:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"Your password must meet Snowflake's security requirements (minimum length, complexity, etc.)."}),a.jsx("li",{children:"If you've forgotten your password, a Snowflake administrator can reset it using: ALTER USER username SET PASSWORD = 'new_password';"}),a.jsxs("li",{children:["For production environments, consider using"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Key-Pair authentication"})," ","instead of passwords for enhanced security."]}),a.jsx("li",{children:"Your password is encrypted and securely stored. It will never be displayed in plain text after saving."})]})]})]})})}function Gie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-keypair-details",children:[a.jsx(Dt,{children:"How do I set up key pair authentication?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"To use key pair authentication, you need to generate an RSA key pair and configure your Snowflake user."}),a.jsx("p",{className:"mb-2",children:"Here's how to set it up:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Generate an RSA key pair using OpenSSL:",a.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"})]}),a.jsxs("li",{children:["Extract the public key:",a.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"})]}),a.jsxs("li",{children:["Assign the public key to your Snowflake user (run this in Snowflake as ACCOUNTADMIN):",a.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...';"})]}),a.jsx("li",{children:"Copy the private key content from rsa_key.p8 and paste it in the Private Key field above."})]}),a.jsxs("p",{className:"mt-2 text-xs",children:["For more details, see"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Snowflake's key pair authentication documentation"}),"."]})]})]})})}function Bie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-passphrase-details",children:[a.jsx(Dt,{children:"What is a passphrase and when do I need it?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"A passphrase is an optional encryption password that protects your private key."}),a.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"If you generated your private key with a passphrase (encrypted key), you must provide it here."}),a.jsx("li",{children:"If your private key is not encrypted (generated without the -nocrypt flag), leave this field empty."}),a.jsx("li",{children:"When generating an encrypted key with OpenSSL, you set the passphrase during the key generation process."}),a.jsx("li",{children:"The passphrase adds an extra layer of security by encrypting the private key file itself."}),a.jsx("li",{children:"This passphrase is only used to decrypt the private key and is never sent to Snowflake."})]})]})]})})}const qie=({form:e})=>{const t=e.watch("credentials.authMethod");return e.watch("type")!==xe.SNOWFLAKE?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.account",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter your Snowflake account identifier",children:"Account"}),a.jsx(vt,{children:a.jsx(gt,{...n,placeholder:"e.g., xy12345.us-east-1"})}),a.jsx(on,{children:a.jsx(zie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.warehouse",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Specify the Snowflake warehouse to use for query execution",children:"Warehouse"}),a.jsx(vt,{children:a.jsx(gt,{...n,placeholder:"Enter warehouse name"})}),a.jsx(on,{children:a.jsx(Fie,{})}),a.jsx(jt,{})]})})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.authMethod",render:({field:n})=>a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{children:"Authentication Method"}),a.jsx(cy,{value:n.value,onValueChange:n.onChange,children:a.jsxs(uy,{children:[a.jsx(Oc,{value:Vs.PASSWORD,children:"Username & Password"}),a.jsx(Oc,{value:Vs.KEY_PAIR,children:"Key Pair"})]})})]}),a.jsx(on,{children:a.jsx(Hie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.username",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your Snowflake username",children:"Username"}),a.jsx(vt,{children:a.jsx(gt,{...n,placeholder:"Enter username"})}),a.jsx(on,{children:a.jsx($ie,{})}),a.jsx(jt,{})]})}),t===Vs.PASSWORD&&a.jsx(Et,{control:e.control,name:"credentials.password",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your Snowflake password",children:"Password"}),a.jsx(vt,{children:a.jsx(gt,{...n,type:"password",placeholder:"Enter password"})}),a.jsx(on,{children:a.jsx(Vie,{})}),a.jsx(jt,{})]})}),t===Vs.KEY_PAIR&&a.jsxs(a.Fragment,{children:[a.jsx(Et,{control:e.control,name:"credentials.privateKey",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Paste your private key in PEM format",children:"Private Key"}),a.jsx(vt,{children:a.jsx(Io,{...n,placeholder:`-----BEGIN PRIVATE KEY-----
828
+ `},_N=aoe(loe)(F6),coe={config:ooe},uoe=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(s){return n.reduceRight(function(i,c){return c(i)},s)}};function H6(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],H6(e[n],t[n]))}),RN(RN({},e),t)}var doe={type:"cancelation",msg:"operation is manually canceled"};function $1(e){var t=!1,n=new Promise(function(r,s){e.then(function(i){return t?s(doe):r(i)}),e.catch(s)});return n.cancel=function(){return t=!0},n}var foe=["monaco"],hoe=noe.create({config:roe,isInitialized:!1,resolve:null,reject:null,monaco:null}),$6=Use(hoe,2),sm=$6[0],my=$6[1];function moe(e){var t=coe.config(e),n=t.monaco,r=Lse(t,foe);my(function(s){return{config:H6(s.config,r),monaco:n}})}function poe(){var e=sm(function(t){var n=t.monaco,r=t.isInitialized,s=t.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!e.isInitialized){if(my({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),$1(V1);if(window.monaco&&window.monaco.editor)return V6(window.monaco),e.resolve(window.monaco),$1(V1);uoe(goe,yoe)(voe)}return $1(V1)}function goe(e){return document.body.appendChild(e)}function xoe(e){var t=document.createElement("script");return e&&(t.src=e),t}function yoe(e){var t=sm(function(r){var s=r.config,i=r.reject;return{config:s,reject:i}}),n=xoe("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function voe(){var e=sm(function(n){var r=n.config,s=n.resolve,i=n.reject;return{config:r,resolve:s,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){var r=n.m||n;V6(r),e.resolve(r)},function(n){e.reject(n)})}function V6(e){sm().monaco||my({monaco:e})}function boe(){return sm(function(e){var t=e.monaco;return t})}var V1=new Promise(function(e,t){return my({resolve:e,reject:t})}),G6={config:moe,init:poe,__getMonacoInstance:boe},Soe={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},G1=Soe,Coe={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Eoe=Coe;function woe({children:e}){return re.createElement("div",{style:Eoe.container},e)}var Roe=woe,joe=Roe;function Toe({width:e,height:t,isEditorReady:n,loading:r,_ref:s,className:i,wrapperProps:c}){return re.createElement("section",{style:{...G1.wrapper,width:e,height:t},...c},!n&&re.createElement(joe,null,r),re.createElement("div",{ref:s,style:{...G1.fullWidth,...!n&&G1.hide},className:i}))}var _oe=Toe,B6=h.memo(_oe);function Noe(e){h.useEffect(e,[])}var q6=Noe;function Aoe(e,t,n=!0){let r=h.useRef(!0);h.useEffect(r.current||!n?()=>{r.current=!1}:e,t)}var Za=Aoe;function Qf(){}function qu(e,t,n,r){return Doe(e,r)||Ooe(e,t,n,r)}function Doe(e,t){return e.editor.getModel(K6(e,t))}function Ooe(e,t,n,r){return e.editor.createModel(t,n,r?K6(e,r):void 0)}function K6(e,t){return e.Uri.parse(t)}function Ioe({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:s,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:u=!1,keepCurrentModifiedModel:f=!1,theme:m="light",loading:x="Loading...",options:g={},height:y="100%",width:v="100%",className:S,wrapperProps:C={},beforeMount:E=Qf,onMount:j=Qf}){let[R,T]=h.useState(!1),[N,D]=h.useState(!0),O=h.useRef(null),_=h.useRef(null),M=h.useRef(null),$=h.useRef(j),L=h.useRef(E),k=h.useRef(!1);q6(()=>{let F=G6.init();return F.then(I=>(_.current=I)&&D(!1)).catch(I=>(I==null?void 0:I.type)!=="cancelation"&&console.error("Monaco initialization: error:",I)),()=>O.current?q():F.cancel()}),Za(()=>{if(O.current&&_.current){let F=O.current.getOriginalEditor(),I=qu(_.current,e||"",r||n||"text",i||"");I!==F.getModel()&&F.setModel(I)}},[i],R),Za(()=>{if(O.current&&_.current){let F=O.current.getModifiedEditor(),I=qu(_.current,t||"",s||n||"text",c||"");I!==F.getModel()&&F.setModel(I)}},[c],R),Za(()=>{let F=O.current.getModifiedEditor();F.getOption(_.current.editor.EditorOption.readOnly)?F.setValue(t||""):t!==F.getValue()&&(F.executeEdits("",[{range:F.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),F.pushUndoStop())},[t],R),Za(()=>{var F,I;(I=(F=O.current)==null?void 0:F.getModel())==null||I.original.setValue(e||"")},[e],R),Za(()=>{let{original:F,modified:I}=O.current.getModel();_.current.editor.setModelLanguage(F,r||n||"text"),_.current.editor.setModelLanguage(I,s||n||"text")},[n,r,s],R),Za(()=>{var F;(F=_.current)==null||F.editor.setTheme(m)},[m],R),Za(()=>{var F;(F=O.current)==null||F.updateOptions(g)},[g],R);let B=h.useCallback(()=>{var G;if(!_.current)return;L.current(_.current);let F=qu(_.current,e||"",r||n||"text",i||""),I=qu(_.current,t||"",s||n||"text",c||"");(G=O.current)==null||G.setModel({original:F,modified:I})},[n,t,s,e,r,i,c]),K=h.useCallback(()=>{var F;!k.current&&M.current&&(O.current=_.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...g}),B(),(F=_.current)==null||F.editor.setTheme(m),T(!0),k.current=!0)},[g,m,B]);h.useEffect(()=>{R&&$.current(O.current,_.current)},[R]),h.useEffect(()=>{!N&&!R&&K()},[N,R,K]);function q(){var I,G,H,ee;let F=(I=O.current)==null?void 0:I.getModel();u||((G=F==null?void 0:F.original)==null||G.dispose()),f||((H=F==null?void 0:F.modified)==null||H.dispose()),(ee=O.current)==null||ee.dispose()}return re.createElement(B6,{width:v,height:y,isEditorReady:R,loading:x,_ref:M,className:S,wrapperProps:C})}var Moe=Ioe;h.memo(Moe);function koe(e){let t=h.useRef();return h.useEffect(()=>{t.current=e},[e]),t.current}var Loe=koe,Kp=new Map;function Poe({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:s,path:i,theme:c="light",line:u,loading:f="Loading...",options:m={},overrideServices:x={},saveViewState:g=!0,keepCurrentModel:y=!1,width:v="100%",height:S="100%",className:C,wrapperProps:E={},beforeMount:j=Qf,onMount:R=Qf,onChange:T,onValidate:N=Qf}){let[D,O]=h.useState(!1),[_,M]=h.useState(!0),$=h.useRef(null),L=h.useRef(null),k=h.useRef(null),B=h.useRef(R),K=h.useRef(j),q=h.useRef(),F=h.useRef(r),I=Loe(i),G=h.useRef(!1),H=h.useRef(!1);q6(()=>{let U=G6.init();return U.then(V=>($.current=V)&&M(!1)).catch(V=>(V==null?void 0:V.type)!=="cancelation"&&console.error("Monaco initialization: error:",V)),()=>L.current?fe():U.cancel()}),Za(()=>{var V,z,W,X;let U=qu($.current,e||r||"",t||s||"",i||n||"");U!==((V=L.current)==null?void 0:V.getModel())&&(g&&Kp.set(I,(z=L.current)==null?void 0:z.saveViewState()),(W=L.current)==null||W.setModel(U),g&&((X=L.current)==null||X.restoreViewState(Kp.get(i))))},[i],D),Za(()=>{var U;(U=L.current)==null||U.updateOptions(m)},[m],D),Za(()=>{!L.current||r===void 0||(L.current.getOption($.current.editor.EditorOption.readOnly)?L.current.setValue(r):r!==L.current.getValue()&&(H.current=!0,L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),L.current.pushUndoStop(),H.current=!1))},[r],D),Za(()=>{var V,z;let U=(V=L.current)==null?void 0:V.getModel();U&&s&&((z=$.current)==null||z.editor.setModelLanguage(U,s))},[s],D),Za(()=>{var U;u!==void 0&&((U=L.current)==null||U.revealLine(u))},[u],D),Za(()=>{var U;(U=$.current)==null||U.editor.setTheme(c)},[c],D);let ee=h.useCallback(()=>{var U;if(!(!k.current||!$.current)&&!G.current){K.current($.current);let V=i||n,z=qu($.current,r||e||"",t||s||"",V||"");L.current=(U=$.current)==null?void 0:U.editor.create(k.current,{model:z,automaticLayout:!0,...m},x),g&&L.current.restoreViewState(Kp.get(V)),$.current.editor.setTheme(c),u!==void 0&&L.current.revealLine(u),O(!0),G.current=!0}},[e,t,n,r,s,i,m,x,g,c,u]);h.useEffect(()=>{D&&B.current(L.current,$.current)},[D]),h.useEffect(()=>{!_&&!D&&ee()},[_,D,ee]),F.current=r,h.useEffect(()=>{var U,V;D&&T&&((U=q.current)==null||U.dispose(),q.current=(V=L.current)==null?void 0:V.onDidChangeModelContent(z=>{H.current||T(L.current.getValue(),z)}))},[D,T]),h.useEffect(()=>{if(D){let U=$.current.editor.onDidChangeMarkers(V=>{var W;let z=(W=L.current.getModel())==null?void 0:W.uri;if(z&&V.find(X=>X.path===z.path)){let X=$.current.editor.getModelMarkers({resource:z});N==null||N(X)}});return()=>{U==null||U.dispose()}}return()=>{}},[D,N]);function fe(){var U,V;(U=q.current)==null||U.dispose(),y?g&&Kp.set(i,L.current.saveViewState()):(V=L.current.getModel())==null||V.dispose(),L.current.dispose()}return re.createElement(B6,{width:v,height:S,isEditorReady:D,loading:f,_ref:k,className:C,wrapperProps:E})}var Uoe=Poe,W6=h.memo(Uoe);function zoe({initialValue:e,onChange:t}){const[n,r]=h.useState((e==null?void 0:e.sqlQuery)??""),{resolvedTheme:s}=Yh();h.useEffect(()=>{e!=null&&e.sqlQuery&&e.sqlQuery!==n&&r(e.sqlQuery)},[e,n]);function i(c){c!==void 0&&(r(c),t({sqlQuery:c}))}return a.jsx("div",{className:"shadow-xs",children:a.jsx(W6,{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-200/4",height:"30vh",language:"sql",value:n,onChange:i,theme:s==="dark"?"vs-dark":"light",options:{selectOnLineNumbers:!0,hideCursorInOverviewRuler:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,overviewRulerBorder:!1}})})}function mS({icon:e,title:t,subtitle:n,rightContent:r,onClick:s,className:i}){const c=e;return a.jsxs("div",{className:se("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",i),onClick:s,children:[a.jsxs("div",{className:"flex flex-grow items-start justify-center gap-3 px-6 py-5",children:[e&&a.jsx("div",{className:"flex items-center justify-center",children:a.jsx(c,{className:"h-6 w-6"})}),a.jsxs("div",{className:"flex flex-grow flex-col gap-1",children:[a.jsx("div",{className:"text-md font-medium",children:t}),n&&a.jsx("div",{className:"text-muted-foreground/60 text-sm",children:n})]})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2 p-4",children:[r,s&&a.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:a.jsx(va,{className:"text-muted-foreground/75 dark:text-muted-foreground/50 h-4 w-4"})})]})]})}var NN=1,Foe=.9,Hoe=.8,$oe=.17,B1=.1,q1=.999,Voe=.9999,Goe=.99,Boe=/[\\\/_+.#"@\[\(\{&]/,qoe=/[\\\/_+.#"@\[\(\{&]/g,Koe=/[\s-]/,Z6=/[\s-]/g;function pS(e,t,n,r,s,i,c){if(i===t.length)return s===e.length?NN:Goe;var u=`${s},${i}`;if(c[u]!==void 0)return c[u];for(var f=r.charAt(i),m=n.indexOf(f,s),x=0,g,y,v,S;m>=0;)g=pS(e,t,n,r,m+1,i+1,c),g>x&&(m===s?g*=NN:Boe.test(e.charAt(m-1))?(g*=Hoe,v=e.slice(s,m-1).match(qoe),v&&s>0&&(g*=Math.pow(q1,v.length))):Koe.test(e.charAt(m-1))?(g*=Foe,S=e.slice(s,m-1).match(Z6),S&&s>0&&(g*=Math.pow(q1,S.length))):(g*=$oe,s>0&&(g*=Math.pow(q1,m-s))),e.charAt(m)!==t.charAt(i)&&(g*=Voe)),(g<B1&&n.charAt(m-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(m-1)!==r.charAt(i))&&(y=pS(e,t,n,r,m+1,i+2,c),y*B1>g&&(g=y*B1)),g>x&&(x=g),m=n.indexOf(f,m+1);return c[u]=x,x}function AN(e){return e.toLowerCase().replace(Z6," ")}function Woe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,pS(e,t,AN(e),AN(t),0,0,{})}var Mf='[cmdk-group=""]',K1='[cmdk-group-items=""]',Zoe='[cmdk-group-heading=""]',Y6='[cmdk-item=""]',DN=`${Y6}:not([aria-disabled="true"])`,gS="cmdk-item-select",Hu="data-value",Yoe=(e,t,n)=>Woe(e,t,n),X6=h.createContext(void 0),om=()=>h.useContext(X6),Q6=h.createContext(void 0),AE=()=>h.useContext(Q6),J6=h.createContext(void 0),eM=h.forwardRef((e,t)=>{let n=$u(()=>{var V,z;return{search:"",value:(z=(V=e.value)!=null?V:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$u(()=>new Set),s=$u(()=>new Map),i=$u(()=>new Map),c=$u(()=>new Set),u=tM(e),{label:f,children:m,value:x,onValueChange:g,filter:y,shouldFilter:v,loop:S,disablePointerSelection:C=!1,vimBindings:E=!0,...j}=e,R=ar(),T=ar(),N=ar(),D=h.useRef(null),O=iie();Ic(()=>{if(x!==void 0){let V=x.trim();n.current.value=V,_.emit()}},[x]),Ic(()=>{O(6,K)},[]);let _=h.useMemo(()=>({subscribe:V=>(c.current.add(V),()=>c.current.delete(V)),snapshot:()=>n.current,setState:(V,z,W)=>{var X,oe,J,de;if(!Object.is(n.current[V],z)){if(n.current[V]=z,V==="search")B(),L(),O(1,k);else if(V==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ye=document.getElementById(N);ye?ye.focus():(X=document.getElementById(R))==null||X.focus()}if(O(7,()=>{var ye;n.current.selectedItemId=(ye=q())==null?void 0:ye.id,_.emit()}),W||O(5,K),((oe=u.current)==null?void 0:oe.value)!==void 0){let ye=z??"";(de=(J=u.current).onValueChange)==null||de.call(J,ye);return}}_.emit()}},emit:()=>{c.current.forEach(V=>V())}}),[]),M=h.useMemo(()=>({value:(V,z,W)=>{var X;z!==((X=i.current.get(V))==null?void 0:X.value)&&(i.current.set(V,{value:z,keywords:W}),n.current.filtered.items.set(V,$(z,W)),O(2,()=>{L(),_.emit()}))},item:(V,z)=>(r.current.add(V),z&&(s.current.has(z)?s.current.get(z).add(V):s.current.set(z,new Set([V]))),O(3,()=>{B(),L(),n.current.value||k(),_.emit()}),()=>{i.current.delete(V),r.current.delete(V),n.current.filtered.items.delete(V);let W=q();O(4,()=>{B(),(W==null?void 0:W.getAttribute("id"))===V&&k(),_.emit()})}),group:V=>(s.current.has(V)||s.current.set(V,new Set),()=>{i.current.delete(V),s.current.delete(V)}),filter:()=>u.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>u.current.disablePointerSelection,listId:R,inputId:N,labelId:T,listInnerRef:D}),[]);function $(V,z){var W,X;let oe=(X=(W=u.current)==null?void 0:W.filter)!=null?X:Yoe;return V?oe(V,n.current.search,z):0}function L(){if(!n.current.search||u.current.shouldFilter===!1)return;let V=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(X=>{let oe=s.current.get(X),J=0;oe.forEach(de=>{let ye=V.get(de);J=Math.max(ye,J)}),z.push([X,J])});let W=D.current;F().sort((X,oe)=>{var J,de;let ye=X.getAttribute("id"),Se=oe.getAttribute("id");return((J=V.get(Se))!=null?J:0)-((de=V.get(ye))!=null?de:0)}).forEach(X=>{let oe=X.closest(K1);oe?oe.appendChild(X.parentElement===oe?X:X.closest(`${K1} > *`)):W.appendChild(X.parentElement===W?X:X.closest(`${K1} > *`))}),z.sort((X,oe)=>oe[1]-X[1]).forEach(X=>{var oe;let J=(oe=D.current)==null?void 0:oe.querySelector(`${Mf}[${Hu}="${encodeURIComponent(X[0])}"]`);J==null||J.parentElement.appendChild(J)})}function k(){let V=F().find(W=>W.getAttribute("aria-disabled")!=="true"),z=V==null?void 0:V.getAttribute(Hu);_.setState("value",z||void 0)}function B(){var V,z,W,X;if(!n.current.search||u.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let J of r.current){let de=(z=(V=i.current.get(J))==null?void 0:V.value)!=null?z:"",ye=(X=(W=i.current.get(J))==null?void 0:W.keywords)!=null?X:[],Se=$(de,ye);n.current.filtered.items.set(J,Se),Se>0&&oe++}for(let[J,de]of s.current)for(let ye of de)if(n.current.filtered.items.get(ye)>0){n.current.filtered.groups.add(J);break}n.current.filtered.count=oe}function K(){var V,z,W;let X=q();X&&(((V=X.parentElement)==null?void 0:V.firstChild)===X&&((W=(z=X.closest(Mf))==null?void 0:z.querySelector(Zoe))==null||W.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function q(){var V;return(V=D.current)==null?void 0:V.querySelector(`${Y6}[aria-selected="true"]`)}function F(){var V;return Array.from(((V=D.current)==null?void 0:V.querySelectorAll(DN))||[])}function I(V){let z=F()[V];z&&_.setState("value",z.getAttribute(Hu))}function G(V){var z;let W=q(),X=F(),oe=X.findIndex(de=>de===W),J=X[oe+V];(z=u.current)!=null&&z.loop&&(J=oe+V<0?X[X.length-1]:oe+V===X.length?X[0]:X[oe+V]),J&&_.setState("value",J.getAttribute(Hu))}function H(V){let z=q(),W=z==null?void 0:z.closest(Mf),X;for(;W&&!X;)W=V>0?sie(W,Mf):oie(W,Mf),X=W==null?void 0:W.querySelector(DN);X?_.setState("value",X.getAttribute(Hu)):G(V)}let ee=()=>I(F().length-1),fe=V=>{V.preventDefault(),V.metaKey?ee():V.altKey?H(1):G(1)},U=V=>{V.preventDefault(),V.metaKey?I(0):V.altKey?H(-1):G(-1)};return h.createElement(tt.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:V=>{var z;(z=j.onKeyDown)==null||z.call(j,V);let W=V.nativeEvent.isComposing||V.keyCode===229;if(!(V.defaultPrevented||W))switch(V.key){case"n":case"j":{E&&V.ctrlKey&&fe(V);break}case"ArrowDown":{fe(V);break}case"p":case"k":{E&&V.ctrlKey&&U(V);break}case"ArrowUp":{U(V);break}case"Home":{V.preventDefault(),I(0);break}case"End":{V.preventDefault(),ee();break}case"Enter":{V.preventDefault();let X=q();if(X){let oe=new Event(gS);X.dispatchEvent(oe)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:M.inputId,id:M.labelId,style:cie},f),py(e,V=>h.createElement(Q6.Provider,{value:_},h.createElement(X6.Provider,{value:M},V))))}),Xoe=h.forwardRef((e,t)=>{var n,r;let s=ar(),i=h.useRef(null),c=h.useContext(J6),u=om(),f=tM(e),m=(r=(n=f.current)==null?void 0:n.forceMount)!=null?r:c==null?void 0:c.forceMount;Ic(()=>{if(!m)return u.item(s,c==null?void 0:c.id)},[m]);let x=nM(s,i,[e.value,e.children,i],e.keywords),g=AE(),y=El(O=>O.value&&O.value===x.current),v=El(O=>m||u.filter()===!1?!0:O.search?O.filtered.items.get(s)>0:!0);h.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(gS,S),()=>O.removeEventListener(gS,S)},[v,e.onSelect,e.disabled]);function S(){var O,_;C(),(_=(O=f.current).onSelect)==null||_.call(O,x.current)}function C(){g.setState("value",x.current,!0)}if(!v)return null;let{disabled:E,value:j,onSelect:R,forceMount:T,keywords:N,...D}=e;return h.createElement(tt.div,{ref:ra(i,t),...D,id:s,"cmdk-item":"",role:"option","aria-disabled":!!E,"aria-selected":!!y,"data-disabled":!!E,"data-selected":!!y,onPointerMove:E||u.getDisablePointerSelection()?void 0:C,onClick:E?void 0:S},e.children)}),Qoe=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...i}=e,c=ar(),u=h.useRef(null),f=h.useRef(null),m=ar(),x=om(),g=El(v=>s||x.filter()===!1?!0:v.search?v.filtered.groups.has(c):!0);Ic(()=>x.group(c),[]),nM(c,u,[e.value,e.heading,f]);let y=h.useMemo(()=>({id:c,forceMount:s}),[s]);return h.createElement(tt.div,{ref:ra(u,t),...i,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},n&&h.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:m},n),py(e,v=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},h.createElement(J6.Provider,{value:y},v))))}),Joe=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=h.useRef(null),i=El(c=>!c.search);return!n&&!i?null:h.createElement(tt.div,{ref:ra(s,t),...r,"cmdk-separator":"",role:"separator"})}),eie=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,i=AE(),c=El(m=>m.search),u=El(m=>m.selectedItemId),f=om();return h.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),h.createElement(tt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":u,id:f.inputId,type:"text",value:s?e.value:c,onChange:m=>{s||i.setState("search",m.target.value),n==null||n(m.target.value)}})}),tie=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,i=h.useRef(null),c=h.useRef(null),u=El(m=>m.selectedItemId),f=om();return h.useEffect(()=>{if(c.current&&i.current){let m=c.current,x=i.current,g,y=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let v=m.offsetHeight;x.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(m),()=>{cancelAnimationFrame(g),y.unobserve(m)}}},[]),h.createElement(tt.div,{ref:ra(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":u,"aria-label":r,id:f.listId},py(e,m=>h.createElement("div",{ref:ra(c,f.listInnerRef),"cmdk-list-sizer":""},m)))}),nie=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:c,...u}=e;return h.createElement(xx,{open:n,onOpenChange:r},h.createElement(yx,{container:c},h.createElement(vx,{"cmdk-overlay":"",className:s}),h.createElement(bx,{"aria-label":e.label,"cmdk-dialog":"",className:i},h.createElement(eM,{ref:t,...u}))))}),rie=h.forwardRef((e,t)=>El(n=>n.filtered.count===0)?h.createElement(tt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),aie=h.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...i}=e;return h.createElement(tt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},py(e,c=>h.createElement("div",{"aria-hidden":!0},c)))}),Nd=Object.assign(eM,{List:tie,Item:Xoe,Input:eie,Group:Qoe,Separator:Joe,Dialog:nie,Empty:rie,Loading:aie});function sie(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function oie(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tM(e){let t=h.useRef(e);return Ic(()=>{t.current=e}),t}var Ic=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $u(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function El(e){let t=AE(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function nM(e,t,n,r=[]){let s=h.useRef(),i=om();return Ic(()=>{var c;let u=(()=>{var m;for(let x of n){if(typeof x=="string")return x.trim();if(typeof x=="object"&&"current"in x)return x.current?(m=x.current.textContent)==null?void 0:m.trim():s.current}})(),f=r.map(m=>m.trim());i.value(e,u,f),(c=t.current)==null||c.setAttribute(Hu,u),s.current=u}),s}var iie=()=>{let[e,t]=h.useState(),n=$u(()=>new Map);return Ic(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function lie(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function py({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(lie(t),{ref:t.ref},n(t.props.children)):n(t)}var cie={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function DE({className:e,...t}){return a.jsx(Nd,{"data-slot":"command",className:se("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function OE({className:e,...t}){return a.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[a.jsx(zc,{className:"size-4 shrink-0 opacity-50"}),a.jsx(Nd.Input,{"data-slot":"command-input",className:se("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",e),...t})]})}function rM({className:e,...t}){return a.jsx(Nd.List,{"data-slot":"command-list",className:se("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function aM({...e}){return a.jsx(Nd.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function sM({className:e,...t}){return a.jsx(Nd.Group,{"data-slot":"command-group",className:se("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",e),...t})}function IE({className:e,...t}){return a.jsx(Nd.Item,{"data-slot":"command-item",className:se("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",e),...t})}function uie(e){const t=die(e),n=h.forwardRef((r,s)=>{const{children:i,...c}=r,u=h.Children.toArray(i),f=u.find(hie);if(f){const m=f.props.children,x=u.map(g=>g===f?h.Children.count(m)>1?h.Children.only(null):h.isValidElement(m)?m.props.children:null:g);return a.jsx(t,{...c,ref:s,children:h.isValidElement(m)?h.cloneElement(m,void 0,x):null})}return a.jsx(t,{...c,ref:s,children:i})});return n.displayName=`${e}.Slot`,n}function die(e){const t=h.forwardRef((n,r)=>{const{children:s,...i}=n;if(h.isValidElement(s)){const c=pie(s),u=mie(i,s.props);return s.type!==h.Fragment&&(u.ref=r?ra(r,c):c),h.cloneElement(s,u)}return h.Children.count(s)>1?h.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fie=Symbol("radix.slottable");function hie(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fie}function mie(e,t){const n={...t};for(const r in t){const s=e[r],i=t[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...u)=>{const f=i(...u);return s(...u),f}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...e,...n}}function pie(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gy="Popover",[oM]=Nr(gy,[Oo]),im=Oo(),[gie,Hl]=oM(gy),iM=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:c=!1}=e,u=im(t),f=h.useRef(null),[m,x]=h.useState(!1),[g,y]=xa({prop:r,defaultProp:s??!1,onChange:i,caller:gy});return a.jsx(Sd,{...u,children:a.jsx(gie,{scope:t,contentId:ar(),triggerRef:f,open:g,onOpenChange:y,onOpenToggle:h.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:m,onCustomAnchorAdd:h.useCallback(()=>x(!0),[]),onCustomAnchorRemove:h.useCallback(()=>x(!1),[]),modal:c,children:n})})};iM.displayName=gy;var lM="PopoverAnchor",xie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(lM,n),i=im(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:u}=s;return h.useEffect(()=>(c(),()=>u()),[c,u]),a.jsx(Cd,{...i,...r,ref:t})});xie.displayName=lM;var cM="PopoverTrigger",uM=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(cM,n),i=im(n),c=wt(t,s.triggerRef),u=a.jsx(tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":pM(s.open),...r,ref:c,onClick:Me(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?u:a.jsx(Cd,{asChild:!0,...i,children:u})});uM.displayName=cM;var ME="PopoverPortal",[yie,vie]=oM(ME,{forceMount:void 0}),dM=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,i=Hl(ME,t);return a.jsx(yie,{scope:t,forceMount:n,children:a.jsx(Yr,{present:n||i.open,children:a.jsx(Hc,{asChild:!0,container:s,children:r})})})};dM.displayName=ME;var md="PopoverContent",fM=h.forwardRef((e,t)=>{const n=vie(md,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,i=Hl(md,e.__scopePopover);return a.jsx(Yr,{present:r||i.open,children:i.modal?a.jsx(Sie,{...s,ref:t}):a.jsx(Cie,{...s,ref:t})})});fM.displayName=md;var bie=uie("PopoverContent.RemoveScroll"),Sie=h.forwardRef((e,t)=>{const n=Hl(md,e.__scopePopover),r=h.useRef(null),s=wt(t,r),i=h.useRef(!1);return h.useEffect(()=>{const c=r.current;if(c)return px(c)},[]),a.jsx(Mh,{as:bie,allowPinchZoom:!0,children:a.jsx(hM,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,c=>{var u;c.preventDefault(),i.current||(u=n.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;i.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),Cie=h.forwardRef((e,t)=>{const n=Hl(md,e.__scopePopover),r=h.useRef(!1),s=h.useRef(!1);return a.jsx(hM,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var c,u;(c=e.onCloseAutoFocus)==null||c.call(e,i),i.defaultPrevented||(r.current||(u=n.triggerRef.current)==null||u.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var f,m;(f=e.onInteractOutside)==null||f.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const c=i.target;((m=n.triggerRef.current)==null?void 0:m.contains(c))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),hM=h.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:x,...g}=e,y=Hl(md,n),v=im(n);return hx(),a.jsx(Ih,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(Fc,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:x,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onDismiss:()=>y.onOpenChange(!1),children:a.jsx(Lh,{"data-state":pM(y.open),role:"dialog",id:y.contentId,...v,...g,ref:t,style:{...g.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)"}})})})}),mM="PopoverClose",Eie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Hl(mM,n);return a.jsx(tt.button,{type:"button",...r,ref:t,onClick:Me(e.onClick,()=>s.onOpenChange(!1))})});Eie.displayName=mM;var wie="PopoverArrow",Rie=h.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=im(n);return a.jsx(Ph,{...s,...r,ref:t})});Rie.displayName=wie;function pM(e){return e?"open":"closed"}var jie=iM,Tie=uM,_ie=dM,Nie=fM;function kE({...e}){return a.jsx(jie,{"data-slot":"popover",...e})}function LE({...e}){return a.jsx(Tie,{"data-slot":"popover-trigger",...e})}function PE({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(_ie,{children:a.jsx(Nie,{"data-slot":"popover-content",align:t,sideOffset:n,className:se("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",e),...r})})}function UE({options:e,value:t,onValueChange:n,placeholder:r="Select an option",emptyMessage:s="No results found.",className:i,disabled:c=!1}){const[u,f]=h.useState(!1),[m,x]=h.useState(""),g=h.useMemo(()=>{const S={};return e.forEach(C=>{const E=C.group??"";Object.prototype.hasOwnProperty.call(S,E)||(S[E]=[]),S[E].push(C)}),S},[e]),y=e.find(S=>S.value===t),v=h.useCallback(S=>{n(S),requestAnimationFrame(()=>{x(""),f(!1)})},[n]);return a.jsxs(kE,{open:u,onOpenChange:f,modal:!0,children:[a.jsx(LE,{asChild:!0,children:a.jsxs(we,{variant:"outline",role:"combobox","aria-expanded":u,className:se("w-full justify-between",!t&&"text-muted-foreground",i),disabled:c,children:[y?y.label:r,a.jsx(WS,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsx(PE,{className:"max-h-[300px] min-w-[300px] overflow-auto p-0",align:"start",sideOffset:5,children:a.jsxs(DE,{children:[a.jsx(OE,{placeholder:`Search ${r.toLowerCase()}...`,value:m,onValueChange:x}),a.jsx(aM,{children:s}),Object.entries(g).map(([S,C])=>a.jsx(sM,{heading:S,children:C.map(E=>a.jsxs(IE,{value:E.value,onSelect:()=>{v(E.value)},keywords:[E.label],children:[a.jsx(Ia,{className:se("mr-2 h-4 w-4",t===E.value?"opacity-100":"opacity-0")}),E.label]},E.value))},S||"default"))]})})]})}function Aie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"service-account-details",children:[a.jsx(Dt,{children:"How do I get a Service Account JSON key?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's what to do:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Go to"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/iam-admin/serviceaccounts",children:"Google Cloud Console"}),"."]}),a.jsxs("li",{children:["Open ",a.jsx("strong",{children:"IAM & Admin → Service Accounts"}),"."]}),a.jsx("li",{children:"Create a new service account or select an existing one."}),a.jsxs("li",{children:["Assign the ",a.jsx("strong",{children:"bigquery.dataEditor"})," and ",a.jsx("strong",{children:"bigquery.jobUser"})," ","roles to this service account to allow read, write, and create access to your project resources."]}),a.jsxs("li",{children:["Open the Service Accounts page, go to the ",a.jsx("strong",{children:"Keys"})," tab, click"," ",a.jsx("strong",{children:"Add key"}),", and select ",a.jsx("strong",{children:"Create new key"}),"."]}),a.jsxs("li",{children:["Choose ",a.jsx("strong",{children:"JSON"})," format and click ",a.jsx("strong",{children:"Create"}),"."]}),a.jsx("li",{children:"Open the downloaded file, copy its entire content, and paste it into the field above."})]})]})]})})}function Die(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"project-id-details",children:[a.jsx(Dt,{children:"How do I find my Project ID?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"This is the ID of your Google Cloud project. BigQuery usage costs will be charged to this project."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your billing project ID:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/",children:"Google Cloud Console"})," ","and sign in with your Google account."]}),a.jsx("li",{children:'Click the project selector dropdown at the top of the page (it shows the current project name or "Select a project").'}),a.jsxs("li",{children:["Find your project in the list. The ",a.jsx("strong",{children:"Project ID"})," is shown in the ID column."]}),a.jsx("li",{children:"If you don't see your project, use the search box to find it by name or ID."})]})]})]})})}function Oie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"gbq-location-details",children:[a.jsx(Dt,{children:"How do I find my dataset location?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to check your dataset location:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/bigquery",children:"Google Cloud Console BigQuery page"}),"."]}),a.jsx("li",{children:"In the left panel, expand your project and find your datasets."}),a.jsxs("li",{children:["Click each dataset name to open its details. The ",a.jsx("strong",{children:"Data location"})," field shows the region where that dataset is stored (for example,"," ",a.jsx("code",{className:"text-sm font-semibold",children:"US"}),","," ",a.jsx("code",{className:"text-sm font-semibold",children:"EU"}),","," ",a.jsx("code",{className:"text-sm font-semibold",children:"asia-northeast1"}),")."]}),a.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."}),a.jsx("li",{children:"Put this location value in the field above."})]})]})]})})}const Iie=({form:e})=>{const[t,n]=h.useState(!1);if(e.watch("type")!==xe.GOOGLE_BIGQUERY)return null;const r=()=>{n(!0),e.setValue("credentials.serviceAccount","",{shouldDirty:!0})},s=()=>{n(!1),e.resetField("credentials.serviceAccount")},i=e.watch("credentials.serviceAccount"),c=i?m5(i):null;return a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.projectId",render:({field:u})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the ID of your Google Cloud project where BigQuery usage will be billed",children:"Project ID"}),a.jsx(vt,{children:a.jsx(gt,{...u,placeholder:"Enter a Project Id"})}),a.jsx(on,{children:a.jsx(Die,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.location",render:({field:u})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Choose the same region where your BigQuery data is stored to ensure queries work correctly",children:"Location"}),a.jsx(vt,{children:a.jsx(UE,{options:FQ,value:u.value,onValueChange:u.onChange,placeholder:"Select a location",emptyMessage:"No locations found",className:"w-full"})}),a.jsx(on,{children:a.jsx(Oie,{})}),a.jsx(jt,{})]})})]}),a.jsx(zr,{title:"Authentication",children:a.jsx(Et,{control:e.control,name:"credentials.serviceAccount",render:({field:u})=>a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{tooltip:"Paste a JSON key from a service account that has access to the selected storage provider",children:"Service Account"}),!t&&i&&a.jsx(we,{variant:"ghost",size:"sm",onClick:r,type:"button",children:"Edit"}),t&&a.jsx(we,{variant:"ghost",size:"sm",onClick:s,type:"button",children:"Cancel"})]}),a.jsx(vt,{children:!t&&c?a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Kt,{href:c.url,children:c.email})}),a.jsx(ot,{children:a.jsx("p",{children:"View in Google Cloud Console"})})]}):a.jsx(Io,{...u,className:"min-h-[150px] font-mono",rows:8,placeholder:"Paste your service account JSON here"})}),a.jsx(on,{children:a.jsx(Aie,{})}),a.jsx(jt,{})]})})})]})};function Mie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-region-details",children:[a.jsx(Dt,{children:"How do I find my Athena region?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your Athena region:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"}),"."]}),a.jsx("li",{children:"Look at the top right corner of the console. The selected region is shown in the region selector dropdown."}),a.jsx("li",{children:"Make sure to copy and paste the same region here in the form to avoid connection or query errors."})]})]})]})})}function kie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-output-bucket-details",children:[a.jsx(Dt,{children:"How do I find a bucket?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["Athena saves query results in an ",a.jsx("strong",{children:"S3 bucket"}),". You need to specify the bucket used for query output."]}),a.jsx("p",{className:"mb-2",children:"Here's how to find or create an S3 bucket for Athena output:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/s3/",children:"the AWS S3 console"}),"."]}),a.jsx("li",{children:"Look for an existing bucket used for Athena query results, or create a new one."}),a.jsx("li",{children:"If creating a new bucket, make sure it is in the same region as your Athena service."}),a.jsx("li",{children:"Enter the bucket name in this form field."})]})]})]})})}function Lie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-access-key-id-details",children:[a.jsx(Dt,{children:"How do I get my AWS Access Key ID?"}),a.jsxs(Ot,{children:[a.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."}),a.jsxs("p",{className:"mb-4 text-sm",children:["Learn more about how to create a user in AWS ",a.jsx(Kt,{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"}),"."]}),a.jsx(JS,{className:"my-4"}),a.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS credentials needed to connect and authenticate."}),a.jsx("p",{className:"mb-2",children:"Here's how to find or create an Access Key ID:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),a.jsxs("li",{children:["Under ",a.jsx("strong",{children:"Access keys"}),", find your existing keys or create a new access key."]}),a.jsx("li",{children:"When you create a new key, download and securely store the Access Key ID and Secret Access Key."})]})]})]})})}function Pie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-secret-access-key-details",children:[a.jsx(Dt,{children:"How do I get my AWS Secret Access Key?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to get your Secret Access Key:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"the AWS IAM Security Credentials page"}),"."]}),a.jsxs("li",{children:["Under ",a.jsx("strong",{children:"Access keys"}),", create a new access key if you don't have one or lost the secret key."]}),a.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 Uie=({form:e})=>{const[t,n]=h.useState("");return h.useEffect(()=>{const r=e.getValues("credentials.accessKeyId");if(r){const s="_".repeat(r.length);n(s),e.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[e]),e.watch("type")!==xe.AWS_ATHENA?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.region",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the AWS region where your Athena service is active",children:"Region"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter a region"})}),a.jsx(on,{children:a.jsx(Mie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.outputBucket",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Specify the S3 bucket where Athena query results will be stored",children:"Output Bucket"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an output bucket"})}),a.jsx(on,{children:a.jsx(kie,{})}),a.jsx(jt,{})]})})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.accessKeyId",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an access key id"})}),a.jsx(on,{children:a.jsx(Lie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.secretAccessKey",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),a.jsx(vt,{children:a.jsx(gt,{...r,type:"password",placeholder:t||"Enter a secret access key"})}),a.jsx(on,{children:a.jsx(Pie,{})}),a.jsx(jt,{})]})})]})]})};function zie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-account-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake account identifier?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["To find the region and locator for your account, see"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/admin-account-identifier#finding-the-region-and-locator-for-an-account",children:"Snowflake documentation"}),"."]}),a.jsxs("ol",{className:"list-inside list-decimal space-y-3 text-sm",children:[a.jsx("li",{children:"Open the account selector and review the list of accounts that you previously signed in to."}),a.jsxs("li",{children:["Select ",a.jsx("strong",{children:"View account details"}),"."]}),a.jsxs("li",{children:["The ",a.jsx("strong",{children:"Account Details"})," dialog displays information about the account, including the account identifier and the account URL."]}),a.jsxs("li",{children:["Copy part of your account identifier from the ",a.jsx("strong",{children:"Account locator"})," field."]}),a.jsx("li",{children:"Find the region in the account selector (e.g. Europe West4 (Netherlands))."}),a.jsxs("li",{children:["Compare the found region with the ",a.jsx("strong",{children:"Account Identifier Region"})," in"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/admin-account-identifier#non-vps-account-locator-formats-by-cloud-platform-and-region",children:"Snowflake documentation"})," ","for locator formats by cloud platform and region."]}),a.jsxs("li",{children:["Create the account identifier by combining the locator and the region like this:"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"locator.region"}),a.jsxs("div",{className:"mt-2",children:["Examples:",a.jsxs("ul",{className:"mt-1 ml-4 space-y-1",children:[a.jsx("li",{children:a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.ap-northeast-3.aws"})}),a.jsx("li",{children:a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"xy12345.north-europe.azure"})})]})]})]})]}),a.jsxs("div",{className:"mt-4 text-sm",children:["More details in"," ",a.jsx(Kt,{className:"underline",href:"https://docs.owox.com/docs/storages/supported-storages/snowflake/",children:"OWOX Snowflake documentation"}),"."]})]})]})})}function Fie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-warehouse-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake warehouse?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"A warehouse in Snowflake is a cluster of compute resources that executes queries and performs data loading operations."}),a.jsx("p",{className:"mb-2",children:"Here's how to find your warehouse:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsx("li",{children:'Log in to your Snowflake account and navigate to the "Warehouses" section in the left sidebar.'}),a.jsx("li",{children:`You'll see a list of available warehouses. Common default names include "COMPUTE_WH" or "PROD_WH".`}),a.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."}),a.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 Hie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-auth-method-details",children:[a.jsx(Dt,{children:"Which authentication method should I choose?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Snowflake supports two authentication methods for programmatic access:"}),a.jsxs("div",{className:"space-y-3 text-sm",children:[a.jsxs("div",{children:[a.jsx("strong",{className:"font-medium",children:"Username & Password:"}),a.jsx("p",{className:"mt-1",children:"The simplest method using your Snowflake username and password. Suitable for development and testing environments."})]}),a.jsxs("div",{children:[a.jsx("strong",{className:"font-medium",children:"Key Pair Authentication:"}),a.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."}),a.jsxs("p",{className:"mt-1",children:["Learn more about"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"key pair authentication"}),"."]})]})]})]})]})})}function $ie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-username-details",children:[a.jsx(Dt,{children:"How do I find my Snowflake username?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Your Snowflake username is the login identifier for your Snowflake account."}),a.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"Use the same username you use to log in to the Snowflake web interface."}),a.jsx("li",{children:"Snowflake usernames are case-insensitive and are typically in uppercase by default."}),a.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."}),a.jsx("li",{children:"You can view all users in your account by running: SHOW USERS; (requires appropriate privileges)"})]})]})]})})}function Vie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-password-details",children:[a.jsx(Dt,{children:"How do I manage my Snowflake password?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Use the password associated with your Snowflake user account for authentication."}),a.jsx("p",{className:"mb-2",children:"Important security considerations:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"Your password must meet Snowflake's security requirements (minimum length, complexity, etc.)."}),a.jsx("li",{children:"If you've forgotten your password, a Snowflake administrator can reset it using: ALTER USER username SET PASSWORD = 'new_password';"}),a.jsxs("li",{children:["For production environments, consider using"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Key-Pair authentication"})," ","instead of passwords for enhanced security."]}),a.jsx("li",{children:"Your password is encrypted and securely stored. It will never be displayed in plain text after saving."})]})]})]})})}function Gie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-keypair-details",children:[a.jsx(Dt,{children:"How do I set up key pair authentication?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"To use key pair authentication, you need to generate an RSA key pair and configure your Snowflake user."}),a.jsx("p",{className:"mb-2",children:"Here's how to set it up:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Generate an RSA key pair using OpenSSL:",a.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"})]}),a.jsxs("li",{children:["Extract the public key:",a.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"})]}),a.jsxs("li",{children:["Assign the public key to your Snowflake user (run this in Snowflake as ACCOUNTADMIN):",a.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...';"})]}),a.jsx("li",{children:"Copy the private key content from rsa_key.p8 and paste it in the Private Key field above."})]}),a.jsxs("p",{className:"mt-2 text-xs",children:["For more details, see"," ",a.jsx(Kt,{className:"underline",href:"https://docs.snowflake.com/en/user-guide/key-pair-auth.html",children:"Snowflake's key pair authentication documentation"}),"."]})]})]})})}function Bie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"snowflake-passphrase-details",children:[a.jsx(Dt,{children:"What is a passphrase and when do I need it?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"A passphrase is an optional encryption password that protects your private key."}),a.jsx("p",{className:"mb-2",children:"Here's what you need to know:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-2 text-sm",children:[a.jsx("li",{children:"If you generated your private key with a passphrase (encrypted key), you must provide it here."}),a.jsx("li",{children:"If your private key is not encrypted (generated without the -nocrypt flag), leave this field empty."}),a.jsx("li",{children:"When generating an encrypted key with OpenSSL, you set the passphrase during the key generation process."}),a.jsx("li",{children:"The passphrase adds an extra layer of security by encrypting the private key file itself."}),a.jsx("li",{children:"This passphrase is only used to decrypt the private key and is never sent to Snowflake."})]})]})]})})}const qie=({form:e})=>{const t=e.watch("credentials.authMethod"),[n,r]=h.useState(""),[s,i]=h.useState("");return h.useEffect(()=>{if(e.getValues("credentials.username")){const u="_".repeat(12);r(u),e.setValue("credentials.password",u,{shouldDirty:!1});const f="_".repeat(20);i(f),e.setValue("credentials.privateKey",f,{shouldDirty:!1})}},[e]),e.watch("type")!==xe.SNOWFLAKE?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.account",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter your Snowflake account identifier",children:"Account"}),a.jsx(vt,{children:a.jsx(gt,{...c,placeholder:"e.g., xy12345.us-east-1"})}),a.jsx(on,{children:a.jsx(zie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.warehouse",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Specify the Snowflake warehouse to use for query execution",children:"Warehouse"}),a.jsx(vt,{children:a.jsx(gt,{...c,placeholder:"Enter warehouse name"})}),a.jsx(on,{children:a.jsx(Fie,{})}),a.jsx(jt,{})]})})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.authMethod",render:({field:c})=>a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{children:"Authentication Method"}),a.jsx(cy,{value:c.value,onValueChange:c.onChange,children:a.jsxs(uy,{children:[a.jsx(Oc,{value:Vs.PASSWORD,children:"Username & Password"}),a.jsx(Oc,{value:Vs.KEY_PAIR,children:"Key Pair"})]})})]}),a.jsx(on,{children:a.jsx(Hie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.username",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your Snowflake username",children:"Username"}),a.jsx(vt,{children:a.jsx(gt,{...c,placeholder:"Enter username"})}),a.jsx(on,{children:a.jsx($ie,{})}),a.jsx(jt,{})]})}),t===Vs.PASSWORD&&a.jsx(Et,{control:e.control,name:"credentials.password",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your Snowflake password",children:"Password"}),a.jsx(vt,{children:a.jsx(gt,{...c,type:"password",placeholder:n||"Enter password"})}),a.jsx(on,{children:a.jsx(Vie,{})}),a.jsx(jt,{})]})}),t===Vs.KEY_PAIR&&a.jsxs(a.Fragment,{children:[a.jsx(Et,{control:e.control,name:"credentials.privateKey",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Paste your private key in PEM format",children:"Private Key"}),a.jsx(vt,{children:a.jsx(Io,{...c,placeholder:s||`-----BEGIN PRIVATE KEY-----
829
829
  ...
830
- -----END PRIVATE KEY-----`,rows:6})}),a.jsx(on,{children:a.jsx(Gie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.privateKeyPassphrase",render:({field:n})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the passphrase if your private key is encrypted",children:"Passphrase (Optional)"}),a.jsx(vt,{children:a.jsx(gt,{...n,type:"password",value:n.value??"",placeholder:"Enter passphrase if key is encrypted"})}),a.jsx(on,{children:a.jsx(Bie,{})}),a.jsx(jt,{})]})})]})]})]})};function Kie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-region-details",children:[a.jsx(Dt,{children:"What is the AWS region?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The AWS region is the geographic location where your Redshift cluster or Serverless workgroup is hosted."}),a.jsx("p",{className:"mb-2",children:"Common examples:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"us-east-1"})," - US East (N. Virginia)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"us-west-2"})," - US West (Oregon)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"eu-west-1"})," - Europe (Ireland)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"ap-southeast-1"})," - Asia Pacific (Singapore)"]})]}),a.jsxs("p",{className:"mt-2 text-sm",children:["You can find your region in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshift/",children:"AWS Redshift Console"}),"."]})]})]})})}function Wie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-workgroup-details",children:[a.jsx(Dt,{children:"What is a Redshift Serverless workgroup?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["A workgroup is a collection of compute resources in Redshift Serverless. Use this field if you're using ",a.jsx("strong",{children:"Redshift Serverless"}),"."]}),a.jsxs("p",{className:"mb-2",children:["You can find your workgroup name in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshiftv2/home#serverless-dashboard",children:"Redshift Serverless Console"}),"."]}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Note:"})," You must provide either a workgroup name (for Serverless) OR a cluster identifier (for provisioned clusters), but not both."]})]})]})})}function Zie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-cluster-details",children:[a.jsx(Dt,{children:"What is a cluster identifier?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["A cluster identifier is the unique name of your"," ",a.jsx("strong",{children:"provisioned Redshift cluster"}),". Use this field if you're using a traditional Redshift cluster (not Serverless)."]}),a.jsxs("p",{className:"mb-2",children:["You can find your cluster identifier in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshiftv2/home#clusters",children:"Redshift Clusters Console"}),"."]}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Note:"})," You must provide either a cluster identifier (for provisioned clusters) OR a workgroup name (for Serverless), but not both."]})]})]})})}function Yie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-database-details",children:[a.jsx(Dt,{children:"What is the database name?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The database name is the name of the database you want to connect to within your Redshift cluster or workgroup."}),a.jsxs("p",{className:"mb-2",children:["Every Redshift cluster/workgroup has at least one database. The default database is often named ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"dev"}),", but you may have created custom databases."]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"This field is required for all authentication methods."})]})]})})}function Xie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-access-key-details",children:[a.jsx(Dt,{children:"What is an AWS Access Key ID?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS security credentials. It's used together with the Secret Access Key to authenticate AWS API requests."}),a.jsxs("p",{className:"mb-2",children:["Access keys are typically 20 characters long and start with"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"AKIA"})," or"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"ASIA"})," (for temporary credentials)."]}),a.jsxs("p",{className:"text-sm",children:["You can create access keys in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"AWS IAM Console"}),"."]})]})]})})}function Qie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-secret-key-details",children:[a.jsx(Dt,{children:"What is an AWS Secret Access Key?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The Secret Access Key is the private part of your AWS security credentials. It's used together with the Access Key ID to sign and authenticate AWS API requests."}),a.jsx("p",{className:"mb-2",children:"Secret Access Keys are typically 40 characters long and are only shown once when created. If you lose it, you'll need to create a new access key pair."}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Security warning:"})," Keep your secret access key secure and never share it publicly. It will be stored encrypted."]})]})]})})}const Jie=({form:e})=>{const[t,n]=h.useState("");return h.useEffect(()=>{const r=e.getValues("config.connectionType"),s=e.watch("type");r===void 0&&s===xe.AWS_REDSHIFT&&e.setValue("config.connectionType",dr.SERVERLESS,{shouldDirty:!1})},[e]),h.useEffect(()=>{const r=e.getValues("credentials.accessKeyId");if(r){const s="_".repeat(r.length);n(s),e.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[e]),e.watch("type")!==xe.AWS_REDSHIFT?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.region",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the AWS region where your Redshift service is active",children:"Region"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter a region"})}),a.jsx(on,{children:a.jsx(Kie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.database",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"The database name to connect to",children:"Database"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter database name"})}),a.jsx(on,{children:a.jsx(Yie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.connectionType",render:({field:r})=>{const s=r.value??dr.SERVERLESS;return a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{tooltip:s===dr.SERVERLESS?"Workgroup name for Redshift Serverless":"Cluster identifier for provisioned Redshift cluster",children:s===dr.SERVERLESS?"Workgroup Name":"Cluster Identifier"}),a.jsx(cy,{value:s,onValueChange:r.onChange,children:a.jsxs(uy,{children:[a.jsx(Oc,{value:dr.SERVERLESS,children:"Serverless"}),a.jsx(Oc,{value:dr.PROVISIONED,children:"Provisioned"})]})})]}),a.jsx(vt,{children:s===dr.SERVERLESS?a.jsx(gt,{...e.register("config.workgroupName"),placeholder:"Enter workgroup name"}):a.jsx(gt,{...e.register("config.clusterIdentifier"),placeholder:"Enter cluster identifier"})}),a.jsx(on,{children:s===dr.SERVERLESS?a.jsx(Wie,{}):a.jsx(Zie,{})}),a.jsx(jt,{})]})}})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.accessKeyId",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an access key id"})}),a.jsx(on,{children:a.jsx(Xie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.secretAccessKey",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),a.jsx(vt,{children:a.jsx(gt,{...r,type:"password",placeholder:t||"Enter a secret access key"})}),a.jsx(on,{children:a.jsx(Qie,{})}),a.jsx(jt,{})]})})]})]})},ele=()=>a.jsx(a.Fragment,{children:a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,className:"mt-2",children:a.jsxs(At,{value:"snowflake-setup",children:[a.jsx(Dt,{children:"How do I get started with Snowflake?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"To use Snowflake as your storage provider, you'll need an active Snowflake account with appropriate permissions."}),a.jsx("p",{className:"mb-2",children:"Here's how to get started:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Sign up for a"," ",a.jsx(Kt,{className:"underline",href:"https://signup.snowflake.com/",children:"Snowflake account"})," ","if you don't have one yet."]}),a.jsx("li",{children:"Make sure you have the necessary privileges to create and access databases, schemas, and warehouses."}),a.jsx("li",{children:"Choose your authentication method: Username & Password for quick setup, or Key-Pair authentication for production environments."}),a.jsx("li",{children:"Fill in the connection details below (account identifier and warehouse)."}),a.jsx("li",{children:"You can access tables using the full path format: database.schema.table (similar to BigQuery and Athena)."})]})]})]})})});function tle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"bigquery-api-details",children:[a.jsx(Dt,{children:"How do I enable the BigQuery API?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["To run queries and process data in Google BigQuery, you need to enable the"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/apis/library/bigquery.googleapis.com",children:"BigQuery API"})," ","in your Google Cloud project."]}),a.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),a.jsxs("li",{children:["If the API isn't enabled yet, click ",a.jsx("strong",{children:"Enable"}),"."]}),a.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})})}function nle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-api-details",children:[a.jsx(Dt,{children:"How do I activate Athena API?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to activate Athena:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"})," ","and sign in to your AWS account."]}),a.jsx("li",{children:"If you haven't used Athena before, you may need to set up a query result location (an S3 bucket)."}),a.jsx("li",{children:"You can start running queries immediately after setup."})]})]})]})})}function rle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-storage-details",children:[a.jsx(Dt,{children:"What is AWS Redshift?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Amazon Redshift is a fast, fully managed cloud data warehouse that makes it simple and cost-effective to analyze data using standard SQL and existing business intelligence tools."}),a.jsx("p",{className:"mb-2",children:"Redshift supports two deployment options:"}),a.jsxs("ul",{className:"mb-2 list-inside list-disc space-y-1 text-sm",children:[a.jsxs("li",{children:[a.jsx("strong",{children:"Redshift Serverless:"})," Automatically scales compute capacity and you only pay for what you use"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Provisioned Clusters:"})," Traditional clusters where you provision and manage compute nodes"]})]}),a.jsxs("p",{className:"text-sm",children:["Learn more in the"," ",a.jsx(Kt,{className:"underline",href:"https://docs.aws.amazon.com/redshift/latest/mgmt/welcome.html",children:"AWS Redshift Documentation"}),"."]})]})]})})}function ale({initialData:e,onSubmit:t,onCancel:n,onDirtyChange:r}){const s=ko({resolver:Ai(mJ),defaultValues:e}),{watch:i,control:c,formState:{isDirty:u,isSubmitting:f}}=s,m=i("type");re.useEffect(()=>{r==null||r(u)},[u,r]);const x=async g=>{const{dirtyFields:y}=s.formState,v=h5(g);return y.credentials||delete v.credentials,t(v)};return a.jsx(Ul,{...s,children:a.jsxs(Ni,{onSubmit:g=>{s.handleSubmit(x)(g)},noValidate:!0,children:[a.jsxs(zl,{children:[a.jsxs(zr,{title:"General",children:[a.jsx(Et,{control:c,name:"title",render:({field:g})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Name the storage to clarify its purpose",children:"Title"}),a.jsx(vt,{children:a.jsx(gt,{...g,placeholder:"Storage title"})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:c,name:"type",render:({field:g})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"The selected source will be used to process data in your Data Marts",children:"Storage Type"}),a.jsx(vt,{children:a.jsxs(sa,{value:g.value,onValueChange:g.onChange,disabled:!!e,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{placeholder:"Select a storage type"})}),a.jsx(la,{children:a.jsx(sy,{children:Nl.getAllTypes().map(({type:y,displayName:v,icon:S,status:C})=>a.jsx(Fn,{value:y,disabled:C===li.COMING_SOON,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(S,{size:20}),v]})},y))})})]})}),a.jsxs(on,{children:[m===xe.GOOGLE_BIGQUERY&&a.jsx(tle,{}),m===xe.AWS_ATHENA&&a.jsx(nle,{}),m===xe.SNOWFLAKE&&a.jsx(ele,{}),m===xe.AWS_REDSHIFT&&a.jsx(rle,{})]}),a.jsx(jt,{})]})})]}),m===xe.GOOGLE_BIGQUERY&&a.jsx(Iie,{form:s}),m===xe.AWS_ATHENA&&a.jsx(Uie,{form:s}),m===xe.SNOWFLAKE&&a.jsx(qie,{form:s}),m===xe.AWS_REDSHIFT&&a.jsx(Jie,{form:s})]}),a.jsxs(Wc,{children:[a.jsx(we,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!u||f,children:"Save"}),a.jsx(we,{variant:"outline",type:"button",onClick:n,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Zc(e){const[t,n]=h.useState(!1),[r,s]=h.useState(!1),i=h.useCallback(()=>{r?n(!0):e()},[r,e]),c=h.useCallback(()=>{n(!1),s(!1),e()},[e]),u=h.useCallback(m=>{s(m)},[]),f=h.useCallback(()=>{s(!1),e()},[e]);return{showUnsavedDialog:t,setShowUnsavedDialog:n,isDirty:r,handleClose:i,confirmClose:c,handleFormDirtyChange:u,handleFormSubmitSuccess:f}}function gM({isOpen:e,onClose:t,dataStorage:n,onSaveSuccess:r}){const{updateDataStorage:s}=iy();Fl(e);const{showUnsavedDialog:i,setShowUnsavedDialog:c,handleClose:u,confirmClose:f,handleFormDirtyChange:m,handleFormSubmitSuccess:x}=Zc(t),g=async v=>{if(n){const S=await s(n.id,v);S&&(r(S),x())}},y=h.useRef(!1);return h.useEffect(()=>{const v=n?"Edit":"Create";e&&!y.current?(De({event:"data_storage_config_open",category:"DataStorage",action:v,label:n==null?void 0:n.type}),y.current=!0):!e&&y.current&&(De({event:"data_storage_config_close",category:"DataStorage",action:v,label:n==null?void 0:n.type}),y.current=!1)},[e,n]),a.jsxs(a.Fragment,{children:[a.jsx(Ei,{open:e,onOpenChange:v=>{v||u()},children:a.jsxs(wi,{children:[a.jsxs(Ri,{children:[a.jsx(ji,{children:"Configure Storage Provider"}),a.jsx(Rl,{children:"Customize settings for your storage provider"})]}),a.jsx(ale,{initialData:n??void 0,onSubmit:g,onCancel:u,onDirtyChange:m})]})}),a.jsx(_r,{open:i,onOpenChange:c,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:f,variant:"destructive"})]})}const sle=({dataStorage:e,onDataStorageChange:t})=>{const[n,r]=h.useState(!1),s=Nl.getInfo(e.type),i=()=>{r(!0)},c=()=>{r(!1)},u=()=>{const f=QO(e);if(De({event:"data_storage_configuration_loaded",category:"DataMart",action:f?"ValidStorage":"InvalidStorage",label:e.type}),!f)return a.jsxs("div",{className:"flex items-center space-x-2 text-sm",children:[a.jsx(Oh,{className:"h-4 w-4 text-red-500"}),a.jsx("span",{className:"text-red-500",children:"Storage configuration is incomplete"})]});const m=(g,y)=>a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[g,":"]})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:y})]}),x=(g,y,v)=>a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[g,":"]})," ",a.jsx(Kt,{href:v,onClick:S=>{S.stopPropagation()},children:y})]});switch(e.type){case xe.GOOGLE_BIGQUERY:{const g=e.config.projectId,y=e.config.location,v=`https://console.cloud.google.com/bigquery?project=${g}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x("Project ID",g,v),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Location",y)]})}case xe.AWS_ATHENA:{const g=e.config.region,y=e.config.outputBucket,v=`https://s3.console.aws.amazon.com/s3/buckets/${y}?region=${g}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[m("Region",g),a.jsx("span",{className:"text-muted-foreground",children:"•"}),x("Bucket",y,v)]})}case xe.SNOWFLAKE:{const g=e.config.account,y=e.config.warehouse;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x("Account",g,"https://app.snowflake.com/"),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Warehouse",y)]})}case xe.AWS_REDSHIFT:{const g=e.config,y=g.region,v=g.database;let S,C;g.connectionType===dr.SERVERLESS?(S=g.workgroupName,C="Workgroup"):(S=g.clusterIdentifier,C="Cluster");const E=`https://${y}.console.aws.amazon.com/redshiftv2/home?region=${y}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[m("Region",y),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Database",v),a.jsx("span",{className:"text-muted-foreground",children:"•"}),x(C,S,E)]})}default:return"Unknown storage type configuration"}};return a.jsxs(a.Fragment,{children:[a.jsx(mS,{title:e.title,icon:s.icon,subtitle:u(),onClick:i}),a.jsx(xE,{children:a.jsx(gM,{isOpen:n,onClose:c,dataStorage:e,onSaveSuccess:f=>{t&&t(f)}})})]})};function ole({initialType:e,onTypeSelect:t}){var c;const[n,r]=h.useState(e??null);h.useEffect(()=>{e!==void 0&&e!==n&&r(e)},[e,n]);const s=u=>{r(u),t(u)},i=[{type:$e.SQL,label:"SQL",description:"SQL query"},{type:$e.TABLE,label:"Table",description:"Existing table"},{type:$e.VIEW,label:"View",description:"Existing view"},{type:$e.TABLE_PATTERN,label:"Pattern",description:"Table pattern"},{type:$e.CONNECTOR,label:"Connector",description:"Data import from Source to Storage"}];return a.jsxs("div",{className:"dm-card-block",children:[a.jsx(Ma,{className:"text-foreground",children:"Definition Type"}),a.jsxs(sa,{value:n??"",onValueChange:u=>{s(u)},children:[a.jsx(ia,{className:"dm-card-formcontrol w-full","aria-label":"Definition Type",children:a.jsx(oa,{placeholder:"Select definition type",children:n&&((c=i.find(u=>u.type===n))==null?void 0:c.label)})}),a.jsx(la,{children:a.jsx(sy,{children:i.map(u=>a.jsxs(Fn,{value:u.type,children:[u.label,a.jsx("span",{className:"text-muted-foreground/80 ml-2",children:u.description})]},u.type))})})]})]})}const ile=ln({definitionType:Sr($e.SQL),definition:ln({sqlQuery:St().min(1,"SQL query is required")})}),lle=e=>{const t=E5(e);return ln({definitionType:Sr($e.TABLE),definition:t})},cle=e=>{const t=E5(e);return ln({definitionType:Sr($e.VIEW),definition:t})},ule=e=>{const t=Aee(e);return ln({definitionType:Sr($e.TABLE_PATTERN),definition:t})},dle=ln({definitionType:Sr($e.CONNECTOR),definition:ln({connector:ln({source:ln({name:St().min(1,"Connector name is required"),configuration:zb(mY(fY())).min(1,"At least one configuration is required"),node:St().min(1,"Node is required"),fields:zb(St()).min(1,"At least one field is required")}),storage:ln({fullyQualifiedName:St().min(1,"fully qualified name is required")})})})}),fle=(e,t)=>{if(!e)return ln({definitionType:pY(Fx($e)),definition:ln({}).optional()});switch(e){case $e.SQL:return ile;case $e.TABLE:return lle(t);case $e.VIEW:return cle(t);case $e.TABLE_PATTERN:return ule(t);case $e.CONNECTOR:return dle;default:return ln({})}};function hle({control:e}){return a.jsx(Et,{control:e,name:"definition.sqlQuery",render:({field:t})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{className:"text-foreground",children:"SQL Query"}),a.jsx(vt,{children:a.jsx(zoe,{initialValue:t.value?{sqlQuery:t.value}:void 0,onChange:n=>{t.onChange(n.sqlQuery)}})}),a.jsx(jt,{})]})})}function mle({control:e,storageType:t}){const n=a5(t),r=s5(t);return a.jsx(Et,{control:e,name:"definition.fullyQualifiedName",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Fully Qualified Table Name"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}function ple({control:e,storageType:t}){const n=a5(t),r=s5(t);return a.jsx(Et,{control:e,name:"definition.fullyQualifiedName",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Fully Qualified View Name"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}function gle({control:e,storageType:t}){const n=EJ(t),r=wJ(t);return a.jsx(Et,{control:e,name:"definition.pattern",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Table Pattern"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}const zE=e=>{switch(e){case $e.SQL:return{sqlQuery:""};case $e.TABLE:return{fullyQualifiedName:""};case $e.VIEW:return{fullyQualifiedName:""};case $e.TABLE_PATTERN:return{pattern:""};case $e.CONNECTOR:return{connector:{source:{name:"",configuration:[],node:"",fields:[]},storage:{fullyQualifiedName:""}}};default:return{}}},xle=Pc("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 FE({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:se(xle({variant:t}),e),...n})}function xM({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:se("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function HE({className:e,...t}){return a.jsx("div",{"data-slot":"alert-description",className:se("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}function yle({connectors:e,selectedConnector:t,loading:n,error:r,onConnectorSelect:s,onConnectorDoubleClick:i}){return h.useEffect(()=>{De({event:"connector_setup",category:"connector_selection",action:"step",label:"Choose Connector"})},[]),n?a.jsx(wE,{variant:"grid"}):r?a.jsxs(FE,{variant:"destructive",children:[a.jsx(Nh,{className:"h-4 w-4"}),a.jsx(HE,{children:"Failed to load available connectors. Please try again."})]}):a.jsxs(gi,{children:[a.jsx(ci,{title:"Choose Connector",children:a.jsx(tse,{children:e.map(c=>a.jsx(nse,{icon:c.logoBase64?a.jsx(Vc,{base64:c.logoBase64,size:20}):null,title:c.displayName,selected:(t==null?void 0:t.name)===c.name,onClick:()=>{s(c)},onDoubleClick:()=>{s(c),i==null||i(c)}},c.name))})}),e.length===0&&a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:"No connectors available",subtitle:"Ask your administrator to configure connectors."})]})}function vle({currentStep:e,totalSteps:t,canGoNext:n,canGoBack:r,isLoading:s=!1,onNext:i,onBack:c,onFinish:u,nextLabel:f="Next",backLabel:m="Back",finishLabel:x="Save"}){const g=e===t;return t===1?a.jsx("div",{className:"w-full",children:a.jsx(we,{className:"w-full",variant:"default",onClick:u,disabled:!n||s,children:x})}):a.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:r&&a.jsxs(we,{variant:"outline",onClick:c,disabled:s,children:[a.jsx(c4,{className:"h-4 w-4"}),m]})}),a.jsxs("div",{className:"text-muted-foreground/75 px-4 text-sm",children:["Step ",e," of ",t]}),a.jsx("div",{className:"flex flex-1 justify-end",children:g?a.jsx(we,{variant:"default",onClick:u,disabled:!n||s,children:x}):a.jsxs(we,{variant:"default",onClick:i,disabled:!n||s,children:[f,a.jsx(va,{className:"h-4 w-4"})]})})]})}function vc({connector:e,size:t=24,variant:n="compact"}){return a.jsx(xo,{icon:a.jsx(Vc,{base64:e.logoBase64,size:t}),title:e.displayName,docUrl:e.docUrl,variant:n})}function td({label:e}){return a.jsx("div",{className:"border-border text-muted-foreground mt-3 flex items-center justify-center gap-2 border-t pt-3 text-sm",children:a.jsx(we,{variant:"outline",asChild:!0,children:a.jsxs(Tr,{to:"https://github.com/OWOX/owox-data-marts/issues",target:"_blank",rel:"noopener noreferrer",children:[e," Open issue here",a.jsx(yi,{className:"h-4 w-4"})]})})})}const xS="**********";function ble({specification:e,configuration:t,onValueChange:n}){const{name:r,title:s}=e,i=s??r,c=r;return a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(gt,{type:"checkbox",id:c,name:r,checked:t[r]||!1,onChange:u=>{n(r,u.target.checked)},className:"text-primary focus:ring-primary border-border h-4 w-4 rounded"}),a.jsx(Ma,{htmlFor:c,className:"cursor-pointer text-sm",children:a.jsx(fa,{htmlFor:c,required:e.required,tooltip:e.description,children:i})})]})}function Sle({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s}=e,i=e.title??e.name;return a.jsx(gt,{id:r,name:r,type:"number",value:t[r]||"",placeholder:s??`Enter ${i.toLowerCase()}`,onChange:c=>{const u=c.target.value,f=u===""?void 0:parseFloat(u);n(r,f)}})}function Cle({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s,default:i}=e,c=e.title??e.name;return a.jsx(Io,{id:r,name:r,value:Array.isArray(t[r])?t[r].join(`
830
+ -----END PRIVATE KEY-----`,rows:6})}),a.jsx(on,{children:a.jsx(Gie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.privateKeyPassphrase",render:({field:c})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the passphrase if your private key is encrypted",children:"Passphrase (Optional)"}),a.jsx(vt,{children:a.jsx(gt,{...c,type:"password",value:c.value??"",placeholder:"Enter passphrase if key is encrypted"})}),a.jsx(on,{children:a.jsx(Bie,{})}),a.jsx(jt,{})]})})]})]})]})};function Kie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-region-details",children:[a.jsx(Dt,{children:"What is the AWS region?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The AWS region is the geographic location where your Redshift cluster or Serverless workgroup is hosted."}),a.jsx("p",{className:"mb-2",children:"Common examples:"}),a.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"us-east-1"})," - US East (N. Virginia)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"us-west-2"})," - US West (Oregon)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"eu-west-1"})," - Europe (Ireland)"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"ap-southeast-1"})," - Asia Pacific (Singapore)"]})]}),a.jsxs("p",{className:"mt-2 text-sm",children:["You can find your region in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshift/",children:"AWS Redshift Console"}),"."]})]})]})})}function Wie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-workgroup-details",children:[a.jsx(Dt,{children:"What is a Redshift Serverless workgroup?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["A workgroup is a collection of compute resources in Redshift Serverless. Use this field if you're using ",a.jsx("strong",{children:"Redshift Serverless"}),"."]}),a.jsxs("p",{className:"mb-2",children:["You can find your workgroup name in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshiftv2/home#serverless-dashboard",children:"Redshift Serverless Console"}),"."]}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Note:"})," You must provide either a workgroup name (for Serverless) OR a cluster identifier (for provisioned clusters), but not both."]})]})]})})}function Zie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-cluster-details",children:[a.jsx(Dt,{children:"What is a cluster identifier?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["A cluster identifier is the unique name of your"," ",a.jsx("strong",{children:"provisioned Redshift cluster"}),". Use this field if you're using a traditional Redshift cluster (not Serverless)."]}),a.jsxs("p",{className:"mb-2",children:["You can find your cluster identifier in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/redshiftv2/home#clusters",children:"Redshift Clusters Console"}),"."]}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Note:"})," You must provide either a cluster identifier (for provisioned clusters) OR a workgroup name (for Serverless), but not both."]})]})]})})}function Yie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-database-details",children:[a.jsx(Dt,{children:"What is the database name?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The database name is the name of the database you want to connect to within your Redshift cluster or workgroup."}),a.jsxs("p",{className:"mb-2",children:["Every Redshift cluster/workgroup has at least one database. The default database is often named ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"dev"}),", but you may have created custom databases."]}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"This field is required for all authentication methods."})]})]})})}function Xie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-access-key-details",children:[a.jsx(Dt,{children:"What is an AWS Access Key ID?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The Access Key ID is part of your AWS security credentials. It's used together with the Secret Access Key to authenticate AWS API requests."}),a.jsxs("p",{className:"mb-2",children:["Access keys are typically 20 characters long and start with"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"AKIA"})," or"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"ASIA"})," (for temporary credentials)."]}),a.jsxs("p",{className:"text-sm",children:["You can create access keys in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/home#/security_credentials",children:"AWS IAM Console"}),"."]})]})]})})}function Qie(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-secret-key-details",children:[a.jsx(Dt,{children:"What is an AWS Secret Access Key?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"The Secret Access Key is the private part of your AWS security credentials. It's used together with the Access Key ID to sign and authenticate AWS API requests."}),a.jsx("p",{className:"mb-2",children:"Secret Access Keys are typically 40 characters long and are only shown once when created. If you lose it, you'll need to create a new access key pair."}),a.jsxs("p",{className:"text-muted-foreground text-sm",children:[a.jsx("strong",{children:"Security warning:"})," Keep your secret access key secure and never share it publicly. It will be stored encrypted."]})]})]})})}const Jie=({form:e})=>{const[t,n]=h.useState("");return h.useEffect(()=>{const r=e.getValues("config.connectionType"),s=e.watch("type");r===void 0&&s===xe.AWS_REDSHIFT&&e.setValue("config.connectionType",dr.SERVERLESS,{shouldDirty:!1})},[e]),h.useEffect(()=>{const r=e.getValues("credentials.accessKeyId");if(r){const s="_".repeat(r.length);n(s),e.setValue("credentials.secretAccessKey",s,{shouldDirty:!1})}},[e]),e.watch("type")!==xe.AWS_REDSHIFT?null:a.jsxs(a.Fragment,{children:[a.jsxs(zr,{title:"Connection Settings",children:[a.jsx(Et,{control:e.control,name:"config.region",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Enter the AWS region where your Redshift service is active",children:"Region"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter a region"})}),a.jsx(on,{children:a.jsx(Kie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.database",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"The database name to connect to",children:"Database"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter database name"})}),a.jsx(on,{children:a.jsx(Yie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"config.connectionType",render:({field:r})=>{const s=r.value??dr.SERVERLESS;return a.jsxs(yt,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(pt,{tooltip:s===dr.SERVERLESS?"Workgroup name for Redshift Serverless":"Cluster identifier for provisioned Redshift cluster",children:s===dr.SERVERLESS?"Workgroup Name":"Cluster Identifier"}),a.jsx(cy,{value:s,onValueChange:r.onChange,children:a.jsxs(uy,{children:[a.jsx(Oc,{value:dr.SERVERLESS,children:"Serverless"}),a.jsx(Oc,{value:dr.PROVISIONED,children:"Provisioned"})]})})]}),a.jsx(vt,{children:s===dr.SERVERLESS?a.jsx(gt,{...e.register("config.workgroupName"),placeholder:"Enter workgroup name"}):a.jsx(gt,{...e.register("config.clusterIdentifier"),placeholder:"Enter cluster identifier"})}),a.jsx(on,{children:s===dr.SERVERLESS?a.jsx(Wie,{}):a.jsx(Zie,{})}),a.jsx(jt,{})]})}})]}),a.jsxs(zr,{title:"Authentication",children:[a.jsx(Et,{control:e.control,name:"credentials.accessKeyId",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Access Key ID used for authentication",children:"Access Key ID"}),a.jsx(vt,{children:a.jsx(gt,{...r,placeholder:"Enter an access key id"})}),a.jsx(on,{children:a.jsx(Xie,{})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:e.control,name:"credentials.secretAccessKey",render:({field:r})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Your AWS Secret Access Key used for authentication",children:"Secret Access Key"}),a.jsx(vt,{children:a.jsx(gt,{...r,type:"password",placeholder:t||"Enter a secret access key"})}),a.jsx(on,{children:a.jsx(Qie,{})}),a.jsx(jt,{})]})})]})]})},ele=()=>a.jsx(a.Fragment,{children:a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,className:"mt-2",children:a.jsxs(At,{value:"snowflake-setup",children:[a.jsx(Dt,{children:"How do I get started with Snowflake?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"To use Snowflake as your storage provider, you'll need an active Snowflake account with appropriate permissions."}),a.jsx("p",{className:"mb-2",children:"Here's how to get started:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Sign up for a"," ",a.jsx(Kt,{className:"underline",href:"https://signup.snowflake.com/",children:"Snowflake account"})," ","if you don't have one yet."]}),a.jsx("li",{children:"Make sure you have the necessary privileges to create and access databases, schemas, and warehouses."}),a.jsx("li",{children:"Choose your authentication method: Username & Password for quick setup, or Key-Pair authentication for production environments."}),a.jsx("li",{children:"Fill in the connection details below (account identifier and warehouse)."}),a.jsx("li",{children:"You can access tables using the full path format: database.schema.table (similar to BigQuery and Athena)."})]})]})]})})});function tle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"bigquery-api-details",children:[a.jsx(Dt,{children:"How do I enable the BigQuery API?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:["To run queries and process data in Google BigQuery, you need to enable the"," ",a.jsx(Kt,{className:"underline",href:"https://console.cloud.google.com/apis/library/bigquery.googleapis.com",children:"BigQuery API"})," ","in your Google Cloud project."]}),a.jsx("p",{className:"mb-2",children:"Here's how to do it:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsx("li",{children:"Open the link above and make sure the correct project is selected."}),a.jsxs("li",{children:["If the API isn't enabled yet, click ",a.jsx("strong",{children:"Enable"}),"."]}),a.jsx("li",{children:"If it's already enabled, you'll see the API dashboard — that's fine."})]})]})]})})}function nle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"athena-api-details",children:[a.jsx(Dt,{children:"How do I activate Athena API?"}),a.jsxs(Ot,{children:[a.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."}),a.jsx("p",{className:"mb-2",children:"Here's how to activate Athena:"}),a.jsxs("ol",{className:"list-inside list-decimal space-y-2 text-sm",children:[a.jsxs("li",{children:["Open"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/athena/",children:"the AWS Athena console"})," ","and sign in to your AWS account."]}),a.jsx("li",{children:"If you haven't used Athena before, you may need to set up a query result location (an S3 bucket)."}),a.jsx("li",{children:"You can start running queries immediately after setup."})]})]})]})})}function rle(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"redshift-storage-details",children:[a.jsx(Dt,{children:"What is AWS Redshift?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"Amazon Redshift is a fast, fully managed cloud data warehouse that makes it simple and cost-effective to analyze data using standard SQL and existing business intelligence tools."}),a.jsx("p",{className:"mb-2",children:"Redshift supports two deployment options:"}),a.jsxs("ul",{className:"mb-2 list-inside list-disc space-y-1 text-sm",children:[a.jsxs("li",{children:[a.jsx("strong",{children:"Redshift Serverless:"})," Automatically scales compute capacity and you only pay for what you use"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Provisioned Clusters:"})," Traditional clusters where you provision and manage compute nodes"]})]}),a.jsxs("p",{className:"text-sm",children:["Learn more in the"," ",a.jsx(Kt,{className:"underline",href:"https://docs.aws.amazon.com/redshift/latest/mgmt/welcome.html",children:"AWS Redshift Documentation"}),"."]})]})]})})}function ale({initialData:e,onSubmit:t,onCancel:n,onDirtyChange:r}){const s=ko({resolver:Ai(mJ),defaultValues:e}),{watch:i,control:c,formState:{isDirty:u,isSubmitting:f}}=s,m=i("type");re.useEffect(()=>{r==null||r(u)},[u,r]);const x=async g=>{const{dirtyFields:y}=s.formState,v=h5(g);return y.credentials||delete v.credentials,t(v)};return a.jsx(Ul,{...s,children:a.jsxs(Ni,{onSubmit:g=>{s.handleSubmit(x)(g)},noValidate:!0,children:[a.jsxs(zl,{children:[a.jsxs(zr,{title:"General",children:[a.jsx(Et,{control:c,name:"title",render:({field:g})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Name the storage to clarify its purpose",children:"Title"}),a.jsx(vt,{children:a.jsx(gt,{...g,placeholder:"Storage title"})}),a.jsx(jt,{})]})}),a.jsx(Et,{control:c,name:"type",render:({field:g})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"The selected source will be used to process data in your Data Marts",children:"Storage Type"}),a.jsx(vt,{children:a.jsxs(sa,{value:g.value,onValueChange:g.onChange,disabled:!!e,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{placeholder:"Select a storage type"})}),a.jsx(la,{children:a.jsx(sy,{children:Nl.getAllTypes().map(({type:y,displayName:v,icon:S,status:C})=>a.jsx(Fn,{value:y,disabled:C===li.COMING_SOON,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(S,{size:20}),v]})},y))})})]})}),a.jsxs(on,{children:[m===xe.GOOGLE_BIGQUERY&&a.jsx(tle,{}),m===xe.AWS_ATHENA&&a.jsx(nle,{}),m===xe.SNOWFLAKE&&a.jsx(ele,{}),m===xe.AWS_REDSHIFT&&a.jsx(rle,{})]}),a.jsx(jt,{})]})})]}),m===xe.GOOGLE_BIGQUERY&&a.jsx(Iie,{form:s}),m===xe.AWS_ATHENA&&a.jsx(Uie,{form:s}),m===xe.SNOWFLAKE&&a.jsx(qie,{form:s}),m===xe.AWS_REDSHIFT&&a.jsx(Jie,{form:s})]}),a.jsxs(Wc,{children:[a.jsx(we,{variant:"default",type:"submit",className:"w-full","aria-label":"Save",disabled:!u||f,children:"Save"}),a.jsx(we,{variant:"outline",type:"button",onClick:n,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function Zc(e){const[t,n]=h.useState(!1),[r,s]=h.useState(!1),i=h.useCallback(()=>{r?n(!0):e()},[r,e]),c=h.useCallback(()=>{n(!1),s(!1),e()},[e]),u=h.useCallback(m=>{s(m)},[]),f=h.useCallback(()=>{s(!1),e()},[e]);return{showUnsavedDialog:t,setShowUnsavedDialog:n,isDirty:r,handleClose:i,confirmClose:c,handleFormDirtyChange:u,handleFormSubmitSuccess:f}}function gM({isOpen:e,onClose:t,dataStorage:n,onSaveSuccess:r}){const{updateDataStorage:s}=iy();Fl(e);const{showUnsavedDialog:i,setShowUnsavedDialog:c,handleClose:u,confirmClose:f,handleFormDirtyChange:m,handleFormSubmitSuccess:x}=Zc(t),g=async v=>{if(n){const S=await s(n.id,v);S&&(r(S),x())}},y=h.useRef(!1);return h.useEffect(()=>{const v=n?"Edit":"Create";e&&!y.current?(De({event:"data_storage_config_open",category:"DataStorage",action:v,label:n==null?void 0:n.type}),y.current=!0):!e&&y.current&&(De({event:"data_storage_config_close",category:"DataStorage",action:v,label:n==null?void 0:n.type}),y.current=!1)},[e,n]),a.jsxs(a.Fragment,{children:[a.jsx(Ei,{open:e,onOpenChange:v=>{v||u()},children:a.jsxs(wi,{children:[a.jsxs(Ri,{children:[a.jsx(ji,{children:"Configure Storage Provider"}),a.jsx(Rl,{children:"Customize settings for your storage provider"})]}),a.jsx(ale,{initialData:n??void 0,onSubmit:g,onCancel:u,onDirtyChange:m})]})}),a.jsx(_r,{open:i,onOpenChange:c,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:f,variant:"destructive"})]})}const sle=({dataStorage:e,onDataStorageChange:t})=>{const[n,r]=h.useState(!1),s=Nl.getInfo(e.type),i=()=>{r(!0)},c=()=>{r(!1)},u=()=>{const f=QO(e);if(De({event:"data_storage_configuration_loaded",category:"DataMart",action:f?"ValidStorage":"InvalidStorage",label:e.type}),!f)return a.jsxs("div",{className:"flex items-center space-x-2 text-sm",children:[a.jsx(Oh,{className:"h-4 w-4 text-red-500"}),a.jsx("span",{className:"text-red-500",children:"Storage configuration is incomplete"})]});const m=(g,y)=>a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[g,":"]})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:y})]}),x=(g,y,v)=>a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[g,":"]})," ",a.jsx(Kt,{href:v,onClick:S=>{S.stopPropagation()},children:y})]});switch(e.type){case xe.GOOGLE_BIGQUERY:{const g=e.config.projectId,y=e.config.location,v=`https://console.cloud.google.com/bigquery?project=${g}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x("Project ID",g,v),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Location",y)]})}case xe.AWS_ATHENA:{const g=e.config.region,y=e.config.outputBucket,v=`https://s3.console.aws.amazon.com/s3/buckets/${y}?region=${g}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[m("Region",g),a.jsx("span",{className:"text-muted-foreground",children:"•"}),x("Bucket",y,v)]})}case xe.SNOWFLAKE:{const g=e.config.account,y=e.config.warehouse;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x("Account",g,"https://app.snowflake.com/"),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Warehouse",y)]})}case xe.AWS_REDSHIFT:{const g=e.config,y=g.region,v=g.database;let S,C;g.connectionType===dr.SERVERLESS?(S=g.workgroupName,C="Workgroup"):(S=g.clusterIdentifier,C="Cluster");const E=`https://${y}.console.aws.amazon.com/redshiftv2/home?region=${y}`;return a.jsxs("div",{className:"flex flex-wrap gap-2",children:[m("Region",y),a.jsx("span",{className:"text-muted-foreground",children:"•"}),m("Database",v),a.jsx("span",{className:"text-muted-foreground",children:"•"}),x(C,S,E)]})}default:return"Unknown storage type configuration"}};return a.jsxs(a.Fragment,{children:[a.jsx(mS,{title:e.title,icon:s.icon,subtitle:u(),onClick:i}),a.jsx(xE,{children:a.jsx(gM,{isOpen:n,onClose:c,dataStorage:e,onSaveSuccess:f=>{t&&t(f)}})})]})};function ole({initialType:e,onTypeSelect:t}){var c;const[n,r]=h.useState(e??null);h.useEffect(()=>{e!==void 0&&e!==n&&r(e)},[e,n]);const s=u=>{r(u),t(u)},i=[{type:$e.SQL,label:"SQL",description:"SQL query"},{type:$e.TABLE,label:"Table",description:"Existing table"},{type:$e.VIEW,label:"View",description:"Existing view"},{type:$e.TABLE_PATTERN,label:"Pattern",description:"Table pattern"},{type:$e.CONNECTOR,label:"Connector",description:"Data import from Source to Storage"}];return a.jsxs("div",{className:"dm-card-block",children:[a.jsx(Ma,{className:"text-foreground",children:"Definition Type"}),a.jsxs(sa,{value:n??"",onValueChange:u=>{s(u)},children:[a.jsx(ia,{className:"dm-card-formcontrol w-full","aria-label":"Definition Type",children:a.jsx(oa,{placeholder:"Select definition type",children:n&&((c=i.find(u=>u.type===n))==null?void 0:c.label)})}),a.jsx(la,{children:a.jsx(sy,{children:i.map(u=>a.jsxs(Fn,{value:u.type,children:[u.label,a.jsx("span",{className:"text-muted-foreground/80 ml-2",children:u.description})]},u.type))})})]})]})}const ile=ln({definitionType:Sr($e.SQL),definition:ln({sqlQuery:St().min(1,"SQL query is required")})}),lle=e=>{const t=E5(e);return ln({definitionType:Sr($e.TABLE),definition:t})},cle=e=>{const t=E5(e);return ln({definitionType:Sr($e.VIEW),definition:t})},ule=e=>{const t=Aee(e);return ln({definitionType:Sr($e.TABLE_PATTERN),definition:t})},dle=ln({definitionType:Sr($e.CONNECTOR),definition:ln({connector:ln({source:ln({name:St().min(1,"Connector name is required"),configuration:zb(mY(fY())).min(1,"At least one configuration is required"),node:St().min(1,"Node is required"),fields:zb(St()).min(1,"At least one field is required")}),storage:ln({fullyQualifiedName:St().min(1,"fully qualified name is required")})})})}),fle=(e,t)=>{if(!e)return ln({definitionType:pY(Fx($e)),definition:ln({}).optional()});switch(e){case $e.SQL:return ile;case $e.TABLE:return lle(t);case $e.VIEW:return cle(t);case $e.TABLE_PATTERN:return ule(t);case $e.CONNECTOR:return dle;default:return ln({})}};function hle({control:e}){return a.jsx(Et,{control:e,name:"definition.sqlQuery",render:({field:t})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{className:"text-foreground",children:"SQL Query"}),a.jsx(vt,{children:a.jsx(zoe,{initialValue:t.value?{sqlQuery:t.value}:void 0,onChange:n=>{t.onChange(n.sqlQuery)}})}),a.jsx(jt,{})]})})}function mle({control:e,storageType:t}){const n=a5(t),r=s5(t);return a.jsx(Et,{control:e,name:"definition.fullyQualifiedName",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Fully Qualified Table Name"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}function ple({control:e,storageType:t}){const n=a5(t),r=s5(t);return a.jsx(Et,{control:e,name:"definition.fullyQualifiedName",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Fully Qualified View Name"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}function gle({control:e,storageType:t}){const n=EJ(t),r=wJ(t);return a.jsx(Et,{control:e,name:"definition.pattern",render:({field:s})=>a.jsxs(yt,{className:"dm-card-block",children:[a.jsx(pt,{children:"Table Pattern"}),a.jsx(vt,{children:a.jsx(gt,{placeholder:n,value:s.value,onChange:s.onChange,className:"dm-card-formcontrol"})}),a.jsx(on,{className:"text-muted-foreground/75",children:r}),a.jsx(jt,{})]})})}const zE=e=>{switch(e){case $e.SQL:return{sqlQuery:""};case $e.TABLE:return{fullyQualifiedName:""};case $e.VIEW:return{fullyQualifiedName:""};case $e.TABLE_PATTERN:return{pattern:""};case $e.CONNECTOR:return{connector:{source:{name:"",configuration:[],node:"",fields:[]},storage:{fullyQualifiedName:""}}};default:return{}}},xle=Pc("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 FE({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:se(xle({variant:t}),e),...n})}function xM({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:se("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function HE({className:e,...t}){return a.jsx("div",{"data-slot":"alert-description",className:se("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}function yle({connectors:e,selectedConnector:t,loading:n,error:r,onConnectorSelect:s,onConnectorDoubleClick:i}){return h.useEffect(()=>{De({event:"connector_setup",category:"connector_selection",action:"step",label:"Choose Connector"})},[]),n?a.jsx(wE,{variant:"grid"}):r?a.jsxs(FE,{variant:"destructive",children:[a.jsx(Nh,{className:"h-4 w-4"}),a.jsx(HE,{children:"Failed to load available connectors. Please try again."})]}):a.jsxs(gi,{children:[a.jsx(ci,{title:"Choose Connector",children:a.jsx(tse,{children:e.map(c=>a.jsx(nse,{icon:c.logoBase64?a.jsx(Vc,{base64:c.logoBase64,size:20}):null,title:c.displayName,selected:(t==null?void 0:t.name)===c.name,onClick:()=>{s(c)},onDoubleClick:()=>{s(c),i==null||i(c)}},c.name))})}),e.length===0&&a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:"No connectors available",subtitle:"Ask your administrator to configure connectors."})]})}function vle({currentStep:e,totalSteps:t,canGoNext:n,canGoBack:r,isLoading:s=!1,onNext:i,onBack:c,onFinish:u,nextLabel:f="Next",backLabel:m="Back",finishLabel:x="Save"}){const g=e===t;return t===1?a.jsx("div",{className:"w-full",children:a.jsx(we,{className:"w-full",variant:"default",onClick:u,disabled:!n||s,children:x})}):a.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:r&&a.jsxs(we,{variant:"outline",onClick:c,disabled:s,children:[a.jsx(c4,{className:"h-4 w-4"}),m]})}),a.jsxs("div",{className:"text-muted-foreground/75 px-4 text-sm",children:["Step ",e," of ",t]}),a.jsx("div",{className:"flex flex-1 justify-end",children:g?a.jsx(we,{variant:"default",onClick:u,disabled:!n||s,children:x}):a.jsxs(we,{variant:"default",onClick:i,disabled:!n||s,children:[f,a.jsx(va,{className:"h-4 w-4"})]})})]})}function vc({connector:e,size:t=24,variant:n="compact"}){return a.jsx(xo,{icon:a.jsx(Vc,{base64:e.logoBase64,size:t}),title:e.displayName,docUrl:e.docUrl,variant:n})}function td({label:e}){return a.jsx("div",{className:"border-border text-muted-foreground mt-3 flex items-center justify-center gap-2 border-t pt-3 text-sm",children:a.jsx(we,{variant:"outline",asChild:!0,children:a.jsxs(Tr,{to:"https://github.com/OWOX/owox-data-marts/issues",target:"_blank",rel:"noopener noreferrer",children:[e," Open issue here",a.jsx(yi,{className:"h-4 w-4"})]})})})}const xS="**********";function ble({specification:e,configuration:t,onValueChange:n}){const{name:r,title:s}=e,i=s??r,c=r;return a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx(gt,{type:"checkbox",id:c,name:r,checked:t[r]||!1,onChange:u=>{n(r,u.target.checked)},className:"text-primary focus:ring-primary border-border h-4 w-4 rounded"}),a.jsx(Ma,{htmlFor:c,className:"cursor-pointer text-sm",children:a.jsx(fa,{htmlFor:c,required:e.required,tooltip:e.description,children:i})})]})}function Sle({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s}=e,i=e.title??e.name;return a.jsx(gt,{id:r,name:r,type:"number",value:t[r]||"",placeholder:s??`Enter ${i.toLowerCase()}`,onChange:c=>{const u=c.target.value,f=u===""?void 0:parseFloat(u);n(r,f)}})}function Cle({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s,default:i}=e,c=e.title??e.name;return a.jsx(Io,{id:r,name:r,value:Array.isArray(t[r])?t[r].join(`
831
831
  `):Array.isArray(i)?i.join(`
832
832
  `):"",placeholder:s??`Enter ${c.toLowerCase()} (one per line)`,rows:4,onChange:u=>{const f=u.target.value.split(`
833
833
  `).filter(m=>m.trim());n(r,f)}})}function Ele({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s,default:i}=e,c=e.title??e.name,u=f=>{if(!f||typeof f!="string"&&typeof f!="number")return"";const m=typeof f=="string"?f:f.toString();try{const x=new Date(m);return isNaN(x.getTime())?"":x.toISOString().split("T")[0]}catch{return""}};return a.jsx(gt,{id:r,name:r,type:"date",value:t[r]||u(i)||"",placeholder:s??`Enter ${c.toLowerCase()}`,onChange:f=>{n(r,f.target.value)}})}function wle({specification:e,configuration:t,onValueChange:n}){const{name:r,placeholder:s}=e,i=e.title??e.name;return a.jsx(gt,{id:r,name:r,type:"text",value:t[r]||"",placeholder:s??`Enter ${i.toLowerCase()}`,onChange:c=>{n(r,c.target.value)}})}function Rle({specification:e,configuration:t,onValueChange:n}){const r=e.title??e.name,{name:s,placeholder:i,default:c}=e;return a.jsx(Io,{id:s,name:s,value:t[s]&&typeof t[s]=="object"?JSON.stringify(t[s],null,2):typeof c=="object"?JSON.stringify(c,null,2):"",placeholder:i??`Enter ${r.toLowerCase()} as JSON`,rows:6,className:"font-mono",onChange:u=>{try{const f=JSON.parse(u.target.value);n(s,f)}catch{n(s,u.target.value)}}})}function jle({specification:e,configuration:t,onValueChange:n,isEditingExisting:r,isSecretEditing:s}){const i=e.title??e.name,c=r&&!s;return a.jsx(gt,{id:e.name,...c?{}:{name:e.name},type:c?"password":"text",autoComplete:c?"new-password":"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:c?xS:t[e.name]||"",...c?{readOnly:!0,disabled:!0}:{},...c?{}:{placeholder:e.placeholder??`Enter ${i.toLowerCase()}`},...c?{}:{onChange:u=>{n(e.name,u.target.value)}}})}function Tle({specification:e,configuration:t,onValueChange:n,specOptions:r}){const{name:s,placeholder:i,default:c}=e,u=e.title??e.name,f=r.map(m=>({value:m,label:m}));return a.jsx(UE,{options:f,value:t[s]||c||"",onValueChange:m=>{n(s,m)},placeholder:i??`Select ${u.toLowerCase()}`,emptyMessage:"No options available",className:"w-full"})}function _le(){const e=h.useRef(new Zf),t=h.useCallback(async(s,i,c)=>await e.current.exchangeCredentials(s,{fieldPath:c,payload:i}),[]),n=h.useCallback(async(s,i)=>{try{return await e.current.checkOAuthStatus(s,i)}catch{return{valid:!1}}},[]),r=h.useCallback(async(s,i)=>await e.current.getOAuthSettings(s,i),[]);return{exchangeCredentials:t,checkStatus:n,getSettings:r}}let kf=null;function Nle({appId:e,scope:t,onSuccess:n,onError:r,disabled:s=!1,children:i}){const[c,u]=h.useState(!1),[f,m]=h.useState(!1),[x,g]=h.useState(null);h.useEffect(()=>{if(window.FB){m(!0);return}if(document.getElementById("facebook-jssdk")){const E=setInterval(()=>{window.FB&&(m(!0),clearInterval(E))},100);return()=>{clearInterval(E)}}if(!e)return;if(kf&&kf!==e){console.warn("Facebook SDK already initialized with different appId");return}kf??(kf=e),window.fbAsyncInit=function(){window.FB&&kf&&(window.FB.init({appId:kf,cookie:!0,xfbml:!0,version:"v23.0"}),m(!0))};const C=document.createElement("script");C.id="facebook-jssdk",C.src="https://connect.facebook.net/en_US/sdk.js",C.async=!0,C.defer=!0,C.crossOrigin="anonymous",document.body.appendChild(C)},[e]);const y=()=>{if(!window.FB||!f){const C=new Error("Facebook SDK not loaded or not ready");g(C.message),r==null||r(C);return}u(!0),g(null),window.FB.login(C=>{var E;if(C.status==="connected"&&C.authResponse){const{accessToken:j,expiresIn:R,userID:T}=C.authResponse;(E=window.FB)==null||E.api("/me?fields=name,email",N=>{const D={accessToken:j,expiresIn:R,userID:T,userName:N.name,userEmail:N.email};n(D),u(!1)})}else{const j=new Error("User cancelled login or did not fully authorize");g(j.message),r==null||r(j),u(!1)}},{scope:t})},v=s||c||!f,S=()=>c?"Connecting...":i||(f?"Continue with Facebook":"Loading...");return a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs(we,{type:"button",onClick:y,disabled:v,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:[a.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.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"})}),S()]}),x&&a.jsx("div",{className:"mt-1 text-xs text-red-600",children:x})]})}function Ale({isLoading:e,status:t,settings:n,onOAuthSuccess:r}){const s=i=>{r({accessToken:i.accessToken})};return a.jsx("div",{className:"mt-2 mb-2",children:a.jsx(Nle,{appId:n==null?void 0:n.vars.AppId,scope:n==null?void 0:n.vars.Scopes,onSuccess:s,disabled:e,children:t!=null&&t.user?a.jsxs(a.Fragment,{children:["Authenticated as ",a.jsx("strong",{children:t.user.name??t.user.id})]}):"Continue with Facebook"})})}function yM({specification:e,option:t,configuration:n,onValueChange:r,connectorName:s,onSecretEditToggle:i,secretEditing:c={},isEditingExisting:u=!1}){const[f,m]=h.useState(!1),[x,g]=h.useState(null),[y,v]=h.useState(null),[S,C]=h.useState(null),E=h.useMemo(()=>{const K=n[e.name],q=t!=null&&t.value&&K?K[t.value]:K;return q==null?void 0:q._source_credential_id},[n,e.name,t==null?void 0:t.value]),j=h.useMemo(()=>t?`${e.name}.${t.value}`:e.name,[e.name,t]),R=h.useMemo(()=>{const K=n[e.name];if(t!=null&&t.value&&K){const q=K[t.value];return q&&typeof q=="object"&&!Array.isArray(q)?q:{}}return K&&typeof K=="object"&&!Array.isArray(K)?K:{}},[n,e.name,t==null?void 0:t.value]),T=h.useMemo(()=>{const K=R;return"_source_credential_id"in K?!1:!!(t!=null&&t.items&&Object.keys(t.items).some(F=>F in K&&K[F]!==void 0&&K[F]!==""))},[R,t]),[N,D]=h.useState(T);h.useEffect(()=>{const K="_source_credential_id"in R,q=(t==null?void 0:t.items)&&Object.keys(t.items).some(F=>F in R&&R[F]!==void 0&&R[F]!=="");K&&N?D(!1):q&&!N&&D(!0)},[R,t,N]);const O=(K,q)=>{if(!(t!=null&&t.value))return;const F=n[e.name]&&typeof n[e.name]=="object"?n[e.name]:{};r(e.name,{...F,[t.value]:{...typeof F[t.value]=="object"&&F[t.value]!==null?F[t.value]:{},[K]:q}})},{checkStatus:_,getSettings:M,exchangeCredentials:$}=_le(),L=async K=>{try{m(!0),C(null);const q=await $(s,K,j),F=n[e.name];t?r(e.name,{...F,[t.value]:{_source_credential_id:q.credentialId}}):r(e.name,{_source_credential_id:q.credentialId})}catch(q){const F=q instanceof Error?q.message:"Failed to exchange OAuth credentials";console.error("Failed to exchange OAuth credentials:",q),C(F)}finally{m(!1)}};h.useEffect(()=>{if(!E){g(null),m(!1);return}let K=!1;return(async()=>{try{m(!0);const F=await _(s,E);K||g(F)}catch(F){K||(console.error("Failed to validate credentials:",F),g({valid:!1}))}finally{K||m(!1)}})(),()=>{K=!0}},[E,s,_]),h.useEffect(()=>{(async()=>{try{const q=await M(s,j);v(q)}catch(q){console.error("Failed to fetch settings:",q),v(null)}})()},[s,j,M]);const k=!!(y!=null&&y.isEnabled);if((N||!k)&&(t!=null&&t.items))return a.jsxs("div",{className:"space-y-4",children:[Object.entries(t.items).map(([K,q])=>{const F=Array.isArray(q.attributes)?q.attributes.includes("SECRET")&&R[K]!==void 0:!1,I=c[e.name]??!1;return a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(fa,{htmlFor:K,required:q.required,tooltip:q.description,className:"mb-2 justify-start",children:q.title??K}),F&&u&&i&&a.jsx(we,{variant:"ghost",size:"sm",type:"button",onClick:()=>{i(e.name,!I)},children:I?"Cancel":"Edit"})]}),$E({specification:{...q,name:K},configuration:R,onValueChange:(G,H)=>{O(G,H)},flags:{isEditingExisting:u,isSecret:F,isSecretEditing:I},connectorName:s})]},K)}),k&&a.jsx(we,{variant:"link",size:"sm",type:"button",onClick:()=>{r(e.name,{[t.value]:{}}),D(!1),m(!1)},className:"px-0",children:"Back to OAuth"})]});const B=(()=>{switch(s){case"FacebookMarketing":return a.jsx(Ale,{isLoading:f,status:x,settings:y,onOAuthSuccess:L});default:return null}})();return a.jsxs("div",{className:"space-y-3",children:[B,S&&a.jsx("div",{className:"text-destructive text-sm",children:S}),(t==null?void 0:t.items)&&Object.keys(t.items).length>0&&a.jsx(we,{variant:"link",size:"sm",type:"button",onClick:()=>{r(e.name,{[t.value]:{}}),D(!0)},className:"px-0",children:"Manually"})]})}function $E({specification:e,configuration:t,onValueChange:n,flags:r,connectorName:s}){const{requiredType:i,options:c}=e,{isSecret:u=!1,isEditingExisting:f=!1,isSecretEditing:m=!1}=r??{};if(e.attributes&&Array.isArray(e.attributes)&&e.attributes.includes("OAUTH_FLOW"))return a.jsx(yM,{specification:e,configuration:t,onValueChange:n,connectorName:s});if(u)return a.jsx(jle,{specification:e,configuration:t,onValueChange:n,isEditingExisting:f,isSecretEditing:m});if(c&&c.length>0)return a.jsx(Tle,{specification:e,configuration:t,onValueChange:n,specOptions:c});switch(i){case zs.BOOLEAN:return a.jsx(ble,{specification:e,configuration:t,onValueChange:n});case zs.NUMBER:return a.jsx(Sle,{specification:e,configuration:t,onValueChange:n});case zs.ARRAY:return a.jsx(Cle,{specification:e,configuration:t,onValueChange:n});case zs.OBJECT:return a.jsx(Rle,{specification:e,configuration:t,onValueChange:n});case zs.DATE:return a.jsx(Ele,{specification:e,configuration:t,onValueChange:n});case zs.STRING:default:return a.jsx(wle,{specification:e,configuration:t,onValueChange:n})}}function Dle({specification:e,configuration:t,isEditingExisting:n,isSecretEditing:r,isSecret:s,onValueChange:i,onSecretEditToggle:c,connectorName:u}){return a.jsxs(uo,{children:[e.requiredType!==zs.BOOLEAN&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(fa,{htmlFor:e.name,required:e.required,tooltip:e.description,children:e.title??e.name}),s&&n&&a.jsx(we,{variant:"ghost",size:"sm",type:"button",onClick:()=>{c(e.name,!r)},children:r?"Cancel":"Edit"})]}),$E({specification:e,configuration:t,onValueChange:i,flags:{isSecret:s,isEditingExisting:n,isSecretEditing:r},connectorName:u})]},e.name)}function Ole({specification:e,configuration:t,onValueChange:n,isEditingExisting:r,isSecretEditing:s,onSecretEditToggle:i,connectorName:c}){const u=h.useMemo(()=>{var v,S;const y=t[e.name];if(y&&typeof y=="object"){const C=Object.keys(y);if(C.length>0)return C[0]}return((S=(v=e.oneOf)==null?void 0:v[0])==null?void 0:S.value)??""},[t,e.name,e.oneOf]),[f,m]=h.useState(u);if(h.useEffect(()=>{m(u)},[u]),h.useEffect(()=>{if(f){const y=t[e.name];y&&typeof y=="object"&&f in y||n(e.name,{[f]:{}})}},[f,e.name,t,n]),!e.oneOf)return null;const x=y=>{m(y)},g=(y,v,S)=>{const C=t[e.name]&&typeof t[e.name]=="object"?t[e.name]:{};n(e.name,{[y]:{...typeof C[y]=="object"&&C[y]!==null?C[y]:{},[v]:S}})};return a.jsx(ese,{label:e.title??e.name,options:e.oneOf.map(y=>({value:y.value,label:y.label})),value:f,onValueChange:x,children:e.oneOf.map(y=>{const v=y.attributes&&Array.isArray(y.attributes)&&y.attributes.includes("OAUTH_FLOW");return a.jsx($ae,{value:y.value,children:v?a.jsx(yM,{specification:e,option:y,configuration:t,onValueChange:n,connectorName:c,onSecretEditToggle:i,secretEditing:{[e.name]:s},isEditingExisting:r}):Object.entries(y.items).map(([S,C])=>{const E=t[e.name]&&typeof t[e.name]=="object"?t[e.name]:{},j=Array.isArray(C.attributes)&&Object.keys(E)[0]===y.value?C.attributes.includes("SECRET"):!1,R=typeof t[e.name]=="object"&&t[e.name]!==null?t[e.name]:{},T=typeof R[y.value]=="object"&&R[y.value]!==null?R[y.value]:{};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(fa,{htmlFor:S,required:C.required,tooltip:C.description,className:"mb-2 justify-start",children:S}),j&&r&&a.jsx(we,{variant:"ghost",size:"sm",type:"button",onClick:()=>{i(e.name,!s)},children:s?"Cancel":"Edit"})]}),$E({specification:{...C,name:S},configuration:T,onValueChange:(N,D)=>{g(y.value,N,D)},flags:{isEditingExisting:r,isSecret:j,isSecretEditing:s},connectorName:c})]},S)})},y.value)})},e.name)}function ON(e,t,n,r,s,i,c){return e.map(u=>{const f=Array.isArray(u.attributes)?u.attributes.includes("SECRET"):!1,m=s[u.name];return u.oneOf&&u.requiredType===zs.OBJECT?a.jsx(Ole,{specification:u,configuration:t,onValueChange:n,isEditingExisting:i,isSecretEditing:m,onSecretEditToggle:r,connectorName:c},u.name):a.jsx(Dle,{specification:u,configuration:t,isEditingExisting:i,isSecret:f,isSecretEditing:m,onValueChange:n,onSecretEditToggle:r,connectorName:c},u.name)})}function IN({collapsibleTitle:e,items:t,configuration:n,onValueChange:r,onSecretEditToggle:s,secretEditing:i,isEditingExisting:c,connectorName:u}){return e?a.jsx(R6,{title:e,children:ON(t,n,r,s,i,c,u)}):ON(t,n,r,s,i,c,u)}function Ile({currentConnectorName:e,onCopyConfiguration:t,connectorSpecification:n}){const[r,s]=h.useState([]),[i,c]=h.useState(!1),[u,f]=h.useState(!1),m=h.useCallback(async()=>{c(!0);try{const y=await Tn.getDataMartsByConnectorName(e);s(y)}catch{s([])}finally{c(!1)}},[e]);h.useEffect(()=>{u&&m()},[u,m]);const x=(y,v)=>{const S=v._id;if(!S){console.error("Configuration does not have _id field");return}t({dataMartId:y.id,dataMartTitle:y.title,configId:S,configuration:v}),f(!1)},g=y=>{const S=[],C=j=>{if(!n)return!0;const R=n.find(T=>T.name===j);return(R==null?void 0:R.required)??!1},E=(j,R,T=0,N=!0)=>{if(j.startsWith("_")||N&&T===0&&!C(j))return;let D=null;if(R==null)D="N/A";else if(typeof R=="string")D=R;else if(typeof R=="number"||typeof R=="boolean")D=String(R);else if(Array.isArray(R))D=JSON.stringify(R);else if(typeof R=="object"){S.push({key:j,value:"{",indent:T}),Object.entries(R).forEach(([O,_])=>{E(O,_,T+1,!1)}),S.push({key:"",value:"}",indent:T});return}else D=JSON.stringify(R);S.push({key:j,value:D,indent:T})};for(const[j,R]of Object.entries(y))E(j,R);return a.jsx("div",{className:"space-y-1 font-mono text-xs",children:S.map(({key:j,value:R,indent:T},N)=>a.jsxs("div",{className:"flex gap-2",style:{paddingLeft:`${String(T*12)}px`},children:[j&&a.jsxs("span",{className:"font-medium",children:[j,":"]}),a.jsx("span",{className:"text-muted-foreground truncate",title:R,children:R})]},N))})};return a.jsx(ga,{children:a.jsxs(Ar,{open:u,onOpenChange:f,children:[a.jsx(Dr,{asChild:!0,children:a.jsxs(we,{type:"button",variant:"ghost",size:"sm",className:"cursor-pointer",children:[a.jsx("span",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Copy from…"}),a.jsx(va,{className:se("text-foreground/75 h-3.5 w-3.5 transition-transform duration-200",u&&"rotate-90")})]})}),a.jsx(Or,{side:"bottom",align:"end",className:"w-72",children:i?a.jsx(Ut,{disabled:!0,children:"Loading…"}):r.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-4 text-center",children:[a.jsx("div",{className:"bg-muted/70 rounded-full p-3",children:a.jsx(oF,{className:"text-muted-foreground h-6 w-6",strokeWidth:1.5})}),a.jsx("span",{className:"text-foreground text-sm font-medium",children:"No matching Data Marts"}),a.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."})]}):a.jsxs("div",{className:"flex flex-col gap-2",children:[a.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."}),a.jsx("div",{children:r.map(y=>{const S=y.definition.connector.source.configuration;return S.length===0?null:S.length===1?a.jsxs(at,{delayDuration:300,children:[a.jsx(st,{asChild:!0,children:a.jsxs(Ut,{onSelect:()=>{x(y,S[0])},children:[a.jsx(xg,{className:"text-foreground h-4 w-4"}),y.title]})}),a.jsx(ot,{side:"right",className:"max-w-sm",children:g(S[0])})]},y.id):a.jsxs(Dx,{children:[a.jsxs(Ox,{className:"flex items-center gap-2",children:[a.jsx(xg,{className:"text-foreground h-4 w-4"}),a.jsx("span",{children:y.title})]}),a.jsx(Ix,{children:S.map((C,E)=>a.jsxs(at,{delayDuration:300,children:[a.jsx(st,{asChild:!0,children:a.jsxs(Ut,{onSelect:()=>{x(y,C)},children:["Configuration ",E+1]})}),a.jsx(ot,{side:"right",className:"max-w-sm",children:g(C)})]},E))})]},y.id)})})]})})]})})}function MN({connector:e,connectorSpecification:t,onConfigurationChange:n,onValidationChange:r,initialConfiguration:s,loading:i=!1,isEditingExisting:c=!1}){const[u,f]=h.useState({}),m=h.useRef(!1),x=h.useRef(!1),[g,y]=h.useState({});h.useEffect(()=>{De({event:"connector_setup",category:e.name,action:"connector_selected",label:e.displayName})},[e]),h.useEffect(()=>{if(t){x.current=!0;const O={...s??{}};t.forEach(_=>{const M=Array.isArray(_.attributes)?_.attributes.includes("SECRET"):!1;O[_.name]===void 0&&_.default!==void 0&&(O[_.name]=_.default),c&&M&&(O[_.name]=xS)}),f(O),m.current=!0,setTimeout(()=>{x.current=!1},0)}},[t,s,c]),h.useEffect(()=>{m.current&&s&&Object.keys(s).length>0&&(x.current=!0,f({...s}),setTimeout(()=>{x.current=!1},0))},[s]),h.useEffect(()=>{m.current&&!x.current&&Object.keys(u).length>0&&(n==null||n(u))},[u,n]);const v=(O,_)=>{f(M=>({...M,[O]:_}))},S=h.useCallback(O=>!(O==null||typeof O=="string"&&O.trim()===""||typeof O=="number"&&isNaN(O)||Array.isArray(O)&&O.length===0),[]),C=h.useCallback((O,_)=>{var $,L;if(typeof O!="object"||O===null)return S(O);if(($=_.attributes)!=null&&$.includes("OAUTH_FLOW")&&"_source_credential_id"in O)return!0;const M=(L=_.oneOf)==null?void 0:L.filter(k=>k.value===Object.keys(O)[0]);return M?M.every(k=>{var B;if((B=k.attributes)!=null&&B.includes("OAUTH_FLOW")){const K=O[k.value];if(typeof K=="object"&&K!==null){if("_source_credential_id"in K)return!0;const q=Object.entries(k.items).filter(([,F])=>F.required);if(q.length>0)return q.every(([F])=>{const I=K[F];return S(I)})}return!1}return Object.entries(k.items).every(([,K])=>k.value in O?C(O[k.value],K):!1)}):S(O[_.name])},[S]),E=h.useCallback((O,_)=>{const M=_.filter(B=>B.required&&B.oneOf),$=M.length===0?!0:M.some(B=>C(O[B.name],B)),k=_.filter(B=>B.required&&B.name!=="Fields").every(B=>S(O[B.name]));return $&&k},[S,C]),j=(O,_)=>{y(M=>({...M,[O]:_})),f(_?M=>({...M,[O]:""}):M=>({...M,[O]:xS}))},R=O=>{const _={...u};Object.entries(O.configuration).forEach(([M,$])=>{["_id","_copiedFrom"].includes(M)||(_[M]=$)}),_._copiedFrom={dataMartId:O.dataMartId,dataMartTitle:O.dataMartTitle,configId:O.configId},f(_)};if(h.useEffect(()=>{if(t&&r){const O=E(u,t);r(O)}},[u,t,r,E]),i)return a.jsx(wE,{variant:"list"});if(!t||t.length===0)return a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:"No configuration found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),a.jsx(td,{label:"Need configuration?"})]});const T=[...t].filter(O=>{var _;return O.name!=="Fields"&&!((_=O.attributes)!=null&&_.includes("HIDE_IN_CONFIG_FORM"))}).sort((O,_)=>{const M=$=>{const L=$.default!=null&&$.default!=="";return $.required&&!L?1:$.required&&L?2:!$.required&&!L?3:4};return M(O)-M(_)}),N=T.filter(O=>{var _;return!((_=O.attributes)!=null&&_.includes("ADVANCED"))}),D=T.filter(O=>{var _;return(_=O.attributes)==null?void 0:_.includes("ADVANCED")});return a.jsx(a.Fragment,{children:a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsxs(ci,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-muted-foreground/75 text-xs font-semibold tracking-wide uppercase",children:"Configure Settings"}),a.jsx(Ile,{currentConnectorName:e.name,onCopyConfiguration:R,connectorSpecification:t})]}),N.length>0&&a.jsx(IN,{items:N,configuration:u,onValueChange:v,onSecretEditToggle:j,secretEditing:g,isEditingExisting:c,connectorName:e.name}),D.length>0&&a.jsx(IN,{collapsibleTitle:"Advanced Settings",items:D,configuration:u,onValueChange:v,onSecretEditToggle:j,secretEditing:g,isEditingExisting:c,connectorName:e.name})]})]})})}function Mle({connector:e,connectorFields:t,selectedField:n,connectorName:r,loading:s=!1,onFieldSelect:i}){const c=r?`Select data for ${r}`:"Select data";return s?a.jsx(wE,{variant:"list"}):!t||t.length===0?a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:r?`No nodes found for ${r}`:"No nodes found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),a.jsx(td,{label:"Missing some data?"})]}):a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsxs(ci,{title:c,children:[a.jsx(j6,{children:t.map(u=>a.jsx(T6,{type:"radio",id:u.name,name:"selectedField",value:u.name,label:u.overview??u.name,checked:n===u.name,onChange:f=>{i(f)},tooltip:u.name&&a.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[a.jsxs("p",{children:[a.jsx("span",{className:"font-semibold",children:"Table name:"})," ",u.destinationName??u.name]}),u.description&&a.jsxs("p",{children:[a.jsx("span",{className:"font-semibold",children:"Description:"})," ",u.description]}),u.documentation&&a.jsxs(Tr,{to:u.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",a.jsx(va,{className:"h-3 w-3"})]})]}),selected:n===u.name},u.name))}),a.jsx(td,{label:"Missing some data?"})]})]})}var fo=(e=>(e.ASC="asc",e.DESC="desc",e.ORIGINAL="original",e))(fo||{});function kN({connector:e,connectorFields:t,selectedField:n,selectedFields:r,onFieldToggle:s,onSelectAllFields:i}){const c=h.useRef(null),[u,f]=h.useState(""),[m,x]=h.useState(fo.ORIGINAL),g=t==null?void 0:t.find(R=>R.name===n),y=h.useMemo(()=>(g==null?void 0:g.fields)??[],[g==null?void 0:g.fields]),v=h.useMemo(()=>(g==null?void 0:g.uniqueKeys)??[],[g==null?void 0:g.uniqueKeys]),S=h.useMemo(()=>{const R=new Map;return y.forEach((T,N)=>R.set(T.name,N)),R},[y]),C=h.useMemo(()=>{const R=y.filter(N=>N.name.toLowerCase().includes(u.toLowerCase().trim())),T=(N,D)=>{const O=v.includes(N.name),_=v.includes(D.name);if(O&&!_)return-1;if(!O&&_)return 1;if(m===fo.ASC)return N.name.localeCompare(D.name);if(m===fo.DESC)return D.name.localeCompare(N.name);const M=S.get(N.name)??0,$=S.get(D.name)??0;return M-$};return[...R].sort(T)},[y,u,v,m,S]),E=y.map(R=>R.name),j=r.filter(R=>E.includes(R)).length;return h.useEffect(()=>{const R=new Set(y.map(_=>_.name)),T=new Set(r),N=new Set(v),D=new Set;if(v.forEach(_=>{R.has(_)&&!T.has(_)&&D.add(_)}),r.some(_=>!N.has(_))||((g==null?void 0:g.defaultFields)??[]).forEach(M=>{R.has(M)&&!T.has(M)&&D.add(M)}),D.size>0){const _=Array.from(D);i(_,!0)}},[y,v,r,g,i]),h.useEffect(()=>{const R=T=>{const D=(T.ctrlKey||T.metaKey)&&T.shiftKey&&T.key.toLowerCase()==="a",O=document.activeElement.tagName;if(!(O==="INPUT"||O==="TEXTAREA")&&D){T.preventDefault();const _=y.map(L=>L.name),$=_.filter(L=>!r.includes(L)).length>0;i(_,$)}};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R)}},[y,r,s,i]),!n||!t?a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),a.jsx(td,{label:"Need fields?"})]}):y.length?a.jsx(gi,{children:a.jsxs(a.Fragment,{children:[a.jsx(vc,{connector:e}),a.jsxs("div",{className:"border-border -mt-6 mb-6 flex w-full items-center gap-2 border-b",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(zc,{className:"text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 cursor-text",onClick:()=>{var R;(R=c.current)==null||R.focus()}}),a.jsx("input",{ref:c,type:"text",placeholder:"Search field",value:u,onChange:R=>{f(R.target.value)},className:"h-12 w-full rounded-none border-0 pl-9 text-sm outline-none"}),u&&a.jsx("button",{type:"button",onClick:()=>{f("")},className:"text-muted-foreground hover:text-foreground absolute top-1/2 right-0 -translate-y-1/2",children:a.jsx(Cc,{className:"h-4 w-4"})})]}),a.jsxs(Ar,{children:[a.jsx(Dr,{asChild:!0,children:a.jsxs(we,{variant:"ghost",size:"icon","aria-label":"Sort fields",children:[m===fo.ASC&&a.jsx(MT,{className:"text-muted-foreground h-4 w-4"}),m===fo.DESC&&a.jsx(IT,{className:"text-muted-foreground h-4 w-4"}),m===fo.ORIGINAL&&a.jsx(kT,{className:"text-muted-foreground h-4 w-4"})]})}),a.jsxs(Or,{align:"end",children:[a.jsxs(Ut,{onSelect:()=>{x(fo.ASC)},children:[a.jsx(MT,{className:"text-muted-foreground mr-2 h-4 w-4"}),"A–Z"]}),a.jsxs(Ut,{onSelect:()=>{x(fo.DESC)},children:[a.jsx(IT,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Z–A"]}),a.jsxs(Ut,{onSelect:()=>{x(fo.ORIGINAL)},children:[a.jsx(kT,{className:"text-muted-foreground mr-2 h-4 w-4"}),"Original"]})]})]})]}),a.jsxs(ci,{title:`Selected ${String(j)} of ${String(E.length)} fields for "${n}" data`,children:[a.jsxs(j6,{children:[C.map(R=>{const T=v.includes(R.name);return a.jsx(T6,{type:"checkbox",id:`field-${R.name}`,name:"selectedFields",value:R.name,checked:r.includes(R.name),selected:r.includes(R.name)||T,disabled:T,onChange:N=>{s(R.name,N)},label:R.name,tooltip:a.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[T&&a.jsxs("p",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-semibold",children:"Unique key"})," ",a.jsx(xb,{className:"text-secondary h-3 w-3"})]}),a.jsxs("p",{children:[a.jsx("span",{className:"font-semibold",children:"Type:"})," ",R.type]}),R.description&&a.jsxs("p",{children:[a.jsx("span",{className:"font-semibold",children:"Description:"})," ",R.description]})]}),rightIcon:T?a.jsx(xb,{className:"text-muted-foreground/75 h-4 w-4"}):void 0},R.name)}),C.length===0&&u&&a.jsxs("div",{className:"text-muted-foreground p-8 text-center text-sm",children:['No fields match "',u,'"']})]}),a.jsx(td,{label:"Need another field?"})]})]})}):a.jsxs(gi,{children:[a.jsx(vc,{connector:e}),a.jsx(xo,{icon:a.jsx(sh,{size:56,strokeWidth:1}),title:"No fields found",subtitle:"This connector might not be fully implemented yet or there could be other issues."}),a.jsx(td,{label:"Need fields?"})]})}const vM=h.createContext(void 0),bM={triggers:[],selectedTrigger:null,isLoading:!1,error:null};function kle(e,t){var n,r;switch(t.type){case"FETCH_TRIGGERS_START":case"FETCH_TRIGGER_START":case"CREATE_TRIGGER_START":case"UPDATE_TRIGGER_START":case"DELETE_TRIGGER_START":return{...e,isLoading:!0,error:null};case"FETCH_TRIGGERS_SUCCESS":return{...e,triggers:t.payload,isLoading:!1};case"FETCH_TRIGGER_SUCCESS":return{...e,selectedTrigger:t.payload,isLoading:!1};case"CREATE_TRIGGER_SUCCESS":return{...e,triggers:[...e.triggers,t.payload],isLoading:!1};case"UPDATE_TRIGGER_SUCCESS":return{...e,triggers:e.triggers.map(s=>s.id===t.payload.id?t.payload:s),selectedTrigger:((n=e.selectedTrigger)==null?void 0:n.id)===t.payload.id?t.payload:e.selectedTrigger,isLoading:!1};case"DELETE_TRIGGER_SUCCESS":return{...e,triggers:e.triggers.filter(s=>s.id!==t.payload),selectedTrigger:((r=e.selectedTrigger)==null?void 0:r.id)===t.payload?null:e.selectedTrigger,isLoading:!1};case"FETCH_TRIGGERS_ERROR":case"FETCH_TRIGGER_ERROR":case"CREATE_TRIGGER_ERROR":case"UPDATE_TRIGGER_ERROR":case"DELETE_TRIGGER_ERROR":return{...e,isLoading:!1,error:t.payload};case"SELECT_TRIGGER":return{...e,selectedTrigger:t.payload};case"RESET":return bM;default:return e}}class Lle extends _l{constructor(){super("/data-marts")}async getScheduledTriggers(t){return this.get(`/${t}/scheduled-triggers`)}async getScheduledTrigger(t,n){return this.get(`/${t}/scheduled-triggers/${n}`)}async createScheduledTrigger(t,n){return this.post(`/${t}/scheduled-triggers`,n)}async updateScheduledTrigger(t,n,r){return this.put(`/${t}/scheduled-triggers/${n}`,r)}async deleteScheduledTrigger(t,n){return this.delete(`/${t}/scheduled-triggers/${n}`)}}const ho=new Lle;var zn=(e=>(e.REPORT_RUN="REPORT_RUN",e.CONNECTOR_RUN="CONNECTOR_RUN",e))(zn||{});const hl={SCHEDULED_REPORT_RUN:"scheduled-report-run-config"};class yS{mapFromDto(t){return{id:t.id,type:t.type,cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive,nextRun:t.nextRunTimestamp?new Date(t.nextRunTimestamp):null,lastRun:t.lastRunTimestamp?new Date(t.lastRunTimestamp):null,triggerConfig:t.triggerConfig,createdById:t.createdById,createdAt:new Date(t.createdAt),modifiedAt:new Date(t.modifiedAt)}}async enhanceWithReportData(t){if(t.type!==zn.REPORT_RUN)return t;const n=t.triggerConfig;if(!n.reportId)return t;try{const r=await oi.getReportById(n.reportId),s=uc(r);return{...t,triggerConfig:{...n,report:s}}}catch(r){return console.error(`Failed to fetch report data for trigger ${t.id}:`,r),t}}async enhanceTriggersWithReportData(t){return Promise.all(t.map(n=>this.enhanceWithReportData(n)))}mapToCreateRequest(t){return{type:zn.REPORT_RUN,cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive,triggerConfig:t.triggerConfig}}mapToUpdateRequest(t){return{cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive}}}class Ple{mapFromDto(t){return{id:t.id,type:t.type,cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive,nextRun:t.nextRunTimestamp?new Date(t.nextRunTimestamp):null,lastRun:t.lastRunTimestamp?new Date(t.lastRunTimestamp):null,triggerConfig:t.triggerConfig,createdById:t.createdById,createdAt:new Date(t.createdAt),modifiedAt:new Date(t.modifiedAt)}}mapToCreateRequest(t){return{type:zn.CONNECTOR_RUN,cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive,triggerConfig:t.triggerConfig}}mapToUpdateRequest(t){return{cronExpression:t.cronExpression,timeZone:t.timeZone,isActive:t.isActive}}}const W1={getMapper(e){switch(e){case zn.REPORT_RUN:return new yS;case zn.CONNECTOR_RUN:return new Ple;default:throw new Error(`Unknown scheduled trigger type: ${String(e)}`)}}},Lf={mapFromDto(e){return W1.getMapper(e.type).mapFromDto(e)},mapFromDtoList(e){return e.map(t=>this.mapFromDto(t))},async mapFromDtoWithReportData(e,t){const n=this.mapFromDto(e);switch(n.type){case zn.REPORT_RUN:return new yS().enhanceWithReportData(n);case zn.CONNECTOR_RUN:{const r=t.definition;return{...n,triggerConfig:{...n.triggerConfig,connector:r}}}default:return n}},async mapFromDtoListWithReportData(e,t){const n=new yS,r=this.mapFromDtoList(e),s=r.filter(c=>c.type===zn.REPORT_RUN),i=await n.enhanceTriggersWithReportData(s);return r.map(c=>{switch(c.type){case zn.REPORT_RUN:return i.find(u=>u.id===c.id)??c;case zn.CONNECTOR_RUN:{const u=t.definition;return{...c,triggerConfig:{...c.triggerConfig,connector:u}}}default:return c}})},mapToCreateRequest(e){return W1.getMapper(e.type).mapToCreateRequest(e)},mapToUpdateRequest(e){return W1.getMapper(e.type).mapToUpdateRequest(e)}};function Ule({children:e}){const[t,n]=h.useReducer(kle,bM),{dataMart:r}=Js(),{fetchAvailableConnectors:s}=Kc();if(!r)throw new Error("Trigger provider must be used within a data mart context");const i=h.useCallback(async v=>{await s(),n({type:"FETCH_TRIGGERS_START"});try{const S=await ho.getScheduledTriggers(v),C=await Lf.mapFromDtoListWithReportData(S,r);n({type:"FETCH_TRIGGERS_SUCCESS",payload:C})}catch(S){const C=S instanceof Error?S.message:"Failed to fetch scheduled triggers";n({type:"FETCH_TRIGGERS_ERROR",payload:C}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:C})}},[r,s]),c=h.useCallback(async(v,S)=>{n({type:"FETCH_TRIGGERS_START"});try{const E=(await ho.getScheduledTriggers(v)).filter(R=>R.type===S),j=await Lf.mapFromDtoListWithReportData(E,r);n({type:"FETCH_TRIGGERS_SUCCESS",payload:j})}catch(C){const E=C instanceof Error?C.message:"Failed to fetch scheduled triggers";n({type:"FETCH_TRIGGERS_ERROR",payload:E}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"ListError",label:E})}},[r]),u=h.useCallback(async(v,S)=>{n({type:"FETCH_TRIGGER_START"});try{const C=await ho.getScheduledTrigger(v,S),E=await Lf.mapFromDtoWithReportData(C,r);n({type:"FETCH_TRIGGER_SUCCESS",payload:E})}catch(C){const E=C instanceof Error?C.message:"Failed to fetch scheduled trigger";n({type:"FETCH_TRIGGER_ERROR",payload:E}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"GetError",label:E})}},[r]),f=h.useCallback(async(v,S,C,E,j,R)=>{n({type:"CREATE_TRIGGER_START"});try{const T={type:S,cronExpression:C,timeZone:E,isActive:j,triggerConfig:R},N=await ho.createScheduledTrigger(v,T),D=await Lf.mapFromDtoWithReportData(N,r);return n({type:"CREATE_TRIGGER_SUCCESS",payload:D}),De({event:"scheduled_trigger_created",category:"ScheduledTrigger",action:"Create",label:S}),In.success("Trigger created"),D}catch(T){const N=T instanceof Error?T.message:"Failed to create scheduled trigger";throw n({type:"CREATE_TRIGGER_ERROR",payload:N}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"CreateError",label:N}),T}},[r]),m=h.useCallback(async(v,S,C,E,j)=>{n({type:"UPDATE_TRIGGER_START"});try{const R={cronExpression:C,timeZone:E,isActive:j},T=await ho.updateScheduledTrigger(v,S,R),N=await Lf.mapFromDtoWithReportData(T,r);n({type:"UPDATE_TRIGGER_SUCCESS",payload:N}),De({event:"scheduled_trigger_updated",category:"ScheduledTrigger",action:"Update",label:N.type}),In.success("Trigger updated")}catch(R){const T=R instanceof Error?R.message:"Failed to update scheduled trigger";throw n({type:"UPDATE_TRIGGER_ERROR",payload:T}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"UpdateError",label:T}),R}},[r]),x=h.useCallback(async(v,S)=>{n({type:"DELETE_TRIGGER_START"});try{await ho.deleteScheduledTrigger(v,S),n({type:"DELETE_TRIGGER_SUCCESS",payload:S}),De({event:"scheduled_trigger_deleted",category:"ScheduledTrigger",action:"Delete",label:S}),In.success("Trigger deleted")}catch(C){const E=C instanceof Error?C.message:"Failed to delete scheduled trigger";throw n({type:"DELETE_TRIGGER_ERROR",payload:E}),De({event:"scheduled_trigger_error",category:"ScheduledTrigger",action:"DeleteError",label:E}),C}},[]),g=h.useCallback(v=>{n({type:"SELECT_TRIGGER",payload:v})},[]),y=h.useCallback(()=>{n({type:"RESET"})},[]);return a.jsx(vM.Provider,{value:{...t,getScheduledTriggers:i,getScheduledTriggersByType:c,getScheduledTrigger:u,createScheduledTrigger:f,updateScheduledTrigger:m,deleteScheduledTrigger:x,selectScheduledTrigger:g,reset:y},children:e})}function SM(){const e=h.useContext(vM);if(e===void 0)throw new Error("useScheduledTriggerContext must be used within a ScheduledTriggerProvider");return e}function zle(e){const{getScheduledTriggers:t,getScheduledTriggersByType:n,getScheduledTrigger:r,createScheduledTrigger:s,updateScheduledTrigger:i,deleteScheduledTrigger:c,selectScheduledTrigger:u,reset:f,triggers:m,selectedTrigger:x,isLoading:g,error:y}=SM();return h.useEffect(()=>(e?t(e):f(),()=>{f()}),[e,t,f]),{triggers:m,selectedTrigger:x,isLoading:g,error:y,getScheduledTriggers:v=>t(v),getScheduledTriggersByType:(v,S)=>n(v,S),getScheduledTrigger:(v,S)=>r(v,S),createScheduledTrigger:(v,S,C,E,j,R)=>s(v,S,C,E,j,R),updateScheduledTrigger:(v,S,C,E,j)=>i(v,S,C,E,j),deleteScheduledTrigger:(v,S)=>c(v,S),selectScheduledTrigger:u}}const Fle=ln({type:Sr(hl.SCHEDULED_REPORT_RUN),reportId:St().min(1,"Report ID is required")}),Hle=dY(),$le=ln({type:Fx(zn),cronExpression:St().min(1,"Cron expression is required"),timeZone:St().min(1,"Time zone is required"),isActive:uY(),triggerConfig:hY([Fle,Hle])});function Vle({initialData:e,preSelectedReportId:t,preSelectedType:n,onSubmit:r}){const s=ko({resolver:Ai($le),defaultValues:{type:e?e.type:n??zn.REPORT_RUN,cronExpression:(e==null?void 0:e.cronExpression)??"",timeZone:(e==null?void 0:e.timeZone)??Intl.DateTimeFormat().resolvedOptions().timeZone,isActive:(e==null?void 0:e.isActive)??!0,triggerConfig:e?e.triggerConfig:{type:hl.SCHEDULED_REPORT_RUN,reportId:t??""}}});h.useEffect(()=>{t&&s.getValues("type")===zn.REPORT_RUN&&s.setValue("triggerConfig",{type:hl.SCHEDULED_REPORT_RUN,reportId:t})},[t,s]),h.useEffect(()=>{n&&(s.setValue("type",n),n===zn.REPORT_RUN?s.setValue("triggerConfig",{type:hl.SCHEDULED_REPORT_RUN,reportId:t??""}):s.setValue("triggerConfig",null))},[n,t,s]);const i=u=>{s.setValue("type",u),u===zn.REPORT_RUN?s.setValue("triggerConfig",{type:hl.SCHEDULED_REPORT_RUN,reportId:t??""}):s.setValue("triggerConfig",null)},c=async u=>{try{await r(u)}catch(f){console.error("Error submitting form:",f)}};return{form:s,handleTypeChange:i,handleSubmit:s.handleSubmit(c),isDirty:s.formState.isDirty}}const Gle=[Ie.GOOGLE_SHEETS,Ie.EMAIL,Ie.SLACK,Ie.MS_TEAMS,Ie.GOOGLE_CHAT];function Ble({value:e,onChange:t,disabled:n}){const{reports:r,fetchReportsByDataMartId:s}=os(),{dataMart:i}=Js();h.useEffect(()=>{i&&s(i.id)},[s,i]);const c=r.filter(u=>Gle.includes(u.dataDestination.type));return a.jsxs(sa,{value:e,onValueChange:t,disabled:n,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{placeholder:"Select a report"})}),a.jsx(la,{children:c.map(u=>{const f=ha.getInfo(u.dataDestination.type).icon;return a.jsx(Fn,{value:u.id,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(f,{className:"h-4 w-4",size:16}),a.jsx("span",{children:u.title})]})},u.id)})})]})}var xy="Switch",[qle]=Nr(xy),[Kle,Wle]=qle(xy),CM=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:i,required:c,disabled:u,value:f="on",onCheckedChange:m,form:x,...g}=e,[y,v]=h.useState(null),S=wt(t,T=>v(T)),C=h.useRef(!1),E=y?x||!!y.closest("form"):!0,[j,R]=xa({prop:s,defaultProp:i??!1,onChange:m,caller:xy});return a.jsxs(Kle,{scope:n,checked:j,disabled:u,children:[a.jsx(tt.button,{type:"button",role:"switch","aria-checked":j,"aria-required":c,"data-state":jM(j),"data-disabled":u?"":void 0,disabled:u,value:f,...g,ref:S,onClick:Me(e.onClick,T=>{R(N=>!N),E&&(C.current=T.isPropagationStopped(),C.current||T.stopPropagation())})}),E&&a.jsx(RM,{control:y,bubbles:!C.current,name:r,value:f,checked:j,required:c,disabled:u,form:x,style:{transform:"translateX(-100%)"}})]})});CM.displayName=xy;var EM="SwitchThumb",wM=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,s=Wle(EM,n);return a.jsx(tt.span,{"data-state":jM(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:t})});wM.displayName=EM;var Zle="SwitchBubbleInput",RM=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...s},i)=>{const c=h.useRef(null),u=wt(c,i),f=WC(n),m=dC(t);return h.useEffect(()=>{const x=c.current;if(!x)return;const g=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(g,"checked").set;if(f!==n&&v){const S=new Event("click",{bubbles:r});v.call(x,n),x.dispatchEvent(S)}},[f,n,r]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:u,style:{...s.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RM.displayName=Zle;function jM(e){return e?"checked":"unchecked"}var Yle=CM,Xle=wM;function VE({className:e,...t}){return a.jsx(Yle,{"data-slot":"switch",className:se("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",e),...t,children:a.jsx(Xle,{"data-slot":"switch-thumb",className:se("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 Qle(e){const t=e.trim().split(/\s+/);return t.length!==5?null:{minute:t[0],hour:t[1],day:t[2],month:t[3],dayOfWeek:t[4]}}function vS(e,t="UTC"){const n=Qle(e);if(!n)return{type:"daily",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:e,intervalType:"minutes",intervalValue:15,timezone:t};const{minute:r,hour:s,day:i,month:c,dayOfWeek:u}=n;if(r.startsWith("*/")&&s==="*"&&i==="*"&&c==="*"&&u==="*"){const g=Number.parseInt(r.substring(2));if(!isNaN(g))return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:e,intervalType:"minutes",intervalValue:g,timezone:t}}if(r!=="*"&&s.startsWith("*/")&&i==="*"&&c==="*"&&u==="*"){const g=Number.parseInt(s.substring(2));if(!isNaN(g)&&r==="0")return{type:"interval",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:e,intervalType:"hours",intervalValue:g,timezone:t}}const f=Number.parseInt(r),m=Number.parseInt(s),x=!isNaN(f)&&!isNaN(m)?`${m.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`:"09:00";if(!isNaN(f)&&!isNaN(m)&&i==="*"&&c==="*"&&u==="*")return{type:"daily",time:x,weekdays:[1,2,3,4,5],monthDays:[1],customCron:e,intervalType:"minutes",intervalValue:15,timezone:t};if(!isNaN(f)&&!isNaN(m)&&i==="*"&&c==="*"&&u!=="*"){const g=u.split(",").map(y=>Number.parseInt(y.trim())).filter(y=>!isNaN(y)&&y>=0&&y<=6);if(g.length>0)return{type:"weekly",time:x,weekdays:g,monthDays:[1],customCron:e,intervalType:"minutes",intervalValue:15,timezone:t}}if(!isNaN(f)&&!isNaN(m)&&i!=="*"&&c==="*"&&u==="*"){const g=i.split(",").map(y=>Number.parseInt(y.trim())).filter(y=>!isNaN(y)&&y>=1&&y<=31);if(g.length>0)return{type:"monthly",time:x,weekdays:[1,2,3,4,5],monthDays:g,customCron:e,intervalType:"minutes",intervalValue:15,timezone:t}}return{type:"custom",time:"09:00",weekdays:[1,2,3,4,5],monthDays:[1],customCron:e,intervalType:"minutes",intervalValue:15,timezone:t}}function TM({options:e,selected:t,onSelectionChange:n,placeholder:r="Select items...",searchPlaceholder:s="Search...",maxDisplayItems:i=3}){const[c,u]=h.useState(!1),f=g=>{const y=t.includes(g)?t.filter(v=>v!==g):[...t,g].sort((v,S)=>v-S);n(y)},m=(g,y)=>{y.preventDefault(),y.stopPropagation(),n(t.filter(v=>v!==g))},x=()=>{if(t.length===0)return a.jsx("span",{className:"text-muted-foreground text-sm",children:r});const g=t.map(y=>e.find(v=>v.value===y)).filter(Boolean);return g.length<=i?a.jsx("div",{className:"flex flex-wrap gap-1",children:g.map(y=>a.jsxs(Rr,{variant:"secondary",className:"h-5 text-xs",children:[y.label,a.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:v=>m(y.value,v),children:a.jsx(Cc,{className:"h-2 w-2"})})]},y.value))}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(Rr,{variant:"secondary",className:"h-5 text-xs",children:[g[0].label,a.jsx("span",{className:"hover:bg-secondary-foreground/20 ml-1 inline-flex cursor-pointer items-center justify-center rounded-full p-0.5",onClick:y=>m(g[0].value,y),children:a.jsx(Cc,{className:"h-2 w-2"})})]}),g.length>1&&a.jsxs(Rr,{variant:"outline",className:"h-5 text-xs",children:["+",g.length-1]})]})};return a.jsxs(kE,{open:c,onOpenChange:u,modal:!0,children:[a.jsx(LE,{asChild:!0,children:a.jsxs(we,{variant:"outline",role:"combobox","aria-expanded":c,className:"h-9 min-h-9 w-full justify-between bg-transparent py-1",children:[a.jsx("div",{className:"flex-1 text-left",children:x()}),a.jsx(WS,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),a.jsx(PE,{className:"max-h-[400px] w-full overflow-y-auto p-0",style:{padding:0},children:a.jsxs(DE,{className:"h-full overflow-visible",children:[a.jsx(OE,{placeholder:s,className:"h-8"}),a.jsxs(rM,{className:"h-full max-h-[350px] overflow-y-auto",children:[a.jsx(aM,{children:"No items found."}),a.jsx(sM,{className:"h-full overflow-visible",children:e.map(g=>a.jsxs(IE,{value:g.value.toString(),onSelect:()=>f(g.value),className:"text-sm",children:[a.jsx(Ia,{className:se("mr-2 h-3 w-3",t.includes(g.value)?"opacity-100":"opacity-0")}),g.label]},g.value))})]})]})})]})}const _M=[{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"}],Wp=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}};function NM(e,t){if(!t)return"Schedule is disabled";const n=e.time;switch(e.type){case"daily":return`Daily at ${n}`;case"weekly":return`Weekly on ${e.weekdays.map(s=>{var i;return(i=_M.find(c=>c.value===s))==null?void 0:i.label}).join(", ")} at ${n}`;case"monthly":{const s=[...e.monthDays].sort((c,u)=>c-u).map(c=>c===1?"1st":c===2?"2nd":c===3?"3rd":`${String(c)}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 ${n}`}case"interval":return e.intervalType==="minutes"?`Every ${String(e.intervalValue)} minute${e.intervalValue!==1?"s":""}`:`Every ${String(e.intervalValue)} hour${e.intervalValue!==1?"s":""}`;case"custom":return"Custom schedule";default:return""}}function Jle(e,t,n=!0){const r=vS(e,t);return NM(r,n)}const ece=Array.from({length:31},(e,t)=>({value:t+1,label:`${String(t+1)}${t===0?"st":t===1?"nd":t===2?"rd":"th"}`})),bS=[5,10,15,30],SS=[1,2,3,4,6,8,12],tce=({value:e,onChange:t,disabled:n})=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Type"}),a.jsxs(sa,{value:e,onValueChange:r=>{t(r)},disabled:n,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{})}),a.jsxs(la,{children:[a.jsx(Fn,{value:"daily",children:"Daily"}),a.jsx(Fn,{value:"weekly",children:"Weekly"}),a.jsx(Fn,{value:"monthly",children:"Monthly"}),a.jsx(Fn,{value:"interval",children:"Interval"})]})]})]}),nce=({value:e,onChange:t,disabled:n})=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Time"}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsx(gt,{className:"w-24",type:"time",value:e,onChange:r=>{t(r.target.value)},disabled:n})})]}),LN=({value:e,onChange:t,disabled:n,timezones:r})=>a.jsxs("div",{className:"w-full space-y-2",children:[a.jsx(Ma,{children:"Timezone"}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsx(UE,{options:r,value:e,onValueChange:t,placeholder:"Select timezone",emptyMessage:"No timezones found",disabled:n,className:"w-full"})})]}),rce=({value:e,onChange:t,disabled:n})=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Days of Week"}),a.jsx("div",{className:n?"pointer-events-none":"",children:a.jsx(TM,{options:_M,selected:e,onSelectionChange:t,placeholder:"Select days...",maxDisplayItems:3})})]}),ace=({value:e,onChange:t,disabled:n})=>a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Days of Month"}),a.jsx("div",{className:n?"pointer-events-none":"",children:a.jsx(TM,{options:ece,selected:e,onSelectionChange:t,placeholder:"Select days...",maxDisplayItems:4})})]}),sce=({intervalType:e,intervalValue:t,onTypeChange:n,onValueChange:r,disabled:s})=>a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Type"}),a.jsxs(sa,{value:e,onValueChange:i=>{n(i)},disabled:s,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{})}),a.jsxs(la,{children:[a.jsx(Fn,{value:"minutes",children:"Minutes"}),a.jsx(Fn,{value:"hours",children:"Hours"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Ma,{children:"Every"}),a.jsxs(sa,{value:t.toString(),onValueChange:i=>{r(Number.parseInt(i)||1)},disabled:s,children:[a.jsx(ia,{className:"w-full",children:a.jsx(oa,{})}),a.jsx(la,{children:(e==="minutes"?bS:SS).map(i=>a.jsxs(Fn,{value:i.toString(),children:[i," ",e==="minutes"?"min":"hr"]},i))})]})]})]}),oce=({value:e,onChange:t,disabled:n})=>a.jsxs("div",{className:"space-y-1",children:[a.jsx(Ma,{className:"text-sm",children:"Cron Expression"}),a.jsx(gt,{value:e,onChange:r=>{t(r.target.value)},placeholder:"0 9 * * *",className:"h-9 font-mono text-sm",disabled:n}),a.jsx("p",{className:"text-muted-foreground text-xs",children:"Format: minute hour day month day-of-week"})]});function CS({cron:e="0 9 * * *",timezone:t,enabled:n=!0,onChange:r,className:s,showPreview:i=!0,showSaveButton:c=!1,hideEnableSwitch:u=!1}){const[f,m]=h.useState(n),[x,g]=h.useState(t??Wp()),[y,v]=h.useState(!1),S=h.useMemo(()=>KX.getTimezonesWithOffset().map(F=>({value:F.identifier,label:F.displayName,offset:F.offsetString,isDST:F.isDST})),[]),[C,E]=h.useState(()=>vS(e,x)),[j,R]=h.useState(""),[T,N]=h.useState("");h.useEffect(()=>{m(n)},[n]),h.useEffect(()=>{const F=t??Wp();g(F)},[t]),h.useEffect(()=>{if(e){const F=vS(e,x);E(F)}},[e,x]);const D=F=>{const[I,G]=F.time.split(":").map(Number);switch(F.type){case"daily":return`${String(G)} ${String(I)} * * *`;case"weekly":return`${String(G)} ${String(I)} * * ${F.weekdays.join(",")}`;case"monthly":return`${String(G)} ${String(I)} ${F.monthDays.join(",")} * *`;case"interval":return F.intervalType==="minutes"?`*/${String(F.intervalValue)} * * * *`:`0 */${String(F.intervalValue)} * * *`;case"custom":return F.customCron;default:return`${String(G)} ${String(I)} * * *`}},O=h.useCallback(F=>{E(I=>{if(I.intervalType===F)return console.log("Type unchanged, skipping update"),I;const H=(F==="minutes"?bS:SS)[0];return{...I,intervalType:F,intervalValue:H}})},[]),_=h.useCallback(F=>{E(I=>(I.intervalType==="minutes"?bS:SS).includes(F)?{...I,intervalValue:F}:I)},[]),M=h.useMemo(()=>F=>NM(F,f),[f]);h.useEffect(()=>{const F=D(C);R(F),N(M(C))},[C,f,x,M]);const $=h.useRef(""),L=h.useRef(""),k=h.useRef(!1);h.useEffect(()=>{const F=D(C);r&&($.current!==F||L.current!==x||k.current!==f)&&(r({cron:F,timezone:x,enabled:f}),$.current=F,L.current=x,k.current=f)},[C,x,f,r]);const B=F=>{m(F)},K=F=>{g(F),E(I=>({...I,timezone:F}))},q=["daily","weekly","monthly"].includes(C.type);return a.jsxs("div",{className:s,children:[!u&&a.jsx("div",{className:"mb-4 space-y-4 pt-0",children:a.jsx("div",{className:"flex items-center justify-end",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ma,{htmlFor:"schedule-enabled",className:"text-sm font-normal",children:f?"Enabled":"Disabled"}),a.jsx(VE,{id:"schedule-enabled",checked:f,onCheckedChange:B})]})})}),a.jsxs("div",{className:"space-y-4 pt-0",children:[a.jsxs("div",{className:`space-y-4 ${f?"":"opacity-50"}`,children:[a.jsx(tce,{value:C.type,onChange:F=>{E(I=>({...I,type:F}))},disabled:!f}),C.type!=="custom"&&C.type!=="interval"&&a.jsxs("div",{className:"flex gap-3",children:[a.jsx(nce,{value:C.time,onChange:F=>{E(I=>({...I,time:F}))},disabled:!f}),q&&a.jsx(LN,{value:x,onChange:K,disabled:!f,timezones:S})]}),(C.type==="interval"||C.type==="custom")&&a.jsx(LN,{value:x,onChange:K,disabled:!f,timezones:S}),C.type==="weekly"&&a.jsx(rce,{value:C.weekdays,onChange:F=>{E(I=>({...I,weekdays:F}))},disabled:!f}),C.type==="monthly"&&a.jsx(ace,{value:C.monthDays,onChange:F=>{E(I=>({...I,monthDays:F}))},disabled:!f}),C.type==="interval"&&a.jsx(sce,{intervalType:C.intervalType,intervalValue:C.intervalValue,onTypeChange:O,onValueChange:_,disabled:!f}),C.type==="custom"&&a.jsx(oce,{value:C.customCron,onChange:F=>{E(I=>({...I,customCron:F}))},disabled:!f})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(JS,{className:"my-3"}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex cursor-pointer items-center justify-between",onClick:()=>{v(!y)},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(v4,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm font-medium",children:"Preview"})]}),y?a.jsx(yg,{className:"text-muted-foreground h-4 w-4"}):a.jsx(as,{className:"text-muted-foreground h-4 w-4"})]}),y&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:"Status:"}),a.jsx(Rr,{variant:f?"default":"secondary",className:"text-xs",children:f?"Enabled":"Disabled"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:"Cron:"}),a.jsx(Rr,{variant:"secondary",className:"font-mono text-xs",children:j})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:"Timezone:"}),a.jsx(Rr,{variant:"outline",className:"text-xs",children:x})]}),a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsx("span",{className:"text-muted-foreground text-xs",children:"Schedule:"}),a.jsx("span",{className:"flex-1 text-right text-xs",children:T})]})]}),f&&q&&x!==Wp()&&a.jsxs(FE,{className:"border-amber-200 bg-amber-50",children:[a.jsx(Nh,{className:"h-4 w-4"}),a.jsx(xM,{children:"Time Zone"}),a.jsxs(HE,{children:["Schedule runs in ",x," (not your local ",Wp()," ","time). Execution time may differ from expected."]})]})]})]})]}),c&&a.jsx(we,{className:"w-full",disabled:!f,children:"Save Schedule"})]})]})}function ice(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"trigger-type-options-description-details",children:[a.jsx(Dt,{children:"How do I choose a type?"}),a.jsxs(Ot,{children:[a.jsxs("p",{className:"mb-2",children:[a.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)."]}),a.jsxs("p",{className:"mb-2",children:[a.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 lce(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"trigger-type-change-description-details",children:[a.jsx(Dt,{children:"How do I change the trigger type?"}),a.jsx(Ot,{children:a.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 cce(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"report-change-description-details",children:[a.jsx(Dt,{children:"How do I change a report?"}),a.jsx(Ot,{children:a.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 uce(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,children:a.jsxs(At,{value:"report-select-description-details",children:[a.jsx(Dt,{children:"How do I choose the report?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"For a Report Run trigger, select one of the available Destinations (e.g., a Google Sheets report)."}),a.jsxs("p",{children:["You can use an existing one or create a new one on the ",a.jsx("strong",{children:"Destinations"})," tab"," ","of this Data Mart."]})]})]})})}function dce({initialData:e,preSelectedReportId:t,preSelectedType:n,onSubmit:r,onCancel:s,onDirtyChange:i}){const[c,u]=h.useState(!1),{form:f,handleTypeChange:m,handleSubmit:x,isDirty:g}=Vle({initialData:e,preSelectedReportId:t,preSelectedType:n,onSubmit:async E=>{u(!0);try{await r(E)}finally{u(!1)}}});h.useEffect(()=>{i==null||i(g)},[g,i]);const{control:y,watch:v}=f,C=v("type")===zn.REPORT_RUN;return a.jsx(Ul,{...f,children:a.jsxs(Ni,{onSubmit:E=>void x(E),noValidate:!1,children:[a.jsxs(zl,{children:[a.jsx(Et,{control:y,name:"type",render:({field:E})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Choose what you want this trigger to run - a report or a connector",children:"Trigger Type"}),a.jsxs(sa,{onValueChange:j=>{E.onChange(j),m(j)},defaultValue:E.value,disabled:!!n||!!e||!!v("triggerConfig.reportId"),children:[a.jsx(vt,{children:a.jsx(ia,{className:"w-full",children:a.jsx(oa,{placeholder:"Select trigger type"})})}),a.jsxs(la,{children:[a.jsx(Fn,{value:zn.REPORT_RUN,children:"Report Run"}),a.jsx(Fn,{value:zn.CONNECTOR_RUN,children:"Connector Run"})]})]}),a.jsx(on,{children:e?a.jsx(lce,{}):a.jsx(ice,{})}),a.jsx(jt,{})]})}),C&&a.jsx(Et,{control:y,name:"triggerConfig.reportId",render:({field:E})=>a.jsxs(yt,{children:[a.jsx(pt,{tooltip:"Select the report that will be run by this trigger",children:"Report"}),a.jsx(vt,{children:a.jsx(UC,{children:a.jsx(Ble,{value:E.value,onChange:E.onChange,disabled:!!t||!!e})})}),a.jsx(on,{children:e!=null&&e.triggerConfig?a.jsx(cce,{}):a.jsx(uce,{})}),a.jsx(jt,{})]})}),a.jsx(CS,{showPreview:!1,cron:v("cronExpression"),timezone:v("timeZone"),enabled:v("isActive"),onChange:E=>{f.setValue("cronExpression",E.cron,{shouldDirty:!0}),f.setValue("timeZone",E.timezone,{shouldDirty:!0}),f.setValue("isActive",E.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"})]}),a.jsxs(Wc,{children:[a.jsx(we,{variant:"default",type:"submit",className:"w-full","aria-label":e?"Save changes":"Create trigger",disabled:!g||c,children:c?e?"Saving...":"Creating...":e?"Save changes":"Create trigger"}),s&&a.jsx(we,{variant:"outline",type:"button",onClick:s,className:"w-full","aria-label":"Cancel",children:"Cancel"})]})]})})}function fce({cronExpression:e,timeZone:t,isEnabled:n=!0}){const r=h.useMemo(()=>Jle(e,t,n),[e,t,n]);return a.jsxs("div",{children:[a.jsx("div",{children:r}),n&&a.jsx("code",{className:"text-muted-foreground mt-1 block text-xs",children:t})]})}function hce({trigger:e,onEditTrigger:t,onDeleteTrigger:n}){const[r,s]=h.useState(!1),[i,c]=h.useState(!1),u=()=>{c(!1),n(e.id)};return a.jsxs("div",{className:"text-right",onClick:f=>{f.stopPropagation()},children:[a.jsxs(Ar,{open:r,onOpenChange:s,children:[a.jsx(Dr,{asChild:!0,children:a.jsx(we,{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:a.jsx(Ao,{className:"dm-card-table-body-row-actionbtn-icon"})})}),a.jsxs(Or,{align:"end",children:[a.jsxs(Ut,{onClick:()=>{t(e.id)},children:[a.jsx(gd,{className:"text-foreground h-4 w-4","aria-hidden":"true"}),"Edit trigger"]}),a.jsx(ts,{}),a.jsxs(Ut,{onClick:()=>{c(!0)},children:[a.jsx(ss,{className:"h-4 w-4 text-red-600","aria-hidden":"true"}),a.jsx("span",{className:"text-red-600",children:"Delete trigger"})]})]})]}),a.jsx(_r,{open:i,onOpenChange:c,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:u,variant:"destructive"})]})}function mce({connector:e}){const{connectors:t}=Kc(),n=Ire(e,t);return a.jsx(a.Fragment,{children:n})}function AM({connector:e}){return a.jsx(mce,{connector:e})}function pce(e){if(e.length===0)return{lastRunDate:null,lastRunStatus:null,totalRuns:0,firstRunDate:null};const t=e[0],n=e[e.length-1],r=new Date(n.createdAt);return{lastRunDate:new Date(t.createdAt),lastRunStatus:t.status,totalRuns:e.length,firstRunDate:r}}const gce=e=>{const{connectors:t}=Kc();return h.useMemo(()=>t.find(n=>n.name===e),[t,e])},xce=re.memo(function({connector:t,children:n}){const r=gce(t.source.name),{dataMart:s,runs:i,getDataMartRuns:c}=Js();h.useEffect(()=>{s!=null&&s.id&&c(s.id)},[s==null?void 0:s.id,c]);const u=h.useMemo(()=>r!=null&&r.logoBase64?a.jsx(Vc,{base64:r.logoBase64,size:20}):null,[r==null?void 0:r.logoBase64]),f=h.useCallback(()=>{s!=null&&s.storage&&JQ(s.storage,t.storage.fullyQualifiedName)},[s==null?void 0:s.storage,t.storage.fullyQualifiedName]),m=h.useMemo(()=>pce(i),[i]),x=h.useMemo(()=>!m.lastRunDate||!m.lastRunStatus?null:{statusType:Ree(m.lastRunStatus),statusText:Tee(m.lastRunStatus),date:m.lastRunDate},[m]),g=h.useMemo(()=>(s==null?void 0:s.storage)&&eJ(s.storage),[s]),y=h.useMemo(()=>{const v=t.source.fields.length.toString();return`${t.source.node} • ${v} fields`},[t.source.node,t.source.fields.length]);return a.jsxs(Jh,{children:[a.jsx(em,{asChild:!0,children:a.jsx("span",{children:n})}),a.jsxs(tm,{children:[a.jsxs(Zx,{children:[a.jsx($C,{children:u}),a.jsxs(Yx,{children:[a.jsx(Xx,{children:a.jsx(AM,{connector:t})}),a.jsx(Qx,{children:y})]})]}),a.jsxs(Jx,{children:[a.jsxs(fi,{children:[a.jsx(hi,{children:"Last run status:"}),a.jsx(mi,{children:x?a.jsx(jd,{type:x.statusType,variant:"ghost",children:x.statusText}):"Not run yet"})]}),a.jsxs(fi,{children:[a.jsx(hi,{children:"Last run date:"}),a.jsx(mi,{children:x?a.jsx(Es,{date:x.date}):"Never run"})]}),a.jsxs(fi,{children:[a.jsx(hi,{children:"Total runs:"}),a.jsxs(mi,{children:[m.totalRuns," runs",m.firstRunDate&&a.jsxs(a.Fragment,{children:[", since"," ",m.firstRunDate.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})]})]})]})]}),a.jsx(ey,{children:a.jsxs(we,{className:"w-full",variant:"default",onClick:f,title:"Open Storage","aria-label":"Open Storage",children:[g,a.jsx(yi,{className:"ml-1 inline h-4 w-4","aria-hidden":"true"})]})})]})]})},(e,t)=>e.connector.source.name===t.connector.source.name&&e.connector.storage.fullyQualifiedName===t.connector.storage.fullyQualifiedName&&e.connector.source.node===t.connector.source.node&&e.connector.source.fields.length===t.connector.source.fields.length);function yce(e){const t=e.triggerConfig,n=ha.getInfo(t.report.dataDestination.type).icon;return a.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[a.jsx(n,{className:"h-4 w-4",size:16}),t.report.title,a.jsx(Eee,{report:t.report,children:a.jsx(Ur,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function vce(e){var s;const t=e.triggerConfig,{connector:n}=t.connector,r=(s=n.info)!=null&&s.logoBase64?a.jsx(Vc,{base64:n.info.logoBase64,className:"h-4 w-4",size:16}):a.jsx(Sc,{className:"h-4 w-4",size:16});return a.jsxs("div",{className:"group inline-flex items-center gap-2 whitespace-nowrap",children:[r,a.jsx(AM,{connector:n}),a.jsx(xce,{connector:n,children:a.jsx(Ur,{className:"inline-block h-4 w-4 align-text-bottom opacity-0 transition-opacity duration-200 group-hover:opacity-100"})})]})}function bce({trigger:e}){switch(e.type){case zn.REPORT_RUN:return yce(e);case zn.CONNECTOR_RUN:return vce(e);default:return a.jsx("div",{className:"text-muted-foreground text-sm",children:"—"})}}function Sce({onEditTrigger:e,onDeleteTrigger:t}){return[{accessorKey:"type",size:150,header:"Trigger Type",cell:({row:n})=>{const s=n.getValue("type")===zn.REPORT_RUN?"Report Run":"Connector Run";return a.jsx(Rr,{variant:"outline",children:s})},meta:{title:"Trigger Type"}},{accessorKey:"triggerConfig",size:35,header:"Run Target",cell:({row:n})=>a.jsx(bce,{trigger:n.original}),meta:{title:"Run Target"}},{accessorKey:"cronExpression",size:20,header:"Schedule",cell:({row:n})=>{const r=n.getValue("cronExpression"),s=n.original.timeZone,i=n.getValue("isActive");return a.jsx(fce,{cronExpression:String(r),timeZone:s,isEnabled:i})},meta:{title:"Schedule"}},{accessorKey:"nextRun",size:15,header:"Next Run",cell:({row:n})=>{const r=n.original.nextRun;return a.jsx("div",{className:"text-muted-foreground text-sm",children:r?a.jsx(Es,{date:new Date(r)}):"Not scheduled"})},meta:{title:"Next Run"}},{accessorKey:"lastRun",size:15,header:"Last Run",cell:({row:n})=>{const r=n.original.lastRun;return a.jsx("div",{className:"text-sm",children:r?a.jsx(Es,{date:new Date(r)}):a.jsx("span",{className:"text-muted-foreground text-sm",children:"Never run"})})},meta:{title:"Last Run"}},{accessorKey:"isActive",size:15,header:"Trigger Status",cell:({row:n})=>{const r=n.getValue("isActive");return a.jsx(jd,{type:r?En.SUCCESS:En.NEUTRAL,variant:"ghost",showIcon:!1,children:r?"Enabled":"Disabled"})},meta:{title:"Trigger Status"}},{id:"actions",size:80,header:({table:n})=>a.jsx(qc,{table:n}),cell:({row:n})=>a.jsx(hce,{trigger:n.original,onEditTrigger:e,onDeleteTrigger:t}),meta:{title:"Actions"}}]}function Cce({table:e,onPreviousClick:t,onNextClick:n}){return a.jsxs("div",{className:"dm-card-pagination",role:"navigation","aria-label":"Table pagination",children:[a.jsx(we,{variant:"outline",size:"sm",onClick:t,disabled:!e.getCanPreviousPage(),"aria-label":"Go to previous page",children:"Previous"}),a.jsx(we,{variant:"outline",size:"sm",onClick:n,disabled:!e.getCanNextPage(),"aria-label":"Go to next page",children:"Next"})]})}function GE({isOpen:e,onClose:t,dataMartId:n,preSelectedReportId:r,preSelectedType:s}){Fl(e);const{createScheduledTrigger:i,updateScheduledTrigger:c,selectedTrigger:u}=SM(),{showUnsavedDialog:f,setShowUnsavedDialog:m,handleClose:x,confirmClose:g,handleFormDirtyChange:y,handleFormSubmitSuccess:v}=Zc(t),S=!!u,C=h.useMemo(()=>u?{type:u.type,cronExpression:u.cronExpression,timeZone:u.timeZone,isActive:u.isActive,triggerConfig:u.type===zn.REPORT_RUN?{type:hl.SCHEDULED_REPORT_RUN,reportId:u.triggerConfig.reportId}:null}:void 0,[u]),E=async R=>{S?await c(n,u.id,R.cronExpression,R.timeZone,R.isActive):await i(n,R.type,R.cronExpression,R.timeZone,R.isActive,R.triggerConfig),v()},j=h.useRef(!1);return h.useEffect(()=>{const R=S?"Edit":"Create",T=(u==null?void 0:u.type)??s;e&&!j.current?(De({event:"scheduled_trigger_config_open",category:"ScheduledTrigger",action:R,label:T}),j.current=!0):!e&&j.current&&(De({event:"scheduled_trigger_config_close",category:"ScheduledTrigger",action:R,label:T}),j.current=!1)},[e,S,u,s]),a.jsxs(a.Fragment,{children:[a.jsx(Ei,{open:e,onOpenChange:R=>{R||x()},children:a.jsxs(wi,{children:[a.jsxs(Ri,{children:[a.jsxs(ji,{children:[S?"Edit":"Create"," Scheduled Trigger"]}),a.jsx(Rl,{children:"Configure automatic runs for your reports or connectors."})]}),a.jsx(dce,{preSelectedReportId:r,preSelectedType:s,initialData:C,onSubmit:E,onCancel:x,onDirtyChange:y})]})}),a.jsx(_r,{open:f,onOpenChange:m,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:g,variant:"destructive"})]})}function Ece({triggers:e,dataMartId:t,onEditTrigger:n,onDeleteTrigger:r}){const[s,i]=h.useState(!1),c=h.useCallback(()=>{i(!1)},[]),u=h.useCallback(j=>{r(j)},[r]),f=h.useMemo(()=>Sce({onEditTrigger:n,onDeleteTrigger:u}),[n,u]),{sorting:m,setSorting:x,columnVisibility:g,setColumnVisibility:y}=Bc({columns:f,storageKeyPrefix:"data-mart-scheduled-triggers",defaultSortingColumn:"type"}),v=Dl({data:e,columns:f,getCoreRowModel:Al(),getPaginationRowModel:nm(),onSortingChange:x,getSortedRowModel:Gc(),getFilteredRowModel:Td(),state:{sorting:m,columnVisibility:g},onColumnVisibilityChange:y,enableGlobalFilter:!0,enableColumnResizing:!1}),S=h.useCallback(()=>{v.previousPage()},[v]),C=h.useCallback(()=>{v.nextPage()},[v]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dm-card-table-wrap",children:a.jsxs(Ol,{id:"scheduled-triggers-table",className:"dm-card-table",role:"table","aria-label":"Scheduled Triggers",children:[a.jsx(Il,{className:"dm-card-table-header",children:v.getHeaderGroups().map(j=>a.jsx(Hn,{className:"dm-card-table-header-row",children:j.headers.map(R=>a.jsx(kl,{className:"[&:has([role=checkbox])]:pl-6 [&>[role=checkbox]]:translate-y-[2px]",scope:"col",style:R.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:R.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(R.getSize())}%`},children:R.isPlaceholder?null:typeof R.column.columnDef.header=="function"?R.column.columnDef.header(R.getContext()):R.column.columnDef.header},R.id))},j.id))}),a.jsx(Ml,{className:"dm-card-table-body",children:v.getRowModel().rows.length?v.getRowModel().rows.map((j,R)=>a.jsx(Hn,{onClick:()=>{n(j.original.id)},className:"dm-card-table-body-row group",role:"row","aria-rowindex":R+1,children:j.getVisibleCells().map((T,N)=>a.jsx(Zr,{className:`whitespace-normal ${T.column.id==="actions"?"actions-cell":""}`,role:"cell","aria-colindex":N+1,style:T.column.id==="type"?{width:150,minWidth:150,maxWidth:150}:T.column.id==="actions"?{width:80,minWidth:80,maxWidth:80}:{width:`${String(T.column.getSize())}%`},children:typeof T.column.columnDef.cell=="function"?T.column.columnDef.cell(T.getContext()):T.column.columnDef.cell},T.id))},j.id)):a.jsx(Hn,{children:a.jsx(Zr,{colSpan:f.length,className:"dm-card-table-body-row-empty",role:"cell",children:a.jsx("span",{role:"status","aria-live":"polite",children:"No scheduled triggers yet. Create a trigger to automate data updates"})})})})]})}),a.jsx(Cce,{table:v,onPreviousClick:S,onNextClick:C}),a.jsx(GE,{isOpen:s,onClose:c,dataMartId:t})]})}function wce({dataMartId:e}){const{triggers:t,deleteScheduledTrigger:n,selectScheduledTrigger:r,selectedTrigger:s}=zle(e),[i,c]=h.useState(!1);h.useEffect(()=>{s&&c(!0)},[s]);const u=x=>{const g=t.find(y=>y.id===x);g&&r(g)},f=()=>{c(!1),r(null)},m=async x=>{try{await n(e,x)}catch(g){console.error("Error deleting trigger:",g)}};return a.jsxs(a.Fragment,{children:[a.jsx(Ece,{triggers:t,dataMartId:e,onEditTrigger:u,onDeleteTrigger:x=>void m(x)}),a.jsx(GE,{isOpen:i,onClose:f,dataMartId:e})]})}function BE(){return a.jsx("div",{className:"dm-card-block !gap-1.5 !py-3",children:a.jsxs("div",{className:"text-foreground flex items-start gap-1.5 text-sm",children:[a.jsx(fx,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Time Triggers"}),a.jsxs("p",{className:"text-muted-foreground",children:["Set up automatic runs in the ",a.jsx("span",{className:"font-medium",children:"Triggers"})," tab once you’ve saved and published this Data Mart."]})]})]})})}function tl(e){return e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}function bs(e){return e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Rce(){return a.jsx(Wt,{variant:"common",type:"single",collapsible:!0,className:"text-sm",children:a.jsxs(At,{value:"redshift-schema-permissions",children:[a.jsx(Dt,{className:"text-sm",children:"How to grant permissions for schema creation?"}),a.jsxs(Ot,{children:[a.jsx("p",{className:"mb-2",children:"You need to grant permissions to the IAM user who will be used to upload data."}),a.jsx("p",{className:"mb-2 text-sm font-medium",children:"Grant permissions:"}),a.jsx("pre",{className:"bg-muted overflow-x-auto rounded p-2 text-xs",children:a.jsx("code",{children:'GRANT CREATE ON DATABASE <DATABASE_NAME> TO "IAM:<USERNAME_IN_IAM>";'})}),a.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["Replace ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"<DATABASE_NAME>"})," with your database name and"," ",a.jsx("code",{className:"bg-muted rounded px-1 py-0.5",children:"<USERNAME_IN_IAM>"})," with your IAM username."]}),a.jsxs("p",{className:"mt-2 text-sm",children:["You can find your IAM username in the"," ",a.jsx(Kt,{className:"underline",href:"https://console.aws.amazon.com/iam/",children:"AWS IAM Console"})," ","under the ",a.jsx("strong",{children:"Users"})," tab."]})]})]})})}function jce({dataStorageType:e,target:t,destinationName:n,connectorName:r,onTargetChange:s}){const i=n.replace(/[^a-zA-Z0-9_]/g,"_"),c=r.replace(/[^a-zA-Z0-9_]/g,"_").toLowerCase(),[u,f]=h.useState(""),[m,x]=h.useState(""),[g,y]=h.useState(""),[v,S]=h.useState(null),[C,E]=h.useState(null),[j,R]=h.useState(null),T=h.useRef(!1),N=h.useRef(!1),D=(L,k=!1)=>L.trim()?k&&L.startsWith('"')&&L.endsWith('"')?L.slice(1,-1)?null:"Quoted identifier cannot be empty":/^[A-Za-z][A-Za-z0-9_]*$/.test(L)?null:"Use letters, numbers, and underscores; start with a letter":"This field is required",O=h.useCallback((L,k,B,K,q,F)=>{let I;if(e===xe.SNOWFLAKE&&q){const H=tl(q),ee=tl(k);I=`${L}.${H}.${ee}`}else if(e===xe.AWS_REDSHIFT)if(!q||!k)I="";else{const H=tl(q),ee=tl(k);I=`${H}.${ee}`}else I=`${L}.${k}`;const G=e===xe.SNOWFLAKE?!!(L&&q&&k&&B===null&&F===null&&K===null):e===xe.AWS_REDSHIFT?!!(q&&k&&F===null&&K===null):!!(L&&k&&B===null&&K===null);s({fullyQualifiedName:I,isValid:G})},[s,e]);h.useEffect(()=>{let L="",k="",B="";if(t!=null&&t.fullyQualifiedName){const ee=t.fullyQualifiedName.match(/(?:[^."]+|"[^"]*")+/g)??[];if(e===xe.SNOWFLAKE&&ee.length===3){const fe=ee[0],U=ee[1],V=ee[2];fe&&U&&V&&(L=fe,k=bs(U),B=bs(V))}else if(e===xe.AWS_REDSHIFT){if(ee.length===2){const fe=ee[0],U=ee[1];fe&&U&&(k=bs(fe),B=bs(U))}else if(ee.length===3){const fe=ee[1],U=ee[2];fe&&U&&(k=bs(fe),B=bs(U))}}else if(ee.length>=2){const fe=ee[0],U=ee[1];fe&&U&&(L=fe,B=U)}}else L=`${c}_owox`,e===xe.SNOWFLAKE?k="PUBLIC":e===xe.AWS_REDSHIFT&&(k=`${c}_owox`),B=i;const K=e===xe.AWS_REDSHIFT?null:D(L),q=e===xe.SNOWFLAKE||e===xe.AWS_REDSHIFT&&k?D(k,!0):null,F=D(B,e===xe.SNOWFLAKE||e===xe.AWS_REDSHIFT);f(L),T.current||(x(k),E(q)),N.current||(y(B),R(F)),S(K);const I=e===xe.SNOWFLAKE&&k?`${L}.${tl(k)}.${tl(B)}`:e===xe.AWS_REDSHIFT?k&&B?`${tl(k)}.${tl(B)}`:"":`${L}.${B}`,G=e===xe.SNOWFLAKE?!!(L&&k&&B&&K===null&&q===null&&F===null):e===xe.AWS_REDSHIFT?!!(k&&B&&q===null&&F===null):!!(L&&B&&K===null&&F===null);!T.current&&!N.current&&((t==null?void 0:t.fullyQualifiedName)!==I||t.isValid!==G)&&O(L,B,K,F,k,q)},[t,i,c,e,O]);const _=L=>{f(L);const k=D(L);S(k),O(L,g,k,j,m,C)},M=L=>{T.current=!0,x(L);const k=D(L,!0);E(k),O(u,g,v,j,L,k)},$=L=>{N.current=!0,y(L);const k=D(L,e===xe.SNOWFLAKE||e===xe.AWS_REDSHIFT);R(k),O(u,L,v,k,m,C)};return a.jsxs(gi,{children:[e===xe.GOOGLE_BIGQUERY&&a.jsxs(a.Fragment,{children:[a.jsx(xo,{icon:a.jsx(hO,{}),title:"Google BigQuery",docUrl:"https://docs.owox.com/docs/storages/supported-storages/google-bigquery/",variant:"compact"}),a.jsxs(ci,{title:"Choose where to store your data",children:[a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"dataset-name",tooltip:"Enter dataset name for Google BigQuery where the connector data will be stored.",children:"Dataset name"}),a.jsx(gt,{type:"text",id:"dataset-name",placeholder:"Enter dataset name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!v,"aria-describedby":v?"dataset-name-error":void 0,onChange:L=>{_(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Dataset is auto-created on first run if it doesn’t exist"}),v&&a.jsx("p",{id:"dataset-name-error",className:"text-destructive text-sm",children:v})]}),a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),a.jsx(gt,{type:"text",id:"table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:g,"aria-invalid":!!j,"aria-describedby":j?"table-name-error":void 0,onChange:L=>{$(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),j&&a.jsx("p",{id:"table-name-error",className:"text-destructive text-sm",children:j})]})]})]}),e===xe.AWS_ATHENA&&a.jsxs(a.Fragment,{children:[a.jsx(xo,{icon:a.jsx(mO,{}),title:"AWS Athena",docUrl:"https://docs.owox.com/docs/storages/supported-storages/aws-athena/",variant:"compact"}),a.jsxs(ci,{title:"Choose where to store your data",children:[a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"database-name",tooltip:"Enter database name for Amazon Athena where the connector data will be stored.",children:"Database name"}),a.jsx(gt,{type:"text",id:"database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!v,"aria-describedby":v?"database-name-error":void 0,onChange:L=>{_(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn’t exist"}),v&&a.jsx("p",{id:"database-name-error",className:"text-destructive text-sm",children:v})]}),a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"athena-table-name",tooltip:"Enter table name where the connector data will be stored.",children:"Table name"}),a.jsx(gt,{type:"text",id:"athena-table-name",placeholder:"Enter table name",autoComplete:"off",className:"box-border w-full",value:g,"aria-invalid":!!j,"aria-describedby":j?"athena-table-name-error":void 0,onChange:L=>{$(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn’t exist"}),j&&a.jsx("p",{id:"athena-table-name-error",className:"text-destructive text-sm",children:j})]})]})]}),e===xe.SNOWFLAKE&&a.jsxs(a.Fragment,{children:[a.jsx(xo,{icon:a.jsx(pO,{}),title:"Snowflake",docUrl:"https://docs.owox.com/docs/storages/supported-storages/snowflake/",variant:"compact"}),a.jsxs(ci,{title:"Choose where to store your data",children:[a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"snowflake-database-name",tooltip:"Enter database name for Snowflake where the connector data will be stored.",children:"Database name"}),a.jsx(gt,{type:"text",id:"snowflake-database-name",placeholder:"Enter database name",autoComplete:"off",className:"box-border w-full",value:u,"aria-invalid":!!v,"aria-describedby":v?"snowflake-database-name-error":void 0,onChange:L=>{_(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Database is auto-created on first run if it doesn't exist"}),v&&a.jsx("p",{id:"snowflake-database-name-error",className:"text-destructive text-sm",children:v})]}),a.jsxs(uo,{children:[a.jsx(fa,{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"}),a.jsx(gt,{type:"text",id:"snowflake-schema-name",placeholder:"PUBLIC",autoComplete:"off",className:"box-border w-full",value:m,"aria-invalid":!!C,"aria-describedby":C?"snowflake-schema-name-error":void 0,onChange:L=>{M(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Schema is auto-created on first run if it doesn't exist"}),C&&a.jsx("p",{id:"snowflake-schema-name-error",className:"text-destructive text-sm",children:C})]}),a.jsxs(uo,{children:[a.jsx(fa,{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"}),a.jsx(gt,{type:"text",id:"snowflake-table-name",placeholder:"my_table",autoComplete:"off",className:"box-border w-full",value:g,"aria-invalid":!!j,"aria-describedby":j?"snowflake-table-name-error":void 0,onChange:L=>{$(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn't exist"}),j&&a.jsx("p",{id:"snowflake-table-name-error",className:"text-destructive text-sm",children:j})]})]})]}),e===xe.AWS_REDSHIFT&&a.jsxs(a.Fragment,{children:[a.jsx(xo,{icon:a.jsx(gO,{}),title:"AWS Redshift",docUrl:"https://docs.owox.com/docs/storages/supported-storages/aws-redshift/",variant:"compact"}),a.jsxs(ci,{title:"Choose where to store your data",children:[a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"redshift-schema-name",tooltip:"Enter schema name for Redshift where the connector data will be stored. Identifiers will be quoted automatically to preserve case sensitivity.",children:"Schema name"}),a.jsx(gt,{type:"text",id:"redshift-schema-name",placeholder:"public",autoComplete:"off",className:"box-border w-full",value:m,"aria-invalid":!!C,"aria-describedby":C?"redshift-schema-name-error":void 0,onChange:L=>{M(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Schema is auto-created on first run if it doesn't exist."}),a.jsx(Rce,{}),C&&a.jsx("p",{id:"redshift-schema-name-error",className:"text-destructive text-sm",children:C})]}),a.jsxs(uo,{children:[a.jsx(fa,{required:!0,htmlFor:"redshift-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"}),a.jsx(gt,{type:"text",id:"redshift-table-name",placeholder:"my_table",autoComplete:"off",className:"box-border w-full",value:g,"aria-invalid":!!j,"aria-describedby":j?"redshift-table-name-error":void 0,onChange:L=>{$(L.target.value)},required:!0}),a.jsx("p",{className:"text-muted-foreground text-sm",children:"Table is auto-created on first run if it doesn't exist. Identifiers will be quoted automatically to preserve case sensitivity."}),j&&a.jsx("p",{id:"redshift-table-name-error",className:"text-destructive text-sm",children:j})]})]})]}),a.jsx(ci,{title:"Schedule updates",children:a.jsx(BE,{})})]})}function Tce({onSubmit:e,dataStorageType:t,configurationOnly:n=!1,existingConnector:r=null,mode:s="full",initialStep:i,preselectedConnector:c,onDirtyChange:u}){const[f,m]=h.useState(!1),[x,g]=h.useState(null),[y,v]=h.useState(""),[S,C]=h.useState([]),[E,j]=h.useState(1),[R,T]=h.useState({}),[N,D]=h.useState(!1),[O,_]=h.useState(new Set),[M,$]=h.useState(new Set),{connectors:L,connectorSpecification:k,connectorFields:B,loading:K,loadingSpecification:q,loadingFields:F,error:I,fetchAvailableConnectors:G,fetchConnectorSpecification:H,fetchConnectorFields:ee}=Kc();h.useEffect(()=>{u==null||u(f)},[f,u]);const[fe,U]=h.useState(null),V=h.useMemo(()=>n?[{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"}],[n,s]),z=V.length,W=h.useCallback(async ke=>{!O.has(ke)&&!q&&(_(It=>new Set(It).add(ke)),await H(ke))},[O,q,H]),X=h.useCallback(async ke=>{M.has(ke)||($(It=>new Set(It).add(ke)),await ee(ke))},[M,ee]);h.useEffect(()=>{if(!c||x||L.length===0)return;const ke=L.find(It=>It.name===c);ke&&(g(ke),j(i??2),W(ke.name),!n&&s!=="fields-only"&&X(ke.name))},[c,L,x,i,n,s,W,X]),h.useEffect(()=>{if(L.length===0&&!K&&G(),r&&L.length>0&&!x){const{source:ke,storage:It}=r;v(ke.node),C(ke.fields),T(ke.configuration[0]||{}),U({fullyQualifiedName:It.fullyQualifiedName,isValid:!0});const Z=L.find(ae=>ae.name===ke.name);Z&&(g(Z),W(Z.name),!n&&s!=="fields-only"&&X(Z.name),s==="fields-only"&&X(Z.name))}if(n&&L.length>0&&!x&&!r){const ke=L[0];g(ke),W(ke.name)}},[s,r,L,n,K,G,W,X,x]);const oe=ke=>{g(ke),T({}),D(!1),m(!0),_(It=>{const Z=new Set(It);return Z.delete(ke.name),Z}),W(ke.name),X(ke.name)},J=ke=>{v(ke),C([]),m(!0)},de=(ke,It)=>{C(It?Z=>Z.includes(ke)?Z:[...Z,ke]:Z=>Z.filter(ae=>ae!==ke)),m(!0)},ye=(ke,It)=>{C(It?Z=>{const ae=ke.filter(me=>!Z.includes(me));return[...Z,...ae]}:Z=>Z.filter(ae=>!ke.includes(ae))),m(!0)},Se=ke=>{U(ke),m(!0)},ze=h.useCallback(ke=>{T(ke),m(!0)},[]),Re=h.useCallback(ke=>{D(ke)},[]);h.useEffect(()=>{k&&(k.some(It=>It.required&&It.name!=="Fields")||D(!0))},[k]),h.useEffect(()=>{const ke=V[E-1];x&&De({event:"connector_setup",category:x.name,action:"step",label:ke.title})},[E,x,V]);const Ge=()=>{E<z&&j(E+1)},rt=()=>{E>1&&j(E-1)},Ht=()=>{if(n)return x!==null&&N;if(s==="fields-only")switch(E){case 1:return S.length>0;default:return!1}switch(E){case 1:return x!==null;case 2:return N;case 3:return y!=="";case 4:return S.length>0;case 5:return fe!==null&&fe.fullyQualifiedName!==""&&fe.isValid;default:return!1}},He=()=>E>1,Zt=(ke,It)=>{if(!ke)return It;const Z=ke.find(ae=>ae.name===It);return(Z==null?void 0:Z.destinationName)??It},gn=()=>{if(n&&E===1)return k&&x?a.jsx(MN,{connector:x,connectorSpecification:k,onConfigurationChange:ze,onValidationChange:Re,initialConfiguration:R,loading:q,isEditingExisting:!!(r!=null&&r.source.configuration.length)}):null;if(s==="fields-only")switch(E){case 1:return x&&y&&B?a.jsx(kN,{connector:x,connectorFields:B,selectedField:y,selectedFields:S,onFieldToggle:de,onSelectAllFields:ye}):null;default:return null}switch(E){case 1:return a.jsx(yle,{connectors:L,selectedConnector:x,loading:K,error:I,onConnectorSelect:oe,onConnectorDoubleClick:()=>{j(ke=>ke<z?ke+1:ke)}});case 2:return x&&k?a.jsx(MN,{connector:x,connectorSpecification:k,onConfigurationChange:ze,onValidationChange:Re,initialConfiguration:R,loading:q,isEditingExisting:!1}):null;case 3:return x&&B?a.jsx(Mle,{connectorFields:B,connector:x,selectedField:y,connectorName:x.displayName,loading:F,onFieldSelect:J}):null;case 4:return x&&y&&B?a.jsx(kN,{connector:x,connectorFields:B,selectedField:y,selectedFields:S,onFieldToggle:de,onSelectAllFields:ye}):null;case 5:return y&&B?a.jsx(jce,{dataStorageType:t,destinationName:Zt(B,y),connectorName:(x==null?void 0:x.displayName)??"",target:fe,onTargetChange:Se}):null;default:return null}};return a.jsxs(Xae,{children:[a.jsx(Qae,{children:gn()}),a.jsx(Jae,{variant:"horizontal",children:a.jsx(vle,{currentStep:E,totalSteps:z,canGoNext:Ht(),canGoBack:He(),isLoading:q||F,onNext:Ge,onBack:rt,onFinish:()=>{n&&x?(e({source:{name:x.name,configuration:[R],node:(r==null?void 0:r.source.node)??y,fields:(r==null?void 0:r.source.fields)??S},storage:(r==null?void 0:r.storage)??{fullyQualifiedName:(r==null?void 0:r.storage.fullyQualifiedName)??""}}),De({event:"connector_setup",category:x.name,action:"created",label:"configuration-only"})):s==="fields-only"&&r?(e({source:{...r.source,fields:S},storage:r.storage}),De({event:"connector_setup",category:r.source.name,action:"created",label:"fields-only"})):x&&fe&&(e({source:{name:x.name,configuration:[R],node:y,fields:S},storage:{fullyQualifiedName:fe.fullyQualifiedName}}),De({event:"connector_setup",category:x.name,action:"created",label:"full"})),m(!1)}})})]})}function DM({isOpen:e,onClose:t,dataStorageType:n,onSubmit:r,configurationOnly:s=!1,existingConnector:i=null,mode:c="full",initialStep:u,preselectedConnector:f}){const{showUnsavedDialog:m,setShowUnsavedDialog:x,handleClose:g,confirmClose:y,handleFormDirtyChange:v,handleFormSubmitSuccess:S}=Zc(t);return Fl(e),a.jsxs(a.Fragment,{children:[a.jsx(Ei,{open:e,onOpenChange:C=>{C||g()},children:a.jsxs(wi,{children:[a.jsxs(Ri,{children:[a.jsx(ji,{children:c==="fields-only"?"Connector Fields":i!=null&&i.source.name?"Edit Connector":"Set Up Connector"}),a.jsx(Rl,{children:c==="fields-only"?"Select fields for your Data Mart":i!=null&&i.source.name?"Update configuration":"Follow these steps to set it up"})]}),a.jsx(Tce,{onSubmit:C=>{r(C),S()},dataStorageType:n,configurationOnly:s||c==="configuration-only",existingConnector:i,mode:c,initialStep:u,preselectedConnector:f,onDirtyChange:v})]})}),a.jsx(_r,{open:m,onOpenChange:x,title:"Unsaved Changes",description:"You have unsaved changes. Exit without saving?",confirmLabel:"Yes, leave now",cancelLabel:"No, stay here",onConfirm:y,variant:"destructive"})]})}const qE=({dataStorageType:e,onSubmit:t,children:n,configurationOnly:r=!1,existingConnector:s=null,preset:i,isOpen:c,onClose:u})=>{const[f,m]=h.useState(!1),[x,g]=h.useState(1),[y,v]=h.useState();h.useEffect(()=>{c!==void 0&&m(c)},[c]);const S=()=>{v(void 0),g(1),m(!0)},C=()=>{m(!1),u==null||u()};return h.useEffect(()=>{i&&(i==="connector"?(v(void 0),g(1),m(!0)):(v(i),g(2),m(!0)))},[i]),a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{onClick:S,style:{cursor:"pointer"},children:n}),a.jsx(hd,{children:a.jsx(DM,{isOpen:f,onClose:C,dataStorageType:e,onSubmit:t,configurationOnly:r,existingConnector:s,initialStep:x,preselectedConnector:y})})]})};function _ce({storageType:e,onSetupConnector:t,preset:n,isOpen:r,onClose:s}){return a.jsx(qE,{dataStorageType:e,onSubmit:t,configurationOnly:!1,preset:n,isOpen:r,onClose:s,children:a.jsxs(we,{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:[a.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:a.jsx(YS,{className:"h-4 w-4",strokeWidth:2.25})}),a.jsx("span",{children:"Setup Connector"}),a.jsx(va,{className:"h-6 w-6"})]})})}const Nce=e=>{switch(e){case xe.GOOGLE_BIGQUERY:return"Google BigQuery";case xe.AWS_ATHENA:return"AWS Athena";case xe.SNOWFLAKE:return"Snowflake";case xe.AWS_REDSHIFT:return"AWS Redshift";default:return e}},Vu=e=>typeof e=="object"&&"connector"in e,Pf=e=>{if(!Vu(e))return!1;const{source:t,storage:n}=e.connector,r=!!t.name&&!!t.configuration&&t.configuration.length>0&&!!t.node&&!!t.fields&&t.fields.length>0,s=n.fullyQualifiedName.split("."),i=s.length===2||s.length===3;return r&&i};function Ace({configIndex:e,connectorDef:t,onRemoveConfiguration:n,onUpdateConfiguration:r,totalConfigurations:s,dataStorage:i}){const c=Nl.getInfo(i.type),{connectors:u,fetchAvailableConnectors:f}=Kc();h.useEffect(()=>{f()},[f]);const m=S=>{const C=u.find(E=>E.name===S);if(C!=null&&C.logoBase64)return()=>a.jsx(Vc,{base64:C.logoBase64,size:24})},x=()=>{const S=t.connector.source.node||"No node selected";return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-muted-foreground/75",children:"Data:"})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:S}),a.jsx("span",{className:"text-muted-foreground",children:"•"}),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsxs("span",{className:"text-muted-foreground flex items-center gap-1 font-medium",children:[a.jsx("span",{children:"Edit config"}),a.jsx(va,{className:"h-3 w-3"})]})}),a.jsx(ot,{children:"Edit connector configuration"})]})]})},g=(S,C,E)=>a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[S,":"]})," ",a.jsx(Kt,{href:E,onClick:j=>{j.stopPropagation()},children:C})]}),y=()=>{switch(i.type){case xe.GOOGLE_BIGQUERY:{const S=i.config.projectId,C=t.connector.storage.fullyQualifiedName,E=C.split(".")[0],j=C.split(".")[1],R=ZQ(S,E);return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g("Dataset",E,R),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Table",j,XO(S,E,j)),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Ur,{className:"h-4 w-4"})}),a.jsx(ot,{children:"The dataset and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case xe.AWS_ATHENA:{const S=i.config.region,C=t.connector.storage.fullyQualifiedName,[E,j]=C.split("."),R=`https://console.aws.amazon.com/athena/home?region=${S}#/query-editor`;return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g("Database",E,R),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Table",j,R),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Ur,{className:"h-4 w-4"})}),a.jsx(ot,{children:"The database and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case xe.SNOWFLAKE:{const S=i.config.account,E=t.connector.storage.fullyQualifiedName.split("."),j=E[0],R=E[1],T=E[2],N=`https://${S}.snowflakecomputing.com`,D=`${N}/#/data/databases/${j}`,O=`${N}/#/data/databases/${j}/schemas/${R}`,_=`${N}/#/data/databases/${j}/schemas/${R}/table/${T}`;return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g("Database",j,D),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Schema",bs(R),O),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Table",bs(T),_),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Ur,{className:"h-4 w-4"})}),a.jsx(ot,{children:"The database, schema and table are automatically created during the first run of the data mart, if they don't already exist"})]})]})}case xe.AWS_REDSHIFT:{const S=i.config,E=t.connector.storage.fullyQualifiedName.split(".");let j,R;E.length===3?(j=bs(E[1]),R=bs(E[2])):(j=bs(E[0]),R=bs(E[1]));const T=S.connectionType===dr.SERVERLESS?`Workgroup: ${S.workgroupName}`:`Cluster: ${S.clusterIdentifier}`,N=`https://console.aws.amazon.com/redshiftv2/home?region=${S.region}#query-editor`;return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{children:[a.jsx("span",{className:"text-muted-foreground/75",children:"Region:"})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:S.region})]}),a.jsx("span",{className:"text-muted-foreground",children:"•"}),a.jsxs("span",{children:[a.jsx("span",{className:"text-muted-foreground/75",children:"Database:"})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:S.database})]}),a.jsx("span",{className:"text-muted-foreground",children:"•"}),a.jsxs("span",{children:[a.jsxs("span",{className:"text-muted-foreground/75",children:[T.split(":")[0],":"]})," ",a.jsx("span",{className:"text-muted-foreground font-medium",children:T.split(":")[1].trim()})]}),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Schema",j,N),a.jsx("span",{className:"text-muted-foreground",children:"•"}),g("Table",R,N),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx(Ur,{className:"h-4 w-4"})}),a.jsx(ot,{children:"The 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"}},v=()=>s!==1;return a.jsxs("div",{className:"border-border flex w-full items-center rounded-lg border-1 p-1 dark:bg-white/2",children:[a.jsx("div",{className:"flex-grow",children:a.jsxs("div",{className:"grid grid-cols-2 items-center gap-4",children:[a.jsx(qE,{dataStorageType:i.type,onSubmit:r(e),configurationOnly:!0,existingConnector:{source:{...t.connector.source,configuration:[t.connector.source.configuration[e]]},storage:t.connector.storage},children:a.jsx(mS,{icon:m(t.connector.source.name),title:t.connector.source.name||"Connector",subtitle:x(),className:"bg-background hover:bg-muted min-h-[80px] cursor-pointer border-0 transition-colors hover:shadow-none"})}),a.jsx(mS,{title:Nce(i.type),icon:c.icon,subtitle:y(),className:"bg-background min-h-[80px] cursor-default border-0 hover:shadow-none dark:bg-white/2"})]})}),a.jsx("div",{className:"shrink-0 px-4",children:a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsx("span",{children:a.jsx(we,{type:"button",variant:"ghost",onClick:()=>{v()&&n(e)},disabled:!v(),children:a.jsx(ss,{className:"h-4 w-4"})})})}),!v()&&a.jsx(ot,{children:"Remove last configuration only after adding a new one."})]})})]})}function Dce({storageType:e,onAddConfiguration:t,existingConnector:n}){return a.jsx("div",{children:a.jsx(qE,{dataStorageType:e,onSubmit:r=>{const s=r.source.configuration[0]||{};t(s)},configurationOnly:!0,existingConnector:n?{source:{...n.source,configuration:[]},storage:n.storage}:void 0,children:a.jsxs(we,{type:"button",variant:"outline",className:"dm-card-table-add-field-btn cursor-pointer",children:[a.jsx(aa,{className:"h-4 w-4"}),a.jsx("span",{children:"Configuration"})]})})})}function Oce({control:e,storageType:t,preset:n,autoOpen:r=!1,saveDataMartDefinition:s}){const{dataMart:i,runDataMart:c}=Rs(),{setValue:u,getValues:f,trigger:m}=hE(),[x,g]=h.useState(!1),[y,v]=h.useState(!1);h.useEffect(()=>{r&&v(!0)},[r]);const S=(i==null?void 0:i.status)??vr.DRAFT,C=async q=>{u("definition",q,{shouldDirty:!0,shouldTouch:!0}),await m("definition")&&s&&s()},E=async q=>{const F=q.source,I=q.storage;await C({connector:{source:F,storage:I}})},j=async q=>{if(i){if(i.status.code!==vr.PUBLISHED){_t.error("Manual run is only available for published data marts");return}await c({id:i.id,payload:q})}},R=q=>async F=>{const G=f().definition;if(typeof G=="object"&&Vu(G)){const H=[...G.connector.source.configuration];H[q]=F.source.configuration[0]||{};const ee={connector:{...G.connector,source:{...G.connector.source,configuration:H}}};await C(ee)}},T=async q=>{const I=f().definition;if(typeof I=="object"&&Vu(I)){const G={connector:{...I.connector,source:{...I.connector.source,fields:q.source.fields}}};await C(G)}g(!1)},N=q=>{j({runType:q.runType,data:q.data})},D=q=>{const F=q.connector.source.fields.length;return a.jsxs(we,{type:"button",variant:"outline",onClick:()=>{g(!0)},className:"dm-card-table-add-field-btn cursor-pointer",children:[a.jsx(lF,{className:"h-4 w-4"}),a.jsxs("span",{children:["Edit Fields (",String(F),")"]})]})},[O,_]=h.useState(null),[M,$]=h.useState(!1),L=q=>{_(q),$(!0)},k=async()=>{O!==null&&(await B(O),_(null),$(!1))},B=async q=>{const I=f().definition;if(Vu(I)&&I.connector.source.configuration.length<=1){const G=zE($e.CONNECTOR);await C(G)}if(typeof I=="object"&&Vu(I)&&I.connector.source.configuration.length>1){const G={...I.connector.source,configuration:I.connector.source.configuration.filter((ee,fe)=>fe!==q)},H={connector:{...I.connector,source:G}};await C(H)}},K=async q=>{const I=f().definition;if(Vu(I)){const G={...I.connector.source,configuration:[...I.connector.source.configuration,q]},H={connector:{...I.connector,source:G}};await C(H)}};return a.jsxs(a.Fragment,{children:[a.jsx(Et,{control:e,name:"definition",render:({field:q})=>a.jsxs(yt,{className:"dark:bg-white/2",children:[a.jsx(vt,{children:a.jsx("div",{className:"space-y-3",children:!Pf(q.value)||S===vr.DRAFT?a.jsx(_ce,{storageType:t,onSetupConnector:F=>{E(F),v(!1)},preset:n,isOpen:y,onClose:()=>{v(!1)}}):a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Dce,{storageType:t,onAddConfiguration:F=>void K(F),existingConnector:Pf(q.value)?{source:q.value.connector.source,storage:q.value.connector.storage}:void 0}),Pf(q.value)&&D(q.value)]}),a.jsx("div",{className:"flex items-center gap-2",children:(i==null?void 0:i.definitionType)===$e.CONNECTOR&&a.jsx(hS,{configuration:i.definition,onManualRun:N,children:a.jsxs(we,{variant:"outline",children:[a.jsx(Dh,{className:"h-4 w-4"}),a.jsx("span",{children:"Manual Run..."})]})})})]}),a.jsx("div",{className:"space-y-3",children:Pf(q.value)&&(i!=null&&i.storage)?q.value.connector.source.configuration.map((F,I)=>{const G=q.value;return a.jsx(hd,{children:a.jsx(Ace,{configIndex:I,connectorDef:G,dataStorage:i.storage,onRemoveConfiguration:H=>{L(H)},onUpdateConfiguration:H=>R(H),dataMartStatus:typeof S=="object"?S.code:S,totalConfigurations:G.connector.source.configuration.length},I)},I)}):null})]})})}),a.jsx(jt,{})]})}),a.jsx(hd,{children:a.jsx(DM,{isOpen:x,onClose:()=>{g(!1)},onSubmit:q=>void T(q),dataStorageType:t,existingConnector:Pf(f().definition)?{source:f().definition.connector.source,storage:f().definition.connector.storage}:void 0,mode:"fields-only"})}),a.jsx(_r,{open:M,onOpenChange:$,title:"Delete Configuration",description:"Are you sure you want to delete this configuration? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{k()},onCancel:()=>{_(null)},variant:"destructive"})]})}function Ice({definitionType:e,storageType:t,preset:n,saveDataMartDefinition:r}){const{control:s}=hE(),[i,c]=h.useState(!1);return h.useEffect(()=>{e===$e.CONNECTOR&&!n?c(!0):c(!1)},[e,n]),a.jsxs("div",{className:"space-y-2",children:[e===$e.SQL&&a.jsx(hle,{control:s}),e===$e.TABLE&&a.jsx(mle,{control:s,storageType:t}),e===$e.VIEW&&a.jsx(ple,{control:s,storageType:t}),e===$e.TABLE_PATTERN&&a.jsx(gle,{control:s,storageType:t}),e===$e.CONNECTOR&&a.jsx(Oce,{control:s,storageType:t,preset:n,autoOpen:i,saveDataMartDefinition:r})]})}function OM(){const[e]=r4(),t=e.get("preset");return h.useMemo(()=>{if(!t)return;const n=t.toLowerCase();return sne(n)},[t])}function Mce(e,t){const[n,r]=h.useState(e);return h.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const kce=1e3,Lce=[es.SUCCESS,es.ERROR,es.CANCELLED];function Pce(e){const[t,n]=h.useState(!1),[r,s]=h.useState(null),i=h.useRef({triggerId:null,abortController:null}),c=h.useCallback(g=>i.current.triggerId===g,[]),u=h.useCallback(g=>{s({isValid:!1,error:g instanceof Error?g.message:"Validation failed"}),n(!1)},[]),f=h.useCallback(async()=>{const{triggerId:g,abortController:y}=i.current;if(g){y==null||y.abort(),i.current={triggerId:null,abortController:null},s(null),n(!1);try{await Tn.abortSqlDryRunTrigger(e,g)}catch(v){console.error("Failed to cancel trigger:",v)}}},[e]),m=h.useCallback(async(g,y)=>{for(;!y.aborted&&c(g);)try{const v=await Tn.getSqlDryRunTriggerStatus(e,g);if(Lce.includes(v)){const S=await Tn.getSqlDryRunTriggerResponse(e,g);s({isValid:S.isValid,error:S.error??void 0,bytes:S.bytes}),n(!1),i.current={triggerId:null,abortController:null};return}await new Promise(S=>setTimeout(S,kce))}catch(v){u(v),i.current={triggerId:null,abortController:null};return}},[e,c,u]),x=h.useCallback(async g=>{await f(),n(!0),s(null);try{const{triggerId:y}=await Tn.createSqlDryRunTrigger(e,g),v=new AbortController;i.current={triggerId:y,abortController:v},await m(y,v.signal)}catch(y){u(y)}},[e,f,m,u]);return h.useEffect(()=>()=>{const{triggerId:g,abortController:y}=i.current;y==null||y.abort(),g&&Tn.abortSqlDryRunTrigger(e,g).catch(()=>{})},[e]),{validateSql:x,isLoading:t,result:r,cancel:f}}const Uce=300;function zce({sql:e,dataMartId:t,debounceDelay:n=Uce,className:r="",onValidationStateChange:s}){const i=Mce(e.trim(),n),{validateSql:c,isLoading:u,result:f,cancel:m}=Pce(t);h.useEffect(()=>{if(!i){m();const g={isLoading:!1,isValid:null,error:null,bytes:null};s==null||s(g);return}c(i)},[i,c,m,s]),h.useEffect(()=>{const g={isLoading:u,isValid:(f==null?void 0:f.isValid)??null,error:(f==null?void 0:f.error)??null,bytes:(f==null?void 0:f.bytes)??null};s==null||s(g)},[u,f,s]);const x=()=>u?a.jsxs("div",{className:"flex h-5 items-center gap-2",children:[a.jsx(Uc,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:"Validating..."})]}):f?f.isValid?a.jsxs("div",{className:"flex h-5 items-center gap-2",children:[a.jsx(GU,{className:"h-4 w-4 text-green-600"}),a.jsx("span",{className:"text-sm font-medium text-green-600",children:"Valid SQL code"}),f.bytes!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mx-1 text-gray-400",children:"•"}),a.jsxs(at,{children:[a.jsx(st,{asChild:!0,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Sc,{className:"h-3 w-3 text-gray-600"}),a.jsx("span",{className:"text-xs text-gray-600",children:lee(f.bytes)})]})}),a.jsx(ot,{children:a.jsx("p",{className:"text-xs",children:"This is an estimated volume and may differ from the actual value"})})]})]})]}):a.jsxs("div",{className:"flex h-9 items-center gap-2",children:[a.jsx(Kf,{className:"h-4 w-4 flex-shrink-0 text-red-600"}),f.error&&a.jsx("span",{className:"text-xs text-red-500",children:f.error})]}):a.jsxs("div",{className:"flex h-5 items-center gap-2 text-gray-500",children:[a.jsx(Sc,{className:"h-4 w-4"}),a.jsx("span",{className:"text-sm",children:"Type a query to get started"})]});return a.jsx("div",{className:`inline-flex h-9 items-center px-3 py-2 ${r}`,children:x()})}const Fce={isValid:null,isLoading:!1,error:null},Hce=(e,t)=>{if(e!==$e.SQL)return"";const n=t;return(n==null?void 0:n.sqlQuery)??""},$ce=e=>zE(e);function Vce({definitionType:e,initialDefinitionType:t,setDefinitionType:n}){const{dataMart:r,updateDataMartDefinition:s,runSchemaActualization:i}=Rs(),c=OM();if(!r)throw new Error("Data mart not found");const{definition:u,id:f,storage:{type:m}}=r,[,x]=h.useState(Fce),[g,y]=h.useState(!1),v=h.useCallback(()=>{if(!e)return;const K={definitionType:e,definition:zE(e)};return u?{definitionType:e,definition:u}:K},[e,u]),S=h.useCallback(()=>{if(!e)return;const K=fle(e,m);return Ai(K)},[e,m]),C=ko({resolver:S(),defaultValues:v(),mode:"onChange"}),{handleSubmit:E,reset:j,watch:R,formState:{isDirty:T,isValid:N}}=C,D=R("definition"),O=Hce(e,D);h.useEffect(()=>{e&&j(v())},[e,j,v]),h.useEffect(()=>{if(!e&&!t&&(c!=null&&c.definitionType)){n(c.definitionType);const K={definitionType:c.definitionType,definition:$ce(c.definitionType)};j(K)}},[c,e,t,j,n]);const _=h.useCallback(K=>{x({isLoading:K.isLoading,isValid:K.isValid,error:K.error})},[]),M=h.useCallback(K=>{n(K)},[n]),$=h.useCallback(async K=>{if(e&&f)try{await s(f,K.definitionType,K.definition),y(!0),j(K)}catch(q){console.error("Failed to update data mart definition:",q)}},[f,e,s,j]);h.useEffect(()=>{g&&(y(!1),i==null||i())},[g,i]);const L=h.useCallback(K=>{K==null||K.preventDefault(),E($)(K)},[E,$]),k=h.useCallback(()=>{j(v())},[j,v]),B=()=>e?a.jsxs("form",{onSubmit:L,className:"space-y-4",children:[a.jsx(Ice,{definitionType:e,storageType:m,preset:c==null?void 0:c.connectorSourceTitle,saveDataMartDefinition:L}),e!==$e.CONNECTOR&&a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(we,{variant:"default",type:"submit",disabled:!N||!T,children:"Save"}),a.jsx(we,{type:"button",variant:"ghost",onClick:k,disabled:!T,children:"Discard"}),e===$e.SQL&&O&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"h-6 w-px bg-gray-300"}),a.jsx(zce,{sql:O,dataMartId:f,onValidationStateChange:_})]})]})]}):null;return a.jsx(BI,{...C,children:a.jsxs("div",{className:"space-y-4",children:[!t&&a.jsx(ole,{initialType:e,onTypeSelect:M}),B()]})})}function Gce(e){switch(e){case xe.GOOGLE_BIGQUERY:return{type:"bigquery-data-mart-schema",fields:[]};case xe.AWS_ATHENA:return{type:"athena-data-mart-schema",fields:[]};case xe.SNOWFLAKE:return{type:"snowflake-data-mart-schema",fields:[]};case xe.AWS_REDSHIFT:return{type:"redshift-data-mart-schema",fields:[]};default:throw new Error(`Unsupported storage type: ${e}`)}}function IM(e){return e.type==="bigquery-data-mart-schema"}function MM(e){return e.type==="athena-data-mart-schema"}function kM(e){return e.type==="snowflake-data-mart-schema"}function PN(e){return e!==null&&typeof e=="object"&&"mode"in e}function UN(e){return e!==null&&typeof e=="object"&&"isPrimaryKey"in e}function zN(e){return e!==null&&typeof e=="object"&&"isPrimaryKey"in e&&!("mode"in e)}function LM(e){return e.type==="redshift-data-mart-schema"}function FN(e){return e!==null&&typeof e=="object"&&"isPrimaryKey"in e&&!("mode"in e)}function Bce(e){return e==null?"":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):""}function Z1(e){return e==null?e:JSON.parse(JSON.stringify(e))}function qce(e){const t=Z1(e),[n,r]=h.useState(t),[s,i]=h.useState(!1);h.useEffect(()=>{const f=Z1(e);r(f),i(!1)},[e]);const c=h.useCallback(f=>{n?IM(n)&&f.every(PN)?(r({...n,fields:f}),i(!0)):MM(n)&&f.every(UN)?(r({...n,fields:f}),i(!0)):kM(n)&&f.every(zN)?(r({...n,fields:f}),i(!0)):LM(n)&&f.every(FN)&&(r({...n,fields:f}),i(!0)):f.length>0&&(PN(f[0])?(r({type:"bigquery-data-mart-schema",fields:f}),i(!0)):UN(f[0])?(r({type:"athena-data-mart-schema",fields:f}),i(!0)):zN(f[0])?(r({type:"snowflake-data-mart-schema",fields:f}),i(!0)):FN(f[0])&&(r({type:"redshift-data-mart-schema",fields:f}),i(!0)))},[n]),u=h.useCallback(()=>{const f=Z1(e);r(f),i(!1)},[e]);return{schema:n,isDirty:s,updateSchema:c,resetSchema:u,setIsDirty:i}}function Kce(e,t){const n=h.useRef(!1),r=h.useRef(!1),[s,i]=h.useState("idle");return h.useEffect(()=>{e||(n.current||r.current)&&(i(t?"error":"success"),n.current=!1,r.current=!1)},[e,t]),{operationStatus:s,startSaveOperation:()=>{n.current=!0,i("idle")},startActualizeOperation:()=>{r.current=!0,i("idle")},resetOperationStatus:()=>{i("idle")}}}function Wce(e){const t=h.useMemo(()=>Array.isArray(e)?Object.fromEntries(e.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)):{},[e]),[n,r]=h.useState({});return h.useEffect(()=>{r(t)},[t]),{columnVisibility:n,setColumnVisibility:r,defaultHiddenColumns:t}}function PM(e,t){const n=e.name?e.name.toLowerCase().includes(t):!1,r=e.alias?e.alias.toLowerCase().includes(t):!1,s=e.description?e.description.toLowerCase().includes(t):!1;if(n||r||s)return!0;const i=e;return i.fields&&i.fields.length>0?i.fields.some(c=>PM(c,t)):!1}function UM(e,t,n=""){const r=[];return e.forEach((s,i)=>{const c=n?`${n}.${String(i)}`:String(i),u=s.name?s.name.toLowerCase().includes(t):!1,f=s.alias?s.alias.toLowerCase().includes(t):!1,m=s.description?s.description.toLowerCase().includes(t):!1;if((u||f||m)&&r.push(c),s.fields&&s.fields.length>0){const x=UM(s.fields,t,c);x.length>0&&(r.includes(c)||r.push(c),r.push(...x))}}),r}function Zce(e,t,n){const r=e.original;if(!n)return!0;const s=n.toLowerCase();return PM(r,s)}function Yce(e){const[t,n]=h.useState(""),r=h.useCallback(i=>{n(i),e.setGlobalFilter(i)},[e]),s=t.toLowerCase();return{value:t,onChange:r,searchValue:s}}function Xce(e){const[t,n]=h.useState(new Set),[r,s]=h.useState(null),i=h.useRef(""),c=h.useMemo(()=>{const S=C=>C.some(E=>E.type===cr.RECORD||E.type===cr.STRUCT||E.fields&&S(E.fields));return S(e)},[e]),u=h.useCallback(S=>{n(C=>{const E=new Set(C);return E.has(S)?E.delete(S):E.add(S),E})},[]),f=h.useCallback(()=>{const S=[],C=(E,j="")=>{E.forEach((R,T)=>{const N=j?`${j}.${String(T)}`:String(T);(R.type===cr.RECORD||R.type===cr.STRUCT)&&R.fields&&R.fields.length>0&&(S.push(N),C(R.fields,N))})};C(e),n(E=>S.every(R=>E.has(R))?new Set:new Set(S))},[e]),m=h.useMemo(()=>{const S=[],C=(E,j="",R=0)=>{E.forEach((T,N)=>{const D=j?`${j}.${String(N)}`:String(N),O=T.type===cr.RECORD||T.type===cr.STRUCT;S.push({...T,path:D,level:R}),O&&T.fields&&t.has(D)&&C(T.fields,D,R+1)})};return C(e),S},[e,t]),x=h.useCallback(S=>{if(S!==i.current)if(i.current=S,S){r===null&&s(new Set(t));const E=UM(e,S).filter(j=>{const R=j.split(".").map(Number);let T=e,N;for(let D=0;D<R.length;D++){if(N=T[R[D]],!N)return!1;if((N.type===cr.RECORD||N.type===cr.STRUCT)&&N.fields&&N.fields.length>0)return!0;D<R.length-1&&(T=N.fields??[])}return!1});n(j=>{const R=new Set(j);return E.forEach(T=>{R.add(T)}),R})}else r!==null&&(n(r),s(null))},[e,t,r]),g=h.useCallback(S=>{const C=m[S];return C.type===cr.RECORD||C.type===cr.STRUCT},[m]),y=h.useMemo(()=>e.map(S=>({...S,fields:void 0})),[e]),v=h.useMemo(()=>{const S=[],C=(E,j="")=>{E.forEach((R,T)=>{const N=j?`${j}.${String(T)}`:String(T);(R.type===cr.RECORD||R.type===cr.STRUCT)&&R.fields&&R.fields.length>0&&(S.push(N),C(R.fields,N))})};return C(e),S.length===0?!1:S.every(E=>t.has(E))},[e,t]);return{expandedRecords:t,hasRecordFields:c,toggleRecordExpansion:u,toggleAllRecords:f,flattenedFields:m,handleSearchChange:x,isRecordType:g,topLevelFields:y,allExpanded:v}}function Qce(e,t,n,r){const s=h.useCallback((f,m)=>{if(n){const x=[...e],g=t[f].path;if(!g)x[f]={...x[f],...m};else{const y=g.split(".").map(Number);let v=x,S;for(let E=0;E<y.length-1;E++)S=v[y[E]],v=S.fields??[];const C=y[y.length-1];v[C]&&(v[C]={...v[C],...m})}n(x)}},[e,t,n]),i=h.useCallback(()=>{if(n){const f={name:"",type:cr.STRING,mode:ph.NULLABLE,isPrimaryKey:!1,status:Oa.DISCONNECTED};n([...e,f])}},[e,n]),c=h.useCallback(f=>{if(n){const m=[...e],x=t[f].path;if(!x)m.splice(f,1);else{const g=x.split(".").map(Number);let y=m,v;for(let C=0;C<g.length-1;C++)v=y[g[C]],y=v.fields??[];const S=g[g.length-1];y.splice(S,1)}n(m)}},[e,t,n]),u=h.useCallback(f=>{var m,x;if(n&&r){const g=[...e],y=t[f].path,v={name:"",type:cr.STRING,mode:ph.NULLABLE,isPrimaryKey:!1,status:Oa.DISCONNECTED};if(!y)(m=g[f]).fields??(m.fields=[]),g[f].fields.push(v);else{const S=y.split(".").map(Number);let C=g;for(let E=0;E<S.length;E++){const j=S[E];E===S.length-1?((x=C[j]).fields??(x.fields=[]),C[j].fields.push(v)):C=C[j].fields??[]}}n(g)}},[e,t,n,r]);return{updateField:s,handleAddRow:i,handleDeleteRow:c,handleAddNestedField:u}}function yy(e,t,n){return{handleDragEnd:h.useCallback(s=>{const{active:i,over:c}=s;if(!c||i.id===c.id||!t)return;if(!n){const y=Number(i.id),v=Number(c.id),S=[...e],[C]=S.splice(y,1);S.splice(v,0,C),t(S);return}const u=n.findIndex((y,v)=>(y.path??String(v))===i.id),f=n.findIndex((y,v)=>(y.path??String(v))===c.id);if(u===-1||f===-1)return;const m=n[u].path,x=n[f].path,g=[...e];if(!m&&!x){const[y]=g.splice(u,1);g.splice(f,0,y),t(g);return}if(m&&x){const y=m.split(".").map(Number),v=x.split(".").map(Number);if(y.length===v.length&&y.slice(0,-1).join(".")===v.slice(0,-1).join(".")){let S=g;for(let R=0;R<y.length-1;R++)S=S[y[R]].fields??[];const C=y[y.length-1],E=v[v.length-1],[j]=S.splice(C,1);S.splice(E,0,j),t(g)}}},[e,n,t])}}function Jce(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const vy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ad(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function KE(e){return"nodeType"in e}function ka(e){var t,n;return e?Ad(e)?e:KE(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function WE(e){const{Document:t}=ka(e);return e instanceof t}function lm(e){return Ad(e)?!1:e instanceof ka(e).HTMLElement}function zM(e){return e instanceof ka(e).SVGElement}function Dd(e){return e?Ad(e)?e.document:KE(e)?WE(e)?e:lm(e)||zM(e)?e.ownerDocument:document:document:document}const No=vy?h.useLayoutEffect:h.useEffect;function ZE(e){const t=h.useRef(e);return No(()=>{t.current=e}),h.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function eue(){const e=h.useRef(null),t=h.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=h.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function xh(e,t){t===void 0&&(t=[e]);const n=h.useRef(e);return No(()=>{n.current!==e&&(n.current=e)},t),n}function cm(e,t){const n=h.useRef();return h.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qg(e){const t=ZE(e),n=h.useRef(null),r=h.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function ES(e){const t=h.useRef();return h.useEffect(()=>{t.current=e},[e]),t.current}let Y1={};function um(e,t){return h.useMemo(()=>{if(t)return t;const n=Y1[e]==null?0:Y1[e]+1;return Y1[e]=n,e+"-"+n},[e,t])}function FM(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((i,c)=>{const u=Object.entries(c);for(const[f,m]of u){const x=i[f];x!=null&&(i[f]=x+e*m)}return i},{...t})}}const nd=FM(1),Jg=FM(-1);function tue(e){return"clientX"in e&&"clientY"in e}function YE(e){if(!e)return!1;const{KeyboardEvent:t}=ka(e.target);return t&&e instanceof t}function nue(e){if(!e)return!1;const{TouchEvent:t}=ka(e.target);return t&&e instanceof t}function wS(e){if(nue(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return tue(e)?{x:e.clientX,y:e.clientY}:null}const yh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[yh.Translate.toString(e),yh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),HN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function rue(e){return e.matches(HN)?e:e.querySelector(HN)}const aue={display:"none"};function sue(e){let{id:t,value:n}=e;return re.createElement("div",{id:t,style:aue},n)}function oue(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;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 re.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function iue(){const[e,t]=h.useState("");return{announce:h.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const HM=h.createContext(null);function lue(e){const t=h.useContext(HM);h.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function cue(){const[e]=h.useState(()=>new Set),t=h.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[h.useCallback(r=>{let{type:s,event:i}=r;e.forEach(c=>{var u;return(u=c[s])==null?void 0:u.call(c,i)})},[e]),t]}const uue={draggable:`
package/dist/index.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <link rel="icon" type="image/png" href="/favicon.png" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>OWOX</title>
9
- <script type="module" crossorigin src="/assets/index-DcwU88EJ.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-CSorzK6f.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-7dcghnJW.css">
11
11
  </head>
12
12
  <body translate="no" class="notranslate">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owox/web",
3
- "version": "0.18.0-next-20260127111051",
3
+ "version": "0.18.0-next-20260127120603",
4
4
  "description": "Web interface for OWOX Data Marts - an open-source solution for Data Analysts",
5
5
  "author": "OWOX",
6
6
  "license": "ELv2",