import{m as c}from"./vendor-ui-CflGdlft.js";document.addEventListener("alpine:init",()=>{c.data("settingsComponent",()=>({sidebarVisible:!1,activeSection:"general",storageUsed:47.3,storageTotal:100,settings:{language:"en",timezone:"America/New_York",dateFormat:"MM/DD/YYYY",autoSave:!0,theme:"light",collapsedSidebar:!1,animations:!0,highContrast:!1,notifications:{desktop:!0,email:!0,sound:!1,marketing:!1},privacy:{analytics:!0,performance:!0,activityHistory:!0},storage:{autoCleanup:!0,cacheLimit:"1000"}},sections:[{id:"general",name:"General",icon:"bi-gear"},{id:"appearance",name:"Appearance",icon:"bi-palette"},{id:"notifications",name:"Notifications",icon:"bi-bell"},{id:"privacy",name:"Privacy",icon:"bi-shield-check"},{id:"storage",name:"Storage",icon:"bi-hdd"}],init(){const e=document.documentElement.getAttribute("data-bs-theme")||localStorage.getItem("theme")||"light";this.settings.theme=e,this.loadSettings()},get storagePercentage(){return this.storageUsed/this.storageTotal*100},get storageRemaining(){return(this.storageTotal-this.storageUsed).toFixed(1)},loadSettings(){const e=localStorage.getItem("appSettings");if(e)try{const t=JSON.parse(e),{theme:i,...s}=t;this.settings={...this.settings,...s}}catch(t){console.warn("Failed to load saved settings:",t)}},saveSettings(){try{localStorage.setItem("appSettings",JSON.stringify(this.settings)),this.showNotification("Settings saved successfully!","success"),this.settings.theme&&(document.documentElement.setAttribute("data-bs-theme",this.settings.theme),localStorage.setItem("theme",this.settings.theme))}catch(e){this.showNotification("Failed to save settings","error"),console.error("Failed to save settings:",e)}},resetSettings(){confirm("Are you sure you want to reset all settings to their default values? This action cannot be undone.")&&(this.settings={language:"en",timezone:"America/New_York",dateFormat:"MM/DD/YYYY",autoSave:!0,theme:"light",collapsedSidebar:!1,animations:!0,highContrast:!1,notifications:{desktop:!0,email:!0,sound:!1,marketing:!1},privacy:{analytics:!0,performance:!0,activityHistory:!0},storage:{autoCleanup:!0,cacheLimit:"1000"}},localStorage.removeItem("appSettings"),document.documentElement.setAttribute("data-bs-theme","light"),this.showNotification("Settings reset to defaults","success"))},setActiveSection(e){this.activeSection=e},toggleSidebar(){this.sidebarVisible=!this.sidebarVisible},setTheme(e){this.settings.theme=e,document.documentElement.setAttribute("data-bs-theme",e),this.saveSettings()},clearCache(){this.showNotification("Cache cleared successfully","success"),this.storageUsed=Math.max(this.storageUsed-5,30)},optimizeStorage(){this.showNotification("Storage optimized successfully","success"),this.storageUsed=Math.max(this.storageUsed-2,35)},exportData(e){const t={settings:this.settings,exportDate:new Date().toISOString(),format:e};let i,s,o;switch(e){case"json":i=JSON.stringify(t,null,2),s="application/json",o="settings-export.json";break;case"csv":i=this.convertToCSV(t),s="text/csv",o="settings-export.csv";break;case"pdf":this.showNotification("PDF export would be generated here","info");return;case"xml":i=this.convertToXML(t),s="application/xml",o="settings-export.xml";break;default:this.showNotification("Unsupported export format","error");return}const a=new Blob([i],{type:s}),n=URL.createObjectURL(a),r=document.createElement("a");r.href=n,r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),this.showNotification(`Data exported as ${e.toUpperCase()}`,"success")},convertToCSV(e){const t=[];t.push("Setting,Value");const i=(s,o="")=>{for(const a in s)typeof s[a]=="object"&&s[a]!==null?i(s[a],o+a+"."):t.push(`${o}${a},${s[a]}`)};return i(e.settings),t.join(`
`)},convertToXML(e){const t=(i,s=0)=>{let o="";const a="  ".repeat(s);for(const n in i)typeof i[n]=="object"&&i[n]!==null?(o+=`${a}<${n}>
`,o+=t(i[n],s+1),o+=`${a}</${n}>
`):o+=`${a}<${n}>${i[n]}</${n}>
`;return o};return`<?xml version="1.0" encoding="UTF-8"?>
<export>
${t(e,1)}</export>`},showNotification(e,t="info"){typeof Swal<"u"?Swal.fire({title:e,icon:t==="success"?"success":t==="error"?"error":t==="warning"?"warning":"info",toast:!0,position:"top-end",showConfirmButton:!1,timer:3e3}):alert(e)}})),c.data("searchComponent",()=>({query:"",results:[],search(){console.log("Searching for:",this.query),this.results=[]}})),c.data("themeSwitch",()=>({currentTheme:"light",init(){this.currentTheme=localStorage.getItem("theme")||"light",document.documentElement.setAttribute("data-bs-theme",this.currentTheme)},toggle(){this.currentTheme=this.currentTheme==="light"?"dark":"light",document.documentElement.setAttribute("data-bs-theme",this.currentTheme),localStorage.setItem("theme",this.currentTheme)}})),c.data("themeSwitch",()=>({currentTheme:"light",init(){this.currentTheme=document.documentElement.getAttribute("data-bs-theme")||localStorage.getItem("theme")||"light"},toggle(){this.currentTheme=this.currentTheme==="light"?"dark":"light",document.documentElement.setAttribute("data-bs-theme",this.currentTheme),localStorage.setItem("theme",this.currentTheme)}}))});
