`).map(l=>l.trim()).filter(Boolean))})})}function wt({initial:s,busy:n,onConfirm:t,onCancel:a}){const[i,l]=f.useState(s||"Memby TV");return e.jsx("div",{className:"scrim",onPointerDown:r=>r.target===r.currentTarget&&a(),children:e.jsxs("div",{className:"dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h2",{children:"Name this device"}),e.jsx("p",{children:"The name a viewer sees in Settings → Devices, and what the console calls it."}),e.jsx(D,{label:"Device name",children:e.jsx("input",{type:"text",value:i,autoFocus:!0,maxLength:80,onChange:r=>l(r.target.value)})}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx(T,{variant:"quiet",onClick:a,children:"Cancel"}),e.jsx(T,{variant:"primary",busy:n,disabled:!i.trim(),onClick:()=>t(i.trim()),children:"Rename"})]})]})})}function kt({initial:s,renaming:n,busy:t,onConfirm:a,onCancel:i}){const[l,r]=f.useState(s);return e.jsx("div",{className:"scrim",onPointerDown:d=>d.target===d.currentTarget&&i(),children:e.jsxs("div",{className:"dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h2",{children:n?"Rename this viewer":"Add a viewer"}),e.jsx("p",{children:"The name shown on the television’s “Who’s watching?” screen. Everything they watch is kept by Memby and never reported to Emby."}),e.jsx(D,{label:"Name",children:e.jsx("input",{type:"text",value:l,autoFocus:!0,maxLength:40,onChange:d=>r(d.target.value)})}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx(T,{variant:"quiet",onClick:i,children:"Cancel"}),e.jsx(T,{variant:"primary",busy:t,disabled:!l.trim(),onClick:()=>a(l.trim()),children:n?"Rename":"Add viewer"})]})]})})}function Nt({pending:s,busy:n,username:t,onConfirm:a,onCancel:i}){const r={"remove-device":{title:"Sign this device out of Memby?",body:"Its Emby account will not be changed. The set can sign in again at any time.",label:"Sign out",destructive:!0},"remove-account":{title:`RemoveMembyaccessfor${t||"this user"}?`,body:"Every Memby device will be signed out. Their Emby account, viewing history and library permissions are untouched.",label:"Remove access",destructive:!0},"reset-recommendations":{title:"Clear this person's stored recommendation choices?",body:"Viewing history remains intact; only the explicit setup answers are removed.",label:"Clear",destructive:!0},"cancel-prompt":{title:"Cancel this person's queued recommendation prompt?",body:"They will not be invited to set up recommendations on their next launch.",label:"Cancel prompt",destructive:!1},"reset-preferences":{title:"Restore the Memby defaults for this person?",body:"Their televisions will pick the change up the next time they check in.",label:"Restore defaults",destructive:!0},"remove-viewer":{title:"Remove this viewer?",body:"What they were part-way through, what they had watched and their favourites are deleted, on every television in the house. The Emby account is untouched.",label:"Remove viewer",destructive:!0},"no-themes":{title:"Allow this person no colour schemes?",body:"They will be left on Midnight with nothing to choose between.",label:"Save anyway",destructive:!0}}[s.kind];return e.jsx(ke,{title:r.title,body:r.body,confirmLabel:r.label,destructive:r.destructive,busy:!!n,onConfirm:a,onCancel:i})}function St(s,n){if(s.kind==="toggle")return n?"On":"Off";if(s.kind==="choice"){const a=(s.options??[]).find(i=>i.value===n);return a?a.label:String(n??"")}if(s.kind==="number")return Number(n)===0&&s.unit?"No limit":s.unit?`${n}${s.unit}`:String(n??"");const t=Array.isArray(n)?n:[];return t.length===0?"None":t.map(a=>{var i;return((i=(s.options??[]).find(l=>l.value===a))==null?void 0:i.label)??a}).join(", ")}function Ct(){const{userId:s=""}=Be(),{wrap:n}=te(),{busy:t,run:a}=se(),i=`/admin/api/accounts/${encodeURIComponent(s)}`,{data:l,error:r,loading:d,reload:c}=Y(`${i}/preferences/history`,{pollMs:3e4}),[o,u]=f.useState(new Set),[j,p]=f.useState(null),g=(l==null?void 0:l.username)||"this account",b=(l==null?void 0:l.devices)??[],h=(l==null?void 0:l.revisions)??[],m=(l==null?void 0:l.catalogue)??[],y=x=>u($=>{const k=new Set($);return k.has(x)?k.del