import{t as e}from"./http-BrugN6o-.js";import{n as t,t as n}from"./notification-BM55Quw3.js";import{t as r}from"./error-handling-CRDNZ9kr.js";var i=(i=!1)=>{let a=i?window.pinia.defineStore:t,{global:o}=window.i18n;return a(`mail-driver`,{state:()=>({mailConfigData:null,mail_driver:`smtp`,mail_drivers:[],basicMailConfig:{mail_driver:``,mail_host:``,from_mail:``,from_name:``},mailgunConfig:{mail_driver:``,mail_mailgun_domain:``,mail_mailgun_secret:``,mail_mailgun_endpoint:``,from_mail:``,from_name:``},sesConfig:{mail_driver:``,mail_host:``,mail_port:null,mail_ses_key:``,mail_ses_secret:``,mail_ses_region:``,from_mail:``,from_name:``},smtpConfig:{mail_driver:``,mail_host:``,mail_port:null,mail_username:``,mail_password:``,mail_encryption:``,from_mail:``,from_name:``}}),actions:{fetchMailDrivers(){return new Promise((t,n)=>{e.get(`/api/v1/mail/drivers`).then(e=>{e.data&&(this.mail_drivers=e.data),t(e)}).catch(e=>{r(e),n(e)})})},fetchMailConfig(){return new Promise((t,n)=>{e.get(`/api/v1/mail/config`).then(e=>{e.data&&(this.mailConfigData=e.data,this.mail_driver=e.data.mail_driver),t(e)}).catch(e=>{r(e),n(e)})})},updateMailConfig(t){return new Promise((i,a)=>{e.post(`/api/v1/mail/config`,t).then(e=>{let t=n();e.data.success?t.showNotification({type:`success`,message:o.t(`wizard.success.`+e.data.success)}):t.showNotification({type:`error`,message:o.t(`wizard.errors.`+e.data.error)}),i(e)}).catch(e=>{r(e),a(e)})})},sendTestMail(t){return new Promise((i,a)=>{e.post(`/api/v1/mail/test`,t).then(e=>{let t=n();e.data.success?t.showNotification({type:`success`,message:o.t(`general.send_mail_successfully`)}):t.showNotification({type:`error`,message:o.t(`validation.something_went_wrong`)}),i(e)}).catch(e=>{r(e),a(e)})})}}})()};export{i as t};