import{a as Ce,b as g,c as Fe,r as u,u as Ae,d as Oe,e as Ue,t as De,f as Ge}from"../chunks/BGnnHgKo.js";import{f as _,e as b,a as h,b as p}from"../chunks/CWb4Vnhz.js";import{i as Te}from"../chunks/CCsGeFPC.js";import{p as $e,m as I,f as Ke,g as Ne,t as L,j as t,a as je,k as R,s as a,c as s,o as x,e as c,r as n,n as Pe,q as m}from"../chunks/CQO205-B.js";import{p as Ie,i as Y}from"../chunks/C98uKxzC.js";import{e as Le,i as Re,a as d}from"../chunks/CsANhQOh.js";async function Ye(){try{return{settings:await Ce.getSettings()}}catch(y){return console.error("Failed to load settings:",y),{settings:{environments:[],settings:{backup_path:"",default_environment_id:null}},error:"Failed to load settings"}}}const et=Object.freeze(Object.defineProperty({__proto__:null,load:Ye},Symbol.toStringTag,{value:"Module"}));var qe=_('
'),ze=_('

Warning

No Superset environments configured. You must add at least one environment to perform backups or migrations.

'),Be=_(' '),Me=_(''),We=_('

Settings

Global Settings

Superset Environments

NameURLUsernameDefaultActions

');function tt(y,q){$e(q,!1);let v=Ie(q,"data",8),i=I(v().settings),o=I({id:"",name:"",url:"",username:"",password:"",is_default:!1}),l=I(null);async function le(){try{console.log("[Settings.handleSaveGlobal][Action] Saving global settings."),await Ae(t(i).settings),d("Global settings saved","success"),console.log("[Settings.handleSaveGlobal][Coherence:OK] Global settings saved.")}catch(e){console.error("[Settings.handleSaveGlobal][Coherence:Failed] Failed to save global settings:",e),d("Failed to save global settings","error")}}async function ce(){try{console.log(`[Settings.handleAddOrUpdateEnv][Action] ${t(l)?"Updating":"Adding"} environment.`),t(l)?(await Oe(t(l),t(o)),d("Environment updated","success")):(await Ue(t(o)),d("Environment added","success")),z(),location.reload(),console.log("[Settings.handleAddOrUpdateEnv][Coherence:OK] Environment saved.")}catch(e){console.error("[Settings.handleAddOrUpdateEnv][Coherence:Failed] Failed to save environment:",e),d("Failed to save environment","error")}}async function ve(e){if(confirm("Are you sure you want to delete this environment?"))try{console.log(`[Settings.handleDeleteEnv][Action] Deleting environment: ${e}`),await Ge(e),d("Environment deleted","success"),location.reload(),console.log("[Settings.handleDeleteEnv][Coherence:OK] Environment deleted.")}catch(r){console.error("[Settings.handleDeleteEnv][Coherence:Failed] Failed to delete environment:",r),d("Failed to delete environment","error")}}async function ue(e){try{console.log(`[Settings.handleTestEnv][Action] Testing environment: ${e}`);const r=await De(e);r.status==="success"?(d("Connection successful","success"),console.log("[Settings.handleTestEnv][Coherence:OK] Connection successful.")):(d(`Connection failed: ${r.message}`,"error"),console.log("[Settings.handleTestEnv][Coherence:Failed] Connection failed."))}catch(r){console.error("[Settings.handleTestEnv][Coherence:Failed] Error testing connection:",r),d("Failed to test connection","error")}}function pe(e){x(o,{...e}),x(l,e.id)}function z(){x(o,{id:"",name:"",url:"",username:"",password:"",is_default:!1}),x(l,null)}Ke(()=>R(v()),()=>{x(i,v().settings)}),Ne(),Te();var k=We(),B=a(s(k),2);{var me=e=>{var r=qe(),f=s(r,!0);n(r),L(()=>p(f,(R(v()),c(()=>v().error)))),h(e,r)};Y(B,e=>{R(v()),c(()=>v().error)&&e(me)})}var E=a(B,2),M=a(s(E),2),S=s(M),W=a(s(S),2);u(W),n(S);var ge=a(S,2);n(M),n(E);var H=a(E,2),J=a(s(H),2);{var be=e=>{var r=ze();h(e,r)};Y(J,e=>{t(i),c(()=>t(i).environments.length===0)&&e(be)})}var C=a(J,2),Q=s(C),V=a(s(Q));Le(V,5,()=>(t(i),c(()=>t(i).environments)),Re,(e,r)=>{var f=Be(),K=s(f),ye=s(K,!0);n(K);var N=a(K),we=s(N,!0);n(N);var j=a(N),ke=s(j,!0);n(j);var P=a(j),Ee=s(P,!0);n(P);var oe=a(P),de=s(oe),ie=a(de,2),Se=a(ie,2);n(oe),n(f),L(()=>{p(ye,(t(r),c(()=>t(r).name))),p(we,(t(r),c(()=>t(r).url))),p(ke,(t(r),c(()=>t(r).username))),p(Ee,(t(r),c(()=>t(r).is_default?"Yes":"No")))}),b("click",de,()=>ue(t(r).id)),b("click",ie,()=>pe(t(r))),b("click",Se,()=>ve(t(r).id)),h(e,f)}),n(V),n(Q),n(C);var X=a(C,2),F=s(X),fe=s(F);n(F);var A=a(F,2),O=s(A),U=a(s(O),2);u(U),n(O);var D=a(O,2),Z=a(s(D),2);u(Z),n(D);var G=a(D,2),ee=a(s(G),2);u(ee),n(G);var T=a(G,2),te=a(s(T),2);u(te),n(T);var $=a(T,2),ae=a(s($),2);u(ae),n($);var re=a($,2),ne=s(re);u(ne),Pe(2),n(re),n(A);var se=a(A,2),w=s(se),he=s(w);n(w);var xe=a(w,2);{var _e=e=>{var r=Me();b("click",r,z),h(e,r)};Y(xe,e=>{t(l)&&e(_e)})}n(se),n(X),n(H),n(k),L(()=>{p(fe,`${t(l)?"Edit":"Add"} Environment`),U.disabled=!!t(l),p(he,`${t(l)?"Update":"Add"} Environment`)}),g(W,()=>t(i).settings.backup_path,e=>m(i,t(i).settings.backup_path=e)),b("click",ge,le),g(U,()=>t(o).id,e=>m(o,t(o).id=e)),g(Z,()=>t(o).name,e=>m(o,t(o).name=e)),g(ee,()=>t(o).url,e=>m(o,t(o).url=e)),g(te,()=>t(o).username,e=>m(o,t(o).username=e)),g(ae,()=>t(o).password,e=>m(o,t(o).password=e)),Fe(ne,()=>t(o).is_default,e=>m(o,t(o).is_default=e)),b("click",w,ce),h(y,k),je()}export{tt as component,et as universal};