1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de4b8822-ae0c-4dd1-afd5-c1cbf5ff588d",e._sentryDebugIdIdentifier="sentry-dbid-de4b8822-ae0c-4dd1-afd5-c1cbf5ff588d")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8722],{2647:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]])},9921:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},10184:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]])},13545:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},15195:(e,t,a)=>{"use strict";a.d(t,{l:()=>p});var s=a(95155),n=a(12115),l=a(20989),r=a(27529),i=a(51268),d=a(40980),c=a(79372);let o={free:"bg-gray-100 text-gray-600",pro:"bg-blue-50 text-blue-700",enterprise:"bg-purple-50 text-purple-700"},x={active:"bg-green-50 text-green-700",trialing:"bg-blue-50 text-blue-700",past_due:"bg-amber-50 text-amber-700",cancelled:"bg-red-50 text-red-700",paused:"bg-gray-100 text-gray-600"};function u(e){return e?(0,d.r6)(e):"â"}let m={no_rail:"No Razorpay subscription or payment link on this tenant â nothing to reconcile.",razorpay_unconfigured:"Razorpay is not configured in this environment.",link_not_paid:"The tenantâs payment link has not been paid â cached values left untouched."};function p({companyId:e,companyName:t,onClose:a}){let[d,g]=(0,n.useState)(null),[y,b]=(0,n.useState)([]),[j,f]=(0,n.useState)(!0),[v,N]=(0,n.useState)(""),[w,C]=(0,n.useState)(!1),[k,S]=(0,n.useState)(""),A=(0,n.useCallback)(async()=>{f(!0),N("");try{let t=await r.Dw.getSubscription(e);g(t.subscription),b(t.events)}catch(e){N((0,i.Q)(e,"Failed to load subscription"))}finally{f(!1)}},[e]);(0,n.useEffect)(()=>{A()},[A]);let D=async()=>{C(!0),S(""),N("");try{let t=await r.Dw.refreshSubscription(e);t.refreshed?(S(`Updated from Razorpay: ${t.changed?.join(", ")}`),await A()):S(m[t.reason??""]??"Already in sync with Razorpay.")}catch(e){N((0,i.Q)(e,"Failed to refresh from Razorpay"))}finally{C(!1)}};return(0,s.jsx)(l.a,{title:"Subscription",subtitle:t,size:"md",onClose:a,children:(0,s.jsxs)("div",{className:"p-5 space-y-4","data-testid":"subscription-info",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Razorpay is the source of truth. Refresh re-reads it and repairs these cached values; plan and comp changes live in Edit company."}),j&&(0,s.jsx)("p",{className:"text-xs text-gray-400 py-2",children:"Loadingâ¦"}),v&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:v}),!j&&!v&&d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"subscription-badges",children:[(0,s.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${o[d.plan]??"bg-gray-100 text-gray-600"}`,children:d.plan}),d.subscriptionStatus&&(0,s.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${x[d.subscriptionStatus]??"bg-gray-100 text-gray-600"}`,children:d.subscriptionStatus}),d.cancelAtPeriodEnd&&(0,s.jsx)("span",{className:"rounded-full px-2 py-0.5 text-xs font-medium bg-amber-50 text-amber-700",children:"cancels at period end"})]}),(0,s.jsxs)("dl",{className:"grid grid-cols-1 gap-2 text-xs",children:[(0,s.jsx)(h,{label:"Current period start",value:u(d.currentPeriodStart)}),(0,s.jsx)(h,{label:"Current period end",value:u(d.currentPeriodEnd)}),(0,s.jsx)(h,{label:"Last payment",value:u(d.lastPaymentAt)}),(0,s.jsx)(h,{label:"Comped since",value:d.compedAt?u(d.compedAt):"Not comped"}),(0,s.jsx)(h,{label:"Razorpay subscription id",value:d.razorpaySubscriptionId??"â",mono:!0}),(0,s.jsx)(h,{label:"Razorpay customer id",value:d.razorpayCustomerId??"â",mono:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-gray-500 mb-2 uppercase tracking-wide",children:["Recent events ",y.length?`(${y.length})`:""]}),0===y.length?(0,s.jsxs)("div",{className:"text-center py-6 text-gray-400",children:[(0,s.jsx)(c.A,{size:28,className:"mx-auto mb-2 opacity-30"}),(0,s.jsx)("p",{className:"text-xs",children:"No subscription events recorded yet."})]}):(0,s.jsx)("div",{className:"space-y-1.5","data-testid":"subscription-events",children:y.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-gray-100 px-3 py-2",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.eventType})}),(0,s.jsx)("span",{className:"text-[11px] text-gray-400 shrink-0",children:u(e.createdAt)})]},e.id))})]})]}
1),k&&(0,s.jsx)("p",{className:"rounded-lg bg-blue-50 px-3 py-2 text-xs text-blue-800","data-testid":"refresh-note",children:k}),(0,s.jsxs)("div",{className:"flex justify-between pt-1",children:[(0,s.jsx)("button",{type:"button",onClick:D,disabled:j||w,className:"btn text-xs","data-testid":"refresh-subscription",children:w?"Refreshingâ¦":"Refresh from Razorpay"}),(0,s.jsx)("button",{type:"button",onClick:a,className:"btn text-xs",children:"Done"})]})]})})}function h({label:e,value:t,mono:a}){return(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3 border-b border-gray-50 pb-1.5 last:border-0",children:[(0,s.jsx)("dt",{className:"text-gray-400 shrink-0",children:e}),(0,s.jsx)("dd",{className:`text-gray-900 text-right break-all ${a?"font-mono text-[11px]":""}`,children:t})]})}},19215:(e,t,a)=>{"use strict";a.d(t,{d:()=>o,y:()=>c});var s=a(95155),n=a(12115),l=a(40980),r=a(52484),i=a(62791),d=a(33210);function c({message:e,type:t,onDismiss:a}){return(0,n.useEffect)(()=>{let e=setTimeout(a,4e3);return()=>clearTimeout(e)},[a]),(0,s.jsxs)("div",{className:(0,l.cn)("flex items-start gap-3 rounded-xl border px-4 py-3 text-sm shadow-sm","success"===t?"border-green-100 bg-green-50 text-green-800":"border-red-100 bg-red-50 text-red-800"),children:["success"===t?(0,s.jsx)(r.A,{size:16,className:"mt-0.5 shrink-0 text-green-600"}):(0,s.jsx)(i.A,{size:16,className:"mt-0.5 shrink-0 text-red-500"}),(0,s.jsx)("span",{className:"flex-1",children:e}),(0,s.jsx)("button",{onClick:a,"aria-label":"Dismiss",title:"Dismiss",className:"shrink-0 opacity-50 hover:opacity-100",children:(0,s.jsx)(d.A,{size:14})})]})}function o(){let[e,t]=(0,n.useState)(null);return{toast:e,show:(0,n.useCallback)((e,a="success")=>t({message:e,type:a}),[]),dismiss:(0,n.useCallback)(()=>t(null),[])}}},20989:(e,t,a)=>{"use strict";a.d(t,{a:()=>r});var s=a(95155),n=a(33210),l=a(80086);function r({title:e,subtitle:t,onClose:a,children:i,size:d="sm"}){return(0,l.yJ)(),(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:(0,s.jsxs)("div",{className:`bg-white rounded-xl shadow-lg w-full max-w-[calc(100vw-1rem)] ${"md"===d?"sm:max-w-md":"sm:max-w-sm"} max-h-[90dvh] overflow-y-auto`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"font-semibold text-gray-900",children:e}),t&&(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:t})]}),(0,s.jsx)("button",{onClick:a,"aria-label":"Close",title:"Close",className:"text-gray-400 hover:text-gray-600",children:(0,s.jsx)(n.A,{size:18})})]}),i]})})}},47831:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]])},48336:(e,t,a)=>{Promise.resolve().then(a.bind(a,62848))},51268:(e,t,a)=>{"use strict";a.d(t,{Q:()=>n});var s=a(27529);function n(e,t){if(e instanceof s.hD){let t="string"==typeof e.data?.message?e.data.message.trim():"";if(t)return t;if(e.message&&!l.test(e.message))return e.message}return t}let l=/^[a-z0-9]+(?:_[a-z0-9]+)*$/},51914:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},52484:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("CircleCheckBig",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},61878:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},62791:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},62848:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>G});var s=a(95155),n=a(12115),l=a(73321),r=a(97086),i=a(27529),d=a(51159),c=a(19215),o=a(40980),x=a(20989),u=a(51268);
1let m={name:"",plan:"free",adminName:"",adminEmail:""};function p({onClose:e,onCreated:t}){let[a,l]=(0,n.useState)(m),[r,d]=(0,n.useState)(""),[c,o]=(0,n.useState)(!1),g=e=>t=>l(a=>({...a,[e]:t.target.value})),y=async e=>{if(e.preventDefault(),!a.name.trim())return void d("Company name is required");d(""),o(!0);try{let e=await i.Dw.createCompany(a);t(e.company)}catch(e){d((0,u.Q)(e,"Failed to create company"))}finally{o(!1)}};return(0,s.jsx)(x.a,{title:"New company",onClose:e,size:"md",children:(0,s.jsxs)("form",{onSubmit:y,className:"p-5 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Company name ",(0,s.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,s.jsx)("input",{className:"input",value:a.name,onChange:g("name"),placeholder:"Acme Staffing",autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Plan"}),(0,s.jsx)(h,{value:a.plan,onChange:g("plan")})]}),(0,s.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-gray-500 mb-3",children:"First admin (optional)"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Admin name"}),(0,s.jsx)("input",{className:"input",value:a.adminName,onChange:g("adminName"),placeholder:"Jane Smith"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Admin email"}),(0,s.jsx)("input",{className:"input",type:"email",value:a.adminEmail,onChange:g("adminEmail"),placeholder:"[email protected]"})]})]}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-2",children:"They get an email to verify and sign in (plus a temporary password for later)."})]}),r&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:r}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,s.jsx)("button",{type:"button",onClick:e,className:"btn text-xs",children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:c,className:"btn-primary text-xs",children:c?"Creatingâ¦":"Create company"})]})]})})}function h({value:e,onChange:t}){return(0,s.jsxs)("select",{className:"input",value:e,onChange:t,children:[(0,s.jsx)("option",{value:"free",children:"Free"}),(0,s.jsx)("option",{value:"starter",children:"Starter"}),(0,s.jsx)("option",{value:"pro",children:"Pro"}),(0,s.jsx)("option",{value:"enterprise",children:"Enterprise (deprecated)"}),(0,s.jsx)("option",{value:"legacy_free",children:"Free â legacy (grandfathered)"})]})}let g=new Set(["free","legacy_free"]);function y(){return new Date(Date.now()+2592e6).toISOString().slice(0,10)}function b({company:e,initialPlan:t,onClose:a,onSaved:l}){let[r,d]=(0,n.useState)({name:e.name,plan:t??e.plan}),[c,o]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[h,j]=(0,n.useState)(!1),[f,v]=(0,n.useState)(y),[N,w]=(0,n.useState)(""),[C,k]=(0,n.useState)(!1),S=r.plan!==e.plan,A=g.has(r.plan),D=S&&!A,E=async t=>{t.preventDefault(),w(""),k(!0);try{await i.Dw.updateCompany(e.id,{name:r.name,...S?{plan:r.plan,reason:c,...m.trim()?{ticketId:m.trim()}:{},...D?h?{perpetual:!0}:{compUntil:new Date(`${f}T23:59:59Z`).toISOString()}:{}}:{}}),l()}catch(e){w((0,u.Q)(e,"Failed to save"))}finally{k(!1)}};return(0,s.jsx)(x.a,{title:"Edit company",onClose:a,children:(0,s.jsxs)("form",{onSubmit:E,className:"p-5 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Company name"}),(0,s.jsx)("input",{className:"input",value:r.name,onChange:e=>d(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Plan"}),(0,s.jsxs)("select",{className:"input",value:r.plan,onChange:e=>d(t=>({...t,plan:e.target.value})),children:[(0,s.jsx)("option",{value:"free",children:"Free"}),(0,s.jsx)("option",{value:"lite",children:"Lite"}),(0,s.jsx)("option",{value:"starter",children:"Starter"}),(0,s.jsx)("option",{value:"pro",children:"Pro"}),(0,s.jsx)("option",{value:"enterprise",children:"Enterprise (deprecated)"}),(0,s.jsx)("option",{value:"legacy_free",children:"Free â legacy (grandfathered)"})]})]}),S&&(0,s.jsxs)("div",{className:"space-y-4 rounded-lg border border-amber-200 bg-amber-50 p-3",children:[(0,s.jsx)("p",{className:"text-xs text-amber-900",children:"This is a manual billing override â no payment is taken. It is recorded in the audit log."}),D&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Comp window"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,s.jsx)("input",{type:"radio",checked:!h,onChange:()=>j(!1)}),(0,s.jsx)("span",{children:"Until"}),(0,s.jsx)("input",{type:"date",className:"input py-1 text-xs",value:f,disabled:h,min:new Date().toISOString().slice(0,10),onChange:e=>v(e.target.value)})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,s.jsx)("input",{type:"radio",checked:h,onChange:()=>j(!0)}),(0,s.jsx)("span",{children:"Perpetual â never lapses, tenant is never billed"})]})]}),h&&(0,s.jsx)("p",{className:"mt-2 text-xs text-amber-800",children:"A perpetual comp is invisible to the lapse-downgrade cron. Prefer a dated window."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Reason ",(0,s.jsx)("span",{className:"text-red-600",children:"*"})]}),(0,s.jsx)("input",{className:"input",value:c,maxLength:500,required:!0,placeholder:"e.g. comped through pilot, per support ticket",onChange:e=>o(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Support ticket ID ",(0,s.jsx)("span",{className:"text-gray-400",children:"(optional)"})]}),(0,s.jsx)("input",{className:"input",value:m,onChange:e=>p(e.target.value)})]})]}),N&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:N}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:a,className:"btn text-xs",children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:C,className:"btn-primary text-xs",children:C?"Savingâ¦":"Save changes"})]})]})})}let j={name:"",email:"",role:"recruiter"};function f({company:e,onClose:t,onAdded:a}
1){let[l,r]=(0,n.useState)(j),[d,c]=(0,n.useState)(""),[o,m]=(0,n.useState)(!1),p=async t=>{if(t.preventDefault(),!l.name||!l.email)return void c("Name and email required");c(""),m(!0);try{await i.Dw.addCompanyUser(e.id,l),a()}catch(e){c((0,u.Q)(e,"Failed to add user"))}finally{m(!1)}};return(0,s.jsx)(x.a,{title:"Add user",subtitle:e.name,onClose:t,children:(0,s.jsxs)("form",{onSubmit:p,className:"p-5 space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Full name"}),(0,s.jsx)("input",{className:"input",value:l.name,onChange:e=>r(t=>({...t,name:e.target.value})),placeholder:"Anita Sharma",autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Email"}),(0,s.jsx)("input",{className:"input",type:"email",value:l.email,onChange:e=>r(t=>({...t,email:e.target.value})),placeholder:"[email protected]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Role"}),(0,s.jsxs)("select",{className:"input",value:l.role,onChange:e=>r(t=>({...t,role:e.target.value})),children:[(0,s.jsx)("option",{value:"recruiter",children:"Recruiter"}),(0,s.jsx)("option",{value:"bd",children:"BD (clients, fees, revenue)"}),(0,s.jsx)("option",{value:"company_admin",children:"Company admin"})]}),(0,s.jsxs)("p",{className:"mt-1 text-[11px] text-gray-400",children:["To add a ",(0,s.jsx)("strong",{children:"client"})," (portal access), use the company's Clients page â a client user is tied to one client company."]})]}),d&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:d}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,s.jsx)("button",{type:"button",onClick:t,className:"btn text-xs",children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:o,className:"btn-primary text-xs",children:o?"Addingâ¦":"Add user + send email"})]})]})})}var v=a(78340);let N=(0,v.A)("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);function w({company:e,users:t,loading:a,onClose:n,onPick:l}){let r=t.filter(e=>"approved"===e.status);return(0,s.jsx)(x.a,{title:"Log in asâ¦",subtitle:e.name,onClose:n,children:(0,s.jsxs)("div",{className:"p-4 space-y-2 max-h-72 overflow-y-auto",children:[a&&(0,s.jsx)("p",{className:"text-sm text-gray-400 text-center py-4",children:"Loadingâ¦"}),!a&&0===r.length&&(0,s.jsx)("p",{className:"text-sm text-gray-400 text-center py-4",children:"No approved users found."}),!a&&r.map(e=>(0,s.jsxs)("button",{onClick:()=>l(e.id),className:"w-full flex items-center gap-3 rounded-lg border border-gray-100 px-3 py-2.5 hover:bg-brand-50 hover:border-brand-200 transition-colors text-left",children:[(0,s.jsx)("div",{className:(0,o.cn)("flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-medium",(0,o.V7)(e.name)),children:(0,o.yC)(e.name)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-gray-400 truncate",children:e.email})]}),(0,s.jsx)("span",{className:(0,o.cn)("badge text-[11px] shrink-0",o._t[e.role]),children:o.fn[e.role]}),(0,s.jsx)(N,{size:13,className:"text-gray-300 shrink-0"})]},e.id))]})})}let C=(0,v.A)("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);var k=a(68459);let S={hard_bounce:"Hard bounce",spam_complaint:"Spam complaint",unsubscribe:"Unsubscribed",manual:"Manual"},A={hard_bounce:"bg-red-50 text-red-700",spam_complaint:"bg-orange-50 text-orange-700",unsubscribe:"bg-amber-50 text-amber-700",manual:"bg-gray-100 text-gray-600"};function D({company:e,onClose:t}
1){let[a,l]=(0,n.useState)([]),[r,d]=(0,n.useState)(!0),[c,o]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[h,g]=(0,n.useState)("manual"),[y,b]=(0,n.useState)(""),[j,f]=(0,n.useState)(!1),v=(0,n.useCallback)(async()=>{d(!0);try{let t=await i.Dw.listSuppressions(e.id);l(t.suppressions)}catch(e){o((0,u.Q)(e,"Failed to load suppressions"))}finally{d(!1)}},[e.id]);(0,n.useEffect)(()=>{v()},[v]);let N=async t=>{if(t.preventDefault(),!m.trim())return void o("Email required");o(""),f(!0);try{await i.Dw.addSuppression(e.id,{email:m.trim(),reason:h,notes:y.trim()||void 0}),p(""),b(""),g("manual"),await v()}catch(e){o((0,u.Q)(e,"Failed to add suppression"))}finally{f(!1)}},w=async t=>{if(window.confirm(`Remove ${t.email} from the suppression list? This tenant will be able to email that address again.`)){o("");try{await i.Dw.removeSuppression(e.id,t.email),await v()}catch(e){o((0,u.Q)(e,"Failed to remove suppression"))}}};return(0,s.jsx)(x.a,{title:"Email suppressions",subtitle:e.name,size:"md",onClose:t,children:(0,s.jsxs)("div",{className:"p-5 space-y-4",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Addresses here are skipped by every outbound email for this tenant. Other tenants are unaffected. Security mail (password reset, account locked) always sends regardless."}),(0,s.jsxs)("form",{onSubmit:N,className:"space-y-2 rounded-lg border border-gray-100 p-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Email address"}),(0,s.jsx)("input",{className:"input",type:"email",value:m,"data-testid":"suppression-email",onChange:e=>p(e.target.value),placeholder:"[email protected]",autoFocus:!0})]}),(0,s.jsx)("div",{className:"flex gap-2",children:(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"label",children:"Reason"}),(0,s.jsxs)("select",{className:"input",value:h,"data-testid":"suppression-reason",onChange:e=>g(e.target.value),children:[(0,s.jsx)("option",{value:"manual",children:"Manual"}),(0,s.jsx)("option",{value:"hard_bounce",children:"Hard bounce"}),(0,s.jsx)("option",{value:"spam_complaint",children:"Spam complaint"}),(0,s.jsx)("option",{value:"unsubscribe",children:"Unsubscribed"})]})]})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Notes ",(0,s.jsx)("span",{className:"text-gray-300",children:"(optional)"})]}),(0,s.jsx)("input",{className:"input",value:y,onChange:e=>b(e.target.value),placeholder:"Why this address was suppressed"})]}),c&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",children:c}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)("button",{type:"submit",disabled:j,className:"btn-primary text-xs","data-testid":"suppression-add",children:j?"Addingâ¦":"Suppress address"})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-xs font-medium text-gray-500 mb-2 uppercase tracking-wide",children:["Suppressed ",r?"":`(${a.length})`]}),r&&(0,s.jsx)("p",{className:"text-xs text-gray-400 py-2",children:"Loadingâ¦"}),!r&&0===a.length&&(0,s.jsxs)("div",{className:"text-center py-6 text-gray-400",children:[(0,s.jsx)(C,{size:28,className:"mx-auto mb-2 opacity-30"}),(0,s.jsx)("p",{className:"text-xs",children:"No suppressed addresses for this tenant."})]}),!r&&a.length>0&&(0,s.jsx)("div",{className:"space-y-1.5","data-testid":"suppression-list",children:a.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-gray-100 px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.email}),e.notes&&(0,s.jsx)("p",{className:"text-xs text-gray-400 truncate",children:e.notes})]}),(0,s.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-medium shrink-0 ${A[e.reason]}`,children:S[e.reason]}),(0,s.jsx)("button",{onClick:()=>w(e),title:"Remove from suppression list",className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-lg shrink-0",children:(0,s.jsx)(k.A,{size:14})})]},e.id))})]}),(0,s.jsx)("div",{className:"flex justify-end pt-1",children:(0,s.jsx)("button",{type:"button",onClick:t,className:"btn text-xs",children:"Done"})})]})})}var E=a(15195);function z(e){return("free"===e.plan||"legacy_free"===e.plan)&&("tri
1aling"===e.subscriptionStatus||"trial_expired"===e.subscriptionStatus)}let T=e=>e.toISOString().slice(0,10);function $(e={},t=new Date){let a=T(new Date(t.getTime()+864e5)),s=e.trialEndsAt?new Date(e.trialEndsAt):null;if(s&&!Number.isNaN(s.getTime())){let e=T(new Date(s.getTime()+864e5));e>a&&(a=e)}return{min:a,max:T(new Date(t.getTime()+31536e6))}}let _=e=>new Date(e).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric",timeZone:"UTC"});function F({company:e,onClose:t,onExtended:a}){let{min:l,max:r}=$(e),d=l>r,[c,o]=(0,n.useState)(()=>(function(e,t=new Date){let a=e.trialEndsAt?new Date(e.trialEndsAt):null,s=T(new Date((a&&!Number.isNaN(a.getTime())&&a.getTime()>t.getTime()?a:t).getTime()+2592e6)),{min:n,max:l}=$(e,t);return s<n?n:s>l?l:s})(e)),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(""),[g,y]=(0,n.useState)(""),[b,j]=(0,n.useState)(!1),f="trial_expired"===e.subscriptionStatus,v="suspended"===e.status,N="pending_purge"===e.status,w=N&&!!e.purgeScheduledBy,C=async t=>{t.preventDefault(),y(""),j(!0);try{let t=await i.Dw.extendTrial(e.id,{until:new Date(`${c}T23:59:59Z`).toISOString(),reason:u.trim(),...p.trim()?{ticketId:p.trim()}:{}}),s=[`${e.name}: trial extended to ${_(t.trialEndsAt)}`];t.reopened&&s.push("access reopened"),t.purgeCancelled&&s.push("scheduled deletion cancelled"),t.stillSuspended&&s.push("still suspended â reactivate to let them sign in"),a(s.join(" \xb7 "))}catch(e){y(e instanceof i.hD&&"string"==typeof e.data?.message?e.data.message:"Could not extend the trial. Nothing was changed.")}finally{j(!1)}};return(0,s.jsx)(x.a,{title:"Extend free trial",onClose:t,children:(0,s.jsxs)("form",{onSubmit:C,className:"p-5 space-y-4","data-testid":"extend-trial-modal",children:[(0,s.jsxs)("p",{className:"text-sm text-gray-700",children:[(0,s.jsx)("span",{className:"font-medium",children:e.name}),e.trialEndsAt?(0,s.jsxs)(s.Fragment,{children:[" â trial ",f?"ended":"ends"," ",(0,s.jsx)("span",{className:"font-medium",children:_(e.trialEndsAt)})]}):null]}),w?(0,s.jsx)("p",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-800",role:"alert",children:"A super admin scheduled this tenant for deletion by hand. Cancel that deletion first if you mean to keep them â extending the trial will not undo it."}):(f||N)&&(0,s.jsxs)("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:[f&&!v&&"This trial has lapsed. Extending it reopens full access. ",N&&"The scheduled deletion will be cancelled."]}),v&&(0,s.jsxs)("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",role:"alert",children:["This tenant is ",(0,s.jsx)("span",{className:"font-medium",children:"suspended"}),". Extending the trial will not let them sign in â reactivate the company separately if that is what you want."]}),d&&(0,s.jsxs)("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",role:"alert",children:["This trial already runs to the ",365,"-day limit. For longer, use a comp."]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",htmlFor:"extend-trial-until",children:"New trial end"}),(0,s.jsx)("input",{id:"extend-trial-until",type:"date",className:"input",value:c,min:l,max:r,required:!0,onChange:e=>o(e.target.value)}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-gray-500",children:["Through the end of that day (UTC). Up to ",365," days ahead â for longer, use a comp."]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",htmlFor:"extend-trial-reason",children:["Reason ",(0,s.jsx)("span",{className:"text-red-600",children:"*"})]}),(0,s.jsx)("input",{id:"extend-trial-reason",className:"input",value:u,maxLength:500,required:!0,placeholder:"e.g. still onboarding their team, asked for more time",onChange:e=>m(e.target.value)}),(0,s.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Recorded in the audit log."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",htmlFor:"extend-trial-ticket",children:["Support ticket ID ",(0,s.jsx)("span",{className:"text-gray-400",children:"(optional)"})]}),(0,s.jsx)("input",{id:"extend-trial-ticket",className:"input",value:p,onChange:e=>h(e.target.value)})]}),g&&(0,s.jsx)("p",{className:"rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700",role:"alert",children:g}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:t,className:"btn text-xs",children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:b||w||d||!u.trim(),className:"btn-primary text-xs",children:b?"Extendingâ¦":"Extend trial"})]})]})})}var M=a(50049),P=a(7810),R=a(89974),I=a(10184),U=a(13545),L=a(94514),q=a(33210),O=a(61878),V=a(51914),Q=a(79372),J=a(2647),H=a(49619),W=a(47831),B=a(63519),Z=a(9921),X=a(66088);let Y={active:"bg-green-50 text-green-700",inactive:"bg-gray-100 text-gray-500",suspended:"bg-red-50 text-red-700",pending:"bg-amber-50 text-amber-700",rejected:"bg-gray-100 text-gray-400"};function G(){let{user:e,startImpersonation:t}=(0,d.A)(),a=(0,l.useRouter)(),{toast:x,show:m,dismiss:h}
1=(0,c.d)(),[g,y]=(0,n.useState)(null),[j,v]=(0,n.useState)([]),[N,C]=(0,n.useState)([]),[k,S]=(0,n.useState)(!0),[A,z]=(0,n.useState)(""),[T,$]=(0,n.useState)("all"),[_,Q]=(0,n.useState)("all"),[J,H]=(0,n.useState)(""),[W,B]=(0,n.useState)([]),[Z,X]=(0,n.useState)(!1),[G,ee]=(0,n.useState)(null),[et,ea]=(0,n.useState)({}),[es,en]=(0,n.useState)(null),[el,er]=(0,n.useState)(!1),[ei,ed]=(0,n.useState)(null),[ec,eo]=(0,n.useState)(null),[ex,eu]=(0,n.useState)(null),[em,ep]=(0,n.useState)(null),[eh,eg]=(0,n.useState)(null),[ey,eb]=(0,n.useState)(null),[ej,ef]=(0,n.useState)(null),[ev,eN]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&"super_admin"!==e.role&&a.replace("/dashboard")},[e,a]);let ew=(0,n.useCallback)(async()=>{if(e&&"super_admin"===e.role){S(!0);try{let[e,t,a]=await Promise.all([i.Dw.getStats(),i.Dw.listCompanies(),i.Dw.listPendingCompanies()]);y(e.stats),v(t.companies),C(a.companies)}catch{}finally{S(!1)}}},[e]);(0,n.useEffect)(()=>{ew()},[ew]),(0,n.useEffect)(()=>{if(!J.trim())return void B([]);let e=setTimeout(async()=>{X(!0);try{let e=await i.Dw.searchUsers(J);B(e.users)}finally{X(!1)}},400);return()=>clearTimeout(e)},[J]);let eC=async e=>{if(et[e])return et[e];en(e);try{let t=await i.Dw.listCompanyUsers(e);return ea(a=>({...a,[e]:t.users})),t.users}finally{en(null)}},ek=async e=>{G===e.id?ee(null):(ee(e.id),await eC(e.id))},eS=async e=>{let t="active"===e.status?"suspended":"active";try{await i.Dw.updateCompany(e.id,{status:t}),m(`${e.name} ${"active"===t?"activated":"suspended"}`),await ew()}catch{m("Failed to update status")}},eA=async(e,t)=>{let a=Math.max(1,Math.floor(t));if(a!==(e.seatCount??2))try{await i.Dw.updateCompany(e.id,{seatCount:a}),m(`${e.name} â ${a} seat${1===a?"":"s"} (manual)`),await ew()}catch{m("Failed to update seats")}},eD=async e=>{let t=!e.agentWriteEnabled;try{await i.Dw.updateCompany(e.id,{agentWriteEnabled:t}),m(`${e.name}: agent writes ${t?"enabled":"disabled"}`),await ew()}catch{m("Failed to update agent writes")}},eE=async e=>{try{await i.Dw.approveCompany(e.id),m(`${e.name} approved`),await ew()}catch{m("Failed to approve")}},ez=async e=>{try{await i.Dw.rejectCompany(e.id),m(`${e.name} rejected`),await ew()}catch{m("Failed to reject")}},eT=async e=>{if(window.confirm(`Schedule "${e.name}" for permanent deletion? 2 3All tenant data â candidates, jobs, applications, resumes, etc. â will be erased after 30 days. You can cancel any time during the grace window from this page.`))try{let t=await i.Dw.schedulePurge(e.id),a=new Date(t.purgeScheduledAt).toLocaleDateString();m(`${e.name} scheduled for deletion on ${a}`),await ew()}catch(e){m((0,u.Q)(e,"Failed to schedule deletion"))}},e$=async e=>{try{await i.Dw.cancelPurge(e.id),m(`${e.name} deletion cancelled â back to suspended`),await ew()}catch(e){m((0,u.Q)(e,"Failed to cancel deletion"))}},e_=async e=>{let t=window.prompt(`IMMEDIATE PERMANENT DELETION of "${e.name}". 4 5This skips the 30-day grace window. Data cannot be recovered. 6 7Type the company name exactly to confirm:`);if(null!==t){if(!(0,o.ff)(t,e.name))return void m("Confirmation text did not match â purge cancelled");try{let t=await i.Dw.purgeNow(e.id),a=Object.values(t.report.recordsDeleted).reduce((e,t)=>e+t,0);m(`${e.name} purged â ${a} rows + ${t.report.gcsFilesDeleted} files deleted`),await ew()}catch(t){let e=t instanceof i.hD?t.data?.message||t.message:"check audit log for details";m(`Purge failed â ${e}`)}}},eF=async(e,a)=>{eN(!0);try{let s=await i.Dw.impersonate(e.id,a);t(void 0,s.user)}catch(e){m((0,u.Q)(e,"No active user found for this company")),eN(!1)}},eM=async e=>{let t=(await eC(e.id)).filter(e=>"approved"===e.status);1===t.length?eF(e,t[0].id):ep(e)},eP=j.filter(e=>(!A||!!e.name.toLowerCase().includes(A.toLowerCase()))&&("all"===T||e.status===T)&&("all"===_||e.plan===_));return(0,s.jsx)(r.A,{children:(0,s.jsxs)("div",{className:"p-6 max-w-4xl mx-auto space-y-6",children:[g&&(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Companies",value:g.activeCompanies,sub:`${g.totalCompanies} total`,icon:M.A,color:"text-blue-600"},{label:"Users",value:g.activeUsers,sub:`${g.totalUsers}
7 total`,icon:P.A,color:"text-purple-600"},{label:"Open Jobs",value:g.openJobs,sub:"across all companies",icon:R.A,color:"text-green-600"},{label:"Candidates",value:g.totalCandidates,sub:"all tenants",icon:I.A,color:"text-amber-600"}].map(({label:e,value:t,sub:a,icon:n,color:l})=>(0,s.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:e}),(0,s.jsx)(n,{size:14,className:l})]}),(0,s.jsx)("p",{className:"text-2xl font-semibold text-gray-900",children:t}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:a})]},e))}),N.length>0&&(0,s.jsxs)("div",{className:"bg-amber-50 rounded-xl border border-amber-100 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)(U.A,{size:15,className:"text-amber-600"}),(0,s.jsxs)("h2",{className:"text-sm font-medium text-amber-800",children:["Pending approvals",(0,s.jsx)("span",{className:"ml-1.5 bg-amber-200 text-amber-800 text-xs rounded-full px-1.5 py-0.5",children:N.length})]})]}),(0,s.jsx)("div",{className:"space-y-2",children:N.map(e=>(0,s.jsxs)("div",{className:"bg-white rounded-lg border border-amber-100 px-3 py-2.5 flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900",children:e.name}),(0,s.jsxs)("p",{className:"text-xs text-gray-400",children:["Requested ",(0,o.Yq)(e.createdAt)," \xb7 by ",e.createdBy]})]}),(0,s.jsxs)("div",{className:"flex gap-1.5 shrink-0",children:[(0,s.jsxs)("button",{onClick:()=>eE(e),className:"btn text-xs bg-green-50 text-green-700 border-green-100 hover:bg-green-100",children:[(0,s.jsx)(L.A,{size:12})," Approve"]}),(0,s.jsxs)("button",{onClick:()=>ez(e),className:"btn-danger text-xs",children:[(0,s.jsx)(q.A,{size:12})," Reject"]})]})]},e.id))})]}),(0,s.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)(O.A,{size:14,className:"text-gray-400"}),(0,s.jsx)("h2",{className:"text-sm font-medium text-gray-700",children:"Find user across all companies"})]}),(0,s.jsx)("input",{className:"input w-full",placeholder:"Search by name or emailâ¦",value:J,onChange:e=>H(e.target.value)}),Z&&(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-2",children:"Searchingâ¦"}),!Z&&J&&0===W.length&&(0,s.jsx)("p",{className:"text-xs text-gray-400 mt-2",children:"No users found."}),W.length>0&&(0,s.jsx)("div",{className:"mt-2 space-y-1",children:W.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2.5 rounded-lg border border-gray-100 px-3 py-2",children:[(0,s.jsx)("div",{className:(0,o.cn)("flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-medium",(0,o.V7)(e.name)),children:(0,o.yC)(e.name)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.name}),(0,s.jsxs)("p",{className:"text-xs text-gray-400 truncate",children:[e.email," \xb7 ",e.tenantName]})]}),(0,s.jsx)("span",{className:(0,o.cn)("badge text-[11px] shrink-0",o._t[e.role]),children:o.fn[e.role]}),(0,s.jsx)("span",{className:(0,o.cn)("badge text-[11px] shrink-0",Y[e.status??"approved"]),children:e.status})]},e.id))})]}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h1",{className:"text-lg font-semibold text-gray-900",children:"Companies"}),(0,s.jsx)("p",{className:"text-sm text-gray-400",children:k?"â¦":`${eP.length} shown`})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("input",{className:"input text-sm w-44",placeholder:"Search companiesâ¦",value:A,onChange:e=>z(e.target.value)}),(0,s.jsxs)("select",{className:"input text-sm w-32",value:T,onChange:e=>$(e.target.value),children:[(0,s.jsx)("option",{value:"all",children:"All status"}),(0,s.jsx)("option",{value:"active",children:"Active"}),(0,s.jsx)("option",{value:"inactive",children:"Inactive"}),(0,s.jsx)("option",{value:"suspended",children:"Suspended"})]}),(0,s.jsxs)("select",{className:"input text-sm w-28",value:_,onCh
7ange:e=>Q(e.target.value),children:[(0,s.jsx)("option",{value:"all",children:"All plans"}),(0,s.jsx)("option",{value:"free",children:"Free"}),(0,s.jsx)("option",{value:"lite",children:"Lite"}),(0,s.jsx)("option",{value:"starter",children:"Starter"}),(0,s.jsx)("option",{value:"pro",children:"Pro"}),(0,s.jsx)("option",{value:"enterprise",children:"Enterprise"})]}),(0,s.jsxs)("button",{onClick:()=>er(!0),className:"btn-primary",children:[(0,s.jsx)(V.A,{size:15})," New company"]})]})]}),x&&(0,s.jsx)(c.y,{message:x.message,type:x.type,onDismiss:h}),el&&(0,s.jsx)(p,{onClose:()=>er(!1),onCreated:async e=>{m(`${e.name} created`),er(!1),await ew()}}),ei&&(0,s.jsx)(b,{company:ei,initialPlan:ec??void 0,onClose:()=>{ed(null),eo(null)},onSaved:async()=>{m("Company updated"),ed(null),eo(null),await ew()}}),ej&&(0,s.jsx)(F,{company:ej,onClose:()=>ef(null),onExtended:async e=>{m(e),ef(null),await ew()}}),ex&&(0,s.jsx)(f,{company:ex,onClose:()=>eu(null),onAdded:async()=>{m("User added â they click Verify in email to sign in");let e=await i.Dw.listCompanyUsers(ex.id);ea(t=>({...t,[ex.id]:e.users})),eu(null),await ew()}}),em&&(0,s.jsx)(w,{company:em,users:et[em.id]??[],loading:es===em.id,onClose:()=>ep(null),onPick:e=>{ep(null),eF(em,e)}}),eh&&(0,s.jsx)(D,{company:eh,onClose:()=>eg(null)}),ey&&(0,s.jsx)(E.l,{companyId:ey.id,companyName:ey.name,onClose:()=>eb(null)}),k&&(0,s.jsx)("div",{className:"space-y-3",children:[1,2].map(e=>(0,s.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-4 animate-pulse",children:[(0,s.jsx)("div",{className:"h-4 bg-gray-100 rounded w-1/3 mb-2"}),(0,s.jsx)("div",{className:"h-3 bg-gray-100 rounded w-1/4"})]},e))}),!k&&0===eP.length&&(0,s.jsxs)("div",{className:"text-center py-16 text-gray-400",children:[(0,s.jsx)(M.A,{size:40,className:"mx-auto mb-3 opacity-30"}),(0,s.jsx)("p",{className:"text-sm",children:A||"all"!==T||"all"!==_?"No companies match your filters.":"No companies yet."})]}),!k&&eP.length>0&&(0,s.jsx)("div",{className:"space-y-3",children:eP.map(e=>(0,s.jsx)(K,{company:e,expanded:G===e.id,users:et[e.id],loadingUsers:es===e.id,impersonating:ev,onToggleExpand:()=>ek(e),onView:()=>eM(e),onEdit:()=>{eo(null),ed(e)},onAddUser:()=>eu(e),onManageSuppressions:()=>eg(e),onViewSubscription:()=>eb(e),onExtendTrial:()=>ef(e),onToggleStatus:()=>eS(e),onSetPlan:t=>{t!==e.plan&&(eo(t),ed(e))},onSetSeats:t=>eA(e,t),onToggleAgentWrite:()=>eD(e),onSchedulePurge:()=>eT(e),onCancelPurge:()=>e$(e),onPurgeNow:()=>e_(e)},e.id))})]})})}function K({company:e,expanded:t,users:a,loadingUsers:n,impersonating:l,onToggleExpand:r,onView:i,onEdit:d,onAddUser:c,onManageSuppressions:x,onViewSubscription:u,onExtendTrial:m,onToggleStatus:p,onSetPlan:h,onSetSeats:g,onToggleAgentWrite:y,onSchedulePurge:b,onCancelPurge:j,onPurgeNow:f}){let v=e.purgeScheduledAt?Math.max(0,Math.ceil((new Date(e.purgeScheduledAt).getTime()-Date.now())/864e5)):null,w=function(e,t=new Date){if(!z(e)||!e.trialEndsAt)return null;let a=new Date(e.trialEndsAt);if(Number.isNaN(a.getTime()))return null;let s=a.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}),n="trial_expired"===e.subscriptionStatus||a.getTime()<=t.getTime();return{text:n?`Trial expired ${s}`:`Trial ends ${s}`,expired:n}}(e);return(0,s.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,s.jsx)("div",{className:(0,o.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-sm font-semibold",(0,o.V7)(e.name)),children:(0,o.yC)(e.name)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("h3",{className:"font-medium text-gray-900 text-sm",children:e.name}),(0,s.jsx)("span",{className:(0,o.cn)("rounded-full px-2 py-0.5 text-xs font-medium",{active:"bg-green-50 text-green-700",inactive:"bg-gray-100 text-gray-500",suspended:"bg-red-50 text-red-700",pending:"bg-amber-50 text-amber-700",pending_purge:"bg-orange-50 text-orange-700"}[e.status]??"bg-gray-100"),children:e.status}),(0,s.jsxs)("select",{value:e.plan,onChange:e=>h(e.target.value),title:"Set plan manually (no payment)",className:(0,o.cn)("rounded-full px-2 py-0.5 text-xs font-medium border-0 cursor-pointer focus:outline-none focus:ring-1 focus:ring-brand-400",{free:"bg-gray-100 text-gray-600",pro:"bg-blue-50 text-blue-700",enterprise:"bg-purple-50 text-purple-700"}[e.plan]??"bg-gray-100"),children:[(0,s.jsx)("option",{value:"free",children:"free"}),(0,s.jsx)("option",{value:"lite",children:"lite"}),(0,s.jsx)("option",{value:"starter",children:"starter"}),(0,s.jsx)("option",{value:"pro",children:"pro"}),(0,s.jsx)("option",{value:"enterprise",children:"enterprise"}),"legacy_free"===e.plan&&(0,s.jsx)("option",{value:"legacy_free",children:"legacy_free"})]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-gray-200 px-1.5 py-0.5 text-xs text-gray-600",title:"Comp/adjust seats manually (no payment)",children:[(0,s.jsx)("button",{type:"button",onClick:()=>g((e.seatCount??2)-1),disabled:(e.seatCount??2)<=1,className:"px-1 text-gray-500 hover:text-gray-900 disabled:opacity-30","aria-label":"Remove a seat",children:"â"}),(0,s.jsxs)("span",{className:"min-w-[3.5rem] text-center tabular-nums",children:[e.seatCount??2," seat",(e.seatCount??2)===1?"":"s"]}),(0,s.jsx)("button",{type:"button",onClick:()=>g((e.seatCount??2)+1),className:"px-1 text-gray-500 hover:text-gray-900","aria-label":"Add a seat",children:"ï¼"})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3 mt-1 text-xs text-gray-400",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(P.A,{size:11})," ",e.stats.userCount," user",1!==e.stats.userCount?"s":""]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(R.A,{size:11})," ",e.stats.openJobCount," open job",1!==e.stats.openJobCount?"s":""]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(I.A,{size:11})," ",e.stats.candidateCount," candidate",1!==e.stats.candidateCount?"s":""]}),w&&(0,s.jsx)("span",{"data-testid":`trial-label-${e.id}`,className:(0,o.cn)("font-medium",w.expired?"text-red-600":"text-amber-700"),children:w.text})]})]})]}),"pending_purge"===e.status&&null!==v&&(0,s.jsxs)("div",{className:"mt-3 rounded-md border border-orange-200 bg-orange-50 px-3 py-2 text-xs text-orange-900 flex items-center justify-between gap-2 flex-wrap",children:[(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-medium",children:"Scheduled for deleti
7on"})," in ",v," day",1===v?"":"s"," ","(",new Date(e.purgeScheduledAt).toLocaleDateString(),")"]}),(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsx)("button",{onClick:j,className:"btn text-xs",children:"Cancel deletion"}),(0,s.jsx)("button",{onClick:f,className:"btn-danger text-xs",title:"Skip the grace window â typed confirmation required",children:"Purge now"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-3 flex-wrap",children:[(0,s.jsxs)("button",{onClick:i,disabled:l,className:"btn text-xs gap-1 disabled:opacity-50",children:[(0,s.jsx)(N,{size:12})," View"]}),(0,s.jsx)("button",{onClick:d,className:"btn text-xs",children:"Edit"}),(0,s.jsxs)("button",{onClick:c,className:"btn text-xs",children:[(0,s.jsx)(V.A,{size:12})," User"]}),(0,s.jsxs)("button",{onClick:x,className:"btn text-xs",title:"Manage email suppression list",children:[(0,s.jsx)(C,{size:12})," Suppressions"]}),(0,s.jsxs)("button",{onClick:u,"data-testid":`subscription-btn-${e.id}`,className:"btn text-xs",title:"View Razorpay subscription state (read-only)",children:[(0,s.jsx)(Q.A,{size:12})," Subscription"]}),z(e)&&(0,s.jsxs)("button",{onClick:m,"data-testid":`extend-trial-btn-${e.id}`,className:"btn text-xs",title:"Move this tenant's free-trial end date",children:[(0,s.jsx)(J.A,{size:12})," Extend trial"]}),(0,s.jsxs)("button",{onClick:y,"data-testid":`agent-write-btn-${e.id}`,className:(0,o.cn)("text-xs rounded-md px-2 py-1 font-medium border",e.agentWriteEnabled?"border-indigo-200 bg-indigo-50 text-indigo-700 hover:bg-indigo-100":"border-gray-200 text-gray-500 hover:bg-gray-50"),title:"Let the Recruiting Agent PROPOSE write actions for this tenant (recruiter still approves each). Default off.",children:[(0,s.jsx)(H.A,{size:12,className:"inline mr-1"}),"Agent writes: ",e.agentWriteEnabled?"On":"Off"]}),"pending_purge"!==e.status&&(0,s.jsx)("button",{onClick:p,title:"active"===e.status?"Suspend":"Activate",className:(0,o.cn)("p-1.5 rounded-lg transition-colors","active"===e.status?"text-gray-400 hover:text-red-500 hover:bg-red-50":"text-gray-400 hover:text-green-600 hover:bg-green-50"),children:"active"===e.status?(0,s.jsx)(W.A,{size:14}):(0,s.jsx)(B.A,{size:14})}),"suspended"===e.status&&(0,s.jsx)("button",{onClick:b,title:"Schedule permanent deletion (30-day grace)",className:"btn-danger text-xs gap-1",children:"Schedule deletion"}),(0,s.jsx)("button",{onClick:r,className:"p-1.5 text-gray-400 hover:text-gray-700 rounded-lg hover:bg-gray-50 ml-auto",children:t?(0,s.jsx)(Z.A,{size:16}):(0,s.jsx)(X.A,{size:16})})]})]}),t&&(0,s.jsxs)("div",{className:"border-t border-gray-100 bg-gray-50 px-4 py-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-gray-500 mb-3 uppercase tracking-wide",children:"Users"}),n&&(0,s.jsx)("p",{className:"text-xs text-gray-400 py-2",children:"Loadingâ¦"}),!n&&(a?.length??0)===0&&(0,s.jsx)("p",{className:"text-xs text-gray-400 py-2",children:"No users yet."}),!n&&(a?.length??0)>0&&(0,s.jsx)("div",{className:"space-y-1.5",children:a.map(e=>(0,s.jsxs)("div",{className:"bg-white rounded-lg border border-gray-100 px-3 py-2 flex items-center gap-2.5",children:[(0,s.jsx)("div",{className:(0,o.cn)("flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-medium",(0,o.V7)(e.name)),children:(0,o.yC)(e.name)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-gray-400 truncate",children:e.email})]}),(0,s.jsx)("span",{className:(0,o.cn)("badge text-[11px] shrink-0",o._t[e.role]),children:o.fn[e.role]}),(0,s.jsx)("span",{className:(0,o.cn)("badge text-[11px] shrink-0","approved"===e.status?"bg-green-50 text-green-700":"pending"===e.status?"bg-amber-50 text-amber-700":"bg-gray-100 text-gray-500"),children:e.status})]},e.id))})]})]})}},63519:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]])},66088:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},68459:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});
7let s=(0,a(78340).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},80086:(e,t,a)=>{"use strict";a.d(t,{yJ:()=>r});var s=a(12115);let n=0,l=null;function r(){(0,s.useEffect)(()=>("u">typeof document&&(0===n&&(l=document.body.style.overflow,document.body.style.overflow="hidden"),n+=1),()=>void("u"<typeof document||0!==n&&0==(n-=1)&&(document.body.style.overflow=l??"",l=null))),[])}},94514:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});let s=(0,a(78340).A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])}},e=>{e.O(0,[8500,8437,9060,2917,7529,7086,9793,8441,2209,7358],()=>e(e.s=48336)),_N_E=e.O()}]);
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.