@aeolus-fleet/console 0.27.0 → 0.27.1

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 (133) hide show
  1. package/.next/standalone/packages/console/.next/BUILD_ID +1 -1
  2. package/.next/standalone/packages/console/.next/build-manifest.json +3 -3
  3. package/.next/standalone/packages/console/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page/server-reference-manifest.json +16 -16
  5. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page.js.nft.json +1 -1
  6. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page/server-reference-manifest.json +16 -16
  8. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page.js.nft.json +1 -1
  9. package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page_client-reference-manifest.js +1 -1
  10. package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page/server-reference-manifest.json +16 -16
  11. package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page.js.nft.json +1 -1
  12. package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page_client-reference-manifest.js +1 -1
  13. package/.next/standalone/packages/console/.next/server/app/(console)/labels/page/server-reference-manifest.json +16 -16
  14. package/.next/standalone/packages/console/.next/server/app/(console)/labels/page.js.nft.json +1 -1
  15. package/.next/standalone/packages/console/.next/server/app/(console)/labels/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page/server-reference-manifest.json +16 -16
  17. package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page.js.nft.json +1 -1
  18. package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page_client-reference-manifest.js +1 -1
  19. package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page/server-reference-manifest.json +16 -16
  20. package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page.js.nft.json +1 -1
  21. package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page_client-reference-manifest.js +1 -1
  22. package/.next/standalone/packages/console/.next/server/app/(console)/network/page/server-reference-manifest.json +16 -16
  23. package/.next/standalone/packages/console/.next/server/app/(console)/network/page.js.nft.json +1 -1
  24. package/.next/standalone/packages/console/.next/server/app/(console)/network/page_client-reference-manifest.js +1 -1
  25. package/.next/standalone/packages/console/.next/server/app/(console)/page/react-loadable-manifest.json +1 -1
  26. package/.next/standalone/packages/console/.next/server/app/(console)/page/server-reference-manifest.json +16 -16
  27. package/.next/standalone/packages/console/.next/server/app/(console)/page.js.nft.json +1 -1
  28. package/.next/standalone/packages/console/.next/server/app/(console)/page_client-reference-manifest.js +1 -1
  29. package/.next/standalone/packages/console/.next/server/app/(console)/settings/page/server-reference-manifest.json +16 -16
  30. package/.next/standalone/packages/console/.next/server/app/(console)/settings/page.js.nft.json +1 -1
  31. package/.next/standalone/packages/console/.next/server/app/(console)/settings/page_client-reference-manifest.js +1 -1
  32. package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page/react-loadable-manifest.json +1 -1
  33. package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page/server-reference-manifest.json +16 -16
  34. package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page.js.nft.json +1 -1
  35. package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page_client-reference-manifest.js +1 -1
  36. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page/server-reference-manifest.json +16 -16
  37. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page.js.nft.json +1 -1
  38. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page_client-reference-manifest.js +1 -1
  39. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page/react-loadable-manifest.json +1 -1
  40. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page/server-reference-manifest.json +16 -16
  41. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page.js.nft.json +1 -1
  42. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page_client-reference-manifest.js +1 -1
  43. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page/react-loadable-manifest.json +1 -1
  44. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page/server-reference-manifest.json +16 -16
  45. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page.js.nft.json +1 -1
  46. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page_client-reference-manifest.js +1 -1
  47. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page/server-reference-manifest.json +16 -16
  48. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page.js.nft.json +1 -1
  49. package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page/server-reference-manifest.json +16 -16
  51. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page.js.nft.json +1 -1
  52. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page/server-reference-manifest.json +16 -16
  54. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page.js.nft.json +1 -1
  55. package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page_client-reference-manifest.js +1 -1
  56. package/.next/standalone/packages/console/.next/server/app/_global-error.html +1 -1
  57. package/.next/standalone/packages/console/.next/server/app/_global-error.rsc +1 -1
  58. package/.next/standalone/packages/console/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  59. package/.next/standalone/packages/console/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  60. package/.next/standalone/packages/console/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  61. package/.next/standalone/packages/console/.next/server/app/_not-found/page.js.nft.json +1 -1
  62. package/.next/standalone/packages/console/.next/server/app/api/reads/[read]/route.js.nft.json +1 -1
  63. package/.next/standalone/packages/console/.next/server/app/sign-in/failed/page.js.nft.json +1 -1
  64. package/.next/standalone/packages/console/.next/server/app/sign-in/page.js.nft.json +1 -1
  65. package/.next/standalone/packages/console/.next/server/app/version/route.js.nft.json +1 -1
  66. package/.next/standalone/packages/console/.next/server/chunks/[root-of-the-server]__06f_104._.js +1 -1
  67. package/.next/standalone/packages/console/.next/server/chunks/[root-of-the-server]__1cfwaji._.js +1 -1
  68. package/.next/standalone/packages/console/.next/server/chunks/_1uqphll._.js +1 -1
  69. package/.next/standalone/packages/console/.next/server/chunks/ssr/0mxb_server_app_(console)_squadrons_blueprints_[name]_page_actions_170owr_.js +1 -1
  70. package/.next/standalone/packages/console/.next/server/chunks/ssr/0mxb_server_app_(console)_squadrons_templates_[name]_page_actions_09abrr0.js +1 -1
  71. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_fleet-health_page_actions_1gb6-fk.js +1 -1
  72. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_needs-crew_page_actions_08gu8-f.js +1 -1
  73. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_network_page_actions_1muuv-j.js +1 -1
  74. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_settings_page_actions_0b6qztr.js +1 -1
  75. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_ships_[shipId]_page_actions_0g2nd1p.js +1 -1
  76. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_squadrons_page_actions_1x3afts.js +1 -1
  77. package/.next/standalone/packages/console/.next/server/chunks/ssr/0ysl_console__next-internal_server_app_(console)_trierarchs_page_actions_1ow37mz.js +1 -1
  78. package/.next/standalone/packages/console/.next/server/chunks/ssr/1eui__next-internal_server_app_(console)_fleet-health_[cause]_page_actions_1kltvcl.js +1 -1
  79. package/.next/standalone/packages/console/.next/server/chunks/ssr/1eui__next-internal_server_app_(console)_needs-attention_page_actions_1jfgclw.js +1 -1
  80. package/.next/standalone/packages/console/.next/server/chunks/ssr/1eui__next-internal_server_app_(console)_squadrons_[squadronId]_page_actions_1lzqlye.js +1 -1
  81. package/.next/standalone/packages/console/.next/server/chunks/ssr/1eui__next-internal_server_app_(console)_trierarchs_[shipId]_page_actions_0l7bxva.js +1 -1
  82. package/.next/standalone/packages/console/.next/server/chunks/ssr/_065633k._.js +1 -1
  83. package/.next/standalone/packages/console/.next/server/chunks/ssr/{_050ulkd._.js → _0dgwyy6._.js} +1 -1
  84. package/.next/standalone/packages/console/.next/server/chunks/ssr/_0eeox-9._.js +1 -1
  85. package/.next/standalone/packages/console/.next/server/chunks/ssr/{_1vc4auf._.js → _0ljoc6_._.js} +1 -1
  86. package/.next/standalone/packages/console/.next/server/chunks/ssr/_15_xzod._.js +1 -1
  87. package/.next/standalone/packages/console/.next/server/chunks/ssr/_1_9jlty._.js +1 -1
  88. package/.next/standalone/packages/console/.next/server/chunks/ssr/{_1j1ejbw._.js → _1calzjj._.js} +1 -1
  89. package/.next/standalone/packages/console/.next/server/chunks/ssr/_1u0h4gj._.js +1 -1
  90. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_common_dist_1_gq_cl._.js +1 -1
  91. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_18f93ie._.js → packages_console_095mmim._.js} +1 -1
  92. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_2004f3v._.js → packages_console_13ry5_2._.js} +1 -1
  93. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_0969g9_._.js → packages_console_1myu9eb._.js} +2 -2
  94. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_1clix79._.js → packages_console_1pds_ub._.js} +1 -1
  95. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console__next-internal_server_app_(console)_inbox_page_actions_0q9_xye.js +1 -1
  96. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console__next-internal_server_app_(console)_labels_page_actions_0tk7mqs.js +1 -1
  97. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console__next-internal_server_app_(console)_page_actions_1ftjjyq.js +1 -1
  98. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_app_(console)_network_network-page_tsx_0qc3h-9._.js +1 -1
  99. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_app_(console)_ships_[shipId]_ship-page_tsx_0oahz0r._.js +1 -1
  100. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_components_organisms_crew-line-dialog_tsx_1qorkk0._.js → packages_console_components_organisms_crew-line-dialog_tsx_1tmwb3z._.js} +1 -1
  101. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_features_ship_ui_organisms_message-sheet_tsx_08bg9ly._.js +1 -1
  102. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_0ditu5u._.js → packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_11piudw._.js} +1 -1
  103. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_13oketj._.js → packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_1_2jov8._.js} +1 -1
  104. package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_features_trierarchs_organisms_clear-worktree-dialog_tsx_1vigea_._.js → packages_console_features_trierarchs_organisms_clear-worktree-dialog_tsx_0dogayz._.js} +1 -1
  105. package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_lib_1b-azvo._.js +1 -1
  106. package/.next/standalone/packages/console/.next/server/middleware-build-manifest.js +3 -3
  107. package/.next/standalone/packages/console/.next/server/pages/500.html +1 -1
  108. package/.next/standalone/packages/console/.next/server/server-reference-manifest.js +1 -1
  109. package/.next/standalone/packages/console/.next/server/server-reference-manifest.json +17 -17
  110. package/.next/standalone/packages/console/.next/static/chunks/0k_f9ghdbhdlh.js +1 -0
  111. package/.next/standalone/packages/console/.next/static/chunks/{40js517zsadm9.js → 1gmxwgg3tuq9j.js} +1 -1
  112. package/.next/standalone/packages/console/.next/static/chunks/{323r-smxvi-fc.js → 1l5d_-f5_4n13.js} +1 -1
  113. package/.next/standalone/packages/console/.next/static/chunks/{2600yzum9pa4e.js → 1lu3lt0jl2qe-.js} +1 -1
  114. package/.next/standalone/packages/console/.next/static/chunks/{2qc_m8dbgxc8w.js → 2chqk2x196ti0.js} +1 -1
  115. package/.next/standalone/packages/console/.next/static/chunks/2j2d4nw9_nas6.js +1 -0
  116. package/.next/standalone/packages/console/.next/static/chunks/{38klmgk3bgj3s.js → 2l7g6epwsx9wf.js} +1 -1
  117. package/.next/standalone/packages/console/.next/static/chunks/{25l_2rj6pvegd.js → 2y5xx24gswylp.js} +1 -1
  118. package/.next/standalone/packages/console/.next/static/chunks/{41ur4zm093e1l.js → 318sjnwsspety.js} +1 -1
  119. package/.next/standalone/packages/console/.next/static/chunks/{2fkwzi80oyuv-.js → 36n7fei4v2kye.js} +1 -1
  120. package/.next/standalone/packages/console/.next/static/chunks/{2n_dccp7oi2ad.js → 3f5v4p3jz0k1g.js} +1 -1
  121. package/.next/standalone/packages/console/.next/static/chunks/3n6d3yt_vtnne.js +1 -0
  122. package/.next/standalone/packages/console/.next/static/chunks/{3kvklsjp8y-7e.js → 3o8213x94m4o3.js} +1 -1
  123. package/.next/standalone/packages/console/.next/static/chunks/{0o8q0d16-yt3a.js → 3qrq-wd28w60w.js} +1 -1
  124. package/.next/standalone/packages/console/.next/static/chunks/{20l4-ecv_oo2h.js → 420usygo4rcxp.js} +1 -1
  125. package/.next/standalone/packages/console/package.json +3 -3
  126. package/README.md +2 -2
  127. package/package.json +3 -3
  128. package/.next/standalone/packages/console/.next/static/chunks/061rac_vo9o5d.js +0 -1
  129. package/.next/standalone/packages/console/.next/static/chunks/0sagpcmh6omoj.js +0 -1
  130. package/.next/standalone/packages/console/.next/static/chunks/18rsibme2venq.js +0 -1
  131. /package/.next/standalone/packages/console/.next/static/{ZV7FLBaZ7IVExYMj-OJbA → Idv688KqeLyROC1itAuuQ}/_buildManifest.js +0 -0
  132. /package/.next/standalone/packages/console/.next/static/{ZV7FLBaZ7IVExYMj-OJbA → Idv688KqeLyROC1itAuuQ}/_clientMiddlewareManifest.js +0 -0
  133. /package/.next/standalone/packages/console/.next/static/{ZV7FLBaZ7IVExYMj-OJbA → Idv688KqeLyROC1itAuuQ}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,15860,e=>{"use strict";var t=e.i(43476),s=e.i(18566),n=e.i(71645),a=e.i(60592),i=e.i(65041),r=e.i(56420);let d={name:"arrow-down-left",size:24,node:[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]};d.node;let l=(0,r.default)(d),o={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};o.node;let c=(0,r.default)(o),u={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};u.node;let m=(0,r.default)(u);var h=e.i(25398),p=e.i(90063),x=e.i(69693);function g(e,t){return RegExp(`"${t}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`).exec(e)?.[1]}let f={"application/vnd.aeolus.squadron.check-in+json":()=>"Checked in at its flagship","application/vnd.aeolus.squadron.role+json":e=>{let t=g(e,"role");return void 0===t?"Given its role":`Given the role: ${t}`},"application/vnd.aeolus.squadron.on-station+json":e=>{let t=g(e,"role");return void 0===t?"Took up its role":`Took up the role: ${t}`},"application/vnd.aeolus.squadron.stand-down+json":()=>"Asked to stand down","application/vnd.aeolus.squadron.stood-down+json":()=>"Stood down"};var v=e.i(79369),b=e.i(49635),w=e.i(46150);function j(e,t){return e.sentAt.localeCompare(t.sentAt)||e.id.localeCompare(t.id)}var y=e.i(15905),N=e.i(67874),k=e.i(17981),C=e.i(88393),S=e.i(39124),T=e.i(78865);function R({message:e,shipId:s,now:n,onOpenMessage:a}){var i,r,d;let o,u,m=e.sender.id===s,h=new Date(e.sentAt),g=void 0!==(u=f[r=(i=e).contentType,r.split(";")[0]?.trim().toLowerCase()??""])?{text:u(i.preview),isCode:!1}:(0,x.isJson)(i.contentType)?{text:0===(o=function(e){let t,s=[],n=0,a=0;for(;a<e.length;){let i=e[a]??"";if('"'===i){let{value:i,end:r}=function(e,t){let s=t+1;for(;s<e.length&&'"'!==e[s];)s+="\\"===e[s]?2:1;return{value:e.slice(t+1,s),end:s+1}}(e,a);1===n&&void 0===t&&e.slice(r).trimStart().startsWith(":")?t=i:1===n&&void 0!==t&&r<=e.length&&'"'===e[r-1]&&(s.push([t,i]),t=void 0),a=r;continue}if("{"===i||"["===i)1===n&&void 0!==t&&(s.push([t,"…"]),t=void 0),n+=1;else if("}"===i||"]"===i)n-=1;else if(1===n&&void 0!==t&&/[-\dtfn]/.test(i)){let n=/^(-?\d[\d.eE+-]*|true|false|null)/.exec(e.slice(a))?.[1];if(void 0!==n){s.push([t,n]),t=void 0,a+=n.length;continue}}a+=1}return s}(d=i.preview)).length?d:o.map(([e,t])=>`${e} ${t}`).join(" · "),isCode:!0}:{text:i.preview,isCode:!1};return(0,t.jsx)("li",{className:"border-b border-border last:border-b-0",children:(0,t.jsxs)("button",{type:"button","data-testid":"message-row","data-message-id":e.id,"aria-label":`${m?"Sent":"Received"} message: ${g.text}`,className:"flex w-full items-start gap-3 px-3.5 py-3 text-left transition-colors duration-(--duration-fast) hover:bg-accent",onClick:()=>{a(e.id)},children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md border border-tone-ended-border bg-tone-ended-bg text-tone-ended-fg [&_svg]:size-(--size-icon-sm)",children:(0,t.jsx)(m?c:l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,t.jsxs)("span",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)(S.Sentence,{parts:m?"ship"===e.recipient.kind?[(0,w.text)("To "),(0,w.ship)(e.recipient.ship)]:[(0,w.text)(`To any ship of type ${e.recipient.type}`)]:[(0,w.text)("From "),(0,w.ship)(e.sender)],className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)(T.StatusBadge,{status:(0,v.deliveryStatus)(e.delivery)})]}),(0,t.jsx)("span",{"data-testid":"message-line",className:(0,p.classNames)("truncate text-muted-foreground",g.isCode?"font-mono text-id":"text-meta"),children:g.text}),(0,t.jsx)("time",{dateTime:e.sentAt,title:(0,b.fullDateTime)(h),className:"text-meta text-muted-foreground tabular-nums",children:(0,b.relativeTime)(h,n)})]})]})})}function $({shipId:e,messages:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the messages"}):"error"===n?(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3",children:[(0,t.jsx)(k.InlineError,{title:"Couldn’t load the messages",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),onClick:a,className:"self-start",children:"Try again"}):null]}):0===s.length?(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(m,{}),title:"No messages yet",description:"Messages this ship sends or receives appear here as they happen."}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:(function(e){let t=new Map(e.map(e=>[e.id,e])),s=new Map;for(let n of e){let e=function(e,t){let s=new Set([e.id]),n=e,a=null===n.inReplyTo?void 0:t.get(n.inReplyTo);for(;a&&!s.has(a.id);)s.add(a.id),a=null===(n=a).inReplyTo?void 0:t.get(n.inReplyTo);return n}(n,t);s.set(e.id,[...s.get(e.id)??[],n])}return[...s.entries()].map(([e,t])=>{let s=t.toSorted(j);return{id:e,messages:s,lastSentAt:s.at(-1)?.sentAt??""}}).toSorted((e,t)=>t.lastSentAt.localeCompare(e.lastSentAt)||t.id.localeCompare(e.id))})(s).map(s=>(0,t.jsx)("section",{"data-testid":"message-thread","aria-label":`Thread of ${String(s.messages.length)} ${1===s.messages.length?"message":"messages"}`,className:"overflow-hidden rounded-lg border border-border bg-card",children:(0,t.jsx)("ol",{children:s.messages.map(s=>(0,t.jsx)(R,{message:s,shipId:e,now:i,onOpenMessage:r},s.id))})},s.id))})}var q=e.i(17540),I=e.i(90262),A=e.i(54492),D=e.i(8041),L=e.i(5387),O=e.i(80581),z=e.i(10921),P=e.i(78608),M=e.i(84156),B=e.i(265),E=e.i(41880),F=e.i(16984),H=e.i(74544),_=e.i(58925),U=e.i(18964),V=e.i(11568),W=e.i(68997),K=e.i(57665),G=e.i(95925),Y=e.i(86875),J=e.i(22016),X=e.i(25242),Q=e.i(66616),Z=e.i(95960);let ee={request:"Couldn’t request crew",remove:"Couldn’t remove the request",restart:"Couldn’t restart the crew"};function et({at:e,now:s,children:n}){return(0,t.jsx)("time",{dateTime:e,title:(0,b.fullDateTime)(new Date(e)),className:"tabular-nums",children:n??(0,b.sinceTime)(new Date(e),s)})}function es({trierarch:e,hasTrierarchs:s}){return(0,t.jsxs)(J.default,{href:s?`/trierarchs/${e.id}`:`/ships/${e.id}`,"data-testid":"crew-request-trierarch",className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground underline decoration-input underline-offset-3 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[(0,t.jsx)(Y.ShipWheel,{"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e.name})]})}function en({requestedBy:e,requestedAt:s,now:n}){let a=null===e?null:e.name===w.OPERATOR_NAME?"you":e.name;return(0,t.jsxs)("span",{"data-testid":"crew-request-requested-by",children:[null===a?"Requested ":`Requested by ${a} `,(0,t.jsx)(et,{at:s,now:n,children:(0,b.relativeTime)(new Date(s),n)}),"."]})}let ea={note:"border-border bg-muted text-muted-foreground",waiting:"border-tone-waiting-border bg-tone-waiting-bg text-tone-waiting-fg",attention:"border-tone-attention-border bg-tone-attention-bg text-tone-attention-fg"};function ei({tone:e,icon:s,children:n}){return(0,t.jsxs)("div",{role:"attention"===e?"alert":"waiting"===e?"status":"note","data-testid":"crew-request-note",className:`flex items-start gap-2 rounded-lg border px-3 py-2.5 text-meta [&_svg]:mt-0.5 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 ${ea[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function er({stage:e,now:s}){let n="running"===e.status?e.startedAt:null,a=(0,A.restartWords)(e);return null===n&&void 0===a?null:(0,t.jsxs)("span",{className:"text-meta text-muted-foreground","data-testid":"crew-request-session",children:[null===n?null:(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(et,{at:n,now:s})]}),null!==n&&void 0!==a?" · ":null,a]})}function ed({rows:e,machineLabels:s=[]}){return(0,t.jsxs)("dl",{"data-testid":"crew-request-settings",className:"grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-x-5 gap-y-3 border-t border-border pt-3",children:[e.map(e=>(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("dt",{className:"text-caption font-medium text-muted-foreground",children:e.label}),(0,t.jsxs)("dd",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-body font-medium",children:[null===e.value?(0,t.jsx)("span",{className:"font-normal text-muted-foreground",children:"None"}):(0,t.jsx)("span",{className:e.isMono?"truncate font-mono text-id":"truncate",children:"Harness"===e.label?(0,Q.harnessWord)(e.value):e.value}),void 0===e.meta?null:(0,t.jsx)("span",{className:"text-meta font-normal text-muted-foreground",children:e.meta})]})]},e.label)),0===s.length?null:(0,t.jsxs)("div",{className:"col-span-full flex min-w-0 flex-col gap-0.5","data-testid":"crew-request-machine-labels",children:[(0,t.jsx)("dt",{className:"text-caption font-medium text-muted-foreground",children:"Machine labels"}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:s.map((e,s)=>(0,t.jsxs)(n.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(Z.LabelChip,{chip:e})]},e.valueId))})]})]})}function el(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(U.ListChecks,{"aria-hidden":!0,className:"size-(--size-icon) text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-section font-semibold",children:"Crew request"})]})}function eo(e){let{noMachineMatchesReason:s}=(0,X.useConsoleConstants)(),{stage:n,requestedBy:a,now:i,canManage:r,isAwaitingCrew:d,busy:l,error:o}=e,c=void 0===o?null:(0,t.jsx)(k.InlineError,{title:ee[o.action],description:`${o.message} Nothing changed.`});if("none"===n.kind)return(0,t.jsxs)("section",{"aria-label":"Crew request","data-testid":"crew-request",className:"flex flex-col gap-2.5 rounded-lg border border-border bg-card px-4 py-3.5 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3.5",children:[(0,t.jsx)(el,{}),(0,t.jsx)("p",{className:"min-w-0 flex-1 text-meta text-muted-foreground",children:e.hasTrierarchs?"No crew request. A crew request keeps this ship crewed: a trierarch starts a session for it and restarts it when it stops.":"No crew request. A crew request puts this ship on your Needs crew list until you crew it by hand."}),r?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(U.ListChecks,{}),isLoading:"request"===l,onClick:e.onRequest,"data-testid":"crew-request-request",children:"Request crew"}):null]}),c]});let u=(0,A.crewRequestAction)(n),m=void 0!==l;return(0,t.jsxs)("section",{"aria-label":"Crew request","data-testid":"crew-request",className:"flex flex-col gap-2.5 rounded-lg border border-border bg-card px-4 py-3.5 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsx)(el,{}),(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-2","data-testid":"crew-request-state",children:["assigned"===n.kind?(0,t.jsx)(T.StatusBadge,{status:n.status}):(0,t.jsx)(T.StatusBadge,{status:n.kind}),"needsCrew"===n.kind?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e.hasTrierarchs?"not assigned yet":n.reason??(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(et,{at:n.requestedAt,now:i})]})}):null,"crewedByHand"===n.kind&&null!==n.since?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["since ",(0,t.jsx)(et,{at:n.since,now:i})]}):null,"assigned"===n.kind?(0,t.jsx)(er,{stage:n,now:i}):null,"assigned"===n.kind&&"releasing"===n.status&&void 0!==e.statusChangedAt?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["asked ",(0,t.jsx)(et,{at:e.statusChangedAt,now:i})]}):null]}),"assigned"===n.kind?(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 text-meta",children:["on ",(0,t.jsx)(es,{trierarch:n.trierarch,hasTrierarchs:e.hasTrierarchs??!1})]}):null,(0,t.jsx)("span",{className:"flex-1"}),"assigned"===n.kind&&"releasing"===n.status?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["Waiting for ",n.trierarch.name]}):null,r?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["remove"===u?(0,t.jsx)(y.Button,{size:"sm",variant:"ghost",isLoading:"remove"===l,disabled:m,onClick:e.onRemove,"data-testid":"crew-request-remove",children:"Remove request"}):null,(0,A.isRestartable)(n)?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(G.RotateCcw,{}),isLoading:"restart"===l,disabled:m,onClick:e.onRestart,"data-testid":"crew-request-restart",children:"Restart"}):null,void 0!==e.onEdit&&void 0!==u?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(W.Pen,{}),disabled:m,onClick:e.onEdit,"data-testid":"crew-request-edit",children:"Edit…"}):null,"release"===u?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(K.Power,{}),disabled:m,onClick:e.onRelease,"data-testid":"crew-request-release",children:"Release…"}):null,"needsCrew"===n.kind&&d&&!e.hasTrierarchs?(0,t.jsx)(y.Button,{size:"sm",variant:"primary",icon:(0,t.jsx)(_.KeyRound,{}),disabled:m,onClick:e.onGetStartingPrompt,"data-testid":"crew-request-prompt",children:"Get starting prompt"}):null]}):null]}),"assigned"===n.kind?function(e,s){let{trierarch:n}=e,a=void 0===s.statusChangedAt?null:(0,t.jsx)(et,{at:s.statusChangedAt,now:s.now});switch(e.status){case"crewing":return(0,t.jsxs)(ei,{tone:"note",icon:(0,t.jsx)(V.LoaderCircle,{"aria-hidden":!0}),children:[n.name," is starting the session."]});case"running":return null;case"restarting":return(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(G.RotateCcw,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:null===a?"The session stopped.":(0,t.jsxs)(t.Fragment,{children:["The session stopped at ",a,"."]})})," ",n.name," is starting it again. Once its restarts are used up it stops trying and the request shows Crashed."]});case"crashed":return(0,t.jsxs)(ei,{tone:"attention",icon:(0,t.jsx)(F.CircleX,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:null===a?"Crashed.":(0,t.jsxs)(t.Fragment,{children:["Crashed at ",a,"."]})})," The session kept stopping and ",n.name," ","stopped trying. The lease still holds, so new deliveries wait in the inbox. Restart crews it again with the same settings."]});case"releasing":return(0,t.jsxs)(ei,{tone:"note",icon:(0,t.jsx)(K.Power,{"aria-hidden":!0}),children:["Releasing: ",n.name," is stopping the session and cleaning up. The request goes away once it confirms."]})}}(n,{statusChangedAt:e.statusChangedAt,now:i}):null,"needsCrew"===n.kind&&e.hasTrierarchs?null===n.reason?(0,t.jsx)(ei,{tone:"note",icon:(0,t.jsx)(V.LoaderCircle,{"aria-hidden":!0}),children:"Waiting for the trierarch plugin to assign a trierarch."}):n.reason===s&&void 0!==e.machineLabels&&e.machineLabels.length>0?(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(H.Clock,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:"No machine matches these labels."})," The plugin places this ship only on a machine with ",(0,P.machineLabelsText)(e.machineLabels),", and none"," ",(0,P.noMatchWords)(e.machineLabels.length).carries,". It assigns a trierarch as soon as one does; until then this ship is on Needs crew."]}):(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(H.Clock,{"aria-hidden":!0}),children:[(0,t.jsxs)("strong",{className:"font-medium",children:[(0,w.capitalised)(n.reason),"."]})," The plugin assigns a trierarch as soon as one fits. Until then this ship is on Needs crew."]}):null,c,void 0===e.settingsRows?null:(0,t.jsx)(ed,{rows:e.settingsRows,machineLabels:e.machineLabels}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["needsCrew"!==n.kind||e.hasTrierarchs?null:"On your Needs crew list. Crew it by hand: get a starting prompt and start a session with it. Crewing it fulfils the request; the request stays until you remove it. ","crewedByHand"===n.kind?`${n.crewedBy.name===w.OPERATOR_NAME?"You":n.crewedBy.name} crewed it by hand. The request stands: if the lease ends, the ship is back on Needs crew until you crew it again or release it. `:null,(0,t.jsx)(en,{requestedBy:a,requestedAt:n.requestedAt,now:i}),"assigned"===n.kind&&"releasing"!==n.status?" The trierarch keeps it crewed until you release it.":null]})]})}var ec=e.i(86165),eu=e.i(48695);let em=(0,q.lazyDialog)(()=>e.A(23569).then(e=>e.RequestCrewDialog),e=>e.isOpen),eh=(0,q.lazyDialog)(()=>e.A(5419).then(e=>e.CrewReleaseDialog),e=>e.isOpen),ep=(0,q.lazyDialog)(()=>e.A(95953).then(e=>e.StartingPromptDialog),e=>e.isOpen);function ex({ship:e,timeline:s,now:a}){let i=(0,I.useAccess)(),r=(0,B.useHasTrierarchPlugin)(),d=(0,L.useRequestCrew)(),l=(0,L.useLabelContext)(),o=(0,L.useRemoveCrewRequest)(),c=(0,L.useReleaseShip)(),u=(0,L.useGetStartingPrompt)(),[m,h]=(0,n.useState)(),[p,x]=(0,n.useState)(),[g,f]=(0,n.useState)(!1),[v,b]=(0,n.useState)(),[w,j]=(0,n.useState)(!1),[y,N]=(0,n.useState)(),[k]=(0,z.useCrewSettings)(null===e.crewRequest?[]:[e.crewRequest.settings])??[],C=function(e){let s=(0,B.useMachines)(),a=(0,ec.useSquadronsConnection)(),i=(0,eu.useSquadrons)(),r=(0,L.useRequestCrew)(),d=(0,L.useLabelContext)(),[l,o]=(0,n.useState)(),[c,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(),p=(0,D.offersOf)(s.data??[]),{shipLabelsMax:x}=(0,X.useConsoleConstants)(),g=void 0===d||void 0===s.data?void 0:(0,P.machineLabelsInputOf)(d,{machines:s.data,shipLabelsMax:x}),f=(0,z.useCrewSettings)(e?.heldSettings===void 0?[]:[e.heldSettings]),v=f?.[0]??null,b=(0,D.settingsOf)("edit"===l?(0,D.valuesOf)(v,p):(0,D.defaultValues)(p)),w=void 0!==l&&void 0!==e&&("edit"!==l||void 0!==f),j=(0,B.useCrewSettingsCheck)(w&&void 0!==s.data?null===c?b:c:void 0),y=async t=>{if(void 0!==e&&void 0!==l){r.reset();try{let e=await j.checkNow();if("refused"===e.kind)return void h(new Date)}catch{}r.mutate({shipId:e.shipId,settings:t},{onSuccess:()=>{o(void 0),(0,E.showToast)("edit"===l?{title:`Settings saved for ${e.shipName}`,description:"Its trierarch restarts the session with them.",tone:"success"}:{title:`Crew requested for ${e.shipName}`,description:"The trierarch plugin assigns a trierarch that fits.",tone:"success"})}})}};return{open:e=>{r.reset(),u(null),h(void 0),o(e)},dialog:void 0===e?null:(0,t.jsx)(em,{shipName:e.shipName,mode:l??"request",state:s.isError?"unreachable":void 0===s.data?"loading":"ready",offers:p,heldSettings:v,squadrons:"connected"===a?(i.data??[]).filter(e=>"disbanded"!==e.state).map(e=>e.id):void 0,...void 0===g?{}:{machineLabels:g},check:j.data,refusedAt:m,error:r.error?.message,isPending:r.isPending,isOpen:w,onOpenChange:e=>{e||o(void 0)},onSettingsChange:e=>{u(e),h(void 0)},onSubmit:e=>void y(e),onRetry:()=>{s.refetch()}})}}("agent"===e.kind&&"retired"!==e.status?{shipId:e.id,shipName:e.name,heldSettings:e.crewRequest?.settings}:void 0);if("agent"!==e.kind||"retired"===e.status)return null;let S=(0,A.crewRequestStage)(e),T=e.crewRequest,R=async(e,t)=>{h(e),x(void 0);try{return await t(),!0}catch(t){return x({action:e,message:t instanceof Error?t.message:String(t)}),!1}finally{h(void 0)}},$=()=>{u.reset(),N((0,M.isUnclaimedPromptOut)(e)&&e.startingPrompt?{issuedAt:e.startingPrompt.issuedAt}:void 0),j(!0),u.mutate({shipId:e.id})},q=async()=>{await R("request",()=>d.mutateAsync({shipId:e.id,settings:{}}))&&(0,E.showToast)({title:`${e.name} needs crew`,description:"It is on your Needs crew list until you crew it.",tone:"success",..."awaitingCrew"===e.status&&i.canManage?{action:{label:"Get starting prompt",onClick:$}}:{}})},F=async()=>{null===T||"assigned"!==S.kind||await R("restart",()=>d.mutateAsync({shipId:e.id,settings:T.settings}))&&(0,E.showToast)({title:`Restarting ${e.name}`,description:`${S.trierarch.name} starts its session again with the same settings.`,tone:"success"})},H=async t=>{b(void 0);let s=(0,A.releaseSteps)(t),n=0;try{for(let t of s)await ("removeCrewRequest"===t?o.mutateAsync({shipId:e.id}):c.mutateAsync({shipId:e.id})),n+=1;f(!1)}catch(t){let e=t instanceof Error?t.message:String(t);b(0===n?`${e} Nothing changed.`:`${e} Its crew request is removed; the session still holds the ship. Try again to end its lease.`)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo,{stage:S,requestedBy:(0,A.requestedBy)(s),statusChangedAt:(0,A.statusChangedAt)(s),now:a,canManage:i.canManage,isAwaitingCrew:"awaitingCrew"===e.status,hasTrierarchs:r,busy:m,error:p,settingsRows:null===T?void 0:(0,D.settingsRows)(k),...null===T||void 0===l?{}:{machineLabels:(0,O.pickedChips)((0,P.machineLabelIdsOf)(k),l)},onRequest:()=>{r?C.open("request"):q()},...r?{onEdit:()=>{C.open("edit")}}:{},onRemove:()=>void R("remove",()=>o.mutateAsync({shipId:e.id})),onRelease:()=>{b(void 0),f(!0)},onRestart:()=>void F(),onGetStartingPrompt:$}),C.dialog,"crewedByHand"===S.kind||"assigned"===S.kind?(0,t.jsx)(eh,{shipName:e.name,stage:S,sessionLocation:null===e.location?null:e.location.description??e.location.kind.toLowerCase(),inFlightCount:e.inFlightDeliveries,isOpen:g,onOpenChange:f,isPending:o.isPending||c.isPending,error:v,onConfirm:()=>void H(S)}):null,(0,t.jsx)(ep,{shipName:e.name,state:u.data?"shown":u.isError?"error":"issuing",prompt:u.data?.prompt,crewLines:u.data?.crewLines,replacesUnclaimed:y,error:u.error?.message,isOpen:w,onOpenChange:e=>{e||(u.reset(),j(!1))},onConfirm:()=>{u.mutate({shipId:e.id})}})]})}var eg=e.i(84294),ef=e.i(19249);function ev({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 bg-card px-3.5 py-3",children:[(0,t.jsx)("dt",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-body text-foreground",children:s})]})}function eb({shipId:e,now:s}){let n=(0,eu.useSquadrons)(),a=(0,eu.useCatalogue)(),i=n.data?.find(t=>t.flagship.shipId===e||t.members.some(t=>t.shipId===e));if(!i)return null;let r=(0,t.jsx)(J.default,{href:`/squadrons/${i.id}`,className:"font-mono hover:underline","data-testid":"ship-squadron-link",children:i.id});if(i.flagship.shipId===e)return(0,t.jsxs)("div",{role:"note","data-testid":"ship-flagship-note",className:"flex flex-wrap items-center gap-3 rounded-lg border border-border bg-muted px-3.5 py-3 text-meta text-foreground",children:[(0,t.jsxs)("span",{className:"grow",children:["Flagship of squadron ",r,": the address for work sent to the team. The squadron manager crews it, so it can’t be released, renamed or retired; it retires when the squadron disbands."]}),(0,t.jsx)(y.Button,{size:"xs",nativeButton:!1,render:(0,t.jsx)(J.default,{href:`/squadrons/${i.id}`}),"data-testid":"ship-open-squadron",children:"Open squadron"})]});let d=i.members.find(t=>t.shipId===e);if(!d)return null;let l=a.data?.blueprints.find(e=>e.repository===i.blueprint.repository&&e.name===i.blueprint.name&&e.version===i.blueprint.version),o=l?.roles.find(e=>e.name===d.role)?.template,c=null===d.crew.lastSeenAt?void 0:(0,b.duration)(new Date(d.crew.lastSeenAt),s);return(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:["silent"===d.health&&"disbanded"!==i.state&&(0,t.jsxs)("div",{role:"alert","data-testid":"ship-silent-alert",className:"rounded-lg border border-tone-attention-border bg-tone-attention-bg px-3.5 py-3 text-meta text-foreground",children:[(0,t.jsx)("strong",{className:"font-semibold text-tone-attention-fg",children:void 0===c?"Silent.":`Silent: not seen for ${c}.`})," It checks in"," ",(0,eg.checkInText)(d.checkInMinutes),", so its session has probably stopped. Get a new crew line and start a new session; the old crew line then stops working."]}),(0,t.jsxs)("dl",{"data-testid":"ship-squadron-facts",className:"grid grid-cols-4 gap-px overflow-hidden rounded-lg border border-border bg-border max-sm:grid-cols-2",children:[(0,t.jsxs)(ev,{label:"Squadron",children:[r,(0,t.jsx)(T.StatusBadge,{status:i.state})]}),(0,t.jsxs)(ev,{label:"Role and template",children:[(0,t.jsx)("span",{className:"rounded-sm bg-secondary px-1.5 font-mono text-id",children:d.role}),o&&(0,t.jsxs)(J.default,{href:(0,eg.templatePath)(o),className:"font-mono text-meta hover:underline",children:[o.name,"@",o.version]})]}),(0,t.jsx)(ev,{label:"Health",children:(0,t.jsx)(ef.HealthIndicator,{health:d.health,detail:"silent"===d.health||"late"===d.health?c:void 0})}),(0,t.jsx)(ev,{label:"Hand-offs",children:l?(0,t.jsx)("span",{className:"text-meta",children:(0,eg.handoffsText)((0,eg.handoffsOf)(l,d.role))}):(0,t.jsx)(J.default,{href:(0,eg.blueprintPath)(i.blueprint),className:"text-meta text-muted-foreground hover:underline",children:"See its blueprint"})})]})]})}var ew=e.i(21959),ej=e.i(15327),ey=e.i(76561),eN=e.i(22768),ek=e.i(10818),eC=e.i(69309),eS=e.i(26478),eT=e.i(66390),eR=e.i(61966),e$=e.i(19321),eq=e.i(63481);function eI({harness:e,model:s,testId:n}){return null===e&&null===s?null:(0,t.jsxs)("span",{"data-testid":n,className:"flex min-w-0 flex-wrap items-center gap-x-1 text-meta text-muted-foreground",children:[null===e?null:(0,t.jsx)("span",{children:(0,Q.harnessWord)(e)}),null!==e&&null!==s?(0,t.jsx)("span",{"aria-hidden":!0,children:"·"}):null,null===s?null:(0,t.jsx)("span",{className:"truncate font-mono text-id",children:s})]})}var eA=e.i(73330);function eD({ping:e,now:s,testId:n}){return null===e?null:(0,t.jsx)("span",{title:`Pinged ${(0,b.fullDateTime)(new Date(e.sentAt))}`,"data-testid":n,"data-state":e.state,className:"text-meta text-muted-foreground tabular-nums",children:(0,eA.pingLine)(e,s)})}var eL=e.i(67927),eO=e.i(93361),ez=e.i(91703);function eP({details:e,bytes:s,version:n,testId:a}){return(0,t.jsxs)("details",{"data-testid":a,className:"group rounded-lg border border-border bg-card",children:[(0,t.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 px-3.5 py-2.5 text-meta text-muted-foreground [&::-webkit-details-marker]:hidden",children:[(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0,className:"size-(--size-icon-sm) shrink-0 transition-transform group-open:rotate-90"}),(0,t.jsx)("span",{className:"font-medium text-foreground",children:"Report details"}),(0,t.jsxs)("span",{className:"tabular-nums",children:["· version ",n]})]}),(0,t.jsx)("div",{className:"px-3.5 pb-3.5",children:(0,t.jsx)(ez.CodeBlock,{label:(0,eO.reportDetailsLabel)(s),code:(0,eO.reportDetailsJson)(e),copyLabel:"Copy report details",codeTestId:`${a}-code`})})]})}var eM=e.i(81830),eB=e.i(39448);function eE({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 bg-card px-3.5 py-3",children:[(0,t.jsx)("dt",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"flex min-w-0 items-center gap-1.5 text-body text-foreground",children:s})]})}function eF({ship:e,now:s,labels:n,way:a}){let i,r="operator"===e.kind,d=null===e.crewedSince?null:new Date(e.crewedSince),l=new Date(e.commissionedAt);return(0,t.jsxs)("dl",{className:"grid grid-cols-4 gap-px overflow-hidden rounded-lg border border-border bg-border max-sm:grid-cols-2",children:[(0,t.jsx)(eE,{label:"Location",children:(0,t.jsxs)("span",{className:"inline-flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)(eq.LocationTag,{kind:e.location?.kind??null,description:e.location?.description,size:"md"}),(0,t.jsx)(eI,{harness:e.harness,model:e.model?.id??null,testId:"ship-model"}),null===e.lastSeenAt?null:(0,t.jsx)("time",{dateTime:e.lastSeenAt,title:(0,b.fullDateTime)(new Date(e.lastSeenAt)),"data-testid":"ship-last-seen",className:"text-meta text-muted-foreground tabular-nums",children:(0,b.lastSeen)(new Date(e.lastSeenAt),s)}),(0,t.jsx)(eD,{ping:e.ping,now:s,testId:"ship-ping-status"}),"agent"!==e.kind?null:(0,t.jsx)(eM.ReportLine,{report:e.report,now:s,variant:"full",testId:"ship-report"})]})}),(0,t.jsx)(eE,{label:"Crewed since",children:d?(0,t.jsx)("time",{dateTime:e.crewedSince??void 0,title:(0,b.fullDateTime)(d),className:"tabular-nums",children:(i=s.getTime()-d.getTime()<864e5?(0,b.clockTime)(d):(0,b.shortDateTime)(d),`${i} \xb7 ${(0,b.duration)(d,s)}`)}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Not crewed"})}),(0,t.jsx)(eE,{label:"Commissioned",children:(0,t.jsx)("time",{dateTime:e.commissionedAt,title:(0,b.fullDateTime)(l),children:r?`Fleet created ${(0,b.dayDate)(l)}`:(0,b.dayDate)(l)})}),(0,t.jsxs)(eE,{label:"Ship id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(eR.CopyButton,{value:e.id,label:"Copy ship id"})]}),void 0===a?null:(0,t.jsxs)("div",{className:"col-span-4 flex min-w-0 items-start gap-4 bg-card px-3.5 py-2.5 max-sm:col-span-2 max-sm:flex-col max-sm:gap-1.5","data-testid":"ship-delivery",children:[(0,t.jsx)("dt",{className:"shrink-0 text-meta text-muted-foreground",children:"Delivery"}),(0,t.jsx)("dd",{className:"min-w-0 flex-1",children:a})]}),void 0===n?null:(0,t.jsxs)("div",{className:"col-span-4 flex min-w-0 items-center gap-4 bg-card px-3.5 py-2.5 max-sm:col-span-2 max-sm:flex-col max-sm:items-start max-sm:gap-1.5","data-testid":"ship-labels",children:[(0,t.jsx)("dt",{className:"shrink-0 text-meta text-muted-foreground",children:"Labels"}),(0,t.jsx)("dd",{className:"min-w-0 flex-1",children:n})]})]})}function eH({icon:e,children:s}){return(0,t.jsxs)("p",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted px-3.5 py-2.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0",children:[e,(0,t.jsx)("span",{children:s})]})}function e_({ship:e,shipId:s,state:n,actions:a,crewRequest:i,now:r,backHref:d="/",labels:l,isPluginShip:o=!1,way:c}){let{fleetScopes:u}=(0,X.useConsoleConstants)();if("loading"===n||"ready"===n&&void 0===e)return(0,t.jsxs)("div",{"aria-busy":!0,"data-testid":"ship-header",className:"flex flex-col gap-4",children:[(0,t.jsx)("span",{className:"sr-only",children:"Loading the ship"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(e$.Skeleton,{className:"h-8 w-40"}),(0,t.jsx)(e$.Skeleton,{className:"h-6 w-20"}),(0,t.jsx)(e$.Skeleton,{className:"h-6 w-16"})]}),(0,t.jsx)(e$.Skeleton,{className:"h-16 w-full rounded-lg"})]});if("not-found"===n||void 0===e)return(0,t.jsx)("div",{"data-testid":"ship-header",children:(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(eN.CircleAlert,{}),title:"Ship not found",description:(0,t.jsxs)(t.Fragment,{children:["No ship with the id ",s?(0,t.jsx)("span",{className:"font-mono text-id",children:s}):"given"," exists in this fleet. The link may be incomplete. Retired ships keep their page."]}),action:(0,t.jsx)(y.Button,{size:"sm",nativeButton:!1,render:({children:e,...s})=>(0,t.jsx)(J.default,{href:d,...s,children:e}),children:"Back to fleet overview"})})});let m="operator"===e.kind,h="retired"===e.status;return(0,t.jsxs)("div",{"data-testid":"ship-header",className:"flex flex-col gap-4 max-sm:gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2.5 max-sm:flex-col max-sm:items-start max-sm:gap-1.5",children:[(0,t.jsx)("h1",{className:"min-w-0",children:(0,t.jsx)(eB.ShipName,{name:e.name,shipId:e.id,size:"title",isSuffixShown:h})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T.StatusBadge,{status:e.status}),m?(0,t.jsxs)(eT.Badge,{variant:"kind",children:[(0,t.jsx)(eS.UserRound,{"aria-hidden":!0}),"operator"]}):(0,t.jsxs)(t.Fragment,{children:[o?(0,t.jsxs)(eT.Badge,{variant:"kind","data-testid":"ship-plugin",children:[(0,t.jsx)(eC.Plug,{"aria-hidden":!0}),"plugin"]}):null,(0,t.jsx)(eT.Badge,{variant:"type",children:e.type}),e.scopes.filter(e=>u.some(t=>t===e)).map(e=>(0,t.jsx)(eT.Badge,{variant:"kind","data-testid":"ship-fleet-scope",children:e},e))]}),"awaitingCrew"===e.status&&null===e.startingPrompt?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm)",children:[(0,t.jsx)(_.KeyRound,{"aria-hidden":!0}),"No starting prompt issued"]}):null,"awaitingCrew"===e.status&&null!==e.startingPrompt?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm)",children:[(0,t.jsx)(_.KeyRound,{"aria-hidden":!0}),(0,t.jsxs)("span",{children:["Prompt issued"," ",(0,t.jsx)("time",{dateTime:e.startingPrompt.issuedAt,title:(0,b.fullDateTime)(new Date(e.startingPrompt.issuedAt)),children:(0,b.relativeTime)(new Date(e.startingPrompt.issuedAt),r)}),e.startingPrompt.isClaimed?", claimed":", not claimed yet"]})]}):null]})]}),a&&!h?(0,t.jsx)("div",{className:(0,p.classNames)("flex flex-wrap items-center gap-2","max-sm:w-full max-sm:[&>*]:flex-1"),children:a}):null]}),m?(0,t.jsx)(eH,{icon:(0,t.jsx)(ek.Info,{"aria-hidden":!0}),children:"argo is your ship. This console session crews it. It can’t be released, renamed or retired."}):null,h&&null!==e.retiredAt?(0,t.jsxs)(eH,{icon:(0,t.jsx)(ey.Archive,{"aria-hidden":!0}),children:["Retired on ",(0,b.fullDateTime)(new Date(e.retiredAt)),". Read-only."]}):null,i,(0,t.jsx)(eF,{ship:e,now:r,labels:l,way:c}),"agent"===e.kind&&e.report?.details&&null!==e.report.detailsBytes?(0,t.jsx)(eP,{details:e.report.details,bytes:e.report.detailsBytes,version:e.report.detailsVersion,testId:"ship-report-details"}):null]})}var eU=e.i(49655),eV=e.i(46157);function eW({view:e,onOpenMessage:s}){let{lines:n,oldest:a}=e;return(0,t.jsxs)("ul",{"data-testid":"ship-way","aria-label":"Its side of the way",className:"flex flex-col gap-1",children:[n.map(e=>(0,t.jsx)(eV.WayLineItem,{line:e,testId:"ship-way-line"},e.text)),a?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-testid":"ship-way-oldest","aria-label":`Open the oldest message waiting: ${a.text}`,onClick:()=>{s(a.messageId)},className:"inline-flex flex-wrap items-center gap-1.5 rounded-xs text-left text-meta hover:underline focus-visible:outline-2 focus-visible:outline-ring max-sm:text-body-touch",children:[(0,t.jsx)(T.StatusBadge,{status:a.status}),a.isOverdue?(0,t.jsx)(eU.AlarmClock,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-tone-attention-fg"}):null,(0,t.jsx)("span",{className:(0,p.classNames)(a.isOverdue?"text-tone-attention-fg":"text-muted-foreground"),children:a.text}),(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0,className:"size-(--size-icon-sm)"})]})}):null]})}var eK=e.i(99261),eG=e.i(89664),eY=e.i(16327),eJ=e.i(56539),eX=e.i(77071),eQ=e.i(63676),eZ=e.i(70703),e0=e.i(6734);let e1=(0,eZ.default)(()=>e.A(67858).then(e=>e.LabelPicker),{loadableGenerated:{modules:[59068]},ssr:!1});function e2({chip:e,labelKey:s,isBusy:a,onUnassign:i,onChange:r}){let[d,l]=(0,n.useState)(!1);return(0,t.jsxs)(e0.Popover,{open:d,onOpenChange:l,children:[(0,t.jsx)(e0.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":`Change or remove ${e.key}=${e.value}`,"data-testid":"ship-label-yours",disabled:a,className:"inline-flex items-center rounded-sm focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60"}),children:(0,t.jsx)(Z.LabelChip,{chip:e,trailing:(0,t.jsx)(eY.ChevronDown,{"aria-hidden":!0}),className:"hover:bg-accent"})}),(0,t.jsxs)(e0.PopoverContent,{align:"start",sideOffset:6,className:"w-72 p-1.5","data-testid":"ship-label-menu",children:[(0,t.jsxs)("span",{className:"flex items-center justify-between px-2 pt-1 pb-1.5 text-meta",children:[(0,t.jsxs)("span",{className:"font-mono",children:[e.key,"=",(0,t.jsx)("span",{className:"text-muted-foreground",children:e.value})]}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"Change the value"})]}),(0,t.jsx)("ul",{className:"flex flex-col",children:(s?.values??[]).map(n=>{let a=n.valueId===e.valueId,i=s?.carriedValueIds.includes(n.valueId)??!1;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",disabled:i,"data-testid":"ship-label-value",className:"flex h-(--size-control-sm) w-full items-center gap-2 rounded-sm px-2 text-left text-body hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none [&_svg]:size-(--size-icon-sm)",onClick:()=>{l(!1),r({from:e.valueId,to:n.valueId})},children:[(0,t.jsx)("span",{className:"w-4",children:i?(0,t.jsx)(eG.Check,{"aria-hidden":!0}):null}),(0,t.jsx)("span",{className:(0,p.classNames)("min-w-0 grow truncate font-mono",i&&!a?"text-muted-foreground":void 0),children:n.value}),(0,t.jsx)("span",{className:"text-meta text-muted-foreground tabular-nums",children:i&&!a?"Carried":`${String(n.shipCount)} ${1===n.shipCount?"ship":"ships"}`})]})},n.valueId)})}),(0,t.jsx)("div",{className:"mt-1 border-t border-border pt-1",children:(0,t.jsxs)("button",{type:"button","data-testid":"ship-label-remove",className:"flex h-(--size-control-sm) w-full items-center gap-2 rounded-sm px-2 text-body text-destructive-text hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",onClick:()=>{l(!1),i(e.valueId)},children:[(0,t.jsx)(eQ.X,{"aria-hidden":!0}),"Remove label"]})})]})]})}function e5({keys:e,isBusy:s,onAssign:a}){let[i,r]=(0,n.useState)(!1);return(0,t.jsxs)(e0.Popover,{open:i,onOpenChange:r,children:[(0,t.jsx)(e0.PopoverTrigger,{render:(0,t.jsx)(y.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(eX.Plus,{}),disabled:s,"data-testid":"ship-labels-add"}),children:"Add label"}),(0,t.jsxs)(e0.PopoverContent,{align:"start",sideOffset:6,className:"w-80 p-2","data-testid":"ship-labels-add-popover",children:[(0,t.jsxs)("span",{className:"flex items-center justify-between px-2 pt-1 pb-2 text-body font-medium",children:["Add a label",(0,t.jsx)("span",{className:"text-meta font-normal text-muted-foreground",children:"Yours"})]}),0===e.length?(0,t.jsx)("p",{className:"px-2 py-2 text-meta text-muted-foreground",children:"You have no labels yet. Define one on the Labels page, then put it on ships here."}):(0,t.jsx)(e1,{groups:[{title:"Yours",keys:[...e]}],pickedValueIds:e.flatMap(e=>e.carriedValueIds),pickedWord:"Carried",onPick:e=>{r(!1),a(e)}}),(0,t.jsx)("p",{className:"mt-2 flex items-center justify-between border-t border-border px-2 pt-2 text-meta",children:(0,t.jsx)(J.default,{href:"/labels",className:"font-medium hover:underline",children:0===e.length?"Define a label":"Manage labels"})})]})]})}function e3({chips:e,keys:s,limit:a,isBusy:i,error:r,onAssign:d,onUnassign:l,onChange:o}){let[c,u]=(0,n.useState)(!1),m=!c&&e.length>3,h=m?e.slice(0,2):e,p=[...new Set(h.filter(e=>"none"!==e.mark).map(e=>e.ownerName))];return(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-2","data-testid":"ship-labels-edit",children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[0===e.length?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"No labels"}):null,h.filter(e=>"none"===e.mark).map(e=>(0,t.jsx)(e2,{chip:e,labelKey:s.find(t=>t.labelId===e.labelId),isBusy:i,onUnassign:l,onChange:o},e.valueId)),m?(0,t.jsxs)("button",{type:"button","aria-label":`Show all ${String(e.length)} labels`,"data-testid":"ship-labels-more",className:"inline-flex h-5.5 items-center rounded-sm bg-secondary px-1.5 text-caption font-medium tabular-nums hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring",onClick:()=>{u(!0)},children:["+",e.length-2]}):null,a.isAtLimit?null:(0,t.jsx)(e5,{keys:s,isBusy:i,onAssign:d}),p.map(e=>(0,t.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["by ",e]}),h.filter(t=>"none"!==t.mark&&t.ownerName===e).map(e=>(0,t.jsx)(Z.LabelChip,{chip:e,testId:"ship-label"},e.valueId))]},e)),c&&e.length>3?(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm px-1 text-meta hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",onClick:()=>{u(!1)},children:[(0,t.jsx)(eJ.ChevronUp,{"aria-hidden":!0}),"Show fewer"]}):null,a.isAtLimit?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"At the limit: a ship carries at most 20 labels (decision 0031)."}):null,void 0===a.count?null:(0,t.jsx)("span",{className:"ml-auto text-meta text-muted-foreground tabular-nums","data-testid":"ship-labels-count",children:a.count})]}),void 0===r?null:(0,t.jsx)(k.InlineError,{title:r.title,description:`Refused: ${r.message}. Nothing changed.`})]})}function e6(e,t){for(let s of e){let e=s.values.find(e=>e.valueId===t);if(void 0!==e)return`${s.key}=${e.value}`}return"the label"}function e7({ship:e}){let{shipLabelsMax:s}=(0,X.useConsoleConstants)(),a=(0,L.useLabelContext)(),i=(0,I.useAccess)(),r=(0,L.useAssignLabel)(),d=(0,L.useUnassignLabel)(),[l,o]=(0,n.useState)(void 0);if(void 0===a)return(0,t.jsx)(e$.Skeleton,{className:"h-5.5 w-40"});let c=(0,O.chipsOf)(e,a);if(!(0,O.canAssignLabelsTo)(e,i))return(0,t.jsx)(eK.ShipLabels,{chips:c});let u=(0,O.assignKeysOf)(e,a),m=e=>t=>{o({title:e,message:t.message})};return(0,t.jsx)(e3,{chips:c,keys:u,limit:(0,O.labelLimitOf)(e,s),isBusy:r.isPending||d.isPending,error:l,onAssign:t=>{o(void 0),r.mutate({shipId:e.id,valueId:t},{onError:m(`Couldn’t add ${e6(u,t)}`)})},onUnassign:t=>{o(void 0),d.mutate({shipId:e.id,valueId:t},{onError:m(`Couldn’t remove ${e6(u,t)}`)})},onChange:({from:t,to:s})=>{o(void 0),d.mutate({shipId:e.id,valueId:t},{onSuccess:()=>{r.mutate({shipId:e.id,valueId:s},{onError:n=>{r.mutate({shipId:e.id,valueId:t}),m(`Couldn’t change ${e6(u,t)} to ${e6(u,s)}`)(n)}})},onError:m(`Couldn’t change ${e6(u,t)}`)})}})}var e4=e.i(87255),e8=e.i(31458);let e9={name:"lock-keyhole",size:24,node:[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]};e9.node;let te=(0,r.default)(e9),tt={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]};tt.node;let ts=(0,r.default)(tt);var tn=e.i(67784),ta=e.i(25799);let ti={name:"mail-minus",size:24,node:[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]};ti.node;let tr=(0,r.default)(ti),td={name:"mail-x",size:24,node:[["path",{d:"M22 12.532V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8.792",key:"8lpqwp"}],["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["path",{d:"m16.5 16.5 5 5",key:"zc9lw7"}],["path",{d:"m21.5 16.5-5 5",key:"1empo3"}]]};td.node;let tl=(0,r.default)(td),to={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};to.node;let tc=(0,r.default)(to),tu={name:"package-x",size:24,node:[["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m16.5 14.5 5 5",key:"ozpm51"}],["path",{d:"m16.5 19.5 5-5",key:"syf6b9"}],["path",{d:"M21 10.5V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l.13-.074",key:"isw6gs"}],["path",{d:"M3.29 7 12 12l8.71-5",key:"19ckod"}],["path",{d:"m7.5 4.27 8.997 5.148",key:"9yrvtv"}]]};tu.node;let tm=(0,r.default)(tu),th={name:"pen-line",size:24,node:[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-3"]};th.node;let tp=(0,r.default)(th),tx={name:"shield-alert",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]};tx.node;let tg=(0,r.default)(tx);var tf=e.i(37817),tv=e.i(40798);function tb(e,t){let s=e.details[t];return"string"==typeof s?s:void 0}function tw(e){return tb(e,"key")??""}function tj(e){return(tb(e,"values")??"").split(",").join(", ")}function ty(e){return e?[(0,w.text)(" by "),(0,w.ship)(e)]:[]}let tN={deregistered:"Its session deregistered.",takenOver:"Taken over by a new console session.",signedOut:"The operator signed out.",passwordReset:"Its session ended with the operator password reset.",retired:"Its session ended: the ship was retired."};function tk(e){return e.message?.isPing===!0}function tC(e){return e.message?[(0,w.text)(tk(e)?"a ping from ":"a message from "),(0,w.ship)(e.message.sender)]:[(0,w.text)("a message")]}function tS(e){let[t,...s]=tC(e);return t?.kind==="text"?[(0,w.text)((0,w.capitalised)(t.text)),...s]:tC(e)}function tT(e,t){let{shipId:s,verb:n}=t,a=e.actor;return[...null===a||a.id===s?[(0,w.text)((0,w.capitalised)(n))]:[(0,w.ship)(a),(0,w.text)(` ${n}`)],(0,w.text)(" "),...tC(e)]}let tR={received:l,sent:c,claimed:ts,released:tn.LogOut,prompt:_.KeyRound,commissioned:e8.Flag,acknowledged:ta.MailCheck,returned:tf.Undo2,undeliverable:tl,secret:te,fleet:e4.Anchor,password:tg,retired:ey.Archive,abandoned:tm,dismissed:tr,renamed:tp,reported:tc},t$={waiting:"border-tone-waiting-border bg-tone-waiting-bg text-tone-waiting-fg",active:"border-tone-active-border bg-tone-active-bg text-tone-active-fg",ok:"border-tone-ok-border bg-tone-ok-bg text-tone-ok-fg",attention:"border-tone-attention-border bg-tone-attention-bg text-tone-attention-fg",ended:"border-tone-ended-border bg-tone-ended-bg text-tone-ended-fg"},tq="flex w-full gap-3 px-3.5 py-3 text-left";function tI({entry:e,shipId:s,now:n,onOpenMessage:a}){let{parts:i,tone:r,icon:d}=function(e,t){switch(e.type){case"FleetInitialised":return{parts:[(0,w.text)("Fleet initialised")],tone:"ended",icon:"fleet"};case"ShipCommissioned":{let t=tb(e,"type");return{parts:[(0,w.text)("Commissioned"),...ty(e.actor),...void 0===t?[]:[(0,w.text)(` as ${t}`)]],tone:"ended",icon:"commissioned"}}case"OwnerSet":return{parts:[(0,w.text)("inherited"===tb(e,"how")?"Owner set: its commissioner's owner":"Owner set: argo by default")],tone:"ended",icon:"commissioned"};case"OwnerChanged":return{parts:"ownerRetired"===tb(e,"why")?[(0,w.text)("Owner retired: argo owns it now")]:[(0,w.text)("Owner changed"),...ty(e.actor)],tone:"ended",icon:"renamed"};case"StartingPromptIssued":return{parts:[(0,w.text)("Starting prompt issued")],tone:"ended",icon:"prompt"};case"ShipClaimed":return{parts:[(0,w.text)(`Claimed by a session on ${function(e){let t=tb(e,"locationDescription");if(void 0!==t&&""!==t)return t;let s=tb(e,"location");return"DEVICE"===s||"CLOUD"===s||"SERVER"===s||"OTHER"===s?(0,tv.locationKindWord)(s):"an unknown location"}(e)}`)],tone:"ok",icon:"claimed"};case"LeaseRevoked":let s,n;return{parts:[..."released"===(s=tb(e,"reason")??"")?[(0,w.text)("Released"),...ty(e.actor),(0,w.text)(".")]:[(0,w.text)(tN[s]??"Its session ended.")],..."number"==typeof(n=e.details.returnedDeliveries)&&n>0?[(0,w.text)(` ${(0,w.counted)(n,{one:"in-flight delivery",many:"in-flight deliveries"})} went back to pending.`)]:[]],tone:"waiting",icon:"released"};case"CredentialRevoked":return{parts:[(0,w.text)("Secret invalidated")],tone:"ended",icon:"secret"};case"OperatorPasswordReset":return{parts:[(0,w.text)("Operator password reset")],tone:"waiting",icon:"password"};case"FleetLimitsChanged":return{parts:[(0,w.text)("Fleet limits changed")],tone:"ended",icon:"fleet"};case"SignInTicketIssued":return{parts:[(0,w.text)("Sign-in ticket issued")],tone:"ended",icon:"password"};case"ViewerSessionStarted":return{parts:[(0,w.text)("Someone started viewing the fleet")],tone:"ended",icon:"password"};case"CrewRequested":return{parts:[(0,w.text)("Crew requested"),...ty(e.actor)],tone:"waiting",icon:"claimed"};case"CrewRequestRemoved":return{parts:[(0,w.text)("Crew request removed"),...ty(e.actor)],tone:"ended",icon:"released"};case"CrewRequestExplained":{let t=tb(e,"reason");return{parts:[(0,w.text)(void 0===t?"Crew request can not be placed yet":`Crew request can not be placed: ${t}`),...ty(e.actor)],tone:"waiting",icon:"reported"}}case"CrewRequestGivenBack":{let t=tb(e,"reason");return{parts:[(0,w.text)(void 0===t?"Crew request given back":`Crew request given back: ${t}`),...ty(e.actor)],tone:"waiting",icon:"released"}}case"WorktreeClearRequested":return{parts:[(0,w.text)(`Clearing of the kept ${tb(e,"repository")??""} worktree requested`),...ty(e.actor)],tone:"waiting",icon:"reported"};case"WorktreeCleared":return{parts:[(0,w.text)("not-kept"===tb(e,"outcome")?`Kept ${tb(e,"repository")??""} worktree cleared (none was kept)`:`Kept ${tb(e,"repository")??""} worktree cleared`),...ty(e.actor)],tone:"ended",icon:"retired"};case"WorktreeClearRemoved":return{parts:[(0,w.text)(`Clearing of the kept ${tb(e,"repository")??""} worktree dropped`),...ty(e.actor)],tone:"ended",icon:"released"};case"CrewAssigned":return{parts:[(0,w.text)("Crew request assigned"),...ty(e.actor)],tone:"waiting",icon:"claimed"};case"CrewStatusChanged":{let t=tb(e,"status");return{parts:[(0,w.text)(void 0===t?"Crew status changed":`Crew ${t}`),...ty(e.actor)],tone:"crashed"===t?"attention":"active",icon:"reported"}}case"LabelDefined":return{parts:[(0,w.text)(`Label ${tw(e)} defined: ${tj(e)}`)],tone:"ended",icon:"reported"};case"LabelValuesChanged":return{parts:[(0,w.text)(`Label ${tw(e)} values changed: ${tj(e)}`)],tone:"ended",icon:"reported"};case"LabelRetired":return{parts:[(0,w.text)(`Label ${tw(e)} retired`)],tone:"ended",icon:"retired"};case"NetworkRulesSet":{let t=e.details.rules,s=String(e.details.version??""),n="number"==typeof t?`Network rules set: ${String(t)} rules`:"Network rules cleared: every ship reaches every ship";return{parts:[(0,w.text)(`${n}, version ${s}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"NetworkRulesDeclared":{let t=e.details.rules,s="number"==typeof t&&t>0?`Network rules declared: ${String(t)} rules`:"Declared network rules withdrawn";return{parts:[(0,w.text)(s),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"ScopesDeclared":{let t="number"==typeof e.details.scopes?e.details.scopes:0;return{parts:[(0,w.text)(`Scopes declared: namespace ${tb(e,"namespace")??""}, ${String(t)} ${1===t?"scope":"scopes"}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"ScopesChanged":{let t=tb(e,"added")??"",s=tb(e,"removed")??"",n=[...""===t?[]:[`granted ${t}`],...""===s?[]:[`revoked ${s}`]];return{parts:[(0,w.text)(`Scopes changed: ${n.join(", ")}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"NetworkPluginRegistered":return{parts:[(0,w.text)(`Networking plugin registered: while unavailable ${tb(e,"whileUnavailable")??""}, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"};case"NetworkPluginUnregistered":return{parts:[(0,w.text)(`Networking plugin unregistered: every ship reaches every ship, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"};case"BuiltInRuleChanged":{let t=tb(e,"verb"),s="viewerRead"===e.details.rule?"viewer read":`${tb(e,"rule")??""}${void 0===t?"":` for ${t}`}`,n=!0===e.details.isOn?"on":"off";return{parts:[(0,w.text)(`Built-in rule ${s} turned ${n}, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"LabelDeleted":return{parts:[(0,w.text)(`Label ${tw(e)} deleted`)],tone:"ended",icon:"retired"};case"LabelAssigned":return{parts:[(0,w.text)(`Labelled ${tw(e)}=${tb(e,"value")??""}`),...ty(e.actor)],tone:"ended",icon:"reported"};case"LabelUnassigned":return{parts:[(0,w.text)(`Label ${tw(e)}=${tb(e,"value")??""} removed`),...ty(e.actor)],tone:"ended",icon:"reported"};case"MessageAccepted":let a;return{parts:(a=e.message)?tk(e)&&"ship"===a.recipient.kind?a.sender.id===t?[(0,w.text)("Pinged "),(0,w.ship)(a.recipient.ship)]:[(0,w.text)("Pinged by "),(0,w.ship)(a.sender)]:a.sender.id===t?"ship"===a.recipient.kind?[(0,w.text)("Sent a message to "),(0,w.ship)(a.recipient.ship)]:[(0,w.text)(`Sent a message to any ship of type ${a.recipient.type}`)]:[(0,w.text)("Received a message from "),(0,w.ship)(a.sender)]:[(0,w.text)("A message was sent")],tone:"ended",icon:e.message?.sender.id===t?"sent":"received"};case"LeasePushed":return{parts:[(0,w.text)("Pushed: its trierarch or plugin watcher receives for its session")],tone:"ok",icon:"received"};case"DeliveryReceived":return{parts:tT(e,{shipId:t,verb:!0===e.details.again?"received again":"received"}),tone:"active",icon:"received"};case"DeliveryHanded":return{parts:tT(e,{shipId:t,verb:!0===e.details.onceMore?"took once more":"took"}),tone:"active",icon:"received"};case"DeliveryHandled":return{parts:tT(e,{shipId:t,verb:"handled"}),tone:"ok",icon:"acknowledged"};case"DeliveryNotHandled":return{parts:[...tS(e),(0,w.text)(" was not handled: its turn died twice")],tone:"attention",icon:"undeliverable"};case"DeliveryOverdue":let i,r,d;return{parts:[...tS(e),(0,w.text)(` is overdue: ${(r="number"==typeof(i=e.details.minutes)?`${String(i)} min`:"too long","notConfirmed"===(d=tb(e,"clock"))?`handed, not confirmed for ${r}`:`waiting ${r} while its session is ${"busy"===d?"busy":"idle"}`)}, argo told`)],tone:"attention",icon:"undeliverable"};case"DeliveryAcknowledged":return{parts:"pong"===tb(e,"answer")?[...tT(e,{shipId:t,verb:"answered"}),(0,w.text)(" with pong")]:tT(e,{shipId:t,verb:"acknowledged"}),tone:"ok",icon:"acknowledged"};case"DeliveryReturned":return{parts:[...tS(e),(0,w.text)(" went back to pending")],tone:"waiting",icon:"returned"};case"DeliveryUndeliverable":return{parts:[...tS(e),(0,w.text)(" became undeliverable")],tone:"attention",icon:"undeliverable"};case"ShipRetired":{let t=e.details.abandonedDeliveries;return{parts:[(0,w.text)("Retired"),...ty(e.actor),(0,w.text)("."),..."number"==typeof t&&t>0?[(0,w.text)(` ${(0,w.counted)(t,{one:"delivery",many:"deliveries"})} abandoned.`)]:[]],tone:"ended",icon:"retired"}}case"DeliveryAbandoned":return{parts:[...tS(e),(0,w.text)(" was abandoned")],tone:"ended",icon:"abandoned"};case"ShipReported":{let t=tb(e,"state")??"in",s=tb(e,"note");return{parts:[(0,w.text)(void 0===s?`Reported ${t}`:`Reported ${t}: ${s}`)],tone:Object.hasOwn(eO.REPORT_TONES,t)?eO.REPORT_TONES[t]:"ended",icon:"reported"}}case"StatementSet":return{parts:[(0,w.text)(`Stated what it is and offers: ${String(e.details.capabilities??"")} capabilities, version ${String(e.details.version??"")}`)],tone:"ended",icon:"reported"};case"TurnReported":{let t=tb(e,"turn");return{parts:[(0,w.text)("busy"===t?"Turn started: busy":"Turn ended: idle")],tone:"busy"===t?"active":"ended",icon:"reported"}}case"ShipRenamed":{let t=tb(e,"from"),s=tb(e,"to");return{parts:[(0,w.text)(void 0===t||void 0===s?"Renamed":`Renamed from ${t} to ${s}`),...ty(e.actor)],tone:"ended",icon:"renamed"}}case"DeliveryDismissed":return{parts:[...tS(e),(0,w.text)(" was dismissed"),...ty(e.actor)],tone:"ended",icon:"dismissed"}}}(e,s),l=tR[d],o=new Date(e.occurredAt),c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":!0,className:(0,p.classNames)("flex size-7 shrink-0 items-center justify-center rounded-md border [&_svg]:size-(--size-icon-sm)",t$[r]),children:(0,t.jsx)(l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(S.Sentence,{parts:i,className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)("time",{dateTime:e.occurredAt,title:(0,b.fullDateTime)(o),className:"text-meta text-muted-foreground tabular-nums",children:(0,b.relativeTime)(o,n)})]})]}),{message:u}=e;return(0,t.jsx)("li",{"data-testid":"ship-timeline-entry","data-type":e.type,className:"border-b border-border last:border-b-0",children:u?(0,t.jsx)("button",{type:"button",className:(0,p.classNames)(tq,"transition-colors duration-(--duration-fast) hover:bg-accent"),onClick:()=>{a(u.id)},children:c}):(0,t.jsx)("div",{className:tq,children:c})})}function tA({shipId:e,entries:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:4,label:"Loading the timeline"}):"error"===n?(0,t.jsxs)("div",{"data-testid":"ship-timeline",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3",children:[(0,t.jsx)(k.InlineError,{title:"Couldn’t load the timeline",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),onClick:a,className:"self-start",children:"Try again"}):null]}):(0,t.jsxs)("div",{"data-testid":"ship-timeline",className:"overflow-hidden rounded-lg border border-border bg-card",children:[(0,t.jsx)("ol",{"aria-label":"Timeline",children:s.map(s=>(0,t.jsx)(tI,{entry:s,shipId:e,now:i,onOpenMessage:r},s.id))}),s.length<=1?(0,t.jsx)("p",{className:"border-t border-border px-3.5 py-3 text-center text-meta text-muted-foreground first:border-t-0",children:"Nothing else yet. Claims, releases and messages appear here as they happen."}):null]})}var tD=e.i(37631),tL=e.i(87964),tO=e.i(46929),tz=e.i(18423),tP=e.i(96676),tM=e.i(9176),tB=e.i(78485),tE=e.i(53573),tF=e.i(85595),tH=e.i(28459),t_=e.i(14732);function tU({party:e}){let s=e.name===w.OPERATOR_NAME;return(0,t.jsx)(eB.ShipName,{name:e.name,shipId:e.id,size:"meta",isOperator:s,isSuffixShown:!s})}function tV({delivery:e}){let{sender:s,recipient:n}=e.message;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-meta text-muted-foreground",children:[(0,t.jsx)(tU,{party:s}),(0,t.jsx)("span",{"aria-hidden":!0,children:"→"}),(0,t.jsx)("span",{className:"sr-only",children:"to"}),"ship"===n.kind?(0,t.jsx)(tU,{party:n.ship}):(0,t.jsxs)("span",{children:["any ship of type ",n.type]})]})}function tW({delivery:e}){let{payload:s,contentType:n}=e.message;return(0,t.jsx)("span",{className:(0,p.classNames)("block min-w-0 truncate text-foreground",(0,x.isJson)(n)?"font-mono text-id":"text-body max-sm:text-body-touch"),title:s,children:s.split("\n")[0]})}function tK(e){return(0,tH.attentionReason)(e)}function tG(e){var t;return`the message from ${e.message.sender.name} to ${"ship"===(t=e.message.recipient).kind?t.ship.name:`any ship of type ${t.type}`}`}function tY({delivery:e,onResend:s,onDismiss:n,pendingIds:a,layout:i}){let r=a.has(e.deliveryId),d="phone"===i;if(void 0===s&&void 0===n)return null;let l=void 0!==s&&(0,tH.canResend)(e)?(0,t.jsx)(y.Button,{size:d?"touch":"sm",variant:d?"primary":"secondary",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),isLoading:r,"data-testid":"attention-resend","aria-label":`Resend ${tG(e)}`,onClick:()=>{s(e.deliveryId)},className:d?"flex-1":void 0,children:"Resend"}):null,o=void 0===n?null:(0,t.jsx)(y.Button,{size:d?"touch":"sm",variant:d?"secondary":"ghost",disabled:r,"data-testid":"attention-dismiss","aria-label":`Dismiss ${tG(e)}`,onClick:()=>{n(e.deliveryId)},className:d?"flex-1":void 0,children:"Dismiss"});return d?(0,t.jsxs)("div",{className:"flex gap-2 pt-1",children:[o,l]}):(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[l,o]})}function tJ({deliveries:e,onOpen:s,now:n,...a}){return(0,t.jsxs)("div",{className:"flex flex-col gap-2 max-sm:hidden",children:[(0,t.jsxs)(t_.Table,{"aria-label":"Undeliverable and not handled deliveries",children:[(0,t.jsx)(t_.TableHeader,{children:(0,t.jsxs)(t_.TableRow,{children:[(0,t.jsx)(t_.TableHead,{children:"State"}),(0,t.jsx)(t_.TableHead,{children:"Message"}),(0,t.jsx)(t_.TableHead,{children:"Reason"}),(0,t.jsx)(t_.TableHead,{children:"Since"}),(0,t.jsx)(t_.TableHead,{children:"Actions"})]})}),(0,t.jsx)(t_.TableBody,{children:e.map(e=>{let i=new Date(e.since);return(0,t.jsxs)(t_.TableRow,{"data-testid":"attention-row","data-delivery-id":e.deliveryId,children:[(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsx)(T.StatusBadge,{status:e.state})}),(0,t.jsx)(t_.TableCell,{className:"max-w-96 align-top",children:(0,t.jsxs)("button",{type:"button","aria-label":`Open ${tG(e)}`,onClick:()=>{s(e)},className:"flex w-full min-w-0 flex-col gap-0.5 rounded-xs text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,t.jsx)(tW,{delivery:e}),(0,t.jsx)(tV,{delivery:e})]})}),(0,t.jsx)(t_.TableCell,{className:"max-w-48 align-top text-meta whitespace-normal text-muted-foreground",children:tK(e)}),(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsxs)("span",{className:"flex flex-col gap-0.5 tabular-nums",children:[(0,t.jsx)("time",{dateTime:e.since,title:(0,b.fullDateTime)(i),className:"text-body text-foreground",children:(0,b.shortDateTime)(i)}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:[(0,b.duration)(i,n)," ago"]})]})}),(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsx)(tY,{delivery:e,layout:"table",...a})})]},e.deliveryId)})})]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"Resend creates a new message with the same payload, linked to the original. Dismiss marks the delivery resolved. Abandoned deliveries are not listed here."})]})}function tX({deliveries:e,onOpen:s,now:n,...a}){return(0,t.jsx)("ul",{"aria-label":"Undeliverable and not handled deliveries",className:"flex flex-col gap-3 sm:hidden",children:e.map(e=>{let i=new Date(e.since),r=n.getTime()-i.getTime()<864e5?(0,b.clockTime)(i):(0,b.shortDateTime)(i);return(0,t.jsxs)("li",{"data-testid":"attention-row","data-delivery-id":e.deliveryId,className:"flex flex-col gap-1.5 rounded-lg border border-border bg-card px-3.5 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(T.StatusBadge,{status:e.state}),(0,t.jsxs)("button",{type:"button","aria-label":`Open ${tG(e)}`,onClick:()=>{s(e)},className:"inline-flex items-center gap-1 rounded-xs text-meta text-muted-foreground tabular-nums focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",children:[(0,b.duration)(i,n),(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0})]})]}),(0,t.jsx)(tW,{delivery:e}),(0,t.jsx)(tV,{delivery:e}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:[tK(e)," Since"," ",(0,t.jsx)("time",{dateTime:e.since,title:(0,b.fullDateTime)(i),className:"tabular-nums",children:r}),"."]}),(0,t.jsx)(tY,{delivery:e,layout:"phone",...a})]},e.deliveryId)})})}function tQ({deliveries:e,state:s,onRetry:n,...a}){return"loading"===s?(0,t.jsxs)("div",{"data-slot":"needs-attention-list","data-state":"loading",children:[(0,t.jsx)(C.LoadingSkeleton,{variant:"table",rows:2,label:"Loading Needs attention",className:"max-sm:hidden"}),(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:2,label:"Loading Needs attention",className:"sm:hidden"})]}):"error"===s?(0,t.jsx)("div",{"data-slot":"needs-attention-list","data-state":"error","data-testid":"attention-error",children:(0,t.jsx)(k.InlineError,{variant:"page",title:"Couldn’t load Needs attention",description:"This page couldn’t reach the fleet server. Undeliverable deliveries are kept on the server, so nothing is lost.",onRetry:n})}):0===e.length?(0,t.jsx)("div",{"data-slot":"needs-attention-list","data-state":"empty","data-testid":"attention-empty",children:(0,t.jsx)(N.EmptyState,{icon:(0,t.jsx)(tF.CircleCheck,{className:"text-tone-ok-fg"}),title:"Nothing needs your attention",description:"Undeliverable deliveries show up here as soon as they happen."})}):(0,t.jsxs)("div",{"data-slot":"needs-attention-list","data-state":"ready",className:"flex flex-col gap-3",children:[(0,t.jsx)(tJ,{deliveries:e,...a}),(0,t.jsx)(tX,{deliveries:e,...a})]})}function tZ({shipId:e}){let a=(0,s.useRouter)(),i=(0,tP.useNow)(),r=(0,tH.useNeedsAttention)(),d=(0,tH.useResendDelivery)(),l=(0,tH.useDismissDelivery)(),o=(0,I.useAccess)(),[c,u]=(0,n.useState)(new Set),m=(r.data??[]).filter(t=>"notHandled"===t.state&&t.ship.id===e),h=(e,t)=>{u(t=>new Set([...t,e])),t().finally(()=>{u(t=>new Set([...t].filter(t=>t!==e)))})};return 0===m.length?null:(0,t.jsxs)("section",{"aria-labelledby":"ship-not-handled","data-testid":"ship-not-handled",className:"flex flex-col gap-2",children:[(0,t.jsxs)("h2",{id:"ship-not-handled",className:"text-body font-semibold",children:["Not handled (",m.length,")"]}),(0,t.jsx)(tQ,{deliveries:m,state:"ready",onRetry:()=>{r.refetch()},onResend:o.canManage?e=>{let t=(0,tH.deliveryWithId)(m,e);h(e,async()=>{try{await d.mutateAsync({deliveryId:e}),t&&(0,E.showToast)({...(0,tH.resentToast)(t),tone:"success"})}catch(e){(0,E.showToast)({title:"Couldn’t resend the message",description:t0(e),tone:"error"})}})}:void 0,onDismiss:o.canManage?e=>{h(e,async()=>{try{await l.mutateAsync({deliveryId:e}),(0,E.showToast)({...tH.DISMISSED_TOAST,tone:"success"})}catch(e){(0,E.showToast)({title:"Couldn’t dismiss the delivery",description:t0(e),tone:"error"})}})}:void 0,onOpen:t=>{a.replace(`/ships/${e}?tab=messages&message=${t.message.id}`,{scroll:!1})},pendingIds:c,now:i})]})}function t0(e){return e instanceof Error?e.message:"Try again in a moment."}let t1="timeline",t2="messages",t5=(0,q.lazyDialog)(()=>e.A(65030).then(e=>e.MessageSheet),e=>e.isOpen);e.s(["ShipPageFor",0,function({shipId:e,tab:r,messageId:d}){let l=(0,s.useRouter)(),o=(0,tP.useNow)(),c=(0,tM.usePluginShipIds)(),u=(0,tE.useShip)(e),m=(0,tE.useShipTimeline)(e),h=(0,tE.useShipMessages)(e),p=(0,tE.useMessage)(d),x=(0,tE.useShipWay)(e),g=(0,B.useMachines)(),f=(0,tz.useLiveFleet)(),w=(0,tL.useConsoleFrame)(),j=(0,eu.useSquadrons)(),y=(0,I.useAccess)(),[N,k]=(0,n.useState)();(0,tB.useSignInWhenSessionEnds)([u.error,m.error,h.error,p.error,f.error]);let C=t=>{let s,n;l.replace((s=new URLSearchParams,t.tab!==t1&&s.set("tab",t.tab),void 0!==t.messageId&&s.set("message",t.messageId),""===(n=s.toString())?`/ships/${e}`:`/ships/${e}?${n}`),{scroll:!1})},S=e=>{C({tab:r,messageId:e})},T="NOT_FOUND"===(0,tO.trpcErrorCode)(u.error)||null===u.data,R=x.data&&u.data?.kind==="agent"?function(e,t){let{now:s,machines:n=[]}=t;if(null===e.lease)return{lines:[],oldest:null};let{by:a,turn:i}=e.lease,r=0===e.waiting?[{icon:"time",tone:"neutral",text:"Nothing waiting"}]:[];return{lines:[null===a?{icon:"pull",tone:"neutral",text:"No trierarch, no plugin (pull)"}:"trierarch"===a.kind?{icon:"computer",tone:"neutral",text:`Trierarch on ${a.trierarch.name}`}:{icon:"watcher",tone:"neutral",text:"Plugin watcher"},...function(e,t){if(e?.kind!=="trierarch")return[];let s=t.machines.find(t=>t.shipId===e.trierarch.id);if(!s?.isSilent)return[];let n=null===s.lastSeenAt?"":` since ${(0,b.sinceTime)(new Date(s.lastSeenAt),t.now)}`;return[{icon:"silent",tone:"attention",text:`Trierarch on ${e.trierarch.name} silent${n}`}]}(a,{now:s,machines:n}),...function(e,t){if(null===e)return[];let s=(0,b.sinceTime)(new Date(e.at),t);return"busy"===e.turn?[{icon:"busy",tone:"active",text:`Busy since ${s}`}]:[{icon:"idle",tone:"neutral",text:`Idle since ${s}`}]}(i,s),...r],oldest:function(e,t){let{oldest:s,waiting:n}=e;if(null===s)return null;let{state:a,way:i}=s.delivery,r=[(0,b.relativeTime)(new Date(i.since),t).toLowerCase()];return"handed"===a&&r.push(i.isPulled?"not acknowledged":"not confirmed"),i.overdue&&r.push(`argo told at ${String(i.overdue.minutes)} min`),n>1&&r.push(`oldest of ${String(n)}`),{messageId:s.messageId,status:(0,v.deliveryStatus)({state:a,isPulled:i.isPulled}),isOverdue:null!==i.overdue,text:r.join(" · ")}}(e,s)}}(x.data,{now:o,machines:g.data??[]}):void 0,q=(0,eg.shipsInSquadrons)(j.data??[]).get(e);return(0,t.jsx)(tD.DetailPage,{onCompose:w.onCompose,onSearch:w.onSearch,banner:w.banner,title:u.data?.name??"Ship",parents:q?[{href:"/squadrons",label:"Squadrons"},{href:`/squadrons/${q.squadronId}`,label:q.squadronId}]:[{href:"/",label:"Fleet overview"}],live:f.live,header:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e_,{ship:u.data??void 0,shipId:e,state:T?"not-found":u.data?"ready":"loading",now:o,actions:u.data?(0,t.jsx)(ew.ShipActions,{ship:u.data,compose:i.ComposeMessage,crewLineFlow:ej.NewCrewLineFlow}):void 0,crewRequest:u.data?(0,t.jsx)(ex,{ship:u.data,timeline:m.data??[],now:o}):void 0,labels:u.data?(0,t.jsx)(e7,{ship:u.data}):void 0,isPluginShip:c.has(e),way:R&&x.data?.lease?(0,t.jsx)(eW,{view:R,onOpenMessage:S}):void 0}),T?null:(0,t.jsx)(eb,{shipId:e,now:o}),T?null:(0,t.jsx)(tZ,{shipId:e})]}),sheet:(0,t.jsx)(t5,{message:p.data,messageId:d,state:"NOT_FOUND"===(0,tO.trpcErrorCode)(p.error)?"not-found":p.data?"ready":"loading",isOpen:void 0!==d,now:o,machines:g.data??[],onOpenMessage:S,onOpenChange:e=>{e||C({tab:r})},onReply:y.canSend?e=>{k({messageId:e.id,sender:e.sender})}:void 0}),children:(0,t.jsxs)(t.Fragment,{children:[T?null:(0,t.jsxs)(a.Tabs,{value:r,onValueChange:e=>{C({tab:e===t2?t2:t1,messageId:d})},children:[(0,t.jsxs)(a.TabsList,{variant:"line","aria-label":`${u.data?.name??"Ship"} history`,children:[(0,t.jsx)(a.TabsTrigger,{variant:"line",value:t1,children:"Timeline"}),(0,t.jsx)(a.TabsTrigger,{variant:"line",value:t2,children:"Messages"})]}),(0,t.jsx)(a.TabsContent,{value:t1,className:"pt-4",children:(0,t.jsx)(tA,{shipId:e,entries:m.data??[],state:m.isError?"error":m.data?"ready":"loading",onRetry:()=>{m.refetch()},now:o,onOpenMessage:S})}),(0,t.jsx)(a.TabsContent,{value:t2,className:"pt-4",children:(0,t.jsx)($,{shipId:e,messages:h.data??[],state:h.isError?"error":h.data?"ready":"loading",onRetry:()=>{h.refetch()},now:o,onOpenMessage:S})})]}),(0,t.jsx)(i.ComposeMessage,{isOpen:void 0!==N,onOpenChange:e=>{e||k(void 0)},replyTo:N})]})})}],15860)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,15860,e=>{"use strict";var t=e.i(43476),s=e.i(18566),n=e.i(71645),a=e.i(60592),i=e.i(65041),r=e.i(56420);let d={name:"arrow-down-left",size:24,node:[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]};d.node;let l=(0,r.default)(d),o={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};o.node;let c=(0,r.default)(o),u={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};u.node;let m=(0,r.default)(u);var h=e.i(25398),p=e.i(90063),x=e.i(69693);function g(e,t){return RegExp(`"${t}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`).exec(e)?.[1]}let f={"application/vnd.aeolus.squadron.check-in+json":()=>"Checked in at its flagship","application/vnd.aeolus.squadron.role+json":e=>{let t=g(e,"role");return void 0===t?"Given its role":`Given the role: ${t}`},"application/vnd.aeolus.squadron.on-station+json":e=>{let t=g(e,"role");return void 0===t?"Took up its role":`Took up the role: ${t}`},"application/vnd.aeolus.squadron.stand-down+json":()=>"Asked to stand down","application/vnd.aeolus.squadron.stood-down+json":()=>"Stood down"};var v=e.i(79369),b=e.i(49635),w=e.i(46150);function j(e,t){return e.sentAt.localeCompare(t.sentAt)||e.id.localeCompare(t.id)}var y=e.i(15905),N=e.i(67874),k=e.i(17981),C=e.i(88393),S=e.i(39124),T=e.i(78865);function R({message:e,shipId:s,now:n,onOpenMessage:a}){var i,r,d;let o,u,m=e.sender.id===s,h=new Date(e.sentAt),g=void 0!==(u=f[r=(i=e).contentType,r.split(";")[0]?.trim().toLowerCase()??""])?{text:u(i.preview),isCode:!1}:(0,x.isJson)(i.contentType)?{text:0===(o=function(e){let t,s=[],n=0,a=0;for(;a<e.length;){let i=e[a]??"";if('"'===i){let{value:i,end:r}=function(e,t){let s=t+1;for(;s<e.length&&'"'!==e[s];)s+="\\"===e[s]?2:1;return{value:e.slice(t+1,s),end:s+1}}(e,a);1===n&&void 0===t&&e.slice(r).trimStart().startsWith(":")?t=i:1===n&&void 0!==t&&r<=e.length&&'"'===e[r-1]&&(s.push([t,i]),t=void 0),a=r;continue}if("{"===i||"["===i)1===n&&void 0!==t&&(s.push([t,"…"]),t=void 0),n+=1;else if("}"===i||"]"===i)n-=1;else if(1===n&&void 0!==t&&/[-\dtfn]/.test(i)){let n=/^(-?\d[\d.eE+-]*|true|false|null)/.exec(e.slice(a))?.[1];if(void 0!==n){s.push([t,n]),t=void 0,a+=n.length;continue}}a+=1}return s}(d=i.preview)).length?d:o.map(([e,t])=>`${e} ${t}`).join(" · "),isCode:!0}:{text:i.preview,isCode:!1};return(0,t.jsx)("li",{className:"border-b border-border last:border-b-0",children:(0,t.jsxs)("button",{type:"button","data-testid":"message-row","data-message-id":e.id,"aria-label":`${m?"Sent":"Received"} message: ${g.text}`,className:"flex w-full items-start gap-3 px-3.5 py-3 text-left transition-colors duration-(--duration-fast) hover:bg-accent",onClick:()=>{a(e.id)},children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md border border-tone-ended-border bg-tone-ended-bg text-tone-ended-fg [&_svg]:size-(--size-icon-sm)",children:(0,t.jsx)(m?c:l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,t.jsxs)("span",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)(S.Sentence,{parts:m?"ship"===e.recipient.kind?[(0,w.text)("To "),(0,w.ship)(e.recipient.ship)]:[(0,w.text)(`To any ship of type ${e.recipient.type}`)]:[(0,w.text)("From "),(0,w.ship)(e.sender)],className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)(T.StatusBadge,{status:(0,v.deliveryStatus)(e.delivery)})]}),(0,t.jsx)("span",{"data-testid":"message-line",className:(0,p.classNames)("truncate text-muted-foreground",g.isCode?"font-mono text-id":"text-meta"),children:g.text}),(0,t.jsx)("time",{dateTime:e.sentAt,title:(0,b.fullDateTime)(h),className:"text-meta text-muted-foreground tabular-nums",children:(0,b.relativeTime)(h,n)})]})]})})}function $({shipId:e,messages:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the messages"}):"error"===n?(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3",children:[(0,t.jsx)(k.InlineError,{title:"Couldn’t load the messages",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),onClick:a,className:"self-start",children:"Try again"}):null]}):0===s.length?(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(m,{}),title:"No messages yet",description:"Messages this ship sends or receives appear here as they happen."}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:(function(e){let t=new Map(e.map(e=>[e.id,e])),s=new Map;for(let n of e){let e=function(e,t){let s=new Set([e.id]),n=e,a=null===n.inReplyTo?void 0:t.get(n.inReplyTo);for(;a&&!s.has(a.id);)s.add(a.id),a=null===(n=a).inReplyTo?void 0:t.get(n.inReplyTo);return n}(n,t);s.set(e.id,[...s.get(e.id)??[],n])}return[...s.entries()].map(([e,t])=>{let s=t.toSorted(j);return{id:e,messages:s,lastSentAt:s.at(-1)?.sentAt??""}}).toSorted((e,t)=>t.lastSentAt.localeCompare(e.lastSentAt)||t.id.localeCompare(e.id))})(s).map(s=>(0,t.jsx)("section",{"data-testid":"message-thread","aria-label":`Thread of ${String(s.messages.length)} ${1===s.messages.length?"message":"messages"}`,className:"overflow-hidden rounded-lg border border-border bg-card",children:(0,t.jsx)("ol",{children:s.messages.map(s=>(0,t.jsx)(R,{message:s,shipId:e,now:i,onOpenMessage:r},s.id))})},s.id))})}var q=e.i(17540),I=e.i(90262),A=e.i(54492),D=e.i(8041),L=e.i(5387),O=e.i(80581),z=e.i(10921),P=e.i(78608),M=e.i(84156),B=e.i(265),E=e.i(41880),F=e.i(16984),H=e.i(74544),_=e.i(58925),U=e.i(18964),V=e.i(11568),W=e.i(68997),K=e.i(57665),G=e.i(95925),Y=e.i(86875),J=e.i(22016),X=e.i(25242),Q=e.i(66616),Z=e.i(95960);let ee={request:"Couldn’t request crew",remove:"Couldn’t remove the request",restart:"Couldn’t restart the crew"};function et({at:e,now:s,children:n}){return(0,t.jsx)("time",{dateTime:e,title:(0,b.fullDateTime)(new Date(e)),className:"tabular-nums",children:n??(0,b.sinceTime)(new Date(e),s)})}function es({trierarch:e,hasTrierarchs:s}){return(0,t.jsxs)(J.default,{href:s?`/trierarchs/${e.id}`:`/ships/${e.id}`,"data-testid":"crew-request-trierarch",className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground underline decoration-input underline-offset-3 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[(0,t.jsx)(Y.ShipWheel,{"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e.name})]})}function en({requestedBy:e,requestedAt:s,now:n}){let a=null===e?null:e.name===w.OPERATOR_NAME?"you":e.name;return(0,t.jsxs)("span",{"data-testid":"crew-request-requested-by",children:[null===a?"Requested ":`Requested by ${a} `,(0,t.jsx)(et,{at:s,now:n,children:(0,b.relativeTime)(new Date(s),n)}),"."]})}let ea={note:"border-border bg-muted text-muted-foreground",waiting:"border-tone-waiting-border bg-tone-waiting-bg text-tone-waiting-fg",attention:"border-tone-attention-border bg-tone-attention-bg text-tone-attention-fg"};function ei({tone:e,icon:s,children:n}){return(0,t.jsxs)("div",{role:"attention"===e?"alert":"waiting"===e?"status":"note","data-testid":"crew-request-note",className:`flex items-start gap-2 rounded-lg border px-3 py-2.5 text-meta [&_svg]:mt-0.5 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 ${ea[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function er({stage:e,now:s}){let n="running"===e.status?e.startedAt:null,a=(0,A.restartWords)(e);return null===n&&void 0===a?null:(0,t.jsxs)("span",{className:"text-meta text-muted-foreground","data-testid":"crew-request-session",children:[null===n?null:(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(et,{at:n,now:s})]}),null!==n&&void 0!==a?" · ":null,a]})}function ed({rows:e,machineLabels:s=[]}){return(0,t.jsxs)("dl",{"data-testid":"crew-request-settings",className:"grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-x-5 gap-y-3 border-t border-border pt-3",children:[e.map(e=>(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("dt",{className:"text-caption font-medium text-muted-foreground",children:e.label}),(0,t.jsxs)("dd",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-body font-medium",children:[null===e.value?(0,t.jsx)("span",{className:"font-normal text-muted-foreground",children:"None"}):(0,t.jsx)("span",{className:e.isMono?"truncate font-mono text-id":"truncate",children:"Harness"===e.label?(0,Q.harnessWord)(e.value):e.value}),void 0===e.meta?null:(0,t.jsx)("span",{className:"text-meta font-normal text-muted-foreground",children:e.meta})]})]},e.label)),0===s.length?null:(0,t.jsxs)("div",{className:"col-span-full flex min-w-0 flex-col gap-0.5","data-testid":"crew-request-machine-labels",children:[(0,t.jsx)("dt",{className:"text-caption font-medium text-muted-foreground",children:"Machine labels"}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:s.map((e,s)=>(0,t.jsxs)(n.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(Z.LabelChip,{chip:e})]},e.valueId))})]})]})}function el(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(U.ListChecks,{"aria-hidden":!0,className:"size-(--size-icon) text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-section font-semibold",children:"Crew request"})]})}function eo(e){let{noMachineMatchesReason:s}=(0,X.useConsoleConstants)(),{stage:n,requestedBy:a,now:i,canManage:r,isAwaitingCrew:d,busy:l,error:o}=e,c=void 0===o?null:(0,t.jsx)(k.InlineError,{title:ee[o.action],description:`${o.message} Nothing changed.`});if("none"===n.kind)return(0,t.jsxs)("section",{"aria-label":"Crew request","data-testid":"crew-request",className:"flex flex-col gap-2.5 rounded-lg border border-border bg-card px-4 py-3.5 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3.5",children:[(0,t.jsx)(el,{}),(0,t.jsx)("p",{className:"min-w-0 flex-1 text-meta text-muted-foreground",children:e.hasTrierarchs?"No crew request. A crew request keeps this ship crewed: a trierarch starts a session for it and restarts it when it stops.":"No crew request. A crew request puts this ship on your Needs crew list until you crew it by hand."}),r?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(U.ListChecks,{}),isLoading:"request"===l,onClick:e.onRequest,"data-testid":"crew-request-request",children:"Request crew"}):null]}),c]});let u=(0,A.crewRequestAction)(n),m=void 0!==l;return(0,t.jsxs)("section",{"aria-label":"Crew request","data-testid":"crew-request",className:"flex flex-col gap-2.5 rounded-lg border border-border bg-card px-4 py-3.5 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsx)(el,{}),(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-2","data-testid":"crew-request-state",children:["assigned"===n.kind?(0,t.jsx)(T.StatusBadge,{status:n.status}):(0,t.jsx)(T.StatusBadge,{status:n.kind}),"needsCrew"===n.kind?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e.hasTrierarchs?"not assigned yet":n.reason??(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(et,{at:n.requestedAt,now:i})]})}):null,"crewedByHand"===n.kind&&null!==n.since?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["since ",(0,t.jsx)(et,{at:n.since,now:i})]}):null,"assigned"===n.kind?(0,t.jsx)(er,{stage:n,now:i}):null,"assigned"===n.kind&&"releasing"===n.status&&void 0!==e.statusChangedAt?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["asked ",(0,t.jsx)(et,{at:e.statusChangedAt,now:i})]}):null]}),"assigned"===n.kind?(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 text-meta",children:["on ",(0,t.jsx)(es,{trierarch:n.trierarch,hasTrierarchs:e.hasTrierarchs??!1})]}):null,(0,t.jsx)("span",{className:"flex-1"}),"assigned"===n.kind&&"releasing"===n.status?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["Waiting for ",n.trierarch.name]}):null,r?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["remove"===u?(0,t.jsx)(y.Button,{size:"sm",variant:"ghost",isLoading:"remove"===l,disabled:m,onClick:e.onRemove,"data-testid":"crew-request-remove",children:"Remove request"}):null,(0,A.isRestartable)(n)?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(G.RotateCcw,{}),isLoading:"restart"===l,disabled:m,onClick:e.onRestart,"data-testid":"crew-request-restart",children:"Restart"}):null,void 0!==e.onEdit&&void 0!==u?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(W.Pen,{}),disabled:m,onClick:e.onEdit,"data-testid":"crew-request-edit",children:"Edit…"}):null,"release"===u?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(K.Power,{}),disabled:m,onClick:e.onRelease,"data-testid":"crew-request-release",children:"Release…"}):null,"needsCrew"===n.kind&&d&&!e.hasTrierarchs?(0,t.jsx)(y.Button,{size:"sm",variant:"primary",icon:(0,t.jsx)(_.KeyRound,{}),disabled:m,onClick:e.onGetStartingPrompt,"data-testid":"crew-request-prompt",children:"Get starting prompt"}):null]}):null]}),"assigned"===n.kind?function(e,s){let{trierarch:n}=e,a=void 0===s.statusChangedAt?null:(0,t.jsx)(et,{at:s.statusChangedAt,now:s.now});switch(e.status){case"crewing":return(0,t.jsxs)(ei,{tone:"note",icon:(0,t.jsx)(V.LoaderCircle,{"aria-hidden":!0}),children:[n.name," is starting the session."]});case"running":return null;case"restarting":return(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(G.RotateCcw,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:null===a?"The session stopped.":(0,t.jsxs)(t.Fragment,{children:["The session stopped at ",a,"."]})})," ",n.name," is starting it again. Once its restarts are used up it stops trying and the request shows Crashed."]});case"crashed":return(0,t.jsxs)(ei,{tone:"attention",icon:(0,t.jsx)(F.CircleX,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:null===a?"Crashed.":(0,t.jsxs)(t.Fragment,{children:["Crashed at ",a,"."]})})," The session kept stopping and ",n.name," ","stopped trying. The lease still holds, so new deliveries wait in the inbox. Restart crews it again with the same settings."]});case"releasing":return(0,t.jsxs)(ei,{tone:"note",icon:(0,t.jsx)(K.Power,{"aria-hidden":!0}),children:["Releasing: ",n.name," is stopping the session and cleaning up. The request goes away once it confirms."]})}}(n,{statusChangedAt:e.statusChangedAt,now:i}):null,"needsCrew"===n.kind&&e.hasTrierarchs?null===n.reason?(0,t.jsx)(ei,{tone:"note",icon:(0,t.jsx)(V.LoaderCircle,{"aria-hidden":!0}),children:"Waiting for the trierarch plugin to assign a trierarch."}):n.reason===s&&void 0!==e.machineLabels&&e.machineLabels.length>0?(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(H.Clock,{"aria-hidden":!0}),children:[(0,t.jsx)("strong",{className:"font-medium",children:"No machine matches these labels."})," The plugin places this ship only on a machine with ",(0,P.machineLabelsText)(e.machineLabels),", and none"," ",(0,P.noMatchWords)(e.machineLabels.length).carries,". It assigns a trierarch as soon as one does; until then this ship is on Needs crew."]}):(0,t.jsxs)(ei,{tone:"waiting",icon:(0,t.jsx)(H.Clock,{"aria-hidden":!0}),children:[(0,t.jsxs)("strong",{className:"font-medium",children:[(0,w.capitalised)(n.reason),"."]})," The plugin assigns a trierarch as soon as one fits. Until then this ship is on Needs crew."]}):null,c,void 0===e.settingsRows?null:(0,t.jsx)(ed,{rows:e.settingsRows,machineLabels:e.machineLabels}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["needsCrew"!==n.kind||e.hasTrierarchs?null:"On your Needs crew list. Crew it by hand: get a starting prompt and start a session with it. Crewing it fulfils the request; the request stays until you remove it. ","crewedByHand"===n.kind?`${n.crewedBy.name===w.OPERATOR_NAME?"You":n.crewedBy.name} crewed it by hand. The request stands: if the lease ends, the ship is back on Needs crew until you crew it again or release it. `:null,(0,t.jsx)(en,{requestedBy:a,requestedAt:n.requestedAt,now:i}),"assigned"===n.kind&&"releasing"!==n.status?" The trierarch keeps it crewed until you release it.":null]})]})}var ec=e.i(86165),eu=e.i(48695);let em=(0,q.lazyDialog)(()=>e.A(23569).then(e=>e.RequestCrewDialog),e=>e.isOpen),eh=(0,q.lazyDialog)(()=>e.A(5419).then(e=>e.CrewReleaseDialog),e=>e.isOpen),ep=(0,q.lazyDialog)(()=>e.A(95953).then(e=>e.StartingPromptDialog),e=>e.isOpen);function ex({ship:e,timeline:s,now:a}){let i=(0,I.useAccess)(),r=(0,B.useHasTrierarchPlugin)(),d=(0,L.useRequestCrew)(),l=(0,L.useLabelContext)(),o=(0,L.useRemoveCrewRequest)(),c=(0,L.useReleaseShip)(),u=(0,L.useGetStartingPrompt)(),[m,h]=(0,n.useState)(),[p,x]=(0,n.useState)(),[g,f]=(0,n.useState)(!1),[v,b]=(0,n.useState)(),[w,j]=(0,n.useState)(!1),[y,N]=(0,n.useState)(),[k]=(0,z.useCrewSettings)(null===e.crewRequest?[]:[e.crewRequest.settings])??[],C=function(e){let s=(0,B.useMachines)(),a=(0,ec.useSquadronsConnection)(),i=(0,eu.useSquadrons)(),r=(0,L.useRequestCrew)(),d=(0,L.useLabelContext)(),[l,o]=(0,n.useState)(),[c,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(),p=(0,D.offersOf)(s.data??[]),{shipLabelsMax:x}=(0,X.useConsoleConstants)(),g=void 0===d||void 0===s.data?void 0:(0,P.machineLabelsInputOf)(d,{machines:s.data,shipLabelsMax:x}),f=(0,z.useCrewSettings)(e?.heldSettings===void 0?[]:[e.heldSettings]),v=f?.[0]??null,b=(0,D.settingsOf)("edit"===l?(0,D.valuesOf)(v,p):(0,D.defaultValues)(p)),w=void 0!==l&&void 0!==e&&("edit"!==l||void 0!==f),j=(0,B.useCrewSettingsCheck)(w&&void 0!==s.data?null===c?b:c:void 0),y=async t=>{if(void 0!==e&&void 0!==l){r.reset();try{let e=await j.checkNow();if("refused"===e.kind)return void h(new Date)}catch{}r.mutate({shipId:e.shipId,settings:t},{onSuccess:()=>{o(void 0),(0,E.showToast)("edit"===l?{title:`Settings saved for ${e.shipName}`,description:"Its trierarch restarts the session with them.",tone:"success"}:{title:`Crew requested for ${e.shipName}`,description:"The trierarch plugin assigns a trierarch that fits.",tone:"success"})}})}};return{open:e=>{r.reset(),u(null),h(void 0),o(e)},dialog:void 0===e?null:(0,t.jsx)(em,{shipName:e.shipName,mode:l??"request",state:s.isError?"unreachable":void 0===s.data?"loading":"ready",offers:p,heldSettings:v,squadrons:"connected"===a?(i.data??[]).filter(e=>"disbanded"!==e.state).map(e=>e.id):void 0,...void 0===g?{}:{machineLabels:g},check:j.data,refusedAt:m,error:r.error?.message,isPending:r.isPending,isOpen:w,onOpenChange:e=>{e||o(void 0)},onSettingsChange:e=>{u(e),h(void 0)},onSubmit:e=>void y(e),onRetry:()=>{s.refetch()}})}}("agent"===e.kind&&"retired"!==e.status?{shipId:e.id,shipName:e.name,heldSettings:e.crewRequest?.settings}:void 0);if("agent"!==e.kind||"retired"===e.status)return null;let S=(0,A.crewRequestStage)(e),T=e.crewRequest,R=async(e,t)=>{h(e),x(void 0);try{return await t(),!0}catch(t){return x({action:e,message:t instanceof Error?t.message:String(t)}),!1}finally{h(void 0)}},$=()=>{u.reset(),N((0,M.isUnclaimedPromptOut)(e)&&e.startingPrompt?{issuedAt:e.startingPrompt.issuedAt}:void 0),j(!0),u.mutate({shipId:e.id})},q=async()=>{await R("request",()=>d.mutateAsync({shipId:e.id,settings:{}}))&&(0,E.showToast)({title:`${e.name} needs crew`,description:"It is on your Needs crew list until you crew it.",tone:"success",..."awaitingCrew"===e.status&&i.canManage?{action:{label:"Get starting prompt",onClick:$}}:{}})},F=async()=>{null===T||"assigned"!==S.kind||await R("restart",()=>d.mutateAsync({shipId:e.id,settings:T.settings}))&&(0,E.showToast)({title:`Restarting ${e.name}`,description:`${S.trierarch.name} starts its session again with the same settings.`,tone:"success"})},H=async t=>{b(void 0);let s=(0,A.releaseSteps)(t),n=0;try{for(let t of s)await ("removeCrewRequest"===t?o.mutateAsync({shipId:e.id}):c.mutateAsync({shipId:e.id})),n+=1;f(!1)}catch(t){let e=t instanceof Error?t.message:String(t);b(0===n?`${e} Nothing changed.`:`${e} Its crew request is removed; the session still holds the ship. Try again to end its lease.`)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo,{stage:S,requestedBy:(0,A.requestedBy)(s),statusChangedAt:(0,A.statusChangedAt)(s),now:a,canManage:i.canManage,isAwaitingCrew:"awaitingCrew"===e.status,hasTrierarchs:r,busy:m,error:p,settingsRows:null===T?void 0:(0,D.settingsRows)(k),...null===T||void 0===l?{}:{machineLabels:(0,O.pickedChips)((0,P.machineLabelIdsOf)(k),l)},onRequest:()=>{r?C.open("request"):q()},...r?{onEdit:()=>{C.open("edit")}}:{},onRemove:()=>void R("remove",()=>o.mutateAsync({shipId:e.id})),onRelease:()=>{b(void 0),f(!0)},onRestart:()=>void F(),onGetStartingPrompt:$}),C.dialog,"crewedByHand"===S.kind||"assigned"===S.kind?(0,t.jsx)(eh,{shipName:e.name,stage:S,sessionLocation:null===e.location?null:e.location.description??e.location.kind.toLowerCase(),inFlightCount:e.inFlightDeliveries,isOpen:g,onOpenChange:f,isPending:o.isPending||c.isPending,error:v,onConfirm:()=>void H(S)}):null,(0,t.jsx)(ep,{shipName:e.name,state:u.data?"shown":u.isError?"error":"issuing",prompt:u.data?.prompt,crewLines:u.data?.crewLines,replacesUnclaimed:y,error:u.error?.message,isOpen:w,onOpenChange:e=>{e||(u.reset(),j(!1))},onConfirm:()=>{u.mutate({shipId:e.id})}})]})}var eg=e.i(84294),ef=e.i(19249);function ev({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 bg-card px-3.5 py-3",children:[(0,t.jsx)("dt",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-body text-foreground",children:s})]})}function eb({shipId:e,now:s}){let n=(0,eu.useSquadrons)(),a=(0,eu.useCatalogue)(),i=n.data?.find(t=>t.flagship.shipId===e||t.members.some(t=>t.shipId===e));if(!i)return null;let r=(0,t.jsx)(J.default,{href:`/squadrons/${i.id}`,className:"font-mono hover:underline","data-testid":"ship-squadron-link",children:i.id});if(i.flagship.shipId===e)return(0,t.jsxs)("div",{role:"note","data-testid":"ship-flagship-note",className:"flex flex-wrap items-center gap-3 rounded-lg border border-border bg-muted px-3.5 py-3 text-meta text-foreground",children:[(0,t.jsxs)("span",{className:"grow",children:["Flagship of squadron ",r,": the address for work sent to the team. The squadron manager crews it, so it can’t be released, renamed or retired; it retires when the squadron disbands."]}),(0,t.jsx)(y.Button,{size:"xs",nativeButton:!1,render:(0,t.jsx)(J.default,{href:`/squadrons/${i.id}`}),"data-testid":"ship-open-squadron",children:"Open squadron"})]});let d=i.members.find(t=>t.shipId===e);if(!d)return null;let l=a.data?.blueprints.find(e=>e.repository===i.blueprint.repository&&e.name===i.blueprint.name&&e.version===i.blueprint.version),o=l?.roles.find(e=>e.name===d.role)?.template,c=null===d.crew.lastSeenAt?void 0:(0,b.duration)(new Date(d.crew.lastSeenAt),s);return(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:["silent"===d.health&&"disbanded"!==i.state&&(0,t.jsxs)("div",{role:"alert","data-testid":"ship-silent-alert",className:"rounded-lg border border-tone-attention-border bg-tone-attention-bg px-3.5 py-3 text-meta text-foreground",children:[(0,t.jsx)("strong",{className:"font-semibold text-tone-attention-fg",children:void 0===c?"Silent.":`Silent: not seen for ${c}.`})," It checks in"," ",(0,eg.checkInText)(d.checkInMinutes),", so its session has probably stopped. Get a new crew line and start a new session; the old crew line then stops working."]}),(0,t.jsxs)("dl",{"data-testid":"ship-squadron-facts",className:"grid grid-cols-4 gap-px overflow-hidden rounded-lg border border-border bg-border max-sm:grid-cols-2",children:[(0,t.jsxs)(ev,{label:"Squadron",children:[r,(0,t.jsx)(T.StatusBadge,{status:i.state})]}),(0,t.jsxs)(ev,{label:"Role and template",children:[(0,t.jsx)("span",{className:"rounded-sm bg-secondary px-1.5 font-mono text-id",children:d.role}),o&&(0,t.jsxs)(J.default,{href:(0,eg.templatePath)(o),className:"font-mono text-meta hover:underline",children:[o.name,"@",o.version]})]}),(0,t.jsx)(ev,{label:"Health",children:(0,t.jsx)(ef.HealthIndicator,{health:d.health,detail:"silent"===d.health||"late"===d.health?c:void 0})}),(0,t.jsx)(ev,{label:"Hand-offs",children:l?(0,t.jsx)("span",{className:"text-meta",children:(0,eg.handoffsText)((0,eg.handoffsOf)(l,d.role))}):(0,t.jsx)(J.default,{href:(0,eg.blueprintPath)(i.blueprint),className:"text-meta text-muted-foreground hover:underline",children:"See its blueprint"})})]})]})}var ew=e.i(21959),ej=e.i(15327),ey=e.i(76561),eN=e.i(22768),ek=e.i(10818),eC=e.i(69309),eS=e.i(26478),eT=e.i(66390),eR=e.i(61966),e$=e.i(19321),eq=e.i(63481);function eI({harness:e,model:s,testId:n}){return null===e&&null===s?null:(0,t.jsxs)("span",{"data-testid":n,className:"flex min-w-0 flex-wrap items-center gap-x-1 text-meta text-muted-foreground",children:[null===e?null:(0,t.jsx)("span",{children:(0,Q.harnessWord)(e)}),null!==e&&null!==s?(0,t.jsx)("span",{"aria-hidden":!0,children:"·"}):null,null===s?null:(0,t.jsx)("span",{className:"truncate font-mono text-id",children:s})]})}var eA=e.i(73330);function eD({ping:e,now:s,testId:n}){return null===e?null:(0,t.jsx)("span",{title:`Pinged ${(0,b.fullDateTime)(new Date(e.sentAt))}`,"data-testid":n,"data-state":e.state,className:"text-meta text-muted-foreground tabular-nums",children:(0,eA.pingLine)(e,s)})}var eL=e.i(67927),eO=e.i(93361),ez=e.i(91703);function eP({details:e,bytes:s,version:n,testId:a}){return(0,t.jsxs)("details",{"data-testid":a,className:"group rounded-lg border border-border bg-card",children:[(0,t.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 px-3.5 py-2.5 text-meta text-muted-foreground [&::-webkit-details-marker]:hidden",children:[(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0,className:"size-(--size-icon-sm) shrink-0 transition-transform group-open:rotate-90"}),(0,t.jsx)("span",{className:"font-medium text-foreground",children:"Report details"}),(0,t.jsxs)("span",{className:"tabular-nums",children:["· version ",n]})]}),(0,t.jsx)("div",{className:"px-3.5 pb-3.5",children:(0,t.jsx)(ez.CodeBlock,{label:(0,eO.reportDetailsLabel)(s),code:(0,eO.reportDetailsJson)(e),copyLabel:"Copy report details",codeTestId:`${a}-code`})})]})}var eM=e.i(81830),eB=e.i(39448);function eE({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1 bg-card px-3.5 py-3",children:[(0,t.jsx)("dt",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"flex min-w-0 items-center gap-1.5 text-body text-foreground",children:s})]})}function eF({ship:e,now:s,labels:n,way:a}){let i,r="operator"===e.kind,d=null===e.crewedSince?null:new Date(e.crewedSince),l=new Date(e.commissionedAt);return(0,t.jsxs)("dl",{className:"grid grid-cols-4 gap-px overflow-hidden rounded-lg border border-border bg-border max-sm:grid-cols-2",children:[(0,t.jsx)(eE,{label:"Location",children:(0,t.jsxs)("span",{className:"inline-flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)(eq.LocationTag,{kind:e.location?.kind??null,description:e.location?.description,size:"md"}),(0,t.jsx)(eI,{harness:e.harness,model:e.model?.id??null,testId:"ship-model"}),null===e.lastSeenAt?null:(0,t.jsx)("time",{dateTime:e.lastSeenAt,title:(0,b.fullDateTime)(new Date(e.lastSeenAt)),"data-testid":"ship-last-seen",className:"text-meta text-muted-foreground tabular-nums",children:(0,b.lastSeen)(new Date(e.lastSeenAt),s)}),(0,t.jsx)(eD,{ping:e.ping,now:s,testId:"ship-ping-status"}),"agent"!==e.kind?null:(0,t.jsx)(eM.ReportLine,{report:e.report,now:s,variant:"full",testId:"ship-report"})]})}),(0,t.jsx)(eE,{label:"Crewed since",children:d?(0,t.jsx)("time",{dateTime:e.crewedSince??void 0,title:(0,b.fullDateTime)(d),className:"tabular-nums",children:(i=s.getTime()-d.getTime()<864e5?(0,b.clockTime)(d):(0,b.shortDateTime)(d),`${i} \xb7 ${(0,b.duration)(d,s)}`)}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Not crewed"})}),(0,t.jsx)(eE,{label:"Commissioned",children:(0,t.jsx)("time",{dateTime:e.commissionedAt,title:(0,b.fullDateTime)(l),children:r?`Fleet created ${(0,b.dayDate)(l)}`:(0,b.dayDate)(l)})}),(0,t.jsxs)(eE,{label:"Ship id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(eR.CopyButton,{value:e.id,label:"Copy ship id"})]}),void 0===a?null:(0,t.jsxs)("div",{className:"col-span-4 flex min-w-0 items-start gap-4 bg-card px-3.5 py-2.5 max-sm:col-span-2 max-sm:flex-col max-sm:gap-1.5","data-testid":"ship-delivery",children:[(0,t.jsx)("dt",{className:"shrink-0 text-meta text-muted-foreground",children:"Delivery"}),(0,t.jsx)("dd",{className:"min-w-0 flex-1",children:a})]}),void 0===n?null:(0,t.jsxs)("div",{className:"col-span-4 flex min-w-0 items-center gap-4 bg-card px-3.5 py-2.5 max-sm:col-span-2 max-sm:flex-col max-sm:items-start max-sm:gap-1.5","data-testid":"ship-labels",children:[(0,t.jsx)("dt",{className:"shrink-0 text-meta text-muted-foreground",children:"Labels"}),(0,t.jsx)("dd",{className:"min-w-0 flex-1",children:n})]})]})}function eH({icon:e,children:s}){return(0,t.jsxs)("p",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted px-3.5 py-2.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0",children:[e,(0,t.jsx)("span",{children:s})]})}function e_({ship:e,shipId:s,state:n,actions:a,crewRequest:i,now:r,backHref:d="/",labels:l,isPluginShip:o=!1,way:c}){let{fleetScopes:u}=(0,X.useConsoleConstants)();if("loading"===n||"ready"===n&&void 0===e)return(0,t.jsxs)("div",{"aria-busy":!0,"data-testid":"ship-header",className:"flex flex-col gap-4",children:[(0,t.jsx)("span",{className:"sr-only",children:"Loading the ship"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(e$.Skeleton,{className:"h-8 w-40"}),(0,t.jsx)(e$.Skeleton,{className:"h-6 w-20"}),(0,t.jsx)(e$.Skeleton,{className:"h-6 w-16"})]}),(0,t.jsx)(e$.Skeleton,{className:"h-16 w-full rounded-lg"})]});if("not-found"===n||void 0===e)return(0,t.jsx)("div",{"data-testid":"ship-header",children:(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(eN.CircleAlert,{}),title:"Ship not found",description:(0,t.jsxs)(t.Fragment,{children:["No ship with the id ",s?(0,t.jsx)("span",{className:"font-mono text-id",children:s}):"given"," exists in this fleet. The link may be incomplete. Retired ships keep their page."]}),action:(0,t.jsx)(y.Button,{size:"sm",nativeButton:!1,render:({children:e,...s})=>(0,t.jsx)(J.default,{href:d,...s,children:e}),children:"Back to fleet overview"})})});let m="operator"===e.kind,h="retired"===e.status;return(0,t.jsxs)("div",{"data-testid":"ship-header",className:"flex flex-col gap-4 max-sm:gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2.5 max-sm:flex-col max-sm:items-start max-sm:gap-1.5",children:[(0,t.jsx)("h1",{className:"min-w-0",children:(0,t.jsx)(eB.ShipName,{name:e.name,shipId:e.id,size:"title",isSuffixShown:h})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T.StatusBadge,{status:e.status}),m?(0,t.jsxs)(eT.Badge,{variant:"kind",children:[(0,t.jsx)(eS.UserRound,{"aria-hidden":!0}),"operator"]}):(0,t.jsxs)(t.Fragment,{children:[o?(0,t.jsxs)(eT.Badge,{variant:"kind","data-testid":"ship-plugin",children:[(0,t.jsx)(eC.Plug,{"aria-hidden":!0}),"plugin"]}):null,(0,t.jsx)(eT.Badge,{variant:"type",children:e.type}),e.scopes.filter(e=>u.some(t=>t===e)).map(e=>(0,t.jsx)(eT.Badge,{variant:"kind","data-testid":"ship-fleet-scope",children:e},e))]}),"awaitingCrew"===e.status&&null===e.startingPrompt?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm)",children:[(0,t.jsx)(_.KeyRound,{"aria-hidden":!0}),"No starting prompt issued"]}):null,"awaitingCrew"===e.status&&null!==e.startingPrompt?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-meta text-muted-foreground [&_svg]:size-(--size-icon-sm)",children:[(0,t.jsx)(_.KeyRound,{"aria-hidden":!0}),(0,t.jsxs)("span",{children:["Prompt issued"," ",(0,t.jsx)("time",{dateTime:e.startingPrompt.issuedAt,title:(0,b.fullDateTime)(new Date(e.startingPrompt.issuedAt)),children:(0,b.relativeTime)(new Date(e.startingPrompt.issuedAt),r)}),e.startingPrompt.isClaimed?", claimed":", not claimed yet"]})]}):null]})]}),a&&!h?(0,t.jsx)("div",{className:(0,p.classNames)("flex flex-wrap items-center gap-2","max-sm:w-full max-sm:[&>*]:flex-1"),children:a}):null]}),m?(0,t.jsx)(eH,{icon:(0,t.jsx)(ek.Info,{"aria-hidden":!0}),children:"argo is your ship. This console session crews it. It can’t be released, renamed or retired."}):null,h&&null!==e.retiredAt?(0,t.jsxs)(eH,{icon:(0,t.jsx)(ey.Archive,{"aria-hidden":!0}),children:["Retired on ",(0,b.fullDateTime)(new Date(e.retiredAt)),". Read-only."]}):null,i,(0,t.jsx)(eF,{ship:e,now:r,labels:l,way:c}),"agent"===e.kind&&e.report?.details&&null!==e.report.detailsBytes?(0,t.jsx)(eP,{details:e.report.details,bytes:e.report.detailsBytes,version:e.report.detailsVersion,testId:"ship-report-details"}):null]})}var eU=e.i(49655),eV=e.i(46157);function eW({view:e,onOpenMessage:s}){let{lines:n,oldest:a}=e;return(0,t.jsxs)("ul",{"data-testid":"ship-way","aria-label":"Its side of the way",className:"flex flex-col gap-1",children:[n.map(e=>(0,t.jsx)(eV.WayLineItem,{line:e,testId:"ship-way-line"},e.text)),a?(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","data-testid":"ship-way-oldest","aria-label":`Open the oldest message waiting: ${a.text}`,onClick:()=>{s(a.messageId)},className:"inline-flex flex-wrap items-center gap-1.5 rounded-xs text-left text-meta hover:underline focus-visible:outline-2 focus-visible:outline-ring max-sm:text-body-touch",children:[(0,t.jsx)(T.StatusBadge,{status:a.status}),a.isOverdue?(0,t.jsx)(eU.AlarmClock,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-tone-attention-fg"}):null,(0,t.jsx)("span",{className:(0,p.classNames)(a.isOverdue?"text-tone-attention-fg":"text-muted-foreground"),children:a.text}),(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0,className:"size-(--size-icon-sm)"})]})}):null]})}var eK=e.i(99261),eG=e.i(89664),eY=e.i(16327),eJ=e.i(56539),eX=e.i(77071),eQ=e.i(63676),eZ=e.i(70703),e0=e.i(6734);let e1=(0,eZ.default)(()=>e.A(67858).then(e=>e.LabelPicker),{loadableGenerated:{modules:[59068]},ssr:!1});function e2({chip:e,labelKey:s,isBusy:a,onUnassign:i,onChange:r}){let[d,l]=(0,n.useState)(!1);return(0,t.jsxs)(e0.Popover,{open:d,onOpenChange:l,children:[(0,t.jsx)(e0.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":`Change or remove ${e.key}=${e.value}`,"data-testid":"ship-label-yours",disabled:a,className:"inline-flex items-center rounded-sm focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60"}),children:(0,t.jsx)(Z.LabelChip,{chip:e,trailing:(0,t.jsx)(eY.ChevronDown,{"aria-hidden":!0}),className:"hover:bg-accent"})}),(0,t.jsxs)(e0.PopoverContent,{align:"start",sideOffset:6,className:"w-72 p-1.5","data-testid":"ship-label-menu",children:[(0,t.jsxs)("span",{className:"flex items-center justify-between px-2 pt-1 pb-1.5 text-meta",children:[(0,t.jsxs)("span",{className:"font-mono",children:[e.key,"=",(0,t.jsx)("span",{className:"text-muted-foreground",children:e.value})]}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"Change the value"})]}),(0,t.jsx)("ul",{className:"flex flex-col",children:(s?.values??[]).map(n=>{let a=n.valueId===e.valueId,i=s?.carriedValueIds.includes(n.valueId)??!1;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",disabled:i,"data-testid":"ship-label-value",className:"flex h-(--size-control-sm) w-full items-center gap-2 rounded-sm px-2 text-left text-body hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none [&_svg]:size-(--size-icon-sm)",onClick:()=>{l(!1),r({from:e.valueId,to:n.valueId})},children:[(0,t.jsx)("span",{className:"w-4",children:i?(0,t.jsx)(eG.Check,{"aria-hidden":!0}):null}),(0,t.jsx)("span",{className:(0,p.classNames)("min-w-0 grow truncate font-mono",i&&!a?"text-muted-foreground":void 0),children:n.value}),(0,t.jsx)("span",{className:"text-meta text-muted-foreground tabular-nums",children:i&&!a?"Carried":`${String(n.shipCount)} ${1===n.shipCount?"ship":"ships"}`})]})},n.valueId)})}),(0,t.jsx)("div",{className:"mt-1 border-t border-border pt-1",children:(0,t.jsxs)("button",{type:"button","data-testid":"ship-label-remove",className:"flex h-(--size-control-sm) w-full items-center gap-2 rounded-sm px-2 text-body text-destructive-text hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",onClick:()=>{l(!1),i(e.valueId)},children:[(0,t.jsx)(eQ.X,{"aria-hidden":!0}),"Remove label"]})})]})]})}function e5({keys:e,isBusy:s,onAssign:a}){let[i,r]=(0,n.useState)(!1);return(0,t.jsxs)(e0.Popover,{open:i,onOpenChange:r,children:[(0,t.jsx)(e0.PopoverTrigger,{render:(0,t.jsx)(y.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(eX.Plus,{}),disabled:s,"data-testid":"ship-labels-add"}),children:"Add label"}),(0,t.jsxs)(e0.PopoverContent,{align:"start",sideOffset:6,className:"w-80 p-2","data-testid":"ship-labels-add-popover",children:[(0,t.jsxs)("span",{className:"flex items-center justify-between px-2 pt-1 pb-2 text-body font-medium",children:["Add a label",(0,t.jsx)("span",{className:"text-meta font-normal text-muted-foreground",children:"Yours"})]}),0===e.length?(0,t.jsx)("p",{className:"px-2 py-2 text-meta text-muted-foreground",children:"You have no labels yet. Define one on the Labels page, then put it on ships here."}):(0,t.jsx)(e1,{groups:[{title:"Yours",keys:[...e]}],pickedValueIds:e.flatMap(e=>e.carriedValueIds),pickedWord:"Carried",onPick:e=>{r(!1),a(e)}}),(0,t.jsx)("p",{className:"mt-2 flex items-center justify-between border-t border-border px-2 pt-2 text-meta",children:(0,t.jsx)(J.default,{href:"/labels",className:"font-medium hover:underline",children:0===e.length?"Define a label":"Manage labels"})})]})]})}function e3({chips:e,keys:s,limit:a,isBusy:i,error:r,onAssign:d,onUnassign:l,onChange:o}){let[c,u]=(0,n.useState)(!1),m=!c&&e.length>3,h=m?e.slice(0,2):e,p=[...new Set(h.filter(e=>"none"!==e.mark).map(e=>e.ownerName))];return(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-2","data-testid":"ship-labels-edit",children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[0===e.length?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"No labels"}):null,h.filter(e=>"none"===e.mark).map(e=>(0,t.jsx)(e2,{chip:e,labelKey:s.find(t=>t.labelId===e.labelId),isBusy:i,onUnassign:l,onChange:o},e.valueId)),m?(0,t.jsxs)("button",{type:"button","aria-label":`Show all ${String(e.length)} labels`,"data-testid":"ship-labels-more",className:"inline-flex h-5.5 items-center rounded-sm bg-secondary px-1.5 text-caption font-medium tabular-nums hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring",onClick:()=>{u(!0)},children:["+",e.length-2]}):null,a.isAtLimit?null:(0,t.jsx)(e5,{keys:s,isBusy:i,onAssign:d}),p.map(e=>(0,t.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["by ",e]}),h.filter(t=>"none"!==t.mark&&t.ownerName===e).map(e=>(0,t.jsx)(Z.LabelChip,{chip:e,testId:"ship-label"},e.valueId))]},e)),c&&e.length>3?(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 rounded-sm px-1 text-meta hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",onClick:()=>{u(!1)},children:[(0,t.jsx)(eJ.ChevronUp,{"aria-hidden":!0}),"Show fewer"]}):null,a.isAtLimit?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"At the limit: a ship carries at most 20 labels (decision 0031)."}):null,void 0===a.count?null:(0,t.jsx)("span",{className:"ml-auto text-meta text-muted-foreground tabular-nums","data-testid":"ship-labels-count",children:a.count})]}),void 0===r?null:(0,t.jsx)(k.InlineError,{title:r.title,description:`Refused: ${r.message}. Nothing changed.`})]})}function e6(e,t){for(let s of e){let e=s.values.find(e=>e.valueId===t);if(void 0!==e)return`${s.key}=${e.value}`}return"the label"}function e7({ship:e}){let{shipLabelsMax:s}=(0,X.useConsoleConstants)(),a=(0,L.useLabelContext)(),i=(0,I.useAccess)(),r=(0,L.useAssignLabel)(),d=(0,L.useUnassignLabel)(),[l,o]=(0,n.useState)(void 0);if(void 0===a)return(0,t.jsx)(e$.Skeleton,{className:"h-5.5 w-40"});let c=(0,O.chipsOf)(e,a);if(!(0,O.canAssignLabelsTo)(e,i))return(0,t.jsx)(eK.ShipLabels,{chips:c});let u=(0,O.assignKeysOf)(e,a),m=e=>t=>{o({title:e,message:t.message})};return(0,t.jsx)(e3,{chips:c,keys:u,limit:(0,O.labelLimitOf)(e,s),isBusy:r.isPending||d.isPending,error:l,onAssign:t=>{o(void 0),r.mutate({shipId:e.id,valueId:t},{onError:m(`Couldn’t add ${e6(u,t)}`)})},onUnassign:t=>{o(void 0),d.mutate({shipId:e.id,valueId:t},{onError:m(`Couldn’t remove ${e6(u,t)}`)})},onChange:({from:t,to:s})=>{o(void 0),d.mutate({shipId:e.id,valueId:t},{onSuccess:()=>{r.mutate({shipId:e.id,valueId:s},{onError:n=>{r.mutate({shipId:e.id,valueId:t}),m(`Couldn’t change ${e6(u,t)} to ${e6(u,s)}`)(n)}})},onError:m(`Couldn’t change ${e6(u,t)}`)})}})}var e4=e.i(87255),e8=e.i(31458);let e9={name:"lock-keyhole",size:24,node:[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]};e9.node;let te=(0,r.default)(e9),tt={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]};tt.node;let ts=(0,r.default)(tt);var tn=e.i(67784),ta=e.i(25799);let ti={name:"mail-minus",size:24,node:[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]};ti.node;let tr=(0,r.default)(ti),td={name:"mail-x",size:24,node:[["path",{d:"M22 12.532V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8.792",key:"8lpqwp"}],["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["path",{d:"m16.5 16.5 5 5",key:"zc9lw7"}],["path",{d:"m21.5 16.5-5 5",key:"1empo3"}]]};td.node;let tl=(0,r.default)(td),to={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};to.node;let tc=(0,r.default)(to),tu={name:"package-x",size:24,node:[["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m16.5 14.5 5 5",key:"ozpm51"}],["path",{d:"m16.5 19.5 5-5",key:"syf6b9"}],["path",{d:"M21 10.5V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l.13-.074",key:"isw6gs"}],["path",{d:"M3.29 7 12 12l8.71-5",key:"19ckod"}],["path",{d:"m7.5 4.27 8.997 5.148",key:"9yrvtv"}]]};tu.node;let tm=(0,r.default)(tu),th={name:"pen-line",size:24,node:[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],aliases:["edit-3"]};th.node;let tp=(0,r.default)(th),tx={name:"shield-alert",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]};tx.node;let tg=(0,r.default)(tx);var tf=e.i(37817),tv=e.i(40798);function tb(e,t){let s=e.details[t];return"string"==typeof s?s:void 0}function tw(e){return tb(e,"key")??""}function tj(e){return(tb(e,"values")??"").split(",").join(", ")}function ty(e){return e?[(0,w.text)(" by "),(0,w.ship)(e)]:[]}let tN={deregistered:"Its session deregistered.",takenOver:"Taken over by a new console session.",signedOut:"The operator signed out.",passwordReset:"Its session ended with the operator password reset.",retired:"Its session ended: the ship was retired."};function tk(e){return e.message?.isPing===!0}function tC(e){return e.message?[(0,w.text)(tk(e)?"a ping from ":"a message from "),(0,w.ship)(e.message.sender)]:[(0,w.text)("a message")]}function tS(e){let[t,...s]=tC(e);return t?.kind==="text"?[(0,w.text)((0,w.capitalised)(t.text)),...s]:tC(e)}function tT(e,t){let{shipId:s,verb:n}=t,a=e.actor;return[...null===a||a.id===s?[(0,w.text)((0,w.capitalised)(n))]:[(0,w.ship)(a),(0,w.text)(` ${n}`)],(0,w.text)(" "),...tC(e)]}let tR={received:l,sent:c,claimed:ts,released:tn.LogOut,prompt:_.KeyRound,commissioned:e8.Flag,acknowledged:ta.MailCheck,returned:tf.Undo2,undeliverable:tl,secret:te,fleet:e4.Anchor,password:tg,retired:ey.Archive,abandoned:tm,dismissed:tr,renamed:tp,reported:tc},t$={waiting:"border-tone-waiting-border bg-tone-waiting-bg text-tone-waiting-fg",active:"border-tone-active-border bg-tone-active-bg text-tone-active-fg",ok:"border-tone-ok-border bg-tone-ok-bg text-tone-ok-fg",attention:"border-tone-attention-border bg-tone-attention-bg text-tone-attention-fg",ended:"border-tone-ended-border bg-tone-ended-bg text-tone-ended-fg"},tq="flex w-full gap-3 px-3.5 py-3 text-left";function tI({entry:e,shipId:s,now:n,onOpenMessage:a}){let{parts:i,tone:r,icon:d}=function(e,t){switch(e.type){case"FleetInitialised":return{parts:[(0,w.text)("Fleet initialised")],tone:"ended",icon:"fleet"};case"ShipCommissioned":{let t=tb(e,"type");return{parts:[(0,w.text)("Commissioned"),...ty(e.actor),...void 0===t?[]:[(0,w.text)(` as ${t}`)]],tone:"ended",icon:"commissioned"}}case"OwnerSet":let s;return{parts:"inherited"===(s=tb(e,"how"))?[(0,w.text)("Owner set: its commissioner's owner")]:"named"===s?[(0,w.text)("Owner set: named"),...ty(e.actor)]:[(0,w.text)("Owner set: argo by default")],tone:"ended",icon:"commissioned"};case"OwnerChanged":return{parts:"ownerRetired"===tb(e,"why")?[(0,w.text)("Owner retired: argo owns it now")]:[(0,w.text)("Owner changed"),...ty(e.actor)],tone:"ended",icon:"renamed"};case"StartingPromptIssued":return{parts:[(0,w.text)("Starting prompt issued")],tone:"ended",icon:"prompt"};case"ShipClaimed":return{parts:[(0,w.text)(`Claimed by a session on ${function(e){let t=tb(e,"locationDescription");if(void 0!==t&&""!==t)return t;let s=tb(e,"location");return"DEVICE"===s||"CLOUD"===s||"SERVER"===s||"OTHER"===s?(0,tv.locationKindWord)(s):"an unknown location"}(e)}`)],tone:"ok",icon:"claimed"};case"LeaseRevoked":let n,a;return{parts:[..."released"===(n=tb(e,"reason")??"")?[(0,w.text)("Released"),...ty(e.actor),(0,w.text)(".")]:[(0,w.text)(tN[n]??"Its session ended.")],..."number"==typeof(a=e.details.returnedDeliveries)&&a>0?[(0,w.text)(` ${(0,w.counted)(a,{one:"in-flight delivery",many:"in-flight deliveries"})} went back to pending.`)]:[]],tone:"waiting",icon:"released"};case"CredentialRevoked":return{parts:[(0,w.text)("Secret invalidated")],tone:"ended",icon:"secret"};case"OperatorPasswordReset":return{parts:[(0,w.text)("Operator password reset")],tone:"waiting",icon:"password"};case"FleetLimitsChanged":return{parts:[(0,w.text)("Fleet limits changed")],tone:"ended",icon:"fleet"};case"SignInTicketIssued":return{parts:[(0,w.text)("Sign-in ticket issued")],tone:"ended",icon:"password"};case"ViewerSessionStarted":return{parts:[(0,w.text)("Someone started viewing the fleet")],tone:"ended",icon:"password"};case"CrewRequested":return{parts:[(0,w.text)("Crew requested"),...ty(e.actor)],tone:"waiting",icon:"claimed"};case"CrewRequestRemoved":return{parts:[(0,w.text)("Crew request removed"),...ty(e.actor)],tone:"ended",icon:"released"};case"CrewRequestExplained":{let t=tb(e,"reason");return{parts:[(0,w.text)(void 0===t?"Crew request can not be placed yet":`Crew request can not be placed: ${t}`),...ty(e.actor)],tone:"waiting",icon:"reported"}}case"CrewRequestGivenBack":{let t=tb(e,"reason");return{parts:[(0,w.text)(void 0===t?"Crew request given back":`Crew request given back: ${t}`),...ty(e.actor)],tone:"waiting",icon:"released"}}case"WorktreeClearRequested":return{parts:[(0,w.text)(`Clearing of the kept ${tb(e,"repository")??""} worktree requested`),...ty(e.actor)],tone:"waiting",icon:"reported"};case"WorktreeCleared":return{parts:[(0,w.text)("not-kept"===tb(e,"outcome")?`Kept ${tb(e,"repository")??""} worktree cleared (none was kept)`:`Kept ${tb(e,"repository")??""} worktree cleared`),...ty(e.actor)],tone:"ended",icon:"retired"};case"WorktreeClearRemoved":return{parts:[(0,w.text)(`Clearing of the kept ${tb(e,"repository")??""} worktree dropped`),...ty(e.actor)],tone:"ended",icon:"released"};case"CrewAssigned":return{parts:[(0,w.text)("Crew request assigned"),...ty(e.actor)],tone:"waiting",icon:"claimed"};case"CrewStatusChanged":{let t=tb(e,"status");return{parts:[(0,w.text)(void 0===t?"Crew status changed":`Crew ${t}`),...ty(e.actor)],tone:"crashed"===t?"attention":"active",icon:"reported"}}case"LabelDefined":return{parts:[(0,w.text)(`Label ${tw(e)} defined: ${tj(e)}`)],tone:"ended",icon:"reported"};case"LabelValuesChanged":return{parts:[(0,w.text)(`Label ${tw(e)} values changed: ${tj(e)}`)],tone:"ended",icon:"reported"};case"LabelRetired":return{parts:[(0,w.text)(`Label ${tw(e)} retired`)],tone:"ended",icon:"retired"};case"NetworkRulesSet":{let t=e.details.rules,s=String(e.details.version??""),n="number"==typeof t?`Network rules set: ${String(t)} rules`:"Network rules cleared: every ship reaches every ship";return{parts:[(0,w.text)(`${n}, version ${s}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"NetworkRulesDeclared":{let t=e.details.rules,s="number"==typeof t&&t>0?`Network rules declared: ${String(t)} rules`:"Declared network rules withdrawn";return{parts:[(0,w.text)(s),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"ScopesDeclared":{let t="number"==typeof e.details.scopes?e.details.scopes:0;return{parts:[(0,w.text)(`Scopes declared: namespace ${tb(e,"namespace")??""}, ${String(t)} ${1===t?"scope":"scopes"}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"ScopesChanged":{let t=tb(e,"added")??"",s=tb(e,"removed")??"",n=[...""===t?[]:[`granted ${t}`],...""===s?[]:[`revoked ${s}`]];return{parts:[(0,w.text)(`Scopes changed: ${n.join(", ")}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"PluginConnected":return{parts:[(0,w.text)("Connected as a plugin: reads every ship"),...ty(e.actor)],tone:"ended",icon:"fleet"};case"PluginDisconnected":return{parts:[(0,w.text)(`No longer a connected plugin: ${tb(e,"why")??""}`),...ty(e.actor)],tone:"ended",icon:"fleet"};case"NetworkPluginRegistered":return{parts:[(0,w.text)(`Networking plugin registered: while unavailable ${tb(e,"whileUnavailable")??""}, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"};case"NetworkPluginUnregistered":return{parts:[(0,w.text)(`Networking plugin unregistered: every ship reaches every ship, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"};case"BuiltInRuleChanged":{let t=tb(e,"verb"),s="viewerRead"===e.details.rule?"viewer read":`${tb(e,"rule")??""}${void 0===t?"":` for ${t}`}`,n=!0===e.details.isOn?"on":"off";return{parts:[(0,w.text)(`Built-in rule ${s} turned ${n}, version ${String(e.details.version??"")}`),...ty(e.actor)],tone:"ended",icon:"fleet"}}case"LabelDeleted":return{parts:[(0,w.text)(`Label ${tw(e)} deleted`)],tone:"ended",icon:"retired"};case"LabelAssigned":return{parts:[(0,w.text)(`Labelled ${tw(e)}=${tb(e,"value")??""}`),...ty(e.actor)],tone:"ended",icon:"reported"};case"LabelUnassigned":return{parts:[(0,w.text)(`Label ${tw(e)}=${tb(e,"value")??""} removed`),...ty(e.actor)],tone:"ended",icon:"reported"};case"MessageAccepted":let i;return{parts:(i=e.message)?tk(e)&&"ship"===i.recipient.kind?i.sender.id===t?[(0,w.text)("Pinged "),(0,w.ship)(i.recipient.ship)]:[(0,w.text)("Pinged by "),(0,w.ship)(i.sender)]:i.sender.id===t?"ship"===i.recipient.kind?[(0,w.text)("Sent a message to "),(0,w.ship)(i.recipient.ship)]:[(0,w.text)(`Sent a message to any ship of type ${i.recipient.type}`)]:[(0,w.text)("Received a message from "),(0,w.ship)(i.sender)]:[(0,w.text)("A message was sent")],tone:"ended",icon:e.message?.sender.id===t?"sent":"received"};case"LeasePushed":return{parts:[(0,w.text)("Pushed: its trierarch or plugin watcher receives for its session")],tone:"ok",icon:"received"};case"DeliveryReceived":return{parts:tT(e,{shipId:t,verb:!0===e.details.again?"received again":"received"}),tone:"active",icon:"received"};case"DeliveryHanded":return{parts:tT(e,{shipId:t,verb:!0===e.details.onceMore?"took once more":"took"}),tone:"active",icon:"received"};case"DeliveryHandled":return{parts:tT(e,{shipId:t,verb:"handled"}),tone:"ok",icon:"acknowledged"};case"DeliveryNotHandled":return{parts:[...tS(e),(0,w.text)(" was not handled: its turn died twice")],tone:"attention",icon:"undeliverable"};case"DeliveryOverdue":let r,d,l;return{parts:[...tS(e),(0,w.text)(` is overdue: ${(d="number"==typeof(r=e.details.minutes)?`${String(r)} min`:"too long","notConfirmed"===(l=tb(e,"clock"))?`handed, not confirmed for ${d}`:`waiting ${d} while its session is ${"busy"===l?"busy":"idle"}`)}, argo told`)],tone:"attention",icon:"undeliverable"};case"DeliveryAcknowledged":return{parts:"pong"===tb(e,"answer")?[...tT(e,{shipId:t,verb:"answered"}),(0,w.text)(" with pong")]:tT(e,{shipId:t,verb:"acknowledged"}),tone:"ok",icon:"acknowledged"};case"DeliveryReturned":return{parts:[...tS(e),(0,w.text)(" went back to pending")],tone:"waiting",icon:"returned"};case"DeliveryUndeliverable":return{parts:[...tS(e),(0,w.text)(" became undeliverable")],tone:"attention",icon:"undeliverable"};case"ShipRetired":{let t=e.details.abandonedDeliveries;return{parts:[(0,w.text)("Retired"),...ty(e.actor),(0,w.text)("."),..."number"==typeof t&&t>0?[(0,w.text)(` ${(0,w.counted)(t,{one:"delivery",many:"deliveries"})} abandoned.`)]:[]],tone:"ended",icon:"retired"}}case"DeliveryAbandoned":return{parts:[...tS(e),(0,w.text)(" was abandoned")],tone:"ended",icon:"abandoned"};case"ShipReported":{let t=tb(e,"state")??"in",s=tb(e,"note");return{parts:[(0,w.text)(void 0===s?`Reported ${t}`:`Reported ${t}: ${s}`)],tone:Object.hasOwn(eO.REPORT_TONES,t)?eO.REPORT_TONES[t]:"ended",icon:"reported"}}case"StatementSet":return{parts:[(0,w.text)(`Stated what it is and offers: ${String(e.details.capabilities??"")} capabilities, version ${String(e.details.version??"")}`)],tone:"ended",icon:"reported"};case"TurnReported":{let t=tb(e,"turn");return{parts:[(0,w.text)("busy"===t?"Turn started: busy":"Turn ended: idle")],tone:"busy"===t?"active":"ended",icon:"reported"}}case"ShipRenamed":{let t=tb(e,"from"),s=tb(e,"to");return{parts:[(0,w.text)(void 0===t||void 0===s?"Renamed":`Renamed from ${t} to ${s}`),...ty(e.actor)],tone:"ended",icon:"renamed"}}case"DeliveryDismissed":return{parts:[...tS(e),(0,w.text)(" was dismissed"),...ty(e.actor)],tone:"ended",icon:"dismissed"}}}(e,s),l=tR[d],o=new Date(e.occurredAt),c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":!0,className:(0,p.classNames)("flex size-7 shrink-0 items-center justify-center rounded-md border [&_svg]:size-(--size-icon-sm)",t$[r]),children:(0,t.jsx)(l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(S.Sentence,{parts:i,className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)("time",{dateTime:e.occurredAt,title:(0,b.fullDateTime)(o),className:"text-meta text-muted-foreground tabular-nums",children:(0,b.relativeTime)(o,n)})]})]}),{message:u}=e;return(0,t.jsx)("li",{"data-testid":"ship-timeline-entry","data-type":e.type,className:"border-b border-border last:border-b-0",children:u?(0,t.jsx)("button",{type:"button",className:(0,p.classNames)(tq,"transition-colors duration-(--duration-fast) hover:bg-accent"),onClick:()=>{a(u.id)},children:c}):(0,t.jsx)("div",{className:tq,children:c})})}function tA({shipId:e,entries:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:4,label:"Loading the timeline"}):"error"===n?(0,t.jsxs)("div",{"data-testid":"ship-timeline",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3",children:[(0,t.jsx)(k.InlineError,{title:"Couldn’t load the timeline",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(y.Button,{size:"sm",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),onClick:a,className:"self-start",children:"Try again"}):null]}):(0,t.jsxs)("div",{"data-testid":"ship-timeline",className:"overflow-hidden rounded-lg border border-border bg-card",children:[(0,t.jsx)("ol",{"aria-label":"Timeline",children:s.map(s=>(0,t.jsx)(tI,{entry:s,shipId:e,now:i,onOpenMessage:r},s.id))}),s.length<=1?(0,t.jsx)("p",{className:"border-t border-border px-3.5 py-3 text-center text-meta text-muted-foreground first:border-t-0",children:"Nothing else yet. Claims, releases and messages appear here as they happen."}):null]})}var tD=e.i(37631),tL=e.i(87964),tO=e.i(46929),tz=e.i(18423),tP=e.i(96676),tM=e.i(9176),tB=e.i(78485),tE=e.i(53573),tF=e.i(85595),tH=e.i(28459),t_=e.i(14732);function tU({party:e}){let s=e.name===w.OPERATOR_NAME;return(0,t.jsx)(eB.ShipName,{name:e.name,shipId:e.id,size:"meta",isOperator:s,isSuffixShown:!s})}function tV({delivery:e}){let{sender:s,recipient:n}=e.message;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-meta text-muted-foreground",children:[(0,t.jsx)(tU,{party:s}),(0,t.jsx)("span",{"aria-hidden":!0,children:"→"}),(0,t.jsx)("span",{className:"sr-only",children:"to"}),"ship"===n.kind?(0,t.jsx)(tU,{party:n.ship}):(0,t.jsxs)("span",{children:["any ship of type ",n.type]})]})}function tW({delivery:e}){let{payload:s,contentType:n}=e.message;return(0,t.jsx)("span",{className:(0,p.classNames)("block min-w-0 truncate text-foreground",(0,x.isJson)(n)?"font-mono text-id":"text-body max-sm:text-body-touch"),title:s,children:s.split("\n")[0]})}function tK(e){return(0,tH.attentionReason)(e)}function tG(e){var t;return`the message from ${e.message.sender.name} to ${"ship"===(t=e.message.recipient).kind?t.ship.name:`any ship of type ${t.type}`}`}function tY({delivery:e,onResend:s,onDismiss:n,pendingIds:a,layout:i}){let r=a.has(e.deliveryId),d="phone"===i;if(void 0===s&&void 0===n)return null;let l=void 0!==s&&(0,tH.canResend)(e)?(0,t.jsx)(y.Button,{size:d?"touch":"sm",variant:d?"primary":"secondary",icon:(0,t.jsx)(h.RotateCw,{"aria-hidden":!0}),isLoading:r,"data-testid":"attention-resend","aria-label":`Resend ${tG(e)}`,onClick:()=>{s(e.deliveryId)},className:d?"flex-1":void 0,children:"Resend"}):null,o=void 0===n?null:(0,t.jsx)(y.Button,{size:d?"touch":"sm",variant:d?"secondary":"ghost",disabled:r,"data-testid":"attention-dismiss","aria-label":`Dismiss ${tG(e)}`,onClick:()=>{n(e.deliveryId)},className:d?"flex-1":void 0,children:"Dismiss"});return d?(0,t.jsxs)("div",{className:"flex gap-2 pt-1",children:[o,l]}):(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[l,o]})}function tJ({deliveries:e,onOpen:s,now:n,...a}){return(0,t.jsxs)("div",{className:"flex flex-col gap-2 max-sm:hidden",children:[(0,t.jsxs)(t_.Table,{"aria-label":"Undeliverable and not handled deliveries",children:[(0,t.jsx)(t_.TableHeader,{children:(0,t.jsxs)(t_.TableRow,{children:[(0,t.jsx)(t_.TableHead,{children:"State"}),(0,t.jsx)(t_.TableHead,{children:"Message"}),(0,t.jsx)(t_.TableHead,{children:"Reason"}),(0,t.jsx)(t_.TableHead,{children:"Since"}),(0,t.jsx)(t_.TableHead,{children:"Actions"})]})}),(0,t.jsx)(t_.TableBody,{children:e.map(e=>{let i=new Date(e.since);return(0,t.jsxs)(t_.TableRow,{"data-testid":"attention-row","data-delivery-id":e.deliveryId,children:[(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsx)(T.StatusBadge,{status:e.state})}),(0,t.jsx)(t_.TableCell,{className:"max-w-96 align-top",children:(0,t.jsxs)("button",{type:"button","aria-label":`Open ${tG(e)}`,onClick:()=>{s(e)},className:"flex w-full min-w-0 flex-col gap-0.5 rounded-xs text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,t.jsx)(tW,{delivery:e}),(0,t.jsx)(tV,{delivery:e})]})}),(0,t.jsx)(t_.TableCell,{className:"max-w-48 align-top text-meta whitespace-normal text-muted-foreground",children:tK(e)}),(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsxs)("span",{className:"flex flex-col gap-0.5 tabular-nums",children:[(0,t.jsx)("time",{dateTime:e.since,title:(0,b.fullDateTime)(i),className:"text-body text-foreground",children:(0,b.shortDateTime)(i)}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:[(0,b.duration)(i,n)," ago"]})]})}),(0,t.jsx)(t_.TableCell,{className:"align-top",children:(0,t.jsx)(tY,{delivery:e,layout:"table",...a})})]},e.deliveryId)})})]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"Resend creates a new message with the same payload, linked to the original. Dismiss marks the delivery resolved. Abandoned deliveries are not listed here."})]})}function tX({deliveries:e,onOpen:s,now:n,...a}){return(0,t.jsx)("ul",{"aria-label":"Undeliverable and not handled deliveries",className:"flex flex-col gap-3 sm:hidden",children:e.map(e=>{let i=new Date(e.since),r=n.getTime()-i.getTime()<864e5?(0,b.clockTime)(i):(0,b.shortDateTime)(i);return(0,t.jsxs)("li",{"data-testid":"attention-row","data-delivery-id":e.deliveryId,className:"flex flex-col gap-1.5 rounded-lg border border-border bg-card px-3.5 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(T.StatusBadge,{status:e.state}),(0,t.jsxs)("button",{type:"button","aria-label":`Open ${tG(e)}`,onClick:()=>{s(e)},className:"inline-flex items-center gap-1 rounded-xs text-meta text-muted-foreground tabular-nums focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-(--size-icon-sm)",children:[(0,b.duration)(i,n),(0,t.jsx)(eL.ChevronRight,{"aria-hidden":!0})]})]}),(0,t.jsx)(tW,{delivery:e}),(0,t.jsx)(tV,{delivery:e}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:[tK(e)," Since"," ",(0,t.jsx)("time",{dateTime:e.since,title:(0,b.fullDateTime)(i),className:"tabular-nums",children:r}),"."]}),(0,t.jsx)(tY,{delivery:e,layout:"phone",...a})]},e.deliveryId)})})}function tQ({deliveries:e,state:s,onRetry:n,...a}){return"loading"===s?(0,t.jsxs)("div",{"data-slot":"needs-attention-list","data-state":"loading",children:[(0,t.jsx)(C.LoadingSkeleton,{variant:"table",rows:2,label:"Loading Needs attention",className:"max-sm:hidden"}),(0,t.jsx)(C.LoadingSkeleton,{variant:"list",rows:2,label:"Loading Needs attention",className:"sm:hidden"})]}):"error"===s?(0,t.jsx)("div",{"data-slot":"needs-attention-list","data-state":"error","data-testid":"attention-error",children:(0,t.jsx)(k.InlineError,{variant:"page",title:"Couldn’t load Needs attention",description:"This page couldn’t reach the fleet server. Undeliverable deliveries are kept on the server, so nothing is lost.",onRetry:n})}):0===e.length?(0,t.jsx)("div",{"data-slot":"needs-attention-list","data-state":"empty","data-testid":"attention-empty",children:(0,t.jsx)(N.EmptyState,{icon:(0,t.jsx)(tF.CircleCheck,{className:"text-tone-ok-fg"}),title:"Nothing needs your attention",description:"Undeliverable deliveries show up here as soon as they happen."})}):(0,t.jsxs)("div",{"data-slot":"needs-attention-list","data-state":"ready",className:"flex flex-col gap-3",children:[(0,t.jsx)(tJ,{deliveries:e,...a}),(0,t.jsx)(tX,{deliveries:e,...a})]})}function tZ({shipId:e}){let a=(0,s.useRouter)(),i=(0,tP.useNow)(),r=(0,tH.useNeedsAttention)(),d=(0,tH.useResendDelivery)(),l=(0,tH.useDismissDelivery)(),o=(0,I.useAccess)(),[c,u]=(0,n.useState)(new Set),m=(r.data??[]).filter(t=>"notHandled"===t.state&&t.ship.id===e),h=(e,t)=>{u(t=>new Set([...t,e])),t().finally(()=>{u(t=>new Set([...t].filter(t=>t!==e)))})};return 0===m.length?null:(0,t.jsxs)("section",{"aria-labelledby":"ship-not-handled","data-testid":"ship-not-handled",className:"flex flex-col gap-2",children:[(0,t.jsxs)("h2",{id:"ship-not-handled",className:"text-body font-semibold",children:["Not handled (",m.length,")"]}),(0,t.jsx)(tQ,{deliveries:m,state:"ready",onRetry:()=>{r.refetch()},onResend:o.canManage?e=>{let t=(0,tH.deliveryWithId)(m,e);h(e,async()=>{try{await d.mutateAsync({deliveryId:e}),t&&(0,E.showToast)({...(0,tH.resentToast)(t),tone:"success"})}catch(e){(0,E.showToast)({title:"Couldn’t resend the message",description:t0(e),tone:"error"})}})}:void 0,onDismiss:o.canManage?e=>{h(e,async()=>{try{await l.mutateAsync({deliveryId:e}),(0,E.showToast)({...tH.DISMISSED_TOAST,tone:"success"})}catch(e){(0,E.showToast)({title:"Couldn’t dismiss the delivery",description:t0(e),tone:"error"})}})}:void 0,onOpen:t=>{a.replace(`/ships/${e}?tab=messages&message=${t.message.id}`,{scroll:!1})},pendingIds:c,now:i})]})}function t0(e){return e instanceof Error?e.message:"Try again in a moment."}let t1="timeline",t2="messages",t5=(0,q.lazyDialog)(()=>e.A(65030).then(e=>e.MessageSheet),e=>e.isOpen);e.s(["ShipPageFor",0,function({shipId:e,tab:r,messageId:d}){let l=(0,s.useRouter)(),o=(0,tP.useNow)(),c=(0,tM.usePluginShipIds)(),u=(0,tE.useShip)(e),m=(0,tE.useShipTimeline)(e),h=(0,tE.useShipMessages)(e),p=(0,tE.useMessage)(d),x=(0,tE.useShipWay)(e),g=(0,B.useMachines)(),f=(0,tz.useLiveFleet)(),w=(0,tL.useConsoleFrame)(),j=(0,eu.useSquadrons)(),y=(0,I.useAccess)(),[N,k]=(0,n.useState)();(0,tB.useSignInWhenSessionEnds)([u.error,m.error,h.error,p.error,f.error]);let C=t=>{let s,n;l.replace((s=new URLSearchParams,t.tab!==t1&&s.set("tab",t.tab),void 0!==t.messageId&&s.set("message",t.messageId),""===(n=s.toString())?`/ships/${e}`:`/ships/${e}?${n}`),{scroll:!1})},S=e=>{C({tab:r,messageId:e})},T="NOT_FOUND"===(0,tO.trpcErrorCode)(u.error)||null===u.data,R=x.data&&u.data?.kind==="agent"?function(e,t){let{now:s,machines:n=[]}=t;if(null===e.lease)return{lines:[],oldest:null};let{by:a,turn:i}=e.lease,r=0===e.waiting?[{icon:"time",tone:"neutral",text:"Nothing waiting"}]:[];return{lines:[null===a?{icon:"pull",tone:"neutral",text:"Pull: nobody wakes it"}:{...(0,v.holderWordsOf)(a),tone:"neutral"},...function(e,t){if(e?.kind!=="trierarch")return[];let s=t.machines.find(t=>t.shipId===e.trierarch.id);if(!s?.isSilent)return[];let n=null===s.lastSeenAt?"":` since ${(0,b.sinceTime)(new Date(s.lastSeenAt),t.now)}`;return[{icon:"silent",tone:"attention",text:`Trierarch on ${e.trierarch.name} silent${n}`}]}(a,{now:s,machines:n}),...function(e,t){if(null===e)return[];let s=(0,b.sinceTime)(new Date(e.at),t);return"busy"===e.turn?[{icon:"busy",tone:"active",text:`Busy since ${s}`}]:[{icon:"idle",tone:"neutral",text:`Idle since ${s}`}]}(i,s),...r],oldest:function(e,t){let{oldest:s,waiting:n}=e;if(null===s)return null;let{state:a,way:i}=s.delivery,r=[(0,b.relativeTime)(new Date(i.since),t).toLowerCase()];return"handed"===a&&r.push(i.isPulled?"not acknowledged":"not confirmed"),i.overdue&&r.push(`argo told at ${String(i.overdue.minutes)} min`),n>1&&r.push(`oldest of ${String(n)}`),{messageId:s.messageId,status:(0,v.deliveryStatus)({state:a,isPulled:i.isPulled}),isOverdue:null!==i.overdue,text:r.join(" · ")}}(e,s)}}(x.data,{now:o,machines:g.data??[]}):void 0,q=(0,eg.shipsInSquadrons)(j.data??[]).get(e);return(0,t.jsx)(tD.DetailPage,{onCompose:w.onCompose,onSearch:w.onSearch,banner:w.banner,title:u.data?.name??"Ship",parents:q?[{href:"/squadrons",label:"Squadrons"},{href:`/squadrons/${q.squadronId}`,label:q.squadronId}]:[{href:"/",label:"Fleet overview"}],live:f.live,header:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e_,{ship:u.data??void 0,shipId:e,state:T?"not-found":u.data?"ready":"loading",now:o,actions:u.data?(0,t.jsx)(ew.ShipActions,{ship:u.data,compose:i.ComposeMessage,crewLineFlow:ej.NewCrewLineFlow}):void 0,crewRequest:u.data?(0,t.jsx)(ex,{ship:u.data,timeline:m.data??[],now:o}):void 0,labels:u.data?(0,t.jsx)(e7,{ship:u.data}):void 0,isPluginShip:c.has(e),way:R&&x.data?.lease?(0,t.jsx)(eW,{view:R,onOpenMessage:S}):void 0}),T?null:(0,t.jsx)(eb,{shipId:e,now:o}),T?null:(0,t.jsx)(tZ,{shipId:e})]}),sheet:(0,t.jsx)(t5,{message:p.data,messageId:d,state:"NOT_FOUND"===(0,tO.trpcErrorCode)(p.error)?"not-found":p.data?"ready":"loading",isOpen:void 0!==d,now:o,machines:g.data??[],onOpenMessage:S,onOpenChange:e=>{e||C({tab:r})},onReply:y.canSend?e=>{k({messageId:e.id,sender:e.sender})}:void 0}),children:(0,t.jsxs)(t.Fragment,{children:[T?null:(0,t.jsxs)(a.Tabs,{value:r,onValueChange:e=>{C({tab:e===t2?t2:t1,messageId:d})},children:[(0,t.jsxs)(a.TabsList,{variant:"line","aria-label":`${u.data?.name??"Ship"} history`,children:[(0,t.jsx)(a.TabsTrigger,{variant:"line",value:t1,children:"Timeline"}),(0,t.jsx)(a.TabsTrigger,{variant:"line",value:t2,children:"Messages"})]}),(0,t.jsx)(a.TabsContent,{value:t1,className:"pt-4",children:(0,t.jsx)(tA,{shipId:e,entries:m.data??[],state:m.isError?"error":m.data?"ready":"loading",onRetry:()=>{m.refetch()},now:o,onOpenMessage:S})}),(0,t.jsx)(a.TabsContent,{value:t2,className:"pt-4",children:(0,t.jsx)($,{shipId:e,messages:h.data??[],state:h.isError?"error":h.data?"ready":"loading",onRetry:()=>{h.refetch()},now:o,onOpenMessage:S})})]}),(0,t.jsx)(i.ComposeMessage,{isOpen:void 0!==N,onOpenChange:e=>{e||k(void 0)},replyTo:N})]})})}],15860)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67858,s=>{s.v(t=>Promise.all(["static/chunks/20l4-ecv_oo2h.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(59068)))},88207,s=>{s.v(t=>Promise.all(["static/chunks/41sjts3oeho4o.js"].map(t=>s.l(t))).then(()=>t(42211)))},5419,s=>{s.v(t=>Promise.all(["static/chunks/117637vz-8m5h.js"].map(t=>s.l(t))).then(()=>t(4510)))},88138,s=>{s.v(t=>Promise.all(["static/chunks/01ew2ssfbg4fk.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(48287)))},95953,s=>{s.v(t=>Promise.all(["static/chunks/26b3un_8lel5h.js"].map(t=>s.l(t))).then(()=>t(82532)))},26403,s=>{s.v(t=>Promise.all(["static/chunks/3hh1avdkv004-.js"].map(t=>s.l(t))).then(()=>t(54988)))},57993,s=>{s.v(t=>Promise.all(["static/chunks/00i6q5loemcdb.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(75027)))},41585,s=>{s.v(t=>Promise.all(["static/chunks/32eiz8wfxjh13.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(11896)))},65030,s=>{s.v(t=>Promise.all(["static/chunks/18rsibme2venq.js"].map(t=>s.l(t))).then(()=>t(33474)))},23569,s=>{s.v(t=>Promise.all(["static/chunks/1rnej87ue7-0n.js","static/chunks/3-e47olei182t.js"].map(t=>s.l(t))).then(()=>t(9967)))}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67858,s=>{s.v(t=>Promise.all(["static/chunks/420usygo4rcxp.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(59068)))},88207,s=>{s.v(t=>Promise.all(["static/chunks/41sjts3oeho4o.js"].map(t=>s.l(t))).then(()=>t(42211)))},5419,s=>{s.v(t=>Promise.all(["static/chunks/117637vz-8m5h.js"].map(t=>s.l(t))).then(()=>t(4510)))},88138,s=>{s.v(t=>Promise.all(["static/chunks/01ew2ssfbg4fk.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(48287)))},95953,s=>{s.v(t=>Promise.all(["static/chunks/26b3un_8lel5h.js"].map(t=>s.l(t))).then(()=>t(82532)))},26403,s=>{s.v(t=>Promise.all(["static/chunks/3hh1avdkv004-.js"].map(t=>s.l(t))).then(()=>t(54988)))},57993,s=>{s.v(t=>Promise.all(["static/chunks/00i6q5loemcdb.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(75027)))},41585,s=>{s.v(t=>Promise.all(["static/chunks/32eiz8wfxjh13.js","static/chunks/2-ncr8s35g33z.js"].map(t=>s.l(t))).then(()=>t(11896)))},65030,s=>{s.v(t=>Promise.all(["static/chunks/2j2d4nw9_nas6.js"].map(t=>s.l(t))).then(()=>t(33474)))},23569,s=>{s.v(t=>Promise.all(["static/chunks/1rnej87ue7-0n.js","static/chunks/3-e47olei182t.js"].map(t=>s.l(t))).then(()=>t(9967)))}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13260,e=>{"use strict";var t=e.i(43476),s=e.i(7921),r=e.i(22016),a=e.i(18566),n=e.i(15905),i=e.i(67874),l=e.i(17981),d=e.i(88393),o=e.i(29870),c=e.i(66390),u=e.i(75867);let m={argo:"You turn it on or off.",plugin:"The networking plugin turns it off while your rules apply, and on for all-to-all."};function h({rows:e,error:s,onRetry:r,isTurning:a,turnError:n,onViewerReadChange:i}){let x;return x=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the built-in rules",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the built-in rules"}):(0,t.jsx)("ul",{className:"flex flex-col divide-y divide-border",children:e.map(e=>(0,t.jsxs)("li",{"data-testid":"network-built-in-rule",className:"flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-body font-medium","data-testid":"network-built-in-rule-name",children:e.name}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:[e.meaning," ","never"===e.turnedBy?null:m[e.turnedBy]]})]}),"argo"===e.turnedBy?(0,t.jsx)(u.Switch,{checked:e.isOn,disabled:a,"aria-label":`${e.name}: ${e.isOn?"on":"off"}`,"data-testid":"network-built-in-viewer-read",onCheckedChange:e=>{i(e)}}):(0,t.jsx)(c.Badge,{variant:"outline","data-testid":"network-built-in-rule-state",children:"never"===e.turnedBy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Lock,{"aria-hidden":!0}),"Never off"]}):e.isOn?"On":"Off"})]},e.key))}),(0,t.jsxs)("section",{"aria-labelledby":"network-built-in","data-testid":"network-built-in",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-built-in",className:"text-body font-semibold",children:"Built-in rules"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet’s own rules, beside yours and the declared ones. They hold before any rule below."}),x,void 0===n?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t turn the viewer reading",description:n})]})}var x=e.i(68877),p=e.i(22768),g=e.i(71645),f=e.i(37338),b=e.i(95960);let v=[{side:"from",label:"From ships with"},{side:"to",label:"To ships with"}];function y({declared:e,error:s,onRetry:r,context:a}){let n;return n=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the declared rules",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:2,label:"Loading the declared rules"}):0===e.length?(0,t.jsx)(i.EmptyState,{variant:"section",title:"No plugin declares rules."}):(0,t.jsx)("ul",{className:"flex flex-col gap-3",children:e.map(e=>(0,t.jsxs)("li",{"data-testid":"network-declared-plugin",className:"flex flex-col gap-2",children:[(0,t.jsxs)("h3",{className:"text-meta font-medium","data-testid":"network-declared-by",children:["Declared by ",e.declaredBy]}),(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:e.rules.map(e=>(0,t.jsx)("li",{"data-testid":"network-declared-rule",className:"flex flex-col gap-2 rounded-md border border-border p-3 sm:flex-row sm:items-start sm:gap-3",children:v.map(({side:s,label:r})=>(0,t.jsxs)("div",{className:"flex min-w-0 grow basis-0 items-start gap-3",children:["to"===s?(0,t.jsx)("span",{className:"mt-6 shrink-0 text-meta text-muted-foreground","data-testid":"network-declared-rule-verb",children:f.VERB_WORDS[e.verb]}):null,"to"===s?(0,t.jsx)(x.ArrowRight,{"aria-hidden":!0,className:"mt-6 hidden size-(--size-icon) shrink-0 text-muted-foreground sm:block"}):null,(0,t.jsx)(w,{label:r,terms:e[s],context:a,testId:`network-declared-rule-${s}`})]},s))},JSON.stringify(e)))})]},e.shipId))}),(0,t.jsxs)("section",{"aria-labelledby":"network-declared","data-testid":"network-declared",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-declared",className:"text-body font-semibold",children:"Declared by plugins"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"Rules plugins need on the labels they own. The networking plugin adds them to your rules; while every ship may message every ship, they change nothing. Only the plugin changes them, and switching it off withdraws them."}),n]})}function w({label:e,terms:s,context:r,testId:a}){let{chips:n,unknown:i}=(0,f.selectorOf)(s,r);return(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":a,children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.length+i.length===0?(0,t.jsx)("span",{className:"text-body",children:"Every ship"}):null,n.map((e,s)=>(0,t.jsxs)(g.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(b.LabelChip,{chip:e,testId:`${a}-value`,..."string"==typeof e.term?{}:{meaning:f.TERM_MEANINGS[e.term.value]}})]},(0,f.termKeyOf)(e.term))),i.map(e=>(0,t.jsxs)("span",{"data-testid":`${a}-unknown`,title:`${(0,f.termKeyOf)(e)}: no longer in this fleet`,className:"inline-flex h-5.5 items-center gap-1 rounded-sm border border-tone-attention-border bg-tone-attention-bg px-1.5 text-id text-tone-attention-fg [&_svg]:size-3",children:[(0,t.jsx)(p.CircleAlert,{"aria-hidden":!0}),"A removed label"]},(0,f.termKeyOf)(e)))]})]})}var j=e.i(47211),k=e.i(89664),N=e.i(56420);let S={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};S.node;let O=(0,N.default)(S);var R=e.i(90063);function C(e){return e.send.map(e=>e.shipId)}let $=-Math.PI/2,T=2*Math.PI;function E(e){return Math.round(100*e)/100}let A={picked:"picked",reached:"may be messaged",unreached:"out of reach"};function I({ships:e,pickedShipId:s,reachableShipIds:r,reachError:a,onPick:n,onRetry:i}){var d;let o=(d=void 0===s?void 0:{pickedShipId:s,reachableShipIds:void 0===a?r:void 0},e.map((t,s)=>{var r,a;let n=$+T*s/e.length,i=1===e.length;return{ship:t,x:i?50:E(50+38*Math.cos(n)),y:i?50:E(50+38*Math.sin(n)),mark:(r=t.id,void 0===(a=d)?"none":r===a.pickedShipId?"picked":void 0===a.reachableShipIds?"none":a.reachableShipIds.includes(r)?"reached":"unreached")}})),c=o.find(e=>"picked"===e.mark),u=o.filter(e=>"reached"===e.mark);return(0,t.jsxs)("section",{"aria-labelledby":"network-reach","data-testid":"network-reach",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-reach",className:"text-body font-semibold",children:"Reach"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet as it stands now: pick a ship to see which ships the rules let it message. Argo reaches every ship, and every ship reaches argo."}),(0,t.jsxs)("div",{className:"relative flex flex-wrap gap-2 md:mx-auto md:block md:aspect-square md:w-full md:max-w-xl","data-testid":"network-reach-graph",children:[void 0===c?null:(0,t.jsx)("svg",{"aria-hidden":!0,viewBox:"0 0 100 100",preserveAspectRatio:"none",className:"pointer-events-none absolute inset-0 hidden size-full md:block",children:u.map(e=>(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:e.x,y2:e.y,vectorEffect:"non-scaling-stroke",className:"stroke-muted-foreground",strokeWidth:1.5},e.ship.id))}),o.map(e=>(0,t.jsx)(B,{node:e,onPick:()=>{n("picked"===e.mark?void 0:e.ship.id)}},e.ship.id))]}),void 0===a?(0,t.jsx)("p",{className:"text-body",role:"status","data-testid":"network-reach-summary",children:function(e){let t=e.find(e=>"picked"===e.mark);if(void 0===t)return"Pick a ship to see which ships it may message.";let s=e.length-1,r=e.filter(e=>"reached"===e.mark).map(e=>e.ship.name);return e.every(e=>"picked"===e.mark||"none"===e.mark)?0===s?`${t.ship.name} is the only ship of the fleet.`:`Finding the ships ${t.ship.name} may message…`:r.length===s?`${t.ship.name} may message every other ship (${String(s)}).`:0===r.length?`${t.ship.name} may message no other ship.`:`${t.ship.name} may message ${String(r.length)} of ${String(s)} ships: ${r.join(", ")}.`}(o)}):(0,t.jsx)(l.InlineError,{title:"Couldn’t explain this ship’s reach",description:a,onRetry:i})]})}function B({node:e,onPick:s}){let{ship:r,mark:a}=e;return(0,t.jsx)(n.Button,{size:"sm",variant:"secondary","aria-pressed":"picked"===a,"aria-label":"none"===a?r.name:`${r.name}, ${A[a]}`,icon:function(e){switch(e){case"picked":return(0,t.jsx)(O,{"aria-hidden":!0});case"reached":return(0,t.jsx)(k.Check,{"aria-hidden":!0});case"unreached":return(0,t.jsx)(j.Ban,{"aria-hidden":!0});case"none":return}}(a),"data-testid":"network-reach-ship","data-mark":a,style:{left:`${String(e.x)}%`,top:`${String(e.y)}%`},className:(0,R.classNames)("md:absolute md:-translate-x-1/2 md:-translate-y-1/2","picked"===a&&"bg-accent ring-2 ring-ring","unreached"===a&&"opacity-45"),onClick:s,children:r.name})}let P={"block-all":{name:"Block all",meaning:"Only argo and answers to a received message get through."},"open-all":{name:"Open all",meaning:"Every ship may message every ship."},"keep-latest":{name:"Keep the latest rules",meaning:"The rules it supplied last stay in force."}};var M=e.i(12470),z=e.i(91727),D=e.i(46033);function L({declaration:e,options:s,bounds:r,isSaving:a,saveError:i,savedNote:d,onSave:o}){let[c,u]=(0,g.useState)(e.whileUnavailable),[m,h]=(0,g.useState)(String(e.notRespondingAfterSeconds)),x=(0,g.useId)(),p=function(e,t){if(!/^\d+$/.test(e.trim()))return"A whole number of seconds.";let s=Number(e.trim());return s<t.min?`At least ${String(t.min)} seconds.`:s>t.max?`At most ${String(t.max)} seconds.`:void 0}(m,r),f=c!==e.whileUnavailable||m.trim()!==String(e.notRespondingAfterSeconds),b=Object.fromEntries(s.map(e=>[e,P[e].name]));return(0,t.jsxs)("section",{"aria-labelledby":"network-declaration","data-testid":"network-declaration",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-declaration",className:"text-body font-semibold",children:"While the networking plugin does not respond"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet judges the plugin not responding when its ship makes no call for this long, and then applies what you choose here, at every send."}),(0,t.jsxs)("form",{className:"flex flex-col gap-3",onSubmit:e=>{e.preventDefault(),void 0===p&&o({whileUnavailable:c,notRespondingAfterSeconds:Number(m.trim())})},children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"text-body font-medium",children:"What holds"}),(0,t.jsxs)(D.Select,{items:b,value:c,disabled:a,onValueChange:e=>{let t=s.find(t=>t===e);void 0!==t&&u(t)},children:[(0,t.jsx)(D.SelectTrigger,{"aria-label":"What holds while the plugin does not respond","data-testid":"network-declaration-while",className:"h-(--size-control) text-body",children:(0,t.jsx)(D.SelectValue,{})}),(0,t.jsx)(D.SelectContent,{children:s.map(e=>(0,t.jsx)(D.SelectItem,{value:e,children:P[e].name},e))})]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground","data-testid":"network-declaration-meaning",children:P[c].meaning})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(z.Label,{htmlFor:x,children:"Not responding after (seconds)"}),(0,t.jsx)(M.Input,{id:x,inputMode:"numeric",className:"w-40",value:m,disabled:a,"aria-invalid":void 0!==p,"aria-describedby":`${x}-hint`,"data-testid":"network-declaration-seconds",onChange:e=>{h(e.target.value)}}),(0,t.jsx)("p",{id:`${x}-hint`,className:void 0===p?"text-meta text-muted-foreground":"text-meta text-destructive",children:p??`From ${String(r.min)} to ${String(r.max)} seconds.`})]}),(0,t.jsx)("div",{children:(0,t.jsx)(n.Button,{type:"submit",variant:"primary",isLoading:a,disabled:!f||void 0!==p,"data-testid":"network-declaration-save",children:"Save"})})]}),void 0===i?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t save",description:i}),void 0===d||f?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-muted-foreground","data-testid":"network-declaration-note",children:d})]})}var V=e.i(11514),F=e.i(77071),K=e.i(59659),_=e.i(80581),W=e.i(24010),U=e.i(94945),q=e.i(26478),G=e.i(63676),Q=e.i(70703),J=e.i(6734);let H=(0,Q.default)(()=>e.A(67858).then(e=>e.LabelPicker),{loadableGenerated:{modules:[59068]},ssr:!1});function X({label:e,picked:s,owners:a,ownerChoices:i,unknown:l,groups:d,max:o,isDisabled:c,problem:u,onAdd:m,onRemove:h,testId:x,popoverTestId:v}){let[y,w]=(0,g.useState)(!1),[j,k]=(0,g.useState)(!1),N=s.length+a.length+l.length,S=new Set(a.map(e=>(0,f.termKeyOf)(e.term))),O=[...["*","#"].map(e=>({term:{owner:e},text:f.OWNER_TERM_MEANINGS[e]})),...i.map(e=>({term:{owner:e.shipId},text:e.name}))];return(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":x,children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"flex min-h-(--size-control-sm) flex-wrap items-center gap-1.5",children:[0===N?(0,t.jsx)("span",{className:"text-body",children:"Every ship"}):null,s.map((e,s)=>(0,t.jsxs)(g.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(b.LabelChip,{chip:e,testId:`${x}-value`,..."string"==typeof e.term?{}:{meaning:f.TERM_MEANINGS[e.term.value]},...c?{}:{onRemove:()=>{h(e.term)}}})]},(0,f.termKeyOf)(e.term))),a.map((e,r)=>(0,t.jsxs)(g.Fragment,{children:[0===r&&0===s.length?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(Y,{owner:e,testId:`${x}-owner`,...!0===c?{}:{onRemove:()=>{h(e.term)}}})]},(0,f.termKeyOf)(e.term))),l.map(e=>(0,t.jsxs)("span",{"data-testid":`${x}-unknown`,title:`${(0,f.termKeyOf)(e)}: no longer in this fleet`,className:"inline-flex h-5.5 items-center gap-1 rounded-sm border border-tone-attention-border bg-tone-attention-bg px-1.5 text-id text-tone-attention-fg [&_svg]:size-3",children:[(0,t.jsx)(p.CircleAlert,{"aria-hidden":!0}),"string"!=typeof e&&"owner"in e?"A removed owner":"A removed label",!0===c?null:(0,t.jsx)("button",{type:"button","aria-label":"string"!=typeof e&&"owner"in e?"Remove the removed owner":"Remove the removed label",onClick:()=>{h(e)},className:"-mr-1 ml-0.5 inline-flex size-4 items-center justify-center rounded-xs hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring",children:(0,t.jsx)(G.X,{"aria-hidden":!0})})]},(0,f.termKeyOf)(e))),N>=o?null:(0,t.jsxs)(J.Popover,{open:y,onOpenChange:w,children:[(0,t.jsx)(J.PopoverTrigger,{render:(0,t.jsx)(n.Button,{type:"button",variant:"ghost",size:"xs",icon:(0,t.jsx)(F.Plus,{}),disabled:c,"data-testid":`${x}-add`}),children:"Add label"}),(0,t.jsxs)(J.PopoverContent,{align:"start",sideOffset:6,className:"w-80 p-2","data-testid":v,children:[(0,t.jsx)("span",{className:"block px-2 pt-1 pb-2 text-body font-medium",children:e}),(0,t.jsx)(H,{groups:d,pickedValueIds:s.flatMap(e=>"string"==typeof e.term?[e.term]:[]),onPick:e=>{w(!1),m(e)},terms:{picked:s.flatMap(e=>"string"==typeof e.term?[]:[e.term]),onPick:e=>{w(!1),m(e)}}}),(0,t.jsxs)("p",{className:"mt-2 flex items-center justify-between gap-2 border-t border-border px-2 pt-2 text-meta text-muted-foreground",children:["All must hold. * is any value, # the same as the other side.",(0,t.jsx)(r.default,{href:"/labels",className:"font-medium text-foreground hover:underline",children:"Manage labels"})]})]})]}),N>=o?null:(0,t.jsxs)(J.Popover,{open:j,onOpenChange:k,children:[(0,t.jsx)(J.PopoverTrigger,{render:(0,t.jsx)(n.Button,{type:"button",variant:"ghost",size:"xs",icon:(0,t.jsx)(F.Plus,{}),disabled:c,"data-testid":`${x}-owner-add`}),children:"Add owner"}),(0,t.jsxs)(J.PopoverContent,{align:"start",sideOffset:6,className:"w-72 p-2","data-testid":`${v}-owner`,children:[(0,t.jsxs)("span",{className:"block px-2 pt-1 pb-2 text-body font-medium",children:[e," the owner"]}),(0,t.jsx)("ul",{className:"flex flex-col",children:O.map(e=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",disabled:S.has((0,f.termKeyOf)(e.term)),"data-testid":`${x}-owner-option`,onClick:()=>{k(!1),m(e.term)},className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-body hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:text-muted-foreground disabled:hover:bg-transparent",children:[(0,t.jsx)(q.UserRound,{"aria-hidden":!0,className:"size-(--size-icon) shrink-0 text-muted-foreground"}),e.text]})},(0,f.termKeyOf)(e.term)))}),(0,t.jsx)("p",{className:"mt-2 border-t border-border px-2 pt-2 text-meta text-muted-foreground",children:"An owner is argo or a person’s ship. # is the same owner as the other side."})]})]})]}),void 0===u?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-tone-attention-fg","data-testid":`${x}-problem`,children:u}),0===l.length?null:(0,t.jsx)("p",{role:"alert",className:"text-meta text-tone-attention-fg",children:"A label or owner here was removed from the fleet: this side matches no ship until you remove it."})]})}function Y({owner:e,onRemove:s,testId:r}){let{owner:a}=e.term,n="*"===a||"#"===a?`${e.text}. ${f.OWNER_TERM_MEANINGS[a]}`:`${e.text}: ships it owns`;return(0,t.jsxs)("span",{role:"group","aria-label":n,title:n,"data-testid":r,className:"inline-flex h-5.5 max-w-full min-w-0 shrink-0 items-center gap-1 rounded-sm border border-border bg-secondary px-1.5 font-mono text-id whitespace-nowrap text-foreground [&_svg]:size-3 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[(0,t.jsx)(q.UserRound,{"aria-hidden":!0}),(0,t.jsxs)("span",{className:"truncate",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"owner="}),(0,t.jsx)("span",{className:"font-medium",children:e.text.slice(6)})]}),void 0===s?null:(0,t.jsx)("button",{type:"button","aria-label":`Remove ${e.text}`,onClick:s,className:"-mr-1 ml-0.5 inline-flex size-4 items-center justify-center rounded-xs text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:(0,t.jsx)(G.X,{"aria-hidden":!0})})]})}let Z=[{side:"from",label:"From ships with"},{side:"to",label:"To ships with"}],ee=()=>crypto.randomUUID();function et({rules:e,context:s,limits:r,isSaving:a,saveError:i,savedNote:d,onSave:o}){let[c,u]=(0,g.useState)(()=>(0,f.draftOf)(e,ee)),[m,h]=(0,g.useState)(!1),p=(0,_.filterGroupsOf)(s),b=(0,f.ownerChoicesOf)(s),v=(0,f.isChanged)(c,e);return(0,t.jsxs)("section",{"aria-labelledby":"network-rules","data-testid":"network-rules",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-rules",className:"text-body font-semibold",children:"Rules"}),"all-to-all"===c.kind?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-body","data-testid":"network-rules-state",children:"No rules: every ship may send to, read and manage every ship."}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"With rules, a ship may send to, read or manage another only when a rule of that verb or a built-in rule allows it."}),(0,t.jsx)("div",{children:(0,t.jsx)(n.Button,{variant:"primary",icon:(0,t.jsx)(F.Plus,{"aria-hidden":!0}),disabled:a,"data-testid":"network-rules-on",onClick:()=>{u((0,f.setRulesOn)(c,!0))},children:"Set rules"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-body","data-testid":"network-rules-state",children:0===c.rules.length?"No rule allows anything yet: once saved, only the built-in rules hold.":"A ship may send to, read or manage another only when a rule of that verb or a built-in rule allows it."}),0===c.rules.length?null:(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:c.rules.map((e,i)=>(0,t.jsxs)("li",{"data-testid":"network-rule",className:"flex flex-col gap-2 rounded-md border border-border p-3 sm:flex-row sm:items-start sm:gap-3",children:[Z.map(({side:n,label:l})=>{let d,o=(0,f.selectorOf)(e[n],s);return(0,t.jsxs)("div",{className:"flex min-w-0 grow basis-0 items-start gap-3",children:["to"===n?(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"Verb"}),(0,t.jsxs)(D.Select,{items:f.VERB_WORDS,value:e.verb,disabled:a,onValueChange:t=>{V.NETWORK_VERBS.some(e=>e===t)&&u((0,f.setVerb)(c,{rule:e.key,verb:t}))},children:[(0,t.jsx)(D.SelectTrigger,{"aria-label":`Verb of rule ${String(i+1)}`,"data-testid":"network-rule-verb",size:"sm",children:(0,t.jsx)(D.SelectValue,{})}),(0,t.jsx)(D.SelectContent,{children:V.NETWORK_VERBS.map(e=>(0,t.jsx)(D.SelectItem,{value:e,children:f.VERB_WORDS[e]},e))})]})]}):null,"to"===n?(0,t.jsx)(x.ArrowRight,{"aria-hidden":!0,className:"mt-6 hidden size-(--size-icon) shrink-0 text-muted-foreground sm:block"}):null,(0,t.jsx)(X,{label:l,picked:o.chips,owners:o.owners,ownerChoices:b,unknown:o.unknown,groups:p,max:r.selectorMax,isDisabled:a,...void 0===(d=(0,f.sameValueProblemOf)(e,{side:n,context:s}))?{}:{problem:d},testId:`network-rule-${n}`,popoverTestId:"network-rule-popover",onAdd:t=>{u((0,f.addTerm)(c,{rule:e.key,side:n,term:t,limits:r}))},onRemove:t=>{u((0,f.removeTerm)(c,{rule:e.key,side:n,term:t}))}})]},n)}),(0,t.jsx)(n.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(K.Trash2,{"aria-hidden":!0}),disabled:a,"aria-label":`Remove rule ${String(i+1)}`,"data-testid":"network-rule-remove",onClick:()=>{u((0,f.removeRule)(c,e.key))}})]},e.key))}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.rules.length>=r.rulesMax?null:(0,t.jsx)(n.Button,{size:"sm",icon:(0,t.jsx)(F.Plus,{"aria-hidden":!0}),disabled:a,"data-testid":"network-rules-add",onClick:()=>{u((0,f.addRule)(c,{newKey:ee,limits:r}))},children:"Add rule"}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground tabular-nums","data-testid":"network-rules-count",children:[c.rules.length," of ",r.rulesMax," rules"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3",children:[(0,t.jsx)(n.Button,{variant:"primary",isLoading:a,disabled:!v||(0,f.hasSameValueOnOneSide)(c),"data-testid":"network-rules-save",onClick:()=>{o((0,f.rulesOf)(c))},children:"Save rules"}),v?(0,t.jsx)(n.Button,{disabled:a,"data-testid":"network-rules-discard",onClick:()=>{u((0,f.draftOf)(e,ee))},children:"Discard changes"}):null,(0,t.jsx)(n.Button,{variant:"ghost",className:"ml-auto",disabled:a,"data-testid":"network-rules-off",onClick:()=>{null===e?u((0,f.setRulesOn)(c,!1)):h(!0)},children:"Remove all rules"})]})]}),void 0===i?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t save the rules",description:i}),void 0===d||v?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-muted-foreground","data-testid":"network-rules-note",children:d}),(0,t.jsx)(W.AlertDialog,{open:m,onOpenChange:e=>{e||a||h(!1)},children:(0,t.jsxs)(W.AlertDialogContent,{"data-testid":"network-rules-off-dialog",className:U.dialogSurface.phoneSheet,children:[(0,t.jsxs)(W.AlertDialogHeader,{children:[(0,t.jsx)(W.AlertDialogTitle,{children:"Remove all rules?"}),(0,t.jsx)(W.AlertDialogDescription,{children:"Every ship may send to, read and manage every ship again from now on. The rules are gone: to have them back, set them again."})]}),(0,t.jsxs)(W.AlertDialogFooter,{children:[(0,t.jsx)(W.AlertDialogClose,{render:(0,t.jsx)(n.Button,{disabled:a}),children:"Cancel"}),(0,t.jsx)(n.Button,{variant:"destructive",isLoading:a,"data-testid":"network-rules-off-confirm",onClick:()=>{h(!1),o(null)},children:"Remove all rules"})]})]})})]})}var es=e.i(49635);function er({refusals:e,error:s,onRetry:r,context:a,now:n}){let o;return o=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the refusals",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the refusals"}):0===e.length?(0,t.jsx)(i.EmptyState,{variant:"section",title:"No send has been refused."}):(0,t.jsx)("ol",{className:"flex flex-col gap-2","data-testid":"network-refusals-list",children:e.map(e=>(0,t.jsx)(ea,{refusal:e,context:a,now:n},e.id))}),(0,t.jsxs)("section",{"aria-labelledby":"network-refusals","data-testid":"network-refusals",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-refusals",className:"text-body font-semibold",children:"Refusals"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The sends the rules refused, newest first, with both ships’ labels as they were then. The sender was told only that its send was refused."}),o]})}function ea({refusal:e,context:s,now:r}){let a,n=new Date(e.at),{recipient:i}=e,l="ship"===i.kind?[i.ship]:i.ships;return(0,t.jsxs)("li",{"data-testid":"network-refusal",className:"flex flex-col gap-2 rounded-md border border-border px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5",children:[(0,t.jsx)("p",{className:"text-body font-medium",children:function(e){let{sender:t,recipient:s}=e;switch(s.kind){case"ship":return`${t.name} tried to message ${s.ship.name}.`;case"type":return`${t.name} tried to message the type ${s.type}: ${(0,_.listed)(s.ships.map(e=>e.name))}.`}}(e)}),(0,t.jsx)("time",{dateTime:e.at,title:(0,es.fullDateTime)(n),className:"text-meta text-muted-foreground tabular-nums",children:(0,es.relativeTime)(n,r)})]}),(0,t.jsxs)("dl",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(en,{side:"From",ship:e.sender,context:s}),l.map(e=>(0,t.jsx)(en,{side:"To",ship:e,context:s},e.id))]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:(a=`Refused by network settings version ${String(e.settingsVersion)}`,null===e.whilePluginUnavailable?`${a}.`:`${a} while the networking plugin was not responding: ${P[e.whilePluginUnavailable].name}.`)})]})}function en({side:e,ship:s,context:r}){let a=(0,_.chipsOf)(s,r);return(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[(0,t.jsxs)("dt",{className:"text-meta text-muted-foreground",children:[e," ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:s.name})]}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1",children:0===a.length?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"No labels"}):a.map(e=>(0,t.jsx)(b.LabelChip,{chip:e,testId:"network-refusal-label"},e.valueId))})]})}var ei=e.i(77821),el=e.i(87964),ed=e.i(90262),eo=e.i(25242),ec=e.i(5387),eu=e.i(18423),em=e.i(28459),eh=e.i(46806),ex=e.i(96676),ep=e.i(3979),eg=e.i(54616),ef=e.i(66027),eb=e.i(12598),ev=e.i(27702);let ey={send:"Every ship may send to every ship.",read:"Every ship may read every ship.",manage:"Every ship may manage every ship."};function ew(e){switch(e.rule){case"argo":return{key:e.rule,name:"argo",meaning:"argo sends to, reads and manages every ship, and every ship reaches argo.",isOn:e.isOn,turnedBy:"never"};case"owner":return{key:e.rule,name:"Owner",meaning:"A ship’s owner sends to, reads and manages the ships it owns.",isOn:e.isOn,turnedBy:"never"};case"answer":return{key:e.rule,name:"Answer",meaning:"A ship may always answer the sender of a message it received.",isOn:e.isOn,turnedBy:"never"};case"viewerRead":return{key:e.rule,name:"Viewer reads",meaning:"The viewer reads every ship.",isOn:e.isOn,turnedBy:"argo"};case"open":return{key:`open-${e.verb}`,name:`Open for ${e.verb}`,meaning:ey[e.verb],isOn:e.isOn,turnedBy:"plugin"}}}var ej=e.i(19273),ek=e.i(78485);e.s(["NetworkPageFor",0,function({pickedShipId:e}){var o,c;let u,m,x,p,g,b,v,w,j=(0,a.useRouter)(),k=(0,ex.useNow)(),N=(0,el.useConsoleFrame)(),S=(0,em.useNeedsAttention)(),O=(0,eu.useLiveFleet)(),R=(0,ed.useAccess)(),$=(0,ep.usePluginNav)(),T=(0,eh.useHasNetwork)(),E=(0,eh.useNetwork)(),A=(0,ec.useLabelContext)(),B=(0,ec.useFleetSnapshot)(),P=(o=T?e:void 0,m=(0,ev.useTRPC)(),(0,ef.useQuery)({...m.fleet.explainReach.queryOptions(void 0===o?ej.skipToken:{fromShipId:o}),select:C})),M=(x=(0,ev.useTRPC)(),(0,ef.useQuery)(x.fleet.reachRefusals.queryOptions(void 0,{enabled:T}))),z=(p=(0,ev.useTRPC)(),(0,ef.useQuery)(p.fleet.declaredNetworkRules.queryOptions(void 0,{enabled:T}))),D=(g=(0,ev.useTRPC)(),(0,ef.useQuery)(g.fleet.builtInRules.queryOptions(void 0,{enabled:T}))),V=(b=(0,ev.useTRPC)(),v=(0,eb.useQueryClient)(),{setViewerRead:e=>{w.mutate({rule:"viewerRead",isOn:e})},isPending:(w=(0,eg.useMutation)(b.fleet.setBuiltInRule.mutationOptions({onSuccess:()=>v.invalidateQueries({queryKey:b.fleet.builtInRules.queryKey()})}))).isPending,error:w.error?.message}),F=(0,eh.useSaveNetworkRules)(),K=(0,eh.useSaveNetworkDeclaration)(),{networkRulesMax:_,shipLabelsMax:W,whileUnavailable:U,notRespondingAfterMinSeconds:q,notRespondingAfterMaxSeconds:G}=(0,eo.useConsoleConstants)();if((0,ek.useSignInWhenSessionEnds)([S.error,O.error]),T)if(E.isError)u=(0,t.jsx)(l.InlineError,{title:"Couldn’t read the network",description:E.error.message,onRetry:()=>{E.refetch()}});else if(void 0===E.data||void 0===A||void 0===B.data)u=(0,t.jsx)(d.LoadingSkeleton,{variant:"detail",rows:4,label:"Loading the network"});else{let s;u=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h,{rows:void 0===D.data?void 0:D.data.map(ew),error:D.error?.message,onRetry:()=>{D.refetch()},isTurning:V.isPending,turnError:V.error,onViewerReadChange:V.setViewerRead}),(0,t.jsx)(et,{rules:E.data.rules,context:A,limits:{rulesMax:_,selectorMax:W},isSaving:F.isPending,saveError:F.error?.message,savedNote:void 0===F.data?void 0:(0,f.supplyNote)(F.data.supply),onSave:e=>{F.mutate(e)}},JSON.stringify(E.data.rules)),(0,t.jsx)(y,{declared:void 0===z.data?void 0:(c=z.data,s=new Map(B.data.map(e=>[e.id,e.name])),c.filter(({rules:e})=>e.length>0).map(({shipId:e,rules:t})=>({shipId:e,declaredBy:s.get(e)??e,rules:t})).sort((e,t)=>e.declaredBy.localeCompare(t.declaredBy))),error:z.error?.message,onRetry:()=>{z.refetch()},context:A}),(0,t.jsx)(L,{declaration:E.data.declaration,options:U,bounds:{min:q,max:G},isSaving:K.isPending,saveError:K.error?.message,savedNote:void 0===K.data?void 0:function(e){switch(e){case"supplied":return"Saved. The networking plugin registered again with it.";case"waiting":return"Saved. The fleet does not answer yet: the networking plugin registers again with it as soon as it does.";case"not-connected":case"unregistered":return"Saved."}}(K.data.supply),onSave:e=>{K.mutate(e)}},JSON.stringify(E.data.declaration)),(0,t.jsx)(I,{ships:B.data.filter(e=>"retired"!==e.status&&"viewer"!==e.kind).map(e=>({id:e.id,name:e.name,isOperator:"operator"===e.kind})).sort((e,t)=>Number(t.isOperator)-Number(e.isOperator)||e.name.localeCompare(t.name)),pickedShipId:e,reachableShipIds:P.data,reachError:P.error?.message,onPick:e=>{j.replace(void 0===e?"/network":`/network?reach=${e}`,{scroll:!1})},onRetry:()=>{P.refetch()}}),(0,t.jsx)(er,{refusals:M.data,error:M.error?.message,onRetry:()=>{M.refetch()},context:A,now:k})]})}else u=(0,t.jsx)(i.EmptyState,{icon:(0,t.jsx)(s.Network,{"aria-hidden":!0}),title:R.canEditNetwork?"The networking plugin is not connected":"Only argo sees the network rules",description:R.canEditNetwork?"Connect it in Settings. Until it supplies rules, every ship may message every ship.":void 0,action:R.canEditNetwork&&$.hasSettings?(0,t.jsx)(n.Button,{nativeButton:!1,render:(0,t.jsx)(r.default,{href:"/settings"}),"data-testid":"network-open-settings",children:"Open Settings"}):void 0});return(0,t.jsx)(ei.ListPage,{...N,title:"Network",description:"Who may send to, read or manage whom. The networking plugin supplies these rules to the fleet, which checks them on every send. Only argo sees this page.",live:O.live,children:u})}],13260)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13260,e=>{"use strict";var t=e.i(43476),s=e.i(7921),r=e.i(22016),a=e.i(18566),n=e.i(15905),i=e.i(67874),l=e.i(17981),d=e.i(88393),o=e.i(29870),c=e.i(66390),u=e.i(75867);let m={argo:"You turn it on or off.",plugin:"The networking plugin turns it off while your rules apply, and on for all-to-all."};function h({rows:e,error:s,onRetry:r,isTurning:a,turnError:n,onViewerReadChange:i}){let x;return x=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the built-in rules",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the built-in rules"}):(0,t.jsx)("ul",{className:"flex flex-col divide-y divide-border",children:e.map(e=>(0,t.jsxs)("li",{"data-testid":"network-built-in-rule",className:"flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-body font-medium","data-testid":"network-built-in-rule-name",children:e.name}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:[e.meaning," ","never"===e.turnedBy?null:m[e.turnedBy]]})]}),"argo"===e.turnedBy?(0,t.jsx)(u.Switch,{checked:e.isOn,disabled:a,"aria-label":`${e.name}: ${e.isOn?"on":"off"}`,"data-testid":"network-built-in-viewer-read",onCheckedChange:e=>{i(e)}}):(0,t.jsx)(c.Badge,{variant:"outline","data-testid":"network-built-in-rule-state",children:"never"===e.turnedBy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Lock,{"aria-hidden":!0}),"Never off"]}):e.isOn?"On":"Off"})]},e.key))}),(0,t.jsxs)("section",{"aria-labelledby":"network-built-in","data-testid":"network-built-in",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-built-in",className:"text-body font-semibold",children:"Built-in rules"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet’s own rules, beside yours and the declared ones. They hold before any rule below."}),x,void 0===n?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t turn the viewer reading",description:n})]})}var x=e.i(68877),p=e.i(22768),g=e.i(71645),f=e.i(37338),v=e.i(95960);let b=[{side:"from",label:"From ships with"},{side:"to",label:"To ships with"}];function y({declared:e,error:s,onRetry:r,context:a}){let n;return n=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the declared rules",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:2,label:"Loading the declared rules"}):0===e.length?(0,t.jsx)(i.EmptyState,{variant:"section",title:"No plugin declares rules."}):(0,t.jsx)("ul",{className:"flex flex-col gap-3",children:e.map(e=>(0,t.jsxs)("li",{"data-testid":"network-declared-plugin",className:"flex flex-col gap-2",children:[(0,t.jsxs)("h3",{className:"text-meta font-medium","data-testid":"network-declared-by",children:["Declared by ",e.declaredBy]}),(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:e.rules.map(e=>(0,t.jsx)("li",{"data-testid":"network-declared-rule",className:"flex flex-col gap-2 rounded-md border border-border p-3 sm:flex-row sm:items-start sm:gap-3",children:b.map(({side:s,label:r})=>(0,t.jsxs)("div",{className:"flex min-w-0 grow basis-0 items-start gap-3",children:["to"===s?(0,t.jsx)("span",{className:"mt-6 shrink-0 text-meta text-muted-foreground","data-testid":"network-declared-rule-verb",children:f.VERB_WORDS[e.verb]}):null,"to"===s?(0,t.jsx)(x.ArrowRight,{"aria-hidden":!0,className:"mt-6 hidden size-(--size-icon) shrink-0 text-muted-foreground sm:block"}):null,(0,t.jsx)(w,{label:r,terms:e[s],context:a,testId:`network-declared-rule-${s}`})]},s))},JSON.stringify(e)))})]},e.shipId))}),(0,t.jsxs)("section",{"aria-labelledby":"network-declared","data-testid":"network-declared",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-declared",className:"text-body font-semibold",children:"Declared by plugins"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"Rules plugins need on the labels they own. The networking plugin adds them to your rules; while every ship may message every ship, they change nothing. Only the plugin changes them, and switching it off withdraws them."}),n]})}function w({label:e,terms:s,context:r,testId:a}){let{chips:n,unknown:i}=(0,f.selectorOf)(s,r);return(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":a,children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.length+i.length===0?(0,t.jsx)("span",{className:"text-body",children:"Every ship"}):null,n.map((e,s)=>(0,t.jsxs)(g.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(v.LabelChip,{chip:e,testId:`${a}-value`,..."string"==typeof e.term?{}:{meaning:f.TERM_MEANINGS[e.term.value]}})]},(0,f.termKeyOf)(e.term))),i.map(e=>(0,t.jsxs)("span",{"data-testid":`${a}-unknown`,title:`${(0,f.termKeyOf)(e)}: no longer in this fleet`,className:"inline-flex h-5.5 items-center gap-1 rounded-sm border border-tone-attention-border bg-tone-attention-bg px-1.5 text-id text-tone-attention-fg [&_svg]:size-3",children:[(0,t.jsx)(p.CircleAlert,{"aria-hidden":!0}),"A removed label"]},(0,f.termKeyOf)(e)))]})]})}var j=e.i(47211),k=e.i(89664),N=e.i(56420);let S={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};S.node;let O=(0,N.default)(S);var R=e.i(90063);function C(e){return e.send.map(e=>e.shipId)}let $=-Math.PI/2,T=2*Math.PI;function E(e){return Math.round(100*e)/100}let A={picked:"picked",reached:"may be messaged",unreached:"out of reach"};function I({ships:e,pickedShipId:s,reachableShipIds:r,reachError:a,onPick:n,onRetry:i}){var d;let o=(d=void 0===s?void 0:{pickedShipId:s,reachableShipIds:void 0===a?r:void 0},e.map((t,s)=>{var r,a;let n=$+T*s/e.length,i=1===e.length;return{ship:t,x:i?50:E(50+38*Math.cos(n)),y:i?50:E(50+38*Math.sin(n)),mark:(r=t.id,void 0===(a=d)?"none":r===a.pickedShipId?"picked":void 0===a.reachableShipIds?"none":a.reachableShipIds.includes(r)?"reached":"unreached")}})),c=o.find(e=>"picked"===e.mark),u=o.filter(e=>"reached"===e.mark);return(0,t.jsxs)("section",{"aria-labelledby":"network-reach","data-testid":"network-reach",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-reach",className:"text-body font-semibold",children:"Reach"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet as it stands now: pick a ship to see which ships the rules let it message. Argo reaches every ship, and every ship reaches argo."}),(0,t.jsxs)("div",{className:"relative flex flex-wrap gap-2 md:mx-auto md:block md:aspect-square md:w-full md:max-w-xl","data-testid":"network-reach-graph",children:[void 0===c?null:(0,t.jsx)("svg",{"aria-hidden":!0,viewBox:"0 0 100 100",preserveAspectRatio:"none",className:"pointer-events-none absolute inset-0 hidden size-full md:block",children:u.map(e=>(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:e.x,y2:e.y,vectorEffect:"non-scaling-stroke",className:"stroke-muted-foreground",strokeWidth:1.5},e.ship.id))}),o.map(e=>(0,t.jsx)(B,{node:e,onPick:()=>{n("picked"===e.mark?void 0:e.ship.id)}},e.ship.id))]}),void 0===a?(0,t.jsx)("p",{className:"text-body",role:"status","data-testid":"network-reach-summary",children:function(e){let t=e.find(e=>"picked"===e.mark);if(void 0===t)return"Pick a ship to see which ships it may message.";let s=e.length-1,r=e.filter(e=>"reached"===e.mark).map(e=>e.ship.name);return e.every(e=>"picked"===e.mark||"none"===e.mark)?0===s?`${t.ship.name} is the only ship of the fleet.`:`Finding the ships ${t.ship.name} may message…`:r.length===s?`${t.ship.name} may message every other ship (${String(s)}).`:0===r.length?`${t.ship.name} may message no other ship.`:`${t.ship.name} may message ${String(r.length)} of ${String(s)} ships: ${r.join(", ")}.`}(o)}):(0,t.jsx)(l.InlineError,{title:"Couldn’t explain this ship’s reach",description:a,onRetry:i})]})}function B({node:e,onPick:s}){let{ship:r,mark:a}=e;return(0,t.jsx)(n.Button,{size:"sm",variant:"secondary","aria-pressed":"picked"===a,"aria-label":"none"===a?r.name:`${r.name}, ${A[a]}`,icon:function(e){switch(e){case"picked":return(0,t.jsx)(O,{"aria-hidden":!0});case"reached":return(0,t.jsx)(k.Check,{"aria-hidden":!0});case"unreached":return(0,t.jsx)(j.Ban,{"aria-hidden":!0});case"none":return}}(a),"data-testid":"network-reach-ship","data-mark":a,style:{left:`${String(e.x)}%`,top:`${String(e.y)}%`},className:(0,R.classNames)("md:absolute md:-translate-x-1/2 md:-translate-y-1/2","picked"===a&&"bg-accent ring-2 ring-ring","unreached"===a&&"opacity-45"),onClick:s,children:r.name})}let P={"block-all":{name:"Block all",meaning:"Only argo and answers to a received message get through."},"open-all":{name:"Open all",meaning:"Every ship may message every ship."},"keep-latest":{name:"Keep the latest rules",meaning:"The rules it supplied last stay in force."}};var M=e.i(12470),z=e.i(91727),D=e.i(46033);function L({declaration:e,options:s,bounds:r,isSaving:a,saveError:i,savedNote:d,onSave:o}){let[c,u]=(0,g.useState)(e.whileUnavailable),[m,h]=(0,g.useState)(String(e.notRespondingAfterSeconds)),x=(0,g.useId)(),p=function(e,t){if(!/^\d+$/.test(e.trim()))return"A whole number of seconds.";let s=Number(e.trim());return s<t.min?`At least ${String(t.min)} seconds.`:s>t.max?`At most ${String(t.max)} seconds.`:void 0}(m,r),f=c!==e.whileUnavailable||m.trim()!==String(e.notRespondingAfterSeconds),v=Object.fromEntries(s.map(e=>[e,P[e].name]));return(0,t.jsxs)("section",{"aria-labelledby":"network-declaration","data-testid":"network-declaration",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-declaration",className:"text-body font-semibold",children:"While the networking plugin does not respond"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The fleet judges the plugin not responding when its ship makes no call for this long, and then applies what you choose here, at every send."}),(0,t.jsxs)("form",{className:"flex flex-col gap-3",onSubmit:e=>{e.preventDefault(),void 0===p&&o({whileUnavailable:c,notRespondingAfterSeconds:Number(m.trim())})},children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"text-body font-medium",children:"What holds"}),(0,t.jsxs)(D.Select,{items:v,value:c,disabled:a,onValueChange:e=>{let t=s.find(t=>t===e);void 0!==t&&u(t)},children:[(0,t.jsx)(D.SelectTrigger,{"aria-label":"What holds while the plugin does not respond","data-testid":"network-declaration-while",className:"h-(--size-control) text-body",children:(0,t.jsx)(D.SelectValue,{})}),(0,t.jsx)(D.SelectContent,{children:s.map(e=>(0,t.jsx)(D.SelectItem,{value:e,children:P[e].name},e))})]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground","data-testid":"network-declaration-meaning",children:P[c].meaning})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(z.Label,{htmlFor:x,children:"Not responding after (seconds)"}),(0,t.jsx)(M.Input,{id:x,inputMode:"numeric",className:"w-40",value:m,disabled:a,"aria-invalid":void 0!==p,"aria-describedby":`${x}-hint`,"data-testid":"network-declaration-seconds",onChange:e=>{h(e.target.value)}}),(0,t.jsx)("p",{id:`${x}-hint`,className:void 0===p?"text-meta text-muted-foreground":"text-meta text-destructive",children:p??`From ${String(r.min)} to ${String(r.max)} seconds.`})]}),(0,t.jsx)("div",{children:(0,t.jsx)(n.Button,{type:"submit",variant:"primary",isLoading:a,disabled:!f||void 0!==p,"data-testid":"network-declaration-save",children:"Save"})})]}),void 0===i?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t save",description:i}),void 0===d||f?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-muted-foreground","data-testid":"network-declaration-note",children:d})]})}var V=e.i(11514),F=e.i(77071),K=e.i(59659),_=e.i(80581),W=e.i(24010),U=e.i(94945),q=e.i(26478),G=e.i(63676),Q=e.i(70703),J=e.i(6734);let H=(0,Q.default)(()=>e.A(67858).then(e=>e.LabelPicker),{loadableGenerated:{modules:[59068]},ssr:!1});function X({label:e,picked:s,owners:a,ownerChoices:i,unknown:l,groups:d,max:o,isDisabled:c,problem:u,onAdd:m,onRemove:h,testId:x,popoverTestId:b}){let[y,w]=(0,g.useState)(!1),[j,k]=(0,g.useState)(!1),N=s.length+a.length+l.length,S=new Set(a.map(e=>(0,f.termKeyOf)(e.term))),O=[...["*","#"].map(e=>({term:{owner:e},text:f.OWNER_TERM_MEANINGS[e]})),...i.map(e=>({term:{owner:e.shipId},text:e.name}))];return(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":x,children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e}),(0,t.jsxs)("div",{className:"flex min-h-(--size-control-sm) flex-wrap items-center gap-1.5",children:[0===N?(0,t.jsx)("span",{className:"text-body",children:"Every ship"}):null,s.map((e,s)=>(0,t.jsxs)(g.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(v.LabelChip,{chip:e,testId:`${x}-value`,..."string"==typeof e.term?{}:{meaning:f.TERM_MEANINGS[e.term.value]},...c?{}:{onRemove:()=>{h(e.term)}}})]},(0,f.termKeyOf)(e.term))),a.map((e,r)=>(0,t.jsxs)(g.Fragment,{children:[0===r&&0===s.length?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(Y,{owner:e,testId:`${x}-owner`,...!0===c?{}:{onRemove:()=>{h(e.term)}}})]},(0,f.termKeyOf)(e.term))),l.map(e=>(0,t.jsxs)("span",{"data-testid":`${x}-unknown`,title:`${(0,f.termKeyOf)(e)}: no longer in this fleet`,className:"inline-flex h-5.5 items-center gap-1 rounded-sm border border-tone-attention-border bg-tone-attention-bg px-1.5 text-id text-tone-attention-fg [&_svg]:size-3",children:[(0,t.jsx)(p.CircleAlert,{"aria-hidden":!0}),"string"!=typeof e&&"owner"in e?"A removed owner":"A removed label",!0===c?null:(0,t.jsx)("button",{type:"button","aria-label":"string"!=typeof e&&"owner"in e?"Remove the removed owner":"Remove the removed label",onClick:()=>{h(e)},className:"-mr-1 ml-0.5 inline-flex size-4 items-center justify-center rounded-xs hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring",children:(0,t.jsx)(G.X,{"aria-hidden":!0})})]},(0,f.termKeyOf)(e))),N>=o?null:(0,t.jsxs)(J.Popover,{open:y,onOpenChange:w,children:[(0,t.jsx)(J.PopoverTrigger,{render:(0,t.jsx)(n.Button,{type:"button",variant:"ghost",size:"xs",icon:(0,t.jsx)(F.Plus,{}),disabled:c,"data-testid":`${x}-add`}),children:"Add label"}),(0,t.jsxs)(J.PopoverContent,{align:"start",sideOffset:6,className:"w-80 p-2","data-testid":b,children:[(0,t.jsx)("span",{className:"block px-2 pt-1 pb-2 text-body font-medium",children:e}),(0,t.jsx)(H,{groups:d,pickedValueIds:s.flatMap(e=>"string"==typeof e.term?[e.term]:[]),onPick:e=>{w(!1),m(e)},terms:{picked:s.flatMap(e=>"string"==typeof e.term?[]:[e.term]),onPick:e=>{w(!1),m(e)}}}),(0,t.jsxs)("p",{className:"mt-2 flex items-center justify-between gap-2 border-t border-border px-2 pt-2 text-meta text-muted-foreground",children:["All must hold. * is any value, # the same as the other side.",(0,t.jsx)(r.default,{href:"/labels",className:"font-medium text-foreground hover:underline",children:"Manage labels"})]})]})]}),N>=o?null:(0,t.jsxs)(J.Popover,{open:j,onOpenChange:k,children:[(0,t.jsx)(J.PopoverTrigger,{render:(0,t.jsx)(n.Button,{type:"button",variant:"ghost",size:"xs",icon:(0,t.jsx)(F.Plus,{}),disabled:c,"data-testid":`${x}-owner-add`}),children:"Add owner"}),(0,t.jsxs)(J.PopoverContent,{align:"start",sideOffset:6,className:"w-72 p-2","data-testid":`${b}-owner`,children:[(0,t.jsxs)("span",{className:"block px-2 pt-1 pb-2 text-body font-medium",children:[e," the owner"]}),(0,t.jsx)("ul",{className:"flex flex-col",children:O.map(e=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",disabled:S.has((0,f.termKeyOf)(e.term)),"data-testid":`${x}-owner-option`,onClick:()=>{k(!1),m(e.term)},className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-body hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:text-muted-foreground disabled:hover:bg-transparent",children:[(0,t.jsx)(q.UserRound,{"aria-hidden":!0,className:"size-(--size-icon) shrink-0 text-muted-foreground"}),e.text]})},(0,f.termKeyOf)(e.term)))}),(0,t.jsx)("p",{className:"mt-2 border-t border-border px-2 pt-2 text-meta text-muted-foreground",children:"An owner is argo or a person’s ship. # is the same owner as the other side."})]})]})]}),void 0===u?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-tone-attention-fg","data-testid":`${x}-problem`,children:u}),0===l.length?null:(0,t.jsx)("p",{role:"alert",className:"text-meta text-tone-attention-fg",children:"A label or owner here was removed from the fleet: this side matches no ship until you remove it."})]})}function Y({owner:e,onRemove:s,testId:r}){let{owner:a}=e.term,n="*"===a||"#"===a?`${e.text}. ${f.OWNER_TERM_MEANINGS[a]}`:`${e.text}: ships it owns`;return(0,t.jsxs)("span",{role:"group","aria-label":n,title:n,"data-testid":r,className:"inline-flex h-5.5 max-w-full min-w-0 shrink-0 items-center gap-1 rounded-sm border border-border bg-secondary px-1.5 font-mono text-id whitespace-nowrap text-foreground [&_svg]:size-3 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[(0,t.jsx)(q.UserRound,{"aria-hidden":!0}),(0,t.jsxs)("span",{className:"truncate",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"owner="}),(0,t.jsx)("span",{className:"font-medium",children:e.text.slice(6)})]}),void 0===s?null:(0,t.jsx)("button",{type:"button","aria-label":`Remove ${e.text}`,onClick:s,className:"-mr-1 ml-0.5 inline-flex size-4 items-center justify-center rounded-xs text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:(0,t.jsx)(G.X,{"aria-hidden":!0})})]})}let Z=[{side:"from",label:"From ships with"},{side:"to",label:"To ships with"}],ee=()=>crypto.randomUUID();function et({rules:e,context:s,limits:r,isSaving:a,saveError:i,savedNote:d,onSave:o}){let[c,u]=(0,g.useState)(()=>(0,f.draftOf)(e,ee)),[m,h]=(0,g.useState)(!1),p=(0,_.filterGroupsOf)(s),v=(0,f.ownerChoicesOf)(s),b=(0,f.isChanged)(c,e);return(0,t.jsxs)("section",{"aria-labelledby":"network-rules","data-testid":"network-rules",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-rules",className:"text-body font-semibold",children:"Rules"}),"all-to-all"===c.kind?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-body","data-testid":"network-rules-state",children:"No rules: every ship may send to, read and manage every ship."}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"With rules, a ship may send to, read or manage another only when a rule of that verb or a built-in rule allows it."}),(0,t.jsx)("div",{children:(0,t.jsx)(n.Button,{variant:"primary",icon:(0,t.jsx)(F.Plus,{"aria-hidden":!0}),disabled:a,"data-testid":"network-rules-on",onClick:()=>{u((0,f.setRulesOn)(c,!0))},children:"Set rules"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-body","data-testid":"network-rules-state",children:0===c.rules.length?"No rule allows anything yet: once saved, only the built-in rules hold.":"A ship may send to, read or manage another only when a rule of that verb or a built-in rule allows it."}),0===c.rules.length?null:(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:c.rules.map((e,i)=>(0,t.jsxs)("li",{"data-testid":"network-rule",className:"flex flex-col gap-2 rounded-md border border-border p-3 sm:flex-row sm:items-start sm:gap-3",children:[Z.map(({side:n,label:l})=>{let d,o=(0,f.selectorOf)(e[n],s);return(0,t.jsxs)("div",{className:"flex min-w-0 grow basis-0 items-start gap-3",children:["to"===n?(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"Verb"}),(0,t.jsxs)(D.Select,{items:f.VERB_WORDS,value:e.verb,disabled:a,onValueChange:t=>{V.NETWORK_VERBS.some(e=>e===t)&&u((0,f.setVerb)(c,{rule:e.key,verb:t}))},children:[(0,t.jsx)(D.SelectTrigger,{"aria-label":`Verb of rule ${String(i+1)}`,"data-testid":"network-rule-verb",size:"sm",children:(0,t.jsx)(D.SelectValue,{})}),(0,t.jsx)(D.SelectContent,{children:V.NETWORK_VERBS.map(e=>(0,t.jsx)(D.SelectItem,{value:e,children:f.VERB_WORDS[e]},e))})]})]}):null,"to"===n?(0,t.jsx)(x.ArrowRight,{"aria-hidden":!0,className:"mt-6 hidden size-(--size-icon) shrink-0 text-muted-foreground sm:block"}):null,(0,t.jsx)(X,{label:l,picked:o.chips,owners:o.owners,ownerChoices:v,unknown:o.unknown,groups:p,max:r.selectorMax,isDisabled:a,...void 0===(d=(0,f.sameValueProblemOf)(e,{side:n,context:s}))?{}:{problem:d},testId:`network-rule-${n}`,popoverTestId:"network-rule-popover",onAdd:t=>{u((0,f.addTerm)(c,{rule:e.key,side:n,term:t,limits:r}))},onRemove:t=>{u((0,f.removeTerm)(c,{rule:e.key,side:n,term:t}))}})]},n)}),(0,t.jsx)(n.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(K.Trash2,{"aria-hidden":!0}),disabled:a,"aria-label":`Remove rule ${String(i+1)}`,"data-testid":"network-rule-remove",onClick:()=>{u((0,f.removeRule)(c,e.key))}})]},e.key))}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.rules.length>=r.rulesMax?null:(0,t.jsx)(n.Button,{size:"sm",icon:(0,t.jsx)(F.Plus,{"aria-hidden":!0}),disabled:a,"data-testid":"network-rules-add",onClick:()=>{u((0,f.addRule)(c,{newKey:ee,limits:r}))},children:"Add rule"}),(0,t.jsxs)("span",{className:"text-meta text-muted-foreground tabular-nums","data-testid":"network-rules-count",children:[c.rules.length," of ",r.rulesMax," rules"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3",children:[(0,t.jsx)(n.Button,{variant:"primary",isLoading:a,disabled:!b||(0,f.hasSameValueOnOneSide)(c),"data-testid":"network-rules-save",onClick:()=>{o((0,f.rulesOf)(c))},children:"Save rules"}),b?(0,t.jsx)(n.Button,{disabled:a,"data-testid":"network-rules-discard",onClick:()=>{u((0,f.draftOf)(e,ee))},children:"Discard changes"}):null,(0,t.jsx)(n.Button,{variant:"ghost",className:"ml-auto",disabled:a,"data-testid":"network-rules-off",onClick:()=>{null===e?u((0,f.setRulesOn)(c,!1)):h(!0)},children:"Remove all rules"})]})]}),void 0===i?null:(0,t.jsx)(l.InlineError,{variant:"field",title:"Couldn’t save the rules",description:i}),void 0===d||b?null:(0,t.jsx)("p",{role:"status",className:"text-meta text-muted-foreground","data-testid":"network-rules-note",children:d}),(0,t.jsx)(W.AlertDialog,{open:m,onOpenChange:e=>{e||a||h(!1)},children:(0,t.jsxs)(W.AlertDialogContent,{"data-testid":"network-rules-off-dialog",className:U.dialogSurface.phoneSheet,children:[(0,t.jsxs)(W.AlertDialogHeader,{children:[(0,t.jsx)(W.AlertDialogTitle,{children:"Remove all rules?"}),(0,t.jsx)(W.AlertDialogDescription,{children:"Every ship may send to, read and manage every ship again from now on. The rules are gone: to have them back, set them again."})]}),(0,t.jsxs)(W.AlertDialogFooter,{children:[(0,t.jsx)(W.AlertDialogClose,{render:(0,t.jsx)(n.Button,{disabled:a}),children:"Cancel"}),(0,t.jsx)(n.Button,{variant:"destructive",isLoading:a,"data-testid":"network-rules-off-confirm",onClick:()=>{h(!1),o(null)},children:"Remove all rules"})]})]})})]})}var es=e.i(49635);function er({refusals:e,error:s,onRetry:r,context:a,now:n}){let o;return o=void 0!==s?(0,t.jsx)(l.InlineError,{title:"Couldn’t read the refusals",description:s,onRetry:r}):void 0===e?(0,t.jsx)(d.LoadingSkeleton,{variant:"list",rows:3,label:"Loading the refusals"}):0===e.length?(0,t.jsx)(i.EmptyState,{variant:"section",title:"No send has been refused."}):(0,t.jsx)("ol",{className:"flex flex-col gap-2","data-testid":"network-refusals-list",children:e.map(e=>(0,t.jsx)(ea,{refusal:e,context:a,now:n},e.id))}),(0,t.jsxs)("section",{"aria-labelledby":"network-refusals","data-testid":"network-refusals",className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsx)("h2",{id:"network-refusals",className:"text-body font-semibold",children:"Refusals"}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:"The sends the rules refused, newest first, with both ships’ labels as they were then. The sender was told only that its send was refused."}),o]})}function ea({refusal:e,context:s,now:r}){let a,n=new Date(e.at),{recipient:i}=e,l="ship"===i.kind?[i.ship]:i.ships;return(0,t.jsxs)("li",{"data-testid":"network-refusal",className:"flex flex-col gap-2 rounded-md border border-border px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5",children:[(0,t.jsx)("p",{className:"text-body font-medium",children:function(e){let{sender:t,recipient:s}=e;switch(s.kind){case"ship":return`${t.name} tried to message ${s.ship.name}.`;case"type":return`${t.name} tried to message the type ${s.type}: ${(0,_.listed)(s.ships.map(e=>e.name))}.`}}(e)}),(0,t.jsx)("time",{dateTime:e.at,title:(0,es.fullDateTime)(n),className:"text-meta text-muted-foreground tabular-nums",children:(0,es.relativeTime)(n,r)})]}),(0,t.jsxs)("dl",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(en,{side:"From",ship:e.sender,context:s}),l.map(e=>(0,t.jsx)(en,{side:"To",ship:e,context:s},e.id))]}),(0,t.jsx)("p",{className:"text-meta text-muted-foreground",children:(a=`Refused by network settings version ${String(e.settingsVersion)}`,null===e.whilePluginUnavailable?`${a}.`:`${a} while the networking plugin was not responding: ${P[e.whilePluginUnavailable].name}.`)})]})}function en({side:e,ship:s,context:r}){let a=(0,_.chipsOf)(s,r);return(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[(0,t.jsxs)("dt",{className:"text-meta text-muted-foreground",children:[e," ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:s.name})]}),(0,t.jsx)("dd",{className:"flex min-w-0 flex-wrap items-center gap-1",children:0===a.length?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"No labels"}):a.map(e=>(0,t.jsx)(v.LabelChip,{chip:e,testId:"network-refusal-label"},e.valueId))})]})}var ei=e.i(77821),el=e.i(87964),ed=e.i(90262),eo=e.i(25242),ec=e.i(5387),eu=e.i(18423),em=e.i(28459),eh=e.i(46806),ex=e.i(96676),ep=e.i(3979),eg=e.i(54616),ef=e.i(66027),ev=e.i(12598),eb=e.i(27702);let ey={send:"Every ship may send to every ship.",read:"Every ship may read every ship.",manage:"Every ship may manage every ship."};function ew(e){switch(e.rule){case"argo":return{key:e.rule,name:"argo",meaning:"argo sends to, reads and manages every ship, and every ship reaches argo.",isOn:e.isOn,turnedBy:"never"};case"owner":return{key:e.rule,name:"Owner",meaning:"A ship’s owner sends to, reads and manages the ships it owns.",isOn:e.isOn,turnedBy:"never"};case"answer":return{key:e.rule,name:"Answer",meaning:"A ship may always answer the sender of a message it received.",isOn:e.isOn,turnedBy:"never"};case"pluginRead":return{key:e.rule,name:"Connected plugins read",meaning:"A plugin argo connected reads every ship, whatever the rules.",isOn:e.isOn,turnedBy:"never"};case"viewerRead":return{key:e.rule,name:"Viewer reads",meaning:"The viewer reads every ship.",isOn:e.isOn,turnedBy:"argo"};case"open":return{key:`open-${e.verb}`,name:`Open for ${e.verb}`,meaning:ey[e.verb],isOn:e.isOn,turnedBy:"plugin"}}}var ej=e.i(19273),ek=e.i(78485);e.s(["NetworkPageFor",0,function({pickedShipId:e}){var o,c;let u,m,x,p,g,v,b,w,j=(0,a.useRouter)(),k=(0,ex.useNow)(),N=(0,el.useConsoleFrame)(),S=(0,em.useNeedsAttention)(),O=(0,eu.useLiveFleet)(),R=(0,ed.useAccess)(),$=(0,ep.usePluginNav)(),T=(0,eh.useHasNetwork)(),E=(0,eh.useNetwork)(),A=(0,ec.useLabelContext)(),B=(0,ec.useFleetSnapshot)(),P=(o=T?e:void 0,m=(0,eb.useTRPC)(),(0,ef.useQuery)({...m.fleet.explainReach.queryOptions(void 0===o?ej.skipToken:{fromShipId:o}),select:C})),M=(x=(0,eb.useTRPC)(),(0,ef.useQuery)(x.fleet.reachRefusals.queryOptions(void 0,{enabled:T}))),z=(p=(0,eb.useTRPC)(),(0,ef.useQuery)(p.fleet.declaredNetworkRules.queryOptions(void 0,{enabled:T}))),D=(g=(0,eb.useTRPC)(),(0,ef.useQuery)(g.fleet.builtInRules.queryOptions(void 0,{enabled:T}))),V=(v=(0,eb.useTRPC)(),b=(0,ev.useQueryClient)(),{setViewerRead:e=>{w.mutate({rule:"viewerRead",isOn:e})},isPending:(w=(0,eg.useMutation)(v.fleet.setBuiltInRule.mutationOptions({onSuccess:()=>b.invalidateQueries({queryKey:v.fleet.builtInRules.queryKey()})}))).isPending,error:w.error?.message}),F=(0,eh.useSaveNetworkRules)(),K=(0,eh.useSaveNetworkDeclaration)(),{networkRulesMax:_,shipLabelsMax:W,whileUnavailable:U,notRespondingAfterMinSeconds:q,notRespondingAfterMaxSeconds:G}=(0,eo.useConsoleConstants)();if((0,ek.useSignInWhenSessionEnds)([S.error,O.error]),T)if(E.isError)u=(0,t.jsx)(l.InlineError,{title:"Couldn’t read the network",description:E.error.message,onRetry:()=>{E.refetch()}});else if(void 0===E.data||void 0===A||void 0===B.data)u=(0,t.jsx)(d.LoadingSkeleton,{variant:"detail",rows:4,label:"Loading the network"});else{let s;u=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h,{rows:void 0===D.data?void 0:D.data.map(ew),error:D.error?.message,onRetry:()=>{D.refetch()},isTurning:V.isPending,turnError:V.error,onViewerReadChange:V.setViewerRead}),(0,t.jsx)(et,{rules:E.data.rules,context:A,limits:{rulesMax:_,selectorMax:W},isSaving:F.isPending,saveError:F.error?.message,savedNote:void 0===F.data?void 0:(0,f.supplyNote)(F.data.supply),onSave:e=>{F.mutate(e)}},JSON.stringify(E.data.rules)),(0,t.jsx)(y,{declared:void 0===z.data?void 0:(c=z.data,s=new Map(B.data.map(e=>[e.id,e.name])),c.filter(({rules:e})=>e.length>0).map(({shipId:e,rules:t})=>({shipId:e,declaredBy:s.get(e)??e,rules:t})).sort((e,t)=>e.declaredBy.localeCompare(t.declaredBy))),error:z.error?.message,onRetry:()=>{z.refetch()},context:A}),(0,t.jsx)(L,{declaration:E.data.declaration,options:U,bounds:{min:q,max:G},isSaving:K.isPending,saveError:K.error?.message,savedNote:void 0===K.data?void 0:function(e){switch(e){case"supplied":return"Saved. The networking plugin registered again with it.";case"waiting":return"Saved. The fleet does not answer yet: the networking plugin registers again with it as soon as it does.";case"not-connected":case"unregistered":return"Saved."}}(K.data.supply),onSave:e=>{K.mutate(e)}},JSON.stringify(E.data.declaration)),(0,t.jsx)(I,{ships:B.data.filter(e=>"retired"!==e.status&&"viewer"!==e.kind).map(e=>({id:e.id,name:e.name,isOperator:"operator"===e.kind})).sort((e,t)=>Number(t.isOperator)-Number(e.isOperator)||e.name.localeCompare(t.name)),pickedShipId:e,reachableShipIds:P.data,reachError:P.error?.message,onPick:e=>{j.replace(void 0===e?"/network":`/network?reach=${e}`,{scroll:!1})},onRetry:()=>{P.refetch()}}),(0,t.jsx)(er,{refusals:M.data,error:M.error?.message,onRetry:()=>{M.refetch()},context:A,now:k})]})}else u=(0,t.jsx)(i.EmptyState,{icon:(0,t.jsx)(s.Network,{"aria-hidden":!0}),title:R.canEditNetwork?"The networking plugin is not connected":"Only argo sees the network rules",description:R.canEditNetwork?"Connect it in Settings. Until it supplies rules, every ship may message every ship.":void 0,action:R.canEditNetwork&&$.hasSettings?(0,t.jsx)(n.Button,{nativeButton:!1,render:(0,t.jsx)(r.default,{href:"/settings"}),"data-testid":"network-open-settings",children:"Open Settings"}):void 0});return(0,t.jsx)(ei.ListPage,{...N,title:"Network",description:"Who may send to, read or manage whom. The networking plugin supplies these rules to the fleet, which checks them on every send. Only argo sees this page.",live:O.live,children:u})}],13260)}]);