1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},i=(new e.Error).stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="2ca2ed41-1b49-496b-a875-ae61d4a9eaff",e._sentryDebugIdIdentifier="sentry-dbid-2ca2ed41-1b49-496b-a875-ae61d4a9eaff")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[370,2629,6309],{37563:(e,i,a)=>{"use strict";a.r(i),a.d(i,{default:()=>ib});var r=a(37876),t=a(14232),n=a(35578),l=a(50900),s=a(89099),o=a(63374),d=a(87602),c=a(13607),u=a(93262),p=a(3732),m=a(61875);let g=({variant:e="default",isClickable:i,onClick:a,ariaLabel:t,children:l,...s})=>{let o="admin"===e,d=i??!!a;return(0,r.jsx)(n.az,{position:"relative",p:4,bg:o?"rgba(127,29,29,0.15)":"rgba(0,0,0,0.6)",border:"1px",borderStyle:o?"dashed":"solid",borderColor:o?"rgba(127,29,29,0.5)":"rgba(255,255,255,0.1)",backdropFilter:"blur(5px)",borderRadius:{base:"16px",lg:"20px"},cursor:d?"pointer":"default",transition:"all 0.15s",_hover:d?{bg:o?"rgba(127,29,29,0.25)":"rgba(0,0,0,0.7)",borderColor:o?"rgba(127,29,29,0.7)":"rgba(255,255,255,0.2)"}:void 0,_focusVisible:d?{outline:"2px solid rgba(255,255,255,0.4)",outlineOffset:"2px"}:void 0,onClick:a,...d?{role:"button",tabIndex:0,"aria-label":t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),a?.(e))}}:{},...s,children:l})},h=()=>(0,r.jsx)(c.o,{width:"100%",height:"100%",py:12,children:(0,r.jsx)(g,{maxW:"420px",width:"100%",children:(0,r.jsxs)(u.T,{spacing:4,py:4,children:[(0,r.jsx)(n.az,{as:m.Eh3,width:"48px",height:"48px",color:"rgba(255,255,255,0.35)"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:"21px",color:"primaryWhite",textAlign:"center",children:"Access Denied"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"lightGray",textAlign:"center",children:"You must be an admin to view this page."})]})})});var f=a(20483);let x=()=>{let{uid:e}=(0,d.GV)(d.Ax.me);return!!e},b=e=>{let i=x()&&e,[a,r]=(0,t.useState)([]),[n,l]=(0,t.useState)(i),[s,o]=(0,t.useState)(null),[d,c]=(0,t.useState)(0),[u,p]=(0,t.useState)(i),[m,g]=(0,t.useState)(d);return(i!==u||d!==m)&&(p(i),g(d),i?(l(!0),o(null)):l(!1)),(0,t.useEffect)(()=>{if(!i)return;let e=!1;return f.SP.get(f.Hr.AdminMembers).then(({data:i})=>{e||(r(i.members||[]),l(!1))}).catch(i=>{e||(console.error("Failed to load admin members:",i),o(i.response?.data?.error||"Failed to load members"),l(!1))}),()=>{e=!0}},[i,d]),{members:a,loading:n,error:s,refresh:(0,t.useCallback)(()=>{c(e=>e+1)},[])}},j="mod:",_=e=>e.toLowerCase().startsWith(j)?e.slice(j.length).trim():null,y=e=>null!==_(e)?"violation_id":/^(cus_|sub_|si_)[a-zA-Z0-9]+$/.test(e)?"stripe_id":e.includes("@")?"email":/^[a-zA-Z0-9]{20,}$/.test(e)?"uid":"name";var v=a(67357),S=a(54043),w=a(35435),z=a(29631),F=a(28343),C=a(34129),R=a(78592),k=a(72547),A=a(92506),E=a(17173),P=a(81474);let T=[{value:"moderator",label:"Moderator"},{value:"support",label:"Support"},{value:"admin",label:"Admin"},{value:"super_admin",label:"Super Admin"}],D=({isOpen:e,onClose:i,onAdded:a,callerRole:n})=>{let[l,s]=(0,t.useState)(""),[o,d]=(0,t.useState)((0,P.jm)(n)?"support":"moderator"),[c,m]=(0,t.useState)(""),[g,h]=(0,t.useState)(!1),[x,b]=(0,t.useState)(null),j=()=>{s(""),d((0,P.jm)(n)?"support":"moderator"),m(""),b(null),h(!1)},_=c.trim(),y=_.length>=3&&_.length<=500,v=T.filter(e=>(0,P.pj)(n,e.value)),w=async()=>{let e=l.trim();if(!e)return void b("Enter an email or UID");if(!y)return void b(`Reason must be 3â500 characters`);if((0,P.pj)(n,o)){h(!0),b(null);try{await f.SP.post(f.Hr.AdminMemberAdd,{identifier:e,role:o,reason:_}),j(),a(),i()}catch(a){console.error("Add admin member failed:",a);let e=a.response?.data?.error,i=a.response?.status;b(e||(i?`Failed to add member (HTTP ${i})`:"Failed to add member")),h(!1)}}};return(0,r.jsx)(A.G,{isOpen:e,onClose:()=>{g||(j(),i())},variant:"confirm",title:"Add Admin Member",subtitle:"Assign a role to a user by email or UID",maxWidth:"480px",onConfirm:w,confirmLabel:"Add Member",isLoading:g,isConfirmDisabled:g||0===l.trim().length||!y||!(0,P.pj)(n,o),children:(0,r.jsxs)(u.T,{spacing:4,align:"stretch",children:[(0,r.jsxs)(C.MJ,{children:[(0,r.jsx)(R.l,{color:"rgba(255,255,255,0.6)",fontFamily:"var(--chakra-fonts-PoppinsRegular)",fontSize:"14px",mb:1,children:"Email or UID"}),(0,r.jsx)(E.$,{placeholder:"[email protected] or abc123...",value:l,onCh
1ange:e=>s(e.target.value),isDisabled:g})]}),(0,r.jsxs)(C.MJ,{children:[(0,r.jsx)(R.l,{color:"rgba(255,255,255,0.6)",fontFamily:"var(--chakra-fonts-PoppinsRegular)",fontSize:"14px",mb:1,children:"Role"}),(0,r.jsx)(S.z,{spacing:2,children:v.map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:e.label,isActive:o===e.value,onClick:()=>d(e.value),isDisabled:g},e.value))})]}),(0,r.jsxs)(C.MJ,{children:[(0,r.jsx)(R.l,{color:"rgba(255,255,255,0.6)",fontFamily:"var(--chakra-fonts-PoppinsRegular)",fontSize:"14px",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{placeholder:"Why are you granting this role? (e.g. new hire, ticket #123)",value:c,onChange:e=>m(e.target.value),isDisabled:g,rows:3,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),x&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:x})]})})},$=[{value:null,label:"None"},{value:"moderator",label:"Moderator"},{value:"support",label:"Support"},{value:"admin",label:"Admin"},{value:"super_admin",label:"Super Admin"}],W=({member:e,onClose:i,onUpdated:a,callerRole:l})=>{let{uid:s}=(0,d.GV)(d.Ax.me),o=!!e&&e.uid===s,[c,m]=(0,t.useState)(e?.admin_role??"support"),[g,h]=(0,t.useState)(""),[x,b]=(0,t.useState)(!1),[j,_]=(0,t.useState)(null),[y,v]=(0,t.useState)(e?.uid??null);(e?.uid??null)!==y&&(v(e?.uid??null),m(e?.admin_role??"support"),h(""),_(null),b(!1));let w=g.trim(),z=w.length>=3&&w.length<=500,E=(0,P.jR)(l,e?.admin_role??null),T=$.filter(i=>(0,P.Pn)(l,e?.admin_role??null,i.value)),D=async r=>{if(e&&(0,P.jR)(l,e.admin_role)&&(0,P.Pn)(l,e.admin_role,r)){if(!z)return void _(`Reason must be 3â500 characters`);b(!0),_(null);try{await f.SP.post(f.Hr.AdminUserUpdate(e.uid),{admin_role:r,__reason:w}),a(),i()}catch(e){_(e.response?.data?.error||"Failed to update member"),b(!1)}}},W=null!==e,L=!e||c===e.admin_role;return(0,r.jsx)(A.G,{isOpen:W,onClose:()=>{x||i()},variant:"confirm",title:"Edit Admin Member",subtitle:"Change role or set to None to remove admin access",maxWidth:"480px",onConfirm:()=>D(c),confirmLabel:"Save",isLoading:x,isConfirmDisabled:x||L||o||!E||!z,children:(0,r.jsxs)(u.T,{spacing:4,align:"stretch",children:[e&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",children:e.user_name||e.email||"Unnamed"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",wordBreak:"break-all",children:[e.email,e.uid].filter(Boolean).join(" \xb7 ")})]}),(0,r.jsxs)(C.MJ,{children:[(0,r.jsx)(R.l,{color:"rgba(255,255,255,0.6)",fontFamily:"var(--chakra-fonts-PoppinsRegular)",fontSize:"14px",mb:1,children:"Role"}),(0,r.jsx)(S.z,{spacing:2,children:T.map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:e.label,isActive:c===e.value,onClick:()=>m(e.value),isDisabled:x||o||!E},e.value??"none"))})]}),(0,r.jsxs)(C.MJ,{children:[(0,r.jsx)(R.l,{color:"rgba(255,255,255,0.6)",fontFamily:"var(--chakra-fonts-PoppinsRegular)",fontSize:"14px",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{placeholder:"Why are you changing this role? (e.g. role change request, ticket #123)",value:g,onChange:e=>h(e.target.value),isDisabled:x||o,rows:3,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),o&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#F6AD55",children:"You can't change your own admin role. Ask another super admin."}),j&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:j})]})})},L={super_admin:{bg:"rgba(159,122,234,0.2)",color:"#B794F4",label:"Super Admin"},admin:{bg:"rgba(99,179,237,0.2)",color:"#63B3ED",label:"Admin"},support:{bg:"rgba(72,187,120,0.2)",color:"#68D391",label:"Support"},moderator:{bg:"rgba(236,201,75,0.2)",color:"#ECC94B",label:"Moderator"},beta:{bg:"rgba(237,137,54,0.2)",color:"#F6AD55",label:"Beta (legacy)"}},B=({members:e,loading:i,error:a,onSelectMember:l,onRefresh:s,callerRole:o})=>{let[d,h]=(0,t.useState)(!1),[f,x]=(0,t.useState)(null),b=(0,r.jsxs)(n.az,{textAlign:"center",py:8,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:{base:"29px",lg:"37px"},color:"primaryWhite",mb:2,children:"Admin Panel"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:{base:"15px",lg:"17px"},color:"lightGray",mb:4,children:"Manage admin team members"}),(0,r.jsx)(c.o,{children:(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.QCG,label:"Add member",onClick:()=>h(!0)})})]}),j=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(D,{isOpen:d,onClose:()=>h(!1),onAdded:s,callerRole:o}),(0,r.jsx)(W,{member:f,onClose:()=>x(null),onUpdated:s,callerRole:o})]});return i?(0,r.jsxs)(u.T,{spacing:6,align:"stretch",children:[b,(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(v.y,{color:"purple",size:"lg"})}),j]}):a?(0,r.jsxs)(u.T,{spacing:6,align:"stretch",children:[b,(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"rgba(255,255,255,0.5)",children:a})}),j]}):0===e.length?(0,r.jsxs)(u.T,{spacing:6,align:"stretch",children:[b,(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"rgba(255,255,255,0.5)",children:"No admin members found."})}),j]}):(0,r.jsxs)(u.T,{align:"stretch",spacing:6,children:[b,(0,r.jsx)(u.T,{align:"stretch",spacing:2,children:e.map(e=>{let i=L[e.admin_role];return(0,r.jsx)(g,{onClick:()=>l(e.uid),children:(0,r.jsxs)(u.T,{align:"stretch",spacing:2,children:[(0,r.jsxs)(S.z,{spacing:2,wrap:"wrap",align:"center",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",children:e.user_name||e.email||"Unnamed"}),(0,r.jsx)(w.vw,{size:"sm",bg:i.bg,color:i.color,borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:i.label}),(0,r.jsx)(z.h,{}),(0,r.jsx)(n.az,{onClick:i=>{i.stopPropagation(),(0,P.jR)(o,e.admin_role)&&x(e)},children:(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.dJk,ariaLabel:"Edit member role",isDisabled:!(0,P.jR)(o,e.admin_role)})})]}),(0,r.jsx)(n.az,{children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",wordBreak:"break-all",children:[e.email,e.uid].filter(
1Boolean).join(" \xb7 ")})})]})},e.uid)})}),j]})};var U=a(56557),N=a.n(U),I=a(66315),O=a.n(I);let M=({result:e,onClick:i,rightSlot:a})=>{let t=[e.uid,e.email||void 0,"unknown"!==e.auth_provider?e.auth_provider:void 0].filter(Boolean);return(0,r.jsx)(g,{onClick:()=>i(e.uid),children:(0,r.jsxs)(u.T,{align:"stretch",spacing:2,children:[(0,r.jsxs)(S.z,{spacing:2,wrap:"wrap",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",children:e.user_name||"No name"}),e.is_subscriber&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(72,187,120,0.2)",color:"#68D391",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Subscriber"}),e.deactivated&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(245,101,101,0.2)",color:"#FC8181",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Deactivated"}),e.violation_count>0&&(0,r.jsxs)(w.vw,{size:"sm",bg:"rgba(237,137,54,0.2)",color:"#F6AD55",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:[e.violation_count," violation",1!==e.violation_count?"s":""]}),e.matched_violation_id&&(0,r.jsxs)(w.vw,{size:"sm",bg:"rgba(99,179,237,0.2)",color:"#63B3ED",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",title:`Matched moderation ID ${e.matched_violation_id}`,children:["matched mod:",e.matched_violation_id.slice(0,8),"â¦"]}),a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(z.h,{}),a]})]}),(0,r.jsx)(n.az,{children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",wordBreak:"break-all",children:t.join(" \xb7 ")})})]})})};N().extend(O());let J={email:"Searching by email",uid:"Searching by UID",name:"Searching by name",violation_id:"Searching by moderation/violation ID",stripe_id:"Searching by Stripe ID (cus_/sub_/si_)"},q=({query:e,results:i,isSearching:a,isDebouncing:l,hasSearched:s,onQueryChange:o,onSelect:d})=>{let m=l||a,g=e.trim(),h=g?y(g):null,{results:b,loading:j}=(()=>{let e=x(),[i,a]=(0,t.useState)([]),[r,n]=(0,t.useState)(e),[l,s]=(0,t.useState)(0),[o,d]=(0,t.useState)(e),[c,u]=(0,t.useState)(l);return(e!==o||l!==c)&&(d(e),u(l),e?n(!0):n(!1)),(0,t.useEffect)(()=>{if(!e)return;let i=!1;return f.SP.get(f.Hr.AdminRecentViews).then(({data:e})=>{i||(a(e.results||[]),n(!1))}).catch(e=>{i||(console.error("Failed to load recent views:",e),a([]),n(!1))}),()=>{i=!0}},[e,l]),{results:i,loading:r,refresh:(0,t.useCallback)(()=>{s(e=>e+1)},[])}})(),_=!g&&!s;return(0,r.jsxs)(u.T,{spacing:6,align:"stretch",children:[(0,r.jsxs)(n.az,{textAlign:"center",py:8,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:{base:"29px",lg:"37px"},color:"primaryWhite",mb:2,children:"Admin Panel"}),(0,r.jsxs)(p.E,{fontFamily:"PoppinsRegular",fontSize:{base:"15px",lg:"17px"},color:"lightGray",mb:6,children:["Search users by email, UID, name, Stripe ID (cus_/sub_/si_), or moderation ID (prefix\xa0",(0,r.jsx)(p.E,{as:"span",fontFamily:"monospace",children:"mod:"}),")"]}),(0,r.jsx)(c.o,{children:(0,r.jsx)(E.$,{variant:"search",placeholder:"email \xb7 UID \xb7 name \xb7 cus_/sub_/si_ \xb7 mod:violationId",value:e,onChange:o,isLoading:m})}),h&&g&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"rgba(255,255,255,0.35)",mt:3,children:J[h]})]}),a&&g&&(0,r.jsx)(c.o,{py:6,children:(0,r.jsx)(v.y,{size:"sm",color:"rgba(255,255,255,0.35)"})}),!m&&s&&0===i.length&&(0,r.jsx)(c.o,{py:6,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"lightGray",children:"No users found."})}),i.length>0&&(0,r.jsx)(u.T,{spacing:3,align:"stretch",children:i.map(e=>(0,r.jsx)(M,{result:e,onClick:d},e.uid))}),_&&(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"14px",color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.5px",children:"Recently viewed"}),j&&0===b.length?(0,r.jsx)(c.o,{py:6,children:(0,r.jsx)(v.y,{size:"sm",color:"rgba(255,255,255,0.35)"})}):0===b.length?(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"14px",color:"rgba(255,255,255,0.4)",children:"No recently viewed profiles yet."}):b.map(e=>(0,r.jsx)(M,{result:e,onClick:d,rightSlot:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.4)",whiteSpace:"nowrap",children:N()(e.viewed_at).fromNow()})},e.uid))]})]})};var G=a(15595);let Y={verify:"Manually verified",reset_yoti_attempts:"Yoti attempts reset",revert_to_restricted:"Reverted to restricted"};var H=a(30920),V=a(73016),K=a(14274),X=a(15637),Q=a(66116),Z=a(27107),ee=a(22005),ei=a(15986),ea=a(4981);let er=e=>null==e||""===e?"â":(0,V.a$)(e,{year:"numeric",month:"short",day:"numeric"},String(e));var et=a(66971);let en=({label:e,info:i})=>(0,r.jsxs)(S.z,{spacing:1.5,align:"center",children:[(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"14px",children:e}),i&&(0,r.jsx)(et.m,{label:i,placement:"top",hasArrow:!0,bg:"rgba(20,20,30,0.95)",color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",px:3,py:2,borderRadius:"md",maxW:"300px",children:(0,r.jsx)(n.az,{as:"button",type:"button",display:"inline-flex",alignItems:"center",color:"rgba(255,255,255,0.35)",cursor:"help",bg:"transparent",border:"0",p:0,_hover:{color:"rgba(255,255,255,0.7)"}
1,_focusVisible:{color:"rgba(255,255,255,0.7)",outline:"2px solid rgba(255,255,255,0.4)",outlineOffset:"2px",borderRadius:"sm"},transition:"color 0.15s ease","aria-label":`About ${e}`,children:(0,r.jsx)(m.u7w,{size:12})})})]}),el=({isOpen:e,actionLabel:i,preview:a,isLoading:l=!1,onCancel:s,onConfirm:o})=>{let[d,c]=(0,t.useState)(""),m=d.trim(),g=m.length<3,h=m.length>500,f=g||h||l;return(0,r.jsx)(A.G,{isOpen:e,onClose:()=>{l||(c(""),s())},variant:"confirm",title:i,subtitle:"A reason is required for the audit log.",maxWidth:"480px",onConfirm:()=>{f||(o(m),c(""))},confirmLabel:"Confirm",cancelLabel:"Cancel",isLoading:l,isConfirmDisabled:f,children:(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[a&&(0,r.jsx)(n.az,{px:3,py:2,borderRadius:"md",bg:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)",children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"rgba(255,255,255,0.7)",wordBreak:"break-word",children:a})}),(0,r.jsx)(k.T,{autoFocus:!0,placeholder:"Why are you making this change? (e.g. user requested via support ticket #123)",value:d,onChange:e=>c(e.target.value),rows:3,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}}),(0,r.jsxs)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:h?"#FC8181":"rgba(255,255,255,0.4)",textAlign:"right",children:[m.length,"/",500]})]})})};var es=a(31416),eo=a(56979);let ed=e=>null==e||""===e?"â":"boolean"==typeof e?e?"Yes":"No":Array.isArray(e)?e.length>0?`${e.length} items`:"None":String(e),ec=({label:e,value:i,field:a,type:n="text",step:l,onSubmit:s,info:o})=>{let[d,c]=(0,t.useState)(!1),[u,g]=(0,t.useState)(""),[h,f]=(0,t.useState)(void 0),[x,b]=(0,t.useState)(!1),j=async i=>{if(!s)return;b(!0);let r=await s({[a]:h},e,i);b(!1),f(void 0),r&&c(!1)};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:o}),d?(0,r.jsxs)(S.z,{spacing:2,maxW:"60%",children:[(0,r.jsx)(E.$,{type:n,value:u,onChange:e=>g(e.target.value),size:"sm",fontSize:"14px",h:"32px",step:"number"===n?l??"1":void 0}),(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.waL,ariaLabel:"Save",onClick:()=>{if(!s)return;let e=u;if("number"===n){let i=Number(u);if(Number.isNaN(i))return;e=i}f(e)},isDisabled:x}),(0,r.jsx)(F.J,{size:"sm",variant:"default",icon:m.IeJ,ariaLabel:"Cancel",onClick:()=>{c(!1),g("")},isDisabled:x})]}):(0,r.jsxs)(S.z,{spacing:2,align:"center",maxW:"60%",children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",wordBreak:"break-word",children:ed(i)}),s&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.dJk,ariaLabel:`Edit ${e}`,onClick:()=>{g(null==i?"":String(i)),c(!0)}})]}),(0,r.jsx)(el,{isOpen:void 0!==h,actionLabel:`Update ${e}`,preview:`${ed(i)} â ${ed(h)}`,isLoading:x,onCancel:()=>f(void 0),onConfirm:j})]})},eu=({label:e,value:i,field:a,onSubmit:n,info:l})=>{let[s,o]=(0,t.useState)(!1),[d,c]=(0,t.useState)(!1),u=!!i,m=async i=>{n&&(c(!0),await n({[a]:!u},e,i),c(!1),o(!1))};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:l}),n?(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(p.E,{color:u?"#FC8181":"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"12px",children:u?"Yes":"No"}),(0,r.jsx)(eo.B,{"aria-label":`Toggle ${e}`,isChecked:u,onChange:()=>{n&&o(!0)},isDisabled:d})]}):(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:u?"Yes":"No"}),(0,r.jsx)(el,{isOpen:s,actionLabel:`Toggle ${e}`,preview:`${u?"Yes":"No"} â ${!u?"Yes":"No"}`,isLoading:d,onCancel:()=>o(!1),onConfirm:m})]})},ep=({label:e,value:i,valueLabel:a,field:n,options:l,onSubmit:s,info:o})=>{let[d,c]=(0,t.useState)(void 0),[u,g]=(0,t.useState)(!1),h=i??null,f=a??l.find(e=>e.value===h)?.label??"â",x=void 0!==d?l.find(e=>e.value===d)?.label??"â":"",b=async i=>{s&&void 0!==d&&(g(!0),await s({[n]:d},e,i),g(!1),c(void 0))},j=l.map(e=>({label:e.label,onClick:()=>(e=>{s&&e!==h&&c(e)})(e.value),isDisabled:u,indicator:e.value===h?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.6)",fontSize:"13px",children:"â"}):void 0}));return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:o}),s?(0,r.jsx)(es._,{items:j,placement:"auto",minWidth:"180px","aria-label":`${e} options`,trigger:({onToggle:e,triggerProps:i})=>(0,r.jsxs)(S.z,{spacing:2,align:"center",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,px:3,py:"6px",borderRadius:"full",bg:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)",_hover:{bg:"rgba(255,255,255,0.1)"},transition:"background 0.15s ease",onClick:()=>!u&&e(),onKeyDown:i=>{u||("Enter"===i.key||" "===i.key)&&(i.preventDefault(),e())},role:"button",tabIndex:0,...i,children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:f}),(0,r.jsx)(m.tEr,{size:11,color:"rgba(255,255,255,0.6)","aria-hidden":!0})]})}):(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:f}),(0,r.jsx)(el,{isOpen:void 0!==d,actionLabel:`Change ${e}`,preview:`${f} â ${x}`,isLoading:u,onCancel:()=>c(void 0),onConfirm:b})]})},em=({label:e,value:i,info:a})=>(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:a}),(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",wordBreak:"break-all",maxW:"60%",children:i||"â"})]}),eg=({label:e,field:i,active:a,value:n,onSubmit:l,clearValue:s=null,reasonField:o,info:d})=>{let[c,u]=(0,t.useState)(null),[g,h]=(0,t.useState)(!1),f=async a=>{if(!l||!c)return;h(!0);let r="clear"===c?{[i]:s}:{[i]:!0,...o?{[o]:a}:{}}
1;await l(r,e,a),h(!1),u(null)},x="clear"===c?`Clear ${e}`:`Activate ${e}`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",children:[(0,r.jsx)(en,{label:e,info:d}),(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(w.vw,{size:"sm",bg:a?"rgba(245,101,101,0.2)":"rgba(72,187,120,0.2)",color:a?"#FC8181":"#68D391",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:a?"Active":"None"}),l&&(a?(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.IeJ,ariaLabel:`Clear ${e}`,onClick:()=>u("clear")}):(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.waL,ariaLabel:`Activate ${e}`,onClick:()=>u("activate")}))]})]}),a&&n&&(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"12px",pl:2,wordBreak:"break-word",children:"object"==typeof n?JSON.stringify(n):String(n)}),(0,r.jsx)(el,{isOpen:null!==c,actionLabel:x,preview:"clear"===c?"Active â None":"None â Active",isLoading:g,onCancel:()=>u(null),onConfirm:f})]})},eh=({value:e,onSubmit:i})=>{let[a,n]=(0,t.useState)(!1),[l,s]=(0,t.useState)(!1),o=null!=e,d=async e=>{i&&(s(!0),await i({social_read_only_until:null},"Read-Only Until",e),s(!1),n(!1))};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:"Read-Only Until",info:"Expiration timestamp for the timed Social and Rooms read-only restriction. It stops applying once passed; admins can also clear it here on appeal. Field: `social_read_only_until`."}),(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:er(e??null)}),o&&i&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.IeJ,ariaLabel:"Clear read-only expiry",onClick:()=>n(!0)})]}),(0,r.jsx)(el,{isOpen:a,actionLabel:"Clear Read-Only expiry",preview:`${er(e??null)} â â`,isLoading:l,onCancel:()=>n(!1),onConfirm:d})]})},ef=({title:e,subtitle:i,children:a})=>(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"12px",color:"rgba(255,255,255,0.55)",textTransform:"uppercase",letterSpacing:"0.5px",mb:i?1:2,children:e}),i&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.4)",mb:2,children:i}),a]}),ex=({label:e,children:i,info:a})=>(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",children:[(0,r.jsx)(en,{label:e,info:a}),"string"==typeof i?(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:i}):i]}),eb={verified:{bg:"rgba(72,187,120,0.2)",fg:"#68D391"},clear:{bg:"rgba(72,187,120,0.2)",fg:"#68D391"},restricted:{bg:"rgba(245,101,101,0.2)",fg:"#FC8181"},unknown:{bg:"rgba(255,255,255,0.08)",fg:"rgba(255,255,255,0.6)"}},ej=({label:e,value:i,info:a})=>i?(0,r.jsxs)(n.az,{children:[(0,r.jsx)(en,{label:e,info:a}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.7)",fontFamily:"PoppinsRegular",fontSize:"13px",mt:1,pl:2,whiteSpace:"pre-wrap",wordBreak:"break-word",children:i})]}):null,e_={verify:"Manually verify age",reset_yoti_attempts:"Reset Yoti attempts",revert_to_restricted:"Revert to restricted"},ey=({ageVerified:e,ageVerification:i,onAgeVerificationSubmit:a})=>{let l=i||{},s=l.status??null,o=eb[s??"unknown"],d=l.yoti_attempt_count??0,c="manual"===l.source&&e,[p,m]=(0,t.useState)(null),[g,h]=(0,t.useState)(!1),f=async e=>{a&&p&&(h(!0),await a(p,e),h(!1),m(null))};return(0,r.jsxs)(ef,{title:"Age Verification",subtitle:"Status, Yoti attempts, and age-estimation classifier output.",children:[(0,r.jsxs)(K.r,{columns:{base:1,md:2},spacingX:6,spacingY:2,children:[(0,r.jsx)(ex,{label:"Verified",info:"Top-level boolean â true if the user has been verified via any source (payment, Yoti, classifier, manual). Field: `age_verified`.",children:(0,r.jsx)(w.vw,{size:"sm",bg:e?"rgba(72,187,120,0.2)":"rgba(245,101,101,0.2)",color:e?"#68D391":"#FC8181",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e?"Yes":"No"})}),(0,r.jsx)(ex,{label:"Status",info:"Gate state from the age-verification pipeline. `restricted` blocks app usage until the user verifies via Yoti or subscription. Field: `age_verification.status`.",children:(0,r.jsx)(w.vw,{size:"sm",bg:o.bg,color:o.fg,borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:s??"â"})}),(0,r.jsx)(ex,{label:"Source",info:"How the user was verified. Field: `age_verification.source`.",children:l.source||"â"}),(0,r.jsx)(ex,{label:"Verified At",info:"When the user was marked verified. Field: `age_verification.verified_at`.",children:er(l.verified_at??null)}),(0,r.jsx)(ex,{label:"Flagged At",info:"When the classifier flagged this user as restricted. Field: `age_verification.flagged_at`.",children:er(l.flagged_at??null)}
1),(0,r.jsx)(ex,{label:"Flag ID",info:"ID of the record in `Admin/AgeEstimationFlags` that set the restricted status. Field: `age_verification.flag_id`.",children:l.flag_id||"â"}),(0,r.jsx)(ex,{label:"Last Scan",info:"Most recent age-estimation scan timestamp. Field: `age_verification.last_scan_at`.",children:er(l.last_scan_at??null)}),(0,r.jsx)(ex,{label:"Last Pass",info:"Most recent time the classifier scan passed. Field: `age_verification.last_pass_at`.",children:er(l.last_pass_at??null)}),(0,r.jsx)(ex,{label:"Last Confidence",info:"Classifier confidence score (0â1) for the most recent scan. Field: `age_verification.last_confidence`.",children:"number"==typeof l.last_confidence?l.last_confidence.toFixed(2):"â"}),(0,r.jsx)(ex,{label:"Consecutive Passes",info:"Clean scans in a row. Resets on any failing scan. Field: `age_verification.consecutive_passes`.",children:String(l.consecutive_passes??0)}),(0,r.jsx)(ex,{label:"Yoti Attempts (24h)",info:"Yoti session starts in the current 24h window. Capped at 5. Field: `age_verification.yoti_attempt_count`.",children:String(l.yoti_attempt_count??0)}),(0,r.jsx)(ex,{label:"Yoti Window Started",info:"When the current 24h Yoti attempt window began. Field: `age_verification.yoti_attempt_window_started_at`.",children:er(l.yoti_attempt_window_started_at??null)})]}),(0,r.jsxs)(u.T,{align:"stretch",spacing:3,mt:3,children:[(0,r.jsx)(ej,{label:"Summary",value:l.summary,info:"Human-readable classifier summary. Field: `age_verification.summary`."}),(0,r.jsx)(ej,{label:"Last Reason",value:l.last_reason,info:"Classifier rationale for the most recent scan. Field: `age_verification.last_reason`."}),(0,r.jsx)(ej,{label:"Key Quote",value:l.key_quote,info:"Excerpt from chat content that tripped the classifier. Field: `age_verification.key_quote`."}),a&&(0,r.jsxs)(S.z,{spacing:2,flexWrap:"wrap",children:[!e&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Manually verify",onClick:()=>m("verify")}),d>0&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Reset Yoti attempts",onClick:()=>m("reset_yoti_attempts")}),c&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Revert to restricted",onClick:()=>m("revert_to_restricted")})]}),(0,r.jsx)(el,{isOpen:null!==p,actionLabel:p?e_[p]:"Age verification action",isLoading:g,onCancel:()=>m(null),onConfirm:f}),l.signal_types&&l.signal_types.length>0&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(en,{label:"Signal Types",info:"Categories of signals the classifier detected. Field: `age_verification.signal_types`."}),(0,r.jsx)(S.z,{spacing:1.5,mt:1,pl:2,flexWrap:"wrap",children:l.signal_types.map((e,i)=>(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(237,137,54,0.15)",color:"#F6AD55",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e},`${e}-${i}`))})]})]})]})},ev=({violation:e})=>{let i=e.context_metadata??null,a=[];return e.is_roleplay_scenario&&a.push({label:"Roleplay",color:"#F6AD55"}),e.is_ai_directed_self_harm&&a.push({label:"AI-directed self-harm",color:"#FC8181"}),e.is_crisis_priority&&a.push({label:`Crisis priority${e.crisis_source?` (${e.crisis_source})`:""}`,color:"#FC8181"}),(0,r.jsx)(n.az,{bg:"rgba(255,255,255,0.03)",borderWidth:"1px",borderColor:"rgba(255,255,255,0.08)",borderRadius:"md",p:3,children:(0,r.jsxs)(u.T,{align:"stretch",spacing:3,children:[(0,r.jsxs)(S.z,{spacing:3,flexWrap:"wrap",children:["number"==typeof e.confidence_score&&(0,r.jsxs)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.85)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:["Confidence ",e.confidence_score.toFixed(2)]}),i?.ai_name&&(0,r.jsxs)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.85)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:["AI: ",i.ai_name]}),i?.user_name&&(0,r.jsxs)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.85)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:["User: ",i.user_name]}),i?.is_groupchat&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.85)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Group chat"}),a.map(e=>(0,r.jsx)(w.vw,{size:"sm",bg:`${e.color}22`,color:e.color,borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e.label},e.label))]}),e.summary&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(en,{label:"Summary",info:"Classifier-written one-paragraph explanation of why the conversation tripped this category. Field: `summary`."}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.8)",fontFamily:"PoppinsRegular",fontSize:"13px",mt:1,pl:2,whiteSpace:"pre-wrap",wordBreak:"break-word",children:e.summary})]}),e.key_quote&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(en,{label:"Key Quote",info:"Specific excerpt the classifier highlighted as the strongest evidence. Field: `key_quote`."}),(0,r.jsx)(n.az,{borderLeftWidth:"2px",borderLeftColor:"rgba(252,129,129,0.6)",pl:3,mt:1,ml:2,children:(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.85)",fontFamily:"PoppinsRegular",fontStyle:"italic",fontSize:"13px",whiteSpace:"pre-wrap",wordBreak:"break-word",children:e.key_quote})})]}),e.conversation_context&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(en,{label:"Conversation Context",info:"Raw conversation snippet (with AI backstory + memories) handed to the classifier. Field: `conversation_context`."}),(0,r.jsx)(n.az,{mt:1,ml:2,p:2,bg:"rgba(0,0,0,0.25)",borderRadius:"sm",maxH:"320px",overflowY:"auto",children:(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.7)",fontFamily:"monospace",fontSize:"12px",whiteSpace:"pre-wrap",wordBreak:"break-word",children:e.conversation_context})})]})]})})},eS=({moderation:e,violations:i,onSubmit:a,onAgeVerificationSubmit:l,onModerationReset:s})=>{let[o,d]=(0,t.useState)(!1),[c,m]=(0,t.useState)(!1),[h,f]=(0,t.useState)(!1),[x,b]=(0,t.useState)(()=>new Set),j=async e=>{s&&(m(!0),await s(e),m(!1),d(!1))};return(0,r.jsxs)(g,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",mb:4,children:"Moderation"}),(0,r.jsxs)(u.T,{spacing:5,align:"stretch",children:[(0,r.jsx)(ef,{title:"Account Sanctions",subtitle:"Hard bans â block all app usage or sharing.",children:(0,r.jsxs)(K.r,{columns:{base:1,md:2},spacingX:6,spacingY:2,children:[(0,r.jsx)(eg,{label:"Account Deactivated",field:"deactivated",active:!!e?.deactivated,value:e?.deactivated_reason,onSubmit:a,clearValue:!1,reasonField:"deactivated_reason",info:"Hard ban â blocks all app usage. Toggle here or set by automated abuse flows. Reason stored in `deactivated_reason`. Field: `deactivated`."}),(0,r.jsx)(eg,{label:"Sharing Deactivated",field:"deactivated_sharing",active:!!e?.deactivated_sharing,onSubmit:a,clearValue:!1,info:"Blocks sharing flows (KinSocial posts, shared AI profiles) but leaves normal app usage intact. Field: `deactivated_sharing`."}),(0,r.jsx)(ec,{label:"Deactivation Reason",field:"deactivated_reason",value:e?.deactivated_reason,onSubmit:a,info:"Free-text justification surfaced on the deactivation banner. Update to clarify or correct â the deactivated flag itself is toggled separately above. Field: `deactivated_reason`."})]})}),(0,r.jsx)(ef,{title:"Community Restrictions",subtitle:"Read-only restrictions apply across KinSocial and Rooms.",children:(0,r.jsxs)(K.r,{columns:{base:1,md:2},spacingX:6,spacingY:2,children:[(0,r.jsx)(eg,{label:"Indefinite Read-Only (Social and Rooms)",field:"social_is_read_only",active:!!e?.social_is_read_only,value:e?.social_read_only_reason,onSubmit:a,clearValue:!1,reasonField:"social_read_only_reason",info:"User can browse KinSocial and Rooms but cannot interact while this indefinite flag is set. Field: `social_is_read_only`."}),(0,r.jsx)(eh,{value:e?.social_read_only_until,onSubmit:a}),(0,r.jsx)(ex,{label:"Admin-Forced Private",info:"Aggregated from this user's KinSocial profiles (`Social/Social/Profiles` where `creatorId == uid`). True if any profile has `adminForcedPrivate === true`.",children:(0,r.jsx)(w.vw,{size:"sm",bg:e?.social_admin_forced_private?"rgba(245,101,101,0.2)":"rgba(72,187,120,0.2)",color:e?.social_admin_forced_private?"#FC8181":"#68D391",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e?.
1social_admin_forced_private?`Forced (${e?.social_profile_count??0} profiles)`:"None"})})]})}),(0,r.jsxs)(ef,{title:"Content Moderation Strikes",subtitle:"Automatic strikes from policy violations in selfies or chats.",children:[(0,r.jsxs)(K.r,{columns:{base:1,md:2},spacingX:6,spacingY:2,children:[(0,r.jsx)(eg,{label:"Restriction",field:"moderation_restricted",active:!!e?.moderation_restricted,value:e?.moderation_restricted,onSubmit:a,info:"Auto-applied by the moderation pipeline. Clearing here resets the restriction. Field: `moderation_restricted`."}),(0,r.jsx)(eg,{label:"Warning (2d)",field:"moderation_warning",active:!!e?.moderation_warning,value:e?.moderation_warning,onSubmit:a,info:"Auto-applied 2-day warning banner. Field: `moderation_warning`."}),(0,r.jsx)(ex,{label:"Consecutive Clean Scans",info:"Count of consecutive clean selfie/chat scans. Resets to 0 on any violation. Field: `moderation_consecutive_clean_scans`.",children:(e=>e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(1)}M`)(e?.moderation_consecutive_clean_scans??0)}),(0,r.jsx)(ex,{label:"Last Action",info:"Most recent moderation action recorded by the pipeline (e.g. `strike`, `clear`). Field: `moderation_last_action`.",children:e?.moderation_last_action||"â"}),(0,r.jsx)(ex,{label:"Last Updated",info:"Timestamp of the most recent moderation state change. Field: `moderation_last_updated`.",children:er(e?.moderation_last_updated)})]}),s&&(0,r.jsxs)(S.z,{mt:3,spacing:2,children:[(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Reset on appeal",onClick:()=>d(!0)}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.4)",children:"Clears restriction + warning + zeros consecutive scans."})]})]}),(0,r.jsx)(ey,{ageVerified:!!e?.age_verified,ageVerification:e?.age_verification??null,onAgeVerificationSubmit:l}),(0,r.jsx)(ef,{title:`Violation History (${i?.length||0})`,children:i&&i.length>0?(0,r.jsxs)(u.T,{align:"stretch",spacing:2,children:[(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(F.J,{size:"sm",variant:"default",label:h?"Hide details":"Show details",onClick:()=>f(e=>!e)}),!h&&(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.45)",fontFamily:"PoppinsRegular",fontSize:"12px",children:["Hidden by default â summaries can contain sensitive content. Expand when reviewing an appeal (or search",(0,r.jsx)(p.E,{as:"span",fontFamily:"monospace",children:" mod:<id> "}),"to jump to a specific one)."]})]}),h&&(0,r.jsx)(n.az,{overflowX:"auto",children:(0,r.jsxs)(X.X,{size:"sm",variant:"unstyled",children:[(0,r.jsx)(Q.d,{children:(0,r.jsx)(Z.Tr,{children:["ID","Category","Type","Summary","Date","Reviewed"].map(e=>(0,r.jsx)(ee.Th,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"12px",textTransform:"uppercase",px:2,children:e},e))})}),(0,r.jsx)(ei.N,{children:i.map(e=>{let i=!!e.id&&x.has(e.id),a=e.context_metadata?.context_type||"â";return(0,r.jsxs)(t.Fragment,{children:[(0,r.jsxs)(Z.Tr,{children:[(0,r.jsx)(ea.Td,{color:"rgba(255,255,255,0.55)",fontFamily:"monospace",fontSize:"12px",whiteSpace:"nowrap",px:2,py:2,verticalAlign:"top",children:e.id??"â"}),(0,r.jsx)(ea.Td,{px:2,py:2,verticalAlign:"top",children:(0,r.jsx)(w.vw,{size:"sm",bg:"CSAM"===e.violation_category?"rgba(245,101,101,0.2)":"rgba(237,137,54,0.2)",color:"CSAM"===e.violation_category?"#FC8181":"#F6AD55",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e.violation_category})}),(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",px:2,py:2,verticalAlign:"top",children:a}),(0,r.jsx)(ea.Td,{color:"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"13px",maxW:"320px",px:2,py:2,verticalAlign:"top",children:e.summary?(0,r.jsx)(n.az,{as:"button",type:"button",textAlign:"left",onClick:()=>(e=>{e&&b(i=>{let a=new Set(i);return a.has(e)?a.delete(e):a.add(e),a})})(e.id),cursor:"pointer",_hover:{color:"rgba(255,255,255,0.85)"},maxW:"100%",isTruncated:!0,"aria-expanded":i,"aria-label":i?"Hide violation details":"Show violation details",children:e.summary}):"â"}),(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",whiteSpace:"nowrap",px:2,py:2,verticalAlign:"top",children:(e=>null==e||""===e?"â":(0,V.a$)(e,{year:"2-digit",month:"numeric",day:"numeric"},String(e)))("object"==typeof e.detected_at&&e.detected_at?1e3*e.detected_at._seconds:e.detected_at)}),(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",px:2,py:2,verticalAlign:"top",children:e.human_review_overturned?"Overturned":e.human_review_status||"â"})]}),i&&(0,r.jsx)(Z.Tr,{children:(0,r.jsx)(ea.Td,{colSpan:6,px:2,py:2,children:(0,r.jsx)(ev,{violation:e})})})]},e.id)})})]})})]}):(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.5)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"No violations on record."})})]}),(0,r.jsx)(el,{isOpen:o,actionLabel:"Reset moderation strikes",preview:"Clears restriction + warning + zeros consecutive scans.",isLoading:c,onCancel:()=>d(!1),onConfirm:j})]})},ew=({title:e,variant:i="default",stack:a=!1,children:t})=>(0,r.jsxs)(g,{variant:i,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",mb:3,children:e}),(0,r.jsx)(K.r,{columns:a?1:{base:1,md:2},spacingX:6,spacingY:3,children:t})]}),ez=({children:e})=>(0,r.jsx)(n.az,{gridColumn:{base:"1",md:"1 / -1"},children:e}),eF=({label:e,ais:i,info:a,emptyLabel:l="None",defaultExpanded:s=!1}
1)=>{let[o,d]=(0,t.useState)(s),c=i.length,g=0===c;return(0,r.jsxs)(u.T,{align:"stretch",spacing:1,width:"100%",children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:`${e} (${c})`,info:a}),g?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"14px",children:l}):(0,r.jsxs)(S.z,{as:"button",spacing:1,align:"center",onClick:()=>d(e=>!e),color:"primaryWhite",cursor:"pointer",_hover:{color:"rgba(255,255,255,0.8)"},children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"14px",children:o?"Hide":"Show names"}),o?(0,r.jsx)(m.tEr,{size:11,"aria-hidden":!0}):(0,r.jsx)(m.xyO,{size:11,"aria-hidden":!0})]})]}),o&&!g&&(0,r.jsx)(n.az,{pl:2,pt:1,borderLeft:"1px solid rgba(255,255,255,0.1)",ml:1,children:(0,r.jsx)(u.T,{align:"stretch",spacing:1,children:i.map(e=>(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",spacing:3,children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",wordBreak:"break-word",children:e.name??(0,r.jsx)(p.E,{as:"span",color:"rgba(255,255,255,0.4)",fontStyle:"italic",children:"(deleted)"})}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.35)",fontFamily:"PoppinsRegular",fontSize:"11px",wordBreak:"break-all",children:e.id})]},e.id))})})]})},eC={fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)"},eR=e=>new Date(e).toLocaleDateString(),ek={pending:"#F6AD55",running:"#F6AD55",succeeded:"#68D391",failed:"#FC8181"},eA=({targetUid:e})=>{let i=(0,G.$)(),[a,l]=(0,t.useState)(""),[s,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(!1),[m,h]=(0,t.useState)([]),[x,b]=(0,t.useState)(null),j=s.trim(),_=j.length>=3&&j.length<=500;(0,t.useEffect)(()=>{_&&x?.startsWith("Reason must be")&&b(null)},[_,x]);let y=(0,t.useRef)(null),v=(0,t.useRef)(!1),w=(0,t.useRef)([]),z=(0,t.useCallback)(async()=>{if(v.current)return w.current;v.current=!0;try{let i=await f.SP.get(f.Hr.AdminUserExportJobs(e),{params:{limit:10}}),a=i.data?.jobs??[];return w.current=a,h(a),a}catch(e){return console.error("Failed to fetch export jobs:",e),w.current}finally{v.current=!1}},[e]);(0,t.useEffect)(()=>{let e=!1,i=a=>{e||(y.current&&clearTimeout(y.current),y.current=setTimeout(async()=>{e||i((await z()).some(e=>"pending"===e.status||"running"===e.status)?3e3:3e4)},a))};return w.current=[],h([]),b(null),l(""),o(""),z().then(a=>{e||i(a.some(e=>"pending"===e.status||"running"===e.status)?3e3:3e4)}),()=>{e=!0,y.current&&(clearTimeout(y.current),y.current=null)}},[e,z]);let[C,R]=(0,t.useState)(!1),P=(0,t.useRef)(null),T=(0,t.useRef)(null),D=e=>{P.current?.(e),P.current=null,T.current=null,R(!1)};(0,t.useEffect)(()=>()=>{P.current&&(P.current(!1),P.current=null,T.current=null,R(!1))},[e]);let $=async()=>{if(!d){if(!_)return void b(`Reason must be 3â500 characters before starting an export.`);if(!U||await (()=>{if(T.current)return T.current;let e=new Promise(e=>{P.current=e,R(!0)});return T.current=e,e})()){c(!0),b(null);try{await f.SP.post(f.Hr.AdminUserExport(e),{emailTo:a.trim()||null,reason:j}),i({title:"Export requested",description:a.trim()?`Will email ${a.trim()} when complete.`:"We will notify [email protected] when it completes.",status:"success",duration:4e3,isClosable:!0}),o(""),z()}catch(a){let e=a?.response?.data?.error||a?.message||"Failed to start export.";b(e),i({title:"Export failed",description:e,status:"error",duration:5e3,isClosable:!0})}finally{c(!1)}}}},W=(0,t.useMemo)(()=>m[0]?.id??null,[m]),L=(0,t.useMemo)(()=>{let e=m.find(e=>"succeeded"===e.status&&"number"==typeof e.created_at);return e?.created_at??null},[m]),B=null!==L?L+15552e6:null,U=null!==B&&Date.now()<B;return(0,r.jsxs)(g,{children:[(0,r.jsxs)(u.T,{align:"stretch",spacing:3,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",children:"Export Account"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.45)",children:"Triggers a JSONL data export for this uid. Attachment URLs only (no binaries). When an email is provided, the result is sent directly to the user â support staff won't see it."}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{...eC,mb:1,children:"Email to (optional)"}),(0,r.jsx)(E.$,{type:"email",value:a,onChange:e=>l(e.target.value),placeholder:"user's email to receive the export",isDisabled:d||C})]}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{...eC,mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{value:s,onChange:e=>o(e.target.value),placeholder:"Why is this export being run? (e.g. data request from user, ticket #123)","aria-label":"Reason",isDisabled:d||C,rows:2,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}}),(0,r.jsx)(p.E,{mt:1,fontFamily:"PoppinsRegular",fontSize:"11px",color:"rgba(255,255,255,0.35)",children:"Recorded in the admin audit log alongside the export. Required (3â500 chars) for traceability."})]}),(0,r.jsx)(S.z,{children:(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:d?"Startingâ¦":"Start export",onClick:$,isDisabled:d||C||!_})}),null!==B&&null!==L&&(0,r.jsxs)(S.z,{spacing:2,align:"center",fontFamily:"PoppinsRegular",fontSize:"12px",children:[(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.55)",children:["Last export: ",eR(L)]}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.3)",children:"\xb7"}),(0,r.jsx)(p.E,{color:U?"#F6AD55":"#68D391",children:U?`Next allowed ${eR(B)} (${(e=>{if(e<=0)return"now";if(e<864e5)return"in <1 day";let i=Math.floor(e/864e5);return 1===i?"in 1 day":`in ${i} days`})(B-Date.now())})`:"Eligible to re-export now (180-day policy)"})]}),x&&(0,r.jsx)(p.E,{color:"#FC8181",fontFamily:"PoppinsRegular",fontSize:"13px",children:x}),(0,r.jsxs)(n.az,{mt:2,children:[(0,r.jsx)(p.E,{...eC,mb:2,textTransform:"uppercase",letterSpacing:"0.5px",children:"Recent exports"}),0===m.length?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.45)",fontFamily:"PoppinsRegular",fontSize:"13px",children:"No exp
1ort jobs yet for this account."}):(0,r.jsx)(u.T,{align:"stretch",spacing:2,children:m.map(e=>(0,r.jsx)(eE,{job:e,isLatest:e.id===W},e.id))})]})]}),(0,r.jsx)(A.G,{variant:"confirm",isOpen:C,onClose:()=>D(!1),onConfirm:()=>D(!0),title:"Override 180-day export policy?",subtitle:null!==B?`Last export was ${eR(L)}. Next allowed ${eR(B)}.`:void 0,confirmLabel:"Export anyway",cancelLabel:"Cancel",maxWidth:"480px",children:(0,r.jsx)(p.E,{variant:"sectionHint",textAlign:"left",children:"Account exports are limited to once every 180 days. Override only for legitimate reasons (failed delivery, appeal, account recovery). The new export will go through the same email/no-email flow as a regular request."})})]})},eE=({job:e,isLatest:i})=>{let a=e.status||"pending",t=ek[a]??"primaryWhite",l=!!e.email_to,s=!l&&e.signed_url,o=(e=>e?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`:"")(e.size_bytes);return(0,r.jsx)(n.az,{p:3,borderRadius:"md",bg:i?"rgba(255,255,255,0.06)":"rgba(255,255,255,0.03)",border:i?"1px solid rgba(255,255,255,0.18)":"1px solid rgba(255,255,255,0.08)",children:(0,r.jsxs)(u.T,{align:"stretch",spacing:1,fontSize:"13px",children:[(0,r.jsxs)(S.z,{justify:"space-between",wrap:"wrap",spacing:2,children:[(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.75)",fontFamily:"PoppinsRegular",fontSize:"12px",children:(e=>e?(0,V.a$)(e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"â")(e.created_at)}),(0,r.jsxs)(p.E,{color:t,fontFamily:"PoppinsSemiBold",fontSize:"12px",textTransform:"uppercase",letterSpacing:"0.5px",children:[a,o&&"succeeded"===a?` \xb7 ${o}`:""]})]}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"11px",wordBreak:"break-all",children:e.id}),l&&(0,r.jsxs)(n.az,{children:[(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.55)",fontFamily:"PoppinsRegular",children:["emailed to"," ",(0,r.jsx)(p.E,{as:"span",color:"primaryWhite",children:e.email_to}),"sent"===e.email_status&&(0,r.jsx)(p.E,{as:"span",color:"#68D391",children:" â sent"}),"failed"===e.email_status&&(0,r.jsx)(p.E,{as:"span",color:"#FC8181",children:" â send failed"}),null===e.email_status&&"succeeded"===a&&(0,r.jsx)(p.E,{as:"span",color:"rgba(255,255,255,0.45)",children:" â delivery state unknown"})]}),"failed"===e.email_status&&e.email_error&&(0,r.jsx)(p.E,{color:"#FC8181",fontFamily:"PoppinsRegular",fontSize:"12px",mt:1,children:e.email_error})]}),s&&(0,r.jsx)(n.az,{children:(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Open export",onClick:()=>e.signed_url&&window.open(e.signed_url,"_blank","noopener,noreferrer")})}),e.error_message&&(0,r.jsx)(p.E,{color:"#FC8181",fontFamily:"PoppinsRegular",children:e.error_message})]})})},eP=[{value:null,label:"None"},{value:"moderator",label:"Moderator"},{value:"support",label:"Support"},{value:"admin",label:"Admin"},{value:"super_admin",label:"Super Admin"}],eT=[{value:null,label:"None"},{value:"available",label:"Available"},{value:"used",label:"Used"}],eD=({coupons:e})=>{let i=Array.isArray(e)?e:[];return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"flex-start",spacing:3,children:[(0,r.jsx)(en,{label:`Coupons (${i.length})`,info:"Subscription coupon codes this user has redeemed. Appended to `subscription_coupons` by `/v1/redeem-coupon`; alerts fire once a user crosses redemption thresholds to flag potential abuse."}),0===i.length?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"None"}):(0,r.jsx)(H.B,{spacing:2,justify:"flex-end",maxW:"70%",children:i.map((e,i)=>(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.75)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:e},`${e}-${i}`))})]})},e$=({payments:e})=>{let i=Array.isArray(e)?e:[];return(0,r.jsxs)(u.T,{align:"stretch",spacing:2,width:"100%",children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",children:[(0,r.jsx)(en,{label:`Pending Payments (${i.length})`,info:"Payments captured by Stripe/Chargebee webhooks but not yet logged to analytics. Drained by `/v1/log-payments`. Field: `pending_payments_to_log`."}),0===i.length&&(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"None"})]}),i.length>0&&(0,r.jsx)(u.T,{align:"stretch",spacing:1,pl:2,children:i.map((e,i)=>{let a="number"==typeof e.amount?e.amount.toFixed(2):"?",t=e.currency??"",l=e.timestamp?er(new Date(e.timestamp).toISOString()):"â";return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",fontSize:"13px",fontFamily:"PoppinsRegular",children:[(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.75)",children:[a," ",t.toUpperCase()]}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",children:l}),e.payment_id&&(0,r.jsx)(n.az,{as:"span",color:"rgba(255,255,255,0.3)",fontSize:"11px",ml:2,children:e.payment_id})]},e.payment_id??i)})})]})},eW=({integrations:e})=>{let i=e.nylas;return(0,r.jsxs)(ew,{title:"Integrations",children:[(0,r.jsx)(eL,{label:"Nylas Calendar",info:"Connected calendar provider (Google/Outlook/iCloud) via Nylas. Stale grants (>14d since last use) get auto-revoked. Field: `nylas_auth_data`.",children:i?`${i.email??"â"} (${i.provider??"?"})`:"None"}),(0,r.jsx)(eL,{label:"Nylas Last Used",info:"Last time the calendar grant was used. Field: `nylas_last_used_calendar`.",children:er(e.nylas_last_used_calendar)}),i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eL,{label:"Nylas Connected",info:"When the calendar grant was originally issued. Field: `nylas_auth_data.created_at`.",children:er(i.created_at)}),(0,r.jsx)(eL,{label:"Nylas Scopes",info:"OAuth scopes the user granted to Nylas. Field: `nylas_auth_data.scopes`.",children:i.scopes.length>0?i.scopes.join(", "):"â"})]}),(0,r.jsx)(eL,{label:"FCM Tokens",info:"Registered push-notification tokens. A high count can indicate stale tokens from uninstalled devices. Field: `notification_tokens` (count only).",children:String(e.notification_token_count)}
1),(0,r.jsx)(eL,{label:"Uploaded Backgrounds",info:"Count of custom chat backgrounds the user has uploaded. Field: `uploaded_background_images`.",children:String(e.uploaded_background_image_count)})]})},eL=({label:e,info:i,children:a})=>(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:i}),(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",wordBreak:"break-word",maxW:"60%",children:a})]}),eB={free:"Free",basic:"Basic",ultra:"Ultra",max:"Max"},eU=({label:e,info:i,isTrial:a,trialPlatform:t,trialExpiresAt:n})=>{let l=a?n?`Yes \xb7 via ${t??"unknown"} until ${er(n)}`:`Yes \xb7 via ${t??"unknown"}`:"No";return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:i}),(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",maxW:"60%",children:l})]})},eN=({label:e,info:i,expiration:a,onSubmit:l})=>{let[s,o]=(0,t.useState)(!1),[d,c]=(0,t.useState)(""),[g,h]=(0,t.useState)(!1),[f,x]=(0,t.useState)(null),b=d.trim(),j=b.length>=3&&b.length<=500,_=g||!j,y=Date.now(),v=!!a&&a>y,w=a?v?`Active until ${er(a)}`:`Expired ${er(a)}`:"â",z=async()=>{if(!l||_)return;h(!0),x(null);let i=await l({gifted_free_trial_expiration:null},e,b);h(!1),i?(c(""),o(!1)):x("Clear failed.")};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:i}),(0,r.jsxs)(S.z,{spacing:2,align:"center",maxW:"60%",children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",children:w}),l&&a&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.WeY,ariaLabel:`Clear ${e}`,onClick:()=>o(!0)})]}),(0,r.jsx)(A.G,{isOpen:s,onClose:()=>{g||(c(""),x(null),o(!1))},variant:"confirm",title:`Clear ${e}`,subtitle:"Nulls gifted_free_trial_expiration. Revokes the user's gift-code trial early â they fall back to whatever else funds their Base tier.",maxWidth:"480px",onConfirm:z,confirmLabel:"Clear trial",isLoading:g,isConfirmDisabled:_,children:(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{value:d,onChange:e=>c(e.target.value),placeholder:"e.g. abuse â early revocation",rows:3,isDisabled:g,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),f&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:f})]})})]})},eI=({label:e,field:i,giftExpiration:a,paidByOtherSource:l,onSubmit:s})=>{let[o,d]=(0,t.useState)(!1),[c,g]=(0,t.useState)(!!a),[h,f]=(0,t.useState)(""),[x,b]=(0,t.useState)(""),[j,_]=(0,t.useState)(!1),[y,v]=(0,t.useState)(null),w=x.trim(),z=w.length>=3&&w.length<=500,C=Date.now(),R=!c||""!==h&&new Date(`${h}T23:59:59`).getTime()>C,P=j||!z||!R,T=()=>{let e=!!a&&a>Date.now();g(e),f(e?(0,V.cG)(a):""),b(""),v(null),_(!1)},D=async()=>{if(!s||P)return;_(!0),v(null);let a=c?new Date(`${h}T23:59:59`).getTime():null,r=await s({[i]:a},e,w);_(!1),r?(T(),d(!1)):v("Gift update failed.")},$=a&&a>C?`Active until ${er(a)}`:"â",W=c?l?"Stores a fallback gift. Won't affect their currently paid coverage; only kicks in if that paid source ever lapses.":"Grants this tier immediately via gift.":"Clears the gift. The user falls back to whatever else funds this tier.";return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:e,info:`Writes ${i}. Reconciliation grants the corresponding is_subscriber_* flag while the timestamp is in the future. Layered on top of paid subs â gifts can't reduce, only add.`}),(0,r.jsxs)(S.z,{spacing:2,align:"center",maxW:"60%",children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",children:$}),s&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.dJk,ariaLabel:`Edit ${e}`,onClick:()=>{s&&(T(),d(!0))}})]}),(0,r.jsx)(A.G,{isOpen:o,onClose:()=>{j||(T(),d(!1))},variant:"confirm",title:`Edit gift: ${e}`,subtitle:"Per-tier gift. Independent of other tiers and paid subscriptions.",maxWidth:"480px",onConfirm:D,confirmLabel:"Save gift",isLoading:j,isConfirmDisabled:P,children:(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Gift status"}),(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"Active",isActive:c,onClick:()=>g(!0),isDisabled:j}),(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"Off",isActive:!c,onClick:()=>g(!1),isDisabled:j})]})]}),c&&(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Expires (date)"}),(0,r.jsx)(E.$,{type:"date",value:h,onChange:e=>f(e.target.value),isDisabled:j}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"11px",color:"rgba(255,255,255,0.4)",mt:1,children:"Use a far-future date (e.g. 2125-01-01) for a lifetime grant."})]}),(0,r.jsx)(n.az,{bg:"rgba(255,255,255,0.05)",borderLeft:"3px solid rgba(255,255,255,0.2)",px:3,py:2,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.6)",children:W})}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{value:x,onChange:e=>b(e.target.value),placeholder:`e.g. comped ${e} for FKP outgoing â ticket #123`,rows:3,isDisabled:j,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),y&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:y})]})})]})}
1,eO=({currentEmail:e,onUpdateEmail:i})=>{let[a,l]=(0,t.useState)(!1),[s,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(""),[g,h]=(0,t.useState)(!1),[f,x]=(0,t.useState)(null),b=s.trim().toLowerCase(),j=d.trim(),_=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),y=j.length>=3&&j.length<=500,v=!!e&&e.toLowerCase()===b,w=g||!_||!y||v,z=()=>{o(""),c(""),x(null),h(!1)},C=async()=>{if(!i||w)return;h(!0),x(null);let{ok:e,error:a}=await i(b,j);h(!1),e?(z(),l(!1)):a&&x(a)};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:"Email",info:"Primary email from the Firebase Auth user record. Source of truth for login. Changing this unlinks all SSO providers â the user can then sign back in with the new email."}),(0,r.jsxs)(S.z,{spacing:2,maxW:"60%",align:"center",children:[(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",wordBreak:"break-all",children:e||"â"}),i&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.dJk,ariaLabel:"Change email",onClick:()=>l(!0)})]}),(0,r.jsx)(A.G,{isOpen:a,onClose:()=>{g||(z(),l(!1))},variant:"confirm",title:"Change email",subtitle:"Unlinks SSO providers and fails if the new email is already in use.",maxWidth:"480px",onConfirm:C,confirmLabel:"Update email",isLoading:g,isConfirmDisabled:w,children:(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Current"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"14px",color:"primaryWhite",wordBreak:"break-all",children:e||"â"})]}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"New email"}),(0,r.jsx)(E.$,{type:"email",value:s,onChange:e=>o(e.target.value),placeholder:"[email protected]",isDisabled:g})]}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{value:d,onChange:e=>c(e.target.value),placeholder:"e.g. user lost access to original email â verified ID via support ticket #123",rows:3,isDisabled:g,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),v&&s&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"#F6AD55",children:"Already the current email."}),f&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:f})]})})]})},eM=({profile:e,auth:i,moderation:a,violations:t,sensitive:n,integrations:l,ais:s,toDeleteAis:o,onSubmit:d,onAgeVerificationSubmit:c,onModerationReset:m,onUpdateEmail:g,callerRole:h,canExport:f=!1,isSelf:x=!1,onSelectTarget:b})=>{let j=x?void 0:d,_=e.admin_role,y=(0,P.Pc)(_),v=null==_||null!==y,w=v?y:String(_),z=(0,P.jm)(h)||v&&(0,P.jR)(h,y),F=eP.filter(e=>(0,P.Pn)(h,y,(0,P.Pc)(e.value))),C=v?"beta"===y?"Beta (legacy)":eP.find(e=>e.value===y)?.label??"None":"Unknown role",R=n?.identity_kit??null,k=n?.referrer_direct_referral_uid??null,A=e.is_subscriber_addon_2,E=e.is_subscriber_addon_1,T=e.is_subscriber,D=T?E&&A?"max":E||A?"ultra":"basic":"free",$=Date.now(),W=e=>"number"==typeof e&&e>$,L=W(e.gifted_basic_expiration),B=W(e.gifted_addon_1_expiration),U=W(e.gifted_addon_2_expiration),N=i=>{let a="base"===i?e.live_subscription_platform:"addon_1"===i?e.live_subscription_platform_addon_1:e.live_subscription_platform_addon_2;return"string"==typeof a&&a.length>0?a:"base"===i&&L||"addon_1"===i&&B||"addon_2"===i&&U?"gifted":null},I=(e,i)=>{if(!e)return"No";let a=N(i);return a?`Yes \xb7 via ${a}`:"Yes (source unknown)"},O=(e,i)=>{if(!e)return!1;let a=N(i);return null!==a&&"gifted"!==a};return(0,r.jsxs)(u.T,{spacing:4,align:"stretch",children:[(0,r.jsxs)(ew,{title:"Account",children:[(0,r.jsx)(em,{label:"UID",value:e.uid,info:"Firebase Auth UID â primary key for this user across Firestore (`Users/{uid}`) and Firebase Auth. Immutable."}),(0,r.jsx)(eO,{currentEmail:i?.email??null,onUpdateEmail:g}),(0,r.jsx)(ec,{label:"Name",field:"user_name",value:e.user_name,info:"User's display name shown in-app (header, chat, etc). User-editable via `/v1/update-info`. Field: `user_name`."}),(0,r.jsx)(ec,{label:"Display Name",field:"share_display_name",value:e.share_display_name,info:"Public name shown on KinSocial posts and shared AI profiles. Separate from `user_name`. User-editable via `/v1/update-info`. Field: `share_display_name`."}),(0,r.jsx)(ec,{label:"Gender",field:"user_gender",value:e.user_gender,info:"User-set current gender. Influences AI persona and prompt generation. User-editable via `/v1/update-info`. Field: `user_gender`."}),(0,r.jsx)(ec,{label:"Birthday",field:"user_birthday",value:e.user_birthday,info:"Used for age-gating (13+) and COPPA compliance. Captured at onboarding or via Settings. Field: `user_birthday`."}
1),(0,r.jsx)(ec,{label:"Geo State",field:"geo_state",value:e.geo_state,info:"2-letter US state code sent by the client (max length 2). Field: `geo_state`."}),(0,r.jsx)(ec,{label:"Timezone",field:"user_timezone",value:e.user_timezone,info:"IANA timezone string (e.g. `America/Los_Angeles`) sent by the client. Used for scheduling proactive AI messages in the user's local time. Field: `user_timezone`."})]}),i&&(0,r.jsxs)(ew,{title:"Authentication",children:[(0,r.jsx)(ec,{label:"Email Verified",field:"email_verified",value:i.email_verified,info:"From the Firebase Auth user record (`emailVerified`). Not stored in Firestore â read-only from the admin panel."}),(0,r.jsx)(ec,{label:"Provider",field:"provider",value:i.provider,info:"Primary sign-in provider from Firebase Auth `providerData`: `google.com`, `apple.com`, or `password`."}),(0,r.jsx)(ec,{label:"Phone Verified",field:"phone_verified",value:e.phone_verified,info:"Set to true when the user completes SMS verification via Linq/Twilio. Field: `phone_verified`."}),(0,r.jsx)(em,{label:"Phone Number",value:e.verified_phone_number??null,info:"E.164 phone number captured during Linq SMS verification. Stored at `Admin/UserMetadata/PhoneNumber/{uid}.verified_phone_number` (kept off the main user doc because it's PII used for the uniqueness check). Read-only â the verification flow is the only writer."}),(0,r.jsx)(eL,{label:"Messaging Phone Verified",info:"Whether the Linq text-messaging integration phone has been confirmed. Field: `Users/{uid}/Integrations/text_messaging.phone_number.verified`.",children:e.messaging_phone_verified?"Yes":"No"}),(0,r.jsx)(em,{label:"Messaging Phone",value:e.messaging_phone_number??null,info:"Phone number used for the SMS/iMessage/RCS messaging integration with the AI. Distinct from the account-verification phone above. Field: `Users/{uid}/Integrations/text_messaging.phone_number.value`. Read-only."}),"string"==typeof e.messaging_phone_pending&&(0,r.jsx)(em,{label:"Messaging Phone (pending)",value:e.messaging_phone_pending,info:"A new number the user requested but hasn't completed verification on yet. Cleared after the 5-minute verify window closes. Field: `Users/{uid}/Integrations/text_messaging.pending_phone_number`."}),(0,r.jsx)(ec,{label:"Created",field:"created_at",value:er(i.created_at),info:"Account creation time from the Firebase Auth user record. Not a Firestore field."}),(0,r.jsx)(ec,{label:"Last Sign-in",field:"last_sign_in",value:er(i.last_sign_in),info:"Last successful sign-in from the Firebase Auth user record. Not a Firestore field."})]}),n&&(0,r.jsxs)(ew,{title:"Signup & Referral",variant:"admin",children:[(0,r.jsx)(em,{label:"First Name",value:R?.first_name||"â",info:"Legal first name captured at signup (typically from the Google/Apple SSO profile). AES-encrypted at rest. Field: `identity_kit.first_name`."}),(0,r.jsx)(em,{label:"Client IP",value:R?.client_ip||"â",info:"IP address seen by the backend at account creation. Used for fraud/abuse analysis. AES-encrypted at rest. Field: `identity_kit.client_ip`."}),(0,r.jsx)(em,{label:"Onboard Source",value:R?.onboard_source||"â",info:"Where this user signed up â `app` (mobile) or `web`. Stored as plaintext (no PII). Field: `identity_kit.onboard_source`."}),(0,r.jsx)(ez,{children:(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"flex-start",spacing:3,children:[(0,r.jsx)(en,{label:"User Agent",info:"Browser/device user-agent string captured at signup. Used alongside IP for device fingerprinting and fraud analysis. AES-encrypted at rest. Field: `identity_kit.user_agent`."}),(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",textAlign:"right",maxW:"70%",wordBreak:"break-word",children:R?.user_agent||"â"})]})}),(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",children:[(0,r.jsx)(en,{label:"Direct Referral UID",info:"UID of the user who directly referred this account (if any). Click to jump to that user's profile. Field: `referrer_direct_referral_uid` (super-admin only, part of the sensitive payload)."}),k?(0,r.jsx)(p.E,{color:b?"#63B3ED":"primaryWhite",cursor:b?"pointer":"default",textDecoration:b?"underline":"none",fontFamily:"PoppinsRegular",fontSize:"14px",textAlign:"right",wordBreak:"break-all",onClick:()=>b?.(k),children:k}):(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"â"})]})]}),(0,r.jsxs)(ew,{title:"Plan & Billing",children:[(0,r.jsx)(eL,{label:"Plan",info:"Effective plan derived from is_subscriber + is_subscriber_addon_1 + is_subscriber_addon_2. Read-only â to change, edit the gifts below or have the user adjust their billing.",children:eB[D]}),(0,r.jsx)(eL,{label:"Base",info:"Raw is_subscriber flag. Source is inferred from the user doc's gifted_*_expiration fields. `Yes (source unknown)` typically means a paid sub (Stripe/Chargebee/RC) the doc doesn't record yet â paid attribution isn't reliably persisted.",children:I(T,"base")}),(0,r.jsx)(eL,{label:"Ultra add-on",info:"Raw is_subscriber_addon_1 flag. Source inferred from gift fields; `Yes (source unknown)` usually means a paid Ultra add-on sub.",children:I(E,"addon_1")}),(0,r.jsx)(eL,{label:"Max add-on",info:"Raw is_subscriber_addon_2 flag. Source inferred from gift fields; `Yes (source unknown)` usually means a paid Max add-on sub.",children:I(A,"addon_2")}),(0,r.jsx)(eu,{label:"Has Paid",field:"has_paid",value:e.has_paid,onSubmit:d,info:"Lifetime flag set the first time the user completes a paid (non-$0) transaction via Stripe/Chargebee/RevenueCat. Field: `has_paid`."}),(0,r.jsx)(eI,{label:"Gifted Base",field:"gifted_basic_expiration",giftExpiration:e.gifted_basic_expiration??null,paidByOtherSource:O(T,"base"),onSubmit:d}),(0,r.jsx)(eI,{label:"Gifted Ultra add-on",field:"gifted_addon_1_expiration",giftExpiration:e.gifted_addon_1_expiration??null,paidByOtherSource:O(E,"addon_1"),onSubmit:d}),(0,r.jsx)(eI,{label:"Gifted Max add-on",field:"gifted_addon_2_expiration",giftExpiration:e.gifted_addon_2_expiration??null,paidByOtherSource:O(A,"addon_2"),onSubmit:d}),(0,r.jsx)(eU,{label:"On free trial",info:"Live trial status from RevenueCat / Chargebee / Stripe (App Store, Play Store, web). Read-only â managed by the billing platform. Distinct from `trial_eligible` below, which is whether the user CAN start a trial. Trial users do NOT have social-write access.",isTrial:!!e.live_is_trial,trialPlatform:e.live_trial_platform??null,trialExpiresAt:e.live_trial_expires_at??null}),(0,r.jsx)(eN,{label:"Gifted free trial",info:"User-to-user gift co
1de redemption (14-day Basic). Set by the redeem flow at `/v1/update-info`; admin can only clear. Treated as a free trial â does NOT grant social-write access. Field: `gifted_free_trial_expiration`.",expiration:e.gifted_free_trial_expiration??null,onSubmit:d}),(0,r.jsx)(eu,{label:"Trial Eligible",field:"trial_eligible",value:e.trial_eligible,onSubmit:d,info:"Whether the user can start a free trial. Explicitly set to `false` after a trial consumes; `null`/unset means eligible. Field: `trial_eligible`."}),(0,r.jsx)(ep,{label:"Reactivation Offer",field:"reactivation_offer_status",value:e.reactivation_offer_status,options:eT,onSubmit:d,info:"Winback-offer state for lapsed subscribers. Set to `available` to re-show the reactivation discount on next visit; `used` after they redeem it. Field: `reactivation_offer_status`."}),(0,r.jsx)(ec,{label:"Sub Grace",field:"sub_grace_period",value:er(e.sub_grace_period),info:"Grace-period end after a basic-tier payment failure. The user keeps access until this timestamp passes. Field: `sub_grace_period`."}),(0,r.jsx)(ec,{label:"Sub Grace (Ultra)",field:"sub_grace_period_addon_1",value:er(e.sub_grace_period_addon_1),info:"Grace period for the Ultra add-on (`is_subscriber_addon_1`). Field: `sub_grace_period_addon_1`."}),(0,r.jsx)(ec,{label:"Sub Grace (Max)",field:"sub_grace_period_addon_2",value:er(e.sub_grace_period_addon_2),info:"Grace period for the Max add-on (`is_subscriber_addon_2`). Field: `sub_grace_period_addon_2`."}),e.stripe_customer_id?(0,r.jsx)(em,{label:"Stripe Customer",value:e.stripe_customer_id,info:"Stripe customer ID (`cus_â¦`) linked to this user. Used to locate the customer in the Stripe dashboard. Field: `stripe_customer_id`."}):(0,r.jsx)(ec,{label:"Stripe Customer",field:"stripe_customer_id",value:null,info:"Stripe customer ID (`cus_â¦`) linked to this user. Used to locate the customer in the Stripe dashboard. Field: `stripe_customer_id`."}),(0,r.jsx)(ez,{children:(0,r.jsx)(eD,{coupons:e.subscription_coupons})}),(0,r.jsx)(ez,{children:(0,r.jsx)(e$,{payments:e.pending_payments_to_log})})]}),(0,r.jsxs)(ew,{title:"Activity",children:[(0,r.jsx)(ec,{label:"Total Messages Sent",field:"total_messages_sent",value:e.total_messages_sent,info:"Lifetime user-message counter. Incremented on every `/v1/send-message` (and variants). Field: `total_messages_sent`."}),(0,r.jsx)(ec,{label:"Cumulative Rewards",field:"cumul_reward_count",value:e.cumul_reward_count,info:"Lifetime count of share-rewards earned (e.g. from referrals and shared AI redemptions). Field: `cumul_reward_count`."}),(0,r.jsx)(ec,{label:"Templates Created",field:"created_template_ids",value:e.created_template_ids,info:"IDs of templates this user has published. Length = number of templates they've authored. Field: `created_template_ids`."}),(0,r.jsx)(ec,{label:"Active Persona",field:"active_persona_id",value:e.active_persona_id,info:"ID of the persona currently selected for chat. User-level field (not per-AI). Field: `active_persona_id`."}),(0,r.jsx)(ec,{label:"Referrer Template",field:"referrer_template_id",value:e.referrer_template_id,info:"Template ID that referred this user â set when they signed up via a shared template link. Used for attribution and template-creator rewards. Field: `referrer_template_id`."})]}),(0,r.jsxs)(ew,{title:"Kindroids",stack:!0,children:[(0,r.jsx)(eF,{label:"Active",ais:s,info:"All Kindroids this user owns (`Users/{uid}/AIs`). Field: `ai_list`.",defaultExpanded:!0}),(0,r.jsx)(eF,{label:"Pending Deletion",ais:o,info:"Kindroids queued for deletion via `/v1/schedule-ai-deletion` but not yet removed. Field: `to_delete_ais`.",defaultExpanded:!0})]}),(0,r.jsxs)(ew,{title:"Beta & Testing",children:[(0,r.jsx)(eu,{label:"Beta User",field:"is_beta_user",value:e.is_beta_user,onSubmit:d,info:"Has access to beta features and staging backends. Set manually or by opt-in flows. Field: `is_beta_user`."}),(0,r.jsx)(ec,{label:"Beta Variant",field:"beta_variant",value:e.beta_variant,onSubmit:d,info:"Free-form A/B bucket string (max 32 chars) for staged rollouts. Field: `beta_variant`."}),(0,r.jsx)(eu,{label:"Alpha User",field:"is_alpha_user",value:e.is_alpha_user,onSubmit:d,info:"Has access to alpha/experimental features â internal only, ahead of beta. Field: `is_alpha_user`."}),(0,r.jsx)(eu,{label:"Test User",field:"is_test_user",value:e.is_test_user,onSubmit:d,info:"Internal test account. Exempts the user from analytics events, some live-tool gating, and certain safety flows. Field: `is_test_user`."}),(0,r.jsx)(eu,{label:"Preview Premium Model",field:"preview_premium_model",value:e.preview_premium_model,onSubmit:d,info:"Temporary access to a premium LLM without a paid subscription. Used for c
1omped previews. Field: `preview_premium_model`."})]}),(0,r.jsx)(eW,{integrations:l}),(0,r.jsx)(eS,{moderation:a,violations:t,onSubmit:d,onAgeVerificationSubmit:c,onModerationReset:m}),(0,P.sf)(h)&&(0,r.jsx)(ew,{title:"Admin Access",children:(0,r.jsx)(ep,{label:"Admin Role",field:"admin_role",value:w,valueLabel:C,options:z?F:eP,onSubmit:z?j:void 0,info:x?"You can't change your own admin role. Ask another super admin.":z?"Admins can grant or revoke `moderator` (Social and Room-report moderation). Super admins can manage every staff role. Field: `admin_role`.":"Only super admins can change support, admin, and super-admin roles. Field: `admin_role`."})}),f&&(0,r.jsx)(eA,{targetUid:e.uid})]})};var eJ=a(96804),eq=a(82239),eG=a(30567);let eY=({isActive:e,onSubmit:i})=>{let[a,n]=(0,t.useState)(!1),[l,s]=(0,t.useState)(!1),o=async a=>{i&&(s(!0),await i(!e,a),s(!1),n(!1))};return(0,r.jsxs)(S.z,{justifyContent:"space-between",width:"100%",align:"center",children:[(0,r.jsx)(en,{label:"Unlimited Selfies",info:"Adds the user to `Admin/AdminData.unlimited_users` â the array `isUnlimitedUser()` checks to grant unlimited selfie credits. Does NOT change the subscription tier."}),i?(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(p.E,{color:e?"#FC8181":"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"12px",children:e?"Yes":"No"}),(0,r.jsx)(eo.B,{"aria-label":"Toggle unlimited selfies",isChecked:e,onChange:()=>n(!0),isDisabled:l})]}):(0,r.jsx)(p.E,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"14px",children:e?"Yes":"No"}),(0,r.jsx)(el,{isOpen:a,actionLabel:e?"Revoke Unlimited Selfies":"Grant Unlimited Selfies",preview:`${e?"Yes":"No"} â ${!e?"Yes":"No"}`,isLoading:l,onCancel:()=>n(!1),onConfirm:o})]})},eH=({targetUid:e,usage:i,onSubmit:a,unlimitedSelfies:t,onUnlimitedSelfiesSubmit:n})=>{let l=(0,eJ.j)();return i?(0,r.jsxs)(u.T,{spacing:4,align:"stretch",children:[(0,r.jsxs)(ew,{title:"Selfies",children:[(0,r.jsx)(ec,{label:"Selfies Remaining",field:"selfies_remaining",value:i.selfies_remaining,type:"number",step:"any",onSubmit:a}),(0,r.jsx)(ec,{label:"Paid Selfies Remaining",field:"paid_selfies_remaining",value:i.paid_selfies_remaining,type:"number",step:"any",onSubmit:a}),(0,r.jsx)(ec,{label:"Selfies Penalty",field:"selfies_penalty",value:i.selfies_penalty,type:"number",step:"any",onSubmit:a}),(0,r.jsx)(ec,{label:"Avatar Gen Counter",field:"avatar_gen_counter",value:i.avatar_gen_counter}),(0,r.jsx)(eY,{isActive:t,onSubmit:n})]}),(0,r.jsxs)(ew,{title:"Audio",children:[(0,r.jsx)(ec,{label:"Audio Credits",field:"audio_credits",value:i.audio_credits,type:"number",onSubmit:a}),(0,r.jsx)(ec,{label:"Paid Audio Credits",field:"paid_audio_credits",value:i.paid_audio_credits,type:"number",onSubmit:a}),(0,r.jsx)(ec,{label:"Trial Conversion Audio Topup Period",field:"trial_conversion_audio_topup_period",value:i.trial_conversion_audio_topup_period}),e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eq.$,{alignSelf:"flex-start",size:"sm",variant:"unstyled",bg:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:"full",color:"rgba(255,255,255,0.8)",px:"14px",height:"32px",fontSize:"14px",fontWeight:500,onClick:l.onOpen,_hover:{bg:"rgba(255,255,255,0.18)",color:"white"},children:"View audio usage"}),l.isOpen&&(0,r.jsx)(eG.g,{isOpen:l.isOpen,onClose:l.onClose,endpoint:f.Hr.AdminUserAudioCreditUsage(e)})]})]}),(0,r.jsxs)(ew,{title:"Slots & Credits",children:[(0,r.jsx)(ec,{label:"Additional Kindroid Slots",field:"additional_kindroid_slots",value:i.additional_kindroid_slots,type:"number",onSubmit:a}),(0,r.jsx)(ec,{label:"Additional Share Slots",field:"additional_share_slots",value:i.additional_share_slots,type:"number",onSubmit:a}),(0,r.jsx)(ec,{label:"Share Rewards Credits",field:"share_rewards_credits",value:i.share_rewards_credits,type:"number",onSubmit:a,info:"Currency subscribers can redeem for 4 slots, 100 regular selfies, or 75k paid audio characters. Field: `share_rewards_credits`."})]})]}):(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.5)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"No usage data available."})};
1var eV=a(14914);let eK={"7d":6048e5,"30d":2592e6},eX={user_email_update:"Email change",user_update:"User update",moderation_reset_appeal:"Moderation reset",age_verification_verify:"Age verify",age_verification_reset_yoti_attempts:"Yoti reset",age_verification_revert_to_restricted:"Age revert",social_moderator_update:"Social moderator",featured_kindroids_update:"Featured update"},eQ=({changes:e,views:i})=>{let[a,l]=(0,t.useState)("all"),[s,o]=(0,t.useState)("30d"),[d,c]=(0,t.useState)(""),[m,h]=(0,t.useState)(""),f=(0,t.useMemo)(()=>[...(e||[]).map((e,i)=>({key:e.id||`change-${i}`,kind:"change",timestamp:e.timestamp,admin_uid:e.admin_uid,admin_email:e.admin_email,admin_role:e.admin_role,action:e.action,field_changes:e.field_changes,reason:e.reason})),...(i||[]).map((e,i)=>({key:`view-${e.admin_uid}-${e.viewed_at}-${i}`,kind:"view",timestamp:e.viewed_at,admin_uid:e.admin_uid,admin_email:e.admin_email,sensitive_accessed:e.sensitive_accessed}))].sort((e,i)=>i.timestamp-e.timestamp),[e,i]),x=(0,t.useMemo)(()=>{let e=0,i=1/0;return"7d"===s||"30d"===s?e=Date.now()-eK[s]:"custom"===s&&(d&&(e=new Date(`${d}T00:00:00`).getTime()),m&&(i=new Date(`${m}T23:59:59.999`).getTime())),f.filter(r=>("changes"!==a||"change"===r.kind)&&("views"!==a||"view"===r.kind)&&!(r.timestamp<e)&&!(r.timestamp>i))},[f,a,s,d,m]);return(0,r.jsxs)(g,{children:[(0,r.jsxs)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"15px",color:"primaryWhite",mb:1,children:["Audit Trail (",x.length,")"]}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.45)",mb:3,children:"Admin writes and reads on this profile. Views are deduplicated to one entry per admin per 7-day window."}),(0,r.jsxs)(H.B,{spacing:2,mb:3,children:[["all","changes","views"].map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"all"===e?"All":"changes"===e?"Changes":"Views",isActive:a===e,onClick:()=>l(e)},e)),(0,r.jsx)(n.az,{w:"8px"}),["all","30d","7d","custom"].map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"all"===e?"All time":"30d"===e?"30 days":"7d"===e?"7 days":"Custom",isActive:s===e,onClick:()=>o(e)},e))]}),"custom"===s&&(0,r.jsxs)(S.z,{spacing:2,mb:3,align:"center",children:[(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.5)",fontFamily:"PoppinsRegular",fontSize:"12px",children:"From"}),(0,r.jsx)(E.$,{type:"date",value:d,onChange:e=>c(e.target.value),size:"sm",fontSize:"13px",h:"32px",maxW:"160px"}),(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.5)",fontFamily:"PoppinsRegular",fontSize:"12px",children:"to"}),(0,r.jsx)(E.$,{type:"date",value:m,onChange:e=>h(e.target.value),size:"sm",fontSize:"13px",h:"32px",maxW:"160px"})]}),0===x.length?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.5)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"No matching entries."}):(0,r.jsx)(n.az,{overflowX:"auto",children:(0,r.jsxs)(X.X,{size:"sm",variant:"unstyled",children:[(0,r.jsx)(Q.d,{children:(0,r.jsx)(Z.Tr,{children:["Date","Type","Admin","Details"].map(e=>(0,r.jsx)(ee.Th,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"12px",textTransform:"uppercase",px:2,children:e},e))})}),(0,r.jsx)(ei.N,{children:x.map(e=>(0,r.jsxs)(Z.Tr,{children:[(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",whiteSpace:"nowrap",px:2,py:2,verticalAlign:"top",children:er(e.timestamp)}),(0,r.jsx)(ea.Td,{px:2,py:2,verticalAlign:"top",children:"change"===e.kind?(0,r.jsxs)(u.T,{align:"start",spacing:1,children:[(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(99,179,237,0.2)",color:"#63B3ED",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Change"}),e.action&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.65)",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:(e=>e?eX[e]??e:"Change")(e.action)})]}):(0,r.jsxs)(S.z,{spacing:1,children:[(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(159,122,234,0.2)",color:"#B794F4",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"View"}),e.sensitive_accessed&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(245,101,101,0.2)",color:"#FC8181",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Sensitive"})]})}),(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",px:2,py:2,verticalAlign:"top",children:"self_service"===e.admin_role?"Self-service":e.admin_email||`${e.admin_uid?.slice(0,8)}...`}),(0,r.jsx)(ea.Td,{fontSize:"13px",px:2,py:2,verticalAlign:"top",children:"change"===e.kind?(0,r.jsxs)(u.T,{align:"start",spacing:1,children:[e.field_changes&&Object.entries(e.field_changes).map(([e,{before:i,after:a}])=>(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"12px",children:[e,":"," ",(0,r.jsx)(eV.C,{fontSize:"11px",bg:"rgba(245,101,101,0.15)",color:"#FC8181",px:1,children:JSON.stringify(i)})," ","â"," ",(0,r.jsx)(eV.C,{fontSize:"11px",bg:"rgba(72,187,120,0.15)",color:"#68D391",px:1,children:JSON.stringify(a)})]},e)),e.reason?(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.75)",fontFamily:"PoppinsRegular",fontSize:"12px",mt:1,whiteSpace:"pre-wrap",wordBreak:"break-word",children:[(0,r.jsx)(p.E,{as:"span",color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",children:"Reason:"})," ",e.reason]}):(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.3)",fontFamily:"PoppinsRegular",fontSize:"11px",fontStyle:"italic",mt:1,children:"(no reason recorded)"})]}):(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.35)",fontFamily:"PoppinsRegular",fontSize:"12px",children:"â"})})]},e.key))})]})})]})},eZ=({data:e,loading:i,error:a,onRefresh:l,onSelectTarget:s})=>{let[o,m]=(0,t.useState)("profile"),g=e?.profile.uid??null,h=((e,i)=>{let a=x(),r=(0,G.$)();return(0,t.useCallback)(async(t,n,l)=>{if(!e||!a)return!1;try{return await f.SP.post(f.Hr.AdminUserUpdate(e),{...t,__reason:l}),r({title:`${n} updated`,status:"success",duration:3e3,isClosable:!0}),i(),!0}catch(e){return r({title:`Failed to update ${n}`,description:e.response?.data?.error||e.message,status:"error",duration:5e3,isClosable:!0}),!1}},[e,i,r,a])})(g,l),b=((e,i)=>{let a=x(),r=(0,G.$)();return(0,t.useCallback)(async(t,n)=>{if(!e||!a)return!1;try{return await f.SP.post(f.Hr.AdminUserAgeVerification(e),{action:t,reason:n}
1),r({title:Y[t],status:"success",duration:3e3,isClosable:!0}),i(),!0}catch(e){return r({title:`Failed: ${Y[t]}`,description:e.response?.data?.error||e.message,status:"error",duration:5e3,isClosable:!0}),!1}},[e,i,r,a])})(g,l),j=((e,i)=>{let a=x(),r=(0,G.$)();return(0,t.useCallback)(async t=>{if(!e||!a)return!1;try{return await f.SP.post(f.Hr.AdminUserModerationReset(e),{reason:t}),r({title:"Moderation reset",status:"success",duration:3e3,isClosable:!0}),i(),!0}catch(e){return r({title:"Failed to reset moderation",description:e.response?.data?.error||e.message,status:"error",duration:5e3,isClosable:!0}),!1}},[e,i,r,a])})(g,l),_=((e,i)=>{let a=x(),r=(0,G.$)();return(0,t.useCallback)(async(t,n)=>{if(!e||!a)return!1;try{return await f.SP.post(f.Hr.AdminUserUnlimitedSelfies(e),{grant:t,reason:n}),r({title:t?"Granted unlimited selfies":"Revoked unlimited selfies",status:"success",duration:3e3,isClosable:!0}),i(),!0}catch(e){return r({title:"Failed to update unlimited selfies",description:e.response?.data?.error||e.message,status:"error",duration:5e3,isClosable:!0}),!1}},[e,i,r,a])})(g,l),y=((e,i)=>{let a=x(),r=(0,G.$)();return(0,t.useCallback)(async(t,n)=>{if(!e||!a)return{ok:!1,error:"Not ready"};try{return await f.SP.post(f.Hr.AdminUserUpdateEmail(e),{email:t,reason:n}),r({title:"Email updated",status:"success",duration:3e3,isClosable:!0}),i(),{ok:!0}}catch(i){let e=i.response?.data?.error||i.message||"Failed to update email";return r({title:"Failed to update email",description:e,status:"error",duration:5e3,isClosable:!0}),{ok:!1,error:e}}},[e,i,r,a])})(g,l),{uid:w}=(0,d.GV)(d.Ax.me);if(i&&!e)return(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(v.y,{color:"purple",size:"lg"})});if(a||!e)return(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"rgba(255,255,255,0.5)",children:a||"User not found"})});let z="super_admin"===e.caller_role,C="admin"===e.caller_role||"super_admin"===e.caller_role,R=C?h:void 0,k=!!g&&g===w;return(0,r.jsxs)(u.T,{spacing:5,align:"stretch",children:[(0,r.jsx)(S.z,{spacing:3,align:"center",children:(0,r.jsxs)(u.T,{align:"start",spacing:0,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:{base:"21px",lg:"25px"},color:"primaryWhite",wordBreak:"break-all",children:e.auth?.email||"No email"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"14px",color:"rgba(255,255,255,0.6)",children:e.profile.user_name||"Unnamed user"}),(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.4)",wordBreak:"break-all",children:e.profile.uid})]})}),(0,r.jsx)(S.z,{spacing:2,overflowX:"auto",pb:2,css:{scrollbarWidth:"none"},children:[{key:"profile",label:"Profile"},{key:"usage",label:"Usage"},{key:"audit",label:"Audit Trail"}].map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:e.label,isActive:o===e.key,onClick:()=>m(e.key)},e.key))}),(0,r.jsxs)(n.az,{children:["profile"===o&&(0,r.jsx)(eM,{profile:e.profile,auth:e.auth,moderation:e.moderation,violations:e.violations,sensitive:e.sensitive,integrations:e.integrations,ais:e.ais,toDeleteAis:e.to_delete_ais_with_names,onSubmit:R,onAgeVerificationSubmit:z?b:void 0,onModerationReset:C?j:void 0,onUpdateEmail:C?y:void 0,callerRole:e.caller_role,canExport:C,isSelf:k,onSelectTarget:s}),"usage"===o&&(0,r.jsx)(eH,{targetUid:g,usage:e.usage,onSubmit:R,unlimitedSelfies:!!e.profile.in_unlimited_users_list,onUnlimitedSelfiesSubmit:C?_:void 0}),"audit"===o&&(0,r.jsx)(eQ,{changes:e.audit_log,views:e.view_audit})]})]})};var e0=a(16196),e5=a(14664),e2=a(54287),e1=a(63727),e3=a(50591);let e4={female:"Female",male:"Male"},e8=({canEdit:e,onSelectTarget:i})=>{let{female:a,male:l,loading:s,error:o,refresh:d,mutate:m,reorder:g}=(e=>{let i=x(),a=(0,G.$)(),r=e&&i,[n,l]=(0,t.useState)([]),[s,o]=(0,t.useState)([]),[d,c]=(0,t.useState)(r),[u,p]=(0,t.useState)(null),[m,g]=(0,t.useState)(0),[h,b]=(0,t.useState)(r),[j,_]=(0,t.useState)(m);(r!==h||m!==j)&&(b(r),_(m),p(null),c(r),r||(l([]),o([]))),(0,t.useEffect)(()=>{if(!r)return;let e=!1;return f.SP.get(f.Hr.AdminFeaturedKindroids).then(({data:i})=>{e||(l(i.female||[]),o(i.male||[]),c(!1))}).catch(i=>{e||(console.error("Failed to load featured kindroids:",i),p(i.response?.data?.error||"Failed to load featured kindroids"),
1c(!1))}),()=>{e=!0}},[r,m]);let y=(0,t.useCallback)(()=>g(e=>e+1),[]),v=(0,t.useCallback)(async({gender:e,share_code:r,action:t,reason:n})=>{if(!i)return!1;try{return await f.SP.post(f.Hr.AdminFeaturedKindroidsUpdate,{gender:e,share_code:r,action:t,reason:n}),a({title:"add"===t?"Added to featured":"Removed from featured",status:"success",duration:3e3,isClosable:!0}),y(),!0}catch(e){return a({title:"Failed to update featured kindroids",description:e.response?.data?.error||e.message,status:"error",duration:5e3,isClosable:!0}),!1}},[i,a,y]),S=(0,t.useCallback)(async(e,r)=>{if(!i)return!1;let t="female"===e?l:o;t(r);try{return await f.SP.post(f.Hr.AdminFeaturedKindroidsReorder,{gender:e,share_codes:r.map(e=>e.share_code)}),!0}catch(i){return t("female"===e?n:s),a({title:"Failed to reorder featured kindroids",description:i.response?.data?.error||i.message,status:"error",duration:5e3,isClosable:!0}),!1}},[i,a,n,s]);return{female:n,male:s,loading:d,error:u,refresh:y,mutate:v,reorder:S}})(!0),[h,b]=(0,t.useState)(null),[j,_]=(0,t.useState)(!1),y=async e=>{h&&(_(!0),await m({gender:h.gender,share_code:h.entry.share_code,action:"remove",reason:e}),_(!1),b(null))},[w,z]=(0,t.useState)(null),[C,R]=(0,t.useState)(""),[P,T]=(0,t.useState)(""),[D,$]=(0,t.useState)(!1),[W,L]=(0,t.useState)(null),B=C.trim(),U=P.trim(),N=U.length>=3&&U.length<=500,I=D||!B||!N,O=()=>{D||(z(null),R(""),T(""),L(null))},M=async()=>{if(!w||I)return;$(!0),L(null);let e=await m({gender:w,share_code:B,action:"add",reason:U});$(!1),e?O():L("Add failed â check that the share code is valid.")};return(0,r.jsxs)(u.T,{spacing:5,align:"stretch",children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",align:"center",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:{base:"21px",lg:"25px"},color:"primaryWhite",children:"Featured Kindroids"}),(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"Refresh",onClick:d})]}),s&&(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(v.y,{color:"purple",size:"lg"})}),o&&!s&&(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"#FC8181",children:o})}),!s&&!o&&(0,r.jsxs)(K.r,{columns:{base:1,md:2},spacing:4,children:[(0,r.jsx)(e6,{gender:"female",entries:a,canEdit:e,onAdd:()=>z("female"),onRemove:e=>b({gender:"female",entry:e}),onReorder:e=>g("female",e),onSelectTarget:i}),(0,r.jsx)(e6,{gender:"male",entries:l,canEdit:e,onAdd:()=>z("male"),onRemove:e=>b({gender:"male",entry:e}),onReorder:e=>g("male",e),onSelectTarget:i})]}),(0,r.jsx)(el,{isOpen:null!==h,actionLabel:h?`Remove from Featured (${e4[h.gender]})`:"Remove from featured",preview:h?`${h.entry.ai_name??"(unknown)"} \xb7 ${h.entry.share_code}`:void 0,isLoading:j,onCancel:()=>b(null),onConfirm:y}),(0,r.jsx)(A.G,{isOpen:null!==w,onClose:O,variant:"confirm",title:w?`Add to Featured (${e4[w]})`:"Add to Featured",subtitle:"Validates the share code, gender, and that the template isn't private/disabled.",maxWidth:"480px",onConfirm:M,confirmLabel:"Add",isLoading:D,isConfirmDisabled:I,children:(0,r.jsxs)(u.T,{spacing:3,align:"stretch",children:[(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Share code"}),(0,r.jsx)(E.$,{value:C,onChange:e=>R(e.target.value),placeholder:"e.g. ABC123",isDisabled:D})]}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,children:"Reason (required)"}),(0,r.jsx)(k.T,{value:P,onChange:e=>T(e.target.value),placeholder:"e.g. promoting for January spotlight",rows:3,isDisabled:D,fontFamily:"PoppinsRegular",fontSize:"14px",bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"primaryWhite",_placeholder:{color:"rgba(255,255,255,0.35)"},_focus:{borderColor:"rgba(255,255,255,0.3)",boxShadow:"none"}})]}),W&&(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"13px",color:"#FC8181",children:W})]})})]})},e6=({gender:e,entries:i,canEdit:a,onAdd:n,onRemove:l,onReorder:s,onSelectTarget:o})=>{let d=(0,e5.FR)((0,e5.MS)(e5.AN,{activationConstraint:{distance:6}})),c=(0,t.useCallback)(e=>{let{active:a,over:r}=e;if(!r||a.id===r.id)return;let t=i.findIndex(e=>e.share_code===a.id),n=i.findIndex(e=>e.share_code===r.id);-1!==t&&-1!==n&&s((0,e2.be)(i,t,n))},[i,s]),m=0===i.length?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.45)",fontFamily:"PoppinsRegular",fontSize:"14px",children:"No featured kindroids in this list."}):a?(0,r.jsx)(e5.Mp,{sensors:d,collisionDetection:e5.fp,onDragEnd:c,children:(0,r.jsx)(e2.gB,{items:i.map(e=>e.share_code),strategy:e2._G,children:(0,r.jsx)(u.T,{align:"stretch",spacing:2,children:i.map(e=>(0,r.jsx)(e7,{entry:e,canEdit:a,onRemove:()=>l(e),onSelectTarget:o},e.share_code))})})}):(0,r.jsx)(u.T,{align:"stretch",spacing:2,children:i.map(e=>(0,r.jsx)(e9,{entry:e,canEdit:a,onRemove:()=>l(e),onSelectTarget:o},e.share_code))});return(0,r.jsx)(g,{children:(0,r.jsxs)(u.T,{align:"stretch",spacing:3,children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",align:"center",children:[(0,r.jsxs)(p.E,{fontFamily:"PoppinsSemiBold",fontSize:"14px",color:"primaryWhite",textTransform:"uppercase",letterSpacing:"0.5px",children:[e4[e]," (",i.length,")"]}),a&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",label:"Add",onClick:n})]}),m]})})},e7=({entry:e,canEdit:i,onRemove:a,onSelectTarget:t})=>{let{attributes:l,listeners:s,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,e2.gl)({id:e.share_code});return(0,r.jsx)(n.az,{ref:o,style:{transform:e1.Ks.Transform.toString(d),transition:c},opacity:u?.5:1,zIndex:u?10:"auto",children:(0,r.jsx)(e9,{entry:e,canEdit:i,onRemove:a,onSelectTarget:t,dragHandleProps:{...l,...s}})})},e9=({entry:e,canEdit:i,onRemove:a,onSelectTarget:t,dragHandleProps:l})=>{let s=(e=>{if(e.missing||null===e.ai_avatar)return null;let i="Male"===e.ai_gender||"Female"===e.ai_gender?e.ai_gender:"Female";return(0,e3.vW)({aiAvatar:e.ai_avatar,aiGender:i,customAvatarUrl:e.custom_avatar_url})})(e);return(0,r.jsxs)(S.z,{justifyContent:"space-between",align:"flex-start",width:"100%",px:3,py:2,borderRadius:"md",bg:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)",spacing:3,children:[l&&(0,r.jsx)(n.az,{flexShrink:0,display:"flex",alignItems:"center",alignSelf:"stretch",px:1,color:"rgba(255,255,255,0.35)",cursor:"grab",_active:{cursor:"grabbing"},"aria-label":"Drag to reorder",...l,children:(0,r.jsx)(m.QRP,{size:16})}),(0,r.jsx)(n.az,{flexShrink:0,boxSize:"44px",borderRadius:"full",overflow:"hidden",bg:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.08)",display:"flex",alignItems:"center",justifyContent:"center",children:s?(0,r.jsx)(e0._,{src:s,alt:e.ai_name??e.share_code,boxSize:"44px",objectFit:"cover",loading:"lazy",fallback:(0,r.jsx)(n.az,{boxSize:"44px",display:"flex",alignItems:"center",justifyContent:"center",children:(0,r.jsx)(m.fWL,{size:20,color:"rgba(255,255,255,0.4)"})})}):(0,r.jsx)(m.fWL,{size:20,color:"rgba(255,255,255,0.4)"})}),(0,r.jsxs)(u.T,{align:"start",spacing:1,minW:0,flex:1,children:[(0,r.jsxs)(S.z,{spacing:2,wrap:"wrap",children:[(0,r.jsx)(p.E,{color:e.missing?"rgba(255,255,255,0.5)":"primaryWhite",fontFamily:"PoppinsSemiBold",fontSize:"14px",wordBreak:"break-word",children:e.ai_name??"(template missing)"}),e.missing&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(245,101,101,0.2)",color:"#FC8181",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Missing"}),e.is_disabled&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(245,101,101,0.2)",color:"#FC8181",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Disabled"}),e.is_private&&(0,r.jsx)(w.vw,{size:"sm",bg:"rgba(237,137,54,0.2)",color:"#F6AD55",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:"Private"})]}),(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.45)",fontFamily:"PoppinsRegular",fontSize:"12px",wordBreak:"break-all",children:[e.share_code,e.uid?" \xb7 creator ":"",e.uid&&(0,r.jsx)(p.E,{as:"span",color:t?"#63B3ED":"rgba(255,255,255,0.45)",cursor:t?"pointer":"default",textDecoration:t?"underline":"none",onClick:()=>e.uid&&t?.(e.uid),children:e.uid})]}),e.share_link&&(0,r.jsx)(p.E,{as:"a",href:e.share_link,target:"_blank",rel:"noreferrer",color:"#63B3ED",fontFamily:"PoppinsRegular",fontSize:"12px",textDecoration:"underline",wordBreak:"break-all",children:"Open share link"})]}),i&&(0,r.jsx)(F.J,{size:"sm",variant:"admin",icon:m.IeJ,ariaLabel:"Remove from featured",onClick:a})]})};var ie=a(27038);let ii={action:null,admin_uids:[],target_uid:null,include_views:!1},ia=(e,i)=>{let a={limit:50};return i&&(a.before=i),e.action&&(a.action=e.action),e.admin_uids.length>0&&(a.admin_uids=e.admin_uids.join(",")),e.target_uid&&(a.target_uid=e.target_uid),e.include_views&&(a.include_views="true"),a},ir=[{label:"All",value:null},{label:"User update",value:"user_update"},{label:"Email change",value:"user_email_update"},{label:"Mod reset",value:"moderation_reset_appeal"},{label:"Age verify",value:"age_verification_verify"},{label:"Yoti reset",value:"age_verification_reset_yoti_attempts"},{label:"Age revert",value:"age_verification_revert_to_restricted"},{label:"Social mod",value:"social_moderator_update"},{label:"Featured",value:"featured_kindroids_update"}],it=({onSelectTarget:e})=>{let{entries:i,loading:a,loadingMore:l,error:s,hasMore:o,filters:d,setFilters:h,refresh:j,loadMore:_}=(e=>{let i=x(),a=e&&i,[r,n]=(0,t.useState)([]),[l,s]=(0,t.useState)(a),[o,d]=(0,t.useState)(!1),[c,u]=(0,t.useState)(null),[p,m]=(0,t.useState)(null),[g,h]=(0,t.useState)(ii),[b,j]=(0,t.useState)(0),[_,y]=(0,t.useState)(a),[v,S]=(0,t.useState)(b),[w,z]=(0,t.useState)(g);(a!==_||b!==v||g!==w)&&(y(a),S(b),z(g),u(null),n([]),m(null),s(a)),(0,t.useEffect)(()=>
1{if(!a)return;let e=!1;return f.SP.get(f.Hr.AdminAuditLog,{params:ia(g)}).then(({data:i})=>{e||(n(i.entries||[]),m(i.next_cursor??null),s(!1))}).catch(i=>{e||(console.error("Failed to load admin audit log:",i),u(i.response?.data?.error||"Failed to load audit log"),s(!1))}),()=>{e=!0}},[a,b,g]);let F=(0,t.useCallback)(e=>{h(i=>({...i,...e}))},[]),C=(0,t.useCallback)(()=>j(e=>e+1),[]),R=(0,t.useCallback)(async()=>{if(a&&!o&&null!==p){d(!0);try{let{data:e}=await f.SP.get(f.Hr.AdminAuditLog,{params:ia(g,p)});n(i=>[...i,...e.entries||[]]),m(e.next_cursor??null)}catch(e){u(e.response?.data?.error||"Failed to load more")}finally{d(!1)}}},[a,g,o,p]);return{entries:r,loading:l,loadingMore:o,error:c,hasMore:null!==p,filters:g,setFilters:F,refresh:C,loadMore:R}})(!0),{members:y}=b(!0),z=(0,t.useMemo)(()=>0===d.admin_uids.length?"All admins":1===d.admin_uids.length?(e=>{let i=y.find(i=>i.uid===e);return i?.user_name||i?.email||`${e.slice(0,8)}â¦`})(d.admin_uids[0]):`${d.admin_uids.length} admins`,[d.admin_uids,y]),C=[...y.slice().sort((e,i)=>(e.user_name||e.email||"").localeCompare(i.user_name||i.email||"")).map(e=>{let i=d.admin_uids.includes(e.uid);return{label:e.user_name||e.email||e.uid,onClick:()=>(e=>{h({admin_uids:d.admin_uids.includes(e)?d.admin_uids.filter(i=>i!==e):[...d.admin_uids,e]})})(e.uid),keepOpen:!0,indicator:i?(0,r.jsx)(m.waL,{size:18,color:"rgba(255,255,255,0.9)"}):null}}),...d.admin_uids.length>0?[{label:"Clear selection",onClick:()=>h({admin_uids:[]})}]:[]];return(0,r.jsxs)(u.T,{spacing:5,align:"stretch",children:[(0,r.jsxs)(S.z,{justifyContent:"space-between",align:"center",children:[(0,r.jsxs)(u.T,{align:"start",spacing:0,children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsBold",fontSize:{base:"21px",lg:"25px"},color:"primaryWhite",children:"Audit Log"}),(0,r.jsxs)(p.E,{fontFamily:"PoppinsRegular",fontSize:"14px",color:"rgba(255,255,255,0.5)",children:["Every admin write across the system. Backed by"," ",(0,r.jsx)(p.E,{as:"span",fontFamily:"monospace",children:"Admin/AuditLog/Entries"}),"."]})]}),(0,r.jsx)(F.J,{size:"sm",variant:"default",label:"Refresh",onClick:j})]}),(0,r.jsx)(g,{children:(0,r.jsxs)(u.T,{align:"stretch",spacing:3,children:[(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,textTransform:"uppercase",letterSpacing:"0.5px",children:"Action"}),(0,r.jsxs)(H.B,{spacing:2,children:[ir.map(e=>(0,r.jsx)(F.J,{size:"sm",variant:"default",label:e.label,isActive:d.action===e.value,onClick:()=>h({action:e.value})},e.label)),(0,r.jsx)(F.J,{size:"sm",variant:"default",label:d.include_views?"Hide view rows":"Show view rows",isActive:d.include_views,onClick:()=>h({include_views:!d.include_views})})]})]}),(0,r.jsxs)(S.z,{spacing:3,flexWrap:"wrap",children:[(0,r.jsxs)(n.az,{flex:1,minW:"220px",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,textTransform:"uppercase",letterSpacing:"0.5px",children:"Admin"}),(0,r.jsx)(es._,{items:C,placement:"auto",minWidth:"260px","aria-label":"Filter by acting admin",emptyLabel:"No admin members loaded",trigger:({onToggle:e,triggerProps:i,isOpen:a})=>(0,r.jsxs)(ie.s,{as:"button",type:"button",onClick:e,align:"center",justify:"space-between",h:"32px",px:3,bg:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"md",color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",width:"100%",...i,children:[(0,r.jsx)(p.E,{noOfLines:1,children:z}),(0,r.jsx)(m.tEr,{size:14,style:{transition:"transform 0.15s",transform:a?"rotate(180deg)":"none"}})]})})]}),(0,r.jsxs)(n.az,{flex:1,minW:"220px",children:[(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"12px",color:"rgba(255,255,255,0.5)",mb:1,textTransform:"uppercase",letterSpacing:"0.5px",children:"Target UID"}),(0,r.jsx)(E.$,{value:d.target_uid??"",onChange:e=>h({target_uid:e.target.value.trim()||null}),placeholder:"Filter by affected user UID",size:"sm",fontSize:"13px",h:"32px"})]})]})]})}),a&&(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(v.y,{color:"purple",size:"lg"})}),s&&!a&&(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"#FC8181",children:s})}),!a&&!s&&0===i.length&&(0,r.jsx)(c.o,{py:12,children:(0,r.jsx)(p.E,{fontFamily:"PoppinsRegular",fontSize:"15px",color:"rgba(255,255,255,0.5)",children:"No entries match the current filters."})}
1),!a&&!s&&i.length>0&&(0,r.jsxs)(g,{children:[(0,r.jsx)(n.az,{overflowX:"auto",children:(0,r.jsxs)(X.X,{size:"sm",variant:"unstyled",children:[(0,r.jsx)(Q.d,{children:(0,r.jsx)(Z.Tr,{children:["Date","Action","Admin","Target","Changes"].map(e=>(0,r.jsx)(ee.Th,{color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",fontSize:"12px",textTransform:"uppercase",px:2,children:e},e))})}),(0,r.jsx)(ei.N,{children:i.map(i=>{let a="view"===i.action||"view_sensitive"===i.action,t=(e=>!!e&&e.startsWith("featured:"))(i.target_uid);return(0,r.jsxs)(Z.Tr,{children:[(0,r.jsx)(ea.Td,{color:"primaryWhite",fontFamily:"PoppinsRegular",fontSize:"13px",whiteSpace:"nowrap",px:2,py:2,verticalAlign:"top",children:er(i.timestamp)}),(0,r.jsx)(ea.Td,{px:2,py:2,verticalAlign:"top",children:(0,r.jsx)(w.vw,{size:"sm",bg:a?"rgba(159,122,234,0.2)":"rgba(99,179,237,0.2)",color:a?"#B794F4":"#63B3ED",borderRadius:"full",fontFamily:"PoppinsRegular",fontSize:"11px",children:(e=>ir.find(i=>i.value===e)?.label??e)(i.action)})}),(0,r.jsx)(ea.Td,{fontFamily:"PoppinsRegular",fontSize:"13px",px:2,py:2,verticalAlign:"top",children:(0,r.jsx)(p.E,{color:e?"#63B3ED":"primaryWhite",cursor:e?"pointer":"default",textDecoration:e?"underline":"none",onClick:()=>e&&e(i.admin_uid),wordBreak:"break-all",children:"self_service"===i.admin_role?"Self-service":i.admin_email||`${i.admin_uid?.slice(0,8)}â¦`})}),(0,r.jsx)(ea.Td,{fontFamily:"PoppinsRegular",fontSize:"13px",px:2,py:2,verticalAlign:"top",children:t?(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.45)",fontFamily:"monospace",fontSize:"12px",children:i.target_uid}):(0,r.jsx)(p.E,{color:e?"#63B3ED":"primaryWhite",cursor:e?"pointer":"default",textDecoration:e?"underline":"none",onClick:()=>e&&i.target_uid&&e(i.target_uid),wordBreak:"break-all",children:i.target_email||`${i.target_uid?.slice(0,8)}â¦`})}),(0,r.jsx)(ea.Td,{fontSize:"13px",px:2,py:2,verticalAlign:"top",children:(0,r.jsxs)(u.T,{align:"start",spacing:1,children:[i.field_changes&&Object.entries(i.field_changes).map(([e,{before:i,after:a}])=>(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.6)",fontFamily:"PoppinsRegular",fontSize:"12px",children:[e,":"," ",(0,r.jsx)(eV.C,{fontSize:"11px",bg:"rgba(245,101,101,0.15)",color:"#FC8181",px:1,children:JSON.stringify(i)})," ","â"," ",(0,r.jsx)(eV.C,{fontSize:"11px",bg:"rgba(72,187,120,0.15)",color:"#68D391",px:1,children:JSON.stringify(a)})]},e)),i.reason&&(0,r.jsxs)(p.E,{color:"rgba(255,255,255,0.75)",fontFamily:"PoppinsRegular",fontSize:"12px",mt:1,whiteSpace:"pre-wrap",wordBreak:"break-word",children:[(0,r.jsx)(p.E,{as:"span",color:"rgba(255,255,255,0.4)",fontFamily:"PoppinsRegular",children:"Reason:"})," ",i.reason]}),!i.field_changes&&!i.reason&&(0,r.jsx)(p.E,{color:"rgba(255,255,255,0.35)",fontFamily:"PoppinsRegular",fontSize:"12px",children:"â"})]})})]},i.id)})})]})}),o&&(0,r.jsx)(c.o,{pt:4,children:(0,r.jsx)(F.J,{size:"sm",variant:"default",label:l?"Loadingâ¦":"Load more",onClick:_,isDisabled:l})})]})]})};var il=a(3500),is=a(49815),io=a(78541),id=a(78372),ic=a(7885);let iu=e=>e.response?.data?.error||e.message||"Something went wrong",ip=({initial:e,onSubmit:i,onCancel:a,submitLabel:l})=>{let[s,o]=(0,t.useState)(e?.prompt??""),[d,c]=(0,t.useState)(e?.scopeOpen??""),[m,g]=(0,t.useState)(e?.scopeFixed??""),[h,f]=(0,t.useState)(e?.visibility??"staff_only"),[x,b]=(0,t.useState)(e?.status??"draft"),[j,_]=(0,t.useState)((e=>{if(!e)return"";let i=6e4*new Date(e).getTimezoneOffset();return new Date(e-i).toISOString().slice(0,16)})(e?.closeAt)),[y,v]=(0,t.useState)(e?e.structuredFields.map(e=>({label:e.label,type:e.type,optionsText:(e.options??[]).join(", ")})):[]),w=(e=>e?new Date(e).getTime():null)(j),z=!!s.trim()&&null!==w,F=(e,i)=>v(a=>a.map((a,r)=>r===e?{...a,...i}:a));return(0,r.jsxs)(u.T,{align:"stretch",spacing:3,color:"white",children:[(0,r.jsx)(p.E,{fontWeight:600,children:"Question prompt"}),(0,r.jsx)(k.T,{value:s,onChange:e=>o(e.target.value),placeholder:"The bounded questionâ¦",bg:"whiteAlpha.100",border:"none"}),(0,r.jsx)(p.E,{fontWeight:600,children:"Open for input (scope)"}),(0,r.jsx)(k.T,{value:d,onChange:e=>c(e.target.value),placeholder:"What is genuinely openâ¦",bg:"whiteAlpha.100",border:"none"}),(0,r.jsx)(p.E,{fontWeight:600,children:"Fixed / off the table"}),(0,r.jsx)(k.T,{value:m,onChange:e=>g(e.target.value),placeholder:"Legal/safety floor â minors, real non-consent, etc.",bg:"whiteAlpha.100",border:"none"}),(0,r.jsxs)(S.z,{align:"start",spacing:4,children:[(0,r.jsxs)(n.az,{flex:1,children:[(0,r.jsx)(p.E,{fontWeight:600,mb:1,children:"Visibility"}),(0,r.jsxs)(il.l,{value:h,onChange:e=>f(e.target.value),bg:"whiteAlpha.100",border:"none",children:[(0,r.jsx)("option",{value:"staff_only",children:"Staff-only (default)"}),(0,r.jsx)("option",{value:"peer_visible",children:"Peer-visible"})]})]}),(0,r.jsxs)(n.az,{flex:1,children:[(0,r.jsx)(p.E,{fontWeight:600,mb:1,children:"Status"}),(0,r.jsxs)(il.l,{value:x,onChange:e=>b(e.target.value),bg:"whiteAlpha.100",border:"none",children:[(0,r.jsx)("option",{value:"draft",children:"Draft"}),(0,r.jsx)("option",{value:"open",children:"Open"}),(0,r.jsx)("option",{value:"closed",children:"Closed"})]})]})]}),(0,r.jsxs)(n.az,{children:[(0,r.jsx)(p.E,{fontWeight:600,mb:1,children:"Close date (required)"}),(0,r.jsx)(is.p,{type:"datetime-local",value:j,onChange:e=>_(e.target.value),bg:"whiteAlpha.100",border:"none"})]}),(0,r.jsx)(io.c,{borderColor:"whiteAlpha.300"}),(0,r.jsxs)(S.z,{justify:"space-between",children:[(0,r.jsxs)(p.E,{fontWeight:600,children:["Optional structured fields (",y.length,"/2)"]}),y.length<2&&(0,r.jsx)(eq.$,{size:"xs",onClick:()=>v(e=>[...e,{label:"",type:"yes_no",optionsText:""}]),children:"Add field"})]}),y.map((e,i)=>(0,r.jsxs)(u.T,{align:"stretch",spacing:2,p:3,bg:"whiteAlpha.50",borderRadius:"md",children:[(0,r.jsxs)(S.z,{children:[(0,r.jsx)(is.p,{flex:2,value:e.label,onChange:e=>F(i,{label:e.target.value}),placeholder:"Field label",bg:"whiteAlpha.100",border:"none"}
1),(0,r.jsxs)(il.l,{flex:1,value:e.type,onChange:e=>F(i,{type:e.target.value}),bg:"whiteAlpha.100",border:"none",children:[(0,r.jsx)("option",{value:"yes_no",children:"Yes / No"}),(0,r.jsx)("option",{value:"select",children:"Select"})]}),(0,r.jsx)(eq.$,{size:"sm",variant:"ghost",onClick:()=>v(e=>e.filter((e,a)=>a!==i)),children:"Remove"})]}),"select"===e.type&&(0,r.jsx)(is.p,{value:e.optionsText,onChange:e=>F(i,{optionsText:e.target.value}),placeholder:"Comma-separated options",bg:"whiteAlpha.100",border:"none"})]},i)),(0,r.jsxs)(S.z,{pt:2,children:[(0,r.jsx)(eq.$,{colorScheme:"orange",onClick:()=>{z&&null!==w&&i({prompt:s.trim(),scopeOpen:d.trim(),scopeFixed:m.trim(),visibility:h,status:x,closeAt:w,structuredFields:y.filter(e=>e.label.trim()).map((e,i)=>{let a={id:`f${i+1}`,label:e.label.trim(),type:e.type};return"select"===e.type&&(a.options=e.optionsText.split(",").map(e=>e.trim()).filter(Boolean)),a})})},isDisabled:!z,children:l}),(0,r.jsx)(eq.$,{variant:"ghost",onClick:a,children:"Cancel"})]})]})},im=({question:e,publishCloseout:i,onBack:a})=>{let{responses:l,loading:s,error:o,moderate:d}=(e=>{let i=x(),a=(0,G.$)(),r=i&&!!e,[n,l]=(0,t.useState)([]),[s,o]=(0,t.useState)(r),[d,c]=(0,t.useState)(null),[u,p]=(0,t.useState)(0),[m,g]=(0,t.useState)(`${e}:${u}`),h=`${e}:${u}`;return h!==m&&(g(h),c(null),o(r),r||l([])),(0,t.useEffect)(()=>{if(!r||!e)return;let i=!1;return(0,ic.Zx)(e).then(({responses:e})=>{i||(l(e),o(!1))}).catch(e=>{i||(c(iu(e)),o(!1))}),()=>{i=!0}},[r,e,u]),{responses:n,loading:s,error:d,moderate:(0,t.useCallback)(async(i,r,t)=>{if(!e)return!1;try{return await (0,ic.PS)({questionId:e,uid:i,action:r,reason:t}),p(e=>e+1),!0}catch(e){return a({title:"Action failed",description:iu(e),status:"error",duration:5e3}),!1}},[e,a])}})(e.id),[c,m]=(0,t.useState)(e.closeout?.body??"");return(0,r.jsxs)(u.T,{align:"stretch",spacing:4,color:"white",children:[(0,r.jsx)(eq.$,{size:"sm",variant:"ghost",alignSelf:"flex-start",onClick:a,children:"â Back"}),(0,r.jsx)(p.E,{fontSize:"lg",fontWeight:700,children:e.prompt}),(0,r.jsxs)(n.az,{p:3,bg:"whiteAlpha.50",borderRadius:"md",children:[(0,r.jsx)(p.E,{fontWeight:600,mb:1,children:"Closeout (published to participants)"}),(0,r.jsx)(k.T,{value:c,onChange:e=>m(e.target.value),placeholder:"Here's what you said, here's what we're doing and whyâ¦",bg:"whiteAlpha.100",border:"none"}),(0,r.jsx)(eq.$,{mt:2,size:"sm",colorScheme:"orange",isDisabled:!c.trim(),onClick:()=>i(e.id,c.trim()),children:"Publish closeout"})]}),(0,r.jsx)(io.c,{borderColor:"whiteAlpha.300"}),(0,r.jsxs)(p.E,{fontWeight:600,children:["Responses (",l.length,")"]}),s&&(0,r.jsx)(v.y,{}),o&&(0,r.jsx)(p.E,{color:"red.300",children:o}),!s&&0===l.length&&(0,r.jsx)(p.E,{color:"whiteAlpha.600",children:"No responses yet."}),l.map(e=>(0,r.jsxs)(n.az,{p:3,bg:"whiteAlpha.50",borderRadius:"md",opacity:e.removed?.5:1,children:[(0,r.jsxs)(S.z,{mb:1,spacing:2,children:[(0,r.jsx)(p.E,{fontSize:"sm",fontWeight:600,children:e.displayName}),e.flagged&&(0,r.jsx)(id.E,{colorScheme:"yellow",children:"Flagged"}),e.removed&&(0,r.jsx)(id.E,{colorScheme:"red",children:"Removed"})]}),(0,r.jsx)(p.E,{fontSize:"sm",whiteSpace:"pre-wrap",children:e.text}),Object.keys(e.structuredAnswers).length>0&&(0,r.jsx)(p.E,{fontSize:"xs",color:"whiteAlpha.600",mt:1,children:Object.entries(e.structuredAnswers).map(([e,i])=>`${e}: ${i}`).join(" \xb7 ")}),(0,r.jsxs)(S.z,{mt:2,spacing:2,children:[(0,r.jsx)(eq.$,{size:"xs",variant:"outline",onClick:()=>d(e.uid,e.flagged?"unflag":"flag"),children:e.flagged?"Unflag":"Flag"}),(0,r.jsx)(eq.$,{size:"xs",colorScheme:e.removed?"green":"red",variant:"outline",onClick:()=>d(e.uid,e.removed?"restore":"remove"),children:e.removed?"Restore":"Remove"})]})]},e.uid))]})},ig=()=>{let{questions:e,loading:i,error:a,createQuestion:l,updateQuestion:s,publishCloseout:o}=(e=>{let i=x(),a=(0,G.$)(),r=e&&i,[n,l]=(0,t.useState)([]),[s,o]=(0,t.useState)(r),[d,c]=(0,t.useState)(null),[u,p]=(0,t.useState)(0),[m,g]=(0,t.useState)(r),[h,f]=(0,t.useState)(u);(r!==m||u!==h)&&(g(r),f(u),c(null),o(r),r||l([])),(0,t.useEffect)(()=>{if(!r)return;let e=!1;return(0,ic.SJ)().then(({questions:i})=>{e||(l(i),o(!1))}).catch(i=>{e||(c(iu(i)),o(!1))}),()=>{e=!0}},[r,u]);let b=(0,t.useCallback)(()=>p(e=>e+1),[]),j=(0,t.useCallback)(async e=>{if(!i)return null;try{let{questionId:i}=await (0,ic.dg)(e);return a({title:"Question created",status:"success",duration:3e3}),b(),i}catch(e){return a({title:"Failed to create",description:iu(e),status:"error",duration:5e3}),null}},[i,a,b]),_=(0,t.useCallback)(async e=>{if(!i)return!1;try{return await (0,ic.Cs)(e),a({title:"Saved",status:"success",duration:2500}),b(),!0}catch(e){return a({title:"Failed to save",description:iu(e),status:"error",duration:5e3}),!1}},[i,a,b]),y=(0,t.useCallback)(async(e,r)=>{if(!i)return!1;try{return await (0,ic.e1)({questionId:e,body:r}),a({title:"Closeout published",status:"success",duration:3e3}),b(),!0}catch(e){return a({title:"Failed to publish",description:iu(e),status:"error",duration:5e3}),!1}},[i,a,b]);return{questions:n,loading:s,error:d,refresh:b,createQuestion:j,updateQuestion:_,publishCloseout:y}})(!0),[d,c]=(0,t.useState)({kind:"list"});return"create"===d.kind?(0,r.jsx)(ip,{submitLabel:"Create",onCancel:()=>c({kind:"list"}),onSubmit:async e=>{await l(e)&&c({kind:"list"})}}):"edit"===d.kind?(0,r.jsx)(ip,{initial:d.question,submitLabel:"Save",onCancel:()=>c({kind:"list"}),onSubmit:async e=>{await s({questionId:d.question.id,...e})&&c({kind:"list"})}}):"responses"===d.kind?(0,r.jsx)(im,{question:d.question,publishCloseout:o,onBack:()=>c({kind:"list"})}):(0,r.jsxs)(u.T,{align:"stretch",spacing:4,color:"white",children:[(0,r.jsxs)(ie.s,{justify:"space-between",align:"center",children:[(0,r.jsx)(p.E,{fontSize:"xl",fontWeight:700,children:"Community Voices"}),(0,r.jsx)(eq.$,{colorScheme:"orange",onClick:()=>c({kind:"create"}),children:"New question"})]}),i&&(0,r.jsx)(v.y,{}),a&&(0,r.jsx)(p.E,{color:"red.300",children:a}),!i&&0===e.length&&(0,r.jsx)(p.E,{color:"whiteAlpha.600",children:"No questions yet."}),e.map(e=>(0,r.jsxs)(n.az,{p:4,bg:"whiteAlpha.50",borderRadius:"md",children:[(0,r.jsxs)(S.z,{mb:2,spacing:2,children:[(0,r.jsx)(id.E,{colorScheme:"open"===e.status?"green":"closed"===e.status?"gray":"purple",children:e.status}),(0,r.jsx)(id.E,{colorScheme:"peer_visible"===e.visibility?"blue":"orange",children:"peer_visible"===e.visibility?"peer-visible":"staff-only"}),e.closeout&&(0,r.jsx)(id.E,{colorScheme:"teal",children:"closeout"})]}),(0,r.jsx)(p.E,{fontWeight:600,mb:2,noOfLines:2,children:e.prompt}),(0,r.jsxs)(p.E,{fontSize:"sm",color:"whiteAlpha.700",mb:3,children:[e.responseCount," responses"]}),(0,r.jsxs)(S.z,{spacing:2,children:[(0,r.jsx)(eq.$,{size:"sm",onClick:()=>c({kind:"edit",question:e}),children:"Edit"}),(0,r.jsx)(eq.$,{size:"sm",variant:"outline",onClick:()=>c({kind:"responses",question:e}),children:"Responses & closeout"})]})]},e.id))]})},ih=l.Ii.getPlatform(),ix=()=>{let e=(0,s.useRouter)(),{adminRole:i}=(0,d.GV)(d.Ax.me),a=(0,P.y9)(i),l=(0,P.jm)(i),c=(0,P.sf)(i),u="string"==typeof e.query.uid?e.query.uid:null,p="string"==typeof e.query.view?e.query.view:null,m=(e,a)=>e?"user":"members"===a?c?"members":"search":"featured"===a?"featured":"audit"===a?l?"audit":"search":"community-voices"===a&&(0,P.sf)(i)?"community-voices":"search",g=m(u,p),[j,v]=(0,t.useState)(u),[S,w]=(0,t.useState)(g),[z,F]=(0,t.useState)(u),[C,R]=(0,t.useState)(p),[k,A]=(0,t.useState)(i);(u!==z||p!==C||i!==k)&&(F(u),R(p),A(i),v(u),w(m(u,p)));let E=(()=>{let e=x(),[i,a]=(0,t.useState)(""),[r,n]=(0,t.useState)([]),[l,s]=(0,t.useState)(!1),[o,d]=(0,t.useState)(!1),[c,u]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let a=i.trim();
1if(!a||!e){d(!1),!a&&c&&(n([]),u(!1));return}let r=y(a);if("violation_id"===r&&!_(a))return void d(!1);d(!0);let t=setTimeout(async()=>{d(!1),s(!0),u(!0);try{let e="violation_id"===r?_(a)??a:a,{data:i}=await f.SP.post(f.Hr.AdminUserSearch,{query:e,type:r});n(i.results||[])}catch(e){console.error("Admin search failed:",e),n([])}finally{s(!1)}},3e3);return()=>clearTimeout(t)},[i,e]);let p=(0,t.useCallback)(()=>{a(""),n([]),u(!1),d(!1)},[]);return{query:i,setQuery:a,results:r,isSearching:l,isDebouncing:o,hasSearched:c,reset:p}})(),{data:T,loading:D,error:$,refresh:W}=(e=>{let i=x()?e:null,[a,r]=(0,t.useState)(null),[n,l]=(0,t.useState)(!!i),[s,o]=(0,t.useState)(null),[d,c]=(0,t.useState)(0),[u,p]=(0,t.useState)(i);i!==u&&(p(i),r(null),o(null),l(!!i)),(0,t.useEffect)(()=>{if(!i)return;let e=!1;return f.SP.get(f.Hr.AdminUserDetail(i)).then(({data:i})=>{e||(r(i),l(!1))}).catch(i=>{e||(console.error("Failed to load user detail:",i),o(i.response?.data?.error||"Failed to load user"),r(null),l(!1))}),()=>{e=!0}},[i,d]);let[m,g]=(0,t.useState)(d);return d!==m&&(g(d),i&&l(!0)),{data:a,loading:n,error:s,refresh:(0,t.useCallback)(()=>{c(e=>e+1)},[])}})(a?j:null),L=b(c&&"members"===S),U=(0,t.useCallback)(i=>{v(i),w("user"),e.replace({pathname:e.pathname,query:{uid:i}},void 0,{shallow:!0})},[e]);return a?(0,r.jsx)(n.az,{width:"100%",bg:"primaryBlack",mt:"web"===ih?o.uF:0,h:"web"===ih?{base:`calc(100vh - ${o.uF.base})`,lg:`calc(100vh - ${o.uF.lg})`}:"100vh",overflowY:"auto",children:(0,r.jsxs)(n.az,{width:"100%",maxW:"900px",mx:"auto",px:4,py:6,children:["search"===S&&(0,r.jsx)(q,{query:E.query,results:E.results,isSearching:E.isSearching,isDebouncing:E.isDebouncing,hasSearched:E.hasSearched,onQueryChange:E.setQuery,onSelect:U}),"user"===S&&(0,r.jsx)(eZ,{data:T,loading:D,error:$,onRefresh:W,onSelectTarget:e=>U(e)}),"members"===S&&c&&(0,r.jsx)(B,{members:L.members,loading:L.loading,error:L.error,onSelectMember:e=>U(e),onRefresh:L.refresh,callerRole:i}),"featured"===S&&(0,r.jsx)(e8,{canEdit:(0,P.sf)(i),onSelectTarget:e=>U(e)}),"audit"===S&&l&&(0,r.jsx)(it,{onSelectTarget:e=>U(e)}),"community-voices"===S&&(0,P.sf)(i)&&(0,r.jsx)(ig,{})]})}):(0,r.jsx)(n.az,{width:"100%",bg:"primaryBlack",mt:"web"===ih?o.uF:0,h:"web"===ih?{base:`calc(100vh - ${o.uF.base})`,lg:`calc(100vh - ${o.uF.lg})`}:"100vh",children:(0,r.jsx)(h,{})})},ib=()=>(0,r.jsx)(ix,{})},74768:(e,i,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin",function(){return a(37563)}])}},e=>{e.O(0,[8511,713,4938,3835,3302,2517,8585,9942,9897,5015,1163,289,8433,2883,8987,1473,1057,5452,6973,6660,3060,6793,8255,6593,8792],()=>e(e.s=74768)),_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.