var k=Object.defineProperty;var g=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var j=(t,n,c)=>n in t?k(t,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):t[n]=c,r=(t,n)=>{for(var c in n||(n={}))A.call(n,c)&&j(t,c,n[c]);if(g)for(var c of g(n))O.call(n,c)&&j(t,c,n[c]);return t};import{b as o,_ as a,z as m,j as e}from"./main.2.8.10.js";import{b}from"./react-router.DMwpH23k.js";import{r as p}from"./index.DpWdl9V1.js";import{S as x}from"./SingleToggle2.DKPfQeBV.js";import{S as F}from"./SnackMsg.7BjcJK1j.js";import"./react-vendor.P7K3d6op.js";function G(){const[t,n]=b.useState({}),[c,f]=b.useState(null),[N,v]=b.useState({show:!1});b.useEffect(()=>{const i=o({},"analytics/check","","GET").then(s=>{s!=null&&s.success&&f(s.data)}),l=o({},"get/config",null,"GET").then(s=>("success"in s&&s.success&&n(s.data),s!=null&&s.success?a("Successfully fetched","bit-integrations"):"Error"));Promise.all([i,l]).catch(s=>{console.error(s)}),m.promise(l,{success:s=>s,error:a("Error Occurred","bit-integrations"),loading:a("Fetching...")})},[]);const y=i=>{const l=r({},t),s=o({data:l},"app/config").then(d=>{if("success"in d&&d.success)return a("Save successfully done","bit-integrations");delete l[i],n(r({},l))}).catch(()=>a("Failed to save","bit-integrations"));m.promise(s,{success:d=>d,error:a("Error Occurred","bit-integrations"),loading:a("Updating...")})},w=i=>{o({isChecked:i},"analytics/optIn").then(l=>{m.success(a("Opt-in status updated","bit-integrations"))}).catch(()=>{m.error(a("Failed to save","bit-integrations"))})},u=p.useAsyncDebounce(y,500),_=p.useAsyncDebounce(w,500),h=({target:{name:i,checked:l}})=>{const s=r({},t);l?s[i]=!0:delete s[i],n(s),u(i)},S=({target:{name:i,value:l}})=>{const s=r({},t);l?s[i]=l:delete s[i],n(s),u(i)},E=()=>{const i=!c;f(i),_(i)};return e.jsxs("div",{className:"btcd-f-settings",children:[e.jsx(F,{snack:N,setSnackbar:v}),e.jsxs("div",{id:"btcd-settings-wrp",className:"btcd-s-wrp",children:[e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsx("div",{children:e.jsxs("b",{children:[e.jsx("span",{className:"btcd-icn  icn-trash-fill mr-2"}),a("Erase all data of this plugin in deletion","bit-integrations")]})}),e.jsx(x,{action:h,name:"erase_db",checked:t==null?void 0:t.erase_db,className:"flx"})]}),e.jsx("br",{})]}),c!==null&&e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsxs("div",{className:"flx flx-start",children:[e.jsx("span",{className:"btcd-icn icn-information-outline mr-2"}),e.jsxs("div",{children:[e.jsx("b",{children:a("Opt In Telemetry Data","bit-integrations")}),e.jsx("br",{}),e.jsx("small",{children:a("If you turn off, Bit Integrations will no longer collect any telemetry data","bit-integrations")})]})]}),e.jsx(x,{action:E,name:"erase_db",checked:c,className:"flx"})]}),e.jsx("br",{})]}),e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsx("div",{className:"",children:e.jsxs("b",{children:[e.jsx("span",{className:"btcd-icn icn-trash-fill mr-2"}),a("Specify after how many days  old log will be deleted","bit-integrations")]})}),e.jsxs("div",{className:"flx",children:[e.jsx("input",{onChange:S,name:"day",value:t==null?void 0:t.day,disabled:!t.enable_log_del,className:"btcd-paper-inp mr-2 wdt-100",placeholder:"Day",type:"number",min:"1"}),e.jsx(x,{action:h,name:"enable_log_del",checked:t==null?void 0:t.enable_log_del,className:"flx"})]})]}),e.jsx("br",{})]}),e.jsx("div",{className:"w-6 mt-3",children:e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsxs("div",{className:"flx flx-start",children:[e.jsx("span",{className:"btcd-icn icn-email mr-2"}),e.jsxs("div",{children:[e.jsx("b",{children:a("Enable Email Notifications for Failed Integrations","bit-integrations")}),e.jsx("br",{}),e.jsx("small",{children:a("When enabled, you will receive an email notification to the admin email whenever an integration execution fails","bit-integrations")})]})]}),e.jsx(x,{action:h,name:"enable_failure_email",checked:t==null?void 0:t.enable_failure_email,className:"flx"})]})}),e.jsx("div",{className:"mb-50"})]})]})}export{G as default};
