1import{av as I,m as P,b as q,s as U,ax as G,r as h,j as e,ay as K,B as p,e as E,f as v,az as Z,aA as W,aB as V,aC as H,d as Q,E as X,Z as J,_ as ee}from"./index-CkEqqj90.js";import{g as D,u as te,p as se,c as ne,d as ae,a as re}from"./users-B_1EBG3P.js";import{c as ie,d as oe,g as le}from"./imap-D9YF04s6.js";import{i as ce,r as de,l as me,a as ue}from"./assistants-WRFB37X9.js";import{T as xe}from"./Badge-CSxOc_8W.js";const ge=t=>I.post("/billing/checkout",null,{params:{price_id:t}}).then(o=>o.data),pe=()=>I.post("/billing/portal").then(t=>t.data),R=t=>I.post("/billing/change-plan",{price_id:t}).then(o=>o.data),he=()=>I.post("/billing/cancel").then(t=>t.data),ye=()=>I.post("/billing/sync").then(t=>t.data),T=[{name:"Free",tier:"free",price:"$0",period:"",features:["15 active submissions","1 active project","5 top agent matches","Email & QueryTracker integration","Submission tracking & analytics"],priceId:null},{name:"Pro",tier:"pro_30",price:"$5.95",period:"/mo",features:["30 active submissions","3 active projects","Unlimited agent matches","Email & QueryTracker integration","Submission tracking & analytics"],priceId:"price_1TbPxFREcNjQrewMwwBImaGs"},{name:"Pro Max",tier:"pro_max",price:"$9.95",period:"/mo",features:["Unlimited submissions","Unlimited projects","Unlimited agent matches","Email & QueryTracker integration","Submission tracking & analytics","Priority support"],priceId:"price_1TbPxFREcNjQrewM5LZTAF1Y"}];function $({title:t,description:o,confirmPhrase:n,pending:u,error:d,onConfirm:s,onCancel:l}){const[a,r]=h.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-700",children:[o," Type"," ",e.jsx("span",{className:"font-mono font-semibold text-red-600",children:n})," to confirm."]}),e.jsx("input",{type:"text",value:a,onChange:c=>r(c.target.value),placeholder:`Type ${n} to confirm`,className:"block w-full rounded-lg border border-red-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-red-400",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"secondary",size:"sm",onClick:l,children:"Cancel"}),e.jsx(p,{variant:"danger",size:"sm",disabled:a!==n||u,onClick:s,children:u?"Deletingâ¦":t})]}),d&&e.jsx("p",{className:"text-xs text-red-500",children:"Something went wrong. Please try again."})]})}function fe(){const{user:t,setAuth:o}=P(),n=P(r=>r.token),[u,d]=h.useState((t==null?void 0:t.email_signature)??""),[s,l]=h.useState(!1),a=v({mutationFn:()=>te({email_signature:u}),onSuccess:r=>{n&&o(n,r),l(!0),setTimeout(()=>l(!1),2e3)}});return e.jsxs("div",{id:"email-signature",className:"bg-white rounded-xl border border-gray-200 p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Email Signature"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Added to the bottom of query emails when you enable the signature option in the Submission Builder."})]}),e.jsx("textarea",{value:u,onChange:r=>{d(r.target.value),l(!1)},rows:5,placeholder:`Best, 2Your Name 3yourwebsite.com`,className:"w-full text-sm rounded-lg border border-gray-300 px-3 py-2.5 font-mono focus:outline-none focus:ring-2 focus:ring-brand-500 resize-y"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(p,{size:"sm",onClick:()=>a.mutate(),disabled:a.isPending,children:a.isPending?"Savingâ¦":s?"Saved â":"Save Signature"}),u&&e.jsx("button",{type:"button",onClick:()=>{d(""),a.mutate()},className:"text-xs text-gray-400 hover:text-red-500 transition-colors",children:"Clear"})]})]})}const be={pro_30:"Pro",pro_max:"Pro Max"};function Y(t){var o,n;return((n=(o=t==null?void 0:t.response)==null?void 0:o.data)==null?void 0:n.detail)??""}const je="https://chromewebstore.google.com/detail/submitme/loclnjafejejelfaceddmgnpebaollai";function ve(){const t=document.documentElement.getAttribute("data-submitme-ext")==="1"||!!window.__submitme_ext;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"SubmitMe Browser Extension"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Required to auto-fill and submit queries on QueryTracker. Works in Chrome, Edge, Arc, and other Chromium-based browsers."})]}),t&&e.jsx("span",{className:"shrink-0 text-xs bg-green-100 text-green-700 px-2.5 py-1 rounded-full font-medium",children:"Installed"})]}),!t&&e.jsxs("a",{href:je,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm font-medium text-brand-600 hover:text-brand-800 border border-brand-200 bg-brand-50 hover:bg-brand-100 rounded-lg px-4 py-2.5 transition-colors",children:[e.jsx(X,{size:14}),"Install from Chrome Web Store"]})]})}function Ne(){const{user:t,token:o,setAuth:n}=P(),[u,d]=h.useState(""),[s,l]=h.useState(null),[a,r]=h.useState("idle"),[c,g]=h.useState(null),b=v({mutationFn:()=>se(u.trim()),onSuccess:y=>{l(y),r("preview"),g(null)},onError:y=>g(Y(y)||"Code not found or not valid for your account.")}),i=v({mutationFn:()=>ne(u.trim()),onSuccess:y=>{o&&n(o,y),r("claimed"),g(null)},onError:y=>g(Y(y)||"Failed to claim code. Please try again.")});function N(){d(""),l(null),r("idle"),g(null)}const x=t!=null&&t.promo_tier&&(t!=null&&t.promo_access_ends_at)?{tier:t.promo_tier,endsAt:t.promo_access_ends_at}:null,f=y=>be[y]??y,k=y=>
3new Date(y).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Promo Code"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Have a promo code? Activate it to unlock temporary access."})]}),a==="claimed"&&s&&e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-xl px-4 py-3 text-sm text-green-700",children:["Promo activated! You now have ",e.jsx("strong",{children:f(s.access_tier)})," access for ",s.token_term_days," days, until ",e.jsx("strong",{children:k(s.access_ends_at)}),". A reminder has been added to your tasks."]}),a==="preview"&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-brand-50 border border-brand-200 rounded-xl p-4 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold text-brand-800",children:["Code: ",e.jsx("span",{className:"font-mono",children:s.code})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-brand-500 font-medium uppercase tracking-wide",children:"Access"}),e.jsx("p",{className:"font-semibold text-brand-900 mt-0.5",children:f(s.access_tier)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-brand-500 font-medium uppercase tracking-wide",children:"Duration"}),e.jsxs("p",{className:"font-semibold text-brand-900 mt-0.5",children:[s.token_term_days," days"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-brand-500 font-medium uppercase tracking-wide",children:"Expires"}),e.jsx("p",{className:"font-semibold text-brand-900 mt-0.5",children:new Date(s.access_ends_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})]})]}),e.jsxs("p",{className:"text-xs text-brand-600",children:["Code must be claimed by ",k(s.claim_expires_at),"."]})]}),c&&e.jsx("p",{className:"text-xs text-red-500",children:c}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{size:"sm",variant:"secondary",onClick:N,children:"Cancel"}),e.jsx(p,{size:"sm",disabled:i.isPending,onClick:()=>i.mutate(),children:i.isPending?"Activatingâ¦":"Activate promo"})]})]}),a==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:u,onChange:y=>{d(y.target.value.toUpperCase()),g(null)},placeholder:"Enter promo code",maxLength:16,className:"flex-1 rounded-lg border border-gray-300 px-3 py-2 text-sm font-mono uppercase tracking-wider focus:outline-none focus:ring-2 focus:ring-brand-500"}),e.jsx(p,{size:"sm",disabled:u.trim().length<6||b.isPending,onClick:()=>b.mutate(),children:b.isPending?"Checkingâ¦":"Claim Code"})]}),c&&e.jsx("p",{className:"text-xs text-red-500",children:c}),x&&e.jsxs("p",{className:"text-xs text-gray-400",children:["Active promo: ",e.jsx("strong",{children:f(x.tier)})," until"," ",new Date(x.endsAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})]})]})]})}function we(){const t=Q(),o=q(),n=P(g=>g.user),u=P(g=>g.logout),[d,s]=h.useState(!1),[l,a]=h.useState(!1),r=v({mutationFn:ae,onSuccess:()=>{n!=null&&n.id&&localStorage.removeItem(`sm_prefs_${n.id}`),localStorage.removeItem("sm_last_project_id"),t.invalidateQueries(),s(!1)}}),c=v({mutationFn:re,onSuccess:()=>{u(),o("/login")}});return e.jsxs("div",{className:"bg-white rounded-xl border border-red-200 p-6 space-y-5",children:[e.jsx("h2",{className:"font-semibold text-red-700",children:"Danger Zone"}),d?e.jsx($,{title:"Permanently Delete All Data",description:"This will erase all your projects and submissions.",confirmPhrase:"DELETE",pending:r.isPending,error:r.isError,onConfirm:()=>r.mutate(),onCancel:()=>s(!1)}):e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:"Delete all projects and submissions"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Permanently removes all your projects, submissions, and related history. Your account stays active."})]}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>s(!0),children:"Delete Data"})]}),e.jsx("div",{className:"border-t border-red-100"}),l?e.jsx($,{title:"Permanently Delete Account",description:"This will permanently delete your account and all data.",confirmPhrase:"DELETE",pending:c.isPending,error:c.isError,onConfirm:()=>c.mutate(),onCancel:()=>a(!1)}):e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:"Delete account"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Permanently deletes your account and all associated data. You will be signed out immediately and cannot recover anything."})]}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>a(!0),children:"Delete Account"})]})]})}function Ce(){const{data:t,refetch:o}=E({queryKey:["gmail-status"],queryFn:J}),{data:n,refetch:u}=E({queryKey:["outlook-status"],queryFn:ee}),{data:d,refetch:s}=E({queryKey:["imap-status"],queryFn:le}),[l,a]=h.useState("none"),[r,c]=h.useState(""),[g,b]=h.useState(""),[i,N]=h.useState(null),x=(t==null?void 0:t.connected)??!1,f=(n==null?void 0:n.connected)??!1,k=(d==null?void 0:d.connected)??!1,y=x||f||k,_=v({mutationFn:Z,onSuccess:C=>{window.location.href=C}}),A=v({mutationFn:W,onSuccess:()=>{o(),a("none")}}),m=v({mutationFn:V,onSuccess:C=>{window.location.href=C}}),w=v({mutationFn:H,onSuccess:()=>{u(),a("none")}}),j=v({mutationFn:()=>ie(r,g),onSuccess:()=>{s(),a("none"),c(""),b(""),N(null)},onError:C=>{var L,O;N(((O=(L=C==null?void 0:C.response)==null?void 0:L.data)==null?void 0:O.detail)??"Connection failed. Check your email and app password.")}}),S=v({mutationFn:oe,onSuccess:()=>{s(),a("none")}}),M=x?"Gmail":f?"Outlook":k?(d==null?void 0:d.label)??"Email":null,B=x?t==null?void 0:t.email:f?n==null?void 0:n.email:d==null?void 0:d.email,z=x?A:f?w:S;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 space-y-1",children:[e.jsxs("div",{className:"pb-3",children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Email Integration"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"Connect an email account to send query letters from your own address."})]}),e.jsxs("div",{className:"py-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:y?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:M}),e.jsxs("p",{className:"text-xs text-green-700 mt-0.5",children:["Connected · ",B]})]}):e.jsx("p",{className:"text-sm font-medium text-gray-800",children:"Email"})}),y?e.jsx(p,{variant:"secondary",size:"sm",disabled:z.isPending,onClick:()=>z.mutate(),children:z.isPending?"Disconnectingâ¦":"Disconnect"}):l==="providers"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{size:"sm",disabled:_.isPending,onClick:()=>_.mutate(),children:_.isPending?"Redirectingâ¦":"Gmail"}),e.jsx(p,{size:"sm",disabled:m.isPending,onClick:()=>m.mutate(),children:m.isPending?"Redirectingâ¦":"Outlook"}),e.jsx(p,{size:"sm",variant:"secondary",onClick:()=>{a("imap-form"),N(null)},children:"Other"}),e.jsx("button",{onClick:()=>a("none"),className:"text-xs text-gray-400 hover:text-gray-600 transition-colors",children:"Cancel"})]}):l!=="imap-form"?e.jsx(p,{size:"sm",onClick:()=>a("providers"),children:"Connect email"}):null]}),l==="imap-form"&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("p",{className:"text-xs text-gray-500",children:["Enter your email and an ",e.jsx("strong",{children:"app-specific password"})," (not your regular password)."," ","Works with Yahoo Mail, Mail.com, AOL, iCloud, and most providers."]}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:r,onChange:C=>c(C.target.value),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500"}),e.jsx("input",{type:"password",placeholder:"App-specific password",value:g,onChange:C=>b(C.target.value),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500"}),i&&e.jsx("p",{className:"text-xs text-red-600",children:i}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{size:"sm",disabled:!r||!g||j.isPending,onClick:()=>j.mutate(),children:j.isPending?"Connectingâ¦":"Connect"}),e.jsx("button",{onClick:()=>{a("providers"),N(null)},className:"text-xs text-gray-400 hover:text-gray-600 transition-colors",children:"Back"})]})]})]})]})}const F={free:0,pro_30:1,pro_max:2};function ke({pending:t,currentTier:o,currentName:n,onConfirm:u,onCancel:d,loading:s,error:l}){const a=F[t.tier]>F[o],r=t.tier==="free";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-xl max-w-md w-full p-6 space-y-4",children:[e.jsx("h3",{className:"font-semibold text-gray-900 text-lg",children:r?"Cancel subscription":a?`Upgrade to ${t.name}`:`Switch to ${t.name}`}),e.jsx("p",{className:"text-sm text-gray-600",children:r?`Your subscription will be cancelled at the end of your current billing period. You'll keep your ${n} features until then.`:a?`Your plan will upgrade to ${t.name} immediately. A prorated charge will be applied for the remainder of the current billing period.`:`Your plan will change to ${t.name} at the end of your current billing period. You'll keep your ${n} features until then.`}),l&&e.jsx("p",{className:"text-xs text-red-600",children:l}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx(p,{variant:"secondary",size:"sm",onClick:d,disabled:s,children:"Cancel"}),e.jsx(p,{variant:r||!a?"danger":"primary",size:"sm",onClick:u,disabled:s,children:s?"Processingâ¦":"Confirm"})]})]})})}function Se({currentTier:t,effectiveTier:o,scheduledTier:n,periodEnd:u,onTierChange:d}){var _,A;
3const[s,l]=h.useState(null),[a,r]=h.useState(null),[c,g]=h.useState(null),b=t!=="free",i=((_=T.find(m=>m.tier===t))==null?void 0:_.name)??"Free",N=((A=T.find(m=>m.tier===n))==null?void 0:A.name)??null,x=u?new Date(u).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):null;async function f(m,w,j){if(t==="free"&&m){l(w),r(null);try{const{url:S}=await ge(m);window.location.href=S}catch{r("Could not start checkout. Please try again."),l(null)}}else g({priceId:m,tier:w,name:j})}async function k(){var w,j;if(!c)return;const m=F[c.tier]>F[t];l("confirm"),r(null);try{c.tier==="free"?await he():m?await R(c.priceId):await R(c.priceId),d(),g(null)}catch(S){const M=(j=(w=S==null?void 0:S.response)==null?void 0:w.data)==null?void 0:j.detail;r(M??"Something went wrong. Please try again.")}finally{l(null)}}async function y(){l("portal"),r(null);try{const{url:m}=await pe();window.location.href=m}catch{r("Could not open billing portal. Please try again."),l(null)}}return e.jsxs(e.Fragment,{children:[c&&e.jsx(ke,{pending:c,currentTier:t,currentName:i,onConfirm:k,onCancel:()=>{g(null),r(null)},loading:s==="confirm",error:a}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Plans"}),b&&e.jsx("button",{onClick:y,disabled:s==="portal",className:"text-xs text-brand-600 hover:text-brand-800 font-medium transition-colors disabled:opacity-50",children:s==="portal"?"Openingâ¦":"Manage billing â"})]}),!c&&a&&e.jsx("p",{className:"text-xs text-red-600",children:a}),n&&x&&e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-xl px-4 py-3 text-sm text-amber-800",children:n==="free"?`Your subscription will be cancelled on ${x}. You'll keep your ${i} features until then.`:`Your plan will change to ${N} on ${x}. You'll keep your ${i} features until then.`}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:T.map(m=>{const w=t===m.tier,j=o===m.tier&&o!==t;return e.jsxs("div",{className:`bg-white rounded-xl border p-5 flex flex-col gap-4 ${j?"border-green-400 ring-1 ring-green-400":w?"border-brand-400 ring-1 ring-brand-400":"border-gray-200"}`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-semibold text-gray-800",children:m.name}),j&&e.jsx("span",{className:"text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded font-medium",children:"On Promo"}),w&&!j&&e.jsx("span",{className:"text-xs bg-brand-100 text-brand-700 px-2 py-0.5 rounded font-medium",children:"Current"})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:[m.price,e.jsx("span",{className:"text-sm font-normal text-gray-400",children:m.period})]})]}),e.jsx("ul",{className:"flex-1 space-y-1.5",children:m.features.map(S=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-gray-600",children:[e.jsx("span",{className:"text-brand-500 mt-0.5",children:"â"}),S]},S))}),e.jsx("div",{children:w||j?e.jsx("div",{className:"h-8"}):m.priceId?e.jsx(p,{size:"sm",className:"w-full",disabled:!!s,onClick:()=>f(m.priceId,m.tier,m.name),children:s===m.tier?"Redirectingâ¦":"Select"}):b&&e.jsx(p,{size:"sm",variant:"secondary",className:"w-full",disabled:!!s,onClick:()=>f(null,"free","Free"),children:"Select"})})]},m.tier)})})]})]})}function Pe(){const t=q();return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Import from QueryTracker"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Migrate your existing query history from a QueryTracker CSV export."})]}),e.jsx(p,{variant:"secondary",size:"sm",onClick:()=>t("/settings/import-querytracker"),children:"Import"})]})}function _e(){const{user:t}=P(),o=Q(),[n,u]=h.useState(""),[d,s]=h.useState(null),l=(t==null?void 0:t.effective_tier)==="pro_max",{data:a=[]}=E({queryKey:["assistants"],queryFn:me,enabled:l}),{data:r=[]}=E({queryKey:["assistant-invitations"],queryFn:ue,enabled:l}),c=v({mutationFn:()=>ce(n.trim()),onSuccess:()=>{u(""),s(null),o.invalidateQueries({queryKey:["assistant-invitations"]})},onError:i=>{var x,f;const N=(f=(x=i==null?void 0:i.response)==null?void 0:x.data)==null?void 0:f.detail;s(N??"Failed to send invitation. Please try again.")}}),g=v({mutationFn:i=>de(i),onSuccess:()=>o.invalidateQueries({queryKey:["assistants"]})}),b=r.filter(i=>!i.accepted_at);return l?e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Author Assistant"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Invite a trusted assistant to submit on your behalf. They'll have access to your account but won't be able to change your billing or delete your data."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Invite by email"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"email",value:n,onChange:i=>{u(i.target.value),s(null)},placeholder:"[email protected]",className:"flex-1 rounded-lg border border-gray-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-400"}),e.jsx(p,{size:"sm",disabled:!n.trim()||c.isPending,onClick:()=>c.mutate(),children:c.isPending?"Sendingâ¦":"Send invite"})]}),d&&e.jsx("p",{className:"text-xs text-red-600",children:d}),c.isSuccess&&e.jsx("p",{className:"text-xs text-green-600",children:"Invitation sent."})]}),a.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Active assistants"}),e.jsx("ul",{className:"divide-y divide-gray-100 rounded-lg border border-gray-200 overflow-hidden",children:a.map(i=>e.jsxs("li",{className:"flex items-center justify-between px-4 py-3 bg-white",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:i.full_name}),e.jsx("p",{className:"text-xs text-gray-500",children:i.email})]}),e.jsx(p,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>g.mutate(i.id),children:"Revoke"})]},i.id))})]}),b.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Pending invitations"}),e.jsx("ul",{className:"divide-y divide-gray-100 rounded-lg border border-gray-200 overflow-hidden",children:b.map(i=>e.jsxs("li",{className:"flex items-center justify-between px-4 py-3 bg-white",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-800",children:i.invitee_email}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Expires ",new Date(i.expires_at).toLocaleDateString()]})]}),e.jsx("span",{className:"text-xs text-yellow-600 font-medium",children:"Pending"})]},i.id))})]})]}):null}function ze(){const{user:t,token:o,setAuth:n,logout:u}=P(),d=q(),[s]=U(),{hash:l}=G(),a=s.get("upgraded")==="1",r=s.get("gmail")==="connected",c=s.get("gmail")==="error",g=s.get("reason"),b=s.get("outlook")==="connected",i=s.get("outlook")==="error",N=s.get("reason");return h.useEffect(()=>{if(o&&((r||c||b||i)&&D().then(x=>n(o,x)).catch(()=>{}),a)){let x=0;const f=setInterval(()=>{x++,ye().then(()=>D()).then(k=>{n(o,k),(k.subscription_tier!=="free"||x>=10)&&clearInterval(f)}).catch(()=>clearInterval(f))},1500);return()=>clearInterval(f)}},[a,r,c,b,i,o,n]),h.useEffect(()=>{if(!l)return;const x=document.getElementById(l.slice(1));x&&x.scrollIntoView({behavior:"smooth",block:"start"})},[l]),e.jsxs("div",{className:"space-y-8 max-w-2xl",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Settings"}),a&&e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-xl px-4 py-3 text-sm text-green-700",children:"Your plan has been upgraded successfully."}),r&&e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-xl px-4 py-3 text-sm text-green-700",children:"Gmail connected successfully."}),c&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-xl px-4 py-3 text-sm text-red-700",children:g==="already_connected"?"This Gmail account is already connected to another SubmitMe account. Please disconnect it there first.":"Failed to connect Gmail. Please try again."}),b&&e.jsx("div",{className:"bg-green-50 border border-green-200 rounded-xl px-4 py-3 text-sm text-green-700",children:"Outlook connected successfully."}),i&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-xl px-4 py-3 text-sm text-red-700",children:N==="already_connected"?"This Outlook account is already connected to another SubmitMe account. Please disconnect it there first.":"Failed to connect Outlook. Please try again."}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 space-y-4",children:[e.jsx("h2",{className:"font-semibold text-gray-800",children:"Account"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500",children:"Name"}),e.jsx("p",{className:"font-medium text-gray-800 mt-0.5",children:t==null?void 0:t.full_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500",children:"Email"}),e.jsx("p",{className:"font-medium text-gray-800 mt-0.5",children:t==null?void 0:t.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-500",children:"Current plan"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(xe,{tier:(t==null?void 0:t.subscription_tier)??"free"})})]})]}),e.jsx("div",{className:"sm:hidden pt-2 border-t border-gray-100",children:e.jsxs("button",{onClick:()=>{u(),d("/login")},className:"flex items-center gap-2 text-sm text-gray-500 hover:text-gray-800 transition-colors",children:[e.jsx(K,{size:14}),"Sign out"]})})]}),e.jsx(Se,{currentTier:(t==null?void 0:t.subscription_tier)??"free",effectiveTier:(t==null?void 0:t.effective_tier)??(t==null?void 0:t.subscription_tier)??"free",sc
3heduledTier:(t==null?void 0:t.scheduled_tier)??null,periodEnd:(t==null?void 0:t.subscription_period_end)??null,onTierChange:()=>{o&&D().then(x=>n(o,x)).catch(()=>{})}}),e.jsx(Ce,{}),e.jsx(fe,{}),e.jsx(_e,{}),e.jsx(ve,{}),e.jsx(Pe,{}),e.jsx(Ne,{}),e.jsx(we,{})]})}export{ze 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.