local-operator-ui 0.42.4 → 0.42.5

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.
Files changed (21) hide show
  1. package/out/main/index.js +4 -0
  2. package/out/renderer/assets/{agent-details-page-BWSojjKJ.js → agent-details-page-sxSaHR4K.js} +1 -1
  3. package/out/renderer/assets/{agent-hub-page-aubDNr6m.js → agent-hub-page-2B3Cz0L7.js} +1 -1
  4. package/out/renderer/assets/{agents-page-DeOCoJow.js → agents-page-SWONT2Y-.js} +3 -3
  5. package/out/renderer/assets/{browser-page-DUwB_Shx.js → browser-page-CEC2xvua.js} +1 -1
  6. package/out/renderer/assets/{browser-webauthn-prompt-D90b-ibP.js → browser-webauthn-prompt-DGYOEUVY.js} +1 -1
  7. package/out/renderer/assets/{index-wz2cjW5P.js → index-CRQJfecC.js} +184 -184
  8. package/out/renderer/assets/{legacy-agents-page-zQ2FJ-pr.js → legacy-agents-page-WYJ6UHsm.js} +1 -1
  9. package/out/renderer/assets/{library-page-CB9dDvmn.js → library-page-DQ0q6JRi.js} +3 -3
  10. package/out/renderer/assets/{mesh-page-SxvMrMpp.js → mesh-page-DO-LVvVi.js} +1 -1
  11. package/out/renderer/assets/{org-access-DVt3GFMX.js → org-access-C90qeM0I.js} +1 -1
  12. package/out/renderer/assets/{projects-page-ACh1mgoo.js → projects-page-BQAyETlA.js} +1 -1
  13. package/out/renderer/assets/{publication-validation-D2z_zWQT.js → publication-validation-RgDLfmCM.js} +1 -1
  14. package/out/renderer/assets/{radient-auth-buttons-Di1zLV23.js → radient-auth-buttons-BmW-BaEj.js} +1 -1
  15. package/out/renderer/assets/{schedules-page-BA4nO5Tw.js → schedules-page-xJSXx04Y.js} +1 -1
  16. package/out/renderer/assets/{settings-page-D5KhLQHE.js → settings-page-CqTYuMWP.js} +1 -1
  17. package/out/renderer/assets/{smartart-58otsUWh.js → smartart-BGclmjFB.js} +1 -1
  18. package/out/renderer/assets/{team-bridge-page-CJdJd9cs.js → team-bridge-page-DrXABFbC.js} +1 -1
  19. package/out/renderer/assets/{use-download-agent-mutation-BAzM19BL.js → use-download-agent-mutation-n0p2QCHH.js} +1 -1
  20. package/out/renderer/index.html +1 -1
  21. package/package.json +1 -1
