PageSourceSearch

https://socialnex.ai/audit/assets/settings-D6bvQ_ZV.js

js socialnex.ai collected 2026-10-05 15:11:20 UTC 27,507 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"./react-vendor-hAxFZxNQ.js";import{af as s,ag as a,ah as i,Z as n,ai as r,aj as l,D as o,u as c,ak as d,L as m,c as u,m as x,f as p,$ as h,a0 as g,a1 as b,a2 as f,al as j,Q as v,U as y,V as N,W as w,Y as k,A as S,_,e as C,am as E}from"./main-FMm0mhBU.js";import{S as M}from"./switch-DMvaYDaX.js";import{teamsApi as A}from"./teams-CyJpouz5.js";import{t as F}from"./twoFactor-D1FmZRK-.js";import"./ui-DlHKYJvh.js";const $="two-factor-status";function B(){const o=s($),[c,d]=e.useState("status"),[m,u]=e.useState(()=>o?.enabled??!1),[x,p]=e.useState(()=>o?.phone_masked??null),[h,g]=e.useState(()=>!a($)),[b,f]=e.useState(""),[j,v]=e.useState(""),[y,N]=e.useState(""),[w,k]=e.useState(""),[S,_]=e.useState(!1);e.useEffect(()=>{F.status().then(e=>{u(e.enabled),p(e.phone_masked),i($,{enabled:e.enabled,phone_masked:e.phone_masked}),g(!1)})},[]);const C=()=>k("");return h?t.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-base",children:"Two-Factor Authentication"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Require a verification code on each login"})]}),m&&t.jsx(n,{className:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",children:"Enabled"})]}),"status"===c&&!m&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-300",children:"SMS verification may incur charges from your mobile carrier."}),t.jsx(r,{variant:"outline",onClick:()=>{C(),d("enter-phone")},children:"Enable Two-Factor Authentication"})]}),"status"===c&&m&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Secured with SMS to ",t.jsx("span",{className:"font-mono",children:x})]}),t.jsx(r,{variant:"outline",className:"text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>{C(),d("disable-confirm")},children:"Disable Two-Factor Authentication"})]}),"enter-phone"===c&&t.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),C(),!b.trim())return void k("Enter your phone number");_(!0);const t=await F.setupSend(b.trim());_(!1),t.success?d("enter-code"):k(t.error||"Failed to send code. Check the number and try again.")},className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your mobile number in international format (e.g. +12025551234)"}),t.jsx(l,{type:"tel",placeholder:"+12025551234",value:b,onChange:e=>f(e.target.value),autoFocus:!0}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"By providing your phone number, you agree that SocialNex may use your email address and phone number to contact you about additional SocialNex.ai products and services. SMS charges may apply."}),w&&t.jsx("p",{className:"text-sm text-red-500",children:w}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(r,{type:"submit",disabled:S,children:S?"Sending…":"Send Code"}),t.jsx(r,{type:"button",variant:"ghost",onClick:()=>{d("status"),C(),f("")},children:"Cancel"})]})]}),"enter-code"===c&&t.jsxs("form",{onSubmit:async e=>{e.preventDefault(),C(),_(!0);const t=await F.setupVerify(b.trim(),j.trim());if(_(!1),t.success){const e=await F.status();u(e.enabled),p(e.phone_masked),i($,{enabled:e.enabled,phone_masked:e.phone_masked}),d("status"),f(""),v("")}else k(t.error||"Invalid code. Please try again.")},className:"space-y-3",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",t.jsx("span",{className:"font-medium",children:b})]}),t.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:j,onChange:e=>v(e.target.value.replace(/\D/g,"")),placeholder:"000000",autoFocus:!0,className:"w-full text-center text-3xl tracking-[0.5em] font-mono border rounded-lg py-4 bg-background focus:outline-none focus:ring-2 focus:ring-primary/50 transition"}),w&&t.jsx("p",{className:"text-sm text-red-500",children:w}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(r,{type:"submit",disabled:S||j.length<6,children:S?"Verifying…":"Verify & Enable"}),t.jsx(r,{type:"button",variant:"ghost",onClick:()=>{d("enter-phone"),C(),v("")},children:"Back"})]})]}),"disable-confirm"===c&&t.jsxs("form",{onSubmit:async e=>{e.preventDefault(),C(),_(!0);const t=await F.disable(y);_(!1),t.success?(u(!1),p(null),i($,{enabled:!1,phone_masked:null}),N(""),d("status")):k(t.error||"Incorrect password.")},className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Confirm your password to disable two-factor authentication."}),t.jsx(l,{type:"password",placeholder:"Your password",value:y,onChange:e=>N(e.target.value),autoFocus:!0}),w&&t.jsx("p",{className:"text-sm text-red-500",children:w}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(r,{type:"submit",variant:"destructive",disabled:S||!y,children:S?"Disabling…":"Disable 2FA"}),t.jsx(r,{type:"button",variant:"ghost",onClick:()=>{d("status"),C(),N("")},children:"Cancel"})]})]})]})}const I={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.4,ease:"easeOut"}}};function U(){return t.jsx(o,{children:t.jsx(D,{})})}function D(){return t.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 xl:px-8 py-8",children:[t.jsx("h1",{className:"text-3xl font-bold tracking-tight mb-8",children:"Settings"}),t.jsx(P,{})]})}function P(){const{user:e}=c(),s="undefined"!=typeof window?JSON.parse(localStorage.getItem("subscriptions")||"{}"):{},a=d(s?.postings?.plan_id)&&!s?.local;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(W,{icon:"material-symbols:person-outline",iconBg:"bg-blue-100 dar
1k:bg-blue-900/40",iconColor:"text-blue-600 dark:text-blue-400",title:"Your Profile",description:"Your account information",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsx(J,{icon:"material-symbols:person",label:"Name",value:[e?.first_name,e?.last_name].filter(Boolean).join(" ")}),t.jsx(J,{icon:"material-symbols:mail-outline",label:"Email",value:e?.email||""})]})}),t.jsx(W,{icon:"material-symbols:storefront-outline",iconBg:"bg-emerald-100 dark:bg-emerald-900/40",iconColor:"text-emerald-600 dark:text-emerald-400",title:"Business Profile",description:"Business details, brand logo, and competitors used to personalize AI-generated content",children:t.jsx(r,{variant:"outline",asChild:!0,children:t.jsxs(m,{to:"/social/businesses",children:["Manage business profiles",t.jsx(u,{name:"ArrowUpRight",className:"size-4"})]})})}),!a&&t.jsx(O,{}),t.jsx(W,{icon:"material-symbols:lock-outline",iconBg:"bg-purple-100 dark:bg-purple-900/40",iconColor:"text-purple-600 dark:text-purple-400",title:"Security",description:"Manage your account security settings",children:t.jsx(B,{})}),t.jsx(R,{}),t.jsx(L,{})]})}
1const T={posts:"Social Media Posts",videos:"Short-Form Videos",ugc:"UGC Videos",static_ads:"Static Ads",video_ads:"Video Ads",blogs:"SEO Blog Posts",email:"Email Design",backlinks:"SEO Backlinks",ig_growth:"Instagram Growth",meta_ads:"Meta Ads Management",google_ads:"Google Ads Management"};function V(e){return e.startsWith("postings_managed_essential_")||e.startsWith("postings_managed_premium_")?"posts":e.replace(/^postings_managed_?/,"").replace(/_\d+$/,"")||"posts"}function R(){const[s,a]=e.useState(null),[i,r]=e.useState(!0),[l,o]=e.useState(null),c=e.useCallback(()=>{r(!0),S.getActiveBundle().then(e=>a(e.subscription)).catch(()=>a(null)).finally(()=>r(!1))},[]);return e.useEffect(()=>{c()},[c]),i?null:s&&0!==s.items.length?t.jsxs(W,{icon:"material-symbols:layers-outline",iconBg:"bg-indigo-100 dark:bg-indigo-900/40",iconColor:"text-indigo-600 dark:text-indigo-400",title:"Managed Services",description:`${s.items.length} active service${1===s.items.length?"":"s"} on your subscription`,actions:t.jsxs(m,{to:"/checkout",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary bg-primary/10 hover:bg-primary/20 rounded-lg transition-colors",children:[t.jsx(u,{name:"material-symbols:add",className:"w-3.5 h-3.5"}),"Add service"]}),children:[t.jsx("div",{className:"space-y-2",children:s.items.map(e=>{const a=V(e.plan_id),i=T[a]||e.plan_id;let r="";e.plan_id.startsWith("postings_managed_essential_")?r="Essential":e.plan_id.startsWith("postings_managed_premium_")&&(r="Premium");const d=e.plan_id.match(/_(\d+)$/),m=d?d[1]:null;return t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:"w-9 h-9 rounded-full bg-indigo-100 dark:bg-indigo-900/30 flex items-center justify-center flex-shrink-0",children:t.jsx(u,{name:"material-symbols:check-circle-outline",className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("p",{className:"text-sm font-semibold",children:i}),r&&t.jsx(n,{className:"bg-purple-100 dark:bg-purple-900/40 text-purple-700 dark:text-purple-300 text-xs",children:r}),m&&t.jsxs(n,{className:"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-xs",children:[m,"/mo"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Active · billed monthly"})]})]}),t.jsx("button",{type:"button",onClick:()=>(async e=>{if(s.items.length<=1)_({title:"Cannot remove the last service",description:"Use the Cancel Subscription option in the Subscription card instead.",variant:"destructive"});else if(window.confirm(`Remove ${T[V(e)]||e} from your subscription? Stripe will prorate the partial period.`)){o(e);try{await S.removeBundleItem({plan_id:e}),_({title:"Service removed",description:"Your next invoice will reflect the change."}),c();try{const e=await fetch(C("/api/v1/auth_status/"),{credentials:"include"}),t=await e.json();t.subscriptions&&localStorage.setItem("subscriptions",JSON.stringify(t.subscriptions)),t.user&&localStorage.setItem("user",JSON.stringify(t.user)),window.dispatchEvent(new Event("authChange"))}catch{}}catch(t){_({title:"Error",description:t?.message||"Failed to remove service.",variant:"destructive"})}finally{o(null)}}})(e.plan_id),disabled:l===e.plan_id||s.items.length<=1,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",title:s.items.length<=1?"Cancel the subscription to remove the last service":"Remove this service",children:l===e.plan_id?t.jsx(u,{name:"material-symbols:sync",className:"w-3.5 h-3.5 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(u,{name:"material-symbols:close",className:"w-3.5 h-3.5"}),"Remove"]})})]},e.plan_id)})}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-4",children:["Add a service from ",t.jsx(m,{to:"/checkout",className:"text-primary underline-offset-2 hover:underline",children:"/checkout"}
1)," — Stripe prorates the partial month onto your next invoice."]})]}):null}function O(){const{activeTeam:s}=c(),a="admin"===s?.role,[i,r]=e.useState([]),[o,d]=e.useState(!1),[x,p]=e.useState([]),[S,C]=e.useState(!1),[E,F]=e.useState(!1),[$,B]=e.useState(""),[I,U]=e.useState("editor"),[D,P]=e.useState(!1),[T,V]=e.useState(!1),[R,O]=e.useState(!1);e.useEffect(()=>{s&&V(s.settings?.require_approval??!1)},[s]);const L=e.useCallback(async()=>{if(s){d(!0);try{const e=await A.listMembers(s.id);r(e)}catch(e){}finally{d(!1)}}},[s]),q=e.useCallback(async()=>{if(s&&a){C(!0);try{const e=await A.listInvitations(s.id);p(e.filter(e=>"pending"===e.status))}catch(e){}finally{C(!1)}}},[s,a]);e.useEffect(()=>{L(),q()},[L,q]);const J=async()=>{if(s&&$.trim()){P(!0);try{await A.sendInvitation(s.id,{email:$.trim(),role:I}),B(""),U("editor"),F(!1),q(),_({title:"Invitation sent",description:`Invitation sent to ${$.trim()}.`})}catch(e){_({title:"Error",description:e.message||"Failed to send invitation.",variant:"destructive"})}finally{P(!1)}}},Y=e=>[e.first_name,e.last_name].filter(Boolean).join(" ")||e.username||e.email,G=e=>e.first_name?e.first_name[0].toUpperCase():e.username?e.username[0].toUpperCase():e.email?e.email[0].toUpperCase():"?",z=e=>{switch(e){case"admin":return"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300";case"editor":return"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300";default:return"bg-muted text-muted-foreground"}},Q=i.length+x.length,Z="undefined"!=typeof window?JSON.parse(localStorage.getItem("subscriptions")||"{}"):{},K=Math.max(...Object.values(Z).map(e=>e?.max_members_per_team??0),1);return s?t.jsxs(W,{icon:"material-symbols:group-outline",iconBg:"bg-orange-100 dark:bg-orange-900/40",iconColor:"text-orange-600 dark:text-orange-400",title:"Team Management",description:`${i.length} member${1!==i.length?"s":""}${x.length?` + ${x.length} pending`:""}`,actions:a?t.jsxs("button",{type:"button",onClick:()=>F(!0),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 rounded-lg transition-colors",children:[t.jsx(u,{name:"material-symbols:person-add-outline",className:"w-4 h-4"}),"Invite Member"]}):void 0,children:[t.jsx(h,{open:E,onOpenChange:e=>{e||(F(!1),B(""))},children:t.jsxs(g,{className:"sm:max-w-md",children:[t.jsxs(b,{children:[t.jsx(f,{children:"Invite a team member"}),t.jsx(j,{children:"They'll receive an email with a link to join your workspace."})]}),t.jsxs("div",{className:"space-y-4 pt-2",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"invite-email",className:"text-sm font-medium mb-1.5 block",children:"Email address"}),t.jsx(l,{id:"invite-email",type:"email",value:$,onChange:e=>B(e.target.value),placeholder:"[email protected]",onKeyDown:e=>{"Enter"===e.key&&J()},autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Role"}),t.jsxs(v,{value:I,onValueChange:e=>U(e),children:[t.jsx(y,{children:t.jsx(N,{})}),t.jsxs(w,{children:[t.jsx(k,{value:"editor",children:"Editor"}),t.jsx(k,{value:"viewer",children:"Viewer"})]})]})]}),t.jsx("button",{type:"button",onClick:J,disabled:D||!$.trim(),className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-white bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:D?t.jsx(u,{name:"material-symbols:sync",className:"w-4 h-4 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(u,{name:"material-symbols:send",className:"w-4 h-4"}),"Send Invitation"]})})]})]})}),o?t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(u,{name:"material-symbols:sync",className:"w-5 h-5 text-primary animate-spin"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading members..."})]}):0===i.length?t.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No members found."}):t.jsx("div",{className:"space-y-3 mb-5",children:i.map(e=>t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:"w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx("span",{className:"text-sm font-semibold text-primary",children:G(e)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold truncate",children:Y(e)}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a?t.jsxs(v,{value:e.role,onValueChange:t=>(async(e,t)=>{if(s)try{await A.changeMemberRole(s.id,e,t),L(),_({title:"Role updated",description:"Member role has been changed."})}catch(a){_({title:"Error",description:"Failed to change member role.",variant:"destructive"})}})(e.user_id,t),children:[t.jsx(y,{className:"w-[110px] h-8 text-xs",children:t.jsx(N,{})}),t.jsxs(w,{children:[t.jsx(k,{value:"admin",children:"Admin"}),t.jsx(k,{value:"editor",children:"Editor"}),t.jsx(k,{value:"viewer",children:"Viewer"})]})]}):t.jsx(n,{className:`text-xs ${z(e.role)}`,children:e.role.charAt(0).toUpperCase()+e.role.slice(1)}),a&&"admin"!==e.role&&t.jsx("button",{type:"button",onClick:()=>(async e=>{if(s)try{await A.removeMember(s.id,e),L(),_({title:"Member removed",description:"Team member has been removed."})}catch(t){_({title:"Error",description:"Failed to remove member.",variant:"destructive"})}})(e.user_id),className:"p-1.5 rounded-lg text-muted-foreground hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",title:"Remove member",children:t.jsx(u,{name:"material-symbols:close",className:"w-4 h-4"})})]})]},e.id))}),a&&!S&&x.length>0&&t.jsxs("div",{className:"mb-5",children:[t.jsx("div",{className:"border-t border-border mb-4"}),t.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Pending Invitations"}),t.jsx("div",{className:"space-y-2",children:x.map(e=>{const a=new Date(e.expires_at),i=new Date,r=Math.max(0,Math.ceil((a.getTime()-i.getTime())/864e5));return t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-amber-50 dark:bg-amber-900/10 border border-amber-200 dark:border-amber-800/30",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:e.email}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",new Date(e.created_at).toLocaleDateString()," · ",r," day",1!==r?"s":""," left"]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[t.jsx(n,{className:`text-xs ${z(e.role)}`,children:e.role.charAt(0).toUpperCase()+e.role.slice(1)}),t.jsx("button",{type:"button",onClick:()=>(async e=>{if(s)try{await A.cancelInvitation(s.id,e),q(),_({title:"Invitation cancelled",description:"The invitation has been cancelled."})}catch(t){_({title:"Error",description:"Failed to cancel invitation.",variant:"destructive"})}})(e.id),className:"p-1.5 rounded-lg text-muted-foreground hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",title:"Cancel invitation",children:t.jsx(u,{name:"material-symbols:close",className:"w-4 h-4"})})]})]},e.id)})})]}),a&&S&&t.jsxs("div",{className:"mb-5",children:[t.jsx("div",{className:"border-t border-border mb-4"}),t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(u,{name:"material-symbols:sync",className:"w-4 h-4 text-muted-foreground animate-spin"}),t.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"Loading invitations..."})]})]}),a&&t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50 mb-5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Require Approval for Editor Posts"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When enabled, social media posts created by Editors must be reviewed and approved by an Admin before they can be published."})]}),t.jsx(M,{checked:T,onCheckedChange:async e=>{if(s){V(e),O(!0);try{await A.updateTeam(s.id,{settings:{...s.settings,require_approval:e}}),window.dispatchEvent(new Event("teamChange")),_({title:e?"Approval required":"Approval disabled",description:e?"Editor posts now require admin a
1pproval before publishing.":"Posts will be published directly."})}catch(t){V(!e),_({title:"Error",description:"Failed to update setting.",variant:"destructive"})}finally{O(!1)}}},disabled:R})]}),t.jsx("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:t.jsxs("p",{className:"text-xs text-muted-foreground",children:[Q," of ",K," seat",1!==K?"s":""," used",Q>=K&&t.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[" ","·"," ",t.jsx(m,{to:"/pricing",className:"underline hover:text-amber-500 transition-colors",children:"Upgrade for more seats"})]})]})})]}):t.jsx(W,{icon:"material-symbols:group-outline",iconBg:"bg-orange-100 dark:bg-orange-900/40",iconColor:"text-orange-600 dark:text-orange-400",title:"Team Management",description:"Manage team members and permissions",children:t.jsx("div",{className:"p-4 rounded-xl bg-muted text-center",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Set up a workspace first to manage team members."})})})}function L(){const s="undefined"!=typeof window?JSON.parse(localStorage.getItem("subscriptions")||"{}"):{},a=Object.keys(s).filter(e=>s[e]),i=d(s?.postings?.plan_id)&&!s?.local,[r,l]=e.useState([]),[o,c]=e.useState(!1),[x,p]=e.useState(null),[h,g]=e.useState(null),[b,f]=e.useState(0);return e.useEffect(()=>{S.getActiveBundle().then(e=>{e.subscription&&e.subscription.is_bundle&&(g(e.subscription.total_cents),f(e.subscription.items.length))}).catch(()=>{})},[]),e.useEffect(()=>{0!==a.length&&(c(!0),S.getPlans().then(e=>l(e.results)).catch(e=>{}).finally(()=>c(!1)))},[]),0===a.length?t.jsx(W,{icon:"material-symbols:credit-card",iconBg:"bg-green-100 dark:bg-green-900/40",iconColor:"text-green-600 dark:text-green-400",title:"Subscription",description:"Manage your subscription plan",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active subscription"}),t.jsxs(m,{to:"/pricing",className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 rounded-lg transition-colors",children:[t.jsx(u,{name:"material-symbols:storefront",className:"w-4 h-4"}),"View Plans"]})]})}):t.jsxs(W,{icon:"material-symbols:credit-card",iconBg:"bg-green-100 dark:bg-green-900/40",iconColor:"text-green-600 dark:text-green-400",title:"Subscription",description:"Manage your subscription plans",actions:i?void 0:t.jsxs(m,{to:"/pricing",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary bg-primary/10 hover:bg-primary/20 rounded-lg transition-colors",children:[t.jsx(u,{name:"material-symbols:storefront",className:"w-3.5 h-3.5"}),"View Plans"]}),children:[o?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(u,{name:"material-symbols:sync",className:"w-5 h-5 text-primary animate-spin"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading plans..."})]}):t.jsx("div",{className:"space-y-3",children:a.map(e=>{const a=r.find(t=>t.plan_id===s[e]?.plan_id)||r.find(t=>t.product===e),i="postings"===e&&null!==h&&b>1,l=i?`Managed Postings · ${b} services`:a?`${a.name} ${a.name_break}`.trim():e.charAt(0).toUpperCase()+e.slice(1),o=i?`$${(h/100).toFixed(0)}/mo`:a?`$${(a.price_cents/100).toFixed(0)}/${"month"===a.interval?"mo":"yr"}`:null;return t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("div",{className:"w-9 h-9 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center flex-shrink-0",children:t.jsx(u,{name:a?.icon||"material-symbols:storefront",className:`w-5 h-5 ${a?.icon_color||"text-green-600"}`})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm font-semibold truncate",children:l}),t.jsx(n,{className:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 text-xs",children:"Active"})]}),o&&t.jsx("p",{className:"text-xs text-muted-foreground",children:o})]})]}),t.jsxs("button",{type:"button",onClick:()=>(async e=>{p(e||"_all");try{const t=await S.createBillingPortalSession(e,window.location.href);window.location.href=t.url}catch(t){_({title:"Error",description:t.message||"Failed to open billing portal.",variant:"destructive"}),p(null)}})(e),disabled:x===e,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary bg-primary/10 hover:bg-primary/20 disabled:opacity-50 rounded-lg transition-colors",children:[x===e?t.jsx(u,{name:"material-symbols:sync",className:"w-3.5 h-3.5 animate-spin"}):t.jsx(u,{name:"material-symbols:open-in-new",className:"w-3.5 h-3.5"}),"Manage"]})]},e)})}),!i&&t.jsx(q,{})]})}function q(){const[s,a]=e.useState(null),[i,n]=e.useState(!0);if(e.useEffect(()=>{E.getUsage().then(a).catch(()=>{}).finally(()=>n(!1))},[]),i||!s)return null;const{credits_used:r,credits_limit:l,image_credit_cost:o}=s,c=0===l,d=c?0:Math.min(100,r/l*100),x=c?"bg-primary":d>=100?"bg-red-500":d>=80?"bg-amber-500":"bg-primary",h=!c&&d>=80,g=new Date;
1g.setMonth(g.getMonth()+1,1);const b=g.toLocaleDateString("en-US",{month:"long",day:"numeric"});return t.jsxs("div",{className:"mt-6 pt-6 border-t border-border",children:[t.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-4",children:"AI Credits This Month"}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[t.jsx("span",{className:"text-sm font-medium",children:"Credits Used"}),t.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:[r.toLocaleString()," / ",c?"Unlimited":l.toLocaleString()]})]}),c?t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unlimited on your plan"}):t.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:p("h-full rounded-full transition-all duration-500",x),style:{width:`${d}%`}})}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["1 text post = 1 credit · 1 image = ",o," credits"]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-4 text-xs text-muted-foreground",children:[t.jsxs("span",{children:["Resets ",b]}),h&&t.jsxs(m,{to:"/pricing",className:"inline-flex items-center gap-1 text-amber-500 hover:text-amber-600 font-medium transition-colors",children:[t.jsx(u,{name:"Zap",className:"w-3 h-3"}),"Upgrade Plan"]})]})]})}function W({icon:e,iconBg:s,iconColor:a,title:i,description:n,actions:r,children:l}){return t.jsx(x.div,{variants:I,children:t.jsx("div",{className:"bg-card rounded-2xl shadow-sm border",children:t.jsxs("div",{className:"p-6 md:p-8",children:[t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:p("w-10 h-10 rounded-xl flex items-center justify-center",s),children:t.jsx(u,{name:e,className:p("w-5 h-5",a)})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-bold",children:i}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n})]})]}),r]}),l]})})})}function J({icon:e,label:s,value:a}){return t.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-muted/50",children:[t.jsx(u,{name:e,className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:s}),t.jsx("p",{className:"text-sm font-medium truncate",children:a||t.jsx("span",{className:"text-muted-foreground italic",children:"Not set"})})]})]})}export{U as component};

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.