@aeolus-fleet/console 0.20.2 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/inbox/page.js.nft.json +1 -1
- package/.next/server/app/inbox/page_client-reference-manifest.js +1 -1
- package/.next/server/app/labels/page.js.nft.json +1 -1
- package/.next/server/app/labels/page_client-reference-manifest.js +1 -1
- package/.next/server/app/needs-attention/page.js.nft.json +1 -1
- package/.next/server/app/needs-attention/page_client-reference-manifest.js +1 -1
- package/.next/server/app/needs-crew/page.js.nft.json +1 -1
- package/.next/server/app/needs-crew/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/ships/[shipId]/page.js.nft.json +1 -1
- package/.next/server/app/ships/[shipId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sign-in/failed/page.js.nft.json +1 -1
- package/.next/server/app/sign-in/failed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sign-in/page.js.nft.json +1 -1
- package/.next/server/app/sign-in/page_client-reference-manifest.js +1 -1
- package/.next/server/app/squadrons/[squadronId]/page.js.nft.json +1 -1
- package/.next/server/app/squadrons/[squadronId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/squadrons/blueprints/[name]/page.js.nft.json +1 -1
- package/.next/server/app/squadrons/blueprints/[name]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/squadrons/connection/route.js.nft.json +1 -1
- package/.next/server/app/squadrons/page.js.nft.json +1 -1
- package/.next/server/app/squadrons/page_client-reference-manifest.js +1 -1
- package/.next/server/app/squadrons/templates/[name]/page.js.nft.json +1 -1
- package/.next/server/app/squadrons/templates/[name]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/trierarch-plugin/connection/route.js.nft.json +1 -1
- package/.next/server/app/trierarchs/[shipId]/page.js.nft.json +1 -1
- package/.next/server/app/trierarchs/[shipId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/trierarchs/page.js.nft.json +1 -1
- package/.next/server/app/trierarchs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/version/route.js.nft.json +1 -1
- package/.next/server/chunks/_0h366h9._.js +1 -1
- package/.next/server/chunks/packages_console_lib_connect-plugin_ts_197hf-1._.js +1 -1
- package/.next/server/chunks/ssr/_0dogq79._.js +1 -1
- package/.next/server/chunks/ssr/_0s2b6hb._.js +1 -1
- package/.next/server/chunks/ssr/_0sko-kt._.js +1 -1
- package/.next/server/chunks/ssr/_0sv2xqb._.js +1 -1
- package/.next/server/chunks/ssr/_0wtj0e-._.js +1 -1
- package/.next/server/chunks/ssr/_0xvm1ng._.js +1 -1
- package/.next/server/chunks/ssr/_0ziovn_._.js +1 -1
- package/.next/server/chunks/ssr/_1442xyx._.js +1 -1
- package/.next/server/chunks/ssr/_181kpys._.js +1 -1
- package/.next/server/chunks/ssr/_19e0e-9._.js +1 -1
- package/.next/server/chunks/ssr/_1ejhqt9._.js +1 -1
- package/.next/server/chunks/ssr/_1kv8ma5._.js +1 -1
- package/.next/server/chunks/ssr/_1ommvbv._.js +1 -1
- package/.next/server/chunks/ssr/_1oofkty._.js +1 -1
- package/.next/server/chunks/ssr/_1r6ce_7._.js +1 -1
- package/.next/server/chunks/ssr/packages_console_app_ships_[shipId]_page_tsx_0fudjay._.js +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{3z61krti-vbu2.js → 108myfe5p_uik.js} +1 -1
- package/.next/static/chunks/{414186x82sxkk.js → 1jt80qxcc5_14.js} +1 -1
- package/.next/static/chunks/{23hfit3epwjh0.js → 2yxtvf_jtfnbf.js} +5 -5
- package/package.json +3 -3
- /package/.next/static/{va-oYqdgsZx7jVoPSVC3a → 2RcnmMJXP55xfywa0IWOJ}/_buildManifest.js +0 -0
- /package/.next/static/{va-oYqdgsZx7jVoPSVC3a → 2RcnmMJXP55xfywa0IWOJ}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{va-oYqdgsZx7jVoPSVC3a → 2RcnmMJXP55xfywa0IWOJ}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,21607,e=>{"use strict";var t=e.i(43476);e.i(31627);var s=e.i(83615),n=e.i(18566),a=e.i(71645),i=e.i(60592),r=e.i(44824),d=e.i(45608),l=e.i(95475),o=e.i(2767),c=e.i(56420);let u={name:"mail-question-mark",size:24,node:[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]],aliases:["mail-question"]};u.node;let h=(0,c.default)(u),m={name:"reply",size:24,node:[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]};m.node;let p=(0,c.default)(m);var x=e.i(69693),g=e.i(49635),f=e.i(46150),b=e.i(91703),j=e.i(15905),v=e.i(61966),w=e.i(75305),y=e.i(19321),N=e.i(67874),k=e.i(39448);function C({parts:e,className:s}){let n;return(0,t.jsx)("span",{className:s,children:(n=new Map,e.map(e=>{let t="text"===e.kind?`text:${e.text}`:`ship:${e.party.id}`,s=n.get(t)??0;return n.set(t,s+1),{key:`${t}#${String(s)}`,part:e}})).map(({key:e,part:s})=>"text"===s.kind?(0,t.jsx)("span",{children:s.text},e):(0,t.jsx)(k.ShipName,{name:s.party.name,shipId:s.party.id,isSuffixShown:s.party.name!==f.OPERATOR_NAME,className:"align-baseline"},e))})}var S=e.i(78865),T=e.i(40798);function q(e){return e.ship?[(0,f.ship)(e.ship)]:[(0,f.text)("a ship")]}var R=e.i(66390);function A({entries:e,recipient:s}){return(0,t.jsx)("ol",{"data-testid":"delivery-history","aria-label":"Delivery history",className:"flex flex-col",children:e.map((n,a)=>{let i=new Date(n.occurredAt);return(0,t.jsxs)("li",{"data-testid":"delivery-history-entry","data-type":n.type,className:"relative flex gap-3 pb-4 last:pb-0",children:[(0,t.jsxs)("span",{"aria-hidden":!0,className:"relative flex w-3 shrink-0 justify-center",children:[(0,t.jsx)("span",{className:"mt-1.5 size-2.5 rounded-full border-2 border-muted-foreground bg-card"}),a<e.length-1?(0,t.jsx)("span",{className:"absolute top-5 bottom-[-0.25rem] w-px bg-border"}):null]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(S.StatusBadge,{status:function(e){switch(e.type){case"MessageAccepted":case"DeliveryReturned":return"pending";case"DeliveryClaimed":return"delivered";case"DeliveryAcknowledged":return"acknowledged";case"DeliveryUndeliverable":return"undeliverable";case"DeliveryAbandoned":return"abandoned";case"DeliveryDismissed":return"dismissed"}}(n)}),(0,t.jsx)("time",{dateTime:n.occurredAt,title:(0,g.fullDateTime)(i),className:"font-mono text-id text-muted-foreground tabular-nums",children:(0,g.secondsTime)(i)}),0===a?(0,t.jsx)(R.Badge,{variant:"outline",children:"Current"}):null]}),(0,t.jsx)(C,{parts:function(e,t){switch(e.type){case"MessageAccepted":return"ship"===t.kind?[(0,f.text)("Stored in the inbox of "),(0,f.ship)(t.ship),(0,f.text)(".")]:[(0,f.text)(`Queued for any ship of type ${t.type}.`)];case"DeliveryClaimed":{let t=null!==e.attempts&&e.attempts>1?`Attempt ${String(e.attempts)}: claimed`:"Claimed";return[(0,f.text)(`${t} by `),...q(e),...function(e){if(null===e)return[];let t=null!==e.description&&""!==e.description?e.description:(0,T.locationKindWord)(e.kind);return[(0,f.text)(`, session on ${t}`)]}(e.location),(0,f.text)(".")]}case"DeliveryReturned":return"ship"===t.kind?[(0,f.text)("Back in the inbox: the session of "),...q(e),(0,f.text)(" ended before acknowledging it.")]:[(0,f.text)("Returned to the queue: the session of "),...q(e),(0,f.text)(" ended before acknowledging it.")];case"DeliveryAcknowledged":return[(0,f.text)("Acknowledged by "),...q(e),(0,f.text)(".")];case"DeliveryUndeliverable":return[(0,f.text)(null===e.attempts?"Never acknowledged: no ship takes it automatically any more.":`Received ${String(e.attempts)} times, never acknowledged.`)];case"DeliveryAbandoned":return[(0,f.text)("Abandoned: "),...q(e),(0,f.text)(" was retired before taking it.")];case"DeliveryDismissed":return[(0,f.text)("Dismissed by the operator: no ship takes it any more.")]}}(n,s),className:"text-meta text-muted-foreground max-sm:text-body-touch"})]})]},n.seq)})})}let I="text-section font-semibold text-foreground";function $({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-3 py-2 last:border-b-0",children:[(0,t.jsx)("dt",{className:"w-24 shrink-0 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 D({message:e}){let s=e.recipient;return(0,t.jsxs)("dl",{"aria-label":"Envelope",className:"overflow-hidden rounded-lg border border-border bg-card",children:[(0,t.jsxs)($,{label:"Message id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(v.CopyButton,{value:e.id,label:"Copy message id"})]}),(0,t.jsx)($,{label:"From",children:(0,t.jsx)(k.ShipName,{name:e.sender.name,shipId:e.sender.id,isSuffixShown:e.sender.name!==f.OPERATOR_NAME})}),(0,t.jsx)($,{label:"To",children:"ship"===s.kind?(0,t.jsx)(k.ShipName,{name:s.ship.name,shipId:s.ship.id,isSuffixShown:s.ship.name!==f.OPERATOR_NAME}):(0,t.jsxs)("span",{children:["Any ship of type ",(0,t.jsx)("span",{className:"font-mono text-id",children:s.type})]})}),(0,t.jsx)($,{label:"Sent",children:(0,t.jsx)("time",{dateTime:e.sentAt,className:"tabular-nums",children:(0,g.fullDateTime)(new Date(e.sentAt))})}),null===e.model?null:(0,t.jsx)($,{label:"Model",children:(0,t.jsx)("span",{className:"truncate font-mono text-id","data-testid":"message-model",children:e.model})}),e.inReplyTo?(0,t.jsx)($,{label:"In reply to",children:(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.inReplyTo})}):null]})}function L({message:e}){let s=(0,x.payloadLabel)(e.payload,e.contentType),n=(0,x.formattedPayload)(e.payload,e.contentType),a=(0,t.jsx)(b.CodeBlock,{label:s,code:e.payload,isWrapped:!0,copyLabel:"Copy payload",codeTestId:"message-payload"});return void 0===n?(0,t.jsxs)("section",{"aria-label":"Payload",className:"flex flex-col gap-2",children:[(0,t.jsx)("h3",{className:I,children:"Payload"}),a]}):(0,t.jsx)("section",{"aria-label":"Payload",className:"flex flex-col gap-2",children:(0,t.jsxs)(i.Tabs,{defaultValue:"formatted",className:"gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:I,children:"Payload"}),(0,t.jsxs)(i.TabsList,{className:"max-sm:w-auto",children:[(0,t.jsx)(i.TabsTrigger,{value:"formatted",children:"Formatted"}),(0,t.jsx)(i.TabsTrigger,{value:"raw",children:"Raw"})]})]}),(0,t.jsx)(i.TabsContent,{value:"formatted",children:(0,t.jsx)(b.CodeBlock,{label:s,code:n,copyValue:e.payload,copyLabel:"Copy payload",codeTestId:"message-payload"})}),(0,t.jsx)(i.TabsContent,{value:"raw",children:a})]})})}function O({message:e}){return(0,t.jsxs)("section",{"aria-label":"Delivery",className:"flex flex-col gap-2 max-sm:order-first",children:[(0,t.jsx)("h3",{className:I,children:"Delivery"}),(0,t.jsx)("div",{className:"rounded-lg border border-border bg-card p-3",children:(0,t.jsx)(A,{entries:e.delivery.history,recipient:e.recipient})})]})}function z(){return(0,t.jsxs)("div",{"aria-busy":!0,className:"flex flex-col gap-4",children:[(0,t.jsx)("span",{className:"sr-only",children:"Loading the message"}),(0,t.jsx)(y.Skeleton,{className:"h-32 w-full rounded-lg"}),(0,t.jsx)(y.Skeleton,{className:"h-28 w-full rounded-lg"}),(0,t.jsx)(y.Skeleton,{className:"h-40 w-full rounded-lg"})]})}function M({message:e,messageId:s,state:n,isOpen:a,onOpenChange:i,onReply:r}){let d="ready"===n&&void 0!==e;return(0,t.jsx)(w.Sheet,{open:a,onOpenChange:i,children:(0,t.jsxs)(w.SheetContent,{side:"right","data-testid":"message-sheet",children:[(0,t.jsx)(w.SheetHeader,{children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(w.SheetTitle,{className:"flex min-w-0 items-baseline gap-1.5",children:[(0,t.jsx)("span",{children:"Message from"}),(0,t.jsx)(k.ShipName,{name:e.sender.name,shipId:e.sender.id,isSuffixShown:e.sender.name!==f.OPERATOR_NAME,className:"text-heading"})]}),(0,t.jsxs)(w.SheetDescription,{children:[(0,t.jsx)(C,{parts:"ship"===e.recipient.kind?[(0,f.text)("To "),(0,f.ship)(e.recipient.ship)]:[(0,f.text)(`To any ship of type ${e.recipient.type}`)]}),". ",(0,S.statusLabel)(e.delivery.state),"."]}),r&&e.sender.name!==f.OPERATOR_NAME?(0,t.jsx)("div",{children:(0,t.jsxs)(j.Button,{size:"xs",icon:(0,t.jsx)(p,{}),"data-testid":"message-reply",onClick:()=>{r(e)},children:["Reply to ",e.sender.name]})}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.SheetTitle,{children:"Message"}),(0,t.jsx)(w.SheetDescription,{children:"not-found"===n?"Couldn’t open this message":"Loading"})]})}),(0,t.jsxs)(w.SheetBody,{className:"flex flex-col gap-5",children:["loading"===n?(0,t.jsx)(z,{}):null,"not-found"===n?(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(h,{}),title:"Message not found",description:(0,t.jsxs)(t.Fragment,{children:["No message with this id exists in this fleet, or the link is incomplete.",s?(0,t.jsx)("span",{className:"mt-2 block font-mono text-id",children:s}):null]})}):null,d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D,{message:e}),(0,t.jsx)(L,{message:e}),(0,t.jsx)(O,{message:e})]}):null]})]})})}let P={name:"arrow-down-left",size:24,node:[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]};P.node;let E=(0,c.default)(P),B={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};B.node;let F=(0,c.default)(B),_={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"}]]};_.node;let V=(0,c.default)(_);var H=e.i(25398),W=e.i(90063);function U(e,t){return RegExp(`"${t}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`).exec(e)?.[1]}let K={"application/vnd.aeolus.squadron.check-in+json":()=>"Checked in at its flagship","application/vnd.aeolus.squadron.role+json":e=>{let t=U(e,"role");return void 0===t?"Given its role":`Given the role: ${t}`},"application/vnd.aeolus.squadron.on-station+json":e=>{let t=U(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"};function G(e,t){return e.sentAt.localeCompare(t.sentAt)||e.id.localeCompare(t.id)}var Y=e.i(17981),X=e.i(88393);function J({message:e,shipId:s,now:n,onOpenMessage:a}){var i,r,d;let l,o,c=e.sender.id===s,u=new Date(e.sentAt),h=void 0!==(o=K[r=(i=e).contentType,r.split(";")[0]?.trim().toLowerCase()??""])?{text:o(i.preview),isCode:!1}:(0,x.isJson)(i.contentType)?{text:0===(l=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:l.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":`${c?"Sent":"Received"} message: ${h.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)(c?F:E,{})}),(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)(C,{parts:c?"ship"===e.recipient.kind?[(0,f.text)("To "),(0,f.ship)(e.recipient.ship)]:[(0,f.text)(`To any ship of type ${e.recipient.type}`)]:[(0,f.text)("From "),(0,f.ship)(e.sender)],className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)(S.StatusBadge,{status:e.delivery.state})]}),(0,t.jsx)("span",{"data-testid":"message-line",className:(0,W.classNames)("truncate text-muted-foreground",h.isCode?"font-mono text-id":"text-meta"),children:h.text}),(0,t.jsx)("time",{dateTime:e.sentAt,title:(0,g.fullDateTime)(u),className:"text-meta text-muted-foreground tabular-nums",children:(0,g.relativeTime)(u,n)})]})]})})}function Q({shipId:e,messages:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(X.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)(Y.InlineError,{title:"Couldn’t load the messages",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(j.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)(V,{}),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(G);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)(J,{message:s,shipId:e,now:i,onOpenMessage:r},s.id))})},s.id))})}var Z=e.i(90262),ee=e.i(54492),et=e.i(10649),es=e.i(5387),en=e.i(80581),ea=e.i(78608),ei=e.i(84156),er=e.i(265),ed=e.i(41880),el=e.i(4510),eo=e.i(9677),ec=e.i(16984),eu=e.i(74544),eh=e.i(58925),em=e.i(18964),ep=e.i(11568),ex=e.i(68997),eg=e.i(57665),ef=e.i(95925),eb=e.i(86875),ej=e.i(22016),ev=e.i(66616),ew=e.i(95960);let ey={request:"Couldn’t request crew",remove:"Couldn’t remove the request",restart:"Couldn’t restart the crew"};function eN({at:e,now:s,children:n}){return(0,t.jsx)("time",{dateTime:e,title:(0,g.fullDateTime)(new Date(e)),className:"tabular-nums",children:n??(0,g.sinceTime)(new Date(e),s)})}function ek({trierarch:e,hasTrierarchs:s}){return(0,t.jsxs)(ej.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)(eb.ShipWheel,{"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e.name})]})}function eC({requestedBy:e,requestedAt:s,now:n}){let a=null===e?null:e.name===f.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)(eN,{at:s,now:n,children:(0,g.relativeTime)(new Date(s),n)}),"."]})}let eS={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 eT({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 ${eS[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function eq({stage:e,now:s}){let n="running"===e.status?e.startedAt:null,a=(0,ee.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)(eN,{at:n,now:s})]}),null!==n&&void 0!==a?" · ":null,a]})}function eR({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,ev.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)(a.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(ew.LabelChip,{chip:e})]},e.valueId))})]})]})}function eA(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(em.ListChecks,{"aria-hidden":!0,className:"size-(--size-icon) text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-section font-semibold",children:"Crew request"})]})}function eI(e){let{stage:s,requestedBy:n,now:a,canManage:i,isAwaitingCrew:r,busy:d,error:l}=e,o=void 0===l?null:(0,t.jsx)(Y.InlineError,{title:ey[l.action],description:`${l.message} Nothing changed.`});if("none"===s.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)(eA,{}),(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."}),i?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(em.ListChecks,{}),isLoading:"request"===d,onClick:e.onRequest,"data-testid":"crew-request-request",children:"Request crew"}):null]}),o]});let c=(0,ee.crewRequestAction)(s),u=void 0!==d;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)(eA,{}),(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-2","data-testid":"crew-request-state",children:["assigned"===s.kind?(0,t.jsx)(S.StatusBadge,{status:s.status}):(0,t.jsx)(S.StatusBadge,{status:s.kind}),"needsCrew"===s.kind?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e.hasTrierarchs?"not assigned yet":s.reason??(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(eN,{at:s.requestedAt,now:a})]})}):null,"crewedByHand"===s.kind&&null!==s.since?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["since ",(0,t.jsx)(eN,{at:s.since,now:a})]}):null,"assigned"===s.kind?(0,t.jsx)(eq,{stage:s,now:a}):null,"assigned"===s.kind&&"releasing"===s.status&&void 0!==e.statusChangedAt?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["asked ",(0,t.jsx)(eN,{at:e.statusChangedAt,now:a})]}):null]}),"assigned"===s.kind?(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 text-meta",children:["on ",(0,t.jsx)(ek,{trierarch:s.trierarch,hasTrierarchs:e.hasTrierarchs??!1})]}):null,(0,t.jsx)("span",{className:"flex-1"}),"assigned"===s.kind&&"releasing"===s.status?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["Waiting for ",s.trierarch.name]}):null,i?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["remove"===c?(0,t.jsx)(j.Button,{size:"sm",variant:"ghost",isLoading:"remove"===d,disabled:u,onClick:e.onRemove,"data-testid":"crew-request-remove",children:"Remove request"}):null,(0,ee.isRestartable)(s)?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(ef.RotateCcw,{}),isLoading:"restart"===d,disabled:u,onClick:e.onRestart,"data-testid":"crew-request-restart",children:"Restart"}):null,void 0!==e.onEdit&&void 0!==c?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(ex.Pen,{}),disabled:u,onClick:e.onEdit,"data-testid":"crew-request-edit",children:"Edit…"}):null,"release"===c?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(eg.Power,{}),disabled:u,onClick:e.onRelease,"data-testid":"crew-request-release",children:"Release…"}):null,"needsCrew"===s.kind&&r&&!e.hasTrierarchs?(0,t.jsx)(j.Button,{size:"sm",variant:"primary",icon:(0,t.jsx)(eh.KeyRound,{}),disabled:u,onClick:e.onGetStartingPrompt,"data-testid":"crew-request-prompt",children:"Get starting prompt"}):null]}):null]}),"assigned"===s.kind?function(e,s){let{trierarch:n}=e,a=void 0===s.statusChangedAt?null:(0,t.jsx)(eN,{at:s.statusChangedAt,now:s.now});switch(e.status){case"crewing":return(0,t.jsxs)(eT,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0}),children:[n.name," is starting the session."]});case"running":return null;case"restarting":return(0,t.jsxs)(eT,{tone:"waiting",icon:(0,t.jsx)(ef.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)(eT,{tone:"attention",icon:(0,t.jsx)(ec.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)(eT,{tone:"note",icon:(0,t.jsx)(eg.Power,{"aria-hidden":!0}),children:["Releasing: ",n.name," is stopping the session and cleaning up. The request goes away once it confirms."]})}}(s,{statusChangedAt:e.statusChangedAt,now:a}):null,"needsCrew"===s.kind&&e.hasTrierarchs?null===s.reason?(0,t.jsx)(eT,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0}),children:"Waiting for the trierarch plugin to assign a trierarch."}):s.reason===eo.NO_MACHINE_MATCHES_REASON&&void 0!==e.machineLabels&&e.machineLabels.length>0?(0,t.jsxs)(eT,{tone:"waiting",icon:(0,t.jsx)(eu.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,ea.machineLabelsText)(e.machineLabels),", and none"," ",(0,ea.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)(eT,{tone:"waiting",icon:(0,t.jsx)(eu.Clock,{"aria-hidden":!0}),children:[(0,t.jsxs)("strong",{className:"font-medium",children:[(0,f.capitalised)(s.reason),"."]})," The plugin assigns a trierarch as soon as one fits. Until then this ship is on Needs crew."]}):null,o,void 0===e.settingsRows?null:(0,t.jsx)(eR,{rows:e.settingsRows,machineLabels:e.machineLabels}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["needsCrew"!==s.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"===s.kind?`${s.crewedBy.name===f.OPERATOR_NAME?"You":s.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)(eC,{requestedBy:n,requestedAt:s.requestedAt,now:a}),"assigned"===s.kind&&"releasing"!==s.status?" The trierarch keeps it crewed until you release it.":null]})]})}var e$=e.i(86165),eD=e.i(48695),eL=e.i(22212),eO=e.i(94945),ez=e.i(75774);let eM={request:{title:e=>`Request a crew for ${e}`,description:"The trierarch plugin picks a trierarch, which starts the session and keeps it crewed.",action:"Request crew",busy:"Requesting"},edit:{title:e=>`Edit the crew request for ${e}`,description:"Saving writes a new version of the settings: its trierarch stops the session and starts it again with them, in the same workspace.",action:"Save and restart",busy:"Saving"}},eP={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",note:"border-border bg-muted text-muted-foreground"};function eE({tone:e,icon:s,children:n}){return(0,t.jsxs)("div",{role:"attention"===e?"alert":"status","data-testid":"request-crew-banner",className:`flex items-start gap-2 rounded-lg border px-3.5 py-2.5 text-meta [&_svg]:mt-0.5 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 ${eP[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function eB(e){let{shipName:s,mode:n,offers:i,heldSettings:r,squadrons:d,machineLabels:l,check:o,refusedAt:c,error:u,isPending:h,onSettingsChange:m,onSubmit:p}=e,x=eM[n],[f,b]=(0,a.useState)(()=>"edit"===n?(0,et.valuesOf)(r,i):(0,et.defaultValues)(i)),v=(0,et.settingsOf)(f),w=o?.kind==="refused"?o:void 0,y=(0,et.promptBytes)(f.firstPrompt)>eo.FIRST_PROMPT_MAX_BYTES,N=f.machineLabels.length>0&&l?.matchOf(f.machineLabels).matching.length===0,k=void 0!==v&&void 0===w&&!y&&!h;return(0,t.jsxs)("form",{noValidate:!0,className:"contents",onSubmit:e=>{e.preventDefault(),k&&p(v)},children:[(0,t.jsxs)(eL.DialogHeader,{children:[(0,t.jsx)(eL.DialogTitle,{children:x.title(s)}),(0,t.jsx)(eL.DialogDescription,{children:x.description})]}),0===i.length?(0,t.jsx)(eE,{tone:"waiting",icon:(0,t.jsx)(eb.ShipWheel,{"aria-hidden":!0}),children:"No machine answers with what it offers yet. Join a machine under Trierarchs, or wait for its trierarch to report."}):void 0!==w&&void 0!==c?(0,t.jsxs)(eE,{tone:"attention",icon:(0,t.jsx)(ec.CircleX,{"aria-hidden":!0}),children:["The trierarch plugin refused: ",w.field,". Nothing was requested. Change the field below and try again."]}):o?.kind!=="noRoom"||N?null:(0,t.jsx)(eE,{tone:"waiting",icon:(0,t.jsx)(eu.Clock,{"aria-hidden":!0}),children:"No trierarch has a free slot right now. You can still request: the request waits on Needs crew and the plugin assigns a trierarch when a slot frees up."}),0===i.length?null:(0,t.jsx)(ez.CrewSettingsFields,{offers:i,values:f,onChange:e=>{b(e),m((0,et.settingsOf)(e))},squadrons:d,refusal:w,isDisabled:h,...void 0===l?{}:{machineLabels:{...l,shipName:s}}}),void 0===u?null:(0,t.jsx)(Y.InlineError,{title:"edit"===n?"Couldn’t save the settings":"Couldn’t request crew",description:`${u} Nothing changed.`}),(0,t.jsxs)(eL.DialogFooter,{className:"items-center",children:[(0,t.jsx)("span",{className:"mr-auto text-meta text-muted-foreground","data-testid":"request-crew-note",children:void 0!==w&&void 0!==c?`Refused at ${(0,g.secondsTime)(c)}. Nothing was requested.`:N?"The request will wait for a machine with these labels.":o?.kind==="noRoom"?"The request will wait for room.":null}),(0,t.jsx)(eL.DialogClose,{render:(0,t.jsx)(j.Button,{type:"button",disabled:h}),children:"Cancel"}),(0,t.jsx)(j.Button,{type:"submit",variant:"primary",icon:(0,t.jsx)(eb.ShipWheel,{}),isLoading:h,disabled:!k,"data-testid":"request-crew-submit",children:h?x.busy:x.action})]})]})}function eF(e){let{shipName:s,mode:n,state:a,isOpen:i,onOpenChange:r,isPending:d,onRetry:l}=e,o=eM[n];return(0,t.jsx)(eL.Dialog,{open:i,onOpenChange:e=>{d||r(e)},children:(0,t.jsx)(eL.DialogContent,{size:"md","data-testid":"request-crew-dialog",className:eO.dialogSurface.phoneFullScreen,children:"ready"===a?(0,t.jsx)(eB,{...e}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eL.DialogHeader,{children:[(0,t.jsx)(eL.DialogTitle,{children:o.title(s)}),(0,t.jsx)(eL.DialogDescription,{children:o.description})]}),"loading"===a?(0,t.jsx)(eE,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0,className:"motion-safe:animate-spin"}),children:"Loading the trierarch plugin’s options."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eE,{tone:"attention",icon:(0,t.jsx)(ec.CircleX,{"aria-hidden":!0}),children:"The trierarch plugin is not answering. Its options can’t load, so a request with settings can’t be made now. Nothing changed."}),(0,t.jsx)("div",{children:(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(H.RotateCw,{}),onClick:l,"data-testid":"request-crew-retry",children:"Try again"})}),"request"===n?(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["You can still crew ",s," by hand: close this and use Get starting prompt."]}):null]}),(0,t.jsxs)(eL.DialogFooter,{className:"items-center",children:[(0,t.jsx)("span",{className:"mr-auto text-meta text-muted-foreground",children:"loading"===a?"Waiting for the trierarch plugin.":`${o.action} is off until the plugin answers.`}),(0,t.jsx)(eL.DialogClose,{render:(0,t.jsx)(j.Button,{type:"button"}),children:"Cancel"}),(0,t.jsx)(j.Button,{type:"button",variant:"primary",icon:(0,t.jsx)(eb.ShipWheel,{}),disabled:!0,children:o.action})]})]})})})}var e_=e.i(82532);function eV({ship:e,timeline:s,now:n}){let i=(0,Z.useAccess)(),r=(0,er.useHasTrierarchPlugin)(),d=(0,es.useRequestCrew)(),l=(0,es.useLabelContext)(),o=(0,es.useRemoveCrewRequest)(),c=(0,es.useReleaseShip)(),u=(0,es.useGetStartingPrompt)(),[h,m]=(0,a.useState)(),[p,x]=(0,a.useState)(),[g,f]=(0,a.useState)(!1),[b,j]=(0,a.useState)(),[v,w]=(0,a.useState)(!1),[y,N]=(0,a.useState)(),k=function(e){let s=(0,er.useMachines)(),n=(0,e$.useSquadronsConnection)(),i=(0,eD.useSquadrons)(),r=(0,es.useRequestCrew)(),d=(0,es.useLabelContext)(),[l,o]=(0,a.useState)(),[c,u]=(0,a.useState)(null),[h,m]=(0,a.useState)(),p=(0,et.offersOf)(s.data??[]),x=void 0===d||void 0===s.data?void 0:(0,ea.machineLabelsInputOf)(d,s.data),g=(0,et.settingsOf)("edit"===l?(0,et.valuesOf)(e?.heldSettings,p):(0,et.defaultValues)(p)),f=void 0!==l&&void 0!==e,b=(0,er.useCrewSettingsCheck)(f&&void 0!==s.data?null===c?g:c:void 0),j=async t=>{if(void 0!==e&&void 0!==l){r.reset();try{let e=await b.checkNow();if("refused"===e.kind)return void m(new Date)}catch{}r.mutate({shipId:e.shipId,settings:t},{onSuccess:()=>{o(void 0),(0,ed.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),m(void 0),o(e)},dialog:void 0===e?null:(0,t.jsx)(eF,{shipName:e.shipName,mode:l??"request",state:s.isError?"unreachable":void 0===s.data?"loading":"ready",offers:p,heldSettings:e.heldSettings,squadrons:"connected"===n?(i.data??[]).filter(e=>"disbanded"!==e.state).map(e=>e.id):void 0,...void 0===x?{}:{machineLabels:x},check:b.data,refusedAt:h,error:r.error?.message,isPending:r.isPending,isOpen:f,onOpenChange:e=>{e||o(void 0)},onSettingsChange:e=>{u(e),m(void 0)},onSubmit:e=>void j(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 C=(0,ee.crewRequestStage)(e),S=e.crewRequest,T=async(e,t)=>{m(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{m(void 0)}},q=()=>{u.reset(),N((0,ei.isUnclaimedPromptOut)(e)&&e.startingPrompt?{issuedAt:e.startingPrompt.issuedAt}:void 0),w(!0),u.mutate({shipId:e.id})},R=async()=>{await T("request",()=>d.mutateAsync({shipId:e.id,settings:{}}))&&(0,ed.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:q}}:{}})},A=async()=>{null===S||"assigned"!==C.kind||await T("restart",()=>d.mutateAsync({shipId:e.id,settings:S.settings}))&&(0,ed.showToast)({title:`Restarting ${e.name}`,description:`${C.trierarch.name} starts its session again with the same settings.`,tone:"success"})},I=async t=>{j(void 0);let s=(0,ee.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);j(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)(eI,{stage:C,requestedBy:(0,ee.requestedBy)(s),statusChangedAt:(0,ee.statusChangedAt)(s),now:n,canManage:i.canManage,isAwaitingCrew:"awaitingCrew"===e.status,hasTrierarchs:r,busy:h,error:p,settingsRows:null===S?void 0:(0,et.settingsRows)(S.settings),...null===S||void 0===l?{}:{machineLabels:(0,en.pickedChips)((0,ea.machineLabelIdsOf)(S.settings),l)},onRequest:()=>{r?k.open("request"):R()},...r?{onEdit:()=>{k.open("edit")}}:{},onRemove:()=>void T("remove",()=>o.mutateAsync({shipId:e.id})),onRelease:()=>{j(void 0),f(!0)},onRestart:()=>void A(),onGetStartingPrompt:q}),k.dialog,"crewedByHand"===C.kind||"assigned"===C.kind?(0,t.jsx)(el.CrewReleaseDialog,{shipName:e.name,stage:C,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:b,onConfirm:()=>void I(C)}):null,(0,t.jsx)(e_.StartingPromptDialog,{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:v,onOpenChange:e=>{e||(u.reset(),w(!1))},onConfirm:()=>{u.mutate({shipId:e.id})}})]})}var eH=e.i(84294),eW=e.i(19249);function eU({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 eK({shipId:e,now:s}){let n=(0,eD.useSquadrons)(),a=(0,eD.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)(ej.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)(j.Button,{size:"xs",nativeButton:!1,render:(0,t.jsx)(ej.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,g.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,eH.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)(eU,{label:"Squadron",children:[r,(0,t.jsx)(S.StatusBadge,{status:i.state})]}),(0,t.jsxs)(eU,{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)(ej.default,{href:(0,eH.templatePath)(o),className:"font-mono text-meta hover:underline",children:[o.name,"@",o.version]})]}),(0,t.jsx)(eU,{label:"Health",children:(0,t.jsx)(eW.HealthIndicator,{health:d.health,detail:"silent"===d.health||"late"===d.health?c:void 0})}),(0,t.jsx)(eU,{label:"Hand-offs",children:l?(0,t.jsx)("span",{className:"text-meta",children:(0,eH.handoffsText)((0,eH.handoffsOf)(l,d.role))}):(0,t.jsx)(ej.default,{href:(0,eH.blueprintPath)(i.blueprint),className:"text-meta text-muted-foreground hover:underline",children:"See its blueprint"})})]})]})}var eG=e.i(5894),eY=e.i(73332),eX=e.i(76561),eJ=e.i(22768),eQ=e.i(10818),eZ=e.i(69309),e0=e.i(26478),e1=e.i(63481);function e2({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,ev.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 e5=e.i(73330);function e3({ping:e,now:s,testId:n}){return null===e?null:(0,t.jsx)("span",{title:`Pinged ${(0,g.fullDateTime)(new Date(e.sentAt))}`,"data-testid":n,"data-state":e.state,className:"text-meta text-muted-foreground tabular-nums",children:(0,e5.pingLine)(e,s)})}var e7=e.i(67927),e4=e.i(93361);function e6({details:e,version:s,testId:n}){return(0,t.jsxs)("details",{"data-testid":n,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)(e7.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 ",s]})]}),(0,t.jsx)("div",{className:"px-3.5 pb-3.5",children:(0,t.jsx)(b.CodeBlock,{label:(0,e4.reportDetailsLabel)(e),code:(0,e4.reportDetailsJson)(e),copyLabel:"Copy report details",codeTestId:`${n}-code`})})]})}var e8=e.i(81830);function e9({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 te({ship:e,now:s,labels:n}){let a,i="operator"===e.kind,r=null===e.crewedSince?null:new Date(e.crewedSince),d=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)(e9,{label:"Location",children:(0,t.jsxs)("span",{className:"inline-flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)(e1.LocationTag,{kind:e.location?.kind??null,description:e.location?.description,size:"md"}),(0,t.jsx)(e2,{harness:e.harness,model:e.model?.id??null,testId:"ship-model"}),null===e.lastSeenAt?null:(0,t.jsx)("time",{dateTime:e.lastSeenAt,title:(0,g.fullDateTime)(new Date(e.lastSeenAt)),"data-testid":"ship-last-seen",className:"text-meta text-muted-foreground tabular-nums",children:(0,g.lastSeen)(new Date(e.lastSeenAt),s)}),(0,t.jsx)(e3,{ping:e.ping,now:s,testId:"ship-ping-status"}),"agent"!==e.kind?null:(0,t.jsx)(e8.ReportLine,{report:e.report,now:s,variant:"full",testId:"ship-report"})]})}),(0,t.jsx)(e9,{label:"Crewed since",children:r?(0,t.jsx)("time",{dateTime:e.crewedSince??void 0,title:(0,g.fullDateTime)(r),className:"tabular-nums",children:(a=s.getTime()-r.getTime()<864e5?(0,g.clockTime)(r):(0,g.shortDateTime)(r),`${a} \xb7 ${(0,g.duration)(r,s)}`)}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Not crewed"})}),(0,t.jsx)(e9,{label:"Commissioned",children:(0,t.jsx)("time",{dateTime:e.commissionedAt,title:(0,g.fullDateTime)(d),children:i?`Fleet created ${(0,g.dayDate)(d)}`:(0,g.dayDate)(d)})}),(0,t.jsxs)(e9,{label:"Ship id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(v.CopyButton,{value:e.id,label:"Copy ship id"})]}),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 tt({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 ts({ship:e,shipId:s,state:n,actions:a,crewRequest:i,now:r,backHref:d="/",labels:l,isPluginShip:o=!1}){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)(y.Skeleton,{className:"h-8 w-40"}),(0,t.jsx)(y.Skeleton,{className:"h-6 w-20"}),(0,t.jsx)(y.Skeleton,{className:"h-6 w-16"})]}),(0,t.jsx)(y.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)(eJ.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)(j.Button,{size:"sm",nativeButton:!1,render:({children:e,...s})=>(0,t.jsx)(ej.default,{href:d,...s,children:e}),children:"Back to fleet overview"})})});let c="operator"===e.kind,u="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)(k.ShipName,{name:e.name,shipId:e.id,size:"title",isSuffixShown:u})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(S.StatusBadge,{status:e.status}),c?(0,t.jsxs)(R.Badge,{variant:"kind",children:[(0,t.jsx)(e0.UserRound,{"aria-hidden":!0}),"operator"]}):(0,t.jsxs)(t.Fragment,{children:[o?(0,t.jsxs)(R.Badge,{variant:"kind","data-testid":"ship-plugin",children:[(0,t.jsx)(eZ.Plug,{"aria-hidden":!0}),"plugin"]}):null,(0,t.jsx)(R.Badge,{variant:"type",children:e.type}),e.scopes.filter(e=>eY.FLEET_SCOPES.some(t=>t===e)).map(e=>(0,t.jsx)(R.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)(eh.KeyRound,{"aria-hidden":!0}),"No starting prompt issued"]}):null]})]}),a&&!u?(0,t.jsx)("div",{className:(0,W.classNames)("flex flex-wrap items-center gap-2","max-sm:w-full max-sm:[&>*]:flex-1"),children:a}):null]}),c?(0,t.jsx)(tt,{icon:(0,t.jsx)(eQ.Info,{"aria-hidden":!0}),children:"argo is your ship. This console session crews it. It can’t be released, renamed or retired."}):null,u&&null!==e.retiredAt?(0,t.jsxs)(tt,{icon:(0,t.jsx)(eX.Archive,{"aria-hidden":!0}),children:["Retired on ",(0,g.fullDateTime)(new Date(e.retiredAt)),". Read-only."]}):null,i,(0,t.jsx)(te,{ship:e,now:r,labels:l}),"agent"===e.kind&&e.report?.details?(0,t.jsx)(e6,{details:e.report.details,version:e.report.detailsVersion,testId:"ship-report-details"}):null]})}var tn=e.i(99261),ta=e.i(89664),ti=e.i(16327),tr=e.i(56539),td=e.i(77071),tl=e.i(63676),to=e.i(6734),tc=e.i(87851);function tu({chip:e,labelKey:s,isBusy:n,onUnassign:i,onChange:r}){let[d,l]=(0,a.useState)(!1);return(0,t.jsxs)(to.Popover,{open:d,onOpenChange:l,children:[(0,t.jsx)(to.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":`Change or remove ${e.key}=${e.value}`,"data-testid":"ship-label-yours",disabled:n,className:"inline-flex items-center rounded-sm focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60"}),children:(0,t.jsx)(ew.LabelChip,{chip:e,trailing:(0,t.jsx)(ti.ChevronDown,{"aria-hidden":!0}),className:"hover:bg-accent"})}),(0,t.jsxs)(to.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)(ta.Check,{"aria-hidden":!0}):null}),(0,t.jsx)("span",{className:(0,W.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)(tl.X,{"aria-hidden":!0}),"Remove label"]})})]})]})}function th({keys:e,isBusy:s,onAssign:n}){let[i,r]=(0,a.useState)(!1);return(0,t.jsxs)(to.Popover,{open:i,onOpenChange:r,children:[(0,t.jsx)(to.PopoverTrigger,{render:(0,t.jsx)(j.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(td.Plus,{}),disabled:s,"data-testid":"ship-labels-add"}),children:"Add label"}),(0,t.jsxs)(to.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)(tc.LabelPicker,{groups:[{title:"Yours",keys:[...e]}],pickedValueIds:e.flatMap(e=>e.carriedValueIds),pickedWord:"Carried",onPick:e=>{r(!1),n(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)(ej.default,{href:"/labels",className:"font-medium hover:underline",children:0===e.length?"Define a label":"Manage labels"})})]})]})}function tm({chips:e,keys:s,limit:n,isBusy:i,error:r,onAssign:d,onUnassign:l,onChange:o}){let[c,u]=(0,a.useState)(!1),h=!c&&e.length>3,m=h?e.slice(0,2):e,p=[...new Set(m.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,m.filter(e=>"none"===e.mark).map(e=>(0,t.jsx)(tu,{chip:e,labelKey:s.find(t=>t.labelId===e.labelId),isBusy:i,onUnassign:l,onChange:o},e.valueId)),h?(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,n.isAtLimit?null:(0,t.jsx)(th,{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]}),m.filter(t=>"none"!==t.mark&&t.ownerName===e).map(e=>(0,t.jsx)(ew.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)(tr.ChevronUp,{"aria-hidden":!0}),"Show fewer"]}):null,n.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===n.count?null:(0,t.jsx)("span",{className:"ml-auto text-meta text-muted-foreground tabular-nums","data-testid":"ship-labels-count",children:n.count})]}),void 0===r?null:(0,t.jsx)(Y.InlineError,{title:r.title,description:`Refused: ${r.message}. Nothing changed.`})]})}function tp(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 tx({ship:e}){let n=(0,es.useLabelContext)(),i=(0,Z.useAccess)(),r=(0,es.useAssignLabel)(),d=(0,es.useUnassignLabel)(),[l,o]=(0,a.useState)(void 0);if(void 0===n)return(0,t.jsx)(y.Skeleton,{className:"h-5.5 w-40"});let c=(0,en.chipsOf)(e,n);if(!(i.canAssignLabels&&"operator"!==e.kind&&"retired"!==e.status))return(0,t.jsx)(tn.ShipLabels,{chips:c});let u=(0,en.assignKeysOf)(e,n),h=e=>t=>{o({title:e,message:t.message})};return(0,t.jsx)(tm,{chips:c,keys:u,limit:(0,en.labelLimitOf)(e),isBusy:r.isPending||d.isPending,error:l,onAssign:t=>{o(void 0),r.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(t)},{onError:h(`Couldn’t add ${tp(u,t)}`)})},onUnassign:t=>{o(void 0),d.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(t)},{onError:h(`Couldn’t remove ${tp(u,t)}`)})},onChange:({from:t,to:n})=>{o(void 0);let a=(0,s.idSchema)("labelValue").parse(t);d.mutate({shipId:e.id,valueId:a},{onSuccess:()=>{r.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(n)},{onError:s=>{r.mutate({shipId:e.id,valueId:a}),h(`Couldn’t change ${tp(u,t)} to ${tp(u,n)}`)(s)}})},onError:h(`Couldn’t change ${tp(u,t)}`)})}})}var tg=e.i(87255),tf=e.i(31458);let tb={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"}]]};tb.node;let tj=(0,c.default)(tb),tv={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"}]]};tv.node;let tw=(0,c.default)(tv);var ty=e.i(67784);let tN={name:"mail-check",size:24,node:[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]};tN.node;let tk=(0,c.default)(tN),tC={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"}]]};tC.node;let tS=(0,c.default)(tC),tT={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"}]]};tT.node;let tq=(0,c.default)(tT),tR={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"}]]};tR.node;let tA=(0,c.default)(tR),tI={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"}]]};tI.node;let t$=(0,c.default)(tI),tD={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"]};tD.node;let tL=(0,c.default)(tD),tO={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"}]]};tO.node;let tz=(0,c.default)(tO);var tM=e.i(37817),tP=e.i(53341),tE=e.i(94661);function tB(e,t){let s=e.details[t];return"string"==typeof s?s:void 0}function tF(e){return tB(e,"key")??""}function t_(e){return(tB(e,"values")??"").split(",").join(", ")}function tV(e){return e?[(0,f.text)(" by "),(0,f.ship)(e)]:[]}let tH={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 tW(e){return null!==e.message&&(0,tP.isPingContentType)(e.message.contentType)}function tU(e){return e.message?[(0,f.text)(tW(e)?"a ping from ":"a message from "),(0,f.ship)(e.message.sender)]:[(0,f.text)("a message")]}function tK(e){let[t,...s]=tU(e);return t?.kind==="text"?[(0,f.text)((0,f.capitalised)(t.text)),...s]:tU(e)}function tG(e,t){let{shipId:s,verb:n}=t,a=e.actor;return[...null===a||a.id===s?[(0,f.text)((0,f.capitalised)(n))]:[(0,f.ship)(a),(0,f.text)(` ${n}`)],(0,f.text)(" "),...tU(e)]}let tY={received:E,sent:F,claimed:tw,released:ty.LogOut,prompt:eh.KeyRound,commissioned:tf.Flag,acknowledged:tk,returned:tM.Undo2,undeliverable:tq,secret:tj,fleet:tg.Anchor,password:tz,retired:eX.Archive,abandoned:t$,dismissed:tS,renamed:tL,reported:tA},tX={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"},tJ="flex w-full gap-3 px-3.5 py-3 text-left";function tQ({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,f.text)("Fleet initialised")],tone:"ended",icon:"fleet"};case"ShipCommissioned":{let t=tB(e,"type");return{parts:[(0,f.text)("Commissioned"),...tV(e.actor),...void 0===t?[]:[(0,f.text)(` as ${t}`)]],tone:"ended",icon:"commissioned"}}case"StartingPromptIssued":return{parts:[(0,f.text)("Starting prompt issued")],tone:"ended",icon:"prompt"};case"ShipClaimed":return{parts:[(0,f.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,T.locationKindWord)(s):"an unknown location"}(e)}`)],tone:"ok",icon:"claimed"};case"LeaseRevoked":let s,n;return{parts:[..."released"===(s=tB(e,"reason")??"")?[(0,f.text)("Released"),...tV(e.actor),(0,f.text)(".")]:[(0,f.text)(tH[s]??"Its session ended.")],..."number"==typeof(n=e.details.returnedDeliveries)&&n>0?[(0,f.text)(` ${(0,f.counted)(n,{one:"in-flight delivery",many:"in-flight deliveries"})} went back to pending.`)]:[]],tone:"waiting",icon:"released"};case"CredentialRevoked":return{parts:[(0,f.text)("Secret invalidated")],tone:"ended",icon:"secret"};case"OperatorPasswordReset":return{parts:[(0,f.text)("Operator password reset")],tone:"waiting",icon:"password"};case"FleetLimitsChanged":return{parts:[(0,f.text)("Fleet limits changed")],tone:"ended",icon:"fleet"};case"SignInTicketIssued":return{parts:[(0,f.text)("Sign-in ticket issued")],tone:"ended",icon:"password"};case"ViewerSessionStarted":return{parts:[(0,f.text)("Someone started viewing the fleet")],tone:"ended",icon:"password"};case"CrewRequested":return{parts:[(0,f.text)("Crew requested"),...tV(e.actor)],tone:"waiting",icon:"claimed"};case"CrewRequestRemoved":return{parts:[(0,f.text)("Crew request removed"),...tV(e.actor)],tone:"ended",icon:"released"};case"CrewRequestExplained":{let t=tB(e,"reason");return{parts:[(0,f.text)(void 0===t?"Crew request can not be placed yet":`Crew request can not be placed: ${t}`),...tV(e.actor)],tone:"waiting",icon:"reported"}}case"WorktreeClearRequested":return{parts:[(0,f.text)(`Clearing of the kept ${tB(e,"repository")??""} worktree requested`),...tV(e.actor)],tone:"waiting",icon:"reported"};case"WorktreeCleared":return{parts:[(0,f.text)("not-kept"===tB(e,"outcome")?`Kept ${tB(e,"repository")??""} worktree cleared (none was kept)`:`Kept ${tB(e,"repository")??""} worktree cleared`),...tV(e.actor)],tone:"ended",icon:"retired"};case"WorktreeClearRemoved":return{parts:[(0,f.text)(`Clearing of the kept ${tB(e,"repository")??""} worktree dropped`),...tV(e.actor)],tone:"ended",icon:"released"};case"CrewAssigned":return{parts:[(0,f.text)("Crew request assigned"),...tV(e.actor)],tone:"waiting",icon:"claimed"};case"CrewStatusChanged":{let t=tB(e,"status");return{parts:[(0,f.text)(void 0===t?"Crew status changed":`Crew ${t}`),...tV(e.actor)],tone:"crashed"===t?"attention":"active",icon:"reported"}}case"LabelDefined":return{parts:[(0,f.text)(`Label ${tF(e)} defined: ${t_(e)}`)],tone:"ended",icon:"reported"};case"LabelValuesChanged":return{parts:[(0,f.text)(`Label ${tF(e)} values changed: ${t_(e)}`)],tone:"ended",icon:"reported"};case"LabelRetired":return{parts:[(0,f.text)(`Label ${tF(e)} retired`)],tone:"ended",icon:"retired"};case"LabelDeleted":return{parts:[(0,f.text)(`Label ${tF(e)} deleted`)],tone:"ended",icon:"retired"};case"LabelAssigned":return{parts:[(0,f.text)(`Labelled ${tF(e)}=${tB(e,"value")??""}`),...tV(e.actor)],tone:"ended",icon:"reported"};case"LabelUnassigned":return{parts:[(0,f.text)(`Label ${tF(e)}=${tB(e,"value")??""} removed`),...tV(e.actor)],tone:"ended",icon:"reported"};case"MessageAccepted":let a;return{parts:(a=e.message)?tW(e)&&"ship"===a.recipient.kind?a.sender.id===t?[(0,f.text)("Pinged "),(0,f.ship)(a.recipient.ship)]:[(0,f.text)("Pinged by "),(0,f.ship)(a.sender)]:a.sender.id===t?"ship"===a.recipient.kind?[(0,f.text)("Sent a message to "),(0,f.ship)(a.recipient.ship)]:[(0,f.text)(`Sent a message to any ship of type ${a.recipient.type}`)]:[(0,f.text)("Received a message from "),(0,f.ship)(a.sender)]:[(0,f.text)("A message was sent")],tone:"ended",icon:e.message?.sender.id===t?"sent":"received"};case"DeliveryClaimed":return{parts:tG(e,{shipId:t,verb:"took"}),tone:"active",icon:"received"};case"DeliveryAcknowledged":return{parts:"pong"===tB(e,"answer")?[...tG(e,{shipId:t,verb:"answered"}),(0,f.text)(" with pong")]:tG(e,{shipId:t,verb:"acknowledged"}),tone:"ok",icon:"acknowledged"};case"DeliveryReturned":return{parts:[...tK(e),(0,f.text)(" went back to pending")],tone:"waiting",icon:"returned"};case"DeliveryUndeliverable":return{parts:[...tK(e),(0,f.text)(" became undeliverable")],tone:"attention",icon:"undeliverable"};case"ShipRetired":{let t=e.details.abandonedDeliveries;return{parts:[(0,f.text)("Retired"),...tV(e.actor),(0,f.text)("."),..."number"==typeof t&&t>0?[(0,f.text)(` ${(0,f.counted)(t,{one:"delivery",many:"deliveries"})} abandoned.`)]:[]],tone:"ended",icon:"retired"}}case"DeliveryAbandoned":return{parts:[...tK(e),(0,f.text)(" was abandoned")],tone:"ended",icon:"abandoned"};case"ShipReported":{let t=tB(e,"state")??"in",s=tB(e,"note");return{parts:[(0,f.text)(void 0===s?`Reported ${t}`:`Reported ${t}: ${s}`)],tone:tE.REPORT_STATES.some(e=>e===t)?e4.REPORT_TONES[t]:"ended",icon:"reported"}}case"ShipRenamed":{let t=tB(e,"from"),s=tB(e,"to");return{parts:[(0,f.text)(void 0===t||void 0===s?"Renamed":`Renamed from ${t} to ${s}`),...tV(e.actor)],tone:"ended",icon:"renamed"}}case"DeliveryDismissed":return{parts:[...tK(e),(0,f.text)(" was dismissed"),...tV(e.actor)],tone:"ended",icon:"dismissed"}}}(e,s),l=tY[d],o=new Date(e.occurredAt),c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":!0,className:(0,W.classNames)("flex size-7 shrink-0 items-center justify-center rounded-md border [&_svg]:size-(--size-icon-sm)",tX[r]),children:(0,t.jsx)(l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(C,{parts:i,className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)("time",{dateTime:e.occurredAt,title:(0,g.fullDateTime)(o),className:"text-meta text-muted-foreground tabular-nums",children:(0,g.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,W.classNames)(tJ,"transition-colors duration-(--duration-fast) hover:bg-accent"),onClick:()=>{a(u.id)},children:c}):(0,t.jsx)("div",{className:tJ,children:c})})}function tZ({shipId:e,entries:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(X.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)(Y.InlineError,{title:"Couldn’t load the timeline",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(j.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)(tQ,{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 t0=e.i(274),t1=e.i(46929),t2=e.i(86413),t5=e.i(18423),t3=e.i(28459),t7=e.i(96676),t4=e.i(9176),t6=e.i(88721),t8=e.i(78485),t9=e.i(53573),se=e.i(3979);let st="timeline",ss="messages";function sn(e){return Array.isArray(e)?e[0]:e}function sa({shipId:e,searchParams:c}){let u=(0,n.useRouter)(),h=(0,t7.useNow)(),m=(0,t4.usePluginShipIds)(),p=sn(c.tab)===ss?ss:st,x=(0,s.idSchema)("message").safeParse(sn(c.message)),g=x.success?x.data:void 0,f=(0,t9.useShip)(e),b=(0,t9.useShipTimeline)(e),j=(0,t9.useShipMessages)(e),v=(0,t9.useMessage)(g),w=(0,t5.useLiveFleet)(),y=(0,t6.useAccountMenu)(h),N=(0,eD.useSquadrons)(),k=(0,t2.useOpenInboxCount)(),C=(0,Z.useAccess)(),S=(0,se.usePluginNav)(),[T,q]=(0,a.useState)(!1),[R,A]=(0,a.useState)(!1),[I,$]=(0,a.useState)(),D=(0,t3.useAttentionCount)();(0,t8.useSignInWhenSessionEnds)([f.error,b.error,j.error,v.error,w.error]);let L=t=>{let s,n;u.replace((s=new URLSearchParams,t.tab!==st&&s.set("tab",t.tab),void 0!==t.messageId&&s.set("message",t.messageId),""===(n=s.toString())?`/ships/${e}`:`/ships/${e}?${n}`),{scroll:!1})},O=e=>{L({tab:p,messageId:e})},z="NOT_FOUND"===(0,t1.trpcErrorCode)(f.error),P=(0,eH.shipsInSquadrons)(N.data??[]).get(e);return(0,t.jsx)(t0.DetailLayout,{title:f.data?.name??"Ship",parents:P?[{href:"/squadrons",label:"Squadrons"},{href:`/squadrons/${P.squadronId}`,label:P.squadronId}]:[{href:"/",label:"Fleet overview"}],live:w.live,nav:{active:"overview",inboxCount:k,attentionCount:D,...S},onCompose:C.canSend?()=>{q(!0)}:void 0,onSearch:()=>{A(!0)},account:y,banner:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.ConsoleNotices,{}),(0,t.jsx)(l.ConsoleGuide,{})]}),header:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ts,{ship:f.data,shipId:e,state:z?"not-found":f.data?"ready":"loading",now:h,actions:f.data?(0,t.jsx)(eG.ShipActions,{ship:f.data}):void 0,crewRequest:f.data?(0,t.jsx)(eV,{ship:f.data,timeline:b.data??[],now:h}):void 0,labels:f.data?(0,t.jsx)(tx,{ship:f.data}):void 0,isPluginShip:m.has(e)}),z?null:(0,t.jsx)(eK,{shipId:e,now:h})]}),sheet:(0,t.jsx)(M,{message:v.data,messageId:g,state:"NOT_FOUND"===(0,t1.trpcErrorCode)(v.error)?"not-found":v.data?"ready":"loading",isOpen:void 0!==g,onOpenChange:e=>{e||L({tab:p})},onReply:C.canSend?e=>{$({messageId:e.id,sender:e.sender})}:void 0}),children:(0,t.jsxs)(t.Fragment,{children:[z?null:(0,t.jsxs)(i.Tabs,{value:p,onValueChange:e=>{L({tab:e===ss?ss:st,messageId:g})},children:[(0,t.jsxs)(i.TabsList,{variant:"line","aria-label":`${f.data?.name??"Ship"} history`,children:[(0,t.jsx)(i.TabsTrigger,{variant:"line",value:st,children:"Timeline"}),(0,t.jsx)(i.TabsTrigger,{variant:"line",value:ss,children:"Messages"})]}),(0,t.jsx)(i.TabsContent,{value:st,className:"pt-4",children:(0,t.jsx)(tZ,{shipId:e,entries:b.data??[],state:b.isError?"error":b.data?"ready":"loading",onRetry:()=>{b.refetch()},now:h,onOpenMessage:O})}),(0,t.jsx)(i.TabsContent,{value:ss,className:"pt-4",children:(0,t.jsx)(Q,{shipId:e,messages:j.data??[],state:j.isError?"error":j.data?"ready":"loading",onRetry:()=>{j.refetch()},now:h,onOpenMessage:O})})]}),(0,t.jsx)(r.ComposeMessage,{isOpen:T,onOpenChange:q}),(0,t.jsx)(r.ComposeMessage,{isOpen:void 0!==I,onOpenChange:e=>{e||$(void 0)},replyTo:I}),(0,t.jsx)(d.ConsoleCommands,{isOpen:R,onOpenChange:A,onCompose:()=>{q(!0)}})]})})}e.s(["default",0,function({params:e,searchParams:n}){let i=(0,s.idSchema)("ship").safeParse((0,a.use)(e).shipId),r=(0,a.use)(n),d=i.success?i.data:(0,s.idSchema)("ship").parse(`shp_${"0".repeat(26)}`);return(0,t.jsx)(sa,{shipId:d,searchParams:r})}],21607)}]);
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,21607,e=>{"use strict";var t=e.i(43476);e.i(31627);var s=e.i(83615),n=e.i(18566),a=e.i(71645),i=e.i(60592),r=e.i(44824),d=e.i(45608),l=e.i(95475),o=e.i(2767),c=e.i(56420);let u={name:"mail-question-mark",size:24,node:[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]],aliases:["mail-question"]};u.node;let h=(0,c.default)(u),m={name:"reply",size:24,node:[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]};m.node;let p=(0,c.default)(m);var x=e.i(69693),g=e.i(49635),f=e.i(46150),b=e.i(91703),j=e.i(15905),v=e.i(61966),w=e.i(75305),y=e.i(19321),N=e.i(67874),k=e.i(39448);function C({parts:e,className:s}){let n;return(0,t.jsx)("span",{className:s,children:(n=new Map,e.map(e=>{let t="text"===e.kind?`text:${e.text}`:`ship:${e.party.id}`,s=n.get(t)??0;return n.set(t,s+1),{key:`${t}#${String(s)}`,part:e}})).map(({key:e,part:s})=>"text"===s.kind?(0,t.jsx)("span",{children:s.text},e):(0,t.jsx)(k.ShipName,{name:s.party.name,shipId:s.party.id,isSuffixShown:s.party.name!==f.OPERATOR_NAME,className:"align-baseline"},e))})}var S=e.i(78865),T=e.i(40798);function q(e){return e.ship?[(0,f.ship)(e.ship)]:[(0,f.text)("a ship")]}var R=e.i(66390);function A({entries:e,recipient:s}){return(0,t.jsx)("ol",{"data-testid":"delivery-history","aria-label":"Delivery history",className:"flex flex-col",children:e.map((n,a)=>{let i=new Date(n.occurredAt);return(0,t.jsxs)("li",{"data-testid":"delivery-history-entry","data-type":n.type,className:"relative flex gap-3 pb-4 last:pb-0",children:[(0,t.jsxs)("span",{"aria-hidden":!0,className:"relative flex w-3 shrink-0 justify-center",children:[(0,t.jsx)("span",{className:"mt-1.5 size-2.5 rounded-full border-2 border-muted-foreground bg-card"}),a<e.length-1?(0,t.jsx)("span",{className:"absolute top-5 bottom-[-0.25rem] w-px bg-border"}):null]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(S.StatusBadge,{status:function(e){switch(e.type){case"MessageAccepted":case"DeliveryReturned":return"pending";case"DeliveryClaimed":return"delivered";case"DeliveryAcknowledged":return"acknowledged";case"DeliveryUndeliverable":return"undeliverable";case"DeliveryAbandoned":return"abandoned";case"DeliveryDismissed":return"dismissed"}}(n)}),(0,t.jsx)("time",{dateTime:n.occurredAt,title:(0,g.fullDateTime)(i),className:"font-mono text-id text-muted-foreground tabular-nums",children:(0,g.secondsTime)(i)}),0===a?(0,t.jsx)(R.Badge,{variant:"outline",children:"Current"}):null]}),(0,t.jsx)(C,{parts:function(e,t){switch(e.type){case"MessageAccepted":return"ship"===t.kind?[(0,f.text)("Stored in the inbox of "),(0,f.ship)(t.ship),(0,f.text)(".")]:[(0,f.text)(`Queued for any ship of type ${t.type}.`)];case"DeliveryClaimed":{let t=null!==e.attempts&&e.attempts>1?`Attempt ${String(e.attempts)}: claimed`:"Claimed";return[(0,f.text)(`${t} by `),...q(e),...function(e){if(null===e)return[];let t=null!==e.description&&""!==e.description?e.description:(0,T.locationKindWord)(e.kind);return[(0,f.text)(`, session on ${t}`)]}(e.location),(0,f.text)(".")]}case"DeliveryReturned":return"ship"===t.kind?[(0,f.text)("Back in the inbox: the session of "),...q(e),(0,f.text)(" ended before acknowledging it.")]:[(0,f.text)("Returned to the queue: the session of "),...q(e),(0,f.text)(" ended before acknowledging it.")];case"DeliveryAcknowledged":return[(0,f.text)("Acknowledged by "),...q(e),(0,f.text)(".")];case"DeliveryUndeliverable":return[(0,f.text)(null===e.attempts?"Never acknowledged: no ship takes it automatically any more.":`Received ${String(e.attempts)} times, never acknowledged.`)];case"DeliveryAbandoned":return[(0,f.text)("Abandoned: "),...q(e),(0,f.text)(" was retired before taking it.")];case"DeliveryDismissed":return[(0,f.text)("Dismissed by the operator: no ship takes it any more.")]}}(n,s),className:"text-meta text-muted-foreground max-sm:text-body-touch"})]})]},n.seq)})})}let I="text-section font-semibold text-foreground";function $({label:e,children:s}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-3 py-2 last:border-b-0",children:[(0,t.jsx)("dt",{className:"w-24 shrink-0 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 D({message:e}){let s=e.recipient;return(0,t.jsxs)("dl",{"aria-label":"Envelope",className:"overflow-hidden rounded-lg border border-border bg-card",children:[(0,t.jsxs)($,{label:"Message id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(v.CopyButton,{value:e.id,label:"Copy message id"})]}),(0,t.jsx)($,{label:"From",children:(0,t.jsx)(k.ShipName,{name:e.sender.name,shipId:e.sender.id,isSuffixShown:e.sender.name!==f.OPERATOR_NAME})}),(0,t.jsx)($,{label:"To",children:"ship"===s.kind?(0,t.jsx)(k.ShipName,{name:s.ship.name,shipId:s.ship.id,isSuffixShown:s.ship.name!==f.OPERATOR_NAME}):(0,t.jsxs)("span",{children:["Any ship of type ",(0,t.jsx)("span",{className:"font-mono text-id",children:s.type})]})}),(0,t.jsx)($,{label:"Sent",children:(0,t.jsx)("time",{dateTime:e.sentAt,className:"tabular-nums",children:(0,g.fullDateTime)(new Date(e.sentAt))})}),null===e.model?null:(0,t.jsx)($,{label:"Model",children:(0,t.jsx)("span",{className:"truncate font-mono text-id","data-testid":"message-model",children:e.model})}),e.inReplyTo?(0,t.jsx)($,{label:"In reply to",children:(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.inReplyTo})}):null]})}function L({message:e}){let s=(0,x.payloadLabel)(e.payload,e.contentType),n=(0,x.formattedPayload)(e.payload,e.contentType),a=(0,t.jsx)(b.CodeBlock,{label:s,code:e.payload,isWrapped:!0,copyLabel:"Copy payload",codeTestId:"message-payload"});return void 0===n?(0,t.jsxs)("section",{"aria-label":"Payload",className:"flex flex-col gap-2",children:[(0,t.jsx)("h3",{className:I,children:"Payload"}),a]}):(0,t.jsx)("section",{"aria-label":"Payload",className:"flex flex-col gap-2",children:(0,t.jsxs)(i.Tabs,{defaultValue:"formatted",className:"gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:I,children:"Payload"}),(0,t.jsxs)(i.TabsList,{className:"max-sm:w-auto",children:[(0,t.jsx)(i.TabsTrigger,{value:"formatted",children:"Formatted"}),(0,t.jsx)(i.TabsTrigger,{value:"raw",children:"Raw"})]})]}),(0,t.jsx)(i.TabsContent,{value:"formatted",children:(0,t.jsx)(b.CodeBlock,{label:s,code:n,copyValue:e.payload,copyLabel:"Copy payload",codeTestId:"message-payload"})}),(0,t.jsx)(i.TabsContent,{value:"raw",children:a})]})})}function O({message:e}){return(0,t.jsxs)("section",{"aria-label":"Delivery",className:"flex flex-col gap-2 max-sm:order-first",children:[(0,t.jsx)("h3",{className:I,children:"Delivery"}),(0,t.jsx)("div",{className:"rounded-lg border border-border bg-card p-3",children:(0,t.jsx)(A,{entries:e.delivery.history,recipient:e.recipient})})]})}function z(){return(0,t.jsxs)("div",{"aria-busy":!0,className:"flex flex-col gap-4",children:[(0,t.jsx)("span",{className:"sr-only",children:"Loading the message"}),(0,t.jsx)(y.Skeleton,{className:"h-32 w-full rounded-lg"}),(0,t.jsx)(y.Skeleton,{className:"h-28 w-full rounded-lg"}),(0,t.jsx)(y.Skeleton,{className:"h-40 w-full rounded-lg"})]})}function M({message:e,messageId:s,state:n,isOpen:a,onOpenChange:i,onReply:r}){let d="ready"===n&&void 0!==e;return(0,t.jsx)(w.Sheet,{open:a,onOpenChange:i,children:(0,t.jsxs)(w.SheetContent,{side:"right","data-testid":"message-sheet",children:[(0,t.jsx)(w.SheetHeader,{children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(w.SheetTitle,{className:"flex min-w-0 items-baseline gap-1.5",children:[(0,t.jsx)("span",{children:"Message from"}),(0,t.jsx)(k.ShipName,{name:e.sender.name,shipId:e.sender.id,isSuffixShown:e.sender.name!==f.OPERATOR_NAME,className:"text-heading"})]}),(0,t.jsxs)(w.SheetDescription,{children:[(0,t.jsx)(C,{parts:"ship"===e.recipient.kind?[(0,f.text)("To "),(0,f.ship)(e.recipient.ship)]:[(0,f.text)(`To any ship of type ${e.recipient.type}`)]}),". ",(0,S.statusLabel)(e.delivery.state),"."]}),r&&e.sender.name!==f.OPERATOR_NAME?(0,t.jsx)("div",{children:(0,t.jsxs)(j.Button,{size:"xs",icon:(0,t.jsx)(p,{}),"data-testid":"message-reply",onClick:()=>{r(e)},children:["Reply to ",e.sender.name]})}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.SheetTitle,{children:"Message"}),(0,t.jsx)(w.SheetDescription,{children:"not-found"===n?"Couldn’t open this message":"Loading"})]})}),(0,t.jsxs)(w.SheetBody,{className:"flex flex-col gap-5",children:["loading"===n?(0,t.jsx)(z,{}):null,"not-found"===n?(0,t.jsx)(N.EmptyState,{variant:"section",icon:(0,t.jsx)(h,{}),title:"Message not found",description:(0,t.jsxs)(t.Fragment,{children:["No message with this id exists in this fleet, or the link is incomplete.",s?(0,t.jsx)("span",{className:"mt-2 block font-mono text-id",children:s}):null]})}):null,d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D,{message:e}),(0,t.jsx)(L,{message:e}),(0,t.jsx)(O,{message:e})]}):null]})]})})}let P={name:"arrow-down-left",size:24,node:[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]};P.node;let E=(0,c.default)(P),B={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};B.node;let F=(0,c.default)(B),_={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"}]]};_.node;let V=(0,c.default)(_);var H=e.i(25398),W=e.i(90063);function U(e,t){return RegExp(`"${t}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`).exec(e)?.[1]}let G={"application/vnd.aeolus.squadron.check-in+json":()=>"Checked in at its flagship","application/vnd.aeolus.squadron.role+json":e=>{let t=U(e,"role");return void 0===t?"Given its role":`Given the role: ${t}`},"application/vnd.aeolus.squadron.on-station+json":e=>{let t=U(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"};function K(e,t){return e.sentAt.localeCompare(t.sentAt)||e.id.localeCompare(t.id)}var Y=e.i(17981),X=e.i(88393);function J({message:e,shipId:s,now:n,onOpenMessage:a}){var i,r,d;let l,o,c=e.sender.id===s,u=new Date(e.sentAt),h=void 0!==(o=G[r=(i=e).contentType,r.split(";")[0]?.trim().toLowerCase()??""])?{text:o(i.preview),isCode:!1}:(0,x.isJson)(i.contentType)?{text:0===(l=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:l.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":`${c?"Sent":"Received"} message: ${h.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)(c?F:E,{})}),(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)(C,{parts:c?"ship"===e.recipient.kind?[(0,f.text)("To "),(0,f.ship)(e.recipient.ship)]:[(0,f.text)(`To any ship of type ${e.recipient.type}`)]:[(0,f.text)("From "),(0,f.ship)(e.sender)],className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)(S.StatusBadge,{status:e.delivery.state})]}),(0,t.jsx)("span",{"data-testid":"message-line",className:(0,W.classNames)("truncate text-muted-foreground",h.isCode?"font-mono text-id":"text-meta"),children:h.text}),(0,t.jsx)("time",{dateTime:e.sentAt,title:(0,g.fullDateTime)(u),className:"text-meta text-muted-foreground tabular-nums",children:(0,g.relativeTime)(u,n)})]})]})})}function Q({shipId:e,messages:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(X.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)(Y.InlineError,{title:"Couldn’t load the messages",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(j.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)(V,{}),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(K);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)(J,{message:s,shipId:e,now:i,onOpenMessage:r},s.id))})},s.id))})}var Z=e.i(90262),ee=e.i(54492),et=e.i(10649),es=e.i(5387),en=e.i(80581),ea=e.i(78608),ei=e.i(84156),er=e.i(265),ed=e.i(41880),el=e.i(4510),eo=e.i(9677),ec=e.i(16984),eu=e.i(74544),eh=e.i(58925),em=e.i(18964),ep=e.i(11568),ex=e.i(68997),eg=e.i(57665),ef=e.i(95925),eb=e.i(86875),ej=e.i(22016),ev=e.i(66616),ew=e.i(95960);let ey={request:"Couldn’t request crew",remove:"Couldn’t remove the request",restart:"Couldn’t restart the crew"};function eN({at:e,now:s,children:n}){return(0,t.jsx)("time",{dateTime:e,title:(0,g.fullDateTime)(new Date(e)),className:"tabular-nums",children:n??(0,g.sinceTime)(new Date(e),s)})}function ek({trierarch:e,hasTrierarchs:s}){return(0,t.jsxs)(ej.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)(eb.ShipWheel,{"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e.name})]})}function eC({requestedBy:e,requestedAt:s,now:n}){let a=null===e?null:e.name===f.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)(eN,{at:s,now:n,children:(0,g.relativeTime)(new Date(s),n)}),"."]})}let eS={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 eT({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 ${eS[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function eq({stage:e,now:s}){let n="running"===e.status?e.startedAt:null,a=(0,ee.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)(eN,{at:n,now:s})]}),null!==n&&void 0!==a?" · ":null,a]})}function eR({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,ev.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)(a.Fragment,{children:[0===s?null:(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:"and"}),(0,t.jsx)(ew.LabelChip,{chip:e})]},e.valueId))})]})]})}function eA(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(em.ListChecks,{"aria-hidden":!0,className:"size-(--size-icon) text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-section font-semibold",children:"Crew request"})]})}function eI(e){let{stage:s,requestedBy:n,now:a,canManage:i,isAwaitingCrew:r,busy:d,error:l}=e,o=void 0===l?null:(0,t.jsx)(Y.InlineError,{title:ey[l.action],description:`${l.message} Nothing changed.`});if("none"===s.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)(eA,{}),(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."}),i?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(em.ListChecks,{}),isLoading:"request"===d,onClick:e.onRequest,"data-testid":"crew-request-request",children:"Request crew"}):null]}),o]});let c=(0,ee.crewRequestAction)(s),u=void 0!==d;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)(eA,{}),(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-2","data-testid":"crew-request-state",children:["assigned"===s.kind?(0,t.jsx)(S.StatusBadge,{status:s.status}):(0,t.jsx)(S.StatusBadge,{status:s.kind}),"needsCrew"===s.kind?(0,t.jsx)("span",{className:"text-meta text-muted-foreground",children:e.hasTrierarchs?"not assigned yet":s.reason??(0,t.jsxs)(t.Fragment,{children:["since ",(0,t.jsx)(eN,{at:s.requestedAt,now:a})]})}):null,"crewedByHand"===s.kind&&null!==s.since?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["since ",(0,t.jsx)(eN,{at:s.since,now:a})]}):null,"assigned"===s.kind?(0,t.jsx)(eq,{stage:s,now:a}):null,"assigned"===s.kind&&"releasing"===s.status&&void 0!==e.statusChangedAt?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["asked ",(0,t.jsx)(eN,{at:e.statusChangedAt,now:a})]}):null]}),"assigned"===s.kind?(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 text-meta",children:["on ",(0,t.jsx)(ek,{trierarch:s.trierarch,hasTrierarchs:e.hasTrierarchs??!1})]}):null,(0,t.jsx)("span",{className:"flex-1"}),"assigned"===s.kind&&"releasing"===s.status?(0,t.jsxs)("span",{className:"text-meta text-muted-foreground",children:["Waiting for ",s.trierarch.name]}):null,i?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["remove"===c?(0,t.jsx)(j.Button,{size:"sm",variant:"ghost",isLoading:"remove"===d,disabled:u,onClick:e.onRemove,"data-testid":"crew-request-remove",children:"Remove request"}):null,(0,ee.isRestartable)(s)?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(ef.RotateCcw,{}),isLoading:"restart"===d,disabled:u,onClick:e.onRestart,"data-testid":"crew-request-restart",children:"Restart"}):null,void 0!==e.onEdit&&void 0!==c?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(ex.Pen,{}),disabled:u,onClick:e.onEdit,"data-testid":"crew-request-edit",children:"Edit…"}):null,"release"===c?(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(eg.Power,{}),disabled:u,onClick:e.onRelease,"data-testid":"crew-request-release",children:"Release…"}):null,"needsCrew"===s.kind&&r&&!e.hasTrierarchs?(0,t.jsx)(j.Button,{size:"sm",variant:"primary",icon:(0,t.jsx)(eh.KeyRound,{}),disabled:u,onClick:e.onGetStartingPrompt,"data-testid":"crew-request-prompt",children:"Get starting prompt"}):null]}):null]}),"assigned"===s.kind?function(e,s){let{trierarch:n}=e,a=void 0===s.statusChangedAt?null:(0,t.jsx)(eN,{at:s.statusChangedAt,now:s.now});switch(e.status){case"crewing":return(0,t.jsxs)(eT,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0}),children:[n.name," is starting the session."]});case"running":return null;case"restarting":return(0,t.jsxs)(eT,{tone:"waiting",icon:(0,t.jsx)(ef.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)(eT,{tone:"attention",icon:(0,t.jsx)(ec.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)(eT,{tone:"note",icon:(0,t.jsx)(eg.Power,{"aria-hidden":!0}),children:["Releasing: ",n.name," is stopping the session and cleaning up. The request goes away once it confirms."]})}}(s,{statusChangedAt:e.statusChangedAt,now:a}):null,"needsCrew"===s.kind&&e.hasTrierarchs?null===s.reason?(0,t.jsx)(eT,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0}),children:"Waiting for the trierarch plugin to assign a trierarch."}):s.reason===eo.NO_MACHINE_MATCHES_REASON&&void 0!==e.machineLabels&&e.machineLabels.length>0?(0,t.jsxs)(eT,{tone:"waiting",icon:(0,t.jsx)(eu.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,ea.machineLabelsText)(e.machineLabels),", and none"," ",(0,ea.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)(eT,{tone:"waiting",icon:(0,t.jsx)(eu.Clock,{"aria-hidden":!0}),children:[(0,t.jsxs)("strong",{className:"font-medium",children:[(0,f.capitalised)(s.reason),"."]})," The plugin assigns a trierarch as soon as one fits. Until then this ship is on Needs crew."]}):null,o,void 0===e.settingsRows?null:(0,t.jsx)(eR,{rows:e.settingsRows,machineLabels:e.machineLabels}),(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["needsCrew"!==s.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"===s.kind?`${s.crewedBy.name===f.OPERATOR_NAME?"You":s.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)(eC,{requestedBy:n,requestedAt:s.requestedAt,now:a}),"assigned"===s.kind&&"releasing"!==s.status?" The trierarch keeps it crewed until you release it.":null]})]})}var e$=e.i(86165),eD=e.i(48695),eL=e.i(22212),eO=e.i(94945),ez=e.i(75774);let eM={request:{title:e=>`Request a crew for ${e}`,description:"The trierarch plugin picks a trierarch, which starts the session and keeps it crewed.",action:"Request crew",busy:"Requesting"},edit:{title:e=>`Edit the crew request for ${e}`,description:"Saving writes a new version of the settings: its trierarch stops the session and starts it again with them, in the same workspace.",action:"Save and restart",busy:"Saving"}},eP={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",note:"border-border bg-muted text-muted-foreground"};function eE({tone:e,icon:s,children:n}){return(0,t.jsxs)("div",{role:"attention"===e?"alert":"status","data-testid":"request-crew-banner",className:`flex items-start gap-2 rounded-lg border px-3.5 py-2.5 text-meta [&_svg]:mt-0.5 [&_svg]:size-(--size-icon-sm) [&_svg]:shrink-0 ${eP[e]}`,children:[s,(0,t.jsx)("span",{children:n})]})}function eB(e){let{shipName:s,mode:n,offers:i,heldSettings:r,squadrons:d,machineLabels:l,check:o,refusedAt:c,error:u,isPending:h,onSettingsChange:m,onSubmit:p}=e,x=eM[n],[f,b]=(0,a.useState)(()=>"edit"===n?(0,et.valuesOf)(r,i):(0,et.defaultValues)(i)),v=(0,et.settingsOf)(f),w=o?.kind==="refused"?o:void 0,y=(0,et.promptBytes)(f.firstPrompt)>eo.FIRST_PROMPT_MAX_BYTES,N=f.machineLabels.length>0&&l?.matchOf(f.machineLabels).matching.length===0,k=void 0!==v&&void 0===w&&!y&&!h;return(0,t.jsxs)("form",{noValidate:!0,className:"contents",onSubmit:e=>{e.preventDefault(),k&&p(v)},children:[(0,t.jsxs)(eL.DialogHeader,{children:[(0,t.jsx)(eL.DialogTitle,{children:x.title(s)}),(0,t.jsx)(eL.DialogDescription,{children:x.description})]}),0===i.length?(0,t.jsx)(eE,{tone:"waiting",icon:(0,t.jsx)(eb.ShipWheel,{"aria-hidden":!0}),children:"No machine answers with what it offers yet. Join a machine under Trierarchs, or wait for its trierarch to report."}):void 0!==w&&void 0!==c?(0,t.jsxs)(eE,{tone:"attention",icon:(0,t.jsx)(ec.CircleX,{"aria-hidden":!0}),children:["The trierarch plugin refused: ",w.field,". Nothing was requested. Change the field below and try again."]}):o?.kind!=="noRoom"||N?null:(0,t.jsx)(eE,{tone:"waiting",icon:(0,t.jsx)(eu.Clock,{"aria-hidden":!0}),children:"No trierarch has a free slot right now. You can still request: the request waits on Needs crew and the plugin assigns a trierarch when a slot frees up."}),0===i.length?null:(0,t.jsx)(ez.CrewSettingsFields,{offers:i,values:f,onChange:e=>{b(e),m((0,et.settingsOf)(e))},squadrons:d,refusal:w,isDisabled:h,...void 0===l?{}:{machineLabels:{...l,shipName:s}}}),void 0===u?null:(0,t.jsx)(Y.InlineError,{title:"edit"===n?"Couldn’t save the settings":"Couldn’t request crew",description:`${u} Nothing changed.`}),(0,t.jsxs)(eL.DialogFooter,{className:"items-center",children:[(0,t.jsx)("span",{className:"mr-auto text-meta text-muted-foreground","data-testid":"request-crew-note",children:void 0!==w&&void 0!==c?`Refused at ${(0,g.secondsTime)(c)}. Nothing was requested.`:N?"The request will wait for a machine with these labels.":o?.kind==="noRoom"?"The request will wait for room.":null}),(0,t.jsx)(eL.DialogClose,{render:(0,t.jsx)(j.Button,{type:"button",disabled:h}),children:"Cancel"}),(0,t.jsx)(j.Button,{type:"submit",variant:"primary",icon:(0,t.jsx)(eb.ShipWheel,{}),isLoading:h,disabled:!k,"data-testid":"request-crew-submit",children:h?x.busy:x.action})]})]})}function eF(e){let{shipName:s,mode:n,state:a,isOpen:i,onOpenChange:r,isPending:d,onRetry:l}=e,o=eM[n];return(0,t.jsx)(eL.Dialog,{open:i,onOpenChange:e=>{d||r(e)},children:(0,t.jsx)(eL.DialogContent,{size:"md","data-testid":"request-crew-dialog",className:eO.dialogSurface.phoneFullScreen,children:"ready"===a?(0,t.jsx)(eB,{...e}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eL.DialogHeader,{children:[(0,t.jsx)(eL.DialogTitle,{children:o.title(s)}),(0,t.jsx)(eL.DialogDescription,{children:o.description})]}),"loading"===a?(0,t.jsx)(eE,{tone:"note",icon:(0,t.jsx)(ep.LoaderCircle,{"aria-hidden":!0,className:"motion-safe:animate-spin"}),children:"Loading the trierarch plugin’s options."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eE,{tone:"attention",icon:(0,t.jsx)(ec.CircleX,{"aria-hidden":!0}),children:"The trierarch plugin is not answering. Its options can’t load, so a request with settings can’t be made now. Nothing changed."}),(0,t.jsx)("div",{children:(0,t.jsx)(j.Button,{size:"sm",icon:(0,t.jsx)(H.RotateCw,{}),onClick:l,"data-testid":"request-crew-retry",children:"Try again"})}),"request"===n?(0,t.jsxs)("p",{className:"text-meta text-muted-foreground",children:["You can still crew ",s," by hand: close this and use Get starting prompt."]}):null]}),(0,t.jsxs)(eL.DialogFooter,{className:"items-center",children:[(0,t.jsx)("span",{className:"mr-auto text-meta text-muted-foreground",children:"loading"===a?"Waiting for the trierarch plugin.":`${o.action} is off until the plugin answers.`}),(0,t.jsx)(eL.DialogClose,{render:(0,t.jsx)(j.Button,{type:"button"}),children:"Cancel"}),(0,t.jsx)(j.Button,{type:"button",variant:"primary",icon:(0,t.jsx)(eb.ShipWheel,{}),disabled:!0,children:o.action})]})]})})})}var e_=e.i(82532);function eV({ship:e,timeline:s,now:n}){let i=(0,Z.useAccess)(),r=(0,er.useHasTrierarchPlugin)(),d=(0,es.useRequestCrew)(),l=(0,es.useLabelContext)(),o=(0,es.useRemoveCrewRequest)(),c=(0,es.useReleaseShip)(),u=(0,es.useGetStartingPrompt)(),[h,m]=(0,a.useState)(),[p,x]=(0,a.useState)(),[g,f]=(0,a.useState)(!1),[b,j]=(0,a.useState)(),[v,w]=(0,a.useState)(!1),[y,N]=(0,a.useState)(),k=function(e){let s=(0,er.useMachines)(),n=(0,e$.useSquadronsConnection)(),i=(0,eD.useSquadrons)(),r=(0,es.useRequestCrew)(),d=(0,es.useLabelContext)(),[l,o]=(0,a.useState)(),[c,u]=(0,a.useState)(null),[h,m]=(0,a.useState)(),p=(0,et.offersOf)(s.data??[]),x=void 0===d||void 0===s.data?void 0:(0,ea.machineLabelsInputOf)(d,s.data),g=(0,et.settingsOf)("edit"===l?(0,et.valuesOf)(e?.heldSettings,p):(0,et.defaultValues)(p)),f=void 0!==l&&void 0!==e,b=(0,er.useCrewSettingsCheck)(f&&void 0!==s.data?null===c?g:c:void 0),j=async t=>{if(void 0!==e&&void 0!==l){r.reset();try{let e=await b.checkNow();if("refused"===e.kind)return void m(new Date)}catch{}r.mutate({shipId:e.shipId,settings:t},{onSuccess:()=>{o(void 0),(0,ed.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),m(void 0),o(e)},dialog:void 0===e?null:(0,t.jsx)(eF,{shipName:e.shipName,mode:l??"request",state:s.isError?"unreachable":void 0===s.data?"loading":"ready",offers:p,heldSettings:e.heldSettings,squadrons:"connected"===n?(i.data??[]).filter(e=>"disbanded"!==e.state).map(e=>e.id):void 0,...void 0===x?{}:{machineLabels:x},check:b.data,refusedAt:h,error:r.error?.message,isPending:r.isPending,isOpen:f,onOpenChange:e=>{e||o(void 0)},onSettingsChange:e=>{u(e),m(void 0)},onSubmit:e=>void j(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 C=(0,ee.crewRequestStage)(e),S=e.crewRequest,T=async(e,t)=>{m(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{m(void 0)}},q=()=>{u.reset(),N((0,ei.isUnclaimedPromptOut)(e)&&e.startingPrompt?{issuedAt:e.startingPrompt.issuedAt}:void 0),w(!0),u.mutate({shipId:e.id})},R=async()=>{await T("request",()=>d.mutateAsync({shipId:e.id,settings:{}}))&&(0,ed.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:q}}:{}})},A=async()=>{null===S||"assigned"!==C.kind||await T("restart",()=>d.mutateAsync({shipId:e.id,settings:S.settings}))&&(0,ed.showToast)({title:`Restarting ${e.name}`,description:`${C.trierarch.name} starts its session again with the same settings.`,tone:"success"})},I=async t=>{j(void 0);let s=(0,ee.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);j(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)(eI,{stage:C,requestedBy:(0,ee.requestedBy)(s),statusChangedAt:(0,ee.statusChangedAt)(s),now:n,canManage:i.canManage,isAwaitingCrew:"awaitingCrew"===e.status,hasTrierarchs:r,busy:h,error:p,settingsRows:null===S?void 0:(0,et.settingsRows)(S.settings),...null===S||void 0===l?{}:{machineLabels:(0,en.pickedChips)((0,ea.machineLabelIdsOf)(S.settings),l)},onRequest:()=>{r?k.open("request"):R()},...r?{onEdit:()=>{k.open("edit")}}:{},onRemove:()=>void T("remove",()=>o.mutateAsync({shipId:e.id})),onRelease:()=>{j(void 0),f(!0)},onRestart:()=>void A(),onGetStartingPrompt:q}),k.dialog,"crewedByHand"===C.kind||"assigned"===C.kind?(0,t.jsx)(el.CrewReleaseDialog,{shipName:e.name,stage:C,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:b,onConfirm:()=>void I(C)}):null,(0,t.jsx)(e_.StartingPromptDialog,{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:v,onOpenChange:e=>{e||(u.reset(),w(!1))},onConfirm:()=>{u.mutate({shipId:e.id})}})]})}var eH=e.i(84294),eW=e.i(19249);function eU({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 eG({shipId:e,now:s}){let n=(0,eD.useSquadrons)(),a=(0,eD.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)(ej.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)(j.Button,{size:"xs",nativeButton:!1,render:(0,t.jsx)(ej.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,g.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,eH.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)(eU,{label:"Squadron",children:[r,(0,t.jsx)(S.StatusBadge,{status:i.state})]}),(0,t.jsxs)(eU,{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)(ej.default,{href:(0,eH.templatePath)(o),className:"font-mono text-meta hover:underline",children:[o.name,"@",o.version]})]}),(0,t.jsx)(eU,{label:"Health",children:(0,t.jsx)(eW.HealthIndicator,{health:d.health,detail:"silent"===d.health||"late"===d.health?c:void 0})}),(0,t.jsx)(eU,{label:"Hand-offs",children:l?(0,t.jsx)("span",{className:"text-meta",children:(0,eH.handoffsText)((0,eH.handoffsOf)(l,d.role))}):(0,t.jsx)(ej.default,{href:(0,eH.blueprintPath)(i.blueprint),className:"text-meta text-muted-foreground hover:underline",children:"See its blueprint"})})]})]})}var eK=e.i(5894),eY=e.i(73332),eX=e.i(76561),eJ=e.i(22768),eQ=e.i(10818),eZ=e.i(69309),e0=e.i(26478),e1=e.i(63481);function e2({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,ev.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 e5=e.i(73330);function e3({ping:e,now:s,testId:n}){return null===e?null:(0,t.jsx)("span",{title:`Pinged ${(0,g.fullDateTime)(new Date(e.sentAt))}`,"data-testid":n,"data-state":e.state,className:"text-meta text-muted-foreground tabular-nums",children:(0,e5.pingLine)(e,s)})}var e7=e.i(67927),e4=e.i(93361);function e6({details:e,version:s,testId:n}){return(0,t.jsxs)("details",{"data-testid":n,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)(e7.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 ",s]})]}),(0,t.jsx)("div",{className:"px-3.5 pb-3.5",children:(0,t.jsx)(b.CodeBlock,{label:(0,e4.reportDetailsLabel)(e),code:(0,e4.reportDetailsJson)(e),copyLabel:"Copy report details",codeTestId:`${n}-code`})})]})}var e8=e.i(81830);function e9({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 te({ship:e,now:s,labels:n}){let a,i="operator"===e.kind,r=null===e.crewedSince?null:new Date(e.crewedSince),d=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)(e9,{label:"Location",children:(0,t.jsxs)("span",{className:"inline-flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)(e1.LocationTag,{kind:e.location?.kind??null,description:e.location?.description,size:"md"}),(0,t.jsx)(e2,{harness:e.harness,model:e.model?.id??null,testId:"ship-model"}),null===e.lastSeenAt?null:(0,t.jsx)("time",{dateTime:e.lastSeenAt,title:(0,g.fullDateTime)(new Date(e.lastSeenAt)),"data-testid":"ship-last-seen",className:"text-meta text-muted-foreground tabular-nums",children:(0,g.lastSeen)(new Date(e.lastSeenAt),s)}),(0,t.jsx)(e3,{ping:e.ping,now:s,testId:"ship-ping-status"}),"agent"!==e.kind?null:(0,t.jsx)(e8.ReportLine,{report:e.report,now:s,variant:"full",testId:"ship-report"})]})}),(0,t.jsx)(e9,{label:"Crewed since",children:r?(0,t.jsx)("time",{dateTime:e.crewedSince??void 0,title:(0,g.fullDateTime)(r),className:"tabular-nums",children:(a=s.getTime()-r.getTime()<864e5?(0,g.clockTime)(r):(0,g.shortDateTime)(r),`${a} \xb7 ${(0,g.duration)(r,s)}`)}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Not crewed"})}),(0,t.jsx)(e9,{label:"Commissioned",children:(0,t.jsx)("time",{dateTime:e.commissionedAt,title:(0,g.fullDateTime)(d),children:i?`Fleet created ${(0,g.dayDate)(d)}`:(0,g.dayDate)(d)})}),(0,t.jsxs)(e9,{label:"Ship id",children:[(0,t.jsx)("span",{className:"truncate font-mono text-id",children:e.id}),(0,t.jsx)(v.CopyButton,{value:e.id,label:"Copy ship id"})]}),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 tt({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 ts({ship:e,shipId:s,state:n,actions:a,crewRequest:i,now:r,backHref:d="/",labels:l,isPluginShip:o=!1}){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)(y.Skeleton,{className:"h-8 w-40"}),(0,t.jsx)(y.Skeleton,{className:"h-6 w-20"}),(0,t.jsx)(y.Skeleton,{className:"h-6 w-16"})]}),(0,t.jsx)(y.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)(eJ.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)(j.Button,{size:"sm",nativeButton:!1,render:({children:e,...s})=>(0,t.jsx)(ej.default,{href:d,...s,children:e}),children:"Back to fleet overview"})})});let c="operator"===e.kind,u="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)(k.ShipName,{name:e.name,shipId:e.id,size:"title",isSuffixShown:u})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(S.StatusBadge,{status:e.status}),c?(0,t.jsxs)(R.Badge,{variant:"kind",children:[(0,t.jsx)(e0.UserRound,{"aria-hidden":!0}),"operator"]}):(0,t.jsxs)(t.Fragment,{children:[o?(0,t.jsxs)(R.Badge,{variant:"kind","data-testid":"ship-plugin",children:[(0,t.jsx)(eZ.Plug,{"aria-hidden":!0}),"plugin"]}):null,(0,t.jsx)(R.Badge,{variant:"type",children:e.type}),e.scopes.filter(e=>eY.FLEET_SCOPES.some(t=>t===e)).map(e=>(0,t.jsx)(R.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)(eh.KeyRound,{"aria-hidden":!0}),"No starting prompt issued"]}):null]})]}),a&&!u?(0,t.jsx)("div",{className:(0,W.classNames)("flex flex-wrap items-center gap-2","max-sm:w-full max-sm:[&>*]:flex-1"),children:a}):null]}),c?(0,t.jsx)(tt,{icon:(0,t.jsx)(eQ.Info,{"aria-hidden":!0}),children:"argo is your ship. This console session crews it. It can’t be released, renamed or retired."}):null,u&&null!==e.retiredAt?(0,t.jsxs)(tt,{icon:(0,t.jsx)(eX.Archive,{"aria-hidden":!0}),children:["Retired on ",(0,g.fullDateTime)(new Date(e.retiredAt)),". Read-only."]}):null,i,(0,t.jsx)(te,{ship:e,now:r,labels:l}),"agent"===e.kind&&e.report?.details?(0,t.jsx)(e6,{details:e.report.details,version:e.report.detailsVersion,testId:"ship-report-details"}):null]})}var tn=e.i(99261),ta=e.i(89664),ti=e.i(16327),tr=e.i(56539),td=e.i(77071),tl=e.i(63676),to=e.i(6734),tc=e.i(87851);function tu({chip:e,labelKey:s,isBusy:n,onUnassign:i,onChange:r}){let[d,l]=(0,a.useState)(!1);return(0,t.jsxs)(to.Popover,{open:d,onOpenChange:l,children:[(0,t.jsx)(to.PopoverTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":`Change or remove ${e.key}=${e.value}`,"data-testid":"ship-label-yours",disabled:n,className:"inline-flex items-center rounded-sm focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60"}),children:(0,t.jsx)(ew.LabelChip,{chip:e,trailing:(0,t.jsx)(ti.ChevronDown,{"aria-hidden":!0}),className:"hover:bg-accent"})}),(0,t.jsxs)(to.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)(ta.Check,{"aria-hidden":!0}):null}),(0,t.jsx)("span",{className:(0,W.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)(tl.X,{"aria-hidden":!0}),"Remove label"]})})]})]})}function th({keys:e,isBusy:s,onAssign:n}){let[i,r]=(0,a.useState)(!1);return(0,t.jsxs)(to.Popover,{open:i,onOpenChange:r,children:[(0,t.jsx)(to.PopoverTrigger,{render:(0,t.jsx)(j.Button,{variant:"ghost",size:"xs",icon:(0,t.jsx)(td.Plus,{}),disabled:s,"data-testid":"ship-labels-add"}),children:"Add label"}),(0,t.jsxs)(to.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)(tc.LabelPicker,{groups:[{title:"Yours",keys:[...e]}],pickedValueIds:e.flatMap(e=>e.carriedValueIds),pickedWord:"Carried",onPick:e=>{r(!1),n(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)(ej.default,{href:"/labels",className:"font-medium hover:underline",children:0===e.length?"Define a label":"Manage labels"})})]})]})}function tm({chips:e,keys:s,limit:n,isBusy:i,error:r,onAssign:d,onUnassign:l,onChange:o}){let[c,u]=(0,a.useState)(!1),h=!c&&e.length>3,m=h?e.slice(0,2):e,p=[...new Set(m.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,m.filter(e=>"none"===e.mark).map(e=>(0,t.jsx)(tu,{chip:e,labelKey:s.find(t=>t.labelId===e.labelId),isBusy:i,onUnassign:l,onChange:o},e.valueId)),h?(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,n.isAtLimit?null:(0,t.jsx)(th,{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]}),m.filter(t=>"none"!==t.mark&&t.ownerName===e).map(e=>(0,t.jsx)(ew.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)(tr.ChevronUp,{"aria-hidden":!0}),"Show fewer"]}):null,n.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===n.count?null:(0,t.jsx)("span",{className:"ml-auto text-meta text-muted-foreground tabular-nums","data-testid":"ship-labels-count",children:n.count})]}),void 0===r?null:(0,t.jsx)(Y.InlineError,{title:r.title,description:`Refused: ${r.message}. Nothing changed.`})]})}function tp(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 tx({ship:e}){let n=(0,es.useLabelContext)(),i=(0,Z.useAccess)(),r=(0,es.useAssignLabel)(),d=(0,es.useUnassignLabel)(),[l,o]=(0,a.useState)(void 0);if(void 0===n)return(0,t.jsx)(y.Skeleton,{className:"h-5.5 w-40"});let c=(0,en.chipsOf)(e,n);if(!(i.canAssignLabels&&"operator"!==e.kind&&"retired"!==e.status))return(0,t.jsx)(tn.ShipLabels,{chips:c});let u=(0,en.assignKeysOf)(e,n),h=e=>t=>{o({title:e,message:t.message})};return(0,t.jsx)(tm,{chips:c,keys:u,limit:(0,en.labelLimitOf)(e),isBusy:r.isPending||d.isPending,error:l,onAssign:t=>{o(void 0),r.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(t)},{onError:h(`Couldn’t add ${tp(u,t)}`)})},onUnassign:t=>{o(void 0),d.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(t)},{onError:h(`Couldn’t remove ${tp(u,t)}`)})},onChange:({from:t,to:n})=>{o(void 0);let a=(0,s.idSchema)("labelValue").parse(t);d.mutate({shipId:e.id,valueId:a},{onSuccess:()=>{r.mutate({shipId:e.id,valueId:(0,s.idSchema)("labelValue").parse(n)},{onError:s=>{r.mutate({shipId:e.id,valueId:a}),h(`Couldn’t change ${tp(u,t)} to ${tp(u,n)}`)(s)}})},onError:h(`Couldn’t change ${tp(u,t)}`)})}})}var tg=e.i(87255),tf=e.i(31458);let tb={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"}]]};tb.node;let tj=(0,c.default)(tb),tv={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"}]]};tv.node;let tw=(0,c.default)(tv);var ty=e.i(67784);let tN={name:"mail-check",size:24,node:[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]};tN.node;let tk=(0,c.default)(tN),tC={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"}]]};tC.node;let tS=(0,c.default)(tC),tT={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"}]]};tT.node;let tq=(0,c.default)(tT),tR={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"}]]};tR.node;let tA=(0,c.default)(tR),tI={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"}]]};tI.node;let t$=(0,c.default)(tI),tD={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"]};tD.node;let tL=(0,c.default)(tD),tO={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"}]]};tO.node;let tz=(0,c.default)(tO);var tM=e.i(37817),tP=e.i(53341),tE=e.i(94661);function tB(e,t){let s=e.details[t];return"string"==typeof s?s:void 0}function tF(e){return tB(e,"key")??""}function t_(e){return(tB(e,"values")??"").split(",").join(", ")}function tV(e){return e?[(0,f.text)(" by "),(0,f.ship)(e)]:[]}let tH={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 tW(e){return null!==e.message&&(0,tP.isPingContentType)(e.message.contentType)}function tU(e){return e.message?[(0,f.text)(tW(e)?"a ping from ":"a message from "),(0,f.ship)(e.message.sender)]:[(0,f.text)("a message")]}function tG(e){let[t,...s]=tU(e);return t?.kind==="text"?[(0,f.text)((0,f.capitalised)(t.text)),...s]:tU(e)}function tK(e,t){let{shipId:s,verb:n}=t,a=e.actor;return[...null===a||a.id===s?[(0,f.text)((0,f.capitalised)(n))]:[(0,f.ship)(a),(0,f.text)(` ${n}`)],(0,f.text)(" "),...tU(e)]}let tY={received:E,sent:F,claimed:tw,released:ty.LogOut,prompt:eh.KeyRound,commissioned:tf.Flag,acknowledged:tk,returned:tM.Undo2,undeliverable:tq,secret:tj,fleet:tg.Anchor,password:tz,retired:eX.Archive,abandoned:t$,dismissed:tS,renamed:tL,reported:tA},tX={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"},tJ="flex w-full gap-3 px-3.5 py-3 text-left";function tQ({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,f.text)("Fleet initialised")],tone:"ended",icon:"fleet"};case"ShipCommissioned":{let t=tB(e,"type");return{parts:[(0,f.text)("Commissioned"),...tV(e.actor),...void 0===t?[]:[(0,f.text)(` as ${t}`)]],tone:"ended",icon:"commissioned"}}case"StartingPromptIssued":return{parts:[(0,f.text)("Starting prompt issued")],tone:"ended",icon:"prompt"};case"ShipClaimed":return{parts:[(0,f.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,T.locationKindWord)(s):"an unknown location"}(e)}`)],tone:"ok",icon:"claimed"};case"LeaseRevoked":let s,n;return{parts:[..."released"===(s=tB(e,"reason")??"")?[(0,f.text)("Released"),...tV(e.actor),(0,f.text)(".")]:[(0,f.text)(tH[s]??"Its session ended.")],..."number"==typeof(n=e.details.returnedDeliveries)&&n>0?[(0,f.text)(` ${(0,f.counted)(n,{one:"in-flight delivery",many:"in-flight deliveries"})} went back to pending.`)]:[]],tone:"waiting",icon:"released"};case"CredentialRevoked":return{parts:[(0,f.text)("Secret invalidated")],tone:"ended",icon:"secret"};case"OperatorPasswordReset":return{parts:[(0,f.text)("Operator password reset")],tone:"waiting",icon:"password"};case"FleetLimitsChanged":return{parts:[(0,f.text)("Fleet limits changed")],tone:"ended",icon:"fleet"};case"SignInTicketIssued":return{parts:[(0,f.text)("Sign-in ticket issued")],tone:"ended",icon:"password"};case"ViewerSessionStarted":return{parts:[(0,f.text)("Someone started viewing the fleet")],tone:"ended",icon:"password"};case"CrewRequested":return{parts:[(0,f.text)("Crew requested"),...tV(e.actor)],tone:"waiting",icon:"claimed"};case"CrewRequestRemoved":return{parts:[(0,f.text)("Crew request removed"),...tV(e.actor)],tone:"ended",icon:"released"};case"CrewRequestExplained":{let t=tB(e,"reason");return{parts:[(0,f.text)(void 0===t?"Crew request can not be placed yet":`Crew request can not be placed: ${t}`),...tV(e.actor)],tone:"waiting",icon:"reported"}}case"CrewRequestGivenBack":{let t=tB(e,"reason");return{parts:[(0,f.text)(void 0===t?"Crew request given back":`Crew request given back: ${t}`),...tV(e.actor)],tone:"waiting",icon:"released"}}case"WorktreeClearRequested":return{parts:[(0,f.text)(`Clearing of the kept ${tB(e,"repository")??""} worktree requested`),...tV(e.actor)],tone:"waiting",icon:"reported"};case"WorktreeCleared":return{parts:[(0,f.text)("not-kept"===tB(e,"outcome")?`Kept ${tB(e,"repository")??""} worktree cleared (none was kept)`:`Kept ${tB(e,"repository")??""} worktree cleared`),...tV(e.actor)],tone:"ended",icon:"retired"};case"WorktreeClearRemoved":return{parts:[(0,f.text)(`Clearing of the kept ${tB(e,"repository")??""} worktree dropped`),...tV(e.actor)],tone:"ended",icon:"released"};case"CrewAssigned":return{parts:[(0,f.text)("Crew request assigned"),...tV(e.actor)],tone:"waiting",icon:"claimed"};case"CrewStatusChanged":{let t=tB(e,"status");return{parts:[(0,f.text)(void 0===t?"Crew status changed":`Crew ${t}`),...tV(e.actor)],tone:"crashed"===t?"attention":"active",icon:"reported"}}case"LabelDefined":return{parts:[(0,f.text)(`Label ${tF(e)} defined: ${t_(e)}`)],tone:"ended",icon:"reported"};case"LabelValuesChanged":return{parts:[(0,f.text)(`Label ${tF(e)} values changed: ${t_(e)}`)],tone:"ended",icon:"reported"};case"LabelRetired":return{parts:[(0,f.text)(`Label ${tF(e)} retired`)],tone:"ended",icon:"retired"};case"LabelDeleted":return{parts:[(0,f.text)(`Label ${tF(e)} deleted`)],tone:"ended",icon:"retired"};case"LabelAssigned":return{parts:[(0,f.text)(`Labelled ${tF(e)}=${tB(e,"value")??""}`),...tV(e.actor)],tone:"ended",icon:"reported"};case"LabelUnassigned":return{parts:[(0,f.text)(`Label ${tF(e)}=${tB(e,"value")??""} removed`),...tV(e.actor)],tone:"ended",icon:"reported"};case"MessageAccepted":let a;return{parts:(a=e.message)?tW(e)&&"ship"===a.recipient.kind?a.sender.id===t?[(0,f.text)("Pinged "),(0,f.ship)(a.recipient.ship)]:[(0,f.text)("Pinged by "),(0,f.ship)(a.sender)]:a.sender.id===t?"ship"===a.recipient.kind?[(0,f.text)("Sent a message to "),(0,f.ship)(a.recipient.ship)]:[(0,f.text)(`Sent a message to any ship of type ${a.recipient.type}`)]:[(0,f.text)("Received a message from "),(0,f.ship)(a.sender)]:[(0,f.text)("A message was sent")],tone:"ended",icon:e.message?.sender.id===t?"sent":"received"};case"DeliveryClaimed":return{parts:tK(e,{shipId:t,verb:"took"}),tone:"active",icon:"received"};case"DeliveryAcknowledged":return{parts:"pong"===tB(e,"answer")?[...tK(e,{shipId:t,verb:"answered"}),(0,f.text)(" with pong")]:tK(e,{shipId:t,verb:"acknowledged"}),tone:"ok",icon:"acknowledged"};case"DeliveryReturned":return{parts:[...tG(e),(0,f.text)(" went back to pending")],tone:"waiting",icon:"returned"};case"DeliveryUndeliverable":return{parts:[...tG(e),(0,f.text)(" became undeliverable")],tone:"attention",icon:"undeliverable"};case"ShipRetired":{let t=e.details.abandonedDeliveries;return{parts:[(0,f.text)("Retired"),...tV(e.actor),(0,f.text)("."),..."number"==typeof t&&t>0?[(0,f.text)(` ${(0,f.counted)(t,{one:"delivery",many:"deliveries"})} abandoned.`)]:[]],tone:"ended",icon:"retired"}}case"DeliveryAbandoned":return{parts:[...tG(e),(0,f.text)(" was abandoned")],tone:"ended",icon:"abandoned"};case"ShipReported":{let t=tB(e,"state")??"in",s=tB(e,"note");return{parts:[(0,f.text)(void 0===s?`Reported ${t}`:`Reported ${t}: ${s}`)],tone:tE.REPORT_STATES.some(e=>e===t)?e4.REPORT_TONES[t]:"ended",icon:"reported"}}case"ShipRenamed":{let t=tB(e,"from"),s=tB(e,"to");return{parts:[(0,f.text)(void 0===t||void 0===s?"Renamed":`Renamed from ${t} to ${s}`),...tV(e.actor)],tone:"ended",icon:"renamed"}}case"DeliveryDismissed":return{parts:[...tG(e),(0,f.text)(" was dismissed"),...tV(e.actor)],tone:"ended",icon:"dismissed"}}}(e,s),l=tY[d],o=new Date(e.occurredAt),c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":!0,className:(0,W.classNames)("flex size-7 shrink-0 items-center justify-center rounded-md border [&_svg]:size-(--size-icon-sm)",tX[r]),children:(0,t.jsx)(l,{})}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsx)(C,{parts:i,className:"text-body text-foreground max-sm:text-body-touch"}),(0,t.jsx)("time",{dateTime:e.occurredAt,title:(0,g.fullDateTime)(o),className:"text-meta text-muted-foreground tabular-nums",children:(0,g.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,W.classNames)(tJ,"transition-colors duration-(--duration-fast) hover:bg-accent"),onClick:()=>{a(u.id)},children:c}):(0,t.jsx)("div",{className:tJ,children:c})})}function tZ({shipId:e,entries:s,state:n,onRetry:a,now:i,onOpenMessage:r}){return"loading"===n?(0,t.jsx)(X.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)(Y.InlineError,{title:"Couldn’t load the timeline",description:"The rest of the page is current. Try again in a moment."}),a?(0,t.jsx)(j.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)(tQ,{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 t0=e.i(274),t1=e.i(46929),t2=e.i(86413),t5=e.i(18423),t3=e.i(28459),t7=e.i(96676),t4=e.i(9176),t6=e.i(88721),t8=e.i(78485),t9=e.i(53573),se=e.i(3979);let st="timeline",ss="messages";function sn(e){return Array.isArray(e)?e[0]:e}function sa({shipId:e,searchParams:c}){let u=(0,n.useRouter)(),h=(0,t7.useNow)(),m=(0,t4.usePluginShipIds)(),p=sn(c.tab)===ss?ss:st,x=(0,s.idSchema)("message").safeParse(sn(c.message)),g=x.success?x.data:void 0,f=(0,t9.useShip)(e),b=(0,t9.useShipTimeline)(e),j=(0,t9.useShipMessages)(e),v=(0,t9.useMessage)(g),w=(0,t5.useLiveFleet)(),y=(0,t6.useAccountMenu)(h),N=(0,eD.useSquadrons)(),k=(0,t2.useOpenInboxCount)(),C=(0,Z.useAccess)(),S=(0,se.usePluginNav)(),[T,q]=(0,a.useState)(!1),[R,A]=(0,a.useState)(!1),[I,$]=(0,a.useState)(),D=(0,t3.useAttentionCount)();(0,t8.useSignInWhenSessionEnds)([f.error,b.error,j.error,v.error,w.error]);let L=t=>{let s,n;u.replace((s=new URLSearchParams,t.tab!==st&&s.set("tab",t.tab),void 0!==t.messageId&&s.set("message",t.messageId),""===(n=s.toString())?`/ships/${e}`:`/ships/${e}?${n}`),{scroll:!1})},O=e=>{L({tab:p,messageId:e})},z="NOT_FOUND"===(0,t1.trpcErrorCode)(f.error),P=(0,eH.shipsInSquadrons)(N.data??[]).get(e);return(0,t.jsx)(t0.DetailLayout,{title:f.data?.name??"Ship",parents:P?[{href:"/squadrons",label:"Squadrons"},{href:`/squadrons/${P.squadronId}`,label:P.squadronId}]:[{href:"/",label:"Fleet overview"}],live:w.live,nav:{active:"overview",inboxCount:k,attentionCount:D,...S},onCompose:C.canSend?()=>{q(!0)}:void 0,onSearch:()=>{A(!0)},account:y,banner:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.ConsoleNotices,{}),(0,t.jsx)(l.ConsoleGuide,{})]}),header:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ts,{ship:f.data,shipId:e,state:z?"not-found":f.data?"ready":"loading",now:h,actions:f.data?(0,t.jsx)(eK.ShipActions,{ship:f.data}):void 0,crewRequest:f.data?(0,t.jsx)(eV,{ship:f.data,timeline:b.data??[],now:h}):void 0,labels:f.data?(0,t.jsx)(tx,{ship:f.data}):void 0,isPluginShip:m.has(e)}),z?null:(0,t.jsx)(eG,{shipId:e,now:h})]}),sheet:(0,t.jsx)(M,{message:v.data,messageId:g,state:"NOT_FOUND"===(0,t1.trpcErrorCode)(v.error)?"not-found":v.data?"ready":"loading",isOpen:void 0!==g,onOpenChange:e=>{e||L({tab:p})},onReply:C.canSend?e=>{$({messageId:e.id,sender:e.sender})}:void 0}),children:(0,t.jsxs)(t.Fragment,{children:[z?null:(0,t.jsxs)(i.Tabs,{value:p,onValueChange:e=>{L({tab:e===ss?ss:st,messageId:g})},children:[(0,t.jsxs)(i.TabsList,{variant:"line","aria-label":`${f.data?.name??"Ship"} history`,children:[(0,t.jsx)(i.TabsTrigger,{variant:"line",value:st,children:"Timeline"}),(0,t.jsx)(i.TabsTrigger,{variant:"line",value:ss,children:"Messages"})]}),(0,t.jsx)(i.TabsContent,{value:st,className:"pt-4",children:(0,t.jsx)(tZ,{shipId:e,entries:b.data??[],state:b.isError?"error":b.data?"ready":"loading",onRetry:()=>{b.refetch()},now:h,onOpenMessage:O})}),(0,t.jsx)(i.TabsContent,{value:ss,className:"pt-4",children:(0,t.jsx)(Q,{shipId:e,messages:j.data??[],state:j.isError?"error":j.data?"ready":"loading",onRetry:()=>{j.refetch()},now:h,onOpenMessage:O})})]}),(0,t.jsx)(r.ComposeMessage,{isOpen:T,onOpenChange:q}),(0,t.jsx)(r.ComposeMessage,{isOpen:void 0!==I,onOpenChange:e=>{e||$(void 0)},replyTo:I}),(0,t.jsx)(d.ConsoleCommands,{isOpen:R,onOpenChange:A,onCompose:()=>{q(!0)}})]})})}e.s(["default",0,function({params:e,searchParams:n}){let i=(0,s.idSchema)("ship").safeParse((0,a.use)(e).shipId),r=(0,a.use)(n),d=i.success?i.data:(0,s.idSchema)("ship").parse(`shp_${"0".repeat(26)}`);return(0,t.jsx)(sa,{shipId:d,searchParams:r})}],21607)}]);
|