@ycodium-ai/plugin-pixel-office 0.2.3576 → 0.2.3608

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/README.md CHANGED
@@ -7,12 +7,16 @@
7
7
  视角被切走(`active: false`)时停掉全部动画与订阅;静止时零重绘。
8
8
 
9
9
  - 视角:`ui.teamViews` 的 `office`,`scopes: ["team", "project"]`,座位 `team.view`。
10
- - 数据全部经公开插件接口:`work.lines.*`、`work.items.list`、`threads.list/get`、
11
- `threads.execution.summary`,刷新靠本插件自己的 `watch` 门铃流(work 事件 + 会话目录流,
12
- 250 ms 合并)。
10
+ - 数据全部经公开插件接口:`work.lines.*`、`work.items.list`、`members.list`、
11
+ `threads.list/get`、`threads.execution.summary`、`auth.remoteAgents.list`、
12
+ `communication.records.list`,刷新靠本插件自己的 `watch` 门铃流
13
+ (work / member / communication 事件 + 会话目录流,250 ms 合并)。
13
14
  - 素材全部自绘:字符画像素小人编译成 box-shadow,房间是纯 CSS 盒,不引外部图片。
14
- - 名册成员 ↔ 成员会话没有公开映射,所以小人以**会话**为单位(负责人会话 + `person` 子会话),
15
- 还没有会话的成员不进房间。
15
+ - 小人以**成员**为单位:有会话的成员坐工位(一个成员一个工位,状态取他名下全部未归档
16
+ 会话的最高优先级,点击打开决定状态的那条),还没有会话的本机成员坐休息区长椅、
17
+ 挂「待派活」。多机是一张楼层图:本机办公室在最前,其他机器各一间小房
18
+ (客户端记得机器名就用机器名),认不出机器的远端主体共用「其他机器」;远端小人不动,
19
+ 名牌下只写「上次通信」与最新一条消息的阶段(已送达 / 已取走 / 已回复)。
16
20
 
17
21
  构建:`node build.mjs`(宿主共享 React 与 plugin-api,只打包自身)。
18
22
  测试:`vp test run plugins/pixel-office`。
