1import{r as n,a as R,j as e,aN as he,aD as te,u as fe}from"./index-L9AYrVUw.js";import{p as ae,L as ge,aF as ne,d as $,aJ as xe,u as V,aQ as be,$ as ve,W as q,f6 as ye,U as re,N as we,aA as Ce,f7 as je,m as C,C as b,R as F,aB as Ne,aE as se}from"./PlanAccessModal-P_W2GThH.js";import{w as Ae,S as W,x as Ee,y as Se,z as ke,D as Le}from"./App-DyVHSnY3.js";import{s as P}from"./productFunnel-DiJFcMU2.js";import{B as _e,P as Re}from"./BillingCycleToggle-CYks6Uh5.js";import{n as Ie}from"./Camera.es-8HNgckmU.js";import{p as Pe}from"./ChartLineUp.es-Cj6aI3xb.js";import{n as Te}from"./User.es-DVlkNLFL.js";import{u as oe,c as J,S as k}from"./locale-Cctu0V3Y.js";import{n as Me}from"./Trash.es-D2Zs5Rpt.js";import{D as Ze,a as De,b as Oe,c as He,m as Ue,p as Fe}from"./FloatingTopMenu-CIhwk2RR.js";import"./index-p7aFGi8o.js";import"./dissolve-CQo8GAUH.js";import"./SnewLogo-Cg53XTnQ.js";import"./segmented-tabs--x9EQobi.js";const $e=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,44H32A20,20,0,0,0,12,64V192a20,20,0,0,0,20,20H224a20,20,0,0,0,20-20V64A20,20,0,0,0,224,44Zm-4,24V88H36V68ZM36,188V112H220v76Zm172-24a12,12,0,0,1-12,12H164a12,12,0,0,1,0-24h32A12,12,0,0,1,208,164Zm-68,0a12,12,0,0,1-12,12H116a12,12,0,0,1,0-24h12A12,12,0,0,1,140,164Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M232,96v96a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V96Z",opacity:"0.2"}),n.createElement("path",{d:"M224,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48Zm0,16V88H32V64Zm0,128H32V104H224v88Zm-16-24a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h32A8,8,0,0,1,208,168Zm-64,0a8,8,0,0,1-8,8H120a8,8,0,0,1,0-16h16A8,8,0,0,1,144,168Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48ZM136,176H120a8,8,0,0,1,0-16h16a8,8,0,0,1,0,16Zm64,0H168a8,8,0,0,1,0-16h32a8,8,0,0,1,0,16ZM32,88V64H224V88Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,50H32A14,14,0,0,0,18,64V192a14,14,0,0,0,14,14H224a14,14,0,0,0,14-14V64A14,14,0,0,0,224,50ZM32,62H224a2,2,0,0,1,2,2V90H30V64A2,2,0,0,1,32,62ZM224,194H32a2,2,0,0,1-2-2V102H226v90A2,2,0,0,1,224,194Zm-18-26a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h32A6,6,0,0,1,206,168Zm-64,0a6,6,0,0,1-6,6H120a6,6,0,0,1,0-12h16A6,6,0,0,1,142,168Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48Zm0,16V88H32V64Zm0,128H32V104H224v88Zm-16-24a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h32A8,8,0,0,1,208,168Zm-64,0a8,8,0,0,1-8,8H120a8,8,0,0,1,0-16h16A8,8,0,0,1,144,168Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M224,52H32A12,12,0,0,0,20,64V192a12,12,0,0,0,12,12H224a12,12,0,0,0,12-12V64A12,12,0,0,0,224,52ZM32,60H224a4,4,0,0,1,4,4V92H28V64A4,4,0,0,1,32,60ZM224,196H32a4,4,0,0,1-4-4V100H228v92A4,4,0,0,1,224,196Zm-20-28a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h32A4,4,0,0,1,204,168Zm-64,0a4,4,0,0,1-4,4H120a4,4,0,0,1,0-8h16A4,4,0,0,1,140,168Z"}))]]),Be=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z",opacity:"0.2"}),n.createElement("path",{d:"M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,
1146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z"}))]]),ie=n.forwardRef((t,r)=>n.createElement(ae,{ref:r,...t,weights:$e}));ie.displayName="CreditCardIcon";const Ve=ie,le=n.forwardRef((t,r)=>n.createElement(ae,{ref:r,...t,weights:Be}));le.displayName="PlugsConnectedIcon";const ze=le;function X({view:t="plan"}){const r=ge(),s=ne(),{user:a}=$(),[o,i]=n.useState(!1),[d,m]=n.useState("yearly"),{lang:u}=R(),c=u==="pt-BR"?{compare:"Compare os planos",compareDetail:"As alterações são aplicadas pelo Stripe. Reduções de plano entram em vigor ao fim do perÃodo atual.",viewPlans:"Ver planos",manage:"Gerenciar assinatura",opening:"Abrindo cobrançaâ¦",loading:"Carregando seu planoâ¦",unavailable:"Não foi possÃvel carregar seu plano.",retry:"Tentar novamente",portalError:"Não foi possÃvel abrir o gerenciamento da assinatura. Tente novamente.",checkoutError:"Não foi possÃvel abrir o checkout. Tente novamente."}:{compare:"Compare plans",compareDetail:"Changes are applied through Stripe. Downgrades take effect at the end of the current period.",viewPlans:"View plans",manage:"Manage subscription",opening:"Opening billingâ¦",loading:"Loading your planâ¦",unavailable:"We couldn't load your plan.",retry:"Try again",portalError:"We couldnât open billing management. Try again.",checkoutError:"We couldnât open checkout. Try again."};n.useEffect(()=>{s.status==="ready"&&s.billingCycle&&m(s.billingCycle)},[s.status,s.billingCycle]);async function x(){if(!(!(a!=null&&a.teamId)||o)){i(!0);try{const{data:f,error:p}=await P.functions.invoke("billing-checkout",{body:{action:"portal",teamId:a.teamId}});if(p)throw p;const l=new URL(f==null?void 0:f.url);if(l.protocol!=="https:"||l.hostname!=="billing.stripe.com")throw Error("INVALID_PORTAL_URL");window.location.assign(l.href)}catch{V.error(c.portalError)}finally{i(!1)}}}async function h(f,p){if(!(!(a!=null&&a.teamId)||o)){i(!0);try{const l=await be(a.teamId,f,p);window.location.assign(l)}catch{V.error(c.checkoutError)}finally{i(!1)}}}const g=["owner","admin"].includes((a==null?void 0:a.role)??"");return e.jsxs("section",{className:"credit-usage-panel","data-no-translate":!0,children:[t==="credits"&&e.jsx(Ae,{credits:s,onRetry:()=>
1{r.invalidateQueries({queryKey:["billing-snapshot"]})}}),t==="plan"&&s.status!=="ready"&&e.jsxs("div",{className:"credit-usage-state",role:"status",children:[e.jsx("strong",{children:s.status==="error"?c.unavailable:c.loading}),s.status==="error"&&e.jsx("button",{className:"credit-usage-button",onClick:()=>{r.invalidateQueries({queryKey:["billing-snapshot"]})},children:c.retry})]}),t==="plan"&&s.status==="ready"&&e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:c.compare}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:c.compareDetail})]}),e.jsx(_e,{value:d,onChange:m})]}),e.jsx("div",{className:"mt-4 grid gap-4",style:{gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))"},children:he.map(f=>e.jsx(Re,{plan:te[f],cycle:d,currentPlan:s.plan,surface:"settings",canManage:g&&!o,onCheckout:p=>{(p==="starter"||p==="pro")&&h(p,d)},onDowngrade:()=>void x()},f))})]}),s.status==="ready"&&e.jsxs("div",{className:"credit-usage-actions",children:[e.jsx("button",{className:"credit-usage-button",onClick:()=>xe({trigger:"manual"}),children:c.viewPlans}),t==="plan"&&e.jsx("button",{className:"credit-usage-button",disabled:o||!["owner","admin"].includes((a==null?void 0:a.role)??""),onClick:x,children:o?c.opening:c.manage})]})]})}async function qe(t,r,s={}){var i,d;const{data:a,error:o}=await P.functions.invoke("user-profile",{body:{action:t,expectedUpdatedAt:r,...s},timeout:3e4});if(o||!(a!=null&&a.ok)){let m=a==null?void 0:a.error;try{m??(m=(d=await((i=o==null?void 0:o.context)==null?void 0:i.json()))==null?void 0:d.error)}catch{}const u={session_expired:"Your session expired. Sign in again.",profile_conflict_reload:"Your profile changed in another tab. Reload your profile and try again.",profile_conflict_or_update_failed:"Your profile could not be saved. Reload your profile and try again.",profile_name_invalid:"Enter a name with no more than 160 characters.",avatar_too_large:"Choose an image smaller than 5 MB.",avatar_invalid_png:"This image could not be processed. Choose another JPEG, PNG, or WebP image.",profile_missing_save_name_first:"Save your name before adding a photo.",profile_request_failed:"Unable to save your profile. Please retry."};throw new Error(u[m]||"Unable to save profile. Check your connection and retry.")}if(window.dispatchEvent(new Event("snew:profile-changed")),typeof BroadcastChannel<"u"){const m=new BroadcastChannel("snew-profile");m.postMessage("changed"),m.close()}}async function We(t){if(!["image/jpeg","image/png","image/webp"].includes(t.type))throw new Error("Choose a JPEG, PNG, or WebP image.");if(!t.size||t.size>5*1024*1024)throw new Error("Choose an image smaller than 5 MB.");const r=await createImageBitmap(t);try{if(!r.width||!r.height||r.width*r.height>16e6)throw new Error("Choose an image with fewer than 16 million pixels.");const s=Math.min(1,512/Math.max(r.width,r.height)),a=document.createElement("canvas");a.width=Math.max(1,Math.round(r.width*s)),a.height=Math.max(1,Math.round(r.height*s));const o=a.getContext("2d");if(!o)throw new Error("Image conversion unavailable");return o.drawImage(r,0,0,a.width,a.height),a.toDataURL("image/png").split(",")[1]}finally{r.close()}}var Ye=Object.defineProperty,_=(t,r)=>Ye(t,"name",{value:r,configurable:!0}),Y="Switch",[Ge,Pt]=ve(Y),[Qe,G]=Ge(Y);function ce(t){const{__scopeSwitch:r,checked:s,children:a,defaultChecked:o,disabled:i,form:d,name:m,onCheckedChange:u,required:c,value:x="on",internal_do_not_use_render:h}=t,[g,f]=we({prop:s,defaultProp:o??!1,onChange:u,caller:Y}),[p,l]=n.useState(null),[w,v]=n.useState(null),j=n.useRef(!1),[y,N]=n.useReducer(E=>E+1,0),L=p?!!d||!!p.closest("form"):!0,S={checked:g,setChecked:f,disabled:i,control:p,setControl:l,name:m,form:d,value:x,hasConsumerStoppedPropagationRef:j,userInteractionCount:y,onUserInteraction:N,required:c,defaultChecked:o,isFormControl:L,bubbleInput:w,setBubbleInput:v};return e.jsx(Qe,{scope:r,...S,children:ue(h)?h(S):a})}_(ce,"SwitchProvider");var Ke="SwitchTrigger",Je=n.forwardRef(_(function({__scopeSwitch:r,onClick:s,...a},o){const{control:i,form:d,value:m,disabled:u,checked:c,required:x,setControl:h,setChecked:g,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:l,bubbleInput:w}=G(Ke,r),v=oe(o,h),j=n.useRef(c);return n.useEffect(()=>{const y=d?i==null?void 0:i.ownerDocument.getElementById(d):i==null?void 0:i.form;if(y instanceof HTMLFormElement){const N=_(()=>g(j.current),"reset");return y.addEventListener("reset",N),()=>y.removeEventListener("reset",N)}},[i,d,g]),e.jsx(q.button,{type:"button",role:"switch","aria-checked":c,"aria-required":x,"data-state":Q(c),"data-disabled":u?"":void 0,disabled:u,value:m,...a,ref:v,onClick:re(s,y=>{p(),g(N=>!N),w&&l&&(f.current=y.isPropagationStopped(),f.current||y.stopPropagation())})})},"SwitchTrigger")),de=n.forwardRef(_(function(r,s){const{__scopeSwitch:a,name:o,checked:i,defaultChecked:d,required:m,disabled:u,value:c,onCheckedChange:x,form:h,...g}=r;return e.jsx(ce,{__scopeSwitch:a,checked:i,defaultChecked:d,disabled:u,required:m,onCheckedChange:x,name:o,form:h,value:c,internal_do_not_use_render:({isFormControl:f})=>e.jsxs(e.Fragment,{children:[e.jsx(Je,{...g,ref:s,__scopeSwitch:a}),f&&e.jsx(at,{__scopeSwitch:a})]})})},"Switch")),Xe="SwitchThumb",et=n.forwardRef(_(function(r,s){const{__scopeSwitch:a,...o}=r,i=G(Xe,a);return e.jsx(q.span,{"data-state":Q(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:s})},"SwitchThumb")),tt="SwitchBubbleInput",at=n.forwardRef(_(function({__scopeSwitch:r,onClick:s,...a},o){const{control:i,hasConsumerStoppedPropagationRef:d,userInteractionCount:m,checked:u,defaultChecked:c,required:x,disabled:h,name:g,value:f,form:p,bubbleInput:l,setBubbleInput:w}=G(tt,r),v=oe(o,w),j=ye(i),y=n.useRef(!1),N=n.useRef(u),L=n.useRef(m);n.useEffect(()=>{const E=l;if(!E)return;const D=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(D,"checked").set,T=m!==L.current;L.current=m;const O=N.current!==u;N.current=u;const B=!(T&&d.current);if(O&&I){y.current=!T;const H=new Event("click",{bubbles:B});I.call(E,u),E.dispatchEvent(H),y.current=!1}},[l,u,d,m]);const S=n.useRef(u);return e.jsx(q.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??S.current,required:x,disabled:h,name:g,value:f,form:p,...a,tabIndex:-1,ref:v,onClick:re(s,E=>{y.current&&E.stopPropagation()}),style:{...a.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})}
1,"SwitchBubbleInput"));function ue(t){return typeof t=="function"}_(ue,"isFunction");function Q(t){return t?"checked":"unchecked"}_(Q,"getState");const me=n.forwardRef(({className:t,...r},s)=>e.jsx(de,{className:J("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...r,ref:s,children:e.jsx(et,{className:J("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));me.displayName=de.displayName;function nt({store:t,storeError:r,onConnect:s}){const{lang:a}=R(),o=a==="pt-BR"?{unavailable:"Conexão da loja indisponÃvel",connected:"conectada",platforms:"Shopify ou Nuvemshop",aria:"Conexão da loja",label:"Loja",title:"Loja virtual",change:"Alterar",connect:"Conectar",changeAria:"Alterar loja conectada",connectAria:"Conectar Shopify ou Nuvemshop"}:{unavailable:"Store connection unavailable",connected:"connected",platforms:"Shopify or Nuvemshop",aria:"Store connection",label:"Store",title:"Online store",change:"Change",connect:"Connect",changeAria:"Change connected store",connectAria:"Connect Shopify or Nuvemshop"},i=!r&&t&&Ce(t.source)?t:null,d=r?o.unavailable:i?`${i.domain||i.name} · ${je(i.source)} ${o.connected}`:o.platforms;return e.jsxs("section",{"data-no-translate":!0,"aria-label":o.aria,children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:`hsl(${b.text.tertiary})`,marginBottom:C[2]},children:o.label}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:C[3],padding:C[4],border:`1px solid hsl(${b.border.secondary})`,borderRadius:F.lg,background:`hsl(${b.bg.primary})`},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:F.md,background:i?`hsl(${b.bg.success})`:`hsl(${b.bg.secondary})`,display:"flex",alignItems:"center",justifyContent:"center",color:i?`hsl(${b.text.success})`:`hsl(${b.text.tertiary})`,flexShrink:0},children:e.jsx(Ne,{size:20,weight:i?"fill":"regular"})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:`hsl(${b.text.primary})`},children:o.title}),e.jsx("div",{style:{fontSize:12,color:r?`hsl(${b.text.danger})`:`hsl(${b.text.tertiary})`,marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:r||d,children:d})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":i?o.changeAria:o.connectAria,style:{fontFamily:"inherit",fontSize:13,fontWeight:500,padding:`${C[2]} ${C[4]}`,borderRadius:F.pill,border:`1px solid hsl(${b.border.secondary})`,background:`hsl(${b.bg.primary})`,color:`hsl(${b.text.primary})`,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:i?o.change:o.connect})]})]})}const z="[email protected]";function rt(t){return t==="pt-BR"?{title:"Privacidade e dados",description:"Solicite uma cópia dos dados associados à sua conta. O pedido abre seu aplicativo de e-mail para confirmação de identidade.",exportLabel:"Solicitar exportação de dados",contactLabel:`Atendimento de privacidade: ${z}`}:{title:"Privacy and data",description:"Request a copy of the data associated with your account. This opens your email app for identity verification.",exportLabel:"Request data export",contactLabel:`Privacy contact: ${z}`}}function st(t,r){const s=t==="pt-BR",a=s?"Solicitação de exportação de dados":"Data export request",o=s?["Olá, equipe Snew,","","Quero solicitar uma cópia dos dados associados à minha conta.",`E-mail da conta: ${r}`,"","Entendo que vocês poderão solicitar uma confirmação de identidade antes de concluir o pedido."].join(` 2`):["Hello Snew team,","","I would like to request a copy of the data associated with my account.",`Account email: ${r}`,"","I understand that you may request identity verification before completing this request."].join(` 3`);return`mailto:${z}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(o)}`}
3class ee extends Error{constructor(r){super(r),this.code=r}}async function ot(t){var a;const{data:r,error:s}=await P.functions.invoke("delete-account",{body:{confirmationEmail:t}});if(s){let o="ACCOUNT_DELETION_FAILED";try{const i=await((a=s.context)==null?void 0:a.json());typeof(i==null?void 0:i.code)=="string"&&(o=i.code)}catch{}throw new ee(o)}if(!(r!=null&&r.ok))throw new ee("ACCOUNT_DELETION_FAILED")}const it={en:{title:"Delete account",description:"Permanently close your Snew account and remove your access.",open:"Delete my account",modalTitle:"Permanently delete your account?",modalDescription:"This action cannot be undone. Before deleting your access, Snew will cancel active subscriptions and disconnect linked stores.",access:"Your login and personal profile will be permanently deleted.",retention:"Financial, fraud-prevention, and security records may be retained when legally required.",owner:"If other people belong to a workspace you own, transfer ownership before deleting your account.",confirmation:"Enter your account email to confirm",cancel:"Cancel",deleting:"Deleting accountâ¦",confirm:"Permanently delete account",errors:{AUTH_REQUIRED:"Sign in again before deleting your account.",CONFIRMATION_MISMATCH:"The email does not match this account.",ACCOUNT_TRANSFER_REQUIRED:"Transfer ownership of your shared workspace before deleting this account.",SUBSCRIPTION_CANCEL_FAILED:"We could not cancel your subscription. Your account was not deleted. Try again.",INTEGRATION_REVOCATION_FAILED:"We could not disconnect your integrations. Your account was not deleted. Try again.",ACCOUNT_DELETION_FAILED:"We could not delete your account. Try again."}},"pt-BR":{title:"Excluir conta",description:"Encerre permanentemente sua conta Snew e remova seu acesso.",open:"Excluir minha conta",modalTitle:"Excluir sua conta permanentemente?",modalDescription:"Esta ação não pode ser desfeita. Antes de excluir seu acesso, a Snew cancelará assinaturas ativas e desconectará as lojas vinculadas.",access:"Seu acesso e seu perfil pessoal serão excluÃdos permanentemente.",retention:"Registros financeiros, antifraude e de segurança poderão ser mantidos quando houver obrigação legal.",owner:"Se outras pessoas participarem de um workspace seu, transfira a propriedade antes de excluir a conta.",confirmation:"Digite o e-mail da sua conta para confirmar",cancel:"Cancelar",deleting:"Excluindo contaâ¦",confirm:"Excluir conta permanentemente",errors:{AUTH_REQUIRED:"Entre novamente antes de excluir sua conta.",CONFIRMATION_MISMATCH:"O e-mail não corresponde a esta conta.",ACCOUNT_TRANSFER_REQUIRED:"Transfira a propriedade do workspace compartilhado antes de excluir esta conta.",SUBSCRIPTION_CANCEL_FAILED:"Não foi possÃvel cancelar sua assinatura. Sua conta não foi excluÃda. Tente novamente.",INTEGRATION_REVOCATION_FAILED:"Não foi possÃvel desconectar suas integrações. Sua conta não foi excluÃda. Tente novamente.",ACCOUNT_DELETION_FAILED:"Não foi possÃvel excluir sua conta. Tente novamente."}}};function lt({accountEmail:t,onDeleted:r}){const{lang:s}=R(),a=it[s],[o,i]=n.useState(!1),[d,m]=n.useState(""),[u,c]=n.useState(!1),[x,h]=n.useState(null),g=d.trim().toLowerCase()===t.trim().toLowerCase(),f=l=>{u||(i(l),l||(m(""),h(null)))},p=async()=>{if(!(!g||u)){c(!0),h(null);try{await ot(d),r?await r():(await P.auth.signOut({scope:"local"}),window.location.assign("/signin?account=deleted"))}catch(l){const w=typeof l=="object"&&l!==null&&"code"in l?l.code:null,v=typeof w=="string"&&w in a.errors?w:"ACCOUNT_DELETION_FAILED";h(a.errors[v]??a.errors.ACCOUNT_DELETION_FAILED),c(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs(W,{padding:"none",className:"overflow-hidden border-destructive/30 shadow-snew-sm","data-no-translate":!0,children:[e.jsx("div",{className:"border-b border-snew-border px-5 py-4 sm:px-6 sm:py-5",children:e.jsx("h2",{className:"text-sm font-semibold text-snew-ink",children:a.title})}),e.jsxs("div",{className:"flex flex-col items-start justify-between gap-4 px-5 py-5 sm:flex-row sm:items-center sm:px-6 sm:py-6",children:[e.jsx("p",{className:"max-w-2xl text-sm leading-6 text-snew-ink-muted",children:a.description}),e.jsx(k,{type:"button",variant:"danger",size:"sm",onClick:()=>i(!0),iconLeft:e.jsx(Me,{size:15}),children:a.open})]})]}),e.jsx(Ze,{open:o,onOpenChange:f,children:e.jsxs(De,{className:"max-w-lg rounded-2xl bg-background",closeLabel:a.cancel,"data-no-translate":!0,children:[e.jsxs(Oe,{children:[e.jsx(He,{children:a.modalTitle}
3),e.jsx(Ue,{className:"leading-6",children:a.modalDescription})]}),e.jsxs("ul",{className:"list-disc space-y-2 pl-5 text-sm leading-5 text-snew-ink-muted",children:[e.jsx("li",{children:a.access}),e.jsx("li",{children:a.retention}),e.jsx("li",{children:a.owner})]}),e.jsx(Ee,{autoComplete:"off",label:a.confirmation,value:d,onChange:l=>m(l.target.value),placeholder:t,disabled:u}),x&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:x}),e.jsxs(Fe,{children:[e.jsx(k,{type:"button",variant:"secondary",onClick:()=>f(!1),disabled:u,children:a.cancel}),e.jsxs(k,{type:"button",variant:"danger",onClick:()=>{p().catch(()=>{h(a.errors.ACCOUNT_DELETION_FAILED),c(!1)})},disabled:!g||u,children:[u&&e.jsx(se,{size:15,className:"animate-spin"}),u?a.deleting:a.confirm]})]})]})})]})}const ct=[{id:"account",icon:e.jsx(Te,{size:16,weight:"regular"})},{id:"plan",icon:e.jsx(Ve,{size:16,weight:"regular"})},{id:"credits",icon:e.jsx(Pe,{size:16,weight:"regular"})},{id:"connections",icon:e.jsx(ze,{size:16,weight:"regular"})}],dt={en:{eyebrow:"Settings",nav:{account:"Account",plan:"Plan & Billing",credits:"Credit Usage",connections:"Connections"},title:{account:"Account",plan:"Plan & Billing",credits:"Credit Usage",connections:"Connections"},sectionsLabel:"Settings sections"},"pt-BR":{eyebrow:"Configurações",nav:{account:"Conta",plan:"Plano e cobrança",credits:"Uso de créditos",connections:"Conexões"},title:{account:"Conta",plan:"Plano e cobrança",credits:"Uso de créditos",connections:"Conexões"},sectionsLabel:"Seções de configurações"}},ut=1100;function Tt({defaultTab:t="account"}){const r=Se(),{lang:s}=R(),[a,o]=n.useState(t),i=fe(),d=dt[s];return e.jsxs("div",{"data-no-translate":!0,style:{flex:1,minHeight:"100%",background:`hsl(${b.bg.tertiary})`,width:"100%",display:"grid",alignContent:"start",gridTemplateColumns:r?"minmax(0, 1fr)":"240px minmax(0, 1fr)",gap:C[8],padding:`calc(64px + ${C[6]}) ${r?C[4]:C[8]} ${C[8]}`},children:[e.jsx("nav",{"aria-label":d.sectionsLabel,style:{display:"flex",flexDirection:r?"row":"column",overflowX:r?"auto":void 0,alignItems:"start",gap:2},children:ct.map(m=>{const u=m.id===a;return e.jsxs("button",{onClick:()=>{o(m.id),i({account:"/settings",plan:"/settings/plan",credits:"/settings/credits",connections:"/settings/connections"}[m.id],{replace:!0})},style:{display:"flex",alignItems:"center",gap:C[3],flexShrink:0,whiteSpace:"nowrap",padding:`${C[2]} ${C[3]}`,background:"transparent",border:"none",borderRadius:F.md,cursor:"pointer",textAlign:"left",fontFamily:"inherit",fontSize:14,fontWeight:u?600:400,color:u?`hsl(${b.text.primary})`:`hsl(${b.text.secondary})`},onMouseEnter:c=>{u||(c.currentTarget.style.background=`hsl(${b.bg.secondary})`)},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{display:"inline-flex",color:"currentColor",width:16,height:16,flexShrink:0},children:m.icon}),d.nav[m.id]]},m.id)})}),e.jsx("main",{style:{paddingTop:0,width:"100%",minWidth:0},children:e.jsxs("div",{style:{width:"100%",maxWidth:ut,margin:"0 auto",paddingBottom:96},children:[e.jsx(xt,{eyebrow:d.eyebrow,title:d.title[a]}),a==="plan"&&e.jsx(X,{}),a==="account"&&e.jsx(mt,{}),a==="credits"&&e.jsx(X,{view:"credits"}),a==="connections"&&e.jsx(gt,{})]})})]})}const pe={en:{loading:"Loading profileâ¦",signIn:"Sign in to manage your profile.",retry:"Retry",section:"Account",reload:"Reload profile",changePhoto:"Change photo",remove:"Remove",choosePhoto:"Choose profile photo",preview:"Preview â not saved yet",previewDetail:"Save this photo to use it across your account.",cancel:"Cancel",savePhoto:"Save photo",name:"Name",placeholder:"Your name",email:"Email",edit:"Edit",notEditable:"Not editable",emailDetail:"Your login email cannot be changed here.",saving:"Saving changesâ¦",applies:"Changes apply to your entire account.",saveName:"Save name",saved:"Profile saved.",saveError:"Unable to save. Try again.",imageError:"Unable to read image.",planLoading:"Loading your planâ¦",planUnavailable:"Plan details are unavailable.",freePlan:"You're on the Free plan.",planActive:"You're on the {plan} plan.",renews:"Your plan renews on {date}.",ends:"Your plan ends on {date}."},"pt-BR":{loading:"Carregando perfilâ¦",signIn:"Entre para gerenciar seu perfil.",retry:"Tentar novamente",section:"Conta",reload:"Recarregar perfil",changePhoto:"Alterar foto",remove:"Remover",choosePhoto:"Escolher foto do perfil",preview:"Prévia â ainda não salva",previewDetail:"Salve esta foto para usá-la em toda a sua conta.",cancel:"Cancelar",savePhoto:"Salvar foto",name:"Nome",placeholder:"Seu nome",email:"E-mail",edit:"Editar",notEditable:"Não editável",emailDetail:"O e-mail de acesso não pode ser alterado aqui.",saving:"Salvando alteraçõesâ¦",applies:"As alterações valem para toda a sua conta.",saveName:"Salvar nome",saved:"Perfil salvo.",saveError:"Não foi possÃvel salvar. Tente novamente.",imageError:"Não foi possÃvel ler a imagem.",planLoading:"Carregando seu planoâ¦",planUnavailable:"Os dados do plano estão indisponÃveis.",freePlan:"Você está no plano Free.",planActive:"Você está no plano {plan}.",renews:"Seu plano renova em {date}.",ends:"Seu plano termina em {date}."}};function mt(){const{user:t,loading:r,error:s,refresh:a}=$(),{lang:o}=R(),i=pe[o];return t?e.jsx(pt,{},t.id):e.jsxs("div",{role:"status",children:[r?i.loading:s||i.signIn,e.jsx("button",{onClick:()=>void a(),children:i.retry})]})}function pt(){var H;const{user:t,refresh:r}=$(),{lang:s}=R(),a=pe[s],o=ne(),[i,d]=n.useState(t!=null&&t.firstName?t.fullName:""),[m,u]=n.useState(!1),[c,x]=n.useState(!1),h=n.useRef(!1),[g,f]=n.useState(""),[p,l]=n.useState(""),[w,v]=n.useState(null),[j,y]=n.useState(null),N=n.useRef(null),L=n.useRef((t==null?void 0:t.profileUpdatedAt)??null),S=n.useRef(!1);if(n.useEffect(()=>{!h.current&&!S.current&&(d(t!=null&&t.firstName?t.fullName:""),L.current=(t==null?void 0:t.profileUpdatedAt)??null)},[t==null?void 0:t.fullName,t==null?void 0:t.firstName,t==null?void 0:t.profileUpdatedAt]),!t)return null;const E=async(A,U={})=>
3{if(!h.current){h.current=!0,x(!0),l(""),f("");try{await qe(A,L.current,U),v(null),y(null),S.current=!1,f(a.saved),A==="save-name"&&u(!1)}catch(M){l(M instanceof Error?M.message:a.saveError)}finally{h.current=!1,x(!1),await r()}}},D=()=>{S.current=!1,L.current=t.profileUpdatedAt??null,d(t.firstName?t.fullName:""),u(!1),l(""),r()},K=async A=>{var M;const U=(M=A.target.files)==null?void 0:M[0];if(A.target.value="",!(!U||h.current)){h.current=!0,x(!0),l(""),f("");try{const Z=await We(U);y(Z),v(`data:image/png;base64,${Z}`)}catch(Z){l(Z instanceof Error?Z.message:a.imageError)}finally{h.current=!1,x(!1)}}},I=t.fullName||t.email.split("@")[0],T=o.status==="ready"?te[o.plan].name:"â",O=(H=o.renewsAt)==null?void 0:H.toLocaleDateString(s==="pt-BR"?"pt-BR":"en-US",{day:"numeric",month:"long",year:"numeric"}),B=o.status==="loading"?a.planLoading:o.status==="error"?a.planUnavailable:o.plan==="free"?a.freePlan:O?(o.scheduledCancel?a.ends:a.renews).replace("{date}",O):a.planActive.replace("{plan}",T);return e.jsxs("section",{"data-no-translate":!0,"aria-label":a.section,"aria-busy":c,className:"w-full max-w-[760px] min-w-0 space-y-8",children:[(p||t.profileError)&&e.jsxs("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-3 rounded-snew-lg border border-[hsl(var(--color-text-danger)/0.22)] bg-[hsl(var(--color-background-danger))] px-4 py-3 text-[13px] text-[hsl(var(--color-text-danger))]",children:[e.jsx("span",{children:p||t.profileError}),e.jsx(k,{type:"button",variant:"tertiary",size:"sm",onClick:D,children:a.reload})]}),e.jsxs("div",{className:"space-y-7",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-5",children:[e.jsx("input",{ref:N,id:"profile-photo-input",className:"sr-only","aria-label":a.choosePhoto,type:"file",accept:"image/jpeg,image/png,image/webp",disabled:c,onChange:K}),e.jsxs("button",{type:"button",className:"group relative shrink-0 rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-snew-ink focus-visible:ring-offset-2","aria-label":a.changePhoto,disabled:c,onClick:()=>{var A;return(A=N.current)==null?void 0:A.click()},children:[e.jsx(Le,{name:I,email:t.email,url:w||t.avatarUrl,size:96}),e.jsx("span",{className:"absolute bottom-0 right-0 flex h-7 w-7 items-center justify-center rounded-full border-2 border-white bg-snew-surface-muted text-snew-ink-muted shadow-snew-sm transition-colors group-hover:bg-snew-border",children:e.jsx(Ie,{size:13,weight:"bold"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"truncate text-[28px] font-semibold leading-tight text-snew-ink sm:text-[32px]",children:I}),e.jsx("p",{className:"mt-1 truncate text-[14px] font-medium text-snew-ink-muted sm:text-[16px]",title:t.email,children:t.email}),(t.avatarUrl||t.avatarObjectKey)&&!j&&e.jsx("button",{type:"button",className:"mt-2 text-[12px] font-medium text-snew-ink-muted underline-offset-4 hover:text-snew-ink hover:underline",disabled:c,onClick:()=>void E("remove-avatar"),children:a.remove})]})]}),j&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-[10px] border border-snew-border bg-snew-surface-muted px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-medium text-snew-ink",children:a.preview}),e.jsx("p",{className:"mt-0.5 text-[11px] text-snew-ink-dim",children:a.previewDetail})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{type:"button",variant:"tertiary",size:"sm",disabled:c,onClick:()=>{v(null),y(null)},children:a.cancel}),e.jsx(k,{type:"button",size:"sm",disabled:c,onClick:()=>void E("save-avatar",{pngBase64:j}),children:a.savePhoto})]})]}),e.jsxs("div",{className:"flex min-h-[68px] items-center gap-3 rounded-[10px] border border-snew-border bg-[#fbfbfb] px-3 py-3 sm:px-4",children:[e.jsx("span",{className:`shrink-0 rounded-md px-3 py-2 text-[13px] font-medium sm:text-[14px] ${o.status==="ready"?"bg-[#d2ffca] text-[#359e22]":"bg-snew-surface-muted text-snew-ink-dim"}`,children:T}),e.jsx("p",{className:"min-w-0 text-[13px] font-medium leading-5 text-snew-ink-muted sm:text-[14px]",children:B})]}),e.jsxs("form",{onSubmit:A=>{A.preventDefault(),E("save-name",{name:i})},children:[e.jsxs("div",{className:"border-y border-snew-border",children:[e.jsxs("div",{className:"flex min-h-[96px] items-center justify-between gap-6 border-b border-snew-border py-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[14px] font-medium text-snew-ink-dim sm:text-[16
3px]",children:a.name}),m?e.jsx("input",{autoFocus:!0,"aria-label":a.name,value:i,maxLength:160,required:!0,disabled:c,placeholder:a.placeholder,onChange:A=>{S.current=!0,d(A.target.value)},className:"mt-1 h-10 w-full rounded-snew-md border border-snew-border bg-white px-3 text-[15px] font-medium text-snew-ink outline-none focus:border-snew-ink"}):e.jsx("p",{className:"mt-1 truncate text-[15px] font-medium text-snew-ink sm:text-[16px]",children:I})]}),m?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(k,{type:"button",variant:"tertiary",size:"sm",disabled:c,onClick:D,children:a.cancel}),e.jsx(k,{type:"submit",size:"sm",disabled:c||!i.trim(),children:a.saveName})]}):e.jsx("button",{type:"button",className:"shrink-0 text-[14px] font-medium text-snew-ink hover:underline sm:text-[16px]",onClick:()=>u(!0),children:a.edit})]}),e.jsxs("div",{className:"flex min-h-[96px] items-center justify-between gap-6 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[14px] font-medium text-snew-ink-dim sm:text-[16px]",children:a.email}),e.jsx("p",{className:"mt-1 truncate text-[15px] font-medium text-snew-ink sm:text-[16px]",title:t.email,children:t.email})]}),e.jsx("p",{className:"shrink-0 text-right text-[12px] font-medium leading-5 text-snew-ink-dim sm:text-[14px]",children:a.notEditable})]})]}),e.jsx("div",{role:"status","aria-live":"polite",className:"mt-3 min-h-5 text-[12px] text-snew-ink-muted",children:c?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(se,{size:14,className:"animate-spin"}),a.saving]}):g?e.jsx("span",{className:"text-[hsl(var(--color-text-success))]",children:g}):null})]})]}),e.jsx(ft,{userId:t.id}),e.jsx(ht,{accountEmail:t.email,lang:s}),e.jsx(lt,{accountEmail:t.email})]})}function ht({accountEmail:t,lang:r}){const s=rt(r);return e.jsxs(W,{padding:"none",className:"overflow-hidden shadow-snew-sm",children:[e.jsx("div",{className:"border-b border-snew-border px-5 py-4 sm:px-6 sm:py-5",children:e.jsx("h2",{className:"text-[14px] font-semibold text-snew-ink",children:s.title})}),e.jsxs("div",{className:"space-y-4 px-5 py-5 sm:px-6 sm:py-6",children:[e.jsx("p",{className:"max-w-[760px] text-[13px] leading-6 text-snew-ink-muted",children:s.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{asChild:!0,type:"button",variant:"secondary",size:"sm",children:e.jsx("a",{href:st(r,t),children:s.exportLabel})})}),e.jsx("p",{className:"text-[11px] text-snew-ink-dim",children:s.contactLabel})]})]})}function ft({userId:t}){const{lang:r}=R(),s=r==="pt-BR",a={onboarding_enabled:!0,creation_reminders_enabled:!0,reengagement_enabled:!0},o=[{key:"onboarding_enabled",title:s?"Orientações de primeiros passos":"Getting started guidance",description:s?"Dicas para concluir a configuração inicial da sua conta.":"Tips to complete your account's initial setup."},{key:"creation_reminders_enabled",title:s?"Lembretes de primeira criação":"First creation reminders",description:s?"Lembretes para ajudar você a criar seu primeiro conteúdo.":"Reminders to help you create your first piece of content."},{key:"reengagement_enabled",title:s?"E-mails de reengajamento":"Re-engagement emails",description:s?"Sugestões para retomar seu trabalho após perÃodos de inatividade.":"Suggestions to resume your work after periods of inactivity."}],[i,d]=n.useState(a),[m,u]=n.useState(!0),[c,x]=n.useState(null),[h,g]=n.useState("");n.useEffect(()=>{let p=!0;return u(!0),g(""),P.from("email_preferences").select("*").eq("user_id",t).maybeSingle().then(({data:l,error:w})=>{if(p){if(w)g(s?"Não foi possÃvel carregar sua preferência.":"We couldn't load your preference.");else{const v=(l==null?void 0:l.lifecycle_enabled)??!0;d({onboarding_enabled:(l==null?void 0:l.onboarding_enabled)??v,creation_reminders_enabled:(l==null?void 0:l.creation_reminders_enabled)??v,reengagement_enabled:(l==null?void 0:l.reengagement_enabled)??v})}u(!1)}}),()=>{p=!1}},[s,t]);const f=async(p,l)=>{if(m||c)return;const w={...i,[p]:l},v=Object.values(w).some(Boolean);x(p),g("");const j=new Date().toISOString(),{error:y}=await P.from("email_preferences").upsert({user_id:t,...w,lifecycle_enabled:v,unsubscribed_at:v?null:j,updated_at:j},{onConflict:"user_id"});y?g(s?"Não foi possÃvel salvar. Tente novamente.":"We couldn't save this preference. Please try again."):(d(w),V.success(s?"Preferência de e-mail atualizada.":"Email preference updated.")),x(null)};return e.jsxs(W,{padding:"none",className:"overflow-hidden shadow-snew-sm",children:[e.jsx("div",{className:"border-b border-snew-border px-5 py-4 sm:px-6 sm:py-5",children:e.jsx("h2",{className:"text-[14px] font-semibold text-snew-ink",children:s?"Preferências de e-mail"
3:"Email preferences"})}),e.jsxs("ul",{className:"divide-y divide-snew-border",children:[o.map(p=>e.jsxs("li",{className:"flex items-center justify-between gap-6 px-5 py-5 sm:px-6",children:[e.jsxs("div",{className:"min-w-0 max-w-2xl",children:[e.jsx("p",{className:"text-[13px] font-medium text-snew-ink",children:p.title}),e.jsx("p",{className:"mt-1 text-[12px] leading-5 text-snew-ink-dim",children:p.description})]}),e.jsx(me,{checked:i[p.key],"aria-label":p.title,disabled:m||c!==null,onCheckedChange:l=>void f(p.key,l),className:"h-7 w-12 data-[state=checked]:bg-snew-ink data-[state=unchecked]:bg-snew-surface-muted [&>span]:h-[22px] [&>span]:w-[22px] data-[state=checked]:[&>span]:translate-x-5"})]},p.key)),e.jsxs("li",{className:"px-5 py-4 sm:px-6",children:[e.jsx("p",{className:"text-[11px] leading-5 text-snew-ink-dim",children:s?"E-mails essenciais de cobrança, segurança e convites permanecem ativos.":"Essential billing, security, and invitation emails remain active."}),h&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-[hsl(var(--color-text-danger))]",children:h})]})]})]})}function gt(){const{user:t}=$(),[r,s]=n.useState(!1);return e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(nt,{store:t==null?void 0:t.activeStore,storeError:t==null?void 0:t.storeError,onConnect:()=>s(!0)}),e.jsx(ke,{open:r,onOpenChange:s})]})}function xt({eyebrow:t,title:r,subtitle:s}){return e.jsxs("div",{style:{marginBottom:C[6]},children:[e.jsx("div",{style:{fontSize:13,color:`hsl(${b.text.tertiary})`,marginBottom:C[1]},children:t}),e.jsx("h1",{style:{fontSize:28,fontWeight:600,margin:0,color:`hsl(${b.text.primary})`},children:r}),s&&e.jsx("p",{style:{fontSize:14,color:`hsl(${b.text.tertiary})`,margin:0,marginTop:C[2]},children:s})]})}export{Tt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.