@@ -1 +1 @@
1
- import{r as x,j as e,c as L}from"./index-DhltrflG.js";import{C as is,E as ee,F as rs,R as ls,G as pe,H as qe,I as Be,J as Ye,K as Ge,a as os,L as _e,q as ke,N as ds}from"./path-utils-BkJr3--b.js";import{P as cs}from"./page-header-B3bOo0UX.js";import{u as F,B as U,A as fe,p as us,h as oe,q as ms,r as hs,s as ps,t as xs,v as Ee,w as De,k as Re}from"./error-boundary-CqZRoe9S.js";import{t as a}from"./messages-Cq_3N7VC.js";import{C as he,D as fs,E as gs,F as bs,G as vs,I as _s,J as ks,K as ws,L as js,M as ys,N as Ns,O as Is,Q as Cs,R as Ss,T as Ne,U as Ms,V as Es,W as Ie,X as Ue,Y as Ke,Z as Ds,_ as xe,$ as we,a0 as Rs,a1 as As,a2 as ge,a3 as Ae,a4 as Ls,a5 as Ps,a6 as je,a7 as $s,a8 as Ve,a9 as be,aa as Ts,ab as Xe,ac as Os,ad as zs,ae as Hs,af as Ws,ag as Fs,ah as qs,ai as Bs,aj as Ys,ak as Gs,al as Us,am as Ks,an as Vs,ao as Xs,ap as Zs,aq as Js,ar as Qs,as as et,at as st,au as tt,av as me,aw as nt}from"./index-wz2cjW5P.js";import{ax as Ce,ay as Se,az as at,aA as Ze}from"./conversation-input-sync-BXv32NfB.js";import"./console-mirror-BiiClM8r.js";function it(s){return s==="failed"?"text-danger":he(s)?"text-ink-muted":"text-ink-dim"}function rt(s){return s==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function lt(s){switch(s){case"requested":return[{term:a("ui.mesh.mesh_approvals_tray.signing"),text:a("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:a("ui.mesh.mesh_approvals_tray.next"),text:a("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:a("ui.mesh.mesh_approvals_tray.after_a_stop"),text:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const ot=({rows:s,error:t,pending:n,refusal:l,onDecide:m,onRetry:u,nowSeconds:g,networkNames:o})=>{F();const _=n!==null,v=x.useMemo(()=>s.filter(p=>he(p.state)),[s]),j=x.useMemo(()=>s.filter(p=>!he(p.state)),[s]),[D,N]=x.useState(!1),d=x.useRef(null),c=x.useRef(null),h=x.useRef(null),I=(p,S)=>{S==="deny"&&v.some(P=>P.approvalId===p&&P.kind==="credential")&&(h.current={id:p,origin:document.activeElement,sawPending:!1}),m(p,S)};x.useLayoutEffect(()=>{const p=h.current;if(!p)return;if(n?.approvalId===p.id&&(p.sawPending=!0),l?.approvalId===p.id){h.current=null;return}const S=s.find(C=>C.approvalId===p.id);if(S?.state==="requested"){!n&&p.sawPending&&(h.current=null);return}if(S?.state==="denied"&&n||(h.current=null,S?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==p.origin))return;(v.length?d.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):c.current?.querySelector("button"))?.focus({preventScroll:!0})},[s,n,l,v.length]);const y=j.some(p=>p.state==="failed"),E=j.filter(p=>p.state==="failed").length,f=l!==null&&s.some(p=>p.approvalId===l.approvalId&&(he(p.state)||D));return v.length===0&&j.length===0&&!t&&!l?null:e.jsxs("section",{ref:d,"aria-label":a("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(fs,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),e.jsx("h2",{className:"text-body-sm text-ink",children:a("ui.mesh.mesh_approvals_tray.approvals")}),v.length>0&&e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:v.length})})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:t}),e.jsx(U,{variant:"secondary",size:"sm",onClick:u,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),v.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:v.map(p=>e.jsx(Le,{row:p,pending:n?.approvalId===p.approvalId?n:null,busy:_,refusal:l?.approvalId===p.approvalId?l:null,onDecide:I,nowSeconds:g,networkNames:o},p.approvalId))}),l&&!f&&e.jsx(Je,{refusal:l}),j.length>0&&e.jsx("div",{ref:c,children:e.jsx(Ce,{open:D,onOpenChange:N,chevronClassName:"text-ink-dim",className:L(v.length>0&&"border-hairline border-t pt-3"),summary:e.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[a("ui.mesh.mesh_approvals_tray.settled_approvals"),e.jsxs("span",{className:"text-ink-dim",children:["(",j.length,")"]}),y&&e.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),E>0&&e.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:E})})]}),children:e.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:j.map(p=>e.jsx(Le,{row:p,pending:n?.approvalId===p.approvalId?n:null,busy:_,refusal:l?.approvalId===p.approvalId?l:null,onDecide:I,nowSeconds:g,networkNames:o},p.approvalId))})})})]})},Le=({row:s,pending:t,busy:n,refusal:l,onDecide:m,nowSeconds:u,networkNames:g})=>{F();const o=he(s.state),_=gs(s),v=bs(s,g),j=vs(s,g),D=_s(s),N=ks(s),d=ws(s),c=js(s.expiresAt,u),h=s.kind==="credential"||s.kind==="unknown",I=h||s.canApproveHere===!1,y=I?[]:lt(s.state),E=ys(s),f=Ns(s.state);return e.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:L("text-meta",it(s.state)),children:s.kind==="credential"&&s.state==="approved"?a("ui.mesh.approval.approved_pending_apply"):Is(s.state)}),e.jsx("div",{className:"grow"}),o&&c&&e.jsx("span",{className:"text-meta text-ink-dim",children:s.kind==="credential"?a("ui.mesh.approval.request_window",{remaining:c}):c})]}),e.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",children:o?v:_}),!I&&s.state==="failed"&&e.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),o&&I&&e.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:s.approveRemedy||a("ui.mesh.approval.cli_review")}),s.kind==="credential"&&s.state==="approved"&&e.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:s.details?.length?a("ui.mesh.approval.approved_apply_hint"):a("ui.mesh.approval.approved_details_missing")}),(E||f)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[E&&e.jsx(U,{variant:"primary",size:"sm",disabled:n,onClick:()=>m(s.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),f&&e.jsx(U,{variant:"ghost",size:"sm",disabled:n,onClick:()=>m(s.approvalId,"deny"),"data-tour-tag":o?"mesh-approval-deny":"mesh-approval-stop",children:o?a("ui.mesh.mesh_approvals_tray.deny"):rt(s.state)}),t&&e.jsx("span",{className:"text-meta text-ink-dim",children:t.decision==="approve"?a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),e.jsxs(Ce,{chevronClassName:"text-ink-dim",summary:e.jsx("span",{className:"text-meta",children:a("ui.mesh.mesh_approvals_tray.details")}),children:[h&&(s.details?.length?e.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:s.details.map((p,S)=>e.jsx("li",{className:"whitespace-pre-wrap",children:p},`${S}:${p}`))}):e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.details_unavailable")})),j.length>0&&e.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:j.map(p=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{className:"text-ink-muted",children:p.term}),e.jsx("dd",{children:p.consequence})]},p.term))}),(D||N)&&e.jsxs("p",{className:"text-meta text-ink-muted",children:[D&&e.jsx("span",{children:D}),D&&N&&e.jsx("span",{children:" · "}),N&&e.jsx("span",{className:"font-mono",children:N})]}),d&&e.jsx("p",{className:"text-meta text-ink-dim",children:d}),y.length>0&&e.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:y.map(p=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{className:"text-ink-muted",children:p.term}),e.jsx("dd",{className:"text-ink-muted",children:p.text})]},p.term))})]}),l&&e.jsx(Je,{refusal:l})]})},Je=({refusal:s})=>(F(),e.jsx(fe,{variant:"warning",className:"text-meta","data-tour-tag":"mesh-approval-refusal",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.sentence}),e.jsx("span",{className:"shrink-0 font-mono text-ink-dim",children:s.code})]})})),dt=4,ve={kind:"idle"};function ct(s){switch(s.kind){case"dragging":case"settling":return s.payload.session.id;case"pressing":return null;default:return null}}function Q(s,t){switch(t.kind){case"press":return s.kind!=="idle"?s:{kind:"pressing",payload:t.payload,originX:t.x,originY:t.y,pointerId:t.pointerId};case"move":return s.kind==="pressing"?Math.max(Math.abs(t.x-s.originX),Math.abs(t.y-s.originY))<dt?s:{kind:"dragging",payload:s.payload,x:t.x,y:t.y,target:t.target,pointerId:s.pointerId}:s.kind==="dragging"?{...s,x:t.x,y:t.y,target:t.target}:s;case"release":return s.kind==="dragging"?{kind:"settling",payload:s.payload,target:s.target}:s.kind==="pressing"?ve:s;case"cancel":case"settled":return ve;default:return s}}const ut=({edges:s,geometry:t,selectedDeviceId:n})=>e.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:t.bounds.width,height:t.bounds.height,children:s.map(l=>{const m=t.networks.get(l.networkId),u=t.devices.get(l.deviceId);if(!m||!u)return null;const g=n!==null&&l.deviceId===n;return e.jsx("path",{"data-mesh-edge":l.key,d:Cs(m,u),fill:"none",strokeWidth:g?2:1.5,className:g?"stroke-ink":"stroke-ink-dim"},l.key)})}),mt={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function ht(s){return s.suspect?"border-l-danger":mt[ee(s)]}const pt={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},xt={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function ft(s,t,n){return[s.label,Ke(s,t),n].filter(Boolean).join(", ")}function se(s){return s.name.trim()||s.id.slice(-6)}function Qe(s,t,n){if(n!=="reached"&&n!=="self"){const l=pe(n);return s.unreachable_reason?`${l} (${s.unreachable_reason})`:l}return s.live_state.trim()?s.live_state.trim():s.locality==="local"?a("ui.mesh.mesh_drop.on_this_device"):a("ui.mesh.mesh_node.on_device",{device:t})}const gt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},bt=({network:s,x:t,y:n,refused:l})=>(F(),e.jsxs("li",{"data-mesh-network":s.id,"data-mesh-network-refused":l?"true":void 0,"data-glass-block":"",className:L("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",l?"border-warning":"border-hairline"),style:{left:t,top:n,width:Ne,height:Ss},children:[e.jsx(Se,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-body-sm text-ink",children:s.label}),e.jsxs("span",{title:a("ui.mesh.mesh_list.epoch",{epoch:s.epoch}),className:"block truncate text-meta text-ink-dim",children:[a("ui.mesh.mesh_graph.device_count",{count:s.memberCount}),s.revokedCount>0?e.jsxs(e.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:s.revokedCount})]}):null]})]})]})),vt=({device:s,x:t,y:n,nowSeconds:l,selected:m,sessions:u,sessionTotal:g,dropState:o,movingSessionId:_,draggedSessionId:v,onOpen:j,onChipPointerDown:D,onChipClick:N,onShowAllSessions:d})=>{F();const{activity:c}=is(s,u.rows),h=c==="working",I=ft(s,l,h?"working":null),y=ee(s);return e.jsxs("li",{"data-mesh-device":s.id,"data-mesh-state":s.state,"data-mesh-drop":o??void 0,"aria-current":m?"true":void 0,"data-glass-block":"",className:L("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",m&&"border-y-ink border-r-ink bg-row-selected",ht(s),pt[s.state],o&&xt[o]),style:{left:t,top:n,width:Ne,height:Ms},children:[e.jsxs("button",{type:"button","data-mesh-device-open":s.id,"data-mesh-reach":y,"aria-label":I,title:rs(s),onClick:()=>j(s.id),className:L("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-start","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Es},children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx(at,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:s.label}),s.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),e.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[e.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:s.sessionCount??"–"}),e.jsx("span",{className:L("min-w-0 truncate text-meta",s.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Ue(s.sessionCount)})]}),e.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:ls[y]}),e.jsx("span",{className:L("shrink-0",qe[y]),children:pe(y)}),h&&e.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:a("ui.mesh.mesh_node.working")}),s.memberships.length>1&&e.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:a("ui.mesh.mesh_node.memberships",{count:s.memberships.length})})]})]}),e.jsxs("ul",{"aria-label":a("ui.mesh.mesh_node.conversations_on",{device:s.label}),className:L("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",o==="accept"&&"opacity-40"),children:[u.shown.map(E=>e.jsx(_t,{session:E,ownerLabel:s.label,ownerReach:y,ownerReachable:s.reachable,moving:_===E.id,dragging:v===E.id,onPointerDown:D,onClick:()=>N(E)},E.id)),u.hidden>0&&e.jsx("li",{className:"shrink-0",children:e.jsxs("button",{type:"button","data-mesh-more":s.id,onClick:()=>d(s.id),className:L("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:a("ui.mesh.mesh_node.shown_conversations",{shown:u.shown.length,total:g}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:g}),children:["+",u.hidden]})})]})]})},_t=({session:s,ownerLabel:t,ownerReach:n,ownerReachable:l,moving:m,dragging:u,onPointerDown:g,onClick:o})=>{F();const _=Qe(s,t,n);return m?e.jsx("li",{role:"status","data-mesh-session":s.id,"data-mesh-moving":"true",children:e.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")})}):e.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":s.id,"data-mesh-dragging":u?"true":void 0,children:e.jsx("button",{type:"button","data-mesh-session":s.id,style:{touchAction:"none"},title:`${se(s)} · ${_}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:se(s),fact:_,owner:t}),onPointerDown:v=>g(v,s),onClick:()=>o(s),className:L("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-start text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",gt[Ds(s,l)],u&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:e.jsx("span",{className:"min-w-0 flex-1 truncate",children:se(s)})})})};function Pe(s){const t=s.trim();if(!t)return null;if(t.startsWith("[")){const l=t.indexOf("]");if(l<=1)return null;const m=t.slice(1,l),u=t.slice(l+1);if(!u)return{host:m,port:null};if(!u.startsWith(":"))return null;const g=Number(u.slice(1));return{host:m,port:Number.isInteger(g)?g:null}}const n=t.lastIndexOf(":");if(n>0){const l=t.slice(n+1);if(/^\d+$/.test(l))return{host:t.slice(0,n),port:Number(l)}}return{host:t,port:null}}function $e(s){const t=s.trim().split(".");if(t.length!==4)return null;for(const n of t)if(!/^\d{1,3}$/.test(n)||Number(n)>255)return null;return`${t[0]}.${t[1]}.${t[2]}`}function kt(s){return`${s}.x`}function wt(s){const t=new Map;for(const l of s.values())for(const m of l)t.set(m,(t.get(m)??0)+1);const n=new Set;for(const[l,m]of t)m>1&&n.add(l);return n}function ye(s){return new Set(s.endpoints.map(t=>t.trim()).filter(Boolean))}function jt(s,t){const n=s.filter(d=>d.id!==t),l=s.find(d=>d.id===t)??null,m=new Map;for(const d of s)m.set(d.id,ye(d));const u=wt(m),g=new Set;for(const d of l?ye(l):[]){if(u.has(d))continue;const c=Pe(d),h=c?$e(c.host):null;h&&g.add(h)}const o=d=>{const c=new Set;for(const h of ye(d)){if(u.has(h))continue;const I=Pe(h),y=I?$e(I.host):null;y&&c.add(y)}return c},_=new Map,v=new Map;for(const d of n){const c=yt(d);if(c){_.set(c,[..._.get(c)??[],d.id]);continue}for(const h of o(d))v.set(h,[...v.get(h)??[],d.id])}const j=new Map(s.map((d,c)=>[d.id,c])),D=d=>[...d].sort((c,h)=>(j.get(c)??0)-(j.get(h)??0)),N=[];for(const[d,c]of _)N.push({prefix:d,tier:"declared",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[d,c]of v)g.has(d)?N.push({prefix:d,tier:"shared",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):c.length>1&&N.push({prefix:d,tier:"probable",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return N.sort((d,c)=>d.tier.localeCompare(c.tier)||d.prefix.localeCompare(c.prefix))}function yt(s){for(const t of s.memberships){const n=t.scope.trim();if(n)return n}return""}const Te={declared:0,shared:1,probable:2};function Nt(s,t){const n=new Map;for(const m of s){let u=null;for(const o of m.deviceIds){const _=t.get(o);_!==void 0&&(u===null||_<u.slot)&&(u={id:o,slot:_})}if(u===null)continue;const g=n.get(u.id);g===void 0?n.set(u.id,{slot:u.slot,groups:[m]}):g.groups.push(m)}const l=m=>{let u=-1;for(const g of m.deviceIds){const o=t.get(g);o!==void 0&&o>u&&(u=o)}return u};return[...n.entries()].sort((m,u)=>m[1].slot-u[1].slot).map(([m,u])=>({deviceId:m,groups:u.groups.sort((g,o)=>l(o)-l(g)||Te[g.tier]-Te[o.tier]||g.prefix.localeCompare(o.prefix))}))}function It(s){return new Map(s.map(t=>[t.deviceId,t.groups.length]))}function Ct(s){return`${s.tier==="declared"?s.prefix:kt(s.prefix)} · ${s.words}`}const Oe=(s,t)=>s.deviceIds.map(n=>t.devices.get(n)).filter(n=>n!==void 0),St=({stacks:s,geometry:t})=>(F(),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:s.map(n=>{const l=n.groups.length,m=new Array(l).fill(0);let u=null;for(let o=l-1;o>=0;o-=1){const _=Oe(n.groups[o],t),v=(_.length===0?0:Math.max(..._.map(j=>j.y+j.height)))+xe;u=u===null?v:Math.max(v,u+we),m[o]=u}const g=t.devices.get(n.deviceId);return n.groups.map((o,_)=>{const v=Oe(o,t);if(v.length===0)return null;const j=l-1-_,D=Math.min(...v.map(y=>y.x)),N=Math.max(...v.map(y=>y.x)),c=(g?.y??Math.min(...v.map(y=>y.y)))-xe-Rs*j,h=o.tier==="declared",I=Ct(o);return e.jsx("div",{"data-mesh-scope":`${o.tier}:${o.prefix}`,"data-mesh-scope-level":_,className:L("absolute rounded-lg",o.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:D-xe-we*j,top:c,width:N+Ne-D+(xe+we*j)*2,height:m[_]-c},children:e.jsx("span",{"data-mesh-scope-label":"",className:L("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",o.tier==="probable"?"text-ink-dim":"text-ink-muted",h&&"font-medium"),children:I})},`${o.tier}:${o.prefix}`)})})})),ze=48,He=1.25,Mt=.0015,Et=({graph:s,slots:t,nowSeconds:n,selectedDeviceId:l,sessions:m,sessionTotals:u,movingSessionId:g,canMove:o,onOpenDevice:_,onAskMove:v,onDropRefused:j,onShowAllSessions:D,summaryId:N})=>{F();const d=x.useRef(null),[c,h]=x.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[I,y]=x.useState({k:1,tx:0,ty:0}),E=x.useRef(!1),f=x.useRef(!1),p=x.useRef(null),S=x.useMemo(()=>jt(s.devices,s.selfDeviceId),[s.devices,s.selfDeviceId]),P=x.useMemo(()=>Nt(S,t.devices),[S,t]),C=x.useMemo(()=>As(t,It(P)),[t,P]),M=x.useMemo(()=>({selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(i=>[i.id,i])),networks:new Map(s.networks.map(i=>[i.id,i]))}),[s]),[k,T]=x.useState(ve),de=x.useRef({kind:"ground"}),te=x.useCallback((i,r)=>{const b=document.elementFromPoint(i,r),A=b?.closest("[data-mesh-device]");if(A){const G=A.getAttribute("data-mesh-device");if(G)return{kind:"device",deviceId:G}}const H=b?.closest("[data-mesh-network]");if(H){const G=H.getAttribute("data-mesh-network");if(G)return{kind:"network",networkId:G}}return{kind:"ground"}},[]),$=x.useMemo(()=>k.kind!=="dragging"&&k.kind!=="settling"?null:ge(k.payload,k.target,M),[k,M]),K=x.useCallback(i=>{if(!$)return null;if($.kind==="plan"){const r=k.kind==="dragging"||k.kind==="settling"?k.target:null;return r&&r.kind==="device"&&r.deviceId===i?"accept":null}if($.kind==="refused"){const r=k.kind==="dragging"||k.kind==="settling"?k.target:null;return r&&r.kind==="device"&&r.deviceId===i?"refuse":null}return null},[$,k]),ne=x.useCallback((i,r)=>{if(!o||i.button!==0)return;f.current=!1;const b=r.locality==="local"?s.selfDeviceId??"":r.owner_device,A=M.devices.get(b),H={session:r,ownerDeviceId:b,ownerLabel:A?.label??r.owner_device_name};try{i.currentTarget.setPointerCapture(i.pointerId)}catch{}T(G=>Q(G,{kind:"press",payload:H,x:i.clientX,y:i.clientY,pointerId:i.pointerId}))},[o,M,s.selfDeviceId]),ae=i=>{if(k.kind==="pressing"||k.kind==="dragging"){const r=te(i.clientX,i.clientY);de.current=r,T(b=>Q(b,{kind:"move",x:i.clientX,y:i.clientY,target:r}));return}V(i)},ce=i=>{if(ue(i),k.kind!=="pressing"&&k.kind!=="dragging")return;if(k.kind==="pressing"){T(b=>Q(b,{kind:"cancel"}));return}const r=ge(k.payload,k.target,M);f.current=!0,T(b=>Q(b,{kind:"release"})),r.kind==="plan"?v({plan:r.plan,alternatives:r.alternatives,risky:r.risky}):r.kind==="refused"&&j({code:r.code,sentence:r.sentence,reach:r.reach,remedy:r.remedy,plan:r.plan??null}),T(b=>Q(b,{kind:"settled"}))};x.useEffect(()=>()=>T(ve),[]);const ie=x.useCallback(()=>{y(Ae(C.bounds,c))},[C.bounds,c]);x.useEffect(()=>{const i=d.current;if(!i)return;const r=()=>{const A=i.getBoundingClientRect();h({width:A.width,height:A.height,clipWidth:i.clientWidth,clipHeight:i.clientHeight,left:A.left,top:A.top})};r();const b=new ResizeObserver(r);return b.observe(i),()=>b.disconnect()},[]),x.useEffect(()=>{E.current||c.width<=0||c.height<=0||(E.current=!0,y(Ae(C.bounds,c)))},[c,C.bounds]),x.useEffect(()=>{const i=p.current;if(p.current={width:c.width,height:c.height},!i||!E.current||c.width<=0||c.height<=0||c.width>=i.width&&c.height>=i.height||!l)return;const r=C.devices.get(l);r&&y(b=>{const A={width:c.clipWidth,height:c.clipHeight},H=Math.max(0,Math.min(A.width-C.bounds.width*b.k,A.height-C.bounds.height*b.k));return Ls(b,r,A,Math.min($s,H))})},[c,l,C]);const q=k.kind==="dragging"?{x:k.x-c.left+12,y:k.y-c.top+12}:{x:0,y:0},re=$?Ps($):null,B=x.useRef(null),w=x.useRef(null),R=x.useRef(null),O=x.useRef(null),Y=x.useCallback(()=>{R.current=null;const i=B.current,r=w.current;if(B.current=null,w.current=null,i){const b=O.current;if(!b)return;y({k:b.transform.k,tx:b.transform.tx+(i.x-b.x),ty:b.transform.ty+(i.y-b.y)});return}r&&y(b=>je(b,{x:r.x,y:r.y},b.k*Math.exp(-r.deltaY*Mt)))},[]),z=x.useCallback(()=>{R.current===null&&(R.current=requestAnimationFrame(Y))},[Y]);x.useEffect(()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},[]);const Z=i=>{!(i.target===i.currentTarget)&&i.button!==1||i.button!==0&&i.button!==1||(O.current={x:i.clientX,y:i.clientY,transform:I},i.currentTarget.setPointerCapture(i.pointerId),i.preventDefault())},V=i=>{O.current&&(B.current={x:i.clientX,y:i.clientY},z())},ue=i=>{O.current&&(O.current=null,B.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId))},J=x.useCallback(i=>{if(i.deltaY===0)return;i.preventDefault();const r=i.currentTarget.getBoundingClientRect();w.current={x:i.clientX-r.left,y:i.clientY-r.top,deltaY:i.deltaY},z()},[z]);x.useEffect(()=>{const i=d.current;if(i)return i.addEventListener("wheel",J,{passive:!1}),()=>i.removeEventListener("wheel",J)},[J]);const le=i=>{const r=i.shiftKey?ze*4:ze;switch(i.key){case"Escape":if(k.kind!=="pressing"&&k.kind!=="dragging")return;i.preventDefault(),k.kind==="dragging"&&(f.current=!0),T(b=>Q(b,{kind:"cancel"}));return;case"0":i.preventDefault(),ie();return;case"+":case"=":i.preventDefault(),y(b=>je(b,{x:c.width/2,y:c.height/2},b.k*He));return;case"-":case"_":i.preventDefault(),y(b=>je(b,{x:c.width/2,y:c.height/2},b.k/He));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{i.preventDefault();const b=i.key==="ArrowLeft"?r:i.key==="ArrowRight"?-r:0,A=i.key==="ArrowUp"?r:i.key==="ArrowDown"?-r:0;y(H=>({...H,tx:H.tx+b,ty:H.ty+A}));return}}};return e.jsxs("div",{ref:d,"data-mesh-canvas":"",role:"group","aria-labelledby":N,tabIndex:0,onPointerDown:Z,onPointerMove:ae,onPointerUp:ce,onPointerCancel:i=>{k.kind==="dragging"&&(f.current=!0),T(r=>Q(r,{kind:"cancel"})),ue(i)},"data-mesh-gesture":k.kind,"data-glass-well":"clear",onKeyDown:le,onDoubleClick:i=>{i.target===i.currentTarget&&ie()},className:L("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[e.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${I.tx}px ${I.ty}px`}}),e.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${I.tx}px, ${I.ty}px, 0) scale(${I.k})`,transformOrigin:"0 0",width:C.bounds.width,height:C.bounds.height},children:[e.jsx(St,{stacks:P,geometry:C}),e.jsx(ut,{edges:s.edges,geometry:C,selectedDeviceId:l}),e.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:s.networks.map(i=>{const r=C.networks.get(i.id);return r?e.jsx(bt,{network:i,x:r.x,y:r.y,refused:$?.kind==="refused"&&k.kind==="dragging"&&k.target.kind==="network"&&k.target.networkId===i.id},i.id):null})}),e.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:s.devices.map(i=>{const r=C.devices.get(i.id);return r?e.jsx(vt,{device:i,x:r.x,y:r.y,nowSeconds:n,selected:i.id===l,sessions:m.get(i.id)??{rows:[],shown:[],hidden:0},sessionTotal:u.get(i.id)??i.sessionCount??0,dropState:K(i.id),movingSessionId:g,draggedSessionId:ct(k),onOpen:_,onChipPointerDown:ne,onChipClick:()=>{if(f.current){f.current=!1;return}_(i.id)},onShowAllSessions:D},i.id):null})})]}),k.kind==="dragging"&&e.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:q.x,top:q.y},children:k.payload.session.name||"untitled"}),k.kind==="dragging"&&re&&e.jsx("div",{"data-mesh-indicator":"",className:L("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",$?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:q.x,maxWidth:Math.max(160,c.width-q.x-12),...q.y>c.height*.6?{bottom:Math.max(12,c.height-q.y+8)}:{top:q.y+24}},children:re})]})};function Dt(s,t,n,l){const m=n.locality==="local"?t:n.owner_device,u=[];for(const g of s)if(g.id!==m){if(g.id===t){u.push({deviceId:g.id,label:l,verb:a("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:a("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}u.push({deviceId:g.id,label:g.label,verb:a("ui.mesh.mesh_card.move_to",{device:g.label}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:g.label})})}return u}function Rt(s,t,n){return Dt(s.devices,s.selfDeviceId,t,n)}function es(s,t,n){const l=Rt(s,t,n),m={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(o=>[o.id,o])),networks:new Map(s.networks.map(o=>[o.id,o]))},u=t.locality==="local"?s.selfDeviceId??"":t.owner_device,g=m.devices.get(u);return l.map(o=>{const _=ge({session:t,ownerDeviceId:u,ownerLabel:g?.label??t.owner_device_name},{kind:"device",deviceId:o.deviceId},m);return{...o,refused:_.kind==="refused"&&_.code!=="busy"?_.sentence:null}})}const ss=({session:s,destinations:t,disabled:n,onChoose:l,onOpenChange:m,trigger:u,triggerLabel:g})=>(F(),e.jsxs(ms,{onOpenChange:m,children:[e.jsx(hs,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":g,"data-mesh-session-menu":s.id,disabled:n||t.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:u})}),e.jsxs(ps,{align:"start",className:"min-w-56",children:[e.jsx(xs,{children:se(s)}),e.jsx(Ee,{}),t.map(o=>e.jsx(De,{"data-mesh-move-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>l(o,!1),children:o.verb},o.deviceId)),e.jsx(Ee,{}),t.map(o=>e.jsx(De,{"data-mesh-copy-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>l(o,!0),children:o.keepVerb},`keep-${o.deviceId}`))]})]})),At=({device:s,sessions:t,sessionTotal:n,nowSeconds:l,destinationsFor:m,movingSessionId:u,canMove:g,canInvite:o,onClose:_,onMove:v,onShowInList:j,onInvite:D,onRemoveMember:N})=>{F();const d=ee(s),c=Be(s),h=s.reachable?[]:s.attempts??[];x.useEffect(()=>{const f=p=>{p.key!=="Escape"||p.defaultPrevented||p.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${s.id}"]`)?.focus(),_())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s.id,_]);const I=s.sessionCount===null?Ue(null):a("ui.mesh.mesh_card.conversation_count",{count:s.sessionCount}),y=s.suspect?Ye():[I,pe(d)].filter(Boolean).join(" · "),E=n>t.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:t.rows.length,total:n}):`${t.rows.length}`;return e.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:s.label}),"data-mesh-panel":s.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[e.jsxs("header",{className:"flex flex-col gap-1",children:[e.jsx(U,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:_,children:a("ui.mesh.mesh_actions.close")}),e.jsx("h2",{className:"text-body-sm text-ink",children:s.label}),e.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[s.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!s.suspect&&d==="unanswered"&&e.jsx(us,{"aria-hidden":"true",className:"size-3.5 text-warning"}),y]})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.memberships")}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:s.memberships.map(f=>e.jsxs("li",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[e.jsx(Se,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),f.networkName]}),e.jsxs("span",{className:"text-meta text-ink-dim",children:[f.role||"member",f.capabilities.length>0?` · ${f.capabilities.join(", ")}`:""]}),o&&e.jsxs(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${f.networkId}:${s.id}`,onClick:()=>N(s,f.networkId),children:[a("ui.mesh.mesh_card.remove_from"),f.networkName,"…"]})]},f.networkId))}),o&&e.jsx(U,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":s.id,onClick:()=>D(s),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[e.jsxs("h3",{className:"text-meta text-ink-dim",children:[a("ui.mesh.mesh_card.conversations"),e.jsxs("span",{className:"text-ink-disabled",children:["(",ee(s)!=="self"&&ee(s)!=="reached"?Ve(null):E,")"]})]}),be(s,l)?e.jsx("p",{className:"text-meta text-warning",children:be(s,l)}):t.rows.length===0?e.jsx("p",{className:"text-meta text-ink-dim",children:s.sessionCount===null?a("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):a("ui.mesh.mesh_card.no_conversations_here")}):e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:t.rows.map(f=>e.jsxs("li",{"data-mesh-panel-session":f.id,className:L("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",u===f.id&&"border-control"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:se(f),children:se(f)}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Qe(f,s.label,ee(s))}),u===f.id?e.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):e.jsx(ss,{session:f,destinations:m(f),disabled:!g,onChoose:(p,S)=>v(f,p,S),trigger:e.jsx(Ze,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:se(f)})})]},f.id))})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.network_addresses")}),s.endpoints.length===0?e.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.no_address_published")}):e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:s.endpoints.map(f=>e.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:f}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},f))})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.status")}),e.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.reach")}),e.jsx("dd",{className:"m-0 text-body-sm text-ink",children:pe(d)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.last_status_frame")}),e.jsx("dd",{className:"m-0 text-body-sm text-ink",children:s.lastSeenAt===null?a("ui.mesh.mesh_card.never"):Ts(l-s.lastSeenAt)})]})]}),!s.reachable&&(c!==""||h.length>0)&&e.jsxs("div",{className:"flex flex-col gap-1",children:[c&&e.jsx("p",{className:"m-0 text-meta text-warning",children:c}),s.linkState==="handshake_refused"&&e.jsx("p",{className:"m-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.handshake_refused_hint")}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{id:`mesh-attempts-label-${s.id}`,className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.addresses_tried")}),e.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${s.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:h.map((f,p)=>{const S=Ge(f.detail);return e.jsxs("li",{"data-mesh-attempt":f.endpoint,className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:f.endpoint}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:S})]},`${f.endpoint}:${p}`)})})]})]}),!c&&h.length===0&&s.reason&&e.jsx("p",{className:"text-meta text-warning",children:s.reason})]}),e.jsx(oe,{}),e.jsx(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":s.id,onClick:()=>j(s.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},Lt=["name","chats","state"],Pt={get name(){return a("ui.mesh.mesh_list.name")},get chats(){return a("ui.mesh.mesh_list.sort_conversations")},get state(){return a("ui.mesh.mesh_list.state")}},We={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function $t(s,t){const n=[...s];switch(t){case"chats":return n.sort((l,m)=>(m.sessionCount??-1)-(l.sessionCount??-1)||l.label.localeCompare(m.label)),n;case"state":return n.sort((l,m)=>We[l.state]-We[m.state]||l.label.localeCompare(m.label)),n;default:return n.sort((l,m)=>l.label.localeCompare(m.label))}}const Fe=8;function Tt(s,t){if(s.locality==="local")return s.live_state||"here";const n=s.owner_device_name||t,l=s.live_state?` · ${s.live_state}`:"";return s.reachable?a("ui.mesh.mesh_list.on_device_state",{device:n,state:l}):a("ui.mesh.mesh_list.on_device_no_answer",{device:n})}const Ot=({graph:s,nowSeconds:t,selectedDeviceId:n,sessions:l,selfLabel:m,canMove:u,onSelect:g,onMove:o,onInvite:_,onRemove:v})=>{F();const[j,D]=x.useState("name"),N=x.useMemo(()=>s.networks.map(d=>({network:d,members:$t(s.devices.filter(c=>c.memberships.some(h=>h.networkId===d.id)),j)})),[s,j]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pe-1",children:[e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_list.sort_devices_by")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Lt.map(d=>e.jsx("button",{type:"button","aria-pressed":j===d,onClick:()=>D(d),className:L("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",j===d&&"bg-surface text-ink"),children:Pt[d]},d))})]}),N.map(({network:d,members:c})=>e.jsxs("section",{"data-mesh-network-group":d.id,className:"flex flex-col gap-2",children:[e.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:a("ui.mesh.mesh_list.epoch",{epoch:d.epoch}),children:[d.label,e.jsxs("span",{className:"text-meta text-ink-dim",children:[d.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:d.memberCount}),d.revokedCount>0?e.jsxs(e.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:d.revokedCount})]}):null]})]}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:c.map(h=>{const I=h.memberships.find(M=>M.networkId===d.id),y=h.id===n,E=l.get(h.id),f=E?.rows??[],p=E?Xe(E,h.sessionCount):h.sessionCount??0,S=ee(h),P=Be(h),C=h.reachable?[]:h.attempts??[];return e.jsxs("li",{"data-mesh-device-row":h.id,"data-mesh-state":h.state,"aria-current":y?"true":void 0,className:L("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",y&&"border-ink bg-row-selected"),children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button","data-mesh-device-open":h.id,onClick:()=>g(h.id),className:L("min-w-0 flex-1 truncate text-start text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:h.label}),e.jsxs("span",{className:L("flex shrink-0 items-center gap-1 text-meta",qe[S]),"data-mesh-reach":S,children:[h.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),h.suspect?pe(S):Ke(h,t),h.suspect&&e.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ye()})]}),e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[I?.role?`${I.role} · `:"",a("ui.mesh.mesh_list.member")]})]}),(P!==""||C.length>0)&&!h.reachable&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[P&&e.jsx("span",{className:"text-meta text-warning",children:P}),C.map((M,k)=>{const T=Ge(M.detail);return e.jsx("span",{"data-mesh-attempt":M.endpoint,className:"text-meta text-ink-dim",children:T?`${M.endpoint} — ${T}`:M.endpoint},`${M.endpoint}:${k}`)})]}),be(h,t)?e.jsxs("span",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_card.conversations")," (",Ve(null),") ·"," ",be(h,t)]}):f.length>0?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"my-1"}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:f.slice(0,Fe).map(M=>e.jsxs("li",{"data-mesh-row-session":M.id,className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:M.name||M.id}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Tt(M,m)}),e.jsx(ss,{session:M,destinations:es(s,M,m),disabled:!u,onChoose:(k,T)=>o(M,k,T),trigger:e.jsx(Ze,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:M.name||M.id})})]},M.id))}),p>f.slice(0,Fe).length&&e.jsx("button",{type:"button",onClick:()=>g(h.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:p})})]}):e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:p})}),(I||h.state!=="self")&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(U,{size:"sm",variant:"ghost","data-mesh-invite":h.id,onClick:()=>_({deviceId:h.id,deviceLabel:h.label}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),I&&e.jsxs(U,{size:"sm",variant:"ghost","data-mesh-remove-member":`${d.id}:${h.id}`,onClick:()=>v({networkId:d.id,networkLabel:d.label,deviceId:h.id,deviceLabel:h.label}),children:[a("ui.mesh.mesh_card.remove_from"),d.label,"…"]})]})]},h.id)})})]},d.id)),s.unmatchedPeers.length>0&&e.jsxs("p",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_graph.device_count",{count:s.unmatchedPeers.length})," ",a("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},zt=({revoked:s})=>{if(s.length===0)return null;const t=a("ui.mesh.mesh_list.revoked_count",{count:s.length});return e.jsx(Ce,{className:"contents",chevron:"trailing",chevronClassName:"text-ink-dim",rowClassName:"min-h-auto py-0",triggerClassName:"inline-flex w-auto items-center gap-1 align-baseline text-meta text-ink-dim hover:text-ink",triggerData:{"data-mesh-revoked-toggle":""},triggerLabel:a("ui.mesh.mesh_list.revoked_toggle_label"),summary:e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block whitespace-pre",children:" · "}),t]}),children:e.jsx("ul",{"data-mesh-revoked":"",className:"m-0 flex list-none flex-col gap-1 p-0",children:s.map(n=>e.jsxs("li",{"data-mesh-revoked-member":n.deviceId,className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-dim",children:[e.jsx("span",{children:n.networkName}),e.jsx("span",{className:"font-mono text-body-sm text-ink",children:n.deviceId}),e.jsx("span",{className:"text-body-sm text-ink-muted",children:n.label}),e.jsxs("span",{children:[n.role?`${n.role} · `:"",a("ui.mesh.mesh_graph.revoked_membership")]})]},`${n.networkId}:${n.deviceId}`))})})},Ht=["canvas","list"],Wt={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},Ft=({state:s,initialPresentation:t="canvas",graph:n,nowSeconds:l,checking:m,staleError:u,onRetry:g,approvals:o,sessions:_,sessionError:v,selfLabel:j,movingSessionId:D,canMove:N,pendingMove:d,onAskMove:c,onDropRefused:h,onChooseMove:I,onCancelMove:y,moveBusy:E,moveReport:f,onDismissReport:p,onWaitForIdle:S,onUndoCopy:P,invite:C,onOpenInvite:M,onInvite:k,onCloseInvite:T,inviteBusy:de,inviteReceipt:te,inviteRefusal:$,remove:K,onOpenRemove:ne,onRemove:ae,onCloseRemove:ce,removeBusy:ie,removeRefusal:q,removed:re})=>{F();const[B,w]=x.useState(t),[R,O]=x.useState(null),Y=n?Os(n):"",z="mesh-summary",Z=zs(n),V=Hs(n,_,n?.selfDeviceId??null),ue=x.useMemo(()=>{const r=new Map;for(const b of n?.devices??[]){const A=V.byDevice.get(b.id);r.set(b.id,A?Xe(A,b.sessionCount):b.sessionCount??0)}return r},[n,V]),J=x.useCallback(r=>{O(r)},[]),le=n?n.devices.find(r=>r.id===R)??null:null,i=x.useCallback((r,b,A)=>{if(!n)return null;const H={selfDeviceId:n.selfDeviceId,devices:new Map(n.devices.map(X=>[X.id,X])),networks:new Map(n.networks.map(X=>[X.id,X]))},G=r.locality==="local"?n.selfDeviceId??"":r.owner_device,ts=H.devices.get(G),W=ge({session:r,ownerDeviceId:G,ownerLabel:ts?.label??r.owner_device_name},{kind:"device",deviceId:b.deviceId},H);if(W.kind==="refused")return h({code:W.code,sentence:W.sentence,reach:W.reach,remedy:W.remedy,plan:W.plan??null}),null;if(W.kind==="none")return null;const Me=A?W.alternatives.find(X=>X.keep)??W.plan:W.plan,ns=[W.plan,...W.alternatives].filter(X=>X.keep!==Me.keep),as={plan:Me,alternatives:ns,risky:W.risky};c(as)},[n,c,h]);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[e.jsx(cs,{title:a("ui.mesh.mesh_page.mesh"),icon:Se,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[m&&e.jsx("output",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.checking")}),(s.kind==="ready"||s.kind==="loading")&&e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_page.presentation")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Ht.map(r=>e.jsx("button",{type:"button","data-mesh-presentation":r,"aria-pressed":B===r,disabled:s.kind!=="ready",onClick:()=>w(r),className:L("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",B===r&&"bg-surface text-ink"),children:Wt[r]},r))})]})]})}),e.jsx(ot,{rows:o.rows,error:o.error,pending:o.pending,refusal:o.decisionRefusal,onDecide:o.onDecide,onRetry:o.onRetry,nowSeconds:o.nowSeconds,networkNames:new Map((n?.networks??[]).map(r=>[r.id,r.label]))}),s.kind==="loading"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[e.jsx(Re,{className:"h-4 w-64"}),e.jsx(Re,{className:"min-h-40 w-full flex-1"})]}),s.kind==="error"&&e.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[e.jsx("p",{children:s.message}),e.jsx(U,{variant:"secondary",size:"sm",onClick:g,className:"w-fit",children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),s.kind==="empty"&&e.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("h2",{className:"text-heading text-ink",children:a("ui.mesh.mesh_page.no_network_on_this_device")}),e.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:a("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),e.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),e.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),s.kind==="ready"&&n&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{id:z,className:"text-meta text-ink-muted","data-mesh-summary":"",children:[e.jsx("span",{children:Y}),e.jsx(zt,{revoked:n.revoked})]}),u&&e.jsx(fe,{variant:"warning",children:e.jsx("p",{children:u})}),v&&e.jsx(fe,{variant:"warning",children:e.jsx("p",{children:v})}),f&&e.jsx(Ws,{receipt:f.kind==="moved"?{verb:f.verb,detail:f.detail,undo:f.undo}:null,refusal:f.kind==="refused"?f.refusal:null,canWait:f.kind==="refused"&&f.plan!==null,onWait:S,onRecheck:g,onUndo:P,onDismiss:p,pending:E}),B==="canvas"?e.jsx(Et,{graph:n,slots:Z,nowSeconds:l,selectedDeviceId:R,sessions:V.byDevice,sessionTotals:ue,movingSessionId:D,canMove:N,onOpenDevice:J,onAskMove:c,onDropRefused:h,onShowAllSessions:J,summaryId:z}):e.jsx(Ot,{graph:n,nowSeconds:l,selectedDeviceId:R,sessions:V.byDevice,selfLabel:j,canMove:N,onSelect:J,onMove:i,onInvite:M,onRemove:ne})]}),le&&e.jsx(At,{device:le,sessions:V.byDevice.get(le.id)??{rows:[],shown:[],hidden:0},sessionTotal:ue.get(le.id)??0,nowSeconds:l,canMove:N,canInvite:s.kind==="ready",movingSessionId:D,destinationsFor:r=>es(n,r,j),onClose:()=>O(null),onMove:i,onInvite:r=>M({deviceId:r.id,deviceLabel:r.label}),onRemoveMember:(r,b)=>{const A=n.networks.find(H=>H.id===b);ne({networkId:b,networkLabel:A?.label??b,deviceId:r.id,deviceLabel:r.label})},onShowInList:r=>{J(r),w("list")}})]})}),e.jsx(Fs,{open:d!==null,plan:d?.plan??qt,alternatives:d?.alternatives??[],risky:d?.risky??!1,busy:E,onCancel:y,onChoose:I}),C&&e.jsx(qs,{open:C.open,options:C.options,deviceId:C.deviceId,deviceLabel:C.deviceLabel,onClose:T,onInvite:k,pending:de,receipt:te,refusal:$}),K&&e.jsx(Bs,{open:K.open,networkLabel:K.networkLabel,deviceLabel:K.deviceLabel,onClose:ce,onConfirm:ae,pending:ie,refusal:q,removed:re})]})},qt={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},Qt=({initialPresentation:s})=>{F();const t=os(),n=_e(t.data,"peers")==="enabled",l=_e(t.data,"session_transfer")==="enabled",m=Ys(n,{stamp:()=>ke.getState().beginAnswer()}),u=Gs(n),g=Us(n,{poll:!1,stamp:()=>ke.getState().beginAnswer()}),o=x.useMemo(()=>({peers:m,networks:u}),[m,u]),_=Ks(o),v=Vs(o),j=Xs(),D=_e(t.data,"approvals")==="enabled",N=Zs(n&&D,{poll:!1}),d=Js(),c=d.isError?{approvalId:d.variables?.approvalId??null,...Qs(d.error)}:null,h=x.useMemo(()=>Math.floor((N.dataUpdatedAt||Date.now())/1e3),[N.dataUpdatedAt]),I=ke(w=>w.settlePlacement),y=et(),E=st(),[f,p]=x.useState(null),[S,P]=x.useState(null),[C,M]=x.useState(null),[k,T]=x.useState(null),[de,te]=x.useState(null),[$,K]=x.useState(null),[ne,ae]=x.useState(null),ce=x.useMemo(()=>{const w=Math.max(m.dataUpdatedAt,u.dataUpdatedAt);return Math.floor((w||Date.now())/1e3)},[m.dataUpdatedAt,u.dataUpdatedAt]),ie=x.useCallback(()=>{m.refetch(),u.refetch(),g.refetch()},[m,u,g]),q=x.useCallback((w,R)=>{p(null);const O={sessionId:w.sessionId,to:w.to,keep:w.keep,waitS:R??w.waitS};j.mutate(O,{onSuccess:Y=>{if(Y.kind==="moved"){const{receipt:z}=Y;I(w.sessionId,z);const Z=z.locality==="local"?a("ui.mesh.mesh_drop.this_device"):v?.devices.find(V=>V.id===z.owner_device)?.label??z.owner_device;P({kind:"moved",verb:z.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:z.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:Z,suffix:z.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:Z,retirement:z.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:z.mode==="keep"?{sessionId:z.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:Z}),waitS:0,lost:tt(Z,a("ui.mesh.mesh_drop.this_device"))}:null});return}P({kind:"refused",refusal:Y.refusal,plan:w})},onError:()=>{P({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:w})}})},[v,j,I]),re=x.useMemo(()=>{if(!v)return[];const w=C?.deviceId,R=w?v.devices.find(O=>O.id===w):void 0;return v.networks.filter(O=>R?!R.memberships.some(Y=>Y.networkId===O.id):!0).map(O=>({id:O.id,label:O.label}))},[v,C]);if(!n)return e.jsx(ds,{to:"/chat",replace:!0});const B=_.kind==="ready"?m.error?me(m.error):u.error?me(u.error):null:null;return e.jsx(Ft,{initialPresentation:s,state:_,graph:v,nowSeconds:ce,checking:m.isFetching||u.isFetching,staleError:B,onRetry:ie,approvals:{rows:N.data??[],error:N.isError?nt(N.error):null,pending:d.isPending?d.variables??null:null,decisionRefusal:c,onDecide:(w,R)=>d.mutate({approvalId:w,decision:R}),onRetry:()=>void N.refetch(),nowSeconds:h},sessions:g.data?.rows??[],movingSessionId:j.isPending?j.variables?.sessionId??null:null,sessionError:g.isError?me(g.error):null,selfLabel:v?.devices.find(w=>w.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:l,pendingMove:f,onAskMove:p,onDropRefused:w=>P({kind:"refused",refusal:{code:w.code,sentence:w.sentence,reach:w.reach,status:null,unconfirmed:!1},plan:w.plan}),onChooseMove:w=>q(w),onCancelMove:()=>p(null),moveBusy:j.isPending,moveReport:S,onDismissReport:()=>P(null),onWaitForIdle:()=>{S?.kind!=="refused"||!S.plan||q(S.plan,Bt)},onUndoCopy:()=>{S?.kind!=="moved"||!S.undo||p({plan:S.undo,alternatives:[],risky:!1})},invite:C===null?null:{open:!0,deviceId:C.deviceId,deviceLabel:C.deviceLabel,options:re},onOpenInvite:w=>{T(null),te(null),M(w)},onInvite:w=>{y.mutate(w,{onSuccess:R=>T(R),onError:R=>te({code:"invite_refused",sentence:me(R),status:null,unconfirmed:!1})})},onCloseInvite:()=>M(null),inviteBusy:y.isPending,inviteReceipt:k,inviteRefusal:de,remove:$===null?null:{open:!0,networkId:$.networkId,networkLabel:$.networkLabel,deviceId:$.deviceId,deviceLabel:$.deviceLabel},onOpenRemove:w=>{ae(null),K(w)},onRemove:w=>{$&&E.mutate({networkId:$.networkId,deviceId:$.deviceId,confirm:w},{onSuccess:R=>ae(R)})},onCloseRemove:()=>K(null),removeBusy:E.isPending,removeRefusal:E.isError?{code:"remove_refused",sentence:me(E.error),status:null,unconfirmed:!1}:null,removed:ne})},Bt=300;export{Qt as MeshPage,Ft as MeshSurface,Qt as default};
1
+ import{r as x,j as e,c as L}from"./index-DhltrflG.js";import{C as is,E as ee,F as rs,R as ls,G as pe,H as qe,I as Be,J as Ye,K as Ge,a as os,L as _e,q as ke,N as ds}from"./path-utils-BkJr3--b.js";import{P as cs}from"./page-header-B3bOo0UX.js";import{u as F,B as U,A as fe,p as us,h as oe,q as ms,r as hs,s as ps,t as xs,v as Ee,w as De,k as Re}from"./error-boundary-CqZRoe9S.js";import{t as a}from"./messages-Cq_3N7VC.js";import{C as he,D as fs,E as gs,F as bs,G as vs,I as _s,J as ks,K as ws,L as js,M as ys,N as Ns,O as Is,Q as Cs,R as Ss,T as Ne,U as Ms,V as Es,W as Ie,X as Ue,Y as Ke,Z as Ds,_ as xe,$ as we,a0 as Rs,a1 as As,a2 as ge,a3 as Ae,a4 as Ls,a5 as Ps,a6 as je,a7 as $s,a8 as Ve,a9 as be,aa as Ts,ab as Xe,ac as Os,ad as zs,ae as Hs,af as Ws,ag as Fs,ah as qs,ai as Bs,aj as Ys,ak as Gs,al as Us,am as Ks,an as Vs,ao as Xs,ap as Zs,aq as Js,ar as Qs,as as et,at as st,au as tt,av as me,aw as nt}from"./index-CRQJfecC.js";import{ax as Ce,ay as Se,az as at,aA as Ze}from"./conversation-input-sync-BXv32NfB.js";import"./console-mirror-BiiClM8r.js";function it(s){return s==="failed"?"text-danger":he(s)?"text-ink-muted":"text-ink-dim"}function rt(s){return s==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function lt(s){switch(s){case"requested":return[{term:a("ui.mesh.mesh_approvals_tray.signing"),text:a("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:a("ui.mesh.mesh_approvals_tray.next"),text:a("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:a("ui.mesh.mesh_approvals_tray.after_a_stop"),text:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const ot=({rows:s,error:t,pending:n,refusal:l,onDecide:m,onRetry:u,nowSeconds:g,networkNames:o})=>{F();const _=n!==null,v=x.useMemo(()=>s.filter(p=>he(p.state)),[s]),j=x.useMemo(()=>s.filter(p=>!he(p.state)),[s]),[D,N]=x.useState(!1),d=x.useRef(null),c=x.useRef(null),h=x.useRef(null),I=(p,S)=>{S==="deny"&&v.some(P=>P.approvalId===p&&P.kind==="credential")&&(h.current={id:p,origin:document.activeElement,sawPending:!1}),m(p,S)};x.useLayoutEffect(()=>{const p=h.current;if(!p)return;if(n?.approvalId===p.id&&(p.sawPending=!0),l?.approvalId===p.id){h.current=null;return}const S=s.find(C=>C.approvalId===p.id);if(S?.state==="requested"){!n&&p.sawPending&&(h.current=null);return}if(S?.state==="denied"&&n||(h.current=null,S?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==p.origin))return;(v.length?d.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):c.current?.querySelector("button"))?.focus({preventScroll:!0})},[s,n,l,v.length]);const y=j.some(p=>p.state==="failed"),E=j.filter(p=>p.state==="failed").length,f=l!==null&&s.some(p=>p.approvalId===l.approvalId&&(he(p.state)||D));return v.length===0&&j.length===0&&!t&&!l?null:e.jsxs("section",{ref:d,"aria-label":a("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(fs,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),e.jsx("h2",{className:"text-body-sm text-ink",children:a("ui.mesh.mesh_approvals_tray.approvals")}),v.length>0&&e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:v.length})})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:t}),e.jsx(U,{variant:"secondary",size:"sm",onClick:u,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),v.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:v.map(p=>e.jsx(Le,{row:p,pending:n?.approvalId===p.approvalId?n:null,busy:_,refusal:l?.approvalId===p.approvalId?l:null,onDecide:I,nowSeconds:g,networkNames:o},p.approvalId))}),l&&!f&&e.jsx(Je,{refusal:l}),j.length>0&&e.jsx("div",{ref:c,children:e.jsx(Ce,{open:D,onOpenChange:N,chevronClassName:"text-ink-dim",className:L(v.length>0&&"border-hairline border-t pt-3"),summary:e.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[a("ui.mesh.mesh_approvals_tray.settled_approvals"),e.jsxs("span",{className:"text-ink-dim",children:["(",j.length,")"]}),y&&e.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),E>0&&e.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:E})})]}),children:e.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:j.map(p=>e.jsx(Le,{row:p,pending:n?.approvalId===p.approvalId?n:null,busy:_,refusal:l?.approvalId===p.approvalId?l:null,onDecide:I,nowSeconds:g,networkNames:o},p.approvalId))})})})]})},Le=({row:s,pending:t,busy:n,refusal:l,onDecide:m,nowSeconds:u,networkNames:g})=>{F();const o=he(s.state),_=gs(s),v=bs(s,g),j=vs(s,g),D=_s(s),N=ks(s),d=ws(s),c=js(s.expiresAt,u),h=s.kind==="credential"||s.kind==="unknown",I=h||s.canApproveHere===!1,y=I?[]:lt(s.state),E=ys(s),f=Ns(s.state);return e.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:L("text-meta",it(s.state)),children:s.kind==="credential"&&s.state==="approved"?a("ui.mesh.approval.approved_pending_apply"):Is(s.state)}),e.jsx("div",{className:"grow"}),o&&c&&e.jsx("span",{className:"text-meta text-ink-dim",children:s.kind==="credential"?a("ui.mesh.approval.request_window",{remaining:c}):c})]}),e.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",children:o?v:_}),!I&&s.state==="failed"&&e.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),o&&I&&e.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:s.approveRemedy||a("ui.mesh.approval.cli_review")}),s.kind==="credential"&&s.state==="approved"&&e.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:s.details?.length?a("ui.mesh.approval.approved_apply_hint"):a("ui.mesh.approval.approved_details_missing")}),(E||f)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[E&&e.jsx(U,{variant:"primary",size:"sm",disabled:n,onClick:()=>m(s.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),f&&e.jsx(U,{variant:"ghost",size:"sm",disabled:n,onClick:()=>m(s.approvalId,"deny"),"data-tour-tag":o?"mesh-approval-deny":"mesh-approval-stop",children:o?a("ui.mesh.mesh_approvals_tray.deny"):rt(s.state)}),t&&e.jsx("span",{className:"text-meta text-ink-dim",children:t.decision==="approve"?a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),e.jsxs(Ce,{chevronClassName:"text-ink-dim",summary:e.jsx("span",{className:"text-meta",children:a("ui.mesh.mesh_approvals_tray.details")}),children:[h&&(s.details?.length?e.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:s.details.map((p,S)=>e.jsx("li",{className:"whitespace-pre-wrap",children:p},`${S}:${p}`))}):e.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.mesh.approval.details_unavailable")})),j.length>0&&e.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:j.map(p=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{className:"text-ink-muted",children:p.term}),e.jsx("dd",{children:p.consequence})]},p.term))}),(D||N)&&e.jsxs("p",{className:"text-meta text-ink-muted",children:[D&&e.jsx("span",{children:D}),D&&N&&e.jsx("span",{children:" · "}),N&&e.jsx("span",{className:"font-mono",children:N})]}),d&&e.jsx("p",{className:"text-meta text-ink-dim",children:d}),y.length>0&&e.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:y.map(p=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{className:"text-ink-muted",children:p.term}),e.jsx("dd",{className:"text-ink-muted",children:p.text})]},p.term))})]}),l&&e.jsx(Je,{refusal:l})]})},Je=({refusal:s})=>(F(),e.jsx(fe,{variant:"warning",className:"text-meta","data-tour-tag":"mesh-approval-refusal",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.sentence}),e.jsx("span",{className:"shrink-0 font-mono text-ink-dim",children:s.code})]})})),dt=4,ve={kind:"idle"};function ct(s){switch(s.kind){case"dragging":case"settling":return s.payload.session.id;case"pressing":return null;default:return null}}function Q(s,t){switch(t.kind){case"press":return s.kind!=="idle"?s:{kind:"pressing",payload:t.payload,originX:t.x,originY:t.y,pointerId:t.pointerId};case"move":return s.kind==="pressing"?Math.max(Math.abs(t.x-s.originX),Math.abs(t.y-s.originY))<dt?s:{kind:"dragging",payload:s.payload,x:t.x,y:t.y,target:t.target,pointerId:s.pointerId}:s.kind==="dragging"?{...s,x:t.x,y:t.y,target:t.target}:s;case"release":return s.kind==="dragging"?{kind:"settling",payload:s.payload,target:s.target}:s.kind==="pressing"?ve:s;case"cancel":case"settled":return ve;default:return s}}const ut=({edges:s,geometry:t,selectedDeviceId:n})=>e.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:t.bounds.width,height:t.bounds.height,children:s.map(l=>{const m=t.networks.get(l.networkId),u=t.devices.get(l.deviceId);if(!m||!u)return null;const g=n!==null&&l.deviceId===n;return e.jsx("path",{"data-mesh-edge":l.key,d:Cs(m,u),fill:"none",strokeWidth:g?2:1.5,className:g?"stroke-ink":"stroke-ink-dim"},l.key)})}),mt={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function ht(s){return s.suspect?"border-l-danger":mt[ee(s)]}const pt={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},xt={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function ft(s,t,n){return[s.label,Ke(s,t),n].filter(Boolean).join(", ")}function se(s){return s.name.trim()||s.id.slice(-6)}function Qe(s,t,n){if(n!=="reached"&&n!=="self"){const l=pe(n);return s.unreachable_reason?`${l} (${s.unreachable_reason})`:l}return s.live_state.trim()?s.live_state.trim():s.locality==="local"?a("ui.mesh.mesh_drop.on_this_device"):a("ui.mesh.mesh_node.on_device",{device:t})}const gt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},bt=({network:s,x:t,y:n,refused:l})=>(F(),e.jsxs("li",{"data-mesh-network":s.id,"data-mesh-network-refused":l?"true":void 0,"data-glass-block":"",className:L("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",l?"border-warning":"border-hairline"),style:{left:t,top:n,width:Ne,height:Ss},children:[e.jsx(Se,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-body-sm text-ink",children:s.label}),e.jsxs("span",{title:a("ui.mesh.mesh_list.epoch",{epoch:s.epoch}),className:"block truncate text-meta text-ink-dim",children:[a("ui.mesh.mesh_graph.device_count",{count:s.memberCount}),s.revokedCount>0?e.jsxs(e.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:s.revokedCount})]}):null]})]})]})),vt=({device:s,x:t,y:n,nowSeconds:l,selected:m,sessions:u,sessionTotal:g,dropState:o,movingSessionId:_,draggedSessionId:v,onOpen:j,onChipPointerDown:D,onChipClick:N,onShowAllSessions:d})=>{F();const{activity:c}=is(s,u.rows),h=c==="working",I=ft(s,l,h?"working":null),y=ee(s);return e.jsxs("li",{"data-mesh-device":s.id,"data-mesh-state":s.state,"data-mesh-drop":o??void 0,"aria-current":m?"true":void 0,"data-glass-block":"",className:L("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",m&&"border-y-ink border-r-ink bg-row-selected",ht(s),pt[s.state],o&&xt[o]),style:{left:t,top:n,width:Ne,height:Ms},children:[e.jsxs("button",{type:"button","data-mesh-device-open":s.id,"data-mesh-reach":y,"aria-label":I,title:rs(s),onClick:()=>j(s.id),className:L("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-start","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Es},children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx(at,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:s.label}),s.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),e.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[e.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:s.sessionCount??"–"}),e.jsx("span",{className:L("min-w-0 truncate text-meta",s.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Ue(s.sessionCount)})]}),e.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:ls[y]}),e.jsx("span",{className:L("shrink-0",qe[y]),children:pe(y)}),h&&e.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:a("ui.mesh.mesh_node.working")}),s.memberships.length>1&&e.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:a("ui.mesh.mesh_node.memberships",{count:s.memberships.length})})]})]}),e.jsxs("ul",{"aria-label":a("ui.mesh.mesh_node.conversations_on",{device:s.label}),className:L("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",o==="accept"&&"opacity-40"),children:[u.shown.map(E=>e.jsx(_t,{session:E,ownerLabel:s.label,ownerReach:y,ownerReachable:s.reachable,moving:_===E.id,dragging:v===E.id,onPointerDown:D,onClick:()=>N(E)},E.id)),u.hidden>0&&e.jsx("li",{className:"shrink-0",children:e.jsxs("button",{type:"button","data-mesh-more":s.id,onClick:()=>d(s.id),className:L("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:a("ui.mesh.mesh_node.shown_conversations",{shown:u.shown.length,total:g}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:g}),children:["+",u.hidden]})})]})]})},_t=({session:s,ownerLabel:t,ownerReach:n,ownerReachable:l,moving:m,dragging:u,onPointerDown:g,onClick:o})=>{F();const _=Qe(s,t,n);return m?e.jsx("li",{role:"status","data-mesh-session":s.id,"data-mesh-moving":"true",children:e.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")})}):e.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":s.id,"data-mesh-dragging":u?"true":void 0,children:e.jsx("button",{type:"button","data-mesh-session":s.id,style:{touchAction:"none"},title:`${se(s)} · ${_}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:se(s),fact:_,owner:t}),onPointerDown:v=>g(v,s),onClick:()=>o(s),className:L("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-start text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",gt[Ds(s,l)],u&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:e.jsx("span",{className:"min-w-0 flex-1 truncate",children:se(s)})})})};function Pe(s){const t=s.trim();if(!t)return null;if(t.startsWith("[")){const l=t.indexOf("]");if(l<=1)return null;const m=t.slice(1,l),u=t.slice(l+1);if(!u)return{host:m,port:null};if(!u.startsWith(":"))return null;const g=Number(u.slice(1));return{host:m,port:Number.isInteger(g)?g:null}}const n=t.lastIndexOf(":");if(n>0){const l=t.slice(n+1);if(/^\d+$/.test(l))return{host:t.slice(0,n),port:Number(l)}}return{host:t,port:null}}function $e(s){const t=s.trim().split(".");if(t.length!==4)return null;for(const n of t)if(!/^\d{1,3}$/.test(n)||Number(n)>255)return null;return`${t[0]}.${t[1]}.${t[2]}`}function kt(s){return`${s}.x`}function wt(s){const t=new Map;for(const l of s.values())for(const m of l)t.set(m,(t.get(m)??0)+1);const n=new Set;for(const[l,m]of t)m>1&&n.add(l);return n}function ye(s){return new Set(s.endpoints.map(t=>t.trim()).filter(Boolean))}function jt(s,t){const n=s.filter(d=>d.id!==t),l=s.find(d=>d.id===t)??null,m=new Map;for(const d of s)m.set(d.id,ye(d));const u=wt(m),g=new Set;for(const d of l?ye(l):[]){if(u.has(d))continue;const c=Pe(d),h=c?$e(c.host):null;h&&g.add(h)}const o=d=>{const c=new Set;for(const h of ye(d)){if(u.has(h))continue;const I=Pe(h),y=I?$e(I.host):null;y&&c.add(y)}return c},_=new Map,v=new Map;for(const d of n){const c=yt(d);if(c){_.set(c,[..._.get(c)??[],d.id]);continue}for(const h of o(d))v.set(h,[...v.get(h)??[],d.id])}const j=new Map(s.map((d,c)=>[d.id,c])),D=d=>[...d].sort((c,h)=>(j.get(c)??0)-(j.get(h)??0)),N=[];for(const[d,c]of _)N.push({prefix:d,tier:"declared",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[d,c]of v)g.has(d)?N.push({prefix:d,tier:"shared",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):c.length>1&&N.push({prefix:d,tier:"probable",deviceIds:D(c),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return N.sort((d,c)=>d.tier.localeCompare(c.tier)||d.prefix.localeCompare(c.prefix))}function yt(s){for(const t of s.memberships){const n=t.scope.trim();if(n)return n}return""}const Te={declared:0,shared:1,probable:2};function Nt(s,t){const n=new Map;for(const m of s){let u=null;for(const o of m.deviceIds){const _=t.get(o);_!==void 0&&(u===null||_<u.slot)&&(u={id:o,slot:_})}if(u===null)continue;const g=n.get(u.id);g===void 0?n.set(u.id,{slot:u.slot,groups:[m]}):g.groups.push(m)}const l=m=>{let u=-1;for(const g of m.deviceIds){const o=t.get(g);o!==void 0&&o>u&&(u=o)}return u};return[...n.entries()].sort((m,u)=>m[1].slot-u[1].slot).map(([m,u])=>({deviceId:m,groups:u.groups.sort((g,o)=>l(o)-l(g)||Te[g.tier]-Te[o.tier]||g.prefix.localeCompare(o.prefix))}))}function It(s){return new Map(s.map(t=>[t.deviceId,t.groups.length]))}function Ct(s){return`${s.tier==="declared"?s.prefix:kt(s.prefix)} · ${s.words}`}const Oe=(s,t)=>s.deviceIds.map(n=>t.devices.get(n)).filter(n=>n!==void 0),St=({stacks:s,geometry:t})=>(F(),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:s.map(n=>{const l=n.groups.length,m=new Array(l).fill(0);let u=null;for(let o=l-1;o>=0;o-=1){const _=Oe(n.groups[o],t),v=(_.length===0?0:Math.max(..._.map(j=>j.y+j.height)))+xe;u=u===null?v:Math.max(v,u+we),m[o]=u}const g=t.devices.get(n.deviceId);return n.groups.map((o,_)=>{const v=Oe(o,t);if(v.length===0)return null;const j=l-1-_,D=Math.min(...v.map(y=>y.x)),N=Math.max(...v.map(y=>y.x)),c=(g?.y??Math.min(...v.map(y=>y.y)))-xe-Rs*j,h=o.tier==="declared",I=Ct(o);return e.jsx("div",{"data-mesh-scope":`${o.tier}:${o.prefix}`,"data-mesh-scope-level":_,className:L("absolute rounded-lg",o.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:D-xe-we*j,top:c,width:N+Ne-D+(xe+we*j)*2,height:m[_]-c},children:e.jsx("span",{"data-mesh-scope-label":"",className:L("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",o.tier==="probable"?"text-ink-dim":"text-ink-muted",h&&"font-medium"),children:I})},`${o.tier}:${o.prefix}`)})})})),ze=48,He=1.25,Mt=.0015,Et=({graph:s,slots:t,nowSeconds:n,selectedDeviceId:l,sessions:m,sessionTotals:u,movingSessionId:g,canMove:o,onOpenDevice:_,onAskMove:v,onDropRefused:j,onShowAllSessions:D,summaryId:N})=>{F();const d=x.useRef(null),[c,h]=x.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[I,y]=x.useState({k:1,tx:0,ty:0}),E=x.useRef(!1),f=x.useRef(!1),p=x.useRef(null),S=x.useMemo(()=>jt(s.devices,s.selfDeviceId),[s.devices,s.selfDeviceId]),P=x.useMemo(()=>Nt(S,t.devices),[S,t]),C=x.useMemo(()=>As(t,It(P)),[t,P]),M=x.useMemo(()=>({selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(i=>[i.id,i])),networks:new Map(s.networks.map(i=>[i.id,i]))}),[s]),[k,T]=x.useState(ve),de=x.useRef({kind:"ground"}),te=x.useCallback((i,r)=>{const b=document.elementFromPoint(i,r),A=b?.closest("[data-mesh-device]");if(A){const G=A.getAttribute("data-mesh-device");if(G)return{kind:"device",deviceId:G}}const H=b?.closest("[data-mesh-network]");if(H){const G=H.getAttribute("data-mesh-network");if(G)return{kind:"network",networkId:G}}return{kind:"ground"}},[]),$=x.useMemo(()=>k.kind!=="dragging"&&k.kind!=="settling"?null:ge(k.payload,k.target,M),[k,M]),K=x.useCallback(i=>{if(!$)return null;if($.kind==="plan"){const r=k.kind==="dragging"||k.kind==="settling"?k.target:null;return r&&r.kind==="device"&&r.deviceId===i?"accept":null}if($.kind==="refused"){const r=k.kind==="dragging"||k.kind==="settling"?k.target:null;return r&&r.kind==="device"&&r.deviceId===i?"refuse":null}return null},[$,k]),ne=x.useCallback((i,r)=>{if(!o||i.button!==0)return;f.current=!1;const b=r.locality==="local"?s.selfDeviceId??"":r.owner_device,A=M.devices.get(b),H={session:r,ownerDeviceId:b,ownerLabel:A?.label??r.owner_device_name};try{i.currentTarget.setPointerCapture(i.pointerId)}catch{}T(G=>Q(G,{kind:"press",payload:H,x:i.clientX,y:i.clientY,pointerId:i.pointerId}))},[o,M,s.selfDeviceId]),ae=i=>{if(k.kind==="pressing"||k.kind==="dragging"){const r=te(i.clientX,i.clientY);de.current=r,T(b=>Q(b,{kind:"move",x:i.clientX,y:i.clientY,target:r}));return}V(i)},ce=i=>{if(ue(i),k.kind!=="pressing"&&k.kind!=="dragging")return;if(k.kind==="pressing"){T(b=>Q(b,{kind:"cancel"}));return}const r=ge(k.payload,k.target,M);f.current=!0,T(b=>Q(b,{kind:"release"})),r.kind==="plan"?v({plan:r.plan,alternatives:r.alternatives,risky:r.risky}):r.kind==="refused"&&j({code:r.code,sentence:r.sentence,reach:r.reach,remedy:r.remedy,plan:r.plan??null}),T(b=>Q(b,{kind:"settled"}))};x.useEffect(()=>()=>T(ve),[]);const ie=x.useCallback(()=>{y(Ae(C.bounds,c))},[C.bounds,c]);x.useEffect(()=>{const i=d.current;if(!i)return;const r=()=>{const A=i.getBoundingClientRect();h({width:A.width,height:A.height,clipWidth:i.clientWidth,clipHeight:i.clientHeight,left:A.left,top:A.top})};r();const b=new ResizeObserver(r);return b.observe(i),()=>b.disconnect()},[]),x.useEffect(()=>{E.current||c.width<=0||c.height<=0||(E.current=!0,y(Ae(C.bounds,c)))},[c,C.bounds]),x.useEffect(()=>{const i=p.current;if(p.current={width:c.width,height:c.height},!i||!E.current||c.width<=0||c.height<=0||c.width>=i.width&&c.height>=i.height||!l)return;const r=C.devices.get(l);r&&y(b=>{const A={width:c.clipWidth,height:c.clipHeight},H=Math.max(0,Math.min(A.width-C.bounds.width*b.k,A.height-C.bounds.height*b.k));return Ls(b,r,A,Math.min($s,H))})},[c,l,C]);const q=k.kind==="dragging"?{x:k.x-c.left+12,y:k.y-c.top+12}:{x:0,y:0},re=$?Ps($):null,B=x.useRef(null),w=x.useRef(null),R=x.useRef(null),O=x.useRef(null),Y=x.useCallback(()=>{R.current=null;const i=B.current,r=w.current;if(B.current=null,w.current=null,i){const b=O.current;if(!b)return;y({k:b.transform.k,tx:b.transform.tx+(i.x-b.x),ty:b.transform.ty+(i.y-b.y)});return}r&&y(b=>je(b,{x:r.x,y:r.y},b.k*Math.exp(-r.deltaY*Mt)))},[]),z=x.useCallback(()=>{R.current===null&&(R.current=requestAnimationFrame(Y))},[Y]);x.useEffect(()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},[]);const Z=i=>{!(i.target===i.currentTarget)&&i.button!==1||i.button!==0&&i.button!==1||(O.current={x:i.clientX,y:i.clientY,transform:I},i.currentTarget.setPointerCapture(i.pointerId),i.preventDefault())},V=i=>{O.current&&(B.current={x:i.clientX,y:i.clientY},z())},ue=i=>{O.current&&(O.current=null,B.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId))},J=x.useCallback(i=>{if(i.deltaY===0)return;i.preventDefault();const r=i.currentTarget.getBoundingClientRect();w.current={x:i.clientX-r.left,y:i.clientY-r.top,deltaY:i.deltaY},z()},[z]);x.useEffect(()=>{const i=d.current;if(i)return i.addEventListener("wheel",J,{passive:!1}),()=>i.removeEventListener("wheel",J)},[J]);const le=i=>{const r=i.shiftKey?ze*4:ze;switch(i.key){case"Escape":if(k.kind!=="pressing"&&k.kind!=="dragging")return;i.preventDefault(),k.kind==="dragging"&&(f.current=!0),T(b=>Q(b,{kind:"cancel"}));return;case"0":i.preventDefault(),ie();return;case"+":case"=":i.preventDefault(),y(b=>je(b,{x:c.width/2,y:c.height/2},b.k*He));return;case"-":case"_":i.preventDefault(),y(b=>je(b,{x:c.width/2,y:c.height/2},b.k/He));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{i.preventDefault();const b=i.key==="ArrowLeft"?r:i.key==="ArrowRight"?-r:0,A=i.key==="ArrowUp"?r:i.key==="ArrowDown"?-r:0;y(H=>({...H,tx:H.tx+b,ty:H.ty+A}));return}}};return e.jsxs("div",{ref:d,"data-mesh-canvas":"",role:"group","aria-labelledby":N,tabIndex:0,onPointerDown:Z,onPointerMove:ae,onPointerUp:ce,onPointerCancel:i=>{k.kind==="dragging"&&(f.current=!0),T(r=>Q(r,{kind:"cancel"})),ue(i)},"data-mesh-gesture":k.kind,"data-glass-well":"clear",onKeyDown:le,onDoubleClick:i=>{i.target===i.currentTarget&&ie()},className:L("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[e.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${I.tx}px ${I.ty}px`}}),e.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${I.tx}px, ${I.ty}px, 0) scale(${I.k})`,transformOrigin:"0 0",width:C.bounds.width,height:C.bounds.height},children:[e.jsx(St,{stacks:P,geometry:C}),e.jsx(ut,{edges:s.edges,geometry:C,selectedDeviceId:l}),e.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:s.networks.map(i=>{const r=C.networks.get(i.id);return r?e.jsx(bt,{network:i,x:r.x,y:r.y,refused:$?.kind==="refused"&&k.kind==="dragging"&&k.target.kind==="network"&&k.target.networkId===i.id},i.id):null})}),e.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:s.devices.map(i=>{const r=C.devices.get(i.id);return r?e.jsx(vt,{device:i,x:r.x,y:r.y,nowSeconds:n,selected:i.id===l,sessions:m.get(i.id)??{rows:[],shown:[],hidden:0},sessionTotal:u.get(i.id)??i.sessionCount??0,dropState:K(i.id),movingSessionId:g,draggedSessionId:ct(k),onOpen:_,onChipPointerDown:ne,onChipClick:()=>{if(f.current){f.current=!1;return}_(i.id)},onShowAllSessions:D},i.id):null})})]}),k.kind==="dragging"&&e.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:q.x,top:q.y},children:k.payload.session.name||"untitled"}),k.kind==="dragging"&&re&&e.jsx("div",{"data-mesh-indicator":"",className:L("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",$?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:q.x,maxWidth:Math.max(160,c.width-q.x-12),...q.y>c.height*.6?{bottom:Math.max(12,c.height-q.y+8)}:{top:q.y+24}},children:re})]})};function Dt(s,t,n,l){const m=n.locality==="local"?t:n.owner_device,u=[];for(const g of s)if(g.id!==m){if(g.id===t){u.push({deviceId:g.id,label:l,verb:a("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:a("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}u.push({deviceId:g.id,label:g.label,verb:a("ui.mesh.mesh_card.move_to",{device:g.label}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:g.label})})}return u}function Rt(s,t,n){return Dt(s.devices,s.selfDeviceId,t,n)}function es(s,t,n){const l=Rt(s,t,n),m={selfDeviceId:s.selfDeviceId,devices:new Map(s.devices.map(o=>[o.id,o])),networks:new Map(s.networks.map(o=>[o.id,o]))},u=t.locality==="local"?s.selfDeviceId??"":t.owner_device,g=m.devices.get(u);return l.map(o=>{const _=ge({session:t,ownerDeviceId:u,ownerLabel:g?.label??t.owner_device_name},{kind:"device",deviceId:o.deviceId},m);return{...o,refused:_.kind==="refused"&&_.code!=="busy"?_.sentence:null}})}const ss=({session:s,destinations:t,disabled:n,onChoose:l,onOpenChange:m,trigger:u,triggerLabel:g})=>(F(),e.jsxs(ms,{onOpenChange:m,children:[e.jsx(hs,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":g,"data-mesh-session-menu":s.id,disabled:n||t.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:u})}),e.jsxs(ps,{align:"start",className:"min-w-56",children:[e.jsx(xs,{children:se(s)}),e.jsx(Ee,{}),t.map(o=>e.jsx(De,{"data-mesh-move-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>l(o,!1),children:o.verb},o.deviceId)),e.jsx(Ee,{}),t.map(o=>e.jsx(De,{"data-mesh-copy-to":o.deviceId,disabled:!!o.refused,title:o.refused??void 0,onSelect:()=>l(o,!0),children:o.keepVerb},`keep-${o.deviceId}`))]})]})),At=({device:s,sessions:t,sessionTotal:n,nowSeconds:l,destinationsFor:m,movingSessionId:u,canMove:g,canInvite:o,onClose:_,onMove:v,onShowInList:j,onInvite:D,onRemoveMember:N})=>{F();const d=ee(s),c=Be(s),h=s.reachable?[]:s.attempts??[];x.useEffect(()=>{const f=p=>{p.key!=="Escape"||p.defaultPrevented||p.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${s.id}"]`)?.focus(),_())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s.id,_]);const I=s.sessionCount===null?Ue(null):a("ui.mesh.mesh_card.conversation_count",{count:s.sessionCount}),y=s.suspect?Ye():[I,pe(d)].filter(Boolean).join(" · "),E=n>t.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:t.rows.length,total:n}):`${t.rows.length}`;return e.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:s.label}),"data-mesh-panel":s.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[e.jsxs("header",{className:"flex flex-col gap-1",children:[e.jsx(U,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:_,children:a("ui.mesh.mesh_actions.close")}),e.jsx("h2",{className:"text-body-sm text-ink",children:s.label}),e.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[s.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!s.suspect&&d==="unanswered"&&e.jsx(us,{"aria-hidden":"true",className:"size-3.5 text-warning"}),y]})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.memberships")}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:s.memberships.map(f=>e.jsxs("li",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[e.jsx(Se,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),f.networkName]}),e.jsxs("span",{className:"text-meta text-ink-dim",children:[f.role||"member",f.capabilities.length>0?` · ${f.capabilities.join(", ")}`:""]}),o&&e.jsxs(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${f.networkId}:${s.id}`,onClick:()=>N(s,f.networkId),children:[a("ui.mesh.mesh_card.remove_from"),f.networkName,"…"]})]},f.networkId))}),o&&e.jsx(U,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":s.id,onClick:()=>D(s),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[e.jsxs("h3",{className:"text-meta text-ink-dim",children:[a("ui.mesh.mesh_card.conversations"),e.jsxs("span",{className:"text-ink-disabled",children:["(",ee(s)!=="self"&&ee(s)!=="reached"?Ve(null):E,")"]})]}),be(s,l)?e.jsx("p",{className:"text-meta text-warning",children:be(s,l)}):t.rows.length===0?e.jsx("p",{className:"text-meta text-ink-dim",children:s.sessionCount===null?a("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):a("ui.mesh.mesh_card.no_conversations_here")}):e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:t.rows.map(f=>e.jsxs("li",{"data-mesh-panel-session":f.id,className:L("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",u===f.id&&"border-control"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:se(f),children:se(f)}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Qe(f,s.label,ee(s))}),u===f.id?e.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):e.jsx(ss,{session:f,destinations:m(f),disabled:!g,onChoose:(p,S)=>v(f,p,S),trigger:e.jsx(Ze,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:se(f)})})]},f.id))})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.network_addresses")}),s.endpoints.length===0?e.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.no_address_published")}):e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:s.endpoints.map(f=>e.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:f}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},f))})]}),e.jsx(oe,{}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.status")}),e.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.reach")}),e.jsx("dd",{className:"m-0 text-body-sm text-ink",children:pe(d)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.last_status_frame")}),e.jsx("dd",{className:"m-0 text-body-sm text-ink",children:s.lastSeenAt===null?a("ui.mesh.mesh_card.never"):Ts(l-s.lastSeenAt)})]})]}),!s.reachable&&(c!==""||h.length>0)&&e.jsxs("div",{className:"flex flex-col gap-1",children:[c&&e.jsx("p",{className:"m-0 text-meta text-warning",children:c}),s.linkState==="handshake_refused"&&e.jsx("p",{className:"m-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.handshake_refused_hint")}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{id:`mesh-attempts-label-${s.id}`,className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.addresses_tried")}),e.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${s.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:h.map((f,p)=>{const S=Ge(f.detail);return e.jsxs("li",{"data-mesh-attempt":f.endpoint,className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:f.endpoint}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:S})]},`${f.endpoint}:${p}`)})})]})]}),!c&&h.length===0&&s.reason&&e.jsx("p",{className:"text-meta text-warning",children:s.reason})]}),e.jsx(oe,{}),e.jsx(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":s.id,onClick:()=>j(s.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},Lt=["name","chats","state"],Pt={get name(){return a("ui.mesh.mesh_list.name")},get chats(){return a("ui.mesh.mesh_list.sort_conversations")},get state(){return a("ui.mesh.mesh_list.state")}},We={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function $t(s,t){const n=[...s];switch(t){case"chats":return n.sort((l,m)=>(m.sessionCount??-1)-(l.sessionCount??-1)||l.label.localeCompare(m.label)),n;case"state":return n.sort((l,m)=>We[l.state]-We[m.state]||l.label.localeCompare(m.label)),n;default:return n.sort((l,m)=>l.label.localeCompare(m.label))}}const Fe=8;function Tt(s,t){if(s.locality==="local")return s.live_state||"here";const n=s.owner_device_name||t,l=s.live_state?` · ${s.live_state}`:"";return s.reachable?a("ui.mesh.mesh_list.on_device_state",{device:n,state:l}):a("ui.mesh.mesh_list.on_device_no_answer",{device:n})}const Ot=({graph:s,nowSeconds:t,selectedDeviceId:n,sessions:l,selfLabel:m,canMove:u,onSelect:g,onMove:o,onInvite:_,onRemove:v})=>{F();const[j,D]=x.useState("name"),N=x.useMemo(()=>s.networks.map(d=>({network:d,members:$t(s.devices.filter(c=>c.memberships.some(h=>h.networkId===d.id)),j)})),[s,j]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pe-1",children:[e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_list.sort_devices_by")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Lt.map(d=>e.jsx("button",{type:"button","aria-pressed":j===d,onClick:()=>D(d),className:L("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",j===d&&"bg-surface text-ink"),children:Pt[d]},d))})]}),N.map(({network:d,members:c})=>e.jsxs("section",{"data-mesh-network-group":d.id,className:"flex flex-col gap-2",children:[e.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:a("ui.mesh.mesh_list.epoch",{epoch:d.epoch}),children:[d.label,e.jsxs("span",{className:"text-meta text-ink-dim",children:[d.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:d.memberCount}),d.revokedCount>0?e.jsxs(e.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:d.revokedCount})]}):null]})]}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:c.map(h=>{const I=h.memberships.find(M=>M.networkId===d.id),y=h.id===n,E=l.get(h.id),f=E?.rows??[],p=E?Xe(E,h.sessionCount):h.sessionCount??0,S=ee(h),P=Be(h),C=h.reachable?[]:h.attempts??[];return e.jsxs("li",{"data-mesh-device-row":h.id,"data-mesh-state":h.state,"aria-current":y?"true":void 0,className:L("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",y&&"border-ink bg-row-selected"),children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button","data-mesh-device-open":h.id,onClick:()=>g(h.id),className:L("min-w-0 flex-1 truncate text-start text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:h.label}),e.jsxs("span",{className:L("flex shrink-0 items-center gap-1 text-meta",qe[S]),"data-mesh-reach":S,children:[h.suspect&&e.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),h.suspect?pe(S):Ke(h,t),h.suspect&&e.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ye()})]}),e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[I?.role?`${I.role} · `:"",a("ui.mesh.mesh_list.member")]})]}),(P!==""||C.length>0)&&!h.reachable&&e.jsxs("div",{className:"flex flex-col gap-0.5",children:[P&&e.jsx("span",{className:"text-meta text-warning",children:P}),C.map((M,k)=>{const T=Ge(M.detail);return e.jsx("span",{"data-mesh-attempt":M.endpoint,className:"text-meta text-ink-dim",children:T?`${M.endpoint} — ${T}`:M.endpoint},`${M.endpoint}:${k}`)})]}),be(h,t)?e.jsxs("span",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_card.conversations")," (",Ve(null),") ·"," ",be(h,t)]}):f.length>0?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"my-1"}),e.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:f.slice(0,Fe).map(M=>e.jsxs("li",{"data-mesh-row-session":M.id,className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:M.name||M.id}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Tt(M,m)}),e.jsx(ss,{session:M,destinations:es(s,M,m),disabled:!u,onChoose:(k,T)=>o(M,k,T),trigger:e.jsx(Ze,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:M.name||M.id})})]},M.id))}),p>f.slice(0,Fe).length&&e.jsx("button",{type:"button",onClick:()=>g(h.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:p})})]}):e.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:p})}),(I||h.state!=="self")&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(U,{size:"sm",variant:"ghost","data-mesh-invite":h.id,onClick:()=>_({deviceId:h.id,deviceLabel:h.label}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),I&&e.jsxs(U,{size:"sm",variant:"ghost","data-mesh-remove-member":`${d.id}:${h.id}`,onClick:()=>v({networkId:d.id,networkLabel:d.label,deviceId:h.id,deviceLabel:h.label}),children:[a("ui.mesh.mesh_card.remove_from"),d.label,"…"]})]})]},h.id)})})]},d.id)),s.unmatchedPeers.length>0&&e.jsxs("p",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_graph.device_count",{count:s.unmatchedPeers.length})," ",a("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},zt=({revoked:s})=>{if(s.length===0)return null;const t=a("ui.mesh.mesh_list.revoked_count",{count:s.length});return e.jsx(Ce,{className:"contents",chevron:"trailing",chevronClassName:"text-ink-dim",rowClassName:"min-h-auto py-0",triggerClassName:"inline-flex w-auto items-center gap-1 align-baseline text-meta text-ink-dim hover:text-ink",triggerData:{"data-mesh-revoked-toggle":""},triggerLabel:a("ui.mesh.mesh_list.revoked_toggle_label"),summary:e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block whitespace-pre",children:" · "}),t]}),children:e.jsx("ul",{"data-mesh-revoked":"",className:"m-0 flex list-none flex-col gap-1 p-0",children:s.map(n=>e.jsxs("li",{"data-mesh-revoked-member":n.deviceId,className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-dim",children:[e.jsx("span",{children:n.networkName}),e.jsx("span",{className:"font-mono text-body-sm text-ink",children:n.deviceId}),e.jsx("span",{className:"text-body-sm text-ink-muted",children:n.label}),e.jsxs("span",{children:[n.role?`${n.role} · `:"",a("ui.mesh.mesh_graph.revoked_membership")]})]},`${n.networkId}:${n.deviceId}`))})})},Ht=["canvas","list"],Wt={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},Ft=({state:s,initialPresentation:t="canvas",graph:n,nowSeconds:l,checking:m,staleError:u,onRetry:g,approvals:o,sessions:_,sessionError:v,selfLabel:j,movingSessionId:D,canMove:N,pendingMove:d,onAskMove:c,onDropRefused:h,onChooseMove:I,onCancelMove:y,moveBusy:E,moveReport:f,onDismissReport:p,onWaitForIdle:S,onUndoCopy:P,invite:C,onOpenInvite:M,onInvite:k,onCloseInvite:T,inviteBusy:de,inviteReceipt:te,inviteRefusal:$,remove:K,onOpenRemove:ne,onRemove:ae,onCloseRemove:ce,removeBusy:ie,removeRefusal:q,removed:re})=>{F();const[B,w]=x.useState(t),[R,O]=x.useState(null),Y=n?Os(n):"",z="mesh-summary",Z=zs(n),V=Hs(n,_,n?.selfDeviceId??null),ue=x.useMemo(()=>{const r=new Map;for(const b of n?.devices??[]){const A=V.byDevice.get(b.id);r.set(b.id,A?Xe(A,b.sessionCount):b.sessionCount??0)}return r},[n,V]),J=x.useCallback(r=>{O(r)},[]),le=n?n.devices.find(r=>r.id===R)??null:null,i=x.useCallback((r,b,A)=>{if(!n)return null;const H={selfDeviceId:n.selfDeviceId,devices:new Map(n.devices.map(X=>[X.id,X])),networks:new Map(n.networks.map(X=>[X.id,X]))},G=r.locality==="local"?n.selfDeviceId??"":r.owner_device,ts=H.devices.get(G),W=ge({session:r,ownerDeviceId:G,ownerLabel:ts?.label??r.owner_device_name},{kind:"device",deviceId:b.deviceId},H);if(W.kind==="refused")return h({code:W.code,sentence:W.sentence,reach:W.reach,remedy:W.remedy,plan:W.plan??null}),null;if(W.kind==="none")return null;const Me=A?W.alternatives.find(X=>X.keep)??W.plan:W.plan,ns=[W.plan,...W.alternatives].filter(X=>X.keep!==Me.keep),as={plan:Me,alternatives:ns,risky:W.risky};c(as)},[n,c,h]);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[e.jsx(cs,{title:a("ui.mesh.mesh_page.mesh"),icon:Se,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[m&&e.jsx("output",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.checking")}),(s.kind==="ready"||s.kind==="loading")&&e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:a("ui.mesh.mesh_page.presentation")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Ht.map(r=>e.jsx("button",{type:"button","data-mesh-presentation":r,"aria-pressed":B===r,disabled:s.kind!=="ready",onClick:()=>w(r),className:L("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",B===r&&"bg-surface text-ink"),children:Wt[r]},r))})]})]})}),e.jsx(ot,{rows:o.rows,error:o.error,pending:o.pending,refusal:o.decisionRefusal,onDecide:o.onDecide,onRetry:o.onRetry,nowSeconds:o.nowSeconds,networkNames:new Map((n?.networks??[]).map(r=>[r.id,r.label]))}),s.kind==="loading"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[e.jsx(Re,{className:"h-4 w-64"}),e.jsx(Re,{className:"min-h-40 w-full flex-1"})]}),s.kind==="error"&&e.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[e.jsx("p",{children:s.message}),e.jsx(U,{variant:"secondary",size:"sm",onClick:g,className:"w-fit",children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),s.kind==="empty"&&e.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("h2",{className:"text-heading text-ink",children:a("ui.mesh.mesh_page.no_network_on_this_device")}),e.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:a("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),e.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),e.jsx("p",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),s.kind==="ready"&&n&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{id:z,className:"text-meta text-ink-muted","data-mesh-summary":"",children:[e.jsx("span",{children:Y}),e.jsx(zt,{revoked:n.revoked})]}),u&&e.jsx(fe,{variant:"warning",children:e.jsx("p",{children:u})}),v&&e.jsx(fe,{variant:"warning",children:e.jsx("p",{children:v})}),f&&e.jsx(Ws,{receipt:f.kind==="moved"?{verb:f.verb,detail:f.detail,undo:f.undo}:null,refusal:f.kind==="refused"?f.refusal:null,canWait:f.kind==="refused"&&f.plan!==null,onWait:S,onRecheck:g,onUndo:P,onDismiss:p,pending:E}),B==="canvas"?e.jsx(Et,{graph:n,slots:Z,nowSeconds:l,selectedDeviceId:R,sessions:V.byDevice,sessionTotals:ue,movingSessionId:D,canMove:N,onOpenDevice:J,onAskMove:c,onDropRefused:h,onShowAllSessions:J,summaryId:z}):e.jsx(Ot,{graph:n,nowSeconds:l,selectedDeviceId:R,sessions:V.byDevice,selfLabel:j,canMove:N,onSelect:J,onMove:i,onInvite:M,onRemove:ne})]}),le&&e.jsx(At,{device:le,sessions:V.byDevice.get(le.id)??{rows:[],shown:[],hidden:0},sessionTotal:ue.get(le.id)??0,nowSeconds:l,canMove:N,canInvite:s.kind==="ready",movingSessionId:D,destinationsFor:r=>es(n,r,j),onClose:()=>O(null),onMove:i,onInvite:r=>M({deviceId:r.id,deviceLabel:r.label}),onRemoveMember:(r,b)=>{const A=n.networks.find(H=>H.id===b);ne({networkId:b,networkLabel:A?.label??b,deviceId:r.id,deviceLabel:r.label})},onShowInList:r=>{J(r),w("list")}})]})}),e.jsx(Fs,{open:d!==null,plan:d?.plan??qt,alternatives:d?.alternatives??[],risky:d?.risky??!1,busy:E,onCancel:y,onChoose:I}),C&&e.jsx(qs,{open:C.open,options:C.options,deviceId:C.deviceId,deviceLabel:C.deviceLabel,onClose:T,onInvite:k,pending:de,receipt:te,refusal:$}),K&&e.jsx(Bs,{open:K.open,networkLabel:K.networkLabel,deviceLabel:K.deviceLabel,onClose:ce,onConfirm:ae,pending:ie,refusal:q,removed:re})]})},qt={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},Qt=({initialPresentation:s})=>{F();const t=os(),n=_e(t.data,"peers")==="enabled",l=_e(t.data,"session_transfer")==="enabled",m=Ys(n,{stamp:()=>ke.getState().beginAnswer()}),u=Gs(n),g=Us(n,{poll:!1,stamp:()=>ke.getState().beginAnswer()}),o=x.useMemo(()=>({peers:m,networks:u}),[m,u]),_=Ks(o),v=Vs(o),j=Xs(),D=_e(t.data,"approvals")==="enabled",N=Zs(n&&D,{poll:!1}),d=Js(),c=d.isError?{approvalId:d.variables?.approvalId??null,...Qs(d.error)}:null,h=x.useMemo(()=>Math.floor((N.dataUpdatedAt||Date.now())/1e3),[N.dataUpdatedAt]),I=ke(w=>w.settlePlacement),y=et(),E=st(),[f,p]=x.useState(null),[S,P]=x.useState(null),[C,M]=x.useState(null),[k,T]=x.useState(null),[de,te]=x.useState(null),[$,K]=x.useState(null),[ne,ae]=x.useState(null),ce=x.useMemo(()=>{const w=Math.max(m.dataUpdatedAt,u.dataUpdatedAt);return Math.floor((w||Date.now())/1e3)},[m.dataUpdatedAt,u.dataUpdatedAt]),ie=x.useCallback(()=>{m.refetch(),u.refetch(),g.refetch()},[m,u,g]),q=x.useCallback((w,R)=>{p(null);const O={sessionId:w.sessionId,to:w.to,keep:w.keep,waitS:R??w.waitS};j.mutate(O,{onSuccess:Y=>{if(Y.kind==="moved"){const{receipt:z}=Y;I(w.sessionId,z);const Z=z.locality==="local"?a("ui.mesh.mesh_drop.this_device"):v?.devices.find(V=>V.id===z.owner_device)?.label??z.owner_device;P({kind:"moved",verb:z.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:z.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:Z,suffix:z.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:Z,retirement:z.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:z.mode==="keep"?{sessionId:z.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:Z}),waitS:0,lost:tt(Z,a("ui.mesh.mesh_drop.this_device"))}:null});return}P({kind:"refused",refusal:Y.refusal,plan:w})},onError:()=>{P({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:w})}})},[v,j,I]),re=x.useMemo(()=>{if(!v)return[];const w=C?.deviceId,R=w?v.devices.find(O=>O.id===w):void 0;return v.networks.filter(O=>R?!R.memberships.some(Y=>Y.networkId===O.id):!0).map(O=>({id:O.id,label:O.label}))},[v,C]);if(!n)return e.jsx(ds,{to:"/chat",replace:!0});const B=_.kind==="ready"?m.error?me(m.error):u.error?me(u.error):null:null;return e.jsx(Ft,{initialPresentation:s,state:_,graph:v,nowSeconds:ce,checking:m.isFetching||u.isFetching,staleError:B,onRetry:ie,approvals:{rows:N.data??[],error:N.isError?nt(N.error):null,pending:d.isPending?d.variables??null:null,decisionRefusal:c,onDecide:(w,R)=>d.mutate({approvalId:w,decision:R}),onRetry:()=>void N.refetch(),nowSeconds:h},sessions:g.data?.rows??[],movingSessionId:j.isPending?j.variables?.sessionId??null:null,sessionError:g.isError?me(g.error):null,selfLabel:v?.devices.find(w=>w.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:l,pendingMove:f,onAskMove:p,onDropRefused:w=>P({kind:"refused",refusal:{code:w.code,sentence:w.sentence,reach:w.reach,status:null,unconfirmed:!1},plan:w.plan}),onChooseMove:w=>q(w),onCancelMove:()=>p(null),moveBusy:j.isPending,moveReport:S,onDismissReport:()=>P(null),onWaitForIdle:()=>{S?.kind!=="refused"||!S.plan||q(S.plan,Bt)},onUndoCopy:()=>{S?.kind!=="moved"||!S.undo||p({plan:S.undo,alternatives:[],risky:!1})},invite:C===null?null:{open:!0,deviceId:C.deviceId,deviceLabel:C.deviceLabel,options:re},onOpenInvite:w=>{T(null),te(null),M(w)},onInvite:w=>{y.mutate(w,{onSuccess:R=>T(R),onError:R=>te({code:"invite_refused",sentence:me(R),status:null,unconfirmed:!1})})},onCloseInvite:()=>M(null),inviteBusy:y.isPending,inviteReceipt:k,inviteRefusal:de,remove:$===null?null:{open:!0,networkId:$.networkId,networkLabel:$.networkLabel,deviceId:$.deviceId,deviceLabel:$.deviceLabel},onOpenRemove:w=>{ae(null),K(w)},onRemove:w=>{$&&E.mutate({networkId:$.networkId,deviceId:$.deviceId,confirm:w},{onSuccess:R=>ae(R)})},onCloseRemove:()=>K(null),removeBusy:E.isPending,removeRefusal:E.isError?{code:"remove_refused",sentence:me(E.error),status:null,unconfirmed:!1}:null,removed:ne})},Bt=300;export{Qt as MeshPage,Ft as MeshSurface,Qt as default};
@@ -1 +1 @@
1
- import{r as f,j as i,c as _}from"./index-DhltrflG.js";import{u as w,b as D,h as P,c as C,d as I,H as W,e as E}from"./index-wz2cjW5P.js";import{u as v,B as m,C as F,D as H,a as O,b as R,d as S,e as z,f as B}from"./error-boundary-CqZRoe9S.js";import{t as a}from"./messages-Cq_3N7VC.js";import{D as $}from"./path-utils-BkJr3--b.js";const k=e=>e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2),M={available:"border-hairline",updating:"border-hairline",applied:"border-hairline",review:"border-warning-border",failed:"border-danger-border"};function T(e){const s=[];for(const o of e??[])for(const d of o.fields??[])for(const t of d.regions??[])(t.provenance==="unresolved"||k(t.local)!==k(t.remote))&&s.push({field:d.field,region:t});return s}function A({regions:e}){return v(),e.length?i.jsx("ul",{className:"space-y-3","data-testid":"hub-update-preview",children:e.map(({field:s,region:o},d)=>i.jsxs("li",{className:"space-y-1 text-meta",children:[i.jsx("p",{className:"font-medium text-ink",children:o.heading||o.name||s}),i.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.local")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.local)||a("ui.agents.navigation.updates.preview.nothing")})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.remote")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.remote)||a("ui.agents.navigation.updates.preview.nothing")})]})]})]},`${s}:${o.id??d}`))}):i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.preview.empty")})}function V({kind:e,name:s,enabled:o}){v();const d=w(o),t=D(),[x,h]=f.useState(null),p=C(e,s),b=P(d.data).get(p),l=I(b),c=t.notes[p],n=t.pending.has(p);if(!b||!l)return c?i.jsx("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:"mb-8 rounded-md border border-hairline p-3 text-body-sm",children:i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-danger":"text-ink",children:c.message})}):null;const u=l.kind==="review",r=b.classification==="baseline-unknown",g=j=>({prefer:j,acknowledgeUnknownBaseline:r}),N=async()=>{const j=await t.applyItem(e,s,{...g(),dryRun:!0});h(j??[])};return i.jsxs("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:_("mb-8 space-y-2 rounded-md border p-3 text-body-sm",M[l.kind]),children:[i.jsxs("p",{className:"flex items-start gap-2 text-ink",children:[i.jsx(W,{mark:l,className:"mt-0.5"}),i.jsx("span",{className:_(l.kind==="failed"&&"text-danger"),children:E(b,l)})]}),t.upgradeMessage&&i.jsx("output",{className:"block text-meta text-warning","data-hub-core-upgrade":!0,children:t.upgradeMessage}),u&&r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.baseline_unknown")}),u&&!r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.merge_guidance")}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.kind==="available"&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s),children:n?a("ui.agents.navigation.updates.action.updating"):a("ui.agents.navigation.updates.action.update")}),l.kind==="failed"&&l.retryable&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.retryItem(e,s),children:n?a("ui.agents.navigation.updates.action.retrying"):a("ui.agents.navigation.updates.action.retry")}),u&&i.jsxs(i.Fragment,{children:[i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void N(),children:n&&!x?a("ui.agents.navigation.updates.action.loading"):a("ui.agents.navigation.updates.action.preview")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("local")),children:a("ui.agents.navigation.updates.action.keep_local")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("remote")),children:a("ui.agents.navigation.updates.action.use_remote")})]})]}),x&&u&&i.jsx(A,{regions:T(x)}),c&&i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-meta text-danger":"text-meta text-ink-muted",children:c.message})]})}const X=()=>({subscribe:!0,autoPush:!1,confirmPublicEgress:!1});function Y({value:e,onChange:s,source:o,item:d,visibility:t,organization:x,destinationKey:h,canEnableAutoPush:p,disabled:b=!1}){v();const l=f.useId(),c=f.useRef(null),[n,u]=f.useState(null);return f.useEffect(()=>{n!==null&&n!==h&&u(null)},[n,h]),i.jsxs("div",{className:"flex flex-col gap-3","data-initial-hub-policy":!0,children:[i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.initial_policy_description")}),["subscribe","autoPush"].map(r=>i.jsxs("label",{htmlFor:`${l}-${r}`,className:"flex items-start gap-3 text-body-sm text-ink",children:[i.jsx(F,{id:`${l}-${r}`,checked:e[r],disabled:b||r==="autoPush"&&!p&&!e.autoPush,onCheckedChange:g=>{r==="subscribe"?s({...e,subscribe:g===!0}):g!==!0?s({...e,autoPush:!1,confirmPublicEgress:!1}):p&&u(h)}}),i.jsxs("span",{children:[i.jsx("span",{className:"block",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe":"ui.hub.subscriptions.auto_push")}),i.jsx("span",{className:"block text-meta text-ink-muted",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe_description":"ui.hub.subscriptions.auto_push_description",{source:o})})]})]},r)),!p&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.subscriptions.unsupported")}),i.jsx(H,{open:n!==null,onOpenChange:r=>{r||u(null)},children:i.jsxs(O,{onOpenAutoFocus:r=>{r.preventDefault(),c.current?.focus()},children:[i.jsxs(R,{children:[i.jsx(S,{children:a("ui.hub.subscriptions.enable_title",{source:o})}),i.jsx(z,{children:t==="public"?a("ui.hub.subscriptions.enable_public",{item:d}):a("ui.hub.subscriptions.enable_private",{item:d,organization:x??o})})]}),i.jsx("p",{className:"text-body-sm text-ink-muted",children:a("ui.hub.subscriptions.enable_safety")}),i.jsxs(B,{children:[i.jsx(m,{ref:c,"data-testid":"hub-policy-cancel",variant:"outline",onClick:()=>u(null),children:a("ui.hub.subscriptions.cancel")}),i.jsx(m,{"data-testid":"hub-policy-enable",disabled:b||!p||n!==h,onClick:()=>{s({...e,autoPush:!0,confirmPublicEgress:t==="public"}),u(null)},children:a("ui.hub.subscriptions.enable")})]})]})})]})}function Z(e,s,o=Date.now()){return e.can_confirm===!0&&e.kind==="skill"&&e.direction==="push"&&e.publication==="create"&&e.proposal?.kind==="skill"&&e.proposal.fields?.document_version===1&&e.preview_receipt.length>0&&e.local_fingerprint.length>0&&e.draft_fingerprint.length>0&&e.proposal_fingerprint.length>0&&e.source_skill===s.sourceSkill&&e.local_alias===s.localAlias&&e.visibility===s.visibility&&e.tenant_id===s.tenantId&&e.policy?.subscribe===s.subscribe&&e.policy?.auto_push===s.autoPush&&e.policy?.confirm_public_egress===s.confirmPublicEgress&&Number.isFinite(Date.parse(e.expires_at))&&Date.parse(e.expires_at)>o}function K(e){return e.local_link_receipt?.state==="complete"&&!!e.link&&e.local_link_receipt.link_id===e.link.link_id&&typeof e.link.policy?.subscribe=="boolean"&&typeof e.link.policy.auto_push=="boolean"&&typeof e.link.policy.revision=="string"&&e.link.policy.revision.length>0}const U=e=>e==="active"||e==="past_due",y=e=>e.status!=="active"?"no_access":U(e.plan.status)?"available":"plan_inactive",ee=e=>e.filter(s=>y(s)==="available"),ie=e=>e.filter(s=>y(s)==="plan_inactive"),se=e=>{if(!(e instanceof $))return null;switch(e.code){case"team_plan_required":return"plan";case"not_a_member":case"insufficient_role":return"no_access";default:return null}};export{Y as H,V as a,ie as b,Z as i,X as n,se as o,K as p,ee as u};
1
+ import{r as f,j as i,c as _}from"./index-DhltrflG.js";import{u as w,b as D,h as P,c as C,d as I,H as W,e as E}from"./index-CRQJfecC.js";import{u as v,B as m,C as F,D as H,a as O,b as R,d as S,e as z,f as B}from"./error-boundary-CqZRoe9S.js";import{t as a}from"./messages-Cq_3N7VC.js";import{D as $}from"./path-utils-BkJr3--b.js";const k=e=>e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2),M={available:"border-hairline",updating:"border-hairline",applied:"border-hairline",review:"border-warning-border",failed:"border-danger-border"};function T(e){const s=[];for(const o of e??[])for(const d of o.fields??[])for(const t of d.regions??[])(t.provenance==="unresolved"||k(t.local)!==k(t.remote))&&s.push({field:d.field,region:t});return s}function A({regions:e}){return v(),e.length?i.jsx("ul",{className:"space-y-3","data-testid":"hub-update-preview",children:e.map(({field:s,region:o},d)=>i.jsxs("li",{className:"space-y-1 text-meta",children:[i.jsx("p",{className:"font-medium text-ink",children:o.heading||o.name||s}),i.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.local")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.local)||a("ui.agents.navigation.updates.preview.nothing")})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.remote")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.remote)||a("ui.agents.navigation.updates.preview.nothing")})]})]})]},`${s}:${o.id??d}`))}):i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.preview.empty")})}function V({kind:e,name:s,enabled:o}){v();const d=w(o),t=D(),[x,h]=f.useState(null),p=C(e,s),b=P(d.data).get(p),l=I(b),c=t.notes[p],n=t.pending.has(p);if(!b||!l)return c?i.jsx("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:"mb-8 rounded-md border border-hairline p-3 text-body-sm",children:i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-danger":"text-ink",children:c.message})}):null;const u=l.kind==="review",r=b.classification==="baseline-unknown",g=j=>({prefer:j,acknowledgeUnknownBaseline:r}),N=async()=>{const j=await t.applyItem(e,s,{...g(),dryRun:!0});h(j??[])};return i.jsxs("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:_("mb-8 space-y-2 rounded-md border p-3 text-body-sm",M[l.kind]),children:[i.jsxs("p",{className:"flex items-start gap-2 text-ink",children:[i.jsx(W,{mark:l,className:"mt-0.5"}),i.jsx("span",{className:_(l.kind==="failed"&&"text-danger"),children:E(b,l)})]}),t.upgradeMessage&&i.jsx("output",{className:"block text-meta text-warning","data-hub-core-upgrade":!0,children:t.upgradeMessage}),u&&r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.baseline_unknown")}),u&&!r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.merge_guidance")}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.kind==="available"&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s),children:n?a("ui.agents.navigation.updates.action.updating"):a("ui.agents.navigation.updates.action.update")}),l.kind==="failed"&&l.retryable&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.retryItem(e,s),children:n?a("ui.agents.navigation.updates.action.retrying"):a("ui.agents.navigation.updates.action.retry")}),u&&i.jsxs(i.Fragment,{children:[i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void N(),children:n&&!x?a("ui.agents.navigation.updates.action.loading"):a("ui.agents.navigation.updates.action.preview")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("local")),children:a("ui.agents.navigation.updates.action.keep_local")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("remote")),children:a("ui.agents.navigation.updates.action.use_remote")})]})]}),x&&u&&i.jsx(A,{regions:T(x)}),c&&i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-meta text-danger":"text-meta text-ink-muted",children:c.message})]})}const X=()=>({subscribe:!0,autoPush:!1,confirmPublicEgress:!1});function Y({value:e,onChange:s,source:o,item:d,visibility:t,organization:x,destinationKey:h,canEnableAutoPush:p,disabled:b=!1}){v();const l=f.useId(),c=f.useRef(null),[n,u]=f.useState(null);return f.useEffect(()=>{n!==null&&n!==h&&u(null)},[n,h]),i.jsxs("div",{className:"flex flex-col gap-3","data-initial-hub-policy":!0,children:[i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.initial_policy_description")}),["subscribe","autoPush"].map(r=>i.jsxs("label",{htmlFor:`${l}-${r}`,className:"flex items-start gap-3 text-body-sm text-ink",children:[i.jsx(F,{id:`${l}-${r}`,checked:e[r],disabled:b||r==="autoPush"&&!p&&!e.autoPush,onCheckedChange:g=>{r==="subscribe"?s({...e,subscribe:g===!0}):g!==!0?s({...e,autoPush:!1,confirmPublicEgress:!1}):p&&u(h)}}),i.jsxs("span",{children:[i.jsx("span",{className:"block",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe":"ui.hub.subscriptions.auto_push")}),i.jsx("span",{className:"block text-meta text-ink-muted",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe_description":"ui.hub.subscriptions.auto_push_description",{source:o})})]})]},r)),!p&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.subscriptions.unsupported")}),i.jsx(H,{open:n!==null,onOpenChange:r=>{r||u(null)},children:i.jsxs(O,{onOpenAutoFocus:r=>{r.preventDefault(),c.current?.focus()},children:[i.jsxs(R,{children:[i.jsx(S,{children:a("ui.hub.subscriptions.enable_title",{source:o})}),i.jsx(z,{children:t==="public"?a("ui.hub.subscriptions.enable_public",{item:d}):a("ui.hub.subscriptions.enable_private",{item:d,organization:x??o})})]}),i.jsx("p",{className:"text-body-sm text-ink-muted",children:a("ui.hub.subscriptions.enable_safety")}),i.jsxs(B,{children:[i.jsx(m,{ref:c,"data-testid":"hub-policy-cancel",variant:"outline",onClick:()=>u(null),children:a("ui.hub.subscriptions.cancel")}),i.jsx(m,{"data-testid":"hub-policy-enable",disabled:b||!p||n!==h,onClick:()=>{s({...e,autoPush:!0,confirmPublicEgress:t==="public"}),u(null)},children:a("ui.hub.subscriptions.enable")})]})]})})]})}function Z(e,s,o=Date.now()){return e.can_confirm===!0&&e.kind==="skill"&&e.direction==="push"&&e.publication==="create"&&e.proposal?.kind==="skill"&&e.proposal.fields?.document_version===1&&e.preview_receipt.length>0&&e.local_fingerprint.length>0&&e.draft_fingerprint.length>0&&e.proposal_fingerprint.length>0&&e.source_skill===s.sourceSkill&&e.local_alias===s.localAlias&&e.visibility===s.visibility&&e.tenant_id===s.tenantId&&e.policy?.subscribe===s.subscribe&&e.policy?.auto_push===s.autoPush&&e.policy?.confirm_public_egress===s.confirmPublicEgress&&Number.isFinite(Date.parse(e.expires_at))&&Date.parse(e.expires_at)>o}function K(e){return e.local_link_receipt?.state==="complete"&&!!e.link&&e.local_link_receipt.link_id===e.link.link_id&&typeof e.link.policy?.subscribe=="boolean"&&typeof e.link.policy.auto_push=="boolean"&&typeof e.link.policy.revision=="string"&&e.link.policy.revision.length>0}const U=e=>e==="active"||e==="past_due",y=e=>e.status!=="active"?"no_access":U(e.plan.status)?"available":"plan_inactive",ee=e=>e.filter(s=>y(s)==="available"),ie=e=>e.filter(s=>y(s)==="plan_inactive"),se=e=>{if(!(e instanceof $))return null;switch(e.code){case"team_plan_required":return"plan";case"not_a_member":case"insufficient_role":return"no_access";default:return null}};export{Y as H,V as a,ie as b,Z as i,X as n,se as o,K as p,ee as u};
@@ -1,4 +1,4 @@
1
- import{j as t,c as R,r as d,u as qn}from"./index-DhltrflG.js";import{t as n,b as $e}from"./messages-Cq_3N7VC.js";import{aq as ze,bT as V,bh as Rt,bi as Bn,bU as $s,bV as zs,bW as Gs,bm as Un,ar as ve,bX as $n,aA as Cr,S as _t,av as Xe,bY as zn,bz as Gn,be as Yn,bf as Hn,bg as Kn,ax as Er,aw as Dt,aZ as Wn,ag as Vn,b4 as Xn,b8 as Jn,b7 as Qn,b6 as Ys,bR as Zn,bB as ea,by as ta,bA as sa,T as le,bZ as Tr,b_ as Rr,bH as qt,b$ as Be,c0 as ra,c1 as jt,bL as na,bM as Hs,c2 as ht,c3 as Dr,bI as aa,c4 as oa,c5 as Ar,as as ia,a7 as ca,a8 as la,a9 as ua,aa as da,ab as pa,c6 as ma,c7 as Or,bc as fa,c8 as _a,af as ja}from"./conversation-input-sync-BXv32NfB.js";import{h as gs,d as _e,a8 as ha,r as xs,u as ga,aa as xa,ab as ba,ac as Je,ad as va,D as Bt,a as nt,c as ye,A as Ut,ae as ts,q as At,s as ya,o as wa,t as ka,y as Na,B as Sa,L as Ca}from"./path-utils-BkJr3--b.js";import{c as gt,u as I,F as Qe,l as $t,G as Ze,H as et,J as tt,K as Pe,B as G,q as bs,r as vs,S as Te,s as ys,w as be,a9 as Ea,aa as Ta,ab as Ra,$ as Da,a0 as Aa,v as Oa,z as ke,a5 as ws,af as ks,a7 as Ns,I as ue,X as zt,g as Ss,T as Pr,L as pe,N as Mr,C as Lr,D as Pa,a as Ma,d as La,A as ss,O as Ia,Y as Fa,Z as qa,_ as Ba,k as Ke}from"./error-boundary-CqZRoe9S.js";import{P as Ks}from"./page-header-B3bOo0UX.js";import{cx as Ua,ce as Ir,cy as $a,cz as za,cm as Ga,b_ as Ya,aL as pt,cA as Ha,A as Ws,bj as Fr,cB as Vs,cw as Ka}from"./index-wz2cjW5P.js";import{o as qr}from"./console-mirror-BiiClM8r.js";import{u as Wa}from"./use-session-snapshot-0k6Oot8j.js";/**
1
+ import{j as t,c as R,r as d,u as qn}from"./index-DhltrflG.js";import{t as n,b as $e}from"./messages-Cq_3N7VC.js";import{aq as ze,bT as V,bh as Rt,bi as Bn,bU as $s,bV as zs,bW as Gs,bm as Un,ar as ve,bX as $n,aA as Cr,S as _t,av as Xe,bY as zn,bz as Gn,be as Yn,bf as Hn,bg as Kn,ax as Er,aw as Dt,aZ as Wn,ag as Vn,b4 as Xn,b8 as Jn,b7 as Qn,b6 as Ys,bR as Zn,bB as ea,by as ta,bA as sa,T as le,bZ as Tr,b_ as Rr,bH as qt,b$ as Be,c0 as ra,c1 as jt,bL as na,bM as Hs,c2 as ht,c3 as Dr,bI as aa,c4 as oa,c5 as Ar,as as ia,a7 as ca,a8 as la,a9 as ua,aa as da,ab as pa,c6 as ma,c7 as Or,bc as fa,c8 as _a,af as ja}from"./conversation-input-sync-BXv32NfB.js";import{h as gs,d as _e,a8 as ha,r as xs,u as ga,aa as xa,ab as ba,ac as Je,ad as va,D as Bt,a as nt,c as ye,A as Ut,ae as ts,q as At,s as ya,o as wa,t as ka,y as Na,B as Sa,L as Ca}from"./path-utils-BkJr3--b.js";import{c as gt,u as I,F as Qe,l as $t,G as Ze,H as et,J as tt,K as Pe,B as G,q as bs,r as vs,S as Te,s as ys,w as be,a9 as Ea,aa as Ta,ab as Ra,$ as Da,a0 as Aa,v as Oa,z as ke,a5 as ws,af as ks,a7 as Ns,I as ue,X as zt,g as Ss,T as Pr,L as pe,N as Mr,C as Lr,D as Pa,a as Ma,d as La,A as ss,O as Ia,Y as Fa,Z as qa,_ as Ba,k as Ke}from"./error-boundary-CqZRoe9S.js";import{P as Ks}from"./page-header-B3bOo0UX.js";import{cx as Ua,ce as Ir,cy as $a,cz as za,cm as Ga,b_ as Ya,aL as pt,cA as Ha,A as Ws,bj as Fr,cB as Vs,cw as Ka}from"./index-CRQJfecC.js";import{o as qr}from"./console-mirror-BiiClM8r.js";import{u as Wa}from"./use-session-snapshot-0k6Oot8j.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{f as y,g as w,p as d,P as f,h as T,r as v,i as $,j as A,k as R,l as L}from"./path-utils-BkJr3--b.js";import{P as I,Q as P,R as N}from"./conversation-input-sync-BXv32NfB.js";import{l as S,a as E}from"./index-wz2cjW5P.js";const p={malware_or_exploitation:"Instructions to build or spread malware, or to attack systems you do not own, cannot be published.",credential_theft:"Instructions to obtain someone else's credentials or tokens cannot be published.",fraud_or_deception:"Instructions to deceive or defraud people cannot be published.",harassment_or_hate:"Instructions to harass, threaten or target people cannot be published.",sexual_content_minors:"This agent cannot be published. If you believe this is a mistake, contact support.",sexual_content:"Explicit sexual content cannot be published.",violence_or_weapons:"Instructions to build weapons or to injure people cannot be published.",drugs_or_controlled_substances:"Instructions to make or traffic illegal drugs cannot be published.",self_harm:"This agent cannot be published. If you believe this is a mistake, contact support.",mass_surveillance_or_privacy_abuse:"Instructions to surveil or profile people without their consent cannot be published.",evasion_or_abuse_tooling:"Instructions to evade or defeat safety and anti-abuse systems cannot be published.",prompt_injection:"This instruction set tries to instruct the reviewer rather than describe an agent, so it cannot be published.",unclear_dual_use:"We could not tell whether this is aimed at your own systems or someone else's. Add a sentence stating the scope and target, then publish again.",other_harmful:"This agent was rejected because its instructions would cause harm."},O=e=>{const n=e.trim();return n.length>12&&/\s/.test(n)&&!/^(not found|bad request|unauthorized|error|internal server error)\.?$/i.test(n)};function k(e){const n=e?.categories?.[0];return n&&N(n)?p[n]:p.other_harmful}function z(e,n){const t=n?.rule?` ${n.rule}`:"";switch(n?.field){case"name":return{body:`Name${t||" is not acceptable"}.`,field:"name"};case"instructions":return{body:t?`The instruction body${t}.`:`The instruction body must be between 1 and ${f} characters.`,field:"instructions"};case"description":return{body:`Description${t}.`,field:"description"};case"tools":return{body:`Tools${t}.`,field:"tools"};case"when_to_use":return{body:`When to use${t}.`,field:"when_to_use"};case"categories":return{body:`Categories${t}.`,field:"categories"};case"tags":return{body:`Tags${t}.`,field:"tags"};default:return{body:e,field:null}}}function H(e,n){const t=n.surface==="pull",a=t?"Nothing was pulled.":"Nothing was published.",o=t?"pull again":"publish again",s=n.name.trim()||(t?"this team":"this agent");switch(e.code){case"name_taken":return e.details?.owned_by_caller===!0?{variant:"danger",headline:"You already published this agent",body:`You published "${s}" already. Update that listing instead of publishing a second one.`,note:null,actions:e.details?.existing_agent_id||n.hubAgentId?["update-listing","focus-name"]:["focus-name"]}:{variant:"danger",headline:"That name is taken",body:`"${s}" is already published on the hub by another account. Agent names are unique across the hub.`,note:null,actions:["focus-name"]};case"name_claim_in_flight":return{variant:"warning",headline:"That name is being published right now",body:`Someone is publishing an agent called "${s}" at this moment. It is not claimed — try again in a moment.`,note:null,actions:["retry"]};case"name_reserved_builtin":{const i=e.details?.builtin_name,u=i?d(i)===d(s):!1;return{variant:"danger",headline:"That name is reserved",body:i&&!u?`"${s}" is reserved by the built-in agent "${i}". Built-in names cannot be published to the hub.`:`"${i??s}" is the name of a built-in agent. Built-in names cannot be published to the hub.`,note:null,actions:["focus-name","install-builtin"]}}case"moderation_rejected":return{variant:"danger",headline:"This agent was not accepted",body:e.details?.reason?.trim()||e.message,note:k(e.details),actions:["edit-instructions"]};case"moderation_unavailable":return{variant:"warning",headline:"Review is temporarily unavailable",body:"We could not review this agent just now. Nothing was published. Try again in a minute.",note:null,actions:["retry"]};case"invalid_instruction_set":{const{body:i,field:u}=z(e.message,e.details);return{variant:"danger",headline:"The agent document is not valid",body:i,note:null,actions:u==="name"?["focus-name"]:u==="instructions"?["edit-instructions"]:["edit-agent"]}}case"payload_too_large":{const i=e.details?.limit_bytes;return{variant:"danger",headline:"This agent is too large to publish",body:i?`The instruction set is larger than ${Math.round(i/1024)} KiB. Shorten the instructions.`:"The instruction set is larger than the hub accepts. Shorten the instructions.",note:null,actions:["edit-instructions"]}}case"not_owner":return{variant:"danger",headline:"You cannot update this listing",body:"This listing belongs to another account.",note:null,actions:["publish-as-new"]};case"agent_not_found":return{variant:"danger",headline:"That listing no longer exists",body:"It may have been delisted.",note:null,actions:["publish-as-new","refresh-hub"]};case"hub_unauthorized":return{variant:"danger",headline:"The hub refused this machine's sign-in",body:`${a} Sign in to Radient again to replace the credential the hub refused, then ${o}.`,note:null,actions:["sign-in"]};case"hub_unavailable":return{variant:"warning",headline:t?"The pull did not go through":"The publication did not go through",body:O(e.message)?e.message:`${a} Try again in a moment, or update the backend if the hub has moved.`,note:null,actions:["retry"]};case"local_failure":return{variant:"warning",headline:t?"The team could not be pulled from this machine":"The agent could not be published from this machine",body:e.message,note:null,actions:["retry"]};case"team_plan_required":return{variant:"warning",headline:"That organization needs an active Team plan",body:t?"Reading an organization's teams is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then pull again.":"Sharing agents inside an organization is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then publish again.",note:null,actions:["retry"]};case"not_a_member":return{variant:"danger",headline:"You are not a member of that organization",body:`${a} Ask an owner of the organization to invite you, then ${o}.`,note:null,actions:[]};case"insufficient_role":{const i=e.details?.required;return{variant:"danger",headline:"Your organization role does not allow this",body:i?`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} the ${i} role. Ask an owner of the organization to change your role, then ${o}.`:`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} a higher role than yours. Ask an owner of the organization to change your role, then ${o}.`,note:null,actions:[]}}case"team_not_found":return{variant:"danger",headline:"That team is no longer published",body:"It may have been delisted since this page was loaded.",note:null,actions:["refresh-hub"]};default:return{variant:"danger",headline:"The agent could not be published",body:e.message,note:null,actions:["retry"]}}}const C=[/^(?:Download agent from Radient failed: )?(?:Error downloading agent from Radient: )?\s*/,/^Failed to download agent(?: [^\s]+)? from Radient Agent Hub(?: due to a requests error)?:\s*/,/^[A-Za-z_][\w.]*\([^)]*\):\s*/],U=/^(\d{3})\b/,B=new Set([404,410]),q=["read timed out","connection timed out","connection refused","connection aborted","connection reset","connectionerror","connecttimeout","remote end closed connection","max retries exceeded","temporary failure in name resolution","name or service not known","no route to host"],x=e=>{const n=e.toLowerCase();return q.some(t=>n.includes(t))||P(e)},D=(e,n)=>{const t=n.trim()?`"${n.trim()}"`:"That agent";if(I(e))switch(e.code){case"agent_not_found":return`${t} is no longer on the hub, so nothing was downloaded.`;case"hub_unavailable":return`The hub did not complete the download, so ${t} was not downloaded.`;default:return`${t} was not downloaded: ${e.message}`}const a=C.reduce((s,i)=>s.replace(i,""),w(e,"").trim()).trim();if(!a)return`${t} could not be downloaded.`;const o=Number(U.exec(a)?.[1]??Number.NaN);return B.has(o)?`${t} is no longer on the hub, so nothing was downloaded.`:x(a)||o===408?`The hub could not be reached, so ${t} was not downloaded.`:o===429?`The hub is busy, so ${t} was not downloaded. Try again in a moment.`:o===401||o===403?`The hub refused this machine's sign-in, so ${t} was not downloaded.`:o>=500?`The hub could not complete the download, so ${t} was not downloaded. Try again in a moment.`:o>=400?`The hub refused the download, so ${t} is not here.`:`${t} was not downloaded: ${a}`},F="The action did not complete.",G=(e,n,t)=>e==="download"?D(n,t):y(F,n),X={"focus-name":"Choose another name","update-listing":"Update the existing listing","install-builtin":"Install the built-in instead",retry:"Try again","edit-instructions":"Edit the instructions","edit-agent":"Edit the agent","publish-as-new":"Publish as a new listing","sign-in":"Sign in again","refresh-hub":"Refresh the hub"},j="download_count",g={all:["public-agents"],list:e=>[...g.all,"list",{page:e.page,perPage:e.perPage,categories:e.categories?.join(",")??void 0,name:e.name??void 0,description:e.description??void 0,sort:e.sort,order:e.order}]},h={all:["org-agents"],list:(e,n)=>[...h.all,"list",e,{page:n.page,perPage:n.perPage,categories:n.categories?.join(",")??void 0,name:n.name??void 0,description:n.description??void 0,sort:n.sort,order:n.order}]},K=e=>e&&e[0]===h.all[0]?String(e[2]??""):null,Z=e=>e.invalidateQueries({queryKey:g.all}),J=(e,n)=>e.invalidateQueries({queryKey:n?[...h.all,"list",n]:h.all}),V=({page:e=1,perPage:n=20,enabled:t=!0,categories:a,name:o,description:s,sort:i=j,order:u="desc",tenantId:c}={})=>{const b={page:e,perPage:n,categories:a,name:o,description:s,sort:i,order:u},_=c?h.list(c,b):g.list(b),l=T({queryKey:_,queryFn:async()=>{const r={};return a&&a.length>0&&(r.categories=a.join(",")),o&&(r.name=o),s&&(r.description=s),r.sort=i,r.order=u,c?await S(c,e,n,r):await E(e,n,r)},select:r=>r.result,enabled:t,retry:v,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,placeholderData:(r,m)=>K(m?.queryKey)===(c??null)?r:void 0});return{...l,agents:l.data?.records,isRefreshing:l.isFetching&&l.data!==void 0,pagination:l.data?{page:l.data.page,perPage:l.data.per_page,totalPages:l.data.total_pages,totalRecords:l.data.total_records}:void 0}},M={name:"Name",description:"Description",instructions:"The instruction body",tools:"Tools"};function ee(e){const n=[],t=(a,o)=>{o&&n.push({field:a,message:`${M[a]} ${o}.`})};return t("name",$(e.name)),t("description",A(e.description)),e.instructions!==null&&t("instructions",R(e.instructions)),t("tools",L(e.tools??[])),n}function ne(e,n){const t=d(e);return n.some(a=>d(a)===t)}function te(e){for(const n of e??[]){const t=n.indexOf(":");if(t<0||n.slice(0,t).trim().toLowerCase()!=="tools")continue;const a=n.slice(t+1).split(",").map(o=>o.trim()).filter(Boolean);return a.length>0?a:null}return null}function ae(e,n){const t=d(e);return n.find(a=>d(a)===t)??null}export{X as P,G as a,g as b,J as c,ne as d,ee as e,Z as i,ae as l,H as p,te as t,V as u};
1
+ import{f as y,g as w,p as d,P as f,h as T,r as v,i as $,j as A,k as R,l as L}from"./path-utils-BkJr3--b.js";import{P as I,Q as P,R as N}from"./conversation-input-sync-BXv32NfB.js";import{l as S,a as E}from"./index-CRQJfecC.js";const p={malware_or_exploitation:"Instructions to build or spread malware, or to attack systems you do not own, cannot be published.",credential_theft:"Instructions to obtain someone else's credentials or tokens cannot be published.",fraud_or_deception:"Instructions to deceive or defraud people cannot be published.",harassment_or_hate:"Instructions to harass, threaten or target people cannot be published.",sexual_content_minors:"This agent cannot be published. If you believe this is a mistake, contact support.",sexual_content:"Explicit sexual content cannot be published.",violence_or_weapons:"Instructions to build weapons or to injure people cannot be published.",drugs_or_controlled_substances:"Instructions to make or traffic illegal drugs cannot be published.",self_harm:"This agent cannot be published. If you believe this is a mistake, contact support.",mass_surveillance_or_privacy_abuse:"Instructions to surveil or profile people without their consent cannot be published.",evasion_or_abuse_tooling:"Instructions to evade or defeat safety and anti-abuse systems cannot be published.",prompt_injection:"This instruction set tries to instruct the reviewer rather than describe an agent, so it cannot be published.",unclear_dual_use:"We could not tell whether this is aimed at your own systems or someone else's. Add a sentence stating the scope and target, then publish again.",other_harmful:"This agent was rejected because its instructions would cause harm."},O=e=>{const n=e.trim();return n.length>12&&/\s/.test(n)&&!/^(not found|bad request|unauthorized|error|internal server error)\.?$/i.test(n)};function k(e){const n=e?.categories?.[0];return n&&N(n)?p[n]:p.other_harmful}function z(e,n){const t=n?.rule?` ${n.rule}`:"";switch(n?.field){case"name":return{body:`Name${t||" is not acceptable"}.`,field:"name"};case"instructions":return{body:t?`The instruction body${t}.`:`The instruction body must be between 1 and ${f} characters.`,field:"instructions"};case"description":return{body:`Description${t}.`,field:"description"};case"tools":return{body:`Tools${t}.`,field:"tools"};case"when_to_use":return{body:`When to use${t}.`,field:"when_to_use"};case"categories":return{body:`Categories${t}.`,field:"categories"};case"tags":return{body:`Tags${t}.`,field:"tags"};default:return{body:e,field:null}}}function H(e,n){const t=n.surface==="pull",a=t?"Nothing was pulled.":"Nothing was published.",o=t?"pull again":"publish again",s=n.name.trim()||(t?"this team":"this agent");switch(e.code){case"name_taken":return e.details?.owned_by_caller===!0?{variant:"danger",headline:"You already published this agent",body:`You published "${s}" already. Update that listing instead of publishing a second one.`,note:null,actions:e.details?.existing_agent_id||n.hubAgentId?["update-listing","focus-name"]:["focus-name"]}:{variant:"danger",headline:"That name is taken",body:`"${s}" is already published on the hub by another account. Agent names are unique across the hub.`,note:null,actions:["focus-name"]};case"name_claim_in_flight":return{variant:"warning",headline:"That name is being published right now",body:`Someone is publishing an agent called "${s}" at this moment. It is not claimed — try again in a moment.`,note:null,actions:["retry"]};case"name_reserved_builtin":{const i=e.details?.builtin_name,u=i?d(i)===d(s):!1;return{variant:"danger",headline:"That name is reserved",body:i&&!u?`"${s}" is reserved by the built-in agent "${i}". Built-in names cannot be published to the hub.`:`"${i??s}" is the name of a built-in agent. Built-in names cannot be published to the hub.`,note:null,actions:["focus-name","install-builtin"]}}case"moderation_rejected":return{variant:"danger",headline:"This agent was not accepted",body:e.details?.reason?.trim()||e.message,note:k(e.details),actions:["edit-instructions"]};case"moderation_unavailable":return{variant:"warning",headline:"Review is temporarily unavailable",body:"We could not review this agent just now. Nothing was published. Try again in a minute.",note:null,actions:["retry"]};case"invalid_instruction_set":{const{body:i,field:u}=z(e.message,e.details);return{variant:"danger",headline:"The agent document is not valid",body:i,note:null,actions:u==="name"?["focus-name"]:u==="instructions"?["edit-instructions"]:["edit-agent"]}}case"payload_too_large":{const i=e.details?.limit_bytes;return{variant:"danger",headline:"This agent is too large to publish",body:i?`The instruction set is larger than ${Math.round(i/1024)} KiB. Shorten the instructions.`:"The instruction set is larger than the hub accepts. Shorten the instructions.",note:null,actions:["edit-instructions"]}}case"not_owner":return{variant:"danger",headline:"You cannot update this listing",body:"This listing belongs to another account.",note:null,actions:["publish-as-new"]};case"agent_not_found":return{variant:"danger",headline:"That listing no longer exists",body:"It may have been delisted.",note:null,actions:["publish-as-new","refresh-hub"]};case"hub_unauthorized":return{variant:"danger",headline:"The hub refused this machine's sign-in",body:`${a} Sign in to Radient again to replace the credential the hub refused, then ${o}.`,note:null,actions:["sign-in"]};case"hub_unavailable":return{variant:"warning",headline:t?"The pull did not go through":"The publication did not go through",body:O(e.message)?e.message:`${a} Try again in a moment, or update the backend if the hub has moved.`,note:null,actions:["retry"]};case"local_failure":return{variant:"warning",headline:t?"The team could not be pulled from this machine":"The agent could not be published from this machine",body:e.message,note:null,actions:["retry"]};case"team_plan_required":return{variant:"warning",headline:"That organization needs an active Team plan",body:t?"Reading an organization's teams is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then pull again.":"Sharing agents inside an organization is part of the Team plan. Ask an owner of the organization to activate it in the Radient console, then publish again.",note:null,actions:["retry"]};case"not_a_member":return{variant:"danger",headline:"You are not a member of that organization",body:`${a} Ask an owner of the organization to invite you, then ${o}.`,note:null,actions:[]};case"insufficient_role":{const i=e.details?.required;return{variant:"danger",headline:"Your organization role does not allow this",body:i?`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} the ${i} role. Ask an owner of the organization to change your role, then ${o}.`:`${t?"Reading an organization's teams needs":"Publishing into an organization needs"} a higher role than yours. Ask an owner of the organization to change your role, then ${o}.`,note:null,actions:[]}}case"team_not_found":return{variant:"danger",headline:"That team is no longer published",body:"It may have been delisted since this page was loaded.",note:null,actions:["refresh-hub"]};default:return{variant:"danger",headline:"The agent could not be published",body:e.message,note:null,actions:["retry"]}}}const C=[/^(?:Download agent from Radient failed: )?(?:Error downloading agent from Radient: )?\s*/,/^Failed to download agent(?: [^\s]+)? from Radient Agent Hub(?: due to a requests error)?:\s*/,/^[A-Za-z_][\w.]*\([^)]*\):\s*/],U=/^(\d{3})\b/,B=new Set([404,410]),q=["read timed out","connection timed out","connection refused","connection aborted","connection reset","connectionerror","connecttimeout","remote end closed connection","max retries exceeded","temporary failure in name resolution","name or service not known","no route to host"],x=e=>{const n=e.toLowerCase();return q.some(t=>n.includes(t))||P(e)},D=(e,n)=>{const t=n.trim()?`"${n.trim()}"`:"That agent";if(I(e))switch(e.code){case"agent_not_found":return`${t} is no longer on the hub, so nothing was downloaded.`;case"hub_unavailable":return`The hub did not complete the download, so ${t} was not downloaded.`;default:return`${t} was not downloaded: ${e.message}`}const a=C.reduce((s,i)=>s.replace(i,""),w(e,"").trim()).trim();if(!a)return`${t} could not be downloaded.`;const o=Number(U.exec(a)?.[1]??Number.NaN);return B.has(o)?`${t} is no longer on the hub, so nothing was downloaded.`:x(a)||o===408?`The hub could not be reached, so ${t} was not downloaded.`:o===429?`The hub is busy, so ${t} was not downloaded. Try again in a moment.`:o===401||o===403?`The hub refused this machine's sign-in, so ${t} was not downloaded.`:o>=500?`The hub could not complete the download, so ${t} was not downloaded. Try again in a moment.`:o>=400?`The hub refused the download, so ${t} is not here.`:`${t} was not downloaded: ${a}`},F="The action did not complete.",G=(e,n,t)=>e==="download"?D(n,t):y(F,n),X={"focus-name":"Choose another name","update-listing":"Update the existing listing","install-builtin":"Install the built-in instead",retry:"Try again","edit-instructions":"Edit the instructions","edit-agent":"Edit the agent","publish-as-new":"Publish as a new listing","sign-in":"Sign in again","refresh-hub":"Refresh the hub"},j="download_count",g={all:["public-agents"],list:e=>[...g.all,"list",{page:e.page,perPage:e.perPage,categories:e.categories?.join(",")??void 0,name:e.name??void 0,description:e.description??void 0,sort:e.sort,order:e.order}]},h={all:["org-agents"],list:(e,n)=>[...h.all,"list",e,{page:n.page,perPage:n.perPage,categories:n.categories?.join(",")??void 0,name:n.name??void 0,description:n.description??void 0,sort:n.sort,order:n.order}]},K=e=>e&&e[0]===h.all[0]?String(e[2]??""):null,Z=e=>e.invalidateQueries({queryKey:g.all}),J=(e,n)=>e.invalidateQueries({queryKey:n?[...h.all,"list",n]:h.all}),V=({page:e=1,perPage:n=20,enabled:t=!0,categories:a,name:o,description:s,sort:i=j,order:u="desc",tenantId:c}={})=>{const b={page:e,perPage:n,categories:a,name:o,description:s,sort:i,order:u},_=c?h.list(c,b):g.list(b),l=T({queryKey:_,queryFn:async()=>{const r={};return a&&a.length>0&&(r.categories=a.join(",")),o&&(r.name=o),s&&(r.description=s),r.sort=i,r.order=u,c?await S(c,e,n,r):await E(e,n,r)},select:r=>r.result,enabled:t,retry:v,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,placeholderData:(r,m)=>K(m?.queryKey)===(c??null)?r:void 0});return{...l,agents:l.data?.records,isRefreshing:l.isFetching&&l.data!==void 0,pagination:l.data?{page:l.data.page,perPage:l.data.per_page,totalPages:l.data.total_pages,totalRecords:l.data.total_records}:void 0}},M={name:"Name",description:"Description",instructions:"The instruction body",tools:"Tools"};function ee(e){const n=[],t=(a,o)=>{o&&n.push({field:a,message:`${M[a]} ${o}.`})};return t("name",$(e.name)),t("description",A(e.description)),e.instructions!==null&&t("instructions",R(e.instructions)),t("tools",L(e.tools??[])),n}function ne(e,n){const t=d(e);return n.some(a=>d(a)===t)}function te(e){for(const n of e??[]){const t=n.indexOf(":");if(t<0||n.slice(0,t).trim().toLowerCase()!=="tools")continue;const a=n.slice(t+1).split(",").map(o=>o.trim()).filter(Boolean);return a.length>0?a:null}return null}function ae(e,n){const t=d(e);return n.find(a=>d(a)===t)??null}export{X as P,G as a,g as b,J as c,ne as d,ee as e,Z as i,ae as l,H as p,te as t,V as u};
@@ -1 +1 @@
1
- import{j as t}from"./index-DhltrflG.js";import{P as l}from"./index-wz2cjW5P.js";import{u as p,a as x,c as b,e as h}from"./path-utils-BkJr3--b.js";import{u as f,A as c,S as v}from"./error-boundary-CqZRoe9S.js";import{r as g}from"./conversation-input-sync-BXv32NfB.js";import{t as e}from"./messages-Cq_3N7VC.js";const j="radient",A=({onSignInSuccess:u,onAfterCredentialUpdate:d,titleText:a=e("ui.common.account.radient_auth_buttons.sign_in_to_radient"),descriptionText:i=e("ui.common.account.radient_auth_buttons.connect_your_radient_account_to_use_radient_services")})=>{f();const _=p(),n=x(),s=b(n.data,"auth"),r=h(s),o=r.data?.find(m=>m.id===j);return n.isSuccess&&!s?t.jsx(c,{variant:"warning",children:e("ui.common.account.radient_auth_buttons.signing_in_needs_a_newer_local_operator_backend_update_the_backen")}):r.isLoading||n.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(v,{size:"md",label:e("ui.common.account.radient_auth_buttons.loading_sign_in_options")})}):o?t.jsxs("div",{className:"mx-auto w-full max-w-md",children:[a&&t.jsx("p",{className:"mb-2 text-center text-heading text-ink",children:a}),i&&t.jsx("p",{className:"mb-6 text-center text-body-sm text-ink-muted",children:i}),t.jsx(l,{provider:o,onConnected:()=>{_.invalidateQueries({queryKey:g.all}),d?.(),u?.()}})]}):t.jsx(c,{variant:"warning",children:e("ui.common.account.radient_auth_buttons.radient_is_not_available_from_this_backend_s_provider_registry")})};export{A as R};
1
+ import{j as t}from"./index-DhltrflG.js";import{P as l}from"./index-CRQJfecC.js";import{u as p,a as x,c as b,e as h}from"./path-utils-BkJr3--b.js";import{u as f,A as c,S as v}from"./error-boundary-CqZRoe9S.js";import{r as g}from"./conversation-input-sync-BXv32NfB.js";import{t as e}from"./messages-Cq_3N7VC.js";const j="radient",A=({onSignInSuccess:u,onAfterCredentialUpdate:d,titleText:a=e("ui.common.account.radient_auth_buttons.sign_in_to_radient"),descriptionText:i=e("ui.common.account.radient_auth_buttons.connect_your_radient_account_to_use_radient_services")})=>{f();const _=p(),n=x(),s=b(n.data,"auth"),r=h(s),o=r.data?.find(m=>m.id===j);return n.isSuccess&&!s?t.jsx(c,{variant:"warning",children:e("ui.common.account.radient_auth_buttons.signing_in_needs_a_newer_local_operator_backend_update_the_backen")}):r.isLoading||n.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(v,{size:"md",label:e("ui.common.account.radient_auth_buttons.loading_sign_in_options")})}):o?t.jsxs("div",{className:"mx-auto w-full max-w-md",children:[a&&t.jsx("p",{className:"mb-2 text-center text-heading text-ink",children:a}),i&&t.jsx("p",{className:"mb-6 text-center text-body-sm text-ink-muted",children:i}),t.jsx(l,{provider:o,onConnected:()=>{_.invalidateQueries({queryKey:g.all}),d?.(),u?.()}})]}):t.jsx(c,{variant:"warning",children:e("ui.common.account.radient_auth_buttons.radient_is_not_available_from_this_backend_s_provider_registry")})};export{A as R};
@@ -1,4 +1,4 @@
1
- import{r as p,l as Ti,j as u,m as Ii,n as gu,o as Ys,h as Zr,f as ie,p as bu,b as Dt,q as ce,v as Re,w as qs,x as Ri,y as Jr,c as Le}from"./index-DhltrflG.js";import{cX as yu,cY as vu,cZ as es,c_ as xu,c$ as wu,d0 as _i,d1 as Cu,d2 as ku,d3 as Su,d4 as Ei,d5 as Pu,d6 as Oi,d7 as Tt,d8 as yo,d9 as ts,da as Mu,db as Ct,dc as vo,dd as Fi,de as Ni,df as Du,cg as Tu,dg as Iu,S as Ru,s as Ai,dh as _u,di as $i,dj as Eu,dk as Ou,aL as _r,dl as Fu,dm as Nu,dn as Au,dp as $u,dq as ju,dr as Lu,aM as Vu,ds as Bu,dt as zu,cw as Hu,c2 as Wu,du as Uu,dv as Yu,dw as qu}from"./index-wz2cjW5P.js";import{h as ji,u as ns,q as Li,A as Ku,a as Gu,c as Qu}from"./path-utils-BkJr3--b.js";import{P as Xu}from"./page-header-B3bOo0UX.js";import{ai as _o,aj as Zu,l as Kt,B as yt,u as fn,S as os,a4 as Ks,L as bt,T as Vi,I as Wo,F as vn,G as xn,H as wn,J as Cn,K as et,M as Er,a5 as Ju,a6 as ed,x as td,a7 as nd,k as od,X as rd,A as Gs}from"./error-boundary-CqZRoe9S.js";import{t as B}from"./messages-Cq_3N7VC.js";import{a4 as nr,aq as Bi,dm as rs,dn as D,dp as sd,av as zi,aw as Hi,S as Wi,T as Pn,dq as ad,as as id,bn as ld,dr as cd,ds as ud,dt as dd,bT as Qs,du as pd,dv as fd,dw as md,dx as hd,dy as Xs,dz as gd,ar as Mn,dA as Lo,ax as bd,dB as yd,dC as vd,dD as xd,dE as wd}from"./conversation-input-sync-BXv32NfB.js";import{s as Or,g as Cd,b as Uo,c as Ui,d as Yi,e as kd,l as Fr,h as Sd,w as Zs,j as Pd,i as to,f as Md,k as Dd}from"./format-esAOn2VS.js";import{a as or,p as Js}from"./parseISO-BHJWTxrA.js";import{t as Ce,c as at,m as qi,a as Ki,n as rr,g as ss,k as Td,b as Gi,e as Qi}from"./en-US-CHJkXXr4.js";import"./console-mirror-BiiClM8r.js";var Id=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Rd=yu(function(e){return Id.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),_d=Rd,Ed=function(t){return t!=="theme"},ea=function(t){return typeof t=="string"&&t.charCodeAt(0)>96?_d:Ed},ta=function(t,n,o){var r;if(n){var s=n.shouldForwardProp;r=t.__emotion_forwardProp&&s?function(a){return t.__emotion_forwardProp(a)&&s(a)}:s}return typeof r!="function"&&o&&(r=t.__emotion_forwardProp),r},Od=function(t){var n=t.cache,o=t.serialized,r=t.isStringTag;return Cu(n,o,r),ku(function(){return Su(n,o,r)}),null},Fd=function e(t,n){var o=t.__emotion_real===t,r=o&&t.__emotion_base||t,s,a;n!==void 0&&(s=n.label,a=n.target);var i=ta(t,n,o),l=i||ea(r),c=!l("as");return function(){var d=arguments,m=o&&t.__emotion_styles!==void 0?t.__emotion_styles.slice(0):[];if(s!==void 0&&m.push("label:"+s+";"),d[0]==null||d[0].raw===void 0)m.push.apply(m,d);else{var y=d[0];m.push(y[0]);for(var g=d.length,h=1;h<g;h++)m.push(d[h],y[h])}var v=vu(function(f,b,C){var w=c&&f.as||r,x="",S=[],P=f;if(f.theme==null){P={};for(var k in f)P[k]=f[k];P.theme=p.useContext(xu)}typeof f.className=="string"?x=wu(b.registered,S,f.className):f.className!=null&&(x=f.className+" ");var R=_i(m.concat(S),b.registered,P);x+=b.key+"-"+R.name,a!==void 0&&(x+=" "+a);var _=c&&i===void 0?ea(w):l,O={};for(var $ in f)c&&$==="as"||_($)&&(O[$]=f[$]);return O.className=x,C&&(O.ref=C),p.createElement(p.Fragment,null,p.createElement(Od,{cache:b,serialized:R,isStringTag:typeof w=="string"}),p.createElement(w,O))});return v.displayName=s!==void 0?s:"Styled("+(typeof r=="string"?r:r.displayName||r.name||"Component")+")",v.defaultProps=t.defaultProps,v.__emotion_real=v,v.__emotion_base=r,v.__emotion_styles=m,v.__emotion_forwardProp=i,Object.defineProperty(v,"toString",{value:function(){return"."+a}}),v.withComponent=function(f,b){var C=e(f,es({},n,b,{shouldForwardProp:ta(v,b,!0)}));return C.apply(void 0,m)},v}},Nd=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],Nr=Fd.bind(null);Nd.forEach(function(e){Nr[e]=Nr(e)});/**
1
+ import{r as p,l as Ti,j as u,m as Ii,n as gu,o as Ys,h as Zr,f as ie,p as bu,b as Dt,q as ce,v as Re,w as qs,x as Ri,y as Jr,c as Le}from"./index-DhltrflG.js";import{cX as yu,cY as vu,cZ as es,c_ as xu,c$ as wu,d0 as _i,d1 as Cu,d2 as ku,d3 as Su,d4 as Ei,d5 as Pu,d6 as Oi,d7 as Tt,d8 as yo,d9 as ts,da as Mu,db as Ct,dc as vo,dd as Fi,de as Ni,df as Du,cg as Tu,dg as Iu,S as Ru,s as Ai,dh as _u,di as $i,dj as Eu,dk as Ou,aL as _r,dl as Fu,dm as Nu,dn as Au,dp as $u,dq as ju,dr as Lu,aM as Vu,ds as Bu,dt as zu,cw as Hu,c2 as Wu,du as Uu,dv as Yu,dw as qu}from"./index-CRQJfecC.js";import{h as ji,u as ns,q as Li,A as Ku,a as Gu,c as Qu}from"./path-utils-BkJr3--b.js";import{P as Xu}from"./page-header-B3bOo0UX.js";import{ai as _o,aj as Zu,l as Kt,B as yt,u as fn,S as os,a4 as Ks,L as bt,T as Vi,I as Wo,F as vn,G as xn,H as wn,J as Cn,K as et,M as Er,a5 as Ju,a6 as ed,x as td,a7 as nd,k as od,X as rd,A as Gs}from"./error-boundary-CqZRoe9S.js";import{t as B}from"./messages-Cq_3N7VC.js";import{a4 as nr,aq as Bi,dm as rs,dn as D,dp as sd,av as zi,aw as Hi,S as Wi,T as Pn,dq as ad,as as id,bn as ld,dr as cd,ds as ud,dt as dd,bT as Qs,du as pd,dv as fd,dw as md,dx as hd,dy as Xs,dz as gd,ar as Mn,dA as Lo,ax as bd,dB as yd,dC as vd,dD as xd,dE as wd}from"./conversation-input-sync-BXv32NfB.js";import{s as Or,g as Cd,b as Uo,c as Ui,d as Yi,e as kd,l as Fr,h as Sd,w as Zs,j as Pd,i as to,f as Md,k as Dd}from"./format-esAOn2VS.js";import{a as or,p as Js}from"./parseISO-BHJWTxrA.js";import{t as Ce,c as at,m as qi,a as Ki,n as rr,g as ss,k as Td,b as Gi,e as Qi}from"./en-US-CHJkXXr4.js";import"./console-mirror-BiiClM8r.js";var Id=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Rd=yu(function(e){return Id.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),_d=Rd,Ed=function(t){return t!=="theme"},ea=function(t){return typeof t=="string"&&t.charCodeAt(0)>96?_d:Ed},ta=function(t,n,o){var r;if(n){var s=n.shouldForwardProp;r=t.__emotion_forwardProp&&s?function(a){return t.__emotion_forwardProp(a)&&s(a)}:s}return typeof r!="function"&&o&&(r=t.__emotion_forwardProp),r},Od=function(t){var n=t.cache,o=t.serialized,r=t.isStringTag;return Cu(n,o,r),ku(function(){return Su(n,o,r)}),null},Fd=function e(t,n){var o=t.__emotion_real===t,r=o&&t.__emotion_base||t,s,a;n!==void 0&&(s=n.label,a=n.target);var i=ta(t,n,o),l=i||ea(r),c=!l("as");return function(){var d=arguments,m=o&&t.__emotion_styles!==void 0?t.__emotion_styles.slice(0):[];if(s!==void 0&&m.push("label:"+s+";"),d[0]==null||d[0].raw===void 0)m.push.apply(m,d);else{var y=d[0];m.push(y[0]);for(var g=d.length,h=1;h<g;h++)m.push(d[h],y[h])}var v=vu(function(f,b,C){var w=c&&f.as||r,x="",S=[],P=f;if(f.theme==null){P={};for(var k in f)P[k]=f[k];P.theme=p.useContext(xu)}typeof f.className=="string"?x=wu(b.registered,S,f.className):f.className!=null&&(x=f.className+" ");var R=_i(m.concat(S),b.registered,P);x+=b.key+"-"+R.name,a!==void 0&&(x+=" "+a);var _=c&&i===void 0?ea(w):l,O={};for(var $ in f)c&&$==="as"||_($)&&(O[$]=f[$]);return O.className=x,C&&(O.ref=C),p.createElement(p.Fragment,null,p.createElement(Od,{cache:b,serialized:R,isStringTag:typeof w=="string"}),p.createElement(w,O))});return v.displayName=s!==void 0?s:"Styled("+(typeof r=="string"?r:r.displayName||r.name||"Component")+")",v.defaultProps=t.defaultProps,v.__emotion_real=v,v.__emotion_base=r,v.__emotion_styles=m,v.__emotion_forwardProp=i,Object.defineProperty(v,"toString",{value:function(){return"."+a}}),v.withComponent=function(f,b){var C=e(f,es({},n,b,{shouldForwardProp:ta(v,b,!0)}));return C.apply(void 0,m)},v}},Nd=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],Nr=Fd.bind(null);Nd.forEach(function(e){Nr[e]=Nr(e)});/**
2
2
  * @mui/styled-engine v6.4.11
3
3
  *
4
4
  * @license MIT
@@ -1,4 +1,4 @@
1
- import{r as l,j as t,c as ue,t as Us}from"./index-DhltrflG.js";import{o as Bs}from"./console-mirror-BiiClM8r.js";import{c9 as zt,ca as Vs,cb as xn,cc as Ke,bu as Hs,a3 as Qn,a4 as Xt,T as Zn,aq as qs,ar as Gs,cd as Ys,ce as Ws,cf as Qs,cg as Zs,ch as Jn,ci as en,a1 as Xn,cj as Js,ck as Xs,at as $t,cl as yn,cm as ea,cn as pt,co as Pt,bc as es,cp as tn,bG as ht,b1 as ta,cq as ts,a0 as na,cr as sa,cs as aa,ct as ia,cu as oa,cv as ra,cw as la,S as ns,av as Kt,aw as Ut,aA as ca,bV as Bt,cx as da,cy as ua,cz as Vt,cA as ga,cB as ma,cC as _a,cD as ss,cE as pa,cF as ha,cG as fa,ap as xa,cH as as,au as is,cI as os,cJ as ya,cK as va,cL as ba,cM as ka,cN as ja,cO as wa,cP as Na,cQ as Sa,bp as rs,aZ as Ma,cR as et,cS as vn,cT as Ca,cU as Aa,cV as Ea,cW as Ia,cX as Ra,cY as Ta,bw as La,cZ as Oa,c_ as Fa,c$ as Da,d0 as bn,d1 as za,d2 as $a,d3 as Pa,bN as Ka}from"./conversation-input-sync-BXv32NfB.js";import{h as Ie,u as nn,af as Ua,ag as Ge,a as sn,c as kt,ah as Ba,Y as Va,ai as Ha,aj as qa,ak as Ga,al as Ya,d as _e,am as Wa,x as Ue,an as Qa,ao as Za,ap as Ja,D as an,aq as Xa,q as st,ar as ei,A as ls,r as ti,L as ni,as as Ht,at as si,au as cs,V as ai}from"./path-utils-BkJr3--b.js";import{cC as ds,cD as ii,cE as oi,cF as us,cG as ri,cH as li,cI as Fe,cJ as ci,S as gs,ca as rt,cb as me,cK as ce,cL as di,cw as ui,cM as gi,aL as kn,cN as mi,cO as _i,cP as dt,c9 as pi,cl as hi,cQ as fi,cR as xi,cS as yi,cT as vi,b$ as jn,cU as bi,bR as ki,c6 as wn,cv as ji,c7 as wi,c8 as Ni,cV as Si,b_ as Mi,cW as Ci}from"./index-wz2cjW5P.js";import{P as Ai}from"./page-header-B3bOo0UX.js";import{c as R,u as se,B as D,S as ye,M as ms,l as Je,Y as jt,Z as wt,_ as Qe,A as ae,m as Nt,n as Ae,k as xe,F as on,G as rn,H as ln,J as cn,K as Ze,L as Ee,I as De,a4 as St,N as Ei,z as it,C as qt,ac as Ii,g as _s,ag as Nn,T as ps,q as Ri,r as Ti,s as Li,v as Oi,w as Sn,p as Fi,E as Di,ah as zi,a8 as $i}from"./error-boundary-CqZRoe9S.js";import{t as n,L as Pi}from"./messages-Cq_3N7VC.js";import{R as Ki}from"./radient-auth-buttons-Di1zLV23.js";import{N as Ui}from"./notebook-pen-FphG2dMG.js";import{B as Bi}from"./book-open-CPvwVqAp.js";import{a as Vi,p as At}from"./parseISO-BHJWTxrA.js";import{i as Hi,a as qe,f as qi}from"./format-esAOn2VS.js";import{t as Gi}from"./en-US-CHJkXXr4.js";/**
1
+ import{r as l,j as t,c as ue,t as Us}from"./index-DhltrflG.js";import{o as Bs}from"./console-mirror-BiiClM8r.js";import{c9 as zt,ca as Vs,cb as xn,cc as Ke,bu as Hs,a3 as Qn,a4 as Xt,T as Zn,aq as qs,ar as Gs,cd as Ys,ce as Ws,cf as Qs,cg as Zs,ch as Jn,ci as en,a1 as Xn,cj as Js,ck as Xs,at as $t,cl as yn,cm as ea,cn as pt,co as Pt,bc as es,cp as tn,bG as ht,b1 as ta,cq as ts,a0 as na,cr as sa,cs as aa,ct as ia,cu as oa,cv as ra,cw as la,S as ns,av as Kt,aw as Ut,aA as ca,bV as Bt,cx as da,cy as ua,cz as Vt,cA as ga,cB as ma,cC as _a,cD as ss,cE as pa,cF as ha,cG as fa,ap as xa,cH as as,au as is,cI as os,cJ as ya,cK as va,cL as ba,cM as ka,cN as ja,cO as wa,cP as Na,cQ as Sa,bp as rs,aZ as Ma,cR as et,cS as vn,cT as Ca,cU as Aa,cV as Ea,cW as Ia,cX as Ra,cY as Ta,bw as La,cZ as Oa,c_ as Fa,c$ as Da,d0 as bn,d1 as za,d2 as $a,d3 as Pa,bN as Ka}from"./conversation-input-sync-BXv32NfB.js";import{h as Ie,u as nn,af as Ua,ag as Ge,a as sn,c as kt,ah as Ba,Y as Va,ai as Ha,aj as qa,ak as Ga,al as Ya,d as _e,am as Wa,x as Ue,an as Qa,ao as Za,ap as Ja,D as an,aq as Xa,q as st,ar as ei,A as ls,r as ti,L as ni,as as Ht,at as si,au as cs,V as ai}from"./path-utils-BkJr3--b.js";import{cC as ds,cD as ii,cE as oi,cF as us,cG as ri,cH as li,cI as Fe,cJ as ci,S as gs,ca as rt,cb as me,cK as ce,cL as di,cw as ui,cM as gi,aL as kn,cN as mi,cO as _i,cP as dt,c9 as pi,cl as hi,cQ as fi,cR as xi,cS as yi,cT as vi,b$ as jn,cU as bi,bR as ki,c6 as wn,cv as ji,c7 as wi,c8 as Ni,cV as Si,b_ as Mi,cW as Ci}from"./index-CRQJfecC.js";import{P as Ai}from"./page-header-B3bOo0UX.js";import{c as R,u as se,B as D,S as ye,M as ms,l as Je,Y as jt,Z as wt,_ as Qe,A as ae,m as Nt,n as Ae,k as xe,F as on,G as rn,H as ln,J as cn,K as Ze,L as Ee,I as De,a4 as St,N as Ei,z as it,C as qt,ac as Ii,g as _s,ag as Nn,T as ps,q as Ri,r as Ti,s as Li,v as Oi,w as Sn,p as Fi,E as Di,ah as zi,a8 as $i}from"./error-boundary-CqZRoe9S.js";import{t as n,L as Pi}from"./messages-Cq_3N7VC.js";import{R as Ki}from"./radient-auth-buttons-BmW-BaEj.js";import{N as Ui}from"./notebook-pen-FphG2dMG.js";import{B as Bi}from"./book-open-CPvwVqAp.js";import{a as Vi,p as At}from"./parseISO-BHJWTxrA.js";import{i as Hi,a as qe,f as qi}from"./format-esAOn2VS.js";import{t as Gi}from"./en-US-CHJkXXr4.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{g as Y,a as E,b as F}from"./library-page-CB9dDvmn.js";import"./index-DhltrflG.js";import"./console-mirror-BiiClM8r.js";import"./path-utils-BkJr3--b.js";import"./messages-Cq_3N7VC.js";import"./page-header-B3bOo0UX.js";import"./conversation-input-sync-BXv32NfB.js";import"./error-boundary-CqZRoe9S.js";import"./index-wz2cjW5P.js";import"./heart-B3mi-jou.js";import"./hash-CzjTtP10.js";import"./use-session-snapshot-0k6Oot8j.js";const B=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0"];function W(n,t){const c=`accent${n%6+1}`;return t[c]?"#"+t[c]:B[n%B.length]}function j(n,t=.45){const c=parseInt(n.slice(1,3),16),s=parseInt(n.slice(3,5),16),a=parseInt(n.slice(5,7),16),p=Math.round(c+(255-c)*t),M=Math.round(s+(255-s)*t),o=Math.round(a+(255-a)*t);return`rgb(${p},${M},${o})`}function G(n){const t=[];for(const c of E(n,"t")){const s=c.textContent.trim();s&&t.push(s)}return t.join(" ")}function V(n){if(!n)return[];const t=Y(n,"ptLst");if(!t)return[];const c=[];for(const s of E(t,"pt")){const a=F(s,"type","node");if(a==="parTrans"||a==="sibTrans")continue;const p=G(s);(p||a==="node")&&c.push({id:F(s,"modelId",""),type:a,text:p})}return c.filter(s=>s.text)}function z(n){if(!n)return"list";const t=Y(n,"layoutDef")||n,s=(F(t,"uniqueId","")||F(t,"defStyle","")||"").toLowerCase();return s.includes("chevron")||s.includes("arrowprocess")||s.includes("process")?"process":s.includes("cycle")||s.includes("continuouscycle")?"cycle":s.includes("hierarchy")||s.includes("orgchart")||s.includes("org")?"hierarchy":s.includes("radial")||s.includes("diverging")?"radial":s.includes("pyramid")||s.includes("invertedpyramid")?"pyramid":s.includes("funnel")?"funnel":s.includes("venn")?"venn":s.includes("matrix")?"matrix":s.includes("list")||s.includes("bullet")?"list":s.includes("relationship")||s.includes("balance")?"relationship":"list"}function $(n,t,c,s,a,p,M,o="#fff",f="center"){if(!t)return;n.save(),n.fillStyle=o,n.textAlign=f,n.textBaseline="middle";const l=t.split(" "),g=M*1.3;let h=[],r="";for(const u of l){const y=r?r+" "+u:u;n.measureText(y).width>a-4&&r?(h.push(r),r=u):r=y}r&&h.push(r);const i=Math.max(1,Math.floor(p/g));h.length>i&&(h=h.slice(0,i));const e=s-(h.length-1)*g/2;for(let u=0;u<h.length;u++)n.fillText(h[u],c,e+u*g);n.restore()}function I(n,t,c,s=14){const a=Math.floor(t/(s*.55)),p=n.split(" "),M=Math.ceil(p.join(" ").length/Math.max(a,1)),o=c/(M*1.4);return Math.max(8,Math.min(s,o))}function L(n,t,c,s,a,p,M,o){n.save(),n.beginPath(),p=Math.min(p,s/2,a/2),n.moveTo(t+p,c),n.arcTo(t+s,c,t+s,c+a,p),n.arcTo(t+s,c+a,t,c+a,p),n.arcTo(t,c+a,t,c,p),n.arcTo(t,c,t+s,c,p),n.closePath(),M&&(n.fillStyle=M,n.fill()),n.restore()}function X(n,t,c,s,a,p,M=1.5){const o=Math.atan2(a-c,s-t),f=8;n.save(),n.strokeStyle=p,n.fillStyle=p,n.lineWidth=M,n.beginPath(),n.moveTo(t,c),n.lineTo(s,a),n.stroke(),n.beginPath(),n.moveTo(s,a),n.lineTo(s-f*Math.cos(o-.4),a-f*Math.sin(o-.4)),n.lineTo(s-f*Math.cos(o+.4),a-f*Math.sin(o+.4)),n.closePath(),n.fill(),n.restore()}function J(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=a/f,g=Math.min(l*.08,10*o),h=Math.min(l*.12,18*o),r=l-h-g,i=p*.7,e=s+(p-i)/2;for(let u=0;u<f;u++){const y=W(u,M),d=c+l*u+g/2,b=u===f-1;n.save(),n.beginPath();const P=d+r+(b?0:h);n.moveTo(d,e),n.lineTo(d+r,e),b||n.lineTo(P,e+i/2),n.lineTo(d+r,e+i),n.lineTo(d,e+i),u>0&&n.lineTo(d+h,e+i/2),n.closePath(),n.fillStyle=y,n.fill(),n.restore();const m=I(t[u].text,r-h,i)*o;n.font=`${m}px sans-serif`;const T=d+(r+(u>0?h:0))/2;$(n,t[u].text,T,e+i/2,r,i,m)}}function K(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=c+a/2,g=s+p/2,h=Math.min(a,p)*.33,r=Math.min(h*.32,40*o);n.save(),n.strokeStyle="#ccc",n.lineWidth=2*o,n.setLineDash([4*o,4*o]),n.beginPath(),n.arc(l,g,h,0,Math.PI*2),n.stroke(),n.setLineDash([]),n.restore();for(let i=0;i<f;i++){const e=i/f*Math.PI*2-Math.PI/2,u=l+h*Math.cos(e),y=g+h*Math.sin(e),d=W(i,M);if(n.save(),n.beginPath(),n.arc(u,y,r,0,Math.PI*2),n.fillStyle=d,n.fill(),n.restore(),f>1){const P=(i+1)/f*Math.PI*2-Math.PI/2,m=(e+P)/2,T=l+h*Math.cos(e+.15),v=g+h*Math.sin(e+.15),k=l+h*Math.cos(P-.15),S=g+h*Math.sin(P-.15);n.save(),n.strokeStyle=d+"99",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(T,v),n.quadraticCurveTo(l+h*1.1*Math.cos(m),g+h*1.1*Math.sin(m),k,S),n.stroke(),n.restore()}const b=I(t[i].text,r*1.7,r*1.2)*o;n.font=`${b}px sans-serif`,$(n,t[i].text,u,y,r*2,r*1.8,b)}}function O(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=Math.max(l.length,1),h=p/(l.length>0?2.8:1.2),r=h*.75,i=Math.min(a*.3,160*o),e=r,u=c+(a-i)/2,y=s+(h-e)/2,d=W(0,M);L(n,u,y,i,e,6*o,d);const b=I(f.text,i-10*o,e)*o;if(n.font=`bold ${b}px sans-serif`,$(n,f.text,u+i/2,y+e/2,i-10,e,b),!l.length)return;const P=(a-20*o)/g,m=s+h*1.5,T=y+e,v=m-4*o;n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(u+i/2,T),n.lineTo(u+i/2,(T+v)/2),n.lineTo(c+10*o,(T+v)/2),n.lineTo(c+a-10*o,(T+v)/2),n.stroke(),n.restore();for(let k=0;k<l.length;k++){const S=c+P*k+8*o,R=m,A=P-16*o,H=r,N=W(k+1,M);n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(S+A/2,(T+v)/2),n.lineTo(S+A/2,R),n.stroke(),n.restore(),L(n,S,R,A,H,5*o,N);const D=I(l[k].text,A-8*o,H)*o;n.font=`${D}px sans-serif`,$(n,l[k].text,S+A/2,R+H/2,A-8,H,D)}}function Q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=c+a/2,h=s+p/2,r=Math.min(a,p)*.18,i=Math.min(a,p)*.36,e=Math.min(i*.28,38*o),u=l.length||1,y=W(0,M);n.save(),n.beginPath(),n.arc(g,h,r,0,Math.PI*2),n.fillStyle=y,n.fill(),n.restore();const d=I(f.text,r*1.6,r*1.2)*o;n.font=`bold ${d}px sans-serif`,$(n,f.text,g,h,r*2,r*2,d);for(let b=0;b<u;b++){const P=b/u*Math.PI*2-Math.PI/2,m=g+i*Math.cos(P),T=h+i*Math.sin(P),v=W(b+1,M),k=g+r*Math.cos(P),S=h+r*Math.sin(P),R=m-e*Math.cos(P),A=T-e*Math.sin(P);X(n,k,S,R,A,v+"99",1.5*o),n.save(),n.beginPath(),n.arc(m,T,e,0,Math.PI*2),n.fillStyle=v,n.fill(),n.restore();const H=I(l[b].text,e*1.7,e*1.2)*o;n.font=`${H}px sans-serif`,$(n,l[b].text,m,T,e*2,e*1.8,H)}}function U(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=(f-g)/f,r=a*h,i=c+(a-r)/2,e=s+g*l,u=W(g,M);n.save(),n.beginPath(),n.moveTo(i,e+l),n.lineTo(i+r,e+l);const y=a*((f-g-1)/f);n.lineTo(c+(a+y)/2,e),n.lineTo(c+(a-y)/2,e),n.closePath(),n.fillStyle=u,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const d=I(t[g].text,r*.6,l*.7)*o;n.font=`${d}px sans-serif`,$(n,t[g].text,c+a/2,e+l/2,r*.6,l*.7,d)}}function Z(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=1-g/f*.55,r=1-(g+1)/f*.55,i=a*h,e=a*r,u=c+(a-i)/2,y=c+(a-e)/2,d=s+g*l,b=W(g,M);n.save(),n.beginPath(),n.moveTo(u,d),n.lineTo(u+i,d),n.lineTo(y+e,d+l),n.lineTo(y,d+l),n.closePath(),n.fillStyle=b,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const P=(i+e)/2,m=I(t[g].text,P*.8,l*.7)*o;n.font=`${m}px sans-serif`,$(n,t[g].text,c+a/2,d+l/2,P*.8,l*.7,m)}}function _(n,t,c,s,a,p,M,o){if(!t.length)return;const f=Math.min(t.length,4),l=c+a/2,g=s+p/2,h=Math.min(a,p)*(f<=2?.32:.28),r=h*.65,i=[];for(let e=0;e<f;e++)i.push(e/f*Math.PI*2-Math.PI/2);for(let e=0;e<f;e++){const u=f>1?l+r*Math.cos(i[e]):l,y=f>1?g+r*Math.sin(i[e]):g,d=W(e,M);n.save(),n.globalAlpha=.55,n.beginPath(),n.arc(u,y,h,0,Math.PI*2),n.fillStyle=d,n.fill(),n.globalAlpha=1,n.strokeStyle="#fff",n.lineWidth=1.5*o,n.stroke(),n.restore();const b=f>1?l+(r+h*.45)*Math.cos(i[e]):l,P=f>1?g+(r+h*.45)*Math.sin(i[e]):g,m=I(t[e].text,h*1.2,h*.7)*o;n.font=`${m}px sans-serif`,$(n,t[e].text,b,P,h*1.2,h*.7,m,"#333")}}function w(n,t,c,s,a,p,M,o){const f=[t[0]||{text:""},t[1]||{text:""},t[2]||{text:""},t[3]||{text:""}],l=a/2,g=p/2,h=8*o;for(let r=0;r<2;r++)for(let i=0;i<2;i++){const e=r*2+i,u=c+i*l+h,y=s+r*g+h,d=l-h*2,b=g-h*2,P=W(e,M);L(n,u,y,d,b,8*o,P);const m=I(f[e].text,d-10,b)*o;n.font=`${m}px sans-serif`,$(n,f[e].text,u+d/2,y+b/2,d-10,b,m)}}function q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f,g=Math.min(l*.2,14*o),h=g*3;for(let r=0;r<f;r++){const i=s+r*l,e=i+l/2,u=W(r,M);n.save(),n.beginPath(),n.arc(c+g,e,g,0,Math.PI*2),n.fillStyle=u,n.fill(),n.restore(),L(n,c+h,i+l*.1,a-h-4*o,l*.8,4*o,u+"22");const y=I(t[r].text,a-h-20*o,l*.7)*o;n.font=`${y}px sans-serif`,n.fillStyle="#333",n.textAlign="left",n.textBaseline="middle",n.fillText(t[r].text,c+h+8*o,e)}}function C(n,t,c,s,a,p,M,o){if(t.length<2){q(n,t,c,s,a,p,M,o);return}const f=t[Math.floor(t.length/2)],l=t.slice(0,Math.floor(t.length/2)),g=t.slice(Math.floor(t.length/2)+1),h=c+a/2,r=s+p/2,i=Math.min(a*.14,p*.25),e=W(Math.floor(t.length/2),M);n.save(),n.beginPath(),n.arc(h,r,i,0,Math.PI*2),n.fillStyle=e,n.fill(),n.restore();const u=I(f.text,i*1.6,i*1.2)*o;n.font=`bold ${u}px sans-serif`,$(n,f.text,h,r,i*2,i*1.8,u);const y=p/Math.max(l.length,g.length,1),d=a*.3,b=y*.7,P=(m,T)=>{const v=T==="left"?c:c+a-d,k=T==="left"?h-i:h+i;for(let S=0;S<m.length;S++){const R=s+y*S+(y-b)/2,A=W(S+(T==="right"?l.length+1:0),M);L(n,v,R,d,b,5*o,A);const H=I(m[S].text,d-8,b)*o;n.font=`${H}px sans-serif`,$(n,m[S].text,v+d/2,R+b/2,d-8,b,H);const N=T==="left"?v+d:v;X(n,N,R+b/2,k,r,A+"88",1.5*o)}};P(l,"left"),P(g,"right")}function x(n,t,c,s,a,p,M,o){const f=t.length;if(!f)return;const l=Math.ceil(Math.sqrt(f)),g=Math.ceil(f/l),h=a/l,r=p/g,i=Math.min(h,r)*.1;for(let e=0;e<f;e++){const u=e%l,y=Math.floor(e/l),d=c+u*h+i,b=s+y*r+i,P=h-i*2,m=r-i*2,T=W(e,M);L(n,d,b,P,m,8*o,T),j(T),n.save();const v=n.createLinearGradient(d,b,d,b+m*.5);v.addColorStop(0,"rgba(255,255,255,0.18)"),v.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=v,n.beginPath(),n.roundRect?.(d,b,P,m,8*o),n.fill(),n.restore();const k=I(t[e].text,P-12*o,m)*o;n.font=`${k}px sans-serif`,$(n,t[e].text,d+P/2,b+m/2,P-12*o,m,k)}}function gn(n,t,c,s,a,p,M,o,f){const l=V(t),g=z(c),h=16*f;n.save(),n.fillStyle="#f7f9fc",n.strokeStyle="#e0e4ec",n.lineWidth=1,n.beginPath(),n.roundRect?.(s,a,p,M,6*f)||n.rect(s,a,p,M),n.fill(),n.stroke();const r=s+h,i=a+h,e=p-h*2,u=M-h*2;if(!l.length){n.fillStyle="#aaa",n.font=`${12*f}px sans-serif`,n.textAlign="center",n.textBaseline="middle",n.fillText("SmartArt Diagram",s+p/2,a+M/2),n.restore();return}switch(g){case"process":J(n,l,r,i,e,u,o,f);break;case"cycle":K(n,l,r,i,e,u,o,f);break;case"hierarchy":O(n,l,r,i,e,u,o,f);break;case"radial":Q(n,l,r,i,e,u,o,f);break;case"pyramid":U(n,l,r,i,e,u,o,f);break;case"funnel":Z(n,l,r,i,e,u,o,f);break;case"venn":_(n,l,r,i,e,u,o,f);break;case"matrix":w(n,l,r,i,e,u,o,f);break;case"list":q(n,l,r,i,e,u,o,f);break;case"relationship":C(n,l,r,i,e,u,o,f);break;default:x(n,l,r,i,e,u,o,f)}n.restore()}export{gn as renderSmartArt};
1
+ import{g as Y,a as E,b as F}from"./library-page-DQ0q6JRi.js";import"./index-DhltrflG.js";import"./console-mirror-BiiClM8r.js";import"./path-utils-BkJr3--b.js";import"./messages-Cq_3N7VC.js";import"./page-header-B3bOo0UX.js";import"./conversation-input-sync-BXv32NfB.js";import"./error-boundary-CqZRoe9S.js";import"./index-CRQJfecC.js";import"./heart-B3mi-jou.js";import"./hash-CzjTtP10.js";import"./use-session-snapshot-0k6Oot8j.js";const B=["#4472C4","#ED7D31","#A9D18E","#FF0000","#FFC000","#5B9BD5","#70AD47","#C00000","#7030A0","#00B0F0"];function W(n,t){const c=`accent${n%6+1}`;return t[c]?"#"+t[c]:B[n%B.length]}function j(n,t=.45){const c=parseInt(n.slice(1,3),16),s=parseInt(n.slice(3,5),16),a=parseInt(n.slice(5,7),16),p=Math.round(c+(255-c)*t),M=Math.round(s+(255-s)*t),o=Math.round(a+(255-a)*t);return`rgb(${p},${M},${o})`}function G(n){const t=[];for(const c of E(n,"t")){const s=c.textContent.trim();s&&t.push(s)}return t.join(" ")}function V(n){if(!n)return[];const t=Y(n,"ptLst");if(!t)return[];const c=[];for(const s of E(t,"pt")){const a=F(s,"type","node");if(a==="parTrans"||a==="sibTrans")continue;const p=G(s);(p||a==="node")&&c.push({id:F(s,"modelId",""),type:a,text:p})}return c.filter(s=>s.text)}function z(n){if(!n)return"list";const t=Y(n,"layoutDef")||n,s=(F(t,"uniqueId","")||F(t,"defStyle","")||"").toLowerCase();return s.includes("chevron")||s.includes("arrowprocess")||s.includes("process")?"process":s.includes("cycle")||s.includes("continuouscycle")?"cycle":s.includes("hierarchy")||s.includes("orgchart")||s.includes("org")?"hierarchy":s.includes("radial")||s.includes("diverging")?"radial":s.includes("pyramid")||s.includes("invertedpyramid")?"pyramid":s.includes("funnel")?"funnel":s.includes("venn")?"venn":s.includes("matrix")?"matrix":s.includes("list")||s.includes("bullet")?"list":s.includes("relationship")||s.includes("balance")?"relationship":"list"}function $(n,t,c,s,a,p,M,o="#fff",f="center"){if(!t)return;n.save(),n.fillStyle=o,n.textAlign=f,n.textBaseline="middle";const l=t.split(" "),g=M*1.3;let h=[],r="";for(const u of l){const y=r?r+" "+u:u;n.measureText(y).width>a-4&&r?(h.push(r),r=u):r=y}r&&h.push(r);const i=Math.max(1,Math.floor(p/g));h.length>i&&(h=h.slice(0,i));const e=s-(h.length-1)*g/2;for(let u=0;u<h.length;u++)n.fillText(h[u],c,e+u*g);n.restore()}function I(n,t,c,s=14){const a=Math.floor(t/(s*.55)),p=n.split(" "),M=Math.ceil(p.join(" ").length/Math.max(a,1)),o=c/(M*1.4);return Math.max(8,Math.min(s,o))}function L(n,t,c,s,a,p,M,o){n.save(),n.beginPath(),p=Math.min(p,s/2,a/2),n.moveTo(t+p,c),n.arcTo(t+s,c,t+s,c+a,p),n.arcTo(t+s,c+a,t,c+a,p),n.arcTo(t,c+a,t,c,p),n.arcTo(t,c,t+s,c,p),n.closePath(),M&&(n.fillStyle=M,n.fill()),n.restore()}function X(n,t,c,s,a,p,M=1.5){const o=Math.atan2(a-c,s-t),f=8;n.save(),n.strokeStyle=p,n.fillStyle=p,n.lineWidth=M,n.beginPath(),n.moveTo(t,c),n.lineTo(s,a),n.stroke(),n.beginPath(),n.moveTo(s,a),n.lineTo(s-f*Math.cos(o-.4),a-f*Math.sin(o-.4)),n.lineTo(s-f*Math.cos(o+.4),a-f*Math.sin(o+.4)),n.closePath(),n.fill(),n.restore()}function J(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=a/f,g=Math.min(l*.08,10*o),h=Math.min(l*.12,18*o),r=l-h-g,i=p*.7,e=s+(p-i)/2;for(let u=0;u<f;u++){const y=W(u,M),d=c+l*u+g/2,b=u===f-1;n.save(),n.beginPath();const P=d+r+(b?0:h);n.moveTo(d,e),n.lineTo(d+r,e),b||n.lineTo(P,e+i/2),n.lineTo(d+r,e+i),n.lineTo(d,e+i),u>0&&n.lineTo(d+h,e+i/2),n.closePath(),n.fillStyle=y,n.fill(),n.restore();const m=I(t[u].text,r-h,i)*o;n.font=`${m}px sans-serif`;const T=d+(r+(u>0?h:0))/2;$(n,t[u].text,T,e+i/2,r,i,m)}}function K(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=c+a/2,g=s+p/2,h=Math.min(a,p)*.33,r=Math.min(h*.32,40*o);n.save(),n.strokeStyle="#ccc",n.lineWidth=2*o,n.setLineDash([4*o,4*o]),n.beginPath(),n.arc(l,g,h,0,Math.PI*2),n.stroke(),n.setLineDash([]),n.restore();for(let i=0;i<f;i++){const e=i/f*Math.PI*2-Math.PI/2,u=l+h*Math.cos(e),y=g+h*Math.sin(e),d=W(i,M);if(n.save(),n.beginPath(),n.arc(u,y,r,0,Math.PI*2),n.fillStyle=d,n.fill(),n.restore(),f>1){const P=(i+1)/f*Math.PI*2-Math.PI/2,m=(e+P)/2,T=l+h*Math.cos(e+.15),v=g+h*Math.sin(e+.15),k=l+h*Math.cos(P-.15),S=g+h*Math.sin(P-.15);n.save(),n.strokeStyle=d+"99",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(T,v),n.quadraticCurveTo(l+h*1.1*Math.cos(m),g+h*1.1*Math.sin(m),k,S),n.stroke(),n.restore()}const b=I(t[i].text,r*1.7,r*1.2)*o;n.font=`${b}px sans-serif`,$(n,t[i].text,u,y,r*2,r*1.8,b)}}function O(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=Math.max(l.length,1),h=p/(l.length>0?2.8:1.2),r=h*.75,i=Math.min(a*.3,160*o),e=r,u=c+(a-i)/2,y=s+(h-e)/2,d=W(0,M);L(n,u,y,i,e,6*o,d);const b=I(f.text,i-10*o,e)*o;if(n.font=`bold ${b}px sans-serif`,$(n,f.text,u+i/2,y+e/2,i-10,e,b),!l.length)return;const P=(a-20*o)/g,m=s+h*1.5,T=y+e,v=m-4*o;n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(u+i/2,T),n.lineTo(u+i/2,(T+v)/2),n.lineTo(c+10*o,(T+v)/2),n.lineTo(c+a-10*o,(T+v)/2),n.stroke(),n.restore();for(let k=0;k<l.length;k++){const S=c+P*k+8*o,R=m,A=P-16*o,H=r,N=W(k+1,M);n.save(),n.strokeStyle="#999",n.lineWidth=1.5*o,n.beginPath(),n.moveTo(S+A/2,(T+v)/2),n.lineTo(S+A/2,R),n.stroke(),n.restore(),L(n,S,R,A,H,5*o,N);const D=I(l[k].text,A-8*o,H)*o;n.font=`${D}px sans-serif`,$(n,l[k].text,S+A/2,R+H/2,A-8,H,D)}}function Q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t[0],l=t.slice(1),g=c+a/2,h=s+p/2,r=Math.min(a,p)*.18,i=Math.min(a,p)*.36,e=Math.min(i*.28,38*o),u=l.length||1,y=W(0,M);n.save(),n.beginPath(),n.arc(g,h,r,0,Math.PI*2),n.fillStyle=y,n.fill(),n.restore();const d=I(f.text,r*1.6,r*1.2)*o;n.font=`bold ${d}px sans-serif`,$(n,f.text,g,h,r*2,r*2,d);for(let b=0;b<u;b++){const P=b/u*Math.PI*2-Math.PI/2,m=g+i*Math.cos(P),T=h+i*Math.sin(P),v=W(b+1,M),k=g+r*Math.cos(P),S=h+r*Math.sin(P),R=m-e*Math.cos(P),A=T-e*Math.sin(P);X(n,k,S,R,A,v+"99",1.5*o),n.save(),n.beginPath(),n.arc(m,T,e,0,Math.PI*2),n.fillStyle=v,n.fill(),n.restore();const H=I(l[b].text,e*1.7,e*1.2)*o;n.font=`${H}px sans-serif`,$(n,l[b].text,m,T,e*2,e*1.8,H)}}function U(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=(f-g)/f,r=a*h,i=c+(a-r)/2,e=s+g*l,u=W(g,M);n.save(),n.beginPath(),n.moveTo(i,e+l),n.lineTo(i+r,e+l);const y=a*((f-g-1)/f);n.lineTo(c+(a+y)/2,e),n.lineTo(c+(a-y)/2,e),n.closePath(),n.fillStyle=u,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const d=I(t[g].text,r*.6,l*.7)*o;n.font=`${d}px sans-serif`,$(n,t[g].text,c+a/2,e+l/2,r*.6,l*.7,d)}}function Z(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f;for(let g=0;g<f;g++){const h=1-g/f*.55,r=1-(g+1)/f*.55,i=a*h,e=a*r,u=c+(a-i)/2,y=c+(a-e)/2,d=s+g*l,b=W(g,M);n.save(),n.beginPath(),n.moveTo(u,d),n.lineTo(u+i,d),n.lineTo(y+e,d+l),n.lineTo(y,d+l),n.closePath(),n.fillStyle=b,n.strokeStyle="#fff",n.lineWidth=2*o,n.fill(),n.stroke(),n.restore();const P=(i+e)/2,m=I(t[g].text,P*.8,l*.7)*o;n.font=`${m}px sans-serif`,$(n,t[g].text,c+a/2,d+l/2,P*.8,l*.7,m)}}function _(n,t,c,s,a,p,M,o){if(!t.length)return;const f=Math.min(t.length,4),l=c+a/2,g=s+p/2,h=Math.min(a,p)*(f<=2?.32:.28),r=h*.65,i=[];for(let e=0;e<f;e++)i.push(e/f*Math.PI*2-Math.PI/2);for(let e=0;e<f;e++){const u=f>1?l+r*Math.cos(i[e]):l,y=f>1?g+r*Math.sin(i[e]):g,d=W(e,M);n.save(),n.globalAlpha=.55,n.beginPath(),n.arc(u,y,h,0,Math.PI*2),n.fillStyle=d,n.fill(),n.globalAlpha=1,n.strokeStyle="#fff",n.lineWidth=1.5*o,n.stroke(),n.restore();const b=f>1?l+(r+h*.45)*Math.cos(i[e]):l,P=f>1?g+(r+h*.45)*Math.sin(i[e]):g,m=I(t[e].text,h*1.2,h*.7)*o;n.font=`${m}px sans-serif`,$(n,t[e].text,b,P,h*1.2,h*.7,m,"#333")}}function w(n,t,c,s,a,p,M,o){const f=[t[0]||{text:""},t[1]||{text:""},t[2]||{text:""},t[3]||{text:""}],l=a/2,g=p/2,h=8*o;for(let r=0;r<2;r++)for(let i=0;i<2;i++){const e=r*2+i,u=c+i*l+h,y=s+r*g+h,d=l-h*2,b=g-h*2,P=W(e,M);L(n,u,y,d,b,8*o,P);const m=I(f[e].text,d-10,b)*o;n.font=`${m}px sans-serif`,$(n,f[e].text,u+d/2,y+b/2,d-10,b,m)}}function q(n,t,c,s,a,p,M,o){if(!t.length)return;const f=t.length,l=p/f,g=Math.min(l*.2,14*o),h=g*3;for(let r=0;r<f;r++){const i=s+r*l,e=i+l/2,u=W(r,M);n.save(),n.beginPath(),n.arc(c+g,e,g,0,Math.PI*2),n.fillStyle=u,n.fill(),n.restore(),L(n,c+h,i+l*.1,a-h-4*o,l*.8,4*o,u+"22");const y=I(t[r].text,a-h-20*o,l*.7)*o;n.font=`${y}px sans-serif`,n.fillStyle="#333",n.textAlign="left",n.textBaseline="middle",n.fillText(t[r].text,c+h+8*o,e)}}function C(n,t,c,s,a,p,M,o){if(t.length<2){q(n,t,c,s,a,p,M,o);return}const f=t[Math.floor(t.length/2)],l=t.slice(0,Math.floor(t.length/2)),g=t.slice(Math.floor(t.length/2)+1),h=c+a/2,r=s+p/2,i=Math.min(a*.14,p*.25),e=W(Math.floor(t.length/2),M);n.save(),n.beginPath(),n.arc(h,r,i,0,Math.PI*2),n.fillStyle=e,n.fill(),n.restore();const u=I(f.text,i*1.6,i*1.2)*o;n.font=`bold ${u}px sans-serif`,$(n,f.text,h,r,i*2,i*1.8,u);const y=p/Math.max(l.length,g.length,1),d=a*.3,b=y*.7,P=(m,T)=>{const v=T==="left"?c:c+a-d,k=T==="left"?h-i:h+i;for(let S=0;S<m.length;S++){const R=s+y*S+(y-b)/2,A=W(S+(T==="right"?l.length+1:0),M);L(n,v,R,d,b,5*o,A);const H=I(m[S].text,d-8,b)*o;n.font=`${H}px sans-serif`,$(n,m[S].text,v+d/2,R+b/2,d-8,b,H);const N=T==="left"?v+d:v;X(n,N,R+b/2,k,r,A+"88",1.5*o)}};P(l,"left"),P(g,"right")}function x(n,t,c,s,a,p,M,o){const f=t.length;if(!f)return;const l=Math.ceil(Math.sqrt(f)),g=Math.ceil(f/l),h=a/l,r=p/g,i=Math.min(h,r)*.1;for(let e=0;e<f;e++){const u=e%l,y=Math.floor(e/l),d=c+u*h+i,b=s+y*r+i,P=h-i*2,m=r-i*2,T=W(e,M);L(n,d,b,P,m,8*o,T),j(T),n.save();const v=n.createLinearGradient(d,b,d,b+m*.5);v.addColorStop(0,"rgba(255,255,255,0.18)"),v.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=v,n.beginPath(),n.roundRect?.(d,b,P,m,8*o),n.fill(),n.restore();const k=I(t[e].text,P-12*o,m)*o;n.font=`${k}px sans-serif`,$(n,t[e].text,d+P/2,b+m/2,P-12*o,m,k)}}function gn(n,t,c,s,a,p,M,o,f){const l=V(t),g=z(c),h=16*f;n.save(),n.fillStyle="#f7f9fc",n.strokeStyle="#e0e4ec",n.lineWidth=1,n.beginPath(),n.roundRect?.(s,a,p,M,6*f)||n.rect(s,a,p,M),n.fill(),n.stroke();const r=s+h,i=a+h,e=p-h*2,u=M-h*2;if(!l.length){n.fillStyle="#aaa",n.font=`${12*f}px sans-serif`,n.textAlign="center",n.textBaseline="middle",n.fillText("SmartArt Diagram",s+p/2,a+M/2),n.restore();return}switch(g){case"process":J(n,l,r,i,e,u,o,f);break;case"cycle":K(n,l,r,i,e,u,o,f);break;case"hierarchy":O(n,l,r,i,e,u,o,f);break;case"radial":Q(n,l,r,i,e,u,o,f);break;case"pyramid":U(n,l,r,i,e,u,o,f);break;case"funnel":Z(n,l,r,i,e,u,o,f);break;case"venn":_(n,l,r,i,e,u,o,f);break;case"matrix":w(n,l,r,i,e,u,o,f);break;case"list":q(n,l,r,i,e,u,o,f);break;case"relationship":C(n,l,r,i,e,u,o,f);break;default:x(n,l,r,i,e,u,o,f)}n.restore()}export{gn as renderSmartArt};