package/assets/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- var J=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!J)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:ht,PLUGIN_UI_BRIDGE_VERSION:wt,PLUGIN_UI_FLOATING_VIEW_PROP:gt,PLUGIN_UI_GLOBAL_KEY:yt,PLUGIN_UI_HOST_CAPABILITIES:bt,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:xt,PLUGIN_UI_HOST_UPGRADE_MESSAGE:vt,TEAM_VIEW_KEY_PATTERN:kt,communicationRecordStage:It,defineTeamView:Z,isTeamViewKey:Pt,pluginUiHostHasCapability:Ot}=J;var ee=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
1
+ var fe=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!fe)throw new Error("This plugin needs a newer Ycodium app. Update the app.");var{HOST_TEAM_VIEW_PREFIX:qt,PLUGIN_UI_BRIDGE_VERSION:$t,PLUGIN_UI_FLOATING_VIEW_PROP:Kt,PLUGIN_UI_GLOBAL_KEY:jt,PLUGIN_UI_HOST_CAPABILITIES:zt,PLUGIN_UI_HOST_COMMAND_PALETTE_UNAVAILABLE_MESSAGE:Vt,PLUGIN_UI_HOST_UPGRADE_MESSAGE:Gt,TEAM_VIEW_KEY_PATTERN:Xt,communicationRecordStage:ee,defineTeamView:ue,isTeamViewKey:Yt,pluginUiHostHasCapability:Qt}=fe;var he=`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
2
2
  @layer properties, theme, base, components, utilities;
3
3
  @layer properties;
4
4
  :root, :host {
@@ -36,9 +36,6 @@ var J=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!J)th
36
36
  max-width: 96rem;
37
37
  }
38
38
  }
39
- .m-0:where(:scope, *) {
40
- margin: calc(var(--spacing, 0.25rem) * 0);
41
- }
42
39
  .m-1:where(:scope, *) {
43
40
  margin: calc(var(--spacing, 0.25rem) * 1);
44
41
  }
@@ -51,9 +48,6 @@ var J=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!J)th
51
48
  .m-4:where(:scope, *) {
52
49
  margin: calc(var(--spacing, 0.25rem) * 4);
53
50
  }
54
- .m-8:where(:scope, *) {
55
- margin: calc(var(--spacing, 0.25rem) * 8);
56
- }
57
51
  .m-9:where(:scope, *) {
58
52
  margin: calc(var(--spacing, 0.25rem) * 9);
59
53
  }
@@ -321,6 +315,106 @@ var J=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!J)th
321
315
  font-size: 11px;
322
316
  line-height: 1.3;
323
317
  }
318
+ .po-bench-seat {
319
+ position: absolute;
320
+ width: 96px;
321
+ height: 24px;
322
+ background: var(--po-furniture);
323
+ border: 3px solid var(--po-furniture-dark);
324
+ border-radius: 5px;
325
+ }
326
+ .po-bench-figure {
327
+ cursor: default;
328
+ }
329
+ .po-bench-tag {
330
+ position: absolute;
331
+ left: 50%;
332
+ transform: translateX(-50%);
333
+ top: calc(100% + 4px);
334
+ white-space: nowrap;
335
+ font-size: 10px;
336
+ line-height: 1.2;
337
+ padding: 0 4px;
338
+ border-radius: 4px;
339
+ color: var(--po-ink);
340
+ background: var(--po-tile-a);
341
+ @supports (color: color-mix(in lab, red, red)) {
342
+ background: color-mix(in srgb, var(--po-tile-a) 82%, white);
343
+ }
344
+ border: 1px solid var(--po-ink);
345
+ @supports (color: color-mix(in lab, red, red)) {
346
+ border: 1px solid color-mix(in srgb, var(--po-ink) 28%, transparent);
347
+ }
348
+ }
349
+ .dark .po-bench-tag {
350
+ background: color-mix(in srgb, #1c222c 88%, black);
351
+ }
352
+ .po-floor-map {
353
+ display: flex;
354
+ flex-direction: column;
355
+ gap: 12px;
356
+ }
357
+ .po-remote-rooms {
358
+ display: flex;
359
+ flex-wrap: wrap;
360
+ gap: 12px;
361
+ justify-content: center;
362
+ padding: 0 12px 12px;
363
+ }
364
+ .po-remote-room {
365
+ position: relative;
366
+ min-width: 220px;
367
+ max-width: 320px;
368
+ padding: 30px 14px 14px;
369
+ background: var(--po-tile-a);
370
+ border: 3px solid var(--po-metal);
371
+ border-radius: 10px;
372
+ }
373
+ .po-remote-room-name {
374
+ position: absolute;
375
+ top: 6px;
376
+ left: 10px;
377
+ margin: 0;
378
+ font-size: 12px;
379
+ font-weight: 600;
380
+ color: var(--po-ink);
381
+ white-space: nowrap;
382
+ overflow: hidden;
383
+ text-overflow: ellipsis;
384
+ max-width: calc(100% - 20px);
385
+ }
386
+ .po-remote-figures {
387
+ display: flex;
388
+ flex-wrap: wrap;
389
+ gap: 10px 18px;
390
+ justify-content: center;
391
+ }
392
+ .po-remote-figure {
393
+ position: relative;
394
+ display: flex;
395
+ flex-direction: column;
396
+ align-items: center;
397
+ width: 96px;
398
+ }
399
+ .po-remote-stage, .po-remote-last {
400
+ font-size: 10px;
401
+ line-height: 1.25;
402
+ color: var(--po-ink);
403
+ text-align: center;
404
+ }
405
+ .po-remote-last {
406
+ opacity: 0.78;
407
+ }
408
+ @media (max-width: 700px) {
409
+ .po-remote-rooms {
410
+ flex-direction: column;
411
+ align-items: stretch;
412
+ }
413
+ .po-remote-room {
414
+ max-width: none;
415
+ width: 100%;
416
+ }
417
+ }
324
418
  .po-island {
325
419
  position: absolute;
326
420
  background: var(--po-tile-a);
@@ -491,4 +585,4 @@ var J=window.__ycodiumPluginHost.modules?.["@ycodium-ai/plugin-api/ui"];if(!J)th
491
585
  }
492
586
  }
493
587
  }
494
- `;var Je=window.__ycodiumPluginHost.react;var{Activity:Rt,Children:Lt,Component:Et,Fragment:Ct,Profiler:Mt,PureComponent:Nt,StrictMode:_t,Suspense:At,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:Dt,__COMPILER_RUNTIME:Ht,act:Ut,cache:Wt,cacheSignal:Bt,captureOwnerStack:Ft,cloneElement:qt,createContext:te,createElement:A,createRef:jt,forwardRef:Vt,isValidElement:zt,lazy:$t,memo:oe,startTransition:Kt,unstable_useCacheRefresh:Gt,use:Xt,useActionState:Yt,useCallback:R,useContext:re,useDebugValue:Qt,useDeferredValue:Jt,useEffect:x,useEffectEvent:Zt,useId:eo,useImperativeHandle:to,useInsertionEffect:oo,useLayoutEffect:ne,useMemo:v,useOptimistic:ro,useReducer:no,useRef:g,useState:C,useSyncExternalStore:ao,useTransition:io,version:so}=Je;var ae=te(null),ie=ae.Provider;function k(){let e=re(ae);if(e===null)throw new Error("pixel-office-ui-not-registered");return e}function O(){let e=k().i18n.usePluginTranslation();return{t:(t,o)=>e(t,o)}}function se({environmentId:e,projectId:t,onBell:o,retryRef:r}){let n=k(),s=v(()=>({projectId:t}),[t]),c=v(()=>({environmentId:e}),[e]),l=n.commands.useSubscription("watch",s,c),a=l.data,d=a?.cursor??null,f=a?.threads,m=l.error!==null||l.isUnavailable,w=g(!1);return x(()=>{r.current=l.refresh}),x(()=>{if(!w.current){w.current=!0,o({cursor:d,failed:m,initial:!0});return}o({cursor:d,failed:m,...f===void 0?{}:{threads:f}})},[d,m,f]),null}var Ze={todo:0,started:0,completed:0,cancelled:0},et=e=>{let t={...Ze};for(let o of e)switch(o.state.group){case"started":t.started+=1;break;case"completed":t.completed+=1;break;case"cancelled":t.cancelled+=1;break;default:t.todo+=1;break}return t},ce=(e,t)=>({workLineId:e.workLineId,name:e.name,archived:e.archivedAt!==null,threadId:e.threadId,counts:et(t.filter(o=>o.workLineId===e.workLineId))}),tt=e=>[...e].sort((t,o)=>t.archived!==o.archived?t.archived?1:-1:t.workLineId.localeCompare(o.workLineId)),le=e=>[...e].sort((t,o)=>t.lineId!==o.lineId?t.lineId.localeCompare(o.lineId):t.role!==o.role?t.role==="lead"?-1:1:t.threadId.localeCompare(o.threadId)),de=(e,t,o,r,n,s)=>({threadId:o,title:r,role:t,status:n,queuePosition:s,lineId:e}),H=e=>{switch(e){case"needs-approval":case"needs-input":case"plan-ready":return"waiting";case"running":return"working";case"background":return"monitoring";case"failed":return"failed";case"stopped":return"asleep";default:return"idle"}},ue=e=>H(e.status??"idle"),U=e=>e.summary?.origin?.requestedBy==="person",j=e=>e==="idle",V=e=>{let t=new Map;for(let o of e){if(o===null||o.continuation!=="queued")continue;let r=o.queue.find(n=>n.status==="blocked"&&n.waitingForCapacity===!0);r!==void 0&&t.set(o.threadId,r.position)}return t},pe=(e,t)=>e==="idle"&&t!==null?"queued":e,fe=(e,t,o)=>me(e,"member",t,o),ot=(e,t,o)=>me(e,"lead",t,o),me=(e,t,o,r)=>de(e,t,o.threadId,o.title,pe(H(o.status),r),r),rt=(e,t,o)=>de(e,"lead",t.id,t.title,pe(ue(t),o),o),he=(e,t)=>[...e!==null&&j(ue(e))?[e.id]:[],...t.filter(o=>j(H(o.status))).map(o=>o.threadId)],we=(e,t)=>{let o=new Set(e.flatMap(r=>r.threadId===null?[]:[r.threadId]));return t.filter(r=>(o.has(r.threadId)||r.parentThreadId!==null&&o.has(r.parentThreadId)&&U(r))&&j(H(r.status))).map(r=>r.threadId)},z=e=>{let t=e.line.workLineId;return{lines:[ce(e.line,e.items)],characters:le([...e.lead===null?[]:[rt(t,e.lead,e.queue.get(e.lead.id)??null)],...e.members.map(o=>fe(t,o,e.queue.get(o.threadId)??null))])}},ge=e=>{let t=new Map(e.threads.map(n=>[n.threadId,n])),o=new Map;for(let n of e.threads){if(n.parentThreadId===null||!U(n))continue;let s=o.get(n.parentThreadId);s===void 0?o.set(n.parentThreadId,[n]):s.push(n)}let r=[];for(let n of e.lines){let s=n.workLineId;if(n.threadId!==null){let c=t.get(n.threadId);c!==void 0&&r.push(ot(s,c,e.queue.get(c.threadId)??null));for(let l of o.get(n.threadId)??[])r.push(fe(s,l,e.queue.get(l.threadId)??null))}}return{lines:tt(e.lines.map(n=>ce(n,e.items))),characters:le(r)}};var D=async e=>{let t=[],o=null;for(;;){let r=await e(o);if(t.push(...r.items),r.nextCursor===null)return t;o=r.nextCursor}},ye=async(e,t,o)=>{if(o.length===0)return V([]);let r=await Promise.all(o.map(n=>e.data.read("threads.execution.summary",{threadId:n},{environmentId:t}).catch(()=>null)));return V(r)};async function be(e,t){let{environmentId:o,projectId:r,workLineId:n}=t,{line:s}=await e.data.read("work.lines.get",{projectId:r,workLineId:n},{environmentId:o}),c=D(y=>e.data.read("work.items.list",{projectId:r,workLineIds:[n],cursor:y},{environmentId:o}));if(s.threadId===null)return z({line:s,lead:null,members:[],items:await c,queue:new Map});let l=s.threadId,[a,d,f]=await Promise.all([e.data.read("threads.get",{threadId:l},{environmentId:o}).catch(()=>null),D(y=>e.data.read("threads.list",{projectId:r,parentThreadId:l,include:["summary"],cursor:y},{environmentId:o})),c]),m=d.filter(U),w=await ye(e,o,he(a,m));return z({line:s,lead:a,members:m,items:f,queue:w})}async function xe(e,t){let{environmentId:o,projectId:r}=t,[n,s,c]=await Promise.all([D(a=>e.data.read("work.lines.list",{projectId:r,includeArchived:!0,cursor:a},{environmentId:o})),D(a=>e.data.read("threads.list",{projectId:r,include:["summary"],cursor:a},{environmentId:o})),D(a=>e.data.read("work.items.list",{projectId:r,cursor:a},{environmentId:o}))]),l=await ye(e,o,we(n,s));return ge({lines:n,threads:s,items:c,queue:l})}var nt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function ve(e){let{environmentId:t,projectId:o,active:r}=e,n=e.scope==="team"?e.workLineId:null,s=k(),c=g(()=>{}),l=R(()=>c.current(),[]),a=v(()=>({scene:null}),[t,o,n]),d=v(()=>({active:!1,dirty:!1,running:null}),[t,o,n]),f=g(e);f.current=e;let[m,w]=C(null),[y,b]=C(!1),[I,M]=C(!1),P=R(()=>!d.active||!f.current.active?Promise.resolve():(d.dirty=!0,d.running!==null||(d.running=(async()=>{try{do{d.dirty=!1;try{let p=f.current.scope==="team"?await be(s,f.current):await xe(s,f.current);if(!d.active||!f.current.active)return;(a.scene===null||!nt(p,a.scene))&&(a.scene=p,w(p)),b(!1)}catch{if(!d.active||!f.current.active)return;b(!0)}}while(d.active&&d.dirty)}finally{d.running=null}})()),d.running),[s,a,d]);x(()=>(d.active=!0,a.scene=null,w(null),b(!1),P(),()=>{d.active=!1}),[d,P,a]);let N=g(null),q=R(p=>{if(M(_=>_===p.failed?_:p.failed),p.initial===!0){p.cursor!==null&&(N.current=p.cursor);return}let E=N.current;if(Object.is(E,p.cursor))return;if(N.current=p.cursor,E!==null&&p.cursor===E+1&&p.threads!==void 0){let _=f.current.scope==="team"?[f.current.threadId]:a.scene?.lines.map(T=>T.threadId)??[],Xe=new Set(_),Ye=new Set([..._,...a.scene?.characters.map(T=>T.threadId)??[]]);if(!p.threads.ids.some(T=>Ye.has(T))&&!p.threads.parentIds.some(T=>Xe.has(T)))return}P()},[a,P]),h=g(r);return x(()=>{r&&!h.current&&P(),h.current=r},[r,P]),{scene:m,loadFailed:y,reload:P,watchFailed:r&&I,retryWatch:l,subscription:r?A(se,{environmentId:t,projectId:o,onBell:q,retryRef:c}):null}}function $(e){return function(o){return A(k().ui[e],{...o})}}var K=$("Empty"),G=$("EmptyHeader"),X=$("EmptyTitle");function Y(e){return A(k().ui.Button,e)}var at={working:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".s.cccc.s.","...kkkk...","..pppppp..","..pp..pp..","..b....b..",".........."],waiting:["...hhhh.s.","..hhhhhh.s","..ssssss.s","..sesses.s","..ssssss.s",".ccccccccc","cccccccccc","cccccccccc",".s.cccc...","...pppp...","..pp..pp..","..pp..pp..","..b....b..",".........."],failed:["..........","..........","...hhhh...","..hhhhhh..","..ssssss..","..ssssss..",".cccccccc.","cccccccccc","sccccccccs","s........s","..pppppp..","..pp..pp..","..b....b..",".........."],idle:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","u.ccccccc.","u.scccc...","...pppp...","..pp..pp..","..pp..pp..","..b....b..",".........."],asleep:["..........","...hhhh...","..hhhhhh..","..ssssss..","..s.ss.s..",".cccccccc.","cccccccccc","cccccccccc",".cccccccc.","..pppppp..","..pppppp..","..........","..........",".........."],monitoring:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".ccccccc..","..pppppp..","..pp..pp..","..pp..pp..","..b....b..",".........."],queued:["...hhhh...","..hhhhhh..","..ssssss..","..sssssee.","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".s.cccccc.","..ppppppk.","..pppppp..","..pppppp..","...b..b...",".........."]},L=3,ke=10,it=14,W=1,Ie=new Map;function Re(e){let t=Ie.get(e);if(t!==void 0)return t;let o=at[e],r=[];for(let[s,c]of o.entries()){if(c.length!==ke)throw new Error(`pose-${e}-row-${s}-width`);for(let[l,a]of[...c].entries())a!=="."&&r.push(`${(l+W)*L}px ${(s+W)*L}px 0 var(--po-${a})`)}let n={boxShadow:r.join(", "),width:(ke+W)*L,height:(it+W)*L};return Ie.set(e,n),n}var Pe=["#f2c9a0","#dcae7c","#c28c5c","#9c6b44"],Oe=["#2f2a26","#5b4632","#8a6a3f","#b58a52","#d9c48f","#6e6e73","#40485c"],Se=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#64748b"],Te=["#334155","#1e293b","#4b5563"],st=e=>{let t=5381;for(let o of e)t=(t*33^o.charCodeAt(0))>>>0;return t};function Le(e){let t=st(e);return{"--po-h":Oe[(t>>>0)%Oe.length],"--po-s":Pe[(t>>>3)%Pe.length],"--po-e":"#26221e","--po-c":Se[(t>>>6)%Se.length],"--po-p":Te[(t>>>9)%Te.length],"--po-b":"#3b2f2a","--po-k":"#4b5563","--po-u":"#f4f1ea"}}var{jsx:i,jsxs:u,Fragment:S}=window.__ycodiumPluginHost.jsxRuntime;var ct=e=>{switch(e.status){case"waiting":return"?";case"failed":return"!";case"asleep":return"z";case"queued":return e.queuePosition===null?"\u2026":String(e.queuePosition);default:return null}},Ee=oe(function(t){let{character:o,slot:r}=t,{t:n}=O(),s=Re(o.status),c=ct(o),l=n(`office.status.${o.status}`),a=g(null),d=g(t.walker);d.current=t.walker;let f=g(r);return ne(()=>{let m=a.current,w=f.current;f.current=r,!(m===null||w.x===r.x&&w.y===r.y)&&d.current.move(o.threadId,m,w,r)},[r,o.threadId]),u("button",{ref:a,type:"button",className:"po-character","data-office-character":o.threadId,"data-office-status":o.status,style:{left:r.x,top:r.y,...Le(o.threadId)},"aria-label":`${n("office.characterLabel",{name:o.title,status:l})}${o.role==="lead"?` \xB7 ${n("office.leadBadge")}`:""}${o.queuePosition!==null?` \xB7 ${n("office.queuePosition",{position:o.queuePosition})}`:""}`,onClick:()=>t.onOpen(o),children:[i("span",{className:"po-sprite-frame",style:{width:s.width,height:s.height},children:i("span",{className:"po-sprite",style:{width:L,height:L,boxShadow:s.boxShadow}})}),c===null?null:i("span",{className:`po-bubble po-bubble-${o.status}`,children:c}),i("span",{className:"po-name",children:o.title})]})});function Q(e){let t=g(null),[o,r]=C(1),n=e.plan.width;x(()=>{let c=t.current;if(c===null||typeof ResizeObserver>"u")return;let l=new ResizeObserver(()=>{let a=Math.min(c.clientWidth/n,1.4);r(d=>Math.abs(d-a)<.001?d:a)});return l.observe(c),()=>l.disconnect()},[n]);let s={width:e.plan.width,height:e.plan.height,transform:`scale(${o})`};return i("div",{ref:t,className:"po-viewport relative flex w-full min-w-0 items-center justify-center overflow-hidden",style:{height:"100%",minHeight:e.plan.height*o,"--po-name-w":e.compact===!0?"64px":"120px"},children:i("div",{className:"relative shrink-0",style:{width:e.plan.width*o,height:e.plan.height*o},children:i("div",{className:"po-stage absolute left-0 top-0 origin-top-left","data-office-room":"",role:"group","aria-label":e.ariaLabel,style:s,children:e.children})})})}var B=(e,t,o,r,n,s)=>i("div",{className:n,style:{left:e,top:t,width:o,height:r}},s);function Ce(e){return u(S,{children:[B(e.x-34,e.y+4,68,10,`po-desk-top${e.dark?" po-desk-dim":""}`,"top"),B(e.x-30,e.y+14,4,18,"po-desk-leg","leg-l"),B(e.x+26,e.y+14,4,18,"po-desk-leg","leg-r"),e.laptop?B(e.x-10,e.y-2,20,7,"po-laptop","laptop"):null]})}function Me(){return u(S,{children:[i("div",{className:"po-floor"}),i("div",{className:"po-wall"}),i("div",{className:"po-window",style:{left:300,top:28}}),i("div",{className:"po-window",style:{left:430,top:28}}),i("div",{className:"po-door"}),i("div",{className:"po-counter"}),i("div",{className:"po-coffee"}),i("div",{className:"po-couch"}),i("div",{className:"po-cooler"}),i("div",{className:"po-plant",style:{left:900,top:130}})]})}function Ne(e){let{t}=O();return u("div",{className:"po-board","data-office-board":"",children:[i("div",{className:"po-board-title",children:e.name}),u("div",{className:"po-board-row",children:[i("span",{className:"po-dot po-dot-todo"}),t("office.counts.todo",{count:e.counts.todo})]}),u("div",{className:"po-board-row",children:[i("span",{className:"po-dot po-dot-started"}),t("office.counts.started",{count:e.counts.started})]}),u("div",{className:"po-board-row",children:[i("span",{className:"po-dot po-dot-completed"}),t("office.counts.completed",{count:e.counts.completed})]}),u("div",{className:"po-board-row",children:[i("span",{className:"po-dot po-dot-cancelled"}),t("office.counts.cancelled",{count:e.counts.cancelled})]})]})}function _e(e){let{t}=O();return u(S,{children:[i("div",{className:`po-island${e.archived?" po-island-archived":""}`,style:lt(e)}),u("div",{className:`po-island-sign${e.archived?" po-island-sign-archived":""}`,style:{left:e.x+8,top:e.y-26},children:[i("span",{className:"po-island-name",children:e.name}),e.archived?i("span",{className:"po-island-badge",children:t("office.archived")}):null,u("span",{className:"po-island-count",children:[t("office.counts.started",{count:e.counts.started})," \xB7"," ",t("office.counts.completed",{count:e.counts.completed})]})]})]})}var lt=e=>({left:e.x,top:e.y,width:e.width,height:e.height});function We(e){let t=new Map,o=new Map,r=["waiting","idle","asleep","monitoring","queued"],n=new Map(r.map(a=>[a,0])),s=e.characters.filter(a=>a.role==="member");for(let[a,d]of s.entries())o.set(d.threadId,{x:150+a%6*130,y:330+Math.floor(a/6)*120});for(let a of e.characters){let d=n.get(a.status);a.role==="lead"&&o.set(a.threadId,{x:470,y:220}),a.status==="working"||a.status==="failed"?t.set(a.threadId,o.get(a.threadId)):d!==void 0?(t.set(a.threadId,dt(a.status,d)),n.set(a.status,d+1)):t.set(a.threadId,o.get(a.threadId))}let c=[...t.values(),...o.values()],l=Math.max(0,...c.map(a=>a.y));return{width:960,height:Math.max(540,l+70),positions:t,homeDesks:o}}var dt=(e,t)=>{switch(e){case"waiting":return{x:830,y:250+t*62};case"idle":return{x:100,y:260+t*58};case"asleep":return{x:100,y:430+t*50};case"monitoring":return{x:215,y:185+t*58};default:return{x:872,y:468+t*52}}},Ae=3,De=296,He=240,Ue=316,ut=24;function Be(e){let t=new Map,o=new Map,r=[],n=new Map;for(let c of e.characters){let l=n.get(c.lineId);l===void 0?n.set(c.lineId,[c]):l.push(c)}let s=156;for(let c=0;c<e.lines.length;c+=Ae){let a=e.lines.slice(c,c+Ae).map(m=>{let w=n.get(m.workLineId)??[],y=new Map,b=new Map,I=[],M=0;for(let h of w){if(h.role==="lead"){let E={x:De/2,y:72};y.set(h.threadId,E),b.set(h.threadId,E);continue}let p={x:58+M%3*90,y:150+Math.floor(M/3)*78};M+=1,y.set(h.threadId,p),h.status==="working"||h.status==="failed"?b.set(h.threadId,p):I.push(h.threadId)}let P=Math.max(0,...[...y.values()].map(h=>h.y)),N=Math.max(He-12,P+80);I.forEach((h,p)=>{b.set(h,{x:40+p%4*72,y:N+Math.floor(p/4)*60})});let q=Math.max(0,...[...b.values()].map(h=>h.y));return{line:m,desks:y,localPositions:b,height:Math.max(He,P+70,q+70)}}),d=Math.max(...a.map(m=>m.height)),f=(960-a.length*Ue)/2;a.forEach((m,w)=>{let y=f+w*Ue+10;r.push({line:m.line,x:y,y:s,width:De,height:d});for(let[b,I]of m.desks)o.set(b,{x:y+I.x,y:s+I.y});for(let[b,I]of m.localPositions)t.set(b,{x:y+I.x,y:s+I.y})}),s+=d+ut}return{islands:r,plan:{width:960,height:s+16,positions:t,homeDesks:o}}}var F=class{walks=new Map;handle=null;requestFrame;cancelFrame;schedule;cancelSchedule;animated;constructor(t={}){let o=t.requestFrame!==void 0||typeof requestAnimationFrame=="function";this.requestFrame=t.requestFrame??(r=>requestAnimationFrame(r)),this.cancelFrame=t.cancelFrame??(r=>cancelAnimationFrame(r)),this.schedule=t.schedule??(r=>Number(setTimeout(r,125))),this.cancelSchedule=t.cancelSchedule??(r=>clearTimeout(r)),this.animated=o}move(t,o,r,n){let s=this.walks.get(t),c=(s===void 0?r.x:s.toX+s.dx)-n.x,l=(s===void 0?r.y:s.toY+s.dy)-n.y,a=Math.max(Math.abs(c),Math.abs(l))<24;if(!this.animated||a){s!==void 0?this.finish(t):this.paintAt(o,0,0);return}this.walks.set(t,{element:o,dx:c,dy:l,toX:n.x,toY:n.y}),o.setAttribute("data-office-walking",""),this.paint(t),this.ensureLoop("raf")}stopAll(){this.clearHandle();let t=[...this.walks.keys()];for(let o of t)this.finish(o);this.walks.clear()}get isWalking(){return this.walks.size>0}clearHandle(){let t=this.handle;this.handle=null,t!==null&&(t.kind==="raf"?this.cancelFrame:this.cancelSchedule)(t.id)}ensureLoop(t){this.handle===null&&(this.handle=t==="raf"?{kind:"raf",id:this.requestFrame(()=>this.step())}:{kind:"timer",id:this.schedule(()=>{this.handle=null,this.ensureLoop("raf")})})}step(){this.handle=null;let t=[...this.walks.keys()];for(let o of t){let r=this.walks.get(o);r!==void 0&&(r.dx=Fe(r.dx),r.dy=Fe(r.dy),r.dx===0&&r.dy===0?this.finish(o):this.paint(o))}this.walks.size>0&&this.ensureLoop("timer")}finish(t){let o=this.walks.get(t);o!==void 0&&(this.walks.delete(t),o.element.removeAttribute("data-office-walking"),this.paintAt(o.element,0,0))}paint(t){let o=this.walks.get(t);o!==void 0&&this.paintAt(o.element,o.dx,o.dy)}paintAt(t,o,r){t.style.transform=o===0&&r===0?"translate(-50%, -100%)":`translate(-50%, -100%) translate(${o}px, ${r}px)`}},Fe=e=>{if(e===0)return 0;let t=Math.min(Math.abs(e),8);return e>0?e-t:e+t};function qe(e){let t=g(null);return t.current===null&&(t.current=new F),x(()=>{e||t.current?.stopAll()},[e]),x(()=>()=>t.current?.stopAll(),[]),t.current}function je(e){let t=k();return R(o=>{t.openThread({environmentId:e,threadId:o.threadId})},[t,e])}function Ve(e){return u(S,{children:[e.characters.map(t=>{let o=e.homeDesks.get(t.threadId);return o===void 0?null:i(Ce,{x:o.x,y:o.y,laptop:t.status==="working"&&e.positions.get(t.threadId)?.x===o.x&&e.positions.get(t.threadId)?.y===o.y,dark:e.archivedLine?.(t)===!0},`desk-${t.threadId}`)}),e.characters.map(t=>{let o=e.positions.get(t.threadId);return o===void 0?null:i(Ee,{character:t,slot:o,walker:e.walker,onOpen:e.onOpen},t.threadId)})]})}function ze(e){let t=v(()=>We(e.scene),[e.scene]),o=je(e.environmentId),r=qe(e.active);return u(Q,{plan:t,ariaLabel:e.scene.lines[0]?.name??"",children:[i(Me,{}),e.scene.lines[0]!==void 0?i(Ne,{name:e.scene.lines[0].name,counts:e.scene.lines[0].counts}):null,i(Ve,{characters:e.scene.characters,positions:t.positions,homeDesks:t.homeDesks,walker:r,onOpen:o})]})}function $e(e){let{t}=O(),{plan:o,islands:r}=v(()=>Be(e.scene),[e.scene]),n=je(e.environmentId),s=qe(e.active),c=R(l=>r.find(a=>a.line.workLineId===l.lineId)?.line.archived===!0,[r]);return u(Q,{plan:o,ariaLabel:t("office.floorLabel",{count:r.length}),compact:!0,children:[i("div",{className:"po-floor"}),r.map(l=>i(_e,{x:l.x,y:l.y,width:l.width,height:l.height,name:l.line.name,archived:l.line.archived,counts:l.line.counts},l.line.workLineId)),i(Ve,{characters:e.scene.characters,positions:o.positions,homeDesks:o.homeDesks,walker:s,onOpen:n,archivedLine:c})]})}var Ke=["working","waiting","monitoring","failed","idle","asleep","queued"];function pt(e){let{t}=O();return i("ul",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 px-4 py-2","data-office-legend":"",children:[...e.statuses].toSorted((o,r)=>Ke.indexOf(o[0])-Ke.indexOf(r[0])).map(([o,r])=>u("li",{className:"flex items-center gap-1.5 text-ui-sm text-muted-foreground",children:[i("span",{className:`po-dot po-dot-${o}`}),t(`office.status.${o}`)," \xD7 ",r]},o))})}function Ge(e){let{t}=O(),o=ve(e),r=v(()=>{let n=new Map;for(let s of o.scene?.characters??[]){let c=s.status;n.set(c,(n.get(c)??0)+1)}return n},[o.scene]);return u("section",{className:"ycodium-pixel-office-ui flex w-full min-w-0 flex-1 flex-col","data-office-scope":e.scope,"data-office-active":e.active,children:[o.subscription,o.watchFailed?u("p",{className:"flex items-center justify-center gap-2 px-4 py-1 text-ui-xs text-warning-foreground",children:[t("office.watchFailed"),i(Y,{size:"sm",onClick:()=>{o.retryWatch()},children:t("office.retryWatch")})]}):null,o.scene===null?o.loadFailed?u(K,{className:"m-auto",children:[i(G,{children:i(X,{children:t("office.loadFailed")})}),i(Y,{onClick:()=>{o.reload()},children:t("office.reload")})]}):i("p",{className:"m-auto",children:t("office.loading")}):o.scene.lines.length===0?i(K,{className:"m-auto",children:i(G,{children:i(X,{children:t("office.noTeams")})})}):u(S,{children:[e.scope==="team"&&e.threadId===null?i("p",{className:"px-4 pt-2 text-ui-xs text-muted-foreground",children:t("office.threadDeleted")}):null,o.scene.characters.length===0?i("p",{className:"px-4 pt-2 text-ui-xs text-muted-foreground",children:t("office.emptyRoom")}):null,i("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.scope==="team"?i(ze,{environmentId:e.environmentId,scene:o.scene,active:e.active}):i($e,{environmentId:e.environmentId,scene:o.scene,active:e.active})}),r.size>0?i(pt,{statuses:r}):null]})]})}function ft(e){return{slots:[Z({key:"office",component:function(o){return u(ie,{value:e,children:[i("style",{children:ee}),i(Ge,{...o})]})}})]}}export{ft as default};
588
+ `;var yt=window.__ycodiumPluginHost.react;var{Activity:eo,Children:to,Component:oo,Fragment:no,Profiler:ro,PureComponent:ao,StrictMode:io,Suspense:so,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:co,__COMPILER_RUNTIME:lo,act:mo,cache:po,cacheSignal:fo,captureOwnerStack:uo,cloneElement:ho,createContext:ge,createElement:j,createRef:go,forwardRef:yo,isValidElement:bo,lazy:wo,memo:V,startTransition:xo,unstable_useCacheRefresh:ko,use:vo,useActionState:Io,useCallback:N,useContext:ye,useDebugValue:Ro,useDeferredValue:Oo,useEffect:L,useEffectEvent:Mo,useId:Po,useImperativeHandle:So,useInsertionEffect:To,useLayoutEffect:be,useMemo:S,useOptimistic:Lo,useReducer:Co,useRef:v,useState:W,useSyncExternalStore:Eo,useTransition:No,version:Ao}=yt;var we=ge(null),xe=we.Provider;function M(){let e=ye(we);if(e===null)throw new Error("pixel-office-ui-not-registered");return e}function R(){let e=M().i18n.usePluginTranslation();return{t:(t,o)=>e(t,o)}}function ke({environmentId:e,projectId:t,onBell:o,retryRef:n}){let r=M(),a=S(()=>({projectId:t}),[t]),l=S(()=>({environmentId:e}),[e]),s=r.commands.useSubscription("watch",a,l),c=s.data,m=c?.cursor??null,i=c?.threads,f=c?.remoteChanged,h=s.error!==null||s.isUnavailable,p=v(!1);return L(()=>{n.current=s.refresh}),L(()=>{if(!p.current){p.current=!0,o({cursor:m,failed:h,initial:!0});return}o({cursor:m,failed:h,...i===void 0?{}:{threads:i},...f!==!0?{}:{remoteChanged:!0}})},[m,h,i,f]),null}var G=e=>e.summary?.origin?.requestedBy==="person",B=(e,t,o,n=null)=>{let r=new Set(o.map(i=>i.memberId)),a=new Map,l=new Map,s=new Set,c=[],m=new Map(t.map(i=>[i.threadId,i]));for(let i of e){if(a.set(i.workLineId,new Map),i.threadId===null)continue;l.set(i.threadId,{lineId:i.workLineId,members:new Set(i.memberIds)});let f=m.get(i.threadId),h=n?.id===i.threadId?n:null;if(f===void 0&&h===null)continue;let p=i.leadMemberId??f?.memberId??h?.memberId;p!=null&&s.add(p),(f?.status==="idle"||h!==null&&(h.status??"idle")==="idle")&&c.push(i.threadId)}for(let i of t){if(i.memberId===void 0||i.archivedAt!==null||!G(i))continue;let f=i.parentThreadId===null?void 0:l.get(i.parentThreadId);if(f===void 0||!f.members.has(i.memberId)||!r.has(i.memberId))continue;let h=a.get(f.lineId),p=h.get(i.memberId);p===void 0?h.set(i.memberId,[i]):p.push(i),s.add(i.memberId),i.status==="idle"&&c.push(i.threadId)}return{byLine:a,localIds:s,idleIds:[...new Set(c)]}};var b=e=>e.memberId===null?e.threadId:`${e.lineId}:${e.memberId}`,H=e=>`${e.lineId}:${e.memberId}`,bt={todo:0,started:0,completed:0,cancelled:0},wt=e=>{let t={...bt};for(let o of e)switch(o.state.group){case"started":t.started+=1;break;case"completed":t.completed+=1;break;case"cancelled":t.cancelled+=1;break;default:t.todo+=1;break}return t},ve=(e,t)=>({workLineId:e.workLineId,name:e.name,archived:e.archivedAt!==null,threadId:e.threadId,counts:wt(t.filter(o=>o.workLineId===e.workLineId))}),xt=e=>[...e].sort((t,o)=>t.archived!==o.archived?t.archived?1:-1:t.workLineId.localeCompare(o.workLineId)),Ie=e=>[...e].sort((t,o)=>t.lineId!==o.lineId?t.lineId.localeCompare(o.lineId):t.role!==o.role?t.role==="lead"?-1:1:b(t).localeCompare(b(o))),Re=e=>[...e].sort((t,o)=>t.lineId!==o.lineId?t.lineId.localeCompare(o.lineId):t.memberId.localeCompare(o.memberId)),Oe=(e,t,o,n,r,a,l)=>({threadId:o,title:n,role:t,status:r,queuePosition:a,lineId:e,memberId:l}),Me=e=>{switch(e){case"needs-approval":case"needs-input":case"plan-ready":return"waiting";case"running":return"working";case"background":return"monitoring";case"failed":return"failed";case"stopped":return"asleep";default:return"idle"}},kt=e=>Me(e.status??"idle"),te=e=>{let t=new Map;for(let o of e){if(o===null||o.continuation!=="queued")continue;let n=o.queue.find(r=>r.status==="blocked"&&r.waitingForCapacity===!0);n!==void 0&&t.set(o.threadId,n.position)}return t},Pe=(e,t)=>e==="idle"&&t!==null?"queued":e,vt=(e,t,o,n)=>Se(e,"lead",t,o,n),Se=(e,t,o,n,r)=>Oe(e,t,o.threadId,o.title,Pe(Me(o.status),n),n,r),It=(e,t,o,n)=>Oe(e,"lead",t.id,t.title,Pe(kt(t),o),o,n),X={waiting:5,failed:4,working:3,queued:2,monitoring:2,idle:1,asleep:1},Te=(e,t,o,n)=>{let r=new Set(e.memberIds),a=[];for(let l of t)!r.has(l.memberId)||l.memberId===e.leadMemberId||o.has(l.memberId)||oe(l,n).kind==="local"&&a.push({memberId:l.memberId,title:l.name,lineId:e.workLineId});return a},Le=(e,t,o)=>{let n=new Map;for(let[r,a]of t??[])for(let l of a){let s=o.get(l.threadId)??null,c={...Se(e,"member",l,s,r),createdAt:l.createdAt},m=n.get(r);(m===void 0||X[c.status]>X[m.status]||X[c.status]===X[m.status]&&c.createdAt>m.createdAt)&&n.set(r,c)}return n},oe=(e,t,o=!1)=>o?{kind:"local"}:e.identity?.kind==="remote-agent"?{kind:"principal",principalId:e.identity.principalId}:t!==void 0&&e.agent!==null&&e.agent.environmentId!==t?{kind:"machine",environmentId:e.agent.environmentId}:{kind:"local"},Ce=(e,t,o,n)=>{let r=new Set(e.flatMap(s=>s.memberIds)),a=o.localIds,l=[];for(let s of t){if(!r.has(s.memberId))continue;let c=oe(s,n,a.has(s.memberId));c.kind!=="local"&&l.push({memberId:s.memberId,principalId:c.kind==="principal"?c.principalId:null})}return l},Ee=(e,t,o,n,r)=>{let a=new Set(e.flatMap(c=>c.memberIds)),l=new Map;for(let c of t){if(!a.has(c.memberId))continue;let m=oe(c,o.current,r.has(c.memberId));if(m.kind==="local")continue;let i=m.kind==="principal"?m.principalId:null,f=m.kind==="machine"?m.environmentId:null,h=n.get(c.memberId)??{lastMessageAt:null,stage:"unknown"},p=i!==null?o.principalLabels?.[i]??c.name:c.name,O={memberId:c.memberId,title:p,...h},w=f??"other",y=l.get(w);y===void 0?l.set(w,[O]):y.push(O)}let s=(c,m)=>c.memberId.localeCompare(m.memberId);return[...l.entries()].sort((c,m)=>c[0]==="other"?1:m[0]==="other"?-1:c[0].localeCompare(m[0])).map(([c,m])=>({environmentId:c==="other"?null:c,members:[...m].sort(s)}))},ne=e=>{let t=e.line.workLineId,o=e.candidates??B([e.line],e.members,e.roster,e.lead),n=Le(t,o.byLine.get(t),e.queue);return{lines:[ve(e.line,e.items)],characters:Ie([...e.lead===null?[]:[It(t,e.lead,e.queue.get(e.lead.id)??null,e.line.leadMemberId??e.lead.memberId??null)],...n.values()]),bench:Re(Te(e.line,e.roster,n,e.machines?.current)),remoteRooms:e.machines===void 0?[]:Ee([e.line],e.roster,e.machines,e.remoteFacts??new Map,o.localIds)}},Ne=e=>{let t=e.candidates??B(e.lines,e.threads,e.roster),o=new Map(e.threads.map(a=>[a.threadId,a])),n=[],r=[];for(let a of e.lines){let l=a.workLineId,s=a.threadId===null?void 0:o.get(a.threadId);s!==void 0&&n.push(vt(l,s,e.queue.get(s.threadId)??null,a.leadMemberId??s.memberId??null));let c=Le(l,t.byLine.get(l),e.queue);for(let m of c.values())n.push(m);r.push(...Te(a,e.roster,c,e.machines?.current))}return{lines:xt(e.lines.map(a=>ve(a,e.items))),characters:Ie(n),bench:Re(r),remoteRooms:e.machines===void 0?[]:Ee(e.lines,e.roster,e.machines,e.remoteFacts??new Map,t.localIds)}};var Ae=e=>{switch(e){case"answered":return"answered";case"picked-up":return"picked-up";case"waiting":return"delivered";default:return"unknown"}},Rt=e=>Ae(ee({replied:e.stages.replied?.recordId!==void 0,toPerson:!1,handedOff:e.stages.handedOff.certainty==="confirmed"||e.claim!=null?"confirmed":e.stages.handedOff.certainty,body:e.bodyState})),Ot=(e,t)=>Ae(ee({replied:t.stages.replied!==null,toPerson:!1,handedOff:t.stages.handedOff!==null?"confirmed":t.participant===null?"unknown":"not-dispatched",body:e.bodyState})),Mt=(e,t)=>{if(t.principalId!==null){if(e.from.kind==="remote-agent"&&e.from.principalId===t.principalId)return{direction:"from",stage:"delivered"};if(e.to?.kind==="remote-agent"&&e.to.principalId===t.principalId)return{direction:"to",stage:Rt(e)}}for(let o of e.targets??[])if(o.member===t.memberId)return{direction:"to",stage:Ot(e,o)}},Fe=e=>{let t=new Map(e.map(o=>[o.memberId,{stage:"unknown",inboundSeen:!1,lastMessageAt:null}]));return{observe(o){for(let n of o)for(let r of e){let a=t.get(r.memberId);if(a===void 0||a.inboundSeen&&a.lastMessageAt!==null)continue;let l=Mt(n,r);l!==void 0&&(l.direction==="to"&&!a.inboundSeen&&(a.stage=l.stage,a.inboundSeen=!0),a.lastMessageAt===null&&(l.direction==="from"||l.stage==="picked-up"||l.stage==="answered")&&(a.lastMessageAt=n.createdAt))}},complete(){return[...t.values()].every(o=>o.inboundSeen&&o.lastMessageAt!==null)},facts(){return new Map([...t].map(([o,n])=>[o,{lastMessageAt:n.lastMessageAt,stage:n.stage}]))}}};var U=async e=>{let t=[],o=null;for(;;){let n=await e(o);if(t.push(...n.items),n.nextCursor===null)return t;o=n.nextCursor}},_e=async(e,t,o)=>{if(o.length===0)return te([]);let n=await Promise.all(o.map(r=>e.data.read("threads.execution.summary",{threadId:r},{environmentId:t}).catch(()=>null)));return te(n)},Be=async(e,t,o)=>U(n=>e.data.read("members.list",{projectId:o,cursor:n},{environmentId:t})),Pt=async(e,t,o)=>{let n=await U(r=>e.data.read("auth.remoteAgents.list",{projectId:o,cursor:r},{environmentId:t}));return Object.fromEntries(n.map(r=>[r.principalId,r.label]))},St=async(e,t,o,n)=>{let r=Fe(n),a=null;for(;;){let l=await e.data.read("communication.records.list",{projectId:o,cursor:a},{environmentId:t});if(r.observe(l.items),l.nextCursor===null||r.complete())return r.facts();a=l.nextCursor}},Tt=async(e,t,o,n,r)=>{let a=JSON.stringify(n),l=r?.key===a?r.facts:null,s=r?.revision,[c,m]=await Promise.all([Pt(e,t,o),l??St(e,t,o,n)]);return r!==void 0&&r.revision===s&&l===null&&(r.key=a,r.facts=m),{principalLabels:c,facts:m}},re=async(e,t,o,n,r,a,l,s)=>{let c=Ce(n,r,a,l.current);return c.length===0?{principalLabels:{},facts:new Map}:Tt(e,t,o,c,s)};async function Ue(e,t,o,n){let{environmentId:r,projectId:a,workLineId:l}=t,{line:s}=await e.data.read("work.lines.get",{projectId:a,workLineId:l},{environmentId:r}),c=U(T=>e.data.read("work.items.list",{projectId:a,workLineIds:[l],cursor:T},{environmentId:r})),m=Be(e,r,a);if(s.threadId===null){let[T,F]=await Promise.all([c,m]),I=B([s],[],F),E=await re(e,r,a,[s],F,I,o,n);return ne({line:s,lead:null,members:[],roster:F,items:T,queue:new Map,candidates:I,machines:{...o,principalLabels:E.principalLabels},remoteFacts:E.facts})}let i=s.threadId,[f,h,p]=await Promise.all([e.data.read("threads.get",{threadId:i},{environmentId:r}).catch(()=>null),U(T=>e.data.read("threads.list",{projectId:a,parentThreadId:i,include:["summary"],cursor:T},{environmentId:r})),c]),O=h.filter(G),w=await m,y=B([s],O,w,f),k=await _e(e,r,y.idleIds),C=await re(e,r,a,[s],w,y,o,n);return ne({line:s,lead:f,members:O,roster:w,items:p,queue:k,candidates:y,machines:{...o,principalLabels:C.principalLabels},remoteFacts:C.facts})}async function De(e,t,o,n){let{environmentId:r,projectId:a}=t,[l,s,c]=await Promise.all([U(p=>e.data.read("work.lines.list",{projectId:a,includeArchived:!0,cursor:p},{environmentId:r})),U(p=>e.data.read("threads.list",{projectId:a,include:["summary"],cursor:p},{environmentId:r})),U(p=>e.data.read("work.items.list",{projectId:a,cursor:p},{environmentId:r}))]),m=await Be(e,r,a),i=B(l,s,m),f=await _e(e,r,i.idleIds),h=await re(e,r,a,l,m,i,o,n);return Ne({lines:l,threads:s,roster:m,items:c,queue:f,candidates:i,machines:{...o,principalLabels:h.principalLabels},remoteFacts:h.facts})}var Lt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function We(e,t){let{environmentId:o,projectId:n,active:r}=e,a=e.scope==="team"?e.workLineId:null,l=M(),s=v(()=>{}),c=N(()=>s.current(),[]),m=S(()=>({scene:null}),[o,n,a]),i=S(()=>({active:!1,dirty:!1,running:null}),[o,n,a]),f=S(()=>({key:null,facts:null,revision:0}),[o,n,a]),h=N(()=>{f.revision+=1,f.key=null,f.facts=null},[f]),p=v(e);p.current=e;let O=v(t);O.current=t;let[w,y]=W(null),[k,C]=W(!1),[T,F]=W(!1),I=N(()=>!i.active||!p.current.active?Promise.resolve():(i.dirty=!0,i.running!==null||(i.running=(async()=>{try{do{i.dirty=!1;try{let g=p.current.scope==="team"?await Ue(l,p.current,O.current,f):await De(l,p.current,O.current,f);if(!i.active||!p.current.active)return;(m.scene===null||!Lt(g,m.scene))&&(m.scene=g,y(g)),C(!1)}catch{if(!i.active||!p.current.active)return;C(!0)}}while(i.active&&i.dirty)}finally{i.running=null}})()),i.running),[l,m,i,f]);L(()=>(i.active=!0,m.scene=null,y(null),C(!1),I(),()=>{i.active=!1}),[i,I,m]);let E=v(null),Z=N(g=>{if(F(K=>K===g.failed?K:g.failed),g.initial===!0){g.cursor!==null&&(E.current=g.cursor);return}let D=E.current;if(Object.is(D,g.cursor))return;E.current=g.cursor;let pe=D!==null&&g.cursor===D+1;if((!pe||g.remoteChanged===!0)&&h(),pe&&g.threads!==void 0){let K=p.current.scope==="team"?[p.current.threadId]:m.scene?.lines.map(_=>_.threadId)??[],ut=new Set(K),ht=new Set([...K,...m.scene?.characters.map(_=>_.threadId)??[]]);if(!g.threads.ids.some(_=>ht.has(_))&&!g.threads.parentIds.some(_=>ut.has(_)))return}I()},[m,I,h]),z=v(r);L(()=>{r&&!z.current&&(h(),I()),z.current=r},[r,I,h]);let x=N(()=>(h(),I()),[h,I]);return{scene:w,loadFailed:k,reload:x,watchFailed:r&&T,retryWatch:c,subscription:r?j(ke,{environmentId:o,projectId:n,onBell:Z,retryRef:s}):null}}function ae(e){return function(o){return j(M().ui[e],{...o})}}var ie=ae("Empty"),se=ae("EmptyHeader"),ce=ae("EmptyTitle");function le(e){return j(M().ui.Button,e)}var Ct={working:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".s.cccc.s.","...kkkk...","..pppppp..","..pp..pp..","..b....b..",".........."],waiting:["...hhhh.s.","..hhhhhh.s","..ssssss.s","..sesses.s","..ssssss.s",".ccccccccc","cccccccccc","cccccccccc",".s.cccc...","...pppp...","..pp..pp..","..pp..pp..","..b....b..",".........."],failed:["..........","..........","...hhhh...","..hhhhhh..","..ssssss..","..ssssss..",".cccccccc.","cccccccccc","sccccccccs","s........s","..pppppp..","..pp..pp..","..b....b..",".........."],idle:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","u.ccccccc.","u.scccc...","...pppp...","..pp..pp..","..pp..pp..","..b....b..",".........."],asleep:["..........","...hhhh...","..hhhhhh..","..ssssss..","..s.ss.s..",".cccccccc.","cccccccccc","cccccccccc",".cccccccc.","..pppppp..","..pppppp..","..........","..........",".........."],monitoring:["...hhhh...","..hhhhhh..","..ssssss..","..sesses..","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".ccccccc..","..pppppp..","..pp..pp..","..pp..pp..","..b....b..",".........."],queued:["...hhhh...","..hhhhhh..","..ssssss..","..sssssee.","..ssssss..",".cccccccc.","cccccccccc","cccccccccc",".s.cccccc.","..ppppppk.","..pppppp..","..pppppp..","...b..b...",".........."]},P=3,He=10,Et=14,Y=1,qe=new Map;function q(e){let t=qe.get(e);if(t!==void 0)return t;let o=Ct[e],n=[];for(let[a,l]of o.entries()){if(l.length!==He)throw new Error(`pose-${e}-row-${a}-width`);for(let[s,c]of[...l].entries())c!=="."&&n.push(`${(s+Y)*P}px ${(a+Y)*P}px 0 var(--po-${c})`)}let r={boxShadow:n.join(", "),width:(He+Y)*P,height:(Et+Y)*P};return qe.set(e,r),r}var $e=["#f2c9a0","#dcae7c","#c28c5c","#9c6b44"],Ke=["#2f2a26","#5b4632","#8a6a3f","#b58a52","#d9c48f","#6e6e73","#40485c"],je=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#64748b"],ze=["#334155","#1e293b","#4b5563"],Nt=e=>{let t=5381;for(let o of e)t=(t*33^o.charCodeAt(0))>>>0;return t};function $(e){let t=Nt(e);return{"--po-h":Ke[(t>>>0)%Ke.length],"--po-s":$e[(t>>>3)%$e.length],"--po-e":"#26221e","--po-c":je[(t>>>6)%je.length],"--po-p":ze[(t>>>9)%ze.length],"--po-b":"#3b2f2a","--po-k":"#4b5563","--po-u":"#f4f1ea"}}var{jsx:d,jsxs:u,Fragment:A}=window.__ycodiumPluginHost.jsxRuntime;var At=e=>{switch(e.status){case"waiting":return"?";case"failed":return"!";case"asleep":return"z";case"queued":return e.queuePosition===null?"\u2026":String(e.queuePosition);default:return null}},Ve=V(function(t){let{character:o,slot:n}=t,r=b(o),{t:a}=R(),l=q(o.status),s=At(o),c=a(`office.status.${o.status}`),m=v(null),i=v(t.walker);i.current=t.walker;let f=v(n);return be(()=>{let h=m.current,p=f.current;f.current=n,!(h===null||p.x===n.x&&p.y===n.y)&&i.current.move(r,h,p,n)},[n,r]),u("button",{ref:m,type:"button",className:"po-character","data-office-character":o.threadId,"data-office-status":o.status,style:{left:n.x,top:n.y,...$(o.memberId??o.threadId)},"aria-label":`${a("office.characterLabel",{name:o.title,status:c})}${o.role==="lead"?` \xB7 ${a("office.leadBadge")}`:""}${o.queuePosition!==null?` \xB7 ${a("office.queuePosition",{position:o.queuePosition})}`:""}`,onClick:()=>t.onOpen(o),children:[d("span",{className:"po-sprite-frame",style:{width:l.width,height:l.height},children:d("span",{className:"po-sprite",style:{width:P,height:P,boxShadow:l.boxShadow}})}),s===null?null:d("span",{className:`po-bubble po-bubble-${o.status}`,children:s}),d("span",{className:"po-name",children:o.title})]})});function de(e){let t=v(null),[o,n]=W(1),r=e.plan.width;L(()=>{let l=t.current;if(l===null||typeof ResizeObserver>"u")return;let s=new ResizeObserver(()=>{let c=Math.min(l.clientWidth/r,1.4);n(m=>Math.abs(m-c)<.001?m:c)});return s.observe(l),()=>s.disconnect()},[r]);let a={width:e.plan.width,height:e.plan.height,transform:`scale(${o})`};return d("div",{ref:t,className:"po-viewport relative flex w-full min-w-0 items-center justify-center overflow-hidden",style:{height:"100%",minHeight:e.plan.height*o,"--po-name-w":e.compact===!0?"64px":"120px"},children:d("div",{className:"relative shrink-0",style:{width:e.plan.width*o,height:e.plan.height*o},children:d("div",{className:"po-stage absolute left-0 top-0 origin-top-left","data-office-room":"",role:"group","aria-label":e.ariaLabel,style:a,children:e.children})})})}var Q=(e,t,o,n,r,a)=>d("div",{className:r,style:{left:e,top:t,width:o,height:n}},a);function Ge(e){return u(A,{children:[Q(e.x-34,e.y+4,68,10,`po-desk-top${e.dark?" po-desk-dim":""}`,"top"),Q(e.x-30,e.y+14,4,18,"po-desk-leg","leg-l"),Q(e.x+26,e.y+14,4,18,"po-desk-leg","leg-r"),e.laptop?Q(e.x-10,e.y-2,20,7,"po-laptop","laptop"):null]})}function Xe(){return u(A,{children:[d("div",{className:"po-floor"}),d("div",{className:"po-wall"}),d("div",{className:"po-window",style:{left:300,top:28}}),d("div",{className:"po-window",style:{left:430,top:28}}),d("div",{className:"po-door"}),d("div",{className:"po-counter"}),d("div",{className:"po-coffee"}),d("div",{className:"po-couch"}),d("div",{className:"po-cooler"}),d("div",{className:"po-plant",style:{left:900,top:130}})]})}function Ye(e){let{t}=R();return u("div",{className:"po-board","data-office-board":"",children:[d("div",{className:"po-board-title",children:e.name}),u("div",{className:"po-board-row",children:[d("span",{className:"po-dot po-dot-todo"}),t("office.counts.todo",{count:e.counts.todo})]}),u("div",{className:"po-board-row",children:[d("span",{className:"po-dot po-dot-started"}),t("office.counts.started",{count:e.counts.started})]}),u("div",{className:"po-board-row",children:[d("span",{className:"po-dot po-dot-completed"}),t("office.counts.completed",{count:e.counts.completed})]}),u("div",{className:"po-board-row",children:[d("span",{className:"po-dot po-dot-cancelled"}),t("office.counts.cancelled",{count:e.counts.cancelled})]})]})}function Qe(e){let{t}=R();return u(A,{children:[d("div",{className:`po-island${e.archived?" po-island-archived":""}`,style:Ft(e)}),u("div",{className:`po-island-sign${e.archived?" po-island-sign-archived":""}`,style:{left:e.x+8,top:e.y-26},children:[d("span",{className:"po-island-name",children:e.name}),e.archived?d("span",{className:"po-island-badge",children:t("office.archived")}):null,u("span",{className:"po-island-count",children:[t("office.counts.started",{count:e.counts.started})," \xB7"," ",t("office.counts.completed",{count:e.counts.completed})]})]})]})}var Ft=e=>({left:e.x,top:e.y,width:e.width,height:e.height});var me=960;function ot(e){let t=new Map,o=new Map,n=["waiting","idle","asleep","monitoring","queued"],r=new Map(n.map(i=>[i,0])),a=e.characters.filter(i=>i.role==="member");for(let[i,f]of a.entries())o.set(b(f),{x:150+i%6*130,y:330+Math.floor(i/6)*120});for(let i of e.characters){let f=r.get(i.status);i.role==="lead"&&o.set(b(i),{x:470,y:220}),i.status==="working"||i.status==="failed"?t.set(b(i),o.get(b(i))):f!==void 0?(t.set(b(i),_t(i.status,f)),r.set(i.status,f+1)):t.set(b(i),o.get(b(i)))}let l=[...t.values(),...o.values()],s=new Map,c=Math.max(524,Math.max(0,...l.map(i=>i.y))+78);e.bench.forEach((i,f)=>s.set(H(i),{x:96+f%6*128,y:c+Math.floor(f/6)*64}));let m=Math.max(0,...[...l,...s.values()].map(i=>i.y));return{width:me,height:Math.max(540,m+70),positions:t,homeDesks:o,bench:s}}var _t=(e,t)=>{switch(e){case"waiting":return{x:830,y:250+t*62};case"idle":return{x:100,y:260+t*58};case"asleep":return{x:100,y:430+t*50};case"monitoring":return{x:215,y:185+t*58};default:return{x:872,y:468+t*52}}},Je=3,Ze=296,et=240,tt=316,Bt=24;function nt(e){let t=new Map,o=new Map,n=[],r=new Map;for(let c of e.characters){let m=r.get(c.lineId);m===void 0?r.set(c.lineId,[c]):m.push(c)}let a=new Map;for(let c of e.bench){let m=a.get(c.lineId);m===void 0?a.set(c.lineId,[c]):m.push(c)}let l=new Map,s=156;for(let c=0;c<e.lines.length;c+=Je){let i=e.lines.slice(c,c+Je).map(p=>{let O=r.get(p.workLineId)??[],w=new Map,y=new Map,k=[],C=0;for(let x of O){if(x.role==="lead"){let D={x:Ze/2,y:72};w.set(b(x),D),y.set(b(x),D);continue}let g={x:58+C%3*90,y:150+Math.floor(C/3)*78};C+=1,w.set(b(x),g),x.status==="working"||x.status==="failed"?y.set(b(x),g):k.push(b(x))}let T=Math.max(0,...[...w.values()].map(x=>x.y)),F=a.get(p.workLineId)??[],I=Math.max(et-12,T+80);k.forEach((x,g)=>{y.set(x,{x:40+g%4*72,y:I+Math.floor(g/4)*60})});let E=new Map,Z=Math.max(I+Math.ceil(k.length/4)*60,T+80);F.forEach((x,g)=>E.set(H(x),{x:40+g%4*72,y:Z+Math.floor(g/4)*60}));let z=Math.max(0,...[...y.values(),...E.values()].map(x=>x.y));return{line:p,desks:w,localPositions:y,localBench:E,height:Math.max(et,T+70,z+70)}}),f=Math.max(...i.map(p=>p.height)),h=(me-i.length*tt)/2;i.forEach((p,O)=>{let w=h+O*tt+10;n.push({line:p.line,x:w,y:s,width:Ze,height:f});for(let[y,k]of p.desks)o.set(y,{x:w+k.x,y:s+k.y});for(let[y,k]of p.localPositions)t.set(y,{x:w+k.x,y:s+k.y});for(let[y,k]of p.localBench)l.set(y,{x:w+k.x,y:s+k.y})}),s+=f+Bt}return{islands:n,plan:{width:me,height:s+16,positions:t,homeDesks:o,bench:l}}}var J=class{walks=new Map;handle=null;requestFrame;cancelFrame;schedule;cancelSchedule;animated;constructor(t={}){let o=t.requestFrame!==void 0||typeof requestAnimationFrame=="function";this.requestFrame=t.requestFrame??(n=>requestAnimationFrame(n)),this.cancelFrame=t.cancelFrame??(n=>cancelAnimationFrame(n)),this.schedule=t.schedule??(n=>Number(setTimeout(n,125))),this.cancelSchedule=t.cancelSchedule??(n=>clearTimeout(n)),this.animated=o}move(t,o,n,r){let a=this.walks.get(t),l=(a===void 0?n.x:a.toX+a.dx)-r.x,s=(a===void 0?n.y:a.toY+a.dy)-r.y,c=Math.max(Math.abs(l),Math.abs(s))<24;if(!this.animated||c){a!==void 0?this.finish(t):this.paintAt(o,0,0);return}this.walks.set(t,{element:o,dx:l,dy:s,toX:r.x,toY:r.y}),o.setAttribute("data-office-walking",""),this.paint(t),this.ensureLoop("raf")}stopAll(){this.clearHandle();let t=[...this.walks.keys()];for(let o of t)this.finish(o);this.walks.clear()}get isWalking(){return this.walks.size>0}clearHandle(){let t=this.handle;this.handle=null,t!==null&&(t.kind==="raf"?this.cancelFrame:this.cancelSchedule)(t.id)}ensureLoop(t){this.handle===null&&(this.handle=t==="raf"?{kind:"raf",id:this.requestFrame(()=>this.step())}:{kind:"timer",id:this.schedule(()=>{this.handle=null,this.ensureLoop("raf")})})}step(){this.handle=null;let t=[...this.walks.keys()];for(let o of t){let n=this.walks.get(o);n!==void 0&&(n.dx=rt(n.dx),n.dy=rt(n.dy),n.dx===0&&n.dy===0?this.finish(o):this.paint(o))}this.walks.size>0&&this.ensureLoop("timer")}finish(t){let o=this.walks.get(t);o!==void 0&&(this.walks.delete(t),o.element.removeAttribute("data-office-walking"),this.paintAt(o.element,0,0))}paint(t){let o=this.walks.get(t);o!==void 0&&this.paintAt(o.element,o.dx,o.dy)}paintAt(t,o,n){t.style.transform=o===0&&n===0?"translate(-50%, -100%)":`translate(-50%, -100%) translate(${o}px, ${n}px)`}},rt=e=>{if(e===0)return 0;let t=Math.min(Math.abs(e),8);return e>0?e-t:e+t};function at(e){let t=v(null);return t.current===null&&(t.current=new J),L(()=>{e||t.current?.stopAll()},[e]),L(()=>()=>t.current?.stopAll(),[]),t.current}function it(e){let t=M();return N(o=>{t.openThread({environmentId:e,threadId:o.threadId})},[t,e])}function Ut(e){let{t}=R(),o=q("idle");return u(A,{children:[d("div",{className:"po-bench-seat",style:{left:e.slot.x-48,top:e.slot.y-42},"aria-hidden":"true"}),u("div",{className:"po-character po-bench-figure","data-office-bench":e.member.memberId,role:"img","aria-label":t("office.benchLabel",{name:e.member.title}),style:{left:e.slot.x,top:e.slot.y,...$(e.member.memberId)},children:[d("span",{className:"po-sprite-frame",style:{width:o.width,height:o.height},children:d("span",{className:"po-sprite",style:{width:P,height:P,boxShadow:o.boxShadow}})}),d("span",{className:"po-name",children:e.member.title}),d("span",{className:"po-bench-tag",children:t("office.benchTitle")})]})]})}function st(e){return u(A,{children:[e.characters.map(t=>{let o=b(t),n=e.homeDesks.get(o);return n===void 0?null:d(Ge,{x:n.x,y:n.y,laptop:t.status==="working"&&e.positions.get(o)?.x===n.x&&e.positions.get(o)?.y===n.y,dark:e.archivedLine?.(t)===!0},`desk-${o}`)}),e.characters.map(t=>{let o=b(t),n=e.positions.get(o);return n===void 0?null:d(Ve,{character:t,slot:n,walker:e.walker,onOpen:e.onOpen},o)}),e.scene.bench.map(t=>{let o=e.bench.get(H(t));return o===void 0?null:d(Ut,{member:t,slot:o},`bench-${H(t)}`)})]})}function ct(e){let t=S(()=>ot(e.scene),[e.scene]),o=it(e.environmentId),n=at(e.active);return u(de,{plan:t,ariaLabel:e.scene.lines[0]?.name??"",children:[d(Xe,{}),e.scene.lines[0]!==void 0?d(Ye,{name:e.scene.lines[0].name,counts:e.scene.lines[0].counts}):null,d(st,{scene:e.scene,characters:e.scene.characters,positions:t.positions,homeDesks:t.homeDesks,bench:t.bench,walker:n,onOpen:o})]})}function lt(e){let{t}=R(),{plan:o,islands:n}=S(()=>nt(e.scene),[e.scene]),r=it(e.environmentId),a=at(e.active),l=N(s=>n.find(c=>c.line.workLineId===s.lineId)?.line.archived===!0,[n]);return u(de,{plan:o,ariaLabel:t("office.floorLabel",{count:n.length}),compact:!0,children:[d("div",{className:"po-floor"}),n.map(s=>d(Qe,{x:s.x,y:s.y,width:s.width,height:s.height,name:s.line.name,archived:s.line.archived,counts:s.line.counts},s.line.workLineId)),d(st,{scene:e.scene,characters:e.scene.characters,positions:o.positions,homeDesks:o.homeDesks,bench:o.bench,walker:a,onOpen:r,archivedLine:l})]})}var dt=(e,t,o,n)=>e.environmentId===null?n:t.find(a=>a.environmentId===e.environmentId)?.label??`${o} \xB7 ${e.environmentId.slice(0,6)}`,Dt=V(function(t){let{t:o}=R(),n=q("idle"),{member:r}=t;return u("div",{className:"po-remote-figure","data-office-remote-member":r.memberId,"data-office-stage":r.stage,role:"img","aria-label":`${o("office.remoteLabel",{name:r.title,stage:o(`office.remoteStage.${r.stage}`)})}${r.lastMessageAt===null?"":` \xB7 ${o("office.lastMessage",{time:t.formatTime(r.lastMessageAt)})}`}`,style:{...$(r.memberId)},children:[d("span",{className:"po-sprite-frame",style:{width:n.width,height:n.height},children:d("span",{className:"po-sprite",style:{width:P,height:P,boxShadow:n.boxShadow}})}),d("span",{className:"po-name",children:r.title}),d("span",{className:"po-remote-stage",children:o(`office.remoteStage.${r.stage}`)}),d("span",{className:"po-remote-last",children:r.lastMessageAt===null?o("office.noMessage"):o("office.lastMessage",{time:t.formatTime(r.lastMessageAt)})})]})});function mt(e){let{t}=R();return e.rooms.length===0?null:d("div",{className:"po-remote-rooms","data-office-remote-rooms":"",children:e.rooms.map(o=>u("section",{className:"po-remote-room","data-office-remote-room":o.environmentId??"other","aria-label":dt(o,e.known,t("office.anotherMachine"),t("office.otherMachines")),children:[d("h3",{className:"po-remote-room-name",children:dt(o,e.known,t("office.anotherMachine"),t("office.otherMachines"))}),d("div",{className:"po-remote-figures",children:o.members.map(n=>d(Dt,{member:n,formatTime:e.formatTime},n.memberId))})]},o.environmentId??"other"))})}var pt=["working","waiting","monitoring","failed","idle","asleep","queued"];function Wt(e){let{t}=R();return d("ul",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 px-4 py-2","data-office-legend":"",children:[...e.statuses].toSorted((o,n)=>pt.indexOf(o[0])-pt.indexOf(n[0])).map(([o,n])=>u("li",{className:"flex items-center gap-1.5 text-ui-sm text-muted-foreground",children:[d("span",{className:`po-dot po-dot-${o}`}),t(`office.status.${o}`)," \xD7 ",n]},o))})}function ft(e){let{t}=R(),o=M(),n=o.useConnectedEnvironments(),r=o.useFormatTimestamp(),a=We(e,{current:e.environmentId}),l=S(()=>{let s=new Map;for(let c of a.scene?.characters??[]){let m=c.status;s.set(m,(s.get(m)??0)+1)}return s},[a.scene]);return u("section",{className:"ycodium-pixel-office-ui flex w-full min-w-0 flex-1 flex-col","data-office-scope":e.scope,"data-office-active":e.active,children:[a.subscription,a.watchFailed?u("p",{className:"flex items-center justify-center gap-2 px-4 py-1 text-ui-xs text-warning-foreground",children:[t("office.watchFailed"),d(le,{size:"sm",onClick:()=>{a.retryWatch()},children:t("office.retryWatch")})]}):null,a.scene===null?a.loadFailed?u(ie,{className:"m-auto",children:[d(se,{children:d(ce,{children:t("office.loadFailed")})}),d(le,{onClick:()=>{a.reload()},children:t("office.reload")})]}):d("p",{className:"m-auto",children:t("office.loading")}):a.scene.lines.length===0?d(ie,{className:"m-auto",children:d(se,{children:d(ce,{children:t("office.noTeams")})})}):u(A,{children:[e.scope==="team"&&e.threadId===null?d("p",{className:"px-4 pt-2 text-ui-xs text-muted-foreground",children:t("office.threadDeleted")}):null,a.scene.characters.length===0?d("p",{className:"px-4 pt-2 text-ui-xs text-muted-foreground",children:t("office.emptyRoom")}):null,u("div",{className:"po-floor-map min-h-0 flex-1 overflow-y-auto","data-office-floor":"",children:[e.scope==="team"?d(ct,{environmentId:e.environmentId,scene:a.scene,active:e.active}):d(lt,{environmentId:e.environmentId,scene:a.scene,active:e.active}),d(mt,{rooms:a.scene.remoteRooms,known:n.map(({environmentId:s,label:c})=>({environmentId:s,label:c})),formatTime:r})]}),l.size>0?d(Wt,{statuses:l}):null]})]})}function Ht(e){return{slots:[ue({key:"office",component:function(o){return u(xe,{value:e,children:[d("style",{children:he}),d(ft,{...o})]})}})]}}export{Ht as default};
package/dist/index.js CHANGED
@@ -6101,7 +6101,24 @@ var LINE_EVENTS = /* @__PURE__ */ new Set([
6101
6101
  "work.line-restored"
6102
6102
  ]);
6103
6103
  var ITEM_EVENTS = /* @__PURE__ */ new Set(["work.item-created", "work.item-updated"]);
6104
- var WATCH_EVENTS = [...LINE_EVENTS, ...ITEM_EVENTS];
6104
+ var MEMBER_EVENTS = /* @__PURE__ */ new Set([
6105
+ "member.created",
6106
+ "member.updated",
6107
+ "member.removed",
6108
+ "member.restored"
6109
+ ]);
6110
+ var COMMUNICATION_EVENTS = /* @__PURE__ */ new Set([
6111
+ "communication.record-sent",
6112
+ "communication.record-handed-off",
6113
+ "communication.record-replied",
6114
+ "communication.record-withdrawn",
6115
+ "communication.record-deleted",
6116
+ "communication.inbox-claimed",
6117
+ "communication.delivery-accepted",
6118
+ "communication.group-message-sent",
6119
+ "communication.delivery-bound"
6120
+ ]);
6121
+ var WATCH_EVENTS = [...LINE_EVENTS, ...ITEM_EVENTS, ...MEMBER_EVENTS, ...COMMUNICATION_EVENTS];
6105
6122
  function registerOfficeWatch(ctx, options = {}) {
6106
6123
  const after = options.after ?? ((delay2, notify) => {
6107
6124
  const timer = NodeTimers.setTimeout(notify, delay2);
@@ -6112,14 +6129,17 @@ function registerOfficeWatch(ctx, options = {}) {
6112
6129
  const timers = /* @__PURE__ */ new Map();
6113
6130
  const pending = /* @__PURE__ */ new Map();
6114
6131
  const subscriptions = /* @__PURE__ */ new Map();
6132
+ const threadProjects = /* @__PURE__ */ new Map();
6115
6133
  let disposed = false;
6116
- const invalidate = (projectId, threads) => {
6134
+ const invalidate = (projectId, threads, remoteChanged = false) => {
6117
6135
  if (disposed || !listeners.has(projectId)) return;
6118
6136
  const batch = pending.get(projectId) ?? {
6119
6137
  broad: false,
6138
+ remoteChanged: false,
6120
6139
  ids: /* @__PURE__ */ new Set(),
6121
6140
  parentIds: /* @__PURE__ */ new Set()
6122
6141
  };
6142
+ if (remoteChanged) batch.remoteChanged = true;
6123
6143
  if (threads === void 0) batch.broad = true;
6124
6144
  else {
6125
6145
  for (const id of threads.ids) batch.ids.add(id);
@@ -6136,6 +6156,7 @@ function registerOfficeWatch(ctx, options = {}) {
6136
6156
  const previous = cursors.get(projectId) ?? emptyChanges();
6137
6157
  const value = {
6138
6158
  cursor: previous.cursor + 1,
6159
+ ...changed?.remoteChanged === true ? { remoteChanged: true } : {},
6139
6160
  ...changed !== void 0 && !changed.broad ? {
6140
6161
  threads: {
6141
6162
  ids: [...changed.ids],
@@ -6150,12 +6171,17 @@ function registerOfficeWatch(ctx, options = {}) {
6150
6171
  };
6151
6172
  const eventProject = (event) => {
6152
6173
  const payload = decodeProjectOption(event.payload);
6153
- return isSome2(payload) ? payload.value.projectId : event.aggregateKind === "project" ? event.aggregateId : null;
6174
+ return isSome2(payload) ? payload.value.projectId : event.aggregateKind === "project" ? event.aggregateId : event.aggregateKind === "thread" ? threadProjects.get(event.aggregateId) ?? null : null;
6154
6175
  };
6155
6176
  const stops = WATCH_EVENTS.map(
6156
6177
  (type) => ctx.events.onRaw(type, (event) => {
6157
6178
  const projectId = eventProject(event);
6158
- if (projectId !== null) invalidate(projectId);
6179
+ if (projectId !== null) {
6180
+ invalidate(projectId, void 0, COMMUNICATION_EVENTS.has(type));
6181
+ } else if (COMMUNICATION_EVENTS.has(type) && event.aggregateKind === "thread") {
6182
+ for (const activeProjectId of listeners.keys())
6183
+ invalidate(activeProjectId, void 0, true);
6184
+ }
6159
6185
  })
6160
6186
  );
6161
6187
  const subscribe = (projectId) => {
@@ -6172,6 +6198,9 @@ function registerOfficeWatch(ctx, options = {}) {
6172
6198
  if (!active() || frame._tag === "synchronized") return;
6173
6199
  if (frame._tag === "delta") {
6174
6200
  const change = frame.change;
6201
+ if (change._tag === "upserted")
6202
+ threadProjects.set(change.thread.threadId, projectId);
6203
+ else threadProjects.delete(change.threadId);
6175
6204
  invalidate(projectId, {
6176
6205
  ids: [change._tag === "removed" ? change.threadId : change.thread.threadId],
6177
6206
  ...change._tag === "upserted" && change.thread.parentThreadId !== null ? { parentIds: [change.thread.parentThreadId] } : {}
@@ -6179,9 +6208,14 @@ function registerOfficeWatch(ctx, options = {}) {
6179
6208
  return;
6180
6209
  }
6181
6210
  if (frame._tag === "refresh") {
6211
+ for (const thread of frame.threads) threadProjects.set(thread.threadId, projectId);
6182
6212
  invalidate(projectId, { ids: frame.threads.map((thread) => thread.threadId) });
6183
6213
  return;
6184
6214
  }
6215
+ for (const [threadId, owner] of threadProjects)
6216
+ if (owner === projectId) threadProjects.delete(threadId);
6217
+ for (const thread of frame.value.items)
6218
+ threadProjects.set(thread.threadId, projectId);
6185
6219
  invalidate(projectId);
6186
6220
  },
6187
6221
  signal
@@ -6235,6 +6269,8 @@ function registerOfficeWatch(ctx, options = {}) {
6235
6269
  timers.delete(projectId);
6236
6270
  pending.delete(projectId);
6237
6271
  cursors.delete(projectId);
6272
+ for (const [threadId, owner] of threadProjects)
6273
+ if (owner === projectId) threadProjects.delete(threadId);
6238
6274
  await subscription?.done;
6239
6275
  }
6240
6276
  }
@@ -6250,6 +6286,7 @@ function registerOfficeWatch(ctx, options = {}) {
6250
6286
  pending.clear();
6251
6287
  listeners.clear();
6252
6288
  cursors.clear();
6289
+ threadProjects.clear();
6253
6290
  subscriptions.clear();
6254
6291
  await Promise.all(owned.map((subscription) => subscription.done));
6255
6292
  });
@@ -6258,7 +6295,7 @@ function registerOfficeWatch(ctx, options = {}) {
6258
6295
  // src/index.ts
6259
6296
  var index_default = definePlugin({
6260
6297
  id: "pixel-office",
6261
- apiVersion: 47,
6298
+ apiVersion: 49,
6262
6299
  activate(ctx) {
6263
6300
  registerOfficeWatch(ctx);
6264
6301
  }
package/locales/en.json CHANGED
@@ -12,6 +12,8 @@
12
12
  "threadDeleted": "This team's group chat was deleted. The room keeps showing its members.",
13
13
  "emptyRoom": "Nobody is in this room yet.",
14
14
  "characterLabel": "{{name}} — {{status}}",
15
+ "benchLabel": "{{name}} — waiting for work",
16
+ "benchTitle": "Waiting for work",
15
17
  "leadBadge": "Lead",
16
18
  "queuePosition": "#{{position}} in line",
17
19
  "status": {
@@ -30,6 +32,17 @@
30
32
  "cancelled": "{{count}} cancelled"
31
33
  },
32
34
  "archived": "Archived",
33
- "floorLabel": "Teams on this floor: {{count}}"
35
+ "floorLabel": "Teams on this floor: {{count}}",
36
+ "otherMachines": "Other machines",
37
+ "anotherMachine": "Another machine",
38
+ "remoteLabel": "{{name}} — {{stage}}",
39
+ "lastMessage": "Last message {{time}}",
40
+ "noMessage": "No messages yet",
41
+ "remoteStage": {
42
+ "delivered": "Delivered",
43
+ "picked-up": "Picked up",
44
+ "answered": "Answered",
45
+ "unknown": "Status unknown"
46
+ }
34
47
  }
35
48
  }
@@ -12,6 +12,8 @@
12
12
  "threadDeleted": "这个团队的群会话已删除。房间里照常显示它的成员。",
13
13
  "emptyRoom": "这个房间里还没有人。",
14
14
  "characterLabel": "{{name}}——{{status}}",
15
+ "benchLabel": "{{name}}——待派活",
16
+ "benchTitle": "待派活",
15
17
  "leadBadge": "负责人",
16
18
  "queuePosition": "排队第 {{position}} 位",
17
19
  "status": {
@@ -30,6 +32,17 @@
30
32
  "cancelled": "{{count}} 件已取消"
31
33
  },
32
34
  "archived": "已归档",
33
- "floorLabel": "本层团队:{{count}} 个"
35
+ "floorLabel": "本层团队:{{count}} 个",
36
+ "otherMachines": "其他机器",
37
+ "anotherMachine": "另一台机器",
38
+ "remoteLabel": "{{name}}——{{stage}}",
39
+ "lastMessage": "上次通信 {{time}}",
40
+ "noMessage": "还没有消息",
41
+ "remoteStage": {
42
+ "delivered": "已送达",
43
+ "picked-up": "已取走",
44
+ "answered": "已回复",
45
+ "unknown": "状态未知"
46
+ }
34
47
  }
35
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-pixel-office",
3
- "version": "0.2.3576",
3
+ "version": "0.2.3608",
4
4
  "description": "A pixel-art office view of the team: each session is a little character at work.",
5
5
  "keywords": [
6
6
  "teams",
@@ -31,7 +31,7 @@
31
31
  "tailwindcss": "^4.0.0",
32
32
  "typescript": "~6.0.3",
33
33
  "vite-plus": "0.2.2",
34
- "@ycodium-ai/plugin-api": "0.2.3576"
34
+ "@ycodium-ai/plugin-api": "0.2.3608"
35
35
  },
36
36
  "ycodium": {
37
37
  "plugin": "./dist/index.js",
@@ -41,6 +41,12 @@
41
41
  {
42
42
  "kind": "work.read"
43
43
  },
44
+ {
45
+ "kind": "members.read"
46
+ },
47
+ {
48
+ "kind": "communication.read"
49
+ },
44
50
  {
45
51
  "kind": "sessionProjection"
46
52
  },