@rubytech/create-maxy-code 0.1.356 → 0.1.357
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.d.ts +2 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.js +109 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-setup.test.js +22 -0
- package/payload/platform/plugins/email/mcp/dist/__tests__/email-setup.test.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts +14 -7
- package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/credentials.js +87 -31
- package/payload/platform/plugins/email/mcp/dist/lib/credentials.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-status.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-status.js +2 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-status.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.js +60 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js +11 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js.map +1 -1
- package/payload/server/{chunk-25UVZNFA.js → chunk-CXEC5RWB.js} +26 -3
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/assets/{AdminLoginScreens-4I5CdIWl.js → AdminLoginScreens-BW1UgfoI.js} +1 -1
- package/payload/server/public/assets/{AdminShell-Bc9F7X_N.js → AdminShell-CDQDkT1R.js} +1 -1
- package/payload/server/public/assets/{Checkbox-DoQV18Ow.js → Checkbox-O1qvMk_u.js} +1 -1
- package/payload/server/public/assets/{OperatorConversations-C1I78hON.css → OperatorConversations-CVH-FoJo.css} +1 -1
- package/payload/server/public/assets/{admin-DLsMA09F.js → admin-BkYc54bi.js} +1 -1
- package/payload/server/public/assets/{browser-w6rY_KAO.js → browser-CySvj140.js} +1 -1
- package/payload/server/public/assets/{calendar-CvEdDFYd.js → calendar-DgP7lal2.js} +1 -1
- package/payload/server/public/assets/chat-gls5aV50.js +1 -0
- package/payload/server/public/assets/{data-p3T_EZFq.js → data-CbI8-CX3.js} +1 -1
- package/payload/server/public/assets/{graph-labels-BNZ8u8TE.js → graph-labels-BNnhRQqM.js} +1 -1
- package/payload/server/public/assets/{graph-BrwfYOr3.js → graph-uFhGyOZR.js} +1 -1
- package/payload/server/public/assets/{operator-BNY1P_mH.js → operator-DeCk_qYw.js} +1 -1
- package/payload/server/public/assets/{page-CtygoIXt.js → page-jGwq-DpW.js} +2 -2
- package/payload/server/public/assets/{public-CDzw6yjH.js → public-DgltXhnD.js} +1 -1
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +4 -4
- package/payload/server/public/chat.html +5 -5
- package/payload/server/public/data.html +4 -4
- package/payload/server/public/graph.html +6 -6
- package/payload/server/public/index.html +6 -6
- package/payload/server/public/operator.html +7 -7
- package/payload/server/public/public.html +5 -5
- package/payload/server/server.js +11 -2
- package/payload/server/userprofile-reconcile-GLGKDVQQ.js +48 -0
- package/payload/server/public/assets/chat-BlOWMUVI.js +0 -1
- /package/payload/server/public/assets/{OperatorConversations-BJY9FZbr.js → OperatorConversations-jqaPCHwB.js} +0 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AAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -4313,6 +4313,10 @@ async function runAdminUserSelfHeal(args) {
|
|
|
4313
4313
|
const { selfHealAdminUser } = await import("./adminuser-self-heal-LC7HZAC6.js");
|
|
4314
4314
|
return selfHealAdminUser({ driver: getDriver(), ...args });
|
|
4315
4315
|
}
|
|
4316
|
+
async function runUserProfileReconcile() {
|
|
4317
|
+
const { reconcileUserProfiles } = await import("./userprofile-reconcile-GLGKDVQQ.js");
|
|
4318
|
+
return reconcileUserProfiles({ driver: getDriver() });
|
|
4319
|
+
}
|
|
4316
4320
|
process.on("SIGINT", async () => {
|
|
4317
4321
|
if (driver) {
|
|
4318
4322
|
await driver.close();
|
|
@@ -5075,6 +5079,7 @@ async function writeAdminUserAndPerson(params) {
|
|
|
5075
5079
|
`
|
|
5076
5080
|
);
|
|
5077
5081
|
}
|
|
5082
|
+
const serverTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
5078
5083
|
const session = getSession();
|
|
5079
5084
|
try {
|
|
5080
5085
|
const result = await session.run(
|
|
@@ -5091,12 +5096,24 @@ async function writeAdminUserAndPerson(params) {
|
|
|
5091
5096
|
au.role = COALESCE(au.role, 'owner')
|
|
5092
5097
|
WITH au
|
|
5093
5098
|
|
|
5099
|
+
// Task 1150 \u2014 UserProfile guaranteed off the just-MERGEd AdminUser.
|
|
5100
|
+
MERGE (au)-[:HAS_PROFILE]->(up:UserProfile {accountId: $accountId, userId: $userId})
|
|
5101
|
+
ON CREATE SET
|
|
5102
|
+
up.createdAt = $now,
|
|
5103
|
+
up.updatedAt = $now,
|
|
5104
|
+
up.profileVersion = 0,
|
|
5105
|
+
up.scope = 'admin',
|
|
5106
|
+
up.timezone = $serverTimezone
|
|
5107
|
+
ON MATCH SET
|
|
5108
|
+
up.timezone = CASE WHEN up.timezone IS NULL OR trim(up.timezone) = '' THEN $serverTimezone ELSE up.timezone END
|
|
5109
|
+
WITH au, (up.createdAt = $now) AS profileIsNew
|
|
5110
|
+
|
|
5094
5111
|
// Case-insensitive Person reuse: same accountId, same givenName, same familyName
|
|
5095
5112
|
// (null/empty familyName collapsed to '' so 'Joel' does NOT match 'Joel Smalley').
|
|
5096
5113
|
OPTIONAL MATCH (existingPerson:Person {accountId: $accountId})
|
|
5097
5114
|
WHERE toLower(existingPerson.givenName) = toLower($givenName)
|
|
5098
5115
|
AND coalesce(toLower(existingPerson.familyName), '') = coalesce(toLower($familyName), '')
|
|
5099
|
-
WITH au, existingPerson
|
|
5116
|
+
WITH au, profileIsNew, existingPerson
|
|
5100
5117
|
|
|
5101
5118
|
CALL {
|
|
5102
5119
|
WITH au, existingPerson
|
|
@@ -5118,14 +5135,19 @@ async function writeAdminUserAndPerson(params) {
|
|
|
5118
5135
|
MERGE (au)-[:OWNS]->(newPerson)
|
|
5119
5136
|
RETURN newPerson AS p, false AS reused
|
|
5120
5137
|
}
|
|
5121
|
-
RETURN reused, elementId(p) AS personElementId,
|
|
5138
|
+
RETURN reused, profileIsNew, elementId(p) AS personElementId,
|
|
5122
5139
|
p.givenName AS givenName, p.familyName AS familyName`,
|
|
5123
|
-
{ userId, fullName: trimmed, accountId, givenName, familyName, now, personEmbedding }
|
|
5140
|
+
{ userId, fullName: trimmed, accountId, givenName, familyName, now, personEmbedding, serverTimezone }
|
|
5124
5141
|
);
|
|
5125
5142
|
if (result.records.length === 0) {
|
|
5126
5143
|
throw new Error("writeAdminUserAndPerson: no record returned");
|
|
5127
5144
|
}
|
|
5128
5145
|
const record = result.records[0];
|
|
5146
|
+
if (record.get("profileIsNew")) {
|
|
5147
|
+
console.error(
|
|
5148
|
+
`[profile] provisioned at admin-bootstrap userId=${userId} accountId=${accountId.slice(0, 8)}\u2026 timezone=${serverTimezone}`
|
|
5149
|
+
);
|
|
5150
|
+
}
|
|
5129
5151
|
return {
|
|
5130
5152
|
personReused: record.get("reused"),
|
|
5131
5153
|
personElementId: record.get("personElementId"),
|
|
@@ -5838,6 +5860,7 @@ export {
|
|
|
5838
5860
|
requirePortEnv,
|
|
5839
5861
|
getSession,
|
|
5840
5862
|
runAdminUserSelfHeal,
|
|
5863
|
+
runUserProfileReconcile,
|
|
5841
5864
|
embed,
|
|
5842
5865
|
GREETING_DIRECTIVE,
|
|
5843
5866
|
ensureConversation,
|
package/payload/server/public/assets/{AdminLoginScreens-4I5CdIWl.js → AdminLoginScreens-BW1UgfoI.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,U as r,b as i,x as a,z as o}from"./OperatorConversations-BJY9FZbr.js";import{i as s}from"./admin-types-DJoj6VJv.js";import{_ as c,u as l}from"./AdminShell-Bc9F7X_N.js";import{t as u}from"./Checkbox-DoQV18Ow.js";var d=`admin-landing-redirected`,f=`/graph`;function p(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var m=e(r(),1);function h(e=`admin`){let[t,n]=(0,m.useState)(`loading`),[r,i]=(0,m.useState)(``),[a,l]=(0,m.useState)(``),[u,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(void 0),[M,N]=(0,m.useState)(null),[P,F]=(0,m.useState)(void 0),[I,L]=(0,m.useState)(null),[ee,R]=(0,m.useState)(null),[z,B]=(0,m.useState)([]),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(void 0),G=(0,m.useRef)(void 0),[K,q]=(0,m.useState)(!1);(0,m.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&q(!0)}).catch(()=>{})},[]);let J=(0,m.useRef)(null),Y=(0,m.useRef)(null);(0,m.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),R(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=s(r.thinkingView);return G.current=i,W(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}if(!a.claude_authenticated){n(`connect-claude`);return}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,m.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,m.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(d)===`1`}catch{}if(p({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(d,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${f}`),window.location.replace(f)}},[t,e]);let X=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();if(t.auth_status===`dead`||t.auth_status===`missing`){n(`connect-claude`);return}}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){o(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),X.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,m.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&n(`enter-pin`)}).catch(()=>{})},[t]);async function Z(e,t){y(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){o(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let a=await r.json();if(a.accounts&&!a.session_key){console.log(`[admin] account picker shown: userId=${a.userId} accountCount=${a.accounts.length}`),B(a.accounts),n(`account-picker`);return}D(a.session_key),R(a.sessionId??null),j(a.businessName),N(a.role??null),F(a.userName===void 0?null:a.userName),L(a.avatar??null);let c=s(a.thinkingView);if(G.current=c,W(c),t)try{sessionStorage.setItem(`maxy-account-id`,t)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,a.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1),H(!1)}}let Q=(0,m.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=a.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let s=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){o(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await Z(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,a]),te=(0,m.useCallback)(async e=>{e.preventDefault(),h(``),await Z(r)},[r]),ne=(0,m.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(d)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,m.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(d)}catch{}i(``),h(``),n(`enter-pin`)},[]);return(0,m.useEffect)(()=>{X.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:a,setOperatorName:l,pinError:u,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:ee,setSessionId:R,accounts:z,accountPickerLoading:V,expandAll:U,setExpandAll:W,expandAllDefaultRef:G,remoteAuthEnabled:K,pinInputRef:J,setPinFormRef:Y,handleSetPin:Q,handleLogin:te,handleAccountSelect:(0,m.useCallback)(async e=>{H(!0),h(``),await Z(r,e)},[r]),handleDisconnect:ne,handleLogout:$}}var g=n();function _({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,m.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,g.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,g.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function v(e){let{pin:t,setPin:n,showPin:r,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:h}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,g.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,g.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>h(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,g.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,g.jsx)(l,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(u,{checked:r,onChange:()=>o(e=>!e),label:`Show PIN`})]}),c&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function y(e){let{pin:t,setPin:n,showPin:r,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,g.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,g.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,g.jsx)(l,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(`div`,{className:`pin-options`,children:(0,g.jsx)(u,{checked:r,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),c&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:c})]})]})}function b(e){let{accounts:n,loading:r,error:o,onSelect:s}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Select an account`}),(0,g.jsx)(`div`,{className:`account-picker-list`,children:n.map(e=>(0,g.jsxs)(`button`,{className:`account-picker-card`,onClick:()=>s(e.accountId),disabled:r,type:`button`,children:[(0,g.jsx)(`span`,{className:`account-picker-name`,children:e.businessName||e.accountId}),(0,g.jsx)(`span`,{className:`account-picker-role`,children:e.role}),r&&(0,g.jsx)(t,{className:`account-picker-spinner`,size:16})]},e.accountId))}),o&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:o})]})})}function x(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:o,pinError:s,setPinError:c,setAppState:u}=e,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);async function _(){h(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&c(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),c(`Could not launch browser.`)}h(!1)}async function v(){o(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),o(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}c(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&c(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),c(`Could not start auth flow.`)}o(!1)}async function y(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),c(``)}return t||d?(0,g.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,g.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,g.jsx)(`button`,{onClick:y,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,g.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,g.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,g.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,g.jsx)(`div`,{style:{marginTop:`12px`},children:(0,g.jsx)(l,{variant:`primary`,onClick:v,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,g.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,g.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsxs)(`div`,{className:`connect-logos`,children:[(0,g.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,g.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,g.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,g.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,g.jsx)(l,{variant:`primary`,onClick:v,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,g.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,g.jsx)(`button`,{onClick:_,disabled:p,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:p?`Launching…`:`Open browser first`}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function S({auth:e}){return e.appState===`loading`?(0,g.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,g.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,g.jsx)(x,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,g.jsx)(y,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):e.appState===`account-picker`?(0,g.jsx)(b,{accounts:e.accounts,loading:e.accountPickerLoading,error:e.pinError,onSelect:e.handleAccountSelect}):null}export{h as n,S as t};
|
|
1
|
+
import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,U as r,b as i,x as a,z as o}from"./OperatorConversations-jqaPCHwB.js";import{i as s}from"./admin-types-DJoj6VJv.js";import{_ as c,u as l}from"./AdminShell-CDQDkT1R.js";import{t as u}from"./Checkbox-O1qvMk_u.js";var d=`admin-landing-redirected`,f=`/graph`;function p(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var m=e(r(),1);function h(e=`admin`){let[t,n]=(0,m.useState)(`loading`),[r,i]=(0,m.useState)(``),[a,l]=(0,m.useState)(``),[u,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(void 0),[M,N]=(0,m.useState)(null),[P,F]=(0,m.useState)(void 0),[I,L]=(0,m.useState)(null),[ee,R]=(0,m.useState)(null),[z,B]=(0,m.useState)([]),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(void 0),G=(0,m.useRef)(void 0),[K,q]=(0,m.useState)(!1);(0,m.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&q(!0)}).catch(()=>{})},[]);let J=(0,m.useRef)(null),Y=(0,m.useRef)(null);(0,m.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),R(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=s(r.thinkingView);return G.current=i,W(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}if(!a.claude_authenticated){n(`connect-claude`);return}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,m.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,m.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(d)===`1`}catch{}if(p({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(d,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${f}`),window.location.replace(f)}},[t,e]);let X=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();if(t.auth_status===`dead`||t.auth_status===`missing`){n(`connect-claude`);return}}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){o(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),X.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,m.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&n(`enter-pin`)}).catch(()=>{})},[t]);async function Z(e,t){y(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){o(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let a=await r.json();if(a.accounts&&!a.session_key){console.log(`[admin] account picker shown: userId=${a.userId} accountCount=${a.accounts.length}`),B(a.accounts),n(`account-picker`);return}D(a.session_key),R(a.sessionId??null),j(a.businessName),N(a.role??null),F(a.userName===void 0?null:a.userName),L(a.avatar??null);let c=s(a.thinkingView);if(G.current=c,W(c),t)try{sessionStorage.setItem(`maxy-account-id`,t)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,a.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1),H(!1)}}let Q=(0,m.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=a.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let s=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){o(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await Z(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,a]),te=(0,m.useCallback)(async e=>{e.preventDefault(),h(``),await Z(r)},[r]),ne=(0,m.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(d)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,m.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(d)}catch{}i(``),h(``),n(`enter-pin`)},[]);return(0,m.useEffect)(()=>{X.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:a,setOperatorName:l,pinError:u,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:ee,setSessionId:R,accounts:z,accountPickerLoading:V,expandAll:U,setExpandAll:W,expandAllDefaultRef:G,remoteAuthEnabled:K,pinInputRef:J,setPinFormRef:Y,handleSetPin:Q,handleLogin:te,handleAccountSelect:(0,m.useCallback)(async e=>{H(!0),h(``),await Z(r,e)},[r]),handleDisconnect:ne,handleLogout:$}}var g=n();function _({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,m.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,g.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,g.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function v(e){let{pin:t,setPin:n,showPin:r,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:h}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,g.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,g.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>h(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,g.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,g.jsx)(l,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(u,{checked:r,onChange:()=>o(e=>!e),label:`Show PIN`})]}),c&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function y(e){let{pin:t,setPin:n,showPin:r,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,g.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,g.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,g.jsx)(l,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(`div`,{className:`pin-options`,children:(0,g.jsx)(u,{checked:r,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),c&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:c})]})]})}function b(e){let{accounts:n,loading:r,error:o,onSelect:s}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Select an account`}),(0,g.jsx)(`div`,{className:`account-picker-list`,children:n.map(e=>(0,g.jsxs)(`button`,{className:`account-picker-card`,onClick:()=>s(e.accountId),disabled:r,type:`button`,children:[(0,g.jsx)(`span`,{className:`account-picker-name`,children:e.businessName||e.accountId}),(0,g.jsx)(`span`,{className:`account-picker-role`,children:e.role}),r&&(0,g.jsx)(t,{className:`account-picker-spinner`,size:16})]},e.accountId))}),o&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:o})]})})}function x(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:o,pinError:s,setPinError:c,setAppState:u}=e,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);async function _(){h(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&c(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),c(`Could not launch browser.`)}h(!1)}async function v(){o(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),o(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}c(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&c(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),c(`Could not start auth flow.`)}o(!1)}async function y(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),c(``)}return t||d?(0,g.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,g.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,g.jsx)(`button`,{onClick:y,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,g.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,g.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,g.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,g.jsx)(`div`,{style:{marginTop:`12px`},children:(0,g.jsx)(l,{variant:`primary`,onClick:v,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,g.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,g.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsxs)(`div`,{className:`connect-logos`,children:[(0,g.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,g.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,g.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,g.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,g.jsx)(`img`,{src:a,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,g.jsx)(l,{variant:`primary`,onClick:v,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,g.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,g.jsx)(`button`,{onClick:_,disabled:p,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:p?`Launching…`:`Open browser first`}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function S({auth:e}){return e.appState===`loading`?(0,g.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,g.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,g.jsx)(x,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,g.jsx)(y,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):e.appState===`account-picker`?(0,g.jsx)(b,{accounts:e.accounts,loading:e.accountPickerLoading,error:e.pinError,onSelect:e.handleAccountSelect}):null}export{h as n,S as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,D as r,F as i,H as a,M as o,N as s,O as c,P as l,R as u,S as d,T as f,U as p,_ as m,b as h,f as g,g as ee,h as _,m as te,t as ne,y as v}from"./OperatorConversations-BJY9FZbr.js";async function y(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var re=u(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),ie=u(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),b=u(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ae=u(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),x=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),S=u(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),oe=u(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),se=u(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),C=u(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),w=u(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),T=u(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),E=e(p(),1),D=n(),O={sm:14,md:16,lg:18},k={sm:30,md:38,lg:46};function ce({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=O[t],h={...e===`send`?{width:k[t],height:k[t]}:{},...u},g=Object.keys(h).length>0;return(0,D.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,D.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,D.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,D.jsx)(n,{size:m})]}),i&&(0,D.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var A=`maxy-shell-side-px`;function le(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function j(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-le());return Math.min(Math.max(e,248),n)}function ue(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(A);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return j(t)}catch{}return 264}function de({targetSelector:e=`.platform`}){let t=(0,E.useRef)(null),[n,r]=(0,E.useState)(()=>ue()),i=(0,E.useRef)(n);(0,E.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,E.useCallback)(()=>{r(e=>{let t=j(e);return t===e?e:t})},[]);(0,E.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(j(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(A,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=j(264);r(e);try{window.localStorage.removeItem(A)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,D.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var M=a();function fe({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,E.useRef)(null),[s,c]=(0,E.useState)({position:`fixed`,visibility:`hidden`}),l=(0,E.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,E.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,E.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,M.createPortal)((0,D.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function N({action:e,disabled:t,open:n,onToggle:r,onClose:i}){let a=(0,E.useRef)(null);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{ref:a,type:`button`,className:`conv-action`,onClick:r,disabled:t,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":e.label,title:e.title,children:e.icon}),n&&(0,D.jsx)(fe,{anchorRef:a,onClose:i,className:e.panelClassName,role:`dialog`,ariaLabel:e.label,children:e.panel()})]})}function pe({actions:e,disabled:t,collapsed:n}){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),u=(0,E.useRef)(null);(0,E.useEffect)(()=>{i(null),o(!1),c(null)},[n]);let d=(0,E.useCallback)(()=>{o(!1),c(null)},[]);return n?(0,D.jsxs)(`div`,{className:`conv-actions`,children:[(0,D.jsx)(`button`,{ref:u,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>o(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`Session actions`,title:`Session actions`,children:(0,D.jsx)(l,{size:12})}),a&&(0,D.jsx)(fe,{anchorRef:u,onClose:d,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,D.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":s===e.key,disabled:t,onClick:()=>c(t=>t===e.key?null:e.key),children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]}),s===e.key&&(0,D.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),d()},children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]},e.key))})]}):(0,D.jsx)(`div`,{className:`conv-actions`,children:e.map(e=>e.panel?(0,D.jsx)(N,{action:e,disabled:t,open:r===e.key,onToggle:()=>i(t=>t===e.key?null:e.key),onClose:()=>i(null)},e.key):(0,D.jsx)(`button`,{type:`button`,className:e.danger?`conv-action conv-action-danger`:`conv-action`,onClick:e.onClick,disabled:t,"aria-busy":e.busy,"aria-label":e.label,title:e.title,children:e.icon},e.key))})}var P=`claude-opus-4-8[1m]`,F=`claude-sonnet-4-6`,I=`claude-haiku-4-5`,me={[P]:`Opus 4.8 (1M context)`,[F]:`Sonnet 4.6`,[I]:`Haiku 4.5`};function he(e){return me[e]??e}var L=[P,F,I];function R(e){return e.replace(/\[1m\]$/,``)}function ge(e){return L.find(t=>R(t)===R(e))??e}var _e=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],z=[`low`,`medium`,`high`,`xhigh`];[..._e],[...z],[...z];var ve=[P,F,I],B={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},V=_e.map(e=>({value:e,label:B[e]??e})),ye={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},H=z.map(e=>({value:e,label:ye[e]??e}));function U(e){if(e){let t=ve.find(t=>R(t)===R(e));if(t)return t}return P}function be({row:e,adminFetch:n,onError:r}){let[i,a]=(0,E.useState)(()=>U(e.model)),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(!1),f=(0,E.useRef)(!1);(0,E.useEffect)(()=>{a(U(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let t=await n(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:i,...o?{permissionMode:o}:{},...c?{effort:c}:{}})});if(!t.ok){r(`Could not reset ${e.title} (status ${t.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${t.status}`),f.current=!1,d(!1);return}let a=await t.json().catch(()=>({}));a.target?window.location.assign(a.target):(r(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){r(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Model`}),(0,D.jsx)(`select`,{"data-kind":`model`,value:i,disabled:u,onChange:e=>a(e.target.value),children:ve.map(e=>(0,D.jsx)(`option`,{value:e,children:he(e)},e))})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Mode`}),(0,D.jsxs)(`select`,{"data-kind":`mode`,value:o,disabled:u,onChange:e=>s(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),V.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Effort`}),(0,D.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(t,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}var xe=[`whatsapp`,`telegram`];function Se(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function W(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function Ce(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function we({target:e,onConfirm:t,onCancel:n}){return e?(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:`Delete this conversation?`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,D.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,D.jsx)(ce,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,D.jsx)(ce,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var G=`auth-refresh-failed`;function Te({error:e,onClose:t}){if(!e)return null;let n=e.reason===G,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:r}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,D.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ee(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,E.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,D.jsx)(`span`,{children:`Claude Code`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,D.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:p>0?W(p):`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:Se(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await Ce(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var De=`https://claude.ai/code`,Oe=200,ke=[500,1e3,1500,2e3,2500,3e3,3e3];function Ae(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${De}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function je(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Me(e){let{businessName:t,cacheKey:n,role:a,userName:l,userAvatar:u,onSelectProjects:p,onSelectPeople:m,onSelectTasks:ne,onSelectAgents:y,onCloseMobileDrawer:O,collapsed:k,selectedWhatsappId:ce,onSelectWhatsappConversation:A,initialWhatsappSurface:le=!1}=e,j=v(n),ue=(0,E.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,D.jsx)(C,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,D.jsx)(be,{row:e,adminFetch:j,onError:e=>V({message:e,failed:!0})})}),[j]),de=h.productName,M=typeof l==`string`?l:l===null?`name unavailable`:t||de,fe=(M.trim().charAt(0)||`?`).toUpperCase(),[N,P]=(0,E.useState)(le?`whatsapp`:`sessions`),[F,I]=(0,E.useState)([]),[me,he]=(0,E.useState)(!1),[L,R]=(0,E.useState)(null),[ge,_e]=(0,E.useState)(!1),[z,ve]=(0,E.useState)(`file`),[B,V]=(0,E.useState)(null),[ye,H]=(0,E.useState)(null),[U,Se]=(0,E.useState)([]),[W,Ce]=(0,E.useState)(!1),[G,Ee]=(0,E.useState)(null),[De,Me]=(0,E.useState)(!1),[K,Ie]=(0,E.useState)(!1),[q,Le]=(0,E.useState)(!1),[Re,ze]=(0,E.useState)(null),[J,Be]=(0,E.useState)([]),[Y,Ve]=(0,E.useState)(null),[He,Ue]=(0,E.useState)(new Set),[We,Ge]=(0,E.useState)(null),[Ke,qe]=(0,E.useState)(new Set),[Je,Ye]=(0,E.useState)(new Set),[Xe,Ze]=(0,E.useState)(new Set),[Qe,$e]=(0,E.useState)(null),[et,X]=(0,E.useState)(``),[tt,nt]=(0,E.useState)(!1),[Z,rt]=(0,E.useState)(!1),it=(0,E.useRef)(null),at=(0,E.useRef)(0),[ot,st]=(0,E.useState)(0);(0,E.useEffect)(()=>{let e=it.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;st(e=>Math.abs(e-t)<1?e:t)});return t.observe(e),()=>t.disconnect()},[N]);let ct=ot>0&&ot<400,[lt,ut]=(0,E.useState)([]),[dt,ft]=(0,E.useState)(!1),[pt,mt]=(0,E.useState)(null),[ht,gt]=(0,E.useState)(`whatsapp`),_t=(0,E.useCallback)(e=>{if(O(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),V({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),V({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),g(n,e.downloadPath,e.downloadRoot??`data`),V({message:`Downloading ${e.name}`,failed:!1})},[n,O]);(0,E.useEffect)(()=>{if(!B)return;let e=setTimeout(()=>V(null),2500);return()=>clearTimeout(e)},[B]);let vt=(0,E.useCallback)(async()=>{if(n){_e(!0),R(null);try{let e=await j(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);I((await e.json()).artefacts??[]),he(!0)}catch(e){let t=e instanceof Error?e.message:String(e);R(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{_e(!1)}}},[n,j]),Q=(0,E.useCallback)(async()=>{if(!n)return null;let e=++at.current;Me(!0),Ee(null);try{let t=await j(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===at.current?(Se(r),ze(n.accountId??null),Be(n.accounts??[]),Ve(e=>e??n.accountId??null),Ce(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===at.current&&Ee(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===at.current&&Me(!1)}},[n,j]),yt=(0,E.useCallback)(async()=>{if(n){mt(null);try{let e=await j(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);ut((await e.json()).conversations??[]),ft(!0)}catch(e){let t=e instanceof Error?e.message:String(e);mt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,j]);(0,E.useEffect)(()=>{!n||W||Q()},[n,W,Q]),(0,E.useEffect)(()=>{if(!n)return;let e=null;return yt(),e=setInterval(()=>{yt()},Ne),()=>{e!==null&&clearInterval(e)}},[n,yt]),(0,E.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,Pe))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let bt=(0,E.useMemo)(()=>{let e=new Map;for(let t of xe)e.set(t,[]);for(let t of lt)e.get(t.channel)?.push(t);for(let t of xe)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[lt]),xt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},St=()=>{A(null),P(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${me?F.length:0} collapsed=${k}`),vt()},$=1.5,Ct=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),vt()},wt=()=>{A(null),P(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${W?U.length:0} collapsed=${k}`),W||Q()},Tt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Et=e=>{P(`whatsapp`),gt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${bt.get(e)?.length??0} collapsed=${k}`)},Dt=(0,E.useCallback)(async e=>{if(Ke.has(e.sessionId))return;qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await j(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ae(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(O(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),H(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),H({sessionId:e.sessionId,reason:r})}finally{qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[j,O,Ke]),Ot=(0,E.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=ke.length;n++){await new Promise(e=>setTimeout(e,ke[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),kt=(0,E.useCallback)(async()=>{if(!Z){rt(!0);try{let e=await j(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(J.length>1&&Y?{targetAccountId:Y}:{})}),t=await e.json().catch(()=>({})),n=Ae(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Ot(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),H(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),H({sessionId:null,reason:t})}finally{rt(!1)}}},[j,Z,Ot,Y,J]),At=(0,E.useCallback)((e,t)=>{e.stopPropagation(),Ge(t)},[]),jt=(0,E.useCallback)(async e=>{if(!He.has(e.sessionId)){Ue(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await j(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),V({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Se(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),V({message:`Delete failed: ${n}`,failed:!0})}finally{Ue(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[j,He,Q]),Mt=(0,E.useCallback)(async(e,t)=>{if(e.stopPropagation(),!Je.has(t.sessionId)){Ye(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await j(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),V({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),V({message:`Stop failed: ${n}`,failed:!0})}finally{Ye(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[j,Je,Q]),Nt=(0,E.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Xe.has(t.sessionId)){Ze(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await j(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),V({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),V({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Ze(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[j,Xe,Q]),Pt=(0,E.useCallback)(async e=>{let t=et.trim();if(!t){V({message:`Title can’t be empty`,failed:!0});return}if(t.length>Oe){V({message:`Title too long (max ${Oe})`,failed:!0});return}nt(!0);try{let n=await j(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),V({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),$e(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),V({message:`Rename failed: ${n}`,failed:!0})}finally{nt(!1)}},[j,et,Q]);return(0,D.jsxs)(`aside`,{className:`side`,children:[(0,D.jsx)(`div`,{className:`side-new-session-row`,children:(0,D.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:kt,disabled:Z,"aria-busy":Z,children:[(0,D.jsx)(se,{size:14}),(0,D.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,D.jsxs)(`nav`,{className:`side-nav`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),O()},children:[(0,D.jsx)(T,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`People`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),y(),O()},children:[(0,D.jsx)(b,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Agents`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),p(),O()},children:[(0,D.jsx)(ae,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:d().term}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),ne(),O()},children:[(0,D.jsx)(S,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`artefacts`?` active`:``}`,onClick:St,children:[(0,D.jsx)(o,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`sessions`?` active`:``}`,onClick:wt,children:[(0,D.jsx)(x,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,D.jsx)(`span`,{className:`kbd`})]}),dt&&xe.filter(e=>bt.get(e).length>0).map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`whatsapp`&&ht===e?` active`:``}`,onClick:()=>Et(e),children:[(0,D.jsx)(_,{channel:e,size:16}),(0,D.jsx)(`span`,{className:`label`,children:xt[e]}),(0,D.jsx)(`span`,{className:`kbd`})]},e)),pt&&(0,D.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,D.jsx)(`span`,{className:`label`,children:pt})})]}),N===`artefacts`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Artefacts`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Ct,disabled:ge,children:(0,D.jsx)(r,{size:12,className:ge?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:ge?`…`:String(F.length)})]})]}),L&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:L}),me&&!L&&F.length>0&&(()=>{let e=F.filter(e=>e.kind===`agent-template`).length,t=F.length-e;return(0,D.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:F.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${z===e.key?` active`:``}`,onClick:()=>ve(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,D.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),me&&!L&&F.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),F.filter(e=>z===`all`?!0:z===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?b:o,r=je(e.updatedAt),a=e.downloadPath!==null;return(0,D.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>_t(e),disabled:!a,style:a?void 0:{cursor:`default`},title:a?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,D.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsx)(`span`,{className:`conv-name-line`,children:(0,D.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),a&&(0,D.jsx)(i,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),N===`sessions`&&(()=>{let e=J.find(e=>e.isHouse)?.accountId??Re,t=J.length>1,n=U.filter(e=>K?!0:!e.isSubagent).filter(e=>q?!0:!e.archived).filter(n=>!t||!Y?!0:(n.accountId??e)===Y),i=U.some(e=>e.isSubagent),a=U.some(e=>e.archived);return(0,D.jsxs)(`div`,{className:`side-list`,ref:it,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Sessions`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Tt,disabled:De,children:(0,D.jsx)(r,{size:12,className:De?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:De?`…`:String(n.length)})]})]}),t&&(0,D.jsxs)(`div`,{className:`side-account-switcher`,children:[(0,D.jsx)(T,{size:12,"aria-hidden":`true`}),(0,D.jsx)(`select`,{"aria-label":`Active account`,title:`The active account. A new session spawns under it, and the list below is scoped to it.`,value:Y??``,onChange:e=>Ve(e.target.value||null),children:J.map(e=>(0,D.jsxs)(`option`,{value:e.accountId,children:[e.businessName||(e.isHouse?`House`:`Client`),` · `,e.accountId.slice(0,8)]},e.accountId))})]}),Re&&(0,D.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,D.jsx)(`code`,{children:Re})}),(i||a)&&(0,D.jsxs)(`div`,{className:`artefact-filter-chips`,children:[i&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ie(e=>!e),title:K?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),a&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${q?` active`:``}`,"aria-pressed":q,onClick:()=>Le(e=>!e),title:q?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),G&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:G}),W&&!G&&n.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),n.map(e=>{let t=je(e.startedAt),n=Ke.has(e.sessionId),r=He.has(e.sessionId),i=Je.has(e.sessionId),a=Xe.has(e.sessionId),o=n||r||i||a,l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,D.jsx)(s,{size:12}),busy:n,onClick:()=>{Dt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,D.jsx)(oe,{size:12}),onClick:()=>{window.location.assign(`/chat?session=${e.sessionId}`)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,D.jsx)(w,{size:12}),busy:i,onClick:t=>{Mt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,D.jsx)(re,{size:12}),busy:a,onClick:t=>{Nt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,D.jsx)(ie,{size:12}),busy:a,onClick:t=>{Nt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,D.jsx)(c,{size:12}),busy:tt&&Qe===e.sessionId,onClick:t=>{t.stopPropagation(),$e(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,D.jsx)(f,{size:12}),danger:!0,busy:r,onClick:t=>{At(t,e)}},ue({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,D.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,D.jsxs)(`div`,{className:`conv-main-static`,children:[(0,D.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,D.jsx)(ee,{channel:e.channel,size:13}),Qe===e.sessionId?(0,D.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:et,disabled:tt,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Pt(e)):t.key===`Escape`&&(t.preventDefault(),$e(null),X(``))},onBlur:()=>{Qe===e.sessionId&&!tt&&($e(null),X(``))}}):(0,D.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,D.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,D.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,D.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,D.jsx)(pe,{actions:l,disabled:o,collapsed:ct})]},e.sessionId)})]})})(),N===`whatsapp`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:xt[ht]}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{yt()},children:(0,D.jsx)(r,{size:12})}),(0,D.jsx)(`span`,{children:String(bt.get(ht).length)})]})]}),bt.get(ht).map(e=>{let t=je(e.lastMessageAt);return(0,D.jsxs)(`div`,{className:`conv conv-with-actions${ce===e.sessionId?` active`:``}`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{A(e),O()},title:e.title,children:[(0,D.jsx)(_,{channel:e.channel,size:14}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[(0,D.jsx)(`span`,{className:`conv-name`,children:te(e)}),e.role===`public`&&(0,D.jsx)(`span`,{className:`conv-tag conv-tag-public`,children:`Public`})]}),t&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),(0,D.jsx)(pe,{actions:[ue({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1,collapsed:ct})]},e.sessionId)})]}),(0,D.jsx)(Fe,{}),(0,D.jsxs)(`div`,{className:`side-foot`,children:[(0,D.jsx)(`div`,{className:`avatar`,children:u?(0,D.jsx)(`img`,{src:u,alt:M}):fe}),(0,D.jsxs)(`div`,{className:`who`,children:[(0,D.jsx)(`span`,{className:`name`,children:M}),(0,D.jsx)(`span`,{className:`role`,children:a??`operator`})]})]}),B&&(0,D.jsx)(`div`,{className:`copy-toast${B.failed?` copy-toast-failed`:``}`,role:`status`,children:B.message}),(0,D.jsx)(Te,{error:ye,onClose:()=>H(null)}),(0,D.jsx)(we,{target:We,onCancel:()=>Ge(null),onConfirm:()=>{let e=We;Ge(null),e&&jt(e)}})]})}var K=5e3,Ne=3e4,Pe=3e4;function Fe(){let[e,t]=(0,E.useState)(null);if((0,E.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},K))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,D.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var Ie=`admin-sidebar-collapsed`,q=`admin-sidebar-drawer-open`;function Le(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ie)===`1`}catch{return!1}}function Re(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ie,`1`):window.sessionStorage.removeItem(Ie)}catch{}}function ze(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}}function J(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(q,`1`):window.sessionStorage.removeItem(q)}catch{}}var Be=720;function Y(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function Ve(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`projectDir`);return!r||!i?null:{sessionId:r,projectDir:i,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`admin`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null}}function He(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function Ue(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,userName:s,userAvatar:c,role:l,children:u,footer:f}=e,[p,h]=(0,E.useState)(()=>Le()),[g,ee]=(0,E.useState)(()=>ze()),[_,te]=(0,E.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${Be}px)`).matches),[v,y]=(0,E.useState)(()=>typeof window>`u`?null:Ve(window.location.pathname,window.location.search)),[re]=(0,E.useState)(()=>v!==null);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${Be}px)`),t=e=>te(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ie=(0,E.useCallback)(e=>{Re(e),h(e)},[]),b=(0,E.useCallback)(e=>{J(e),ee(e)},[]);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${p} drawer=${g}`)},[]),(0,E.useEffect)(()=>{typeof window>`u`||!v||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${v.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]);let ae=(0,E.useCallback)(e=>{if(e===null){y(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Y(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?y(e):window.location.href=n.href},[]),x=_?g:!p,S=(0,E.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Be}px)`).matches){let e=g;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),b(!e)}else{let e=p;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),ie(!e)}},[p,g,ie,b]),oe=(0,E.useCallback)(e=>{let t=He(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),[se,C]=(0,E.useState)(`chat`),[w,T]=(0,E.useState)([]);(0,E.useEffect)(()=>{if(r!==`operator`||!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||T(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[r,t]);let O=(0,E.useMemo)(()=>[...new Set(w.map(e=>e.channel))],[w]),k={collapsed:p,mobileDrawerOpen:g,sidebarOpen:x,onToggleSidebar:S,setMobileDrawerOpen:b,selectedWhatsapp:v,onClearWhatsapp:()=>y(null)};return r===`operator`?(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(m,{businessName:n,variant:r,onNavigate:oe,conversationsCount:w.length,conversationsChannels:O,onOpenConversations:()=>C(`conversations`),onToggleSidebar:S,sidebarOpen:x,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t}),(0,D.jsx)(`div`,{className:`platform platform-operator`,children:se===`conversations`?(0,D.jsx)(ne,{conversations:w,sessionKey:t??``,onBack:()=>C(`chat`)}):typeof u==`function`?u(k):u}),f]}):(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(m,{businessName:n,variant:r,onNavigate:oe,onToggleSidebar:S,sidebarOpen:x,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t}),(0,D.jsxs)(`div`,{className:`platform${g?` menu-open`:``}${p?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,D.jsx)(Me,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,onSelectProjects:()=>{window.location.href=`/graph?label=${d().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>b(!1),collapsed:p,mobileDrawerOpen:g,selectedWhatsappId:v?.sessionId??null,onSelectWhatsappConversation:ae,initialWhatsappSurface:re}),!_&&(0,D.jsx)(de,{}),typeof u==`function`?u(k):u]}),g&&(0,D.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>b(!1)}),f]})}export{y as _,I as a,ge as c,T as d,w as f,b as g,S as h,Ce as i,he as l,se as m,Ae as n,P as o,C as p,Ee as r,F as s,Ue as t,ce as u};
|
|
1
|
+
import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,D as r,F as i,H as a,M as o,N as s,O as c,P as l,R as u,S as d,T as f,U as p,_ as m,b as h,f as g,g as ee,h as _,m as te,t as ne,y as v}from"./OperatorConversations-jqaPCHwB.js";async function y(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var re=u(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),ie=u(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),b=u(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ae=u(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),x=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),S=u(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),oe=u(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),se=u(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),C=u(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),w=u(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),T=u(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),E=e(p(),1),D=n(),O={sm:14,md:16,lg:18},k={sm:30,md:38,lg:46};function ce({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=O[t],h={...e===`send`?{width:k[t],height:k[t]}:{},...u},g=Object.keys(h).length>0;return(0,D.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,D.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,D.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,D.jsx)(n,{size:m})]}),i&&(0,D.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var A=`maxy-shell-side-px`;function le(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function j(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-le());return Math.min(Math.max(e,248),n)}function ue(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(A);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return j(t)}catch{}return 264}function de({targetSelector:e=`.platform`}){let t=(0,E.useRef)(null),[n,r]=(0,E.useState)(()=>ue()),i=(0,E.useRef)(n);(0,E.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,E.useCallback)(()=>{r(e=>{let t=j(e);return t===e?e:t})},[]);(0,E.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(j(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(A,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=j(264);r(e);try{window.localStorage.removeItem(A)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,D.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var M=a();function fe({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,E.useRef)(null),[s,c]=(0,E.useState)({position:`fixed`,visibility:`hidden`}),l=(0,E.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,E.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,E.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,M.createPortal)((0,D.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function N({action:e,disabled:t,open:n,onToggle:r,onClose:i}){let a=(0,E.useRef)(null);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{ref:a,type:`button`,className:`conv-action`,onClick:r,disabled:t,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":e.label,title:e.title,children:e.icon}),n&&(0,D.jsx)(fe,{anchorRef:a,onClose:i,className:e.panelClassName,role:`dialog`,ariaLabel:e.label,children:e.panel()})]})}function pe({actions:e,disabled:t,collapsed:n}){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),u=(0,E.useRef)(null);(0,E.useEffect)(()=>{i(null),o(!1),c(null)},[n]);let d=(0,E.useCallback)(()=>{o(!1),c(null)},[]);return n?(0,D.jsxs)(`div`,{className:`conv-actions`,children:[(0,D.jsx)(`button`,{ref:u,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>o(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`Session actions`,title:`Session actions`,children:(0,D.jsx)(l,{size:12})}),a&&(0,D.jsx)(fe,{anchorRef:u,onClose:d,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,D.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":s===e.key,disabled:t,onClick:()=>c(t=>t===e.key?null:e.key),children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]}),s===e.key&&(0,D.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),d()},children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]},e.key))})]}):(0,D.jsx)(`div`,{className:`conv-actions`,children:e.map(e=>e.panel?(0,D.jsx)(N,{action:e,disabled:t,open:r===e.key,onToggle:()=>i(t=>t===e.key?null:e.key),onClose:()=>i(null)},e.key):(0,D.jsx)(`button`,{type:`button`,className:e.danger?`conv-action conv-action-danger`:`conv-action`,onClick:e.onClick,disabled:t,"aria-busy":e.busy,"aria-label":e.label,title:e.title,children:e.icon},e.key))})}var P=`claude-opus-4-8[1m]`,F=`claude-sonnet-4-6`,I=`claude-haiku-4-5`,me={[P]:`Opus 4.8 (1M context)`,[F]:`Sonnet 4.6`,[I]:`Haiku 4.5`};function he(e){return me[e]??e}var L=[P,F,I];function R(e){return e.replace(/\[1m\]$/,``)}function ge(e){return L.find(t=>R(t)===R(e))??e}var _e=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],z=[`low`,`medium`,`high`,`xhigh`];[..._e],[...z],[...z];var ve=[P,F,I],B={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},V=_e.map(e=>({value:e,label:B[e]??e})),ye={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},H=z.map(e=>({value:e,label:ye[e]??e}));function U(e){if(e){let t=ve.find(t=>R(t)===R(e));if(t)return t}return P}function be({row:e,adminFetch:n,onError:r}){let[i,a]=(0,E.useState)(()=>U(e.model)),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(!1),f=(0,E.useRef)(!1);(0,E.useEffect)(()=>{a(U(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let t=await n(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:i,...o?{permissionMode:o}:{},...c?{effort:c}:{}})});if(!t.ok){r(`Could not reset ${e.title} (status ${t.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${t.status}`),f.current=!1,d(!1);return}let a=await t.json().catch(()=>({}));a.target?window.location.assign(a.target):(r(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){r(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Model`}),(0,D.jsx)(`select`,{"data-kind":`model`,value:i,disabled:u,onChange:e=>a(e.target.value),children:ve.map(e=>(0,D.jsx)(`option`,{value:e,children:he(e)},e))})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Mode`}),(0,D.jsxs)(`select`,{"data-kind":`mode`,value:o,disabled:u,onChange:e=>s(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),V.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Effort`}),(0,D.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(t,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}var xe=[`whatsapp`,`telegram`];function Se(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function W(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function Ce(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function we({target:e,onConfirm:t,onCancel:n}){return e?(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:`Delete this conversation?`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,D.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,D.jsx)(ce,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,D.jsx)(ce,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var G=`auth-refresh-failed`;function Te({error:e,onClose:t}){if(!e)return null;let n=e.reason===G,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:r}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,D.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ee(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,E.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,D.jsx)(`span`,{children:`Claude Code`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,D.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:p>0?W(p):`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:Se(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await Ce(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var De=`https://claude.ai/code`,Oe=200,ke=[500,1e3,1500,2e3,2500,3e3,3e3];function Ae(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${De}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function je(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Me(e){let{businessName:t,cacheKey:n,role:a,userName:l,userAvatar:u,onSelectProjects:p,onSelectPeople:m,onSelectTasks:ne,onSelectAgents:y,onCloseMobileDrawer:O,collapsed:k,selectedWhatsappId:ce,onSelectWhatsappConversation:A,initialWhatsappSurface:le=!1}=e,j=v(n),ue=(0,E.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,D.jsx)(C,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,D.jsx)(be,{row:e,adminFetch:j,onError:e=>V({message:e,failed:!0})})}),[j]),de=h.productName,M=typeof l==`string`?l:l===null?`name unavailable`:t||de,fe=(M.trim().charAt(0)||`?`).toUpperCase(),[N,P]=(0,E.useState)(le?`whatsapp`:`sessions`),[F,I]=(0,E.useState)([]),[me,he]=(0,E.useState)(!1),[L,R]=(0,E.useState)(null),[ge,_e]=(0,E.useState)(!1),[z,ve]=(0,E.useState)(`file`),[B,V]=(0,E.useState)(null),[ye,H]=(0,E.useState)(null),[U,Se]=(0,E.useState)([]),[W,Ce]=(0,E.useState)(!1),[G,Ee]=(0,E.useState)(null),[De,Me]=(0,E.useState)(!1),[K,Ie]=(0,E.useState)(!1),[q,Le]=(0,E.useState)(!1),[Re,ze]=(0,E.useState)(null),[J,Be]=(0,E.useState)([]),[Y,Ve]=(0,E.useState)(null),[He,Ue]=(0,E.useState)(new Set),[We,Ge]=(0,E.useState)(null),[Ke,qe]=(0,E.useState)(new Set),[Je,Ye]=(0,E.useState)(new Set),[Xe,Ze]=(0,E.useState)(new Set),[Qe,$e]=(0,E.useState)(null),[et,X]=(0,E.useState)(``),[tt,nt]=(0,E.useState)(!1),[Z,rt]=(0,E.useState)(!1),it=(0,E.useRef)(null),at=(0,E.useRef)(0),[ot,st]=(0,E.useState)(0);(0,E.useEffect)(()=>{let e=it.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;st(e=>Math.abs(e-t)<1?e:t)});return t.observe(e),()=>t.disconnect()},[N]);let ct=ot>0&&ot<400,[lt,ut]=(0,E.useState)([]),[dt,ft]=(0,E.useState)(!1),[pt,mt]=(0,E.useState)(null),[ht,gt]=(0,E.useState)(`whatsapp`),_t=(0,E.useCallback)(e=>{if(O(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),V({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),V({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),g(n,e.downloadPath,e.downloadRoot??`data`),V({message:`Downloading ${e.name}`,failed:!1})},[n,O]);(0,E.useEffect)(()=>{if(!B)return;let e=setTimeout(()=>V(null),2500);return()=>clearTimeout(e)},[B]);let vt=(0,E.useCallback)(async()=>{if(n){_e(!0),R(null);try{let e=await j(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);I((await e.json()).artefacts??[]),he(!0)}catch(e){let t=e instanceof Error?e.message:String(e);R(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{_e(!1)}}},[n,j]),Q=(0,E.useCallback)(async()=>{if(!n)return null;let e=++at.current;Me(!0),Ee(null);try{let t=await j(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===at.current?(Se(r),ze(n.accountId??null),Be(n.accounts??[]),Ve(e=>e??n.accountId??null),Ce(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===at.current&&Ee(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===at.current&&Me(!1)}},[n,j]),yt=(0,E.useCallback)(async()=>{if(n){mt(null);try{let e=await j(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);ut((await e.json()).conversations??[]),ft(!0)}catch(e){let t=e instanceof Error?e.message:String(e);mt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,j]);(0,E.useEffect)(()=>{!n||W||Q()},[n,W,Q]),(0,E.useEffect)(()=>{if(!n)return;let e=null;return yt(),e=setInterval(()=>{yt()},Ne),()=>{e!==null&&clearInterval(e)}},[n,yt]),(0,E.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,Pe))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let bt=(0,E.useMemo)(()=>{let e=new Map;for(let t of xe)e.set(t,[]);for(let t of lt)e.get(t.channel)?.push(t);for(let t of xe)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[lt]),xt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},St=()=>{A(null),P(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${me?F.length:0} collapsed=${k}`),vt()},$=1.5,Ct=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),vt()},wt=()=>{A(null),P(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${W?U.length:0} collapsed=${k}`),W||Q()},Tt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Et=e=>{P(`whatsapp`),gt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${bt.get(e)?.length??0} collapsed=${k}`)},Dt=(0,E.useCallback)(async e=>{if(Ke.has(e.sessionId))return;qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await j(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ae(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(O(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),H(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),H({sessionId:e.sessionId,reason:r})}finally{qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[j,O,Ke]),Ot=(0,E.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=ke.length;n++){await new Promise(e=>setTimeout(e,ke[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),kt=(0,E.useCallback)(async()=>{if(!Z){rt(!0);try{let e=await j(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(J.length>1&&Y?{targetAccountId:Y}:{})}),t=await e.json().catch(()=>({})),n=Ae(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Ot(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),H(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),H({sessionId:null,reason:t})}finally{rt(!1)}}},[j,Z,Ot,Y,J]),At=(0,E.useCallback)((e,t)=>{e.stopPropagation(),Ge(t)},[]),jt=(0,E.useCallback)(async e=>{if(!He.has(e.sessionId)){Ue(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await j(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),V({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Se(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),V({message:`Delete failed: ${n}`,failed:!0})}finally{Ue(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[j,He,Q]),Mt=(0,E.useCallback)(async(e,t)=>{if(e.stopPropagation(),!Je.has(t.sessionId)){Ye(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await j(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),V({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),V({message:`Stop failed: ${n}`,failed:!0})}finally{Ye(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[j,Je,Q]),Nt=(0,E.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Xe.has(t.sessionId)){Ze(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await j(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),V({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),V({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Ze(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[j,Xe,Q]),Pt=(0,E.useCallback)(async e=>{let t=et.trim();if(!t){V({message:`Title can’t be empty`,failed:!0});return}if(t.length>Oe){V({message:`Title too long (max ${Oe})`,failed:!0});return}nt(!0);try{let n=await j(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),V({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),$e(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),V({message:`Rename failed: ${n}`,failed:!0})}finally{nt(!1)}},[j,et,Q]);return(0,D.jsxs)(`aside`,{className:`side`,children:[(0,D.jsx)(`div`,{className:`side-new-session-row`,children:(0,D.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:kt,disabled:Z,"aria-busy":Z,children:[(0,D.jsx)(se,{size:14}),(0,D.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,D.jsxs)(`nav`,{className:`side-nav`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),O()},children:[(0,D.jsx)(T,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`People`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),y(),O()},children:[(0,D.jsx)(b,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Agents`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),p(),O()},children:[(0,D.jsx)(ae,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:d().term}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),ne(),O()},children:[(0,D.jsx)(S,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`artefacts`?` active`:``}`,onClick:St,children:[(0,D.jsx)(o,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`sessions`?` active`:``}`,onClick:wt,children:[(0,D.jsx)(x,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,D.jsx)(`span`,{className:`kbd`})]}),dt&&xe.filter(e=>bt.get(e).length>0).map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`whatsapp`&&ht===e?` active`:``}`,onClick:()=>Et(e),children:[(0,D.jsx)(_,{channel:e,size:16}),(0,D.jsx)(`span`,{className:`label`,children:xt[e]}),(0,D.jsx)(`span`,{className:`kbd`})]},e)),pt&&(0,D.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,D.jsx)(`span`,{className:`label`,children:pt})})]}),N===`artefacts`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Artefacts`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Ct,disabled:ge,children:(0,D.jsx)(r,{size:12,className:ge?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:ge?`…`:String(F.length)})]})]}),L&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:L}),me&&!L&&F.length>0&&(()=>{let e=F.filter(e=>e.kind===`agent-template`).length,t=F.length-e;return(0,D.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:F.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${z===e.key?` active`:``}`,onClick:()=>ve(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,D.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),me&&!L&&F.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),F.filter(e=>z===`all`?!0:z===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?b:o,r=je(e.updatedAt),a=e.downloadPath!==null;return(0,D.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>_t(e),disabled:!a,style:a?void 0:{cursor:`default`},title:a?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,D.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsx)(`span`,{className:`conv-name-line`,children:(0,D.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),a&&(0,D.jsx)(i,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),N===`sessions`&&(()=>{let e=J.find(e=>e.isHouse)?.accountId??Re,t=J.length>1,n=U.filter(e=>K?!0:!e.isSubagent).filter(e=>q?!0:!e.archived).filter(n=>!t||!Y?!0:(n.accountId??e)===Y),i=U.some(e=>e.isSubagent),a=U.some(e=>e.archived);return(0,D.jsxs)(`div`,{className:`side-list`,ref:it,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Sessions`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Tt,disabled:De,children:(0,D.jsx)(r,{size:12,className:De?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:De?`…`:String(n.length)})]})]}),t&&(0,D.jsxs)(`div`,{className:`side-account-switcher`,children:[(0,D.jsx)(T,{size:12,"aria-hidden":`true`}),(0,D.jsx)(`select`,{"aria-label":`Active account`,title:`The active account. A new session spawns under it, and the list below is scoped to it.`,value:Y??``,onChange:e=>Ve(e.target.value||null),children:J.map(e=>(0,D.jsxs)(`option`,{value:e.accountId,children:[e.businessName||(e.isHouse?`House`:`Client`),` · `,e.accountId.slice(0,8)]},e.accountId))})]}),Re&&(0,D.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,D.jsx)(`code`,{children:Re})}),(i||a)&&(0,D.jsxs)(`div`,{className:`artefact-filter-chips`,children:[i&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ie(e=>!e),title:K?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),a&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${q?` active`:``}`,"aria-pressed":q,onClick:()=>Le(e=>!e),title:q?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),G&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:G}),W&&!G&&n.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),n.map(e=>{let t=je(e.startedAt),n=Ke.has(e.sessionId),r=He.has(e.sessionId),i=Je.has(e.sessionId),a=Xe.has(e.sessionId),o=n||r||i||a,l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,D.jsx)(s,{size:12}),busy:n,onClick:()=>{Dt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,D.jsx)(oe,{size:12}),onClick:()=>{window.location.assign(`/chat?session=${e.sessionId}`)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,D.jsx)(w,{size:12}),busy:i,onClick:t=>{Mt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,D.jsx)(re,{size:12}),busy:a,onClick:t=>{Nt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,D.jsx)(ie,{size:12}),busy:a,onClick:t=>{Nt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,D.jsx)(c,{size:12}),busy:tt&&Qe===e.sessionId,onClick:t=>{t.stopPropagation(),$e(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,D.jsx)(f,{size:12}),danger:!0,busy:r,onClick:t=>{At(t,e)}},ue({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,D.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,D.jsxs)(`div`,{className:`conv-main-static`,children:[(0,D.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,D.jsx)(ee,{channel:e.channel,size:13}),Qe===e.sessionId?(0,D.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:et,disabled:tt,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Pt(e)):t.key===`Escape`&&(t.preventDefault(),$e(null),X(``))},onBlur:()=>{Qe===e.sessionId&&!tt&&($e(null),X(``))}}):(0,D.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,D.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,D.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,D.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,D.jsx)(pe,{actions:l,disabled:o,collapsed:ct})]},e.sessionId)})]})})(),N===`whatsapp`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:xt[ht]}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{yt()},children:(0,D.jsx)(r,{size:12})}),(0,D.jsx)(`span`,{children:String(bt.get(ht).length)})]})]}),bt.get(ht).map(e=>{let t=je(e.lastMessageAt);return(0,D.jsxs)(`div`,{className:`conv conv-with-actions${ce===e.sessionId?` active`:``}`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{A(e),O()},title:e.title,children:[(0,D.jsx)(_,{channel:e.channel,size:14}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[(0,D.jsx)(`span`,{className:`conv-name`,children:te(e)}),e.role===`public`&&(0,D.jsx)(`span`,{className:`conv-tag conv-tag-public`,children:`Public`})]}),t&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),(0,D.jsx)(pe,{actions:[ue({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1,collapsed:ct})]},e.sessionId)})]}),(0,D.jsx)(Fe,{}),(0,D.jsxs)(`div`,{className:`side-foot`,children:[(0,D.jsx)(`div`,{className:`avatar`,children:u?(0,D.jsx)(`img`,{src:u,alt:M}):fe}),(0,D.jsxs)(`div`,{className:`who`,children:[(0,D.jsx)(`span`,{className:`name`,children:M}),(0,D.jsx)(`span`,{className:`role`,children:a??`operator`})]})]}),B&&(0,D.jsx)(`div`,{className:`copy-toast${B.failed?` copy-toast-failed`:``}`,role:`status`,children:B.message}),(0,D.jsx)(Te,{error:ye,onClose:()=>H(null)}),(0,D.jsx)(we,{target:We,onCancel:()=>Ge(null),onConfirm:()=>{let e=We;Ge(null),e&&jt(e)}})]})}var K=5e3,Ne=3e4,Pe=3e4;function Fe(){let[e,t]=(0,E.useState)(null);if((0,E.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},K))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,D.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var Ie=`admin-sidebar-collapsed`,q=`admin-sidebar-drawer-open`;function Le(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ie)===`1`}catch{return!1}}function Re(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ie,`1`):window.sessionStorage.removeItem(Ie)}catch{}}function ze(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}}function J(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(q,`1`):window.sessionStorage.removeItem(q)}catch{}}var Be=720;function Y(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function Ve(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`projectDir`);return!r||!i?null:{sessionId:r,projectDir:i,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`admin`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null}}function He(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function Ue(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,userName:s,userAvatar:c,role:l,children:u,footer:f}=e,[p,h]=(0,E.useState)(()=>Le()),[g,ee]=(0,E.useState)(()=>ze()),[_,te]=(0,E.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${Be}px)`).matches),[v,y]=(0,E.useState)(()=>typeof window>`u`?null:Ve(window.location.pathname,window.location.search)),[re]=(0,E.useState)(()=>v!==null);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${Be}px)`),t=e=>te(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ie=(0,E.useCallback)(e=>{Re(e),h(e)},[]),b=(0,E.useCallback)(e=>{J(e),ee(e)},[]);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${p} drawer=${g}`)},[]),(0,E.useEffect)(()=>{typeof window>`u`||!v||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${v.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]);let ae=(0,E.useCallback)(e=>{if(e===null){y(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Y(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?y(e):window.location.href=n.href},[]),x=_?g:!p,S=(0,E.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Be}px)`).matches){let e=g;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),b(!e)}else{let e=p;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),ie(!e)}},[p,g,ie,b]),oe=(0,E.useCallback)(e=>{let t=He(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),[se,C]=(0,E.useState)(`chat`),[w,T]=(0,E.useState)([]);(0,E.useEffect)(()=>{if(r!==`operator`||!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||T(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[r,t]);let O=(0,E.useMemo)(()=>[...new Set(w.map(e=>e.channel))],[w]),k={collapsed:p,mobileDrawerOpen:g,sidebarOpen:x,onToggleSidebar:S,setMobileDrawerOpen:b,selectedWhatsapp:v,onClearWhatsapp:()=>y(null)};return r===`operator`?(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(m,{businessName:n,variant:r,onNavigate:oe,conversationsCount:w.length,conversationsChannels:O,onOpenConversations:()=>C(`conversations`),onToggleSidebar:S,sidebarOpen:x,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t}),(0,D.jsx)(`div`,{className:`platform platform-operator`,children:se===`conversations`?(0,D.jsx)(ne,{conversations:w,sessionKey:t??``,onBack:()=>C(`chat`)}):typeof u==`function`?u(k):u}),f]}):(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(m,{businessName:n,variant:r,onNavigate:oe,onToggleSidebar:S,sidebarOpen:x,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t}),(0,D.jsxs)(`div`,{className:`platform${g?` menu-open`:``}${p?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,D.jsx)(Me,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,onSelectProjects:()=>{window.location.href=`/graph?label=${d().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>b(!1),collapsed:p,mobileDrawerOpen:g,selectedWhatsappId:v?.sessionId??null,onSelectWhatsappConversation:ae,initialWhatsappSurface:re}),!_&&(0,D.jsx)(de,{}),typeof u==`function`?u(k):u]}),g&&(0,D.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>b(!1)}),f]})}export{y as _,I as a,ge as c,T as d,w as f,b as g,S as h,Ce as i,he as l,se as m,Ae as n,P as o,C as p,Ee as r,F as s,Ue as t,ce as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e}from"./OperatorConversations-
|
|
1
|
+
import{C as e}from"./OperatorConversations-jqaPCHwB.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
|