import{r as R,Y as D,Z as N,_ as F,a0 as C,a1 as E,a2 as z,a3 as O,a4 as _,R as u,a5 as j,a6 as A,j as a,i as b,T as m,a7 as T,a8 as B,a9 as V,aa as H,ab as I}from"./index-BX768Frx.js";import{T as M}from"./tag-DIbqHQC5.js";import{$ as Q,a as U}from"./useToggleState-DWs3jB3l.js";import{u as G}from"./useSuspenseQuery-Br7OCbDP.js";import{M as L}from"./main-B6XIaWoX.js";import"./useBaseQuery-DCSHiJ5h.js";function Y(i,e,t){let{labelProps:s,inputProps:r,isSelected:n,isPressed:l,isDisabled:d,isReadOnly:o}=Q(i,e,t);return{labelProps:s,inputProps:{...r,role:"switch",checked:n},isSelected:n,isPressed:l,isDisabled:d,isReadOnly:o}}const Z=R.createContext(null),q=R.forwardRef(function(e,t){let{inputRef:s=null,...r}=e;[e,t]=D(r,t,Z);let n=N(F(s,e.inputRef!==void 0?e.inputRef:null)),l=U(e),{labelProps:d,inputProps:o,isSelected:p,isDisabled:h,isReadOnly:x,isPressed:g}=Y({...C(e),children:typeof e.children=="function"?!0:e.children},l,n),{isFocused:$,isFocusVisible:v,focusProps:S}=E(),k=e.isDisabled||e.isReadOnly,{hoverProps:w,isHovered:y}=z({...e,isDisabled:k}),P=O({...e,defaultClassName:"react-aria-Switch",values:{isSelected:p,isPressed:g,isHovered:y,isFocused:$,isFocusVisible:v,isDisabled:h,isReadOnly:x,state:l}}),c=_(e,{global:!0});return delete c.id,delete c.onClick,u.createElement("label",{...j(c,d,w,P),ref:t,slot:e.slot||void 0,"data-selected":p||void 0,"data-pressed":g||void 0,"data-hovered":y||void 0,"data-focused":$||void 0,"data-focus-visible":v||void 0,"data-disabled":h||void 0,"data-readonly":x||void 0},u.createElement(A,{elementType:"span"},u.createElement("input",{...j(o,S),ref:n})),P.children)});function f({title:i,description:e,...t}){return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(q,{...t,className:b("group flex gap-2",t.className),children:({isSelected:s})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{className:b("relative inline-flex h-6 w-10 shrink-0 cursor-pointer rounded-full border-3 border-transparent transition-colors duration-200 ease-in-out group-data-disabled:cursor-default","group-data-selected:bg-accent group-data-selected:hover:bg-accent-hover bg-zinc-200 group-data-disabled:bg-zinc-300 dark:bg-zinc-600 group-data-disabled:dark:bg-zinc-800","group-data-focus-visible:outline-accent group-data-focus-visible:outline-2 group-data-focus-visible:outline-offset-2"),children:a.jsx("div",{className:b("pointer-events-none inline-block size-4.5 transform rounded-full bg-white shadow-sm transition duration-200 ease-in-out group-data-disabled:bg-zinc-200 group-data-disabled:dark:bg-zinc-700",s&&"translate-x-4")})}),i&&a.jsx(m,{as:"div",size:"md",weight:"medium",className:"text-primary",children:i})]})}),e&&a.jsx(m,{as:"div",size:"sm",className:"text-secondary ml-12",children:e})]})}function te(){const i=G(V()),e=T.useNavigate(),t=B();return i.data.__type==="unauthenticated"?(e({to:"/login",search:{returnUrl:t.state.location.pathname}}),null):a.jsx(J,{alertingSettings:i.data.configuration})}function J({alertingSettings:i}){const e=H(),t=I({defaultValues:{enabled:i.enabled,email:i.email_report},onSubmit:s=>{e.mutate({enabled:s.value.enabled,email_report:s.value.email},{onError:()=>{t.reset()}})}});return a.jsx(L,{title:"Settings",children:a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx(m,{weight:"medium",className:"text-secondary",children:"Alerting properties"}),a.jsxs("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),t.handleSubmit()},className:"flex flex-col gap-4",children:[a.jsx(t.Field,{name:"enabled",children:s=>a.jsx(f,{"aria-label":`${s.state.value?"Disable":"Enable"} alerting service at plakar.io`,title:a.jsxs(a.Fragment,{children:["Enable alerting service at"," ",a.jsx("strong",{className:"text-accent",children:"plakar.io"})]}),description:"Securely send concise task summaries to your account on our servers—your backup data stays on your side.",isSelected:s.state.value,onChange:s.handleChange,onBlur:s.handleBlur}),listeners:{onChange:t.handleSubmit}}),i.enabled&&a.jsx(t.Field,{name:"email",children:s=>a.jsx(f,{"aria-label":`${s.state.value?"Disable":"Receive"} alerts by email`,title:"Receive alerts by email",description:"Get issue notifications and weekly backup summaries—only metadata, never your actual data.",isSelected:s.state.value,onChange:s.handleChange,onBlur:s.handleBlur}),listeners:{onChange:t.handleSubmit}}),a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(f,{"aria-label":"Enable alerting to custom webhook",title:"Enable alerting to custom webhook",description:"Send alerts to your own webhook URL for custom processing.",isDisabled:!0}),a.jsx(M,{variant:"brand",leftIcon:"bell",children:"Available soon"})]})]})]})})}export{te as component};
