@tickernelz/wardmote-ui 2026.1115.2 → 2026.1115.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/dist/assets/{AdapterManager-DlCyzyMu.js → AdapterManager-DD2p5mWg.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-4n8ZC6o0.js → AdvancedToolsRoute-DlPZ_L6N.js} +1 -1
- package/dist/assets/{AgentActionButtons-LV4FbrTY.js → AgentActionButtons-sm-e5f06.js} +1 -1
- package/dist/assets/{AgentChat-CXR66MM4.js → AgentChat-b78UeZDu.js} +1 -1
- package/dist/assets/{AgentChats-C4cEfRO_.js → AgentChats-XK32PfX0.js} +1 -1
- package/dist/assets/{AgentDefaults-BZwFysUw.js → AgentDefaults-BZlzjR_2.js} +1 -1
- package/dist/assets/{AgentDetail-DPCbH362.js → AgentDetail-DwlY6mx-.js} +1 -1
- package/dist/assets/{AgentTodoCard-82Za1R6Y.js → AgentTodoCard-C6-lHXns.js} +1 -1
- package/dist/assets/{Agents-BotjqSPg.js → Agents-C1-WHkTj.js} +3 -3
- package/dist/assets/{AppDetail-B5T_4Bu-.js → AppDetail-9cue4nY2.js} +1 -1
- package/dist/assets/{AppNotConnected-eBGlritA.js → AppNotConnected-oZ4OtRZ5.js} +1 -1
- package/dist/assets/{ApprovalCard-CyXVBGnO.js → ApprovalCard-B1Fs4K4S.js} +1 -1
- package/dist/assets/{ApprovalDetail-BSNBUdim.js → ApprovalDetail-BchdkauI.js} +1 -1
- package/dist/assets/{ApprovalPayload-vezR61PH.js → ApprovalPayload-HdMQnZAw.js} +1 -1
- package/dist/assets/{Approvals-YzDki85i.js → Approvals-ecXixAXF.js} +1 -1
- package/dist/assets/{AppsReview-D02Q501S.js → AppsReview-DSeqYXkI.js} +1 -1
- package/dist/assets/{ArtifactCard-CC5aIvtf.js → ArtifactCard-B9GVJfR3.js} +1 -1
- package/dist/assets/{Artifacts-CnP5QapS.js → Artifacts-Cfi9iGlP.js} +1 -1
- package/dist/assets/{AssistantConnection-refIKgUa.js → AssistantConnection-D1H83dKT.js} +1 -1
- package/dist/assets/{AttentionInteractionResolver-_l8MisRg.js → AttentionInteractionResolver-K_Jeu6_2.js} +1 -1
- package/dist/assets/{AuditHub-CKyN1yDa.js → AuditHub-DlVx-mPL.js} +1 -1
- package/dist/assets/{BoardChat-Dn5D5hbo.js → BoardChat-BWW2praB.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-CDn9Qoy4.js → BootstrapSetupUxLab-C4zke6Cv.js} +1 -1
- package/dist/assets/{Browse-BQApRQGO.js → Browse-DLwvtbXu.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-BAwZpX0_.js → BudgetPolicyCard-B6DX8U3d.js} +1 -1
- package/dist/assets/{CaseDetail-CPGVCggR.js → CaseDetail-dci6PiNM.js} +1 -1
- package/dist/assets/{Cases-CpluIjg7.js → Cases-DySeA3ym.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-C15kjogV.js → ChatEndpointDetail-DYg7hB9_.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-Czgls4T4.js → ChatEndpointSetup-D82OKj2o.js} +1 -1
- package/dist/assets/{ChoiceControls-Dd_bVqHH.js → ChoiceControls-BCF1vPaa.js} +1 -1
- package/dist/assets/{Companies-DK47FHh_.js → Companies-gUbW68nN.js} +1 -1
- package/dist/assets/{CompanyAccess-G_ygWCdy.js → CompanyAccess-C0cDvj8M.js} +1 -1
- package/dist/assets/{CompanyActivity-BzF5S-ak.js → CompanyActivity-CbIPKv4K.js} +1 -1
- package/dist/assets/{CompanyConnections-V6QokJbP.js → CompanyConnections-BezhEQiP.js} +1 -1
- package/dist/assets/{CompanyEnvironments-Dtsf3CLS.js → CompanyEnvironments-6-P8NN3Q.js} +1 -1
- package/dist/assets/{CompanyExport-CMPWrtnT.js → CompanyExport-UdhY3JMr.js} +1 -1
- package/dist/assets/{CompanyImport-1brk-ZPP.js → CompanyImport-Dj5G-Ci_.js} +1 -1
- package/dist/assets/{CompanySettings-DXs4duFl.js → CompanySettings-ifpz0tmL.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-C2DZeyFu.js → CompanySettingsPluginPage-BCK7KaI1.js} +1 -1
- package/dist/assets/{CompanySkills-BE6s5mI1.js → CompanySkills-mzA6IM7-.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-7wvPpeNM.js → ConfigureBuiltInAgentModal-DsiGg71e.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-i8-LiYxQ.js → CopyableGatewayUrl-DwtHLPUd.js} +1 -1
- package/dist/assets/{Dashboard-CU-kG6C4.js → Dashboard-CHGehxNs.js} +1 -1
- package/dist/assets/{DecisionDateChips-BhvEmkt1.js → DecisionDateChips-Ce1EP_35.js} +1 -1
- package/dist/assets/{DecisionQueuePage-CBULv6cY.js → DecisionQueuePage-B55ERukD.js} +1 -1
- package/dist/assets/{DesignGuide-BwncU-wB.js → DesignGuide-CoW-4sZp.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-BPf_8pC0.js → EmailEndpointSetup-Q4I-LgnZ.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-CqvRHX5r.js → ExecutionWorkspaceDetail-_LuHtfta.js} +1 -1
- package/dist/assets/{GatewayDetail-Br82oQib.js → GatewayDetail-BKCHLhcu.js} +1 -1
- package/dist/assets/{GatewaysList-kBD3cwdU.js → GatewaysList-CZ-_zFD_.js} +1 -1
- package/dist/assets/{GoalDetail-BFeUPzal.js → GoalDetail-Bd04vnyA.js} +1 -1
- package/dist/assets/{GoalTree-CaQSt6o5.js → GoalTree-DtvAb581.js} +1 -1
- package/dist/assets/{Goals-CnYUdXEo.js → Goals-BXW_WXNa.js} +1 -1
- package/dist/assets/{ImageGalleryModal-QrZd2HrQ.js → ImageGalleryModal-xeIIyU7g.js} +1 -1
- package/dist/assets/{Inbox-C6bCCEH6.js → Inbox-DmxWV98u.js} +1 -1
- package/dist/assets/{InstanceAdvanced-CTjlJp69.js → InstanceAdvanced-DMrEvjyY.js} +1 -1
- package/dist/assets/{InviteLanding-C65R08_E.js → InviteLanding-C-S7p6JM.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-mdn5NFzU.js → IssueChatLongThreadPerf-BWbJprSQ.js} +1 -1
- package/dist/assets/{IssueChatThread-CZ9Q-xq-.js → IssueChatThread-DmAyIOuN.js} +1 -1
- package/dist/assets/{IssueDetail-svM2GGnk.js → IssueDetail-issXYSBj.js} +1 -1
- package/dist/assets/{IssueOutputSection-Du3C5TFv.js → IssueOutputSection-BioA9Nux.js} +1 -1
- package/dist/assets/{IssueRecoveryActionCard-Bq2QDhQA.js → IssueRecoveryActionCard-CGWmkRkb.js} +1 -1
- package/dist/assets/{IssueReferencePill-Cnjk1Ugc.js → IssueReferencePill-DWL74G_c.js} +1 -1
- package/dist/assets/{IssueThreadInteractionCard-CAzrNSjO.js → IssueThreadInteractionCard-bP4n_lcw.js} +1 -1
- package/dist/assets/{Issues-D97SDuYL.js → Issues-ButYwujh.js} +1 -1
- package/dist/assets/{LiveNowTodoLine-Cq1ub6Gj.js → LiveNowTodoLine-CiCmi71g.js} +1 -1
- package/dist/assets/{ManagedAiConnectionDetails-COyNN_aD.js → ManagedAiConnectionDetails-CgCv2fqy.js} +1 -1
- package/dist/assets/{McpConnect-CYsPUSYV.js → McpConnect-CeT7gUW_.js} +1 -1
- package/dist/assets/{MembershipAction-DYMy7umB.js → MembershipAction-BX9XIExA.js} +1 -1
- package/dist/assets/{ModelsAndProviders-BJaNzbhV.js → ModelsAndProviders-SEGB5DIt.js} +1 -1
- package/dist/assets/{NewAgent-DGXol110.js → NewAgent-LKqNzfsM.js} +1 -1
- package/dist/assets/{OmpAllSettings-BvYkLMhp.js → OmpAllSettings-1aXWEp6h.js} +1 -1
- package/dist/assets/{PipelineSettings-B6Am-LrO.js → PipelineSettings-UFCz50OY.js} +1 -1
- package/dist/assets/{Pipelines-MgjAhzew.js → Pipelines-n5EQOzN2.js} +1 -1
- package/dist/assets/{PixelsOffice-DnBnPerp.js → PixelsOffice-De61dU2s.js} +1 -1
- package/dist/assets/{PluginPage-C1XADFT2.js → PluginPage-CBSnEw7x.js} +1 -1
- package/dist/assets/{PluginSettings-CapWiXsO.js → PluginSettings-D2pNKDKr.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-PJCQrW25.js → ProfileDetailRoute-DCbTvhPd.js} +1 -1
- package/dist/assets/{ProfileSettings-DXbA8GQP.js → ProfileSettings-BUYIctBS.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-DaZPFglw.js → ProfileWizardRoute-o4Kf_DhP.js} +1 -1
- package/dist/assets/{ProjectDetail-DQxMbc1Q.js → ProjectDetail-DOF0t71W.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-dA3zVCbf.js → ProjectWorkspaceDetail-BEbFq9oK.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-DnzUTFfW.js → ProjectWorkspacesContent-DwVqtur5.js} +1 -1
- package/dist/assets/{Projects-D3ZC8FJk.js → Projects-BsZYs3Fo.js} +1 -1
- package/dist/assets/{PublicIssueSharePage-BtWc4gq4.js → PublicIssueSharePage-8uOICn1V.js} +1 -1
- package/dist/assets/{ReviewQueueCard-C9YVH9hi.js → ReviewQueueCard-rQxgVMx_.js} +1 -1
- package/dist/assets/{RichWorkProductCard-CJPI3xQY.js → RichWorkProductCard-FcmQ5fHH.js} +1 -1
- package/dist/assets/{RoutineDetail-DUZXGXpv.js → RoutineDetail-DWqy00zc.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-CQJpihoC.js → RoutineRunVariablesDialog-DaGovqJt.js} +1 -1
- package/dist/assets/{Routines-CZMUFOH1.js → Routines-BE2PduWG.js} +1 -1
- package/dist/assets/{ScrollToBottom-wVHhI6vr.js → ScrollToBottom-DiemLpd4.js} +1 -1
- package/dist/assets/{Search-8efHT3Mn.js → Search-B_dblFtf.js} +1 -1
- package/dist/assets/{Secrets-BZCIDLKj.js → Secrets-D8ZlRoVo.js} +1 -1
- package/dist/assets/{SkillSourceTree-D31jixpq.js → SkillSourceTree-CDK_UwP7.js} +1 -1
- package/dist/assets/{SkillSources-Bn1LRP0O.js → SkillSources-C8inxmWw.js} +1 -1
- package/dist/assets/{SkillStudio-C4o17_hm.js → SkillStudio-8S7xrus7.js} +1 -1
- package/dist/assets/{SourceTrustBadge-C0F4cAmH.js → SourceTrustBadge-DTVyCj4T.js} +1 -1
- package/dist/assets/{StatusCards-BIvnBXBN.js → StatusCards-BpujcoJb.js} +1 -1
- package/dist/assets/{SummarySlotCard-Bpu8HBIR.js → SummarySlotCard-CTolnfbx.js} +1 -1
- package/dist/assets/{TaskChatLab-DAEcgWdy.js → TaskChatLab-BfJcSULz.js} +1 -1
- package/dist/assets/{TaskChatMarker-Bbn6iq01.js → TaskChatMarker-BYJIRrTg.js} +1 -1
- package/dist/assets/{TaskChatProtocolCard-wllJ9P2o.js → TaskChatProtocolCard-DTsBzh1L.js} +1 -1
- package/dist/assets/{TaskChatThreadView-Bnyakc3A.js → TaskChatThreadView-CBwEERny.js} +1 -1
- package/dist/assets/{TaskTreeControls-BFz5K7U-.js → TaskTreeControls-BzPeXKPq.js} +1 -1
- package/dist/assets/{Terminal-DGUlqBL9.js → Terminal-DGY0GEez.js} +1 -1
- package/dist/assets/{TerminalView-Cz01H-I5.js → TerminalView-CZkTSDKg.js} +1 -1
- package/dist/assets/{TrustPresetSection-lyB0V8c9.js → TrustPresetSection-DeIvlixJ.js} +1 -1
- package/dist/assets/{UserProfile-5qgIbXdf.js → UserProfile-BkcJ9Wfx.js} +1 -1
- package/dist/assets/{WhatNeedsMe-DjxO39CR.js → WhatNeedsMe-Bg72QkYe.js} +1 -1
- package/dist/assets/{Workspaces-BzTr5cqx.js → Workspaces-BeS2M4CD.js} +1 -1
- package/dist/assets/{connection-owner-EECE9Eiz.js → connection-owner-qWfs2q4d.js} +1 -1
- package/dist/assets/{index-DbENFODe.js → index-CSIXA5y5.js} +3 -3
- package/dist/assets/{issue-properties-BmOIUOmd.js → issue-properties-D3qASSPI.js} +1 -1
- package/dist/assets/{issue-workspace-selection-CIvSmFv2.js → issue-workspace-selection-sfcpgxzV.js} +1 -1
- package/dist/assets/{pipeline-stage-presentation-DoJvVCJ3.js → pipeline-stage-presentation-C9WooPFB.js} +1 -1
- package/dist/assets/{shared-BMQlB2gM.js → shared-57amdu2f.js} +1 -1
- package/dist/assets/{transcript-adapter-DDVisW9K.js → transcript-adapter-D7nXUOr3.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-BNKrqAT0.js → useSummaryDraftStream-1H3w75Dm.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var zn=Object.defineProperty;var u=(t,e)=>zn(t,"name",{value:e,configurable:!0});import{i as Ke}from"./rolldown-runtime-ZpX3ckPj.js";import{O as Z,jt as Hn,na as Yn,t as Zt,ta as Xn}from"./createLucideIcon-B-uEJvX6.js";import{X as Ue,_ as Ve,g as Qt,r as Ot,t as N,v as D}from"./queryKeys-yuC-YxZI.js";import{tt as Gn}from"./mention-chips-DiRTrrHG.js";import{n as qn}from"./CompanyContext-DDgccGSs.js";import{W as Kn,t as Q,zt as Wt}from"./router-2HX_SyKK.js";import{t as Ze}from"./scroll-area-Drh0SHUe.js";import{t as Un}from"./coins-DOScIoKX.js";import{t as Vn}from"./external-link-CxXijrsp.js";import{t as Zn}from"./inbox-BqqJhYb6.js";import{r as Qn,t as z}from"./button-D3bYvq4T.js";import{t as Qe}from"./pause-Dt9kKzpY.js";import{t as zt}from"./play-BEx2fnvh.js";import{t as Jn}from"./radio-ljY5_vGs.js";import{t as ts}from"./x-hMw21ejo.js";import{r as es}from"./SidebarContext-CQAYTXv1.js";import{t as xt}from"./badge-Dz4tmpgp.js";import{a as ns}from"./ToastContext-BL2cptrZ.js";import{t as At}from"./agents-DjsXf9UL.js";import{t as Je}from"./heartbeats-xPg7ZEsm.js";import{t as tn}from"./access-RvWIoVKp.js";import{t as en}from"./routines-5Q3z9LWd.js";import{n as ss}from"./BreadcrumbContext-_dNLeVnD.js";import{t as is}from"./card-CtkberpO.js";import{Pa as re,Xa as rs,fa as nn,gt as os,no as as,ua as sn,v as ls}from"./index-DbENFODe.js";import{r as cs,s as us,t as fs}from"./sheet-_2ap0Qlb.js";import{t as ds}from"./AttentionInteractionResolver-_l8MisRg.js";import{t as hs}from"./pipelines-DRMWZLsA.js";import{t as ms}from"./budgets-Dh83JquC.js";var rn={name:"alarm-smoke",size:24,node:[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]};rn.node;var gs=Zt(rn),on={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};on.node;var ps=Zt(on),an={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};an.node;var ws=Zt(an),_=Ke(Yn(),1),Ht={snapshot:u(t=>Ot.get(`/companies/${t}/pixels-office`),"snapshot"),timeline:u((t,e)=>{const s=new URLSearchParams({from:e.from,to:e.to});return e.cursor&&s.set("cursor",e.cursor),Ot.get(`/companies/${t}/pixels-office/timeline?${s.toString()}`)},"timeline"),replaceSeats:u((t,e)=>Ot.put(`/companies/${t}/pixels-office/seats`,{assignments:e}),"replaceSeats")};var vs=.15,xs=.3,ln=.5,ys=.001,bs=.5,cn="#808080",Is="#FF00FF",As="#3A3A5C",Ts=.2,un=.6,oe=.1,Yt=new Map;function Jt(t,e,s){const n=Yt.get(t);if(n)return n;const i=s.colorize?Ss(e,s):mn(e,s);return Yt.set(t,i),i}u(Jt,"getColorizedSprite");function Cs(){Yt.clear()}u(Cs,"clearColorizeCache");function Ss(t,e){const{h:s,s:n,b:i,c:r}=e,o=[];for(const a of t){const l=[];for(const c of a){if(c===""){l.push("");continue}const d=parseInt(c.slice(1,3),16),m=parseInt(c.slice(3,5),16),f=parseInt(c.slice(5,7),16);let g=(.299*d+.587*m+.114*f)/255;if(r!==0){const p=(100+r)/100;g=.5+(g-.5)*p}i!==0&&(g=g+i/200),g=Math.max(0,Math.min(1,g));const v=fn(c),y=hn(s,n/100,g);l.push(dn(y,v))}o.push(l)}return o}u(Ss,"colorizeSprite");function fn(t){return t.length>7?parseInt(t.slice(7,9),16):255}u(fn,"extractAlpha");function dn(t,e){return e>=255?t:`${t}${e.toString(16).padStart(2,"0").toUpperCase()}`}u(dn,"appendAlpha");function hn(t,e,s){const n=(1-Math.abs(2*s-1))*e,i=t/60,r=n*(1-Math.abs(i%2-1));let o=0,a=0,l=0;i<1?(o=n,a=r,l=0):i<2?(o=r,a=n,l=0):i<3?(o=0,a=n,l=r):i<4?(o=0,a=r,l=n):i<5?(o=r,a=0,l=n):(o=n,a=0,l=r);const c=s-n/2,d=Math.round((o+c)*255),m=Math.round((a+c)*255),f=Math.round((l+c)*255);return`#${Nt(d).toString(16).padStart(2,"0")}${Nt(m).toString(16).padStart(2,"0")}${Nt(f).toString(16).padStart(2,"0")}`.toUpperCase()}u(hn,"hslToHex");function Nt(t){return Math.max(0,Math.min(255,t))}u(Nt,"clamp255");function _s(t,e,s){const n=t/255,i=e/255,r=s/255,o=Math.max(n,i,r),a=Math.min(n,i,r),l=(o+a)/2;if(o===a)return[0,0,l];const c=o-a,d=l>.5?c/(2-o-a):c/(o+a);let m=0;return o===n?m=((i-r)/c+(i<r?6:0))*60:o===i?m=((r-n)/c+2)*60:m=((n-i)/c+4)*60,[m,d,l]}u(_s,"rgbToHsl");function mn(t,e){const{h:s,s:n,b:i,c:r}=e,o=[];for(const a of t){const l=[];for(const c of a){if(c===""){l.push("");continue}const d=parseInt(c.slice(1,3),16),m=parseInt(c.slice(3,5),16),f=parseInt(c.slice(5,7),16),g=fn(c),[v,y,p]=_s(d,m,f),b=((v+s)%360+360)%360,x=Math.max(0,Math.min(1,y+n/100));let T=p;if(r!==0){const w=(100+r)/100;T=.5+(T-.5)*w}i!==0&&(T=T+i/200),T=Math.max(0,Math.min(1,T));const A=hn(b,x,T);l.push(dn(A,g))}o.push(l)}return o}u(mn,"adjustSprite");var ks=Array.from({length:16},()=>Array(16).fill(cn)),_t=[];function Rs(t){_t=t,Cs()}u(Rs,"setFloorSprites");function Ms(t){const e=t-1;return e<0?null:e<_t.length?_t[e]:_t.length===0&&t>=1?ks:null}u(Ms,"getFloorSprite");function Fs(){return!0}u(Fs,"hasFloorSprites");function Es(t,e){const s=`floor-${t}-${e.h}-${e.s}-${e.b}-${e.c}`,n=Ms(t);return n?Jt(s,n,{...e,colorize:!0}):Array.from({length:16},()=>Array(16).fill(Is))}u(Es,"getColorizedFloorSprite");var $={WALL:0,FLOOR_1:1,FLOOR_2:2,FLOOR_3:3,FLOOR_4:4,FLOOR_5:5,FLOOR_6:6,FLOOR_7:7,FLOOR_8:8,FLOOR_9:9,VOID:255},E={IDLE:"idle",WALK:"walk",TYPE:"type"},S={DOWN:0,LEFT:1,RIGHT:2,UP:3},K=new Map,rt=new Map,Xt=new Map,ae=new Map,kt=new Map,Gt=null,gn=null;function Os(t){if(!t?.catalog||!t?.sprites)return!1;const e=t.catalog.map(f=>{const g=t.sprites[f.id];return g?{type:f.id,label:f.label,footprintW:f.footprintW,footprintH:f.footprintH,sprite:g,isDesk:f.isDesk,category:f.category,...f.orientation?{orientation:f.orientation}:{},...f.canPlaceOnSurfaces?{canPlaceOnSurfaces:!0}:{},...f.backgroundTiles?{backgroundTiles:f.backgroundTiles}:{},...f.canPlaceOnWalls?{canPlaceOnWalls:!0}:{},...f.mirrorSide?{mirrorSide:!0}:{}}:null}).filter(f=>f!==null);for(const f of t.catalog)if(f.mirrorSide&&f.orientation==="side"){const g=e.find(v=>v.type===f.id);g&&e.push({...g,type:`${f.id}:left`,orientation:"left",mirrorSide:!0})}if(e.length===0)return!1;K.clear(),rt.clear(),Xt.clear(),ae.clear(),kt.clear();const s=new Map;for(const f of t.catalog)if(f.groupId&&f.orientation){if(f.state&&f.state!=="off")continue;let g=s.get(f.groupId);g||(g=new Map,s.set(f.groupId,g)),f.orientation==="side"?(g.set("right",f.id),f.mirrorSide&&g.set("left",`${f.id}:left`)):g.set(f.orientation,f.id)}const n=new Map;for(const f of t.catalog)f.groupId&&f.rotationScheme&&n.set(f.groupId,f.rotationScheme);const i=new Set,r=["front","right","back","left"];for(const[f,g]of s){if(g.size<2)continue;const v=n.get(f);let y=r;v==="2-way"&&(y=["front","right"]);const p=y.filter(A=>g.has(A));if(p.length<2)continue;const b={};for(const A of p)b[A]=g.get(A);const x={orientations:p,members:b},T=new Set;for(const A of Object.values(b))T.has(A)||(K.set(A,x),T.add(A));for(const[A,w]of Object.entries(b))A!=="front"&&i.add(w)}const o=new Map;for(const f of t.catalog)if(f.groupId&&f.state){const g=`${f.groupId}|${f.orientation||""}`;let v=o.get(g);if(v||(v=new Map,o.set(g,v)),f.animationGroup&&f.frame!==void 0&&f.frame>0)continue;v.set(f.state,f.id)}for(const f of o.values()){const g=f.get("on"),v=f.get("off");g&&v&&(rt.set(g,v),rt.set(v,g),Xt.set(v,g),ae.set(g,v))}for(const f of t.catalog)if(f.groupId&&f.orientation&&f.state==="on"){if(f.animationGroup&&f.frame!==void 0&&f.frame>0)continue;const g=rt.get(f.id);if(g){const v=K.get(g);if(v){const y={};for(const b of v.orientations){const x=v.members[b];y[b]=rt.get(x)??x}const p={orientations:v.orientations,members:y};for(const b of Object.values(y))K.has(b)||K.set(b,p)}}}const a=new Map;for(const f of t.catalog)if(f.animationGroup&&f.frame!==void 0){let g=a.get(f.animationGroup);g||(g=[],a.set(f.animationGroup,g)),g.push({id:f.id,frame:f.frame})}for(const[f,g]of a)g.sort((v,y)=>v.frame-y.frame),kt.set(f,g.map(v=>v.id));const l=new Set;for(const f of t.catalog)f.state==="on"&&l.add(f.id);Gt=e;const c=e.filter(f=>!i.has(f.type)&&!l.has(f.type));for(const f of c)(K.has(f.type)||rt.has(f.type))&&(f.label=f.label.replace(/ - Front - Off$/,"").replace(/ - Front$/,"").replace(/ - Off$/,""));gn=c;const d=new Set(Array.from(K.values())).size,m=kt.size;return!0}u(Os,"buildDynamicCatalog");function Y(t){return Gt?Gt.find(e=>e.type===t):gn?.find(e=>e.type===t)}u(Y,"getCatalogEntry");function Ns(t){return Xt.get(t)??t}u(Ns,"getOnStateType");function Ls(t){for(const[,e]of kt)if(e.includes(t))return e;return null}u(Ls,"getAnimationFrames");function js(t){const e=K.get(t);if(e){for(const[s,n]of Object.entries(e.members))if(n===t)return s}}u(js,"getOrientationInGroup");function Ps(t){const e=[];for(let s=0;s<t.rows;s++){const n=[];for(let i=0;i<t.cols;i++)n.push(t.tiles[s*t.cols+i]);e.push(n)}return e}u(Ps,"layoutToTileMap");function Bs(t){const e=new Map;for(const n of t){const i=Y(n.type);if(!i||!i.isDesk)continue;const r=n.row*16+i.sprite.length;for(let o=0;o<i.footprintH;o++)for(let a=0;a<i.footprintW;a++){const l=`${n.col+a},${n.row+o}`,c=e.get(l);(c===void 0||r>c)&&e.set(l,r)}}const s=[];for(let n=0;n<t.length;n++){const i=t[n],r=Y(i.type);if(!r)continue;const o=i.col*16,a=i.row*16;let l=a+r.sprite.length;if(r.category==="chairs"&&(r.orientation==="back"?l=(i.row+r.footprintH)*16+1:l=(i.row+1)*16),r.canPlaceOnSurfaces)for(let m=0;m<r.footprintH;m++)for(let f=0;f<r.footprintW;f++){const g=e.get(`${i.col+f},${i.row+m}`);g!==void 0&&g+.5>l&&(l=g+.5)}let c=r.sprite;if(i.color){const{h:m,s:f,b:g,c:v}=i.color;c=Jt(`furn-${i.type}-${m}-${f}-${g}-${v}-${i.color.colorize?1:0}`,r.sprite,i.color)}let d=!1;r.mirrorSide&&js(i.type)==="left"&&(d=!0),s.push({sprite:c,x:o,y:a,zY:l,sourceIndex:n,...d?{mirrored:!0}:{}})}return s}u(Bs,"layoutToFurnitureInstances");function Ds(t,e){const s=new Set;for(const n of t){const i=Y(n.type);if(!i)continue;const r=i.backgroundTiles||0;for(let o=0;o<i.footprintH;o++)if(!(o<r))for(let a=0;a<i.footprintW;a++){const l=`${n.col+a},${n.row+o}`;e&&e.has(l)||s.add(l)}}return s}u(Ds,"getBlockedTiles");function $s(t){switch(t){case"front":return S.DOWN;case"back":return S.UP;case"left":return S.LEFT;case"right":case"side":return S.RIGHT;default:return S.DOWN}}u($s,"orientationToFacing");function qt(t){const e=new Map,s=new Set;for(const i of t){const r=Y(i.type);if(!(!r||!r.isDesk))for(let o=0;o<r.footprintH;o++)for(let a=0;a<r.footprintW;a++)s.add(`${i.col+a},${i.row+o}`)}const n=[{dc:0,dr:-1,facing:S.UP},{dc:0,dr:1,facing:S.DOWN},{dc:-1,dr:0,facing:S.LEFT},{dc:1,dr:0,facing:S.RIGHT}];for(const i of t){const r=Y(i.type);if(!r||r.category!=="chairs")continue;let o=0;const a=r.backgroundTiles??0;for(let l=a;l<r.footprintH;l++)for(let c=0;c<r.footprintW;c++){const d=i.col+c,m=i.row+l;let f=S.DOWN;if(r.orientation)f=$s(r.orientation);else for(const v of n)if(s.has(`${d+v.dc},${m+v.dr}`)){f=v.facing;break}const g=o===0?i.uid:`${i.uid}:${o}`;e.set(g,{uid:g,seatCol:d,seatRow:m,facingDir:f,assigned:!1}),o++}}return e}u(qt,"layoutToSeats");var Ws={h:35,s:30,b:15,c:0},zs={h:25,s:45,b:5,c:10};function Hs(){const t=$.WALL,e=$.FLOOR_1,s=$.FLOOR_2,n=[],i=[];for(let r=0;r<11;r++)for(let o=0;o<20;o++)r===0||r===10||o===0||o===19?(n.push(t),i.push(null)):o<10?(n.push(e),i.push(Ws)):(n.push(s),i.push(zs));return{version:1,cols:20,rows:11,tiles:n,tileColors:i,furniture:[]}}u(Hs,"createDefaultLayout");var Ys="bubble-permission",Xs="Permission bubble: white square with '...' in amber, and a tail pointer (11x13)";var Gs={_:"",B:"#555566",F:"#EEEEFF",A:"#CCA700"},qs=[["B","B","B","B","B","B","B","B","B","B","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","A","F","A","F","A","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","B","B","B","B","B","B","B","B","B","B"],["_","_","_","_","B","B","B","_","_","_","_"],["_","_","_","_","_","B","_","_","_","_","_"],["_","_","_","_","_","_","_","_","_","_","_"]],Ks={name:Ys,description:Xs,width:11,height:13,palette:Gs,pixels:qs},Us="bubble-waiting",Vs="Waiting bubble: white square with green checkmark, and a tail pointer (11x13)";var Zs={_:"",B:"#555566",F:"#EEEEFF",G:"#44BB66"},Qs=[["_","B","B","B","B","B","B","B","B","B","_"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","G","F","B"],["B","F","F","F","F","F","F","G","F","F","B"],["B","F","F","G","F","F","G","F","F","F","B"],["B","F","F","F","G","G","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["_","B","B","B","B","B","B","B","B","B","_"],["_","_","_","_","B","B","B","_","_","_","_"],["_","_","_","_","_","B","_","_","_","_","_"],["_","_","_","_","_","_","_","_","_","_","_"]],Js={name:Us,description:Vs,width:11,height:13,palette:Zs,pixels:Qs};function pn(t){return t.pixels.map(e=>e.map(s=>t.palette[s]??s))}u(pn,"resolveBubbleSprite");var za=pn(Ks),Ha=pn(Js),ft=null;function ti(t){ft=t,Kt.clear()}u(ti,"setCharacterTemplates");function ei(){return ft?ft.length:6}u(ei,"getLoadedCharacterCount");function ni(t){return t.map(e=>[...e].reverse())}u(ni,"flipSpriteHorizontal");var Kt=new Map;function si(t,e){const s={h:e,s:0,b:0,c:0},n=u(o=>mn(o,s),"shift"),i=u(o=>[n(o[0]),n(o[1]),n(o[2]),n(o[3])],"shiftWalk"),r=u(o=>[n(o[0]),n(o[1])],"shiftPair");return{walk:{[S.DOWN]:i(t.walk[S.DOWN]),[S.UP]:i(t.walk[S.UP]),[S.RIGHT]:i(t.walk[S.RIGHT]),[S.LEFT]:i(t.walk[S.LEFT])},typing:{[S.DOWN]:r(t.typing[S.DOWN]),[S.UP]:r(t.typing[S.UP]),[S.RIGHT]:r(t.typing[S.RIGHT]),[S.LEFT]:r(t.typing[S.LEFT])},reading:{[S.DOWN]:r(t.reading[S.DOWN]),[S.UP]:r(t.reading[S.UP]),[S.RIGHT]:r(t.reading[S.RIGHT]),[S.LEFT]:r(t.reading[S.LEFT])}}}u(si,"hueShiftSprites");function ii(t,e){const s=[];for(let n=0;n<e;n++)s.push(new Array(t).fill(""));return s}u(ii,"emptySprite");function ri(t,e=0){const s=`${t}:${e}`,n=Kt.get(s);if(n)return n;let i;if(ft){const r=ft[t%ft.length],o=r.down,a=r.up,l=r.right,c=ni;i={walk:{[S.DOWN]:[o[0],o[1],o[2],o[1]],[S.UP]:[a[0],a[1],a[2],a[1]],[S.RIGHT]:[l[0],l[1],l[2],l[1]],[S.LEFT]:[c(l[0]),c(l[1]),c(l[2]),c(l[1])]},typing:{[S.DOWN]:[o[3],o[4]],[S.UP]:[a[3],a[4]],[S.RIGHT]:[l[3],l[4]],[S.LEFT]:[c(l[3]),c(l[4])]},reading:{[S.DOWN]:[o[5],o[6]],[S.UP]:[a[5],a[6]],[S.RIGHT]:[l[5],l[6]],[S.LEFT]:[c(l[5]),c(l[6])]}}}else{const r=ii(16,32),o=[r,r,r,r],a=[r,r];i={walk:{[S.DOWN]:o,[S.UP]:o,[S.RIGHT]:o,[S.LEFT]:o},typing:{[S.DOWN]:a,[S.UP]:a,[S.RIGHT]:a,[S.LEFT]:a},reading:{[S.DOWN]:a,[S.UP]:a,[S.RIGHT]:a,[S.LEFT]:a}}}return e!==0&&(i=si(i,e)),Kt.set(s,i),i}u(ri,"getCharacterSprites");var q=[];function oi(t){q=t}u(oi,"setWallSprites");function ai(){return q.length>0}u(ai,"hasWallSprites");function wn(t,e,s){const n=s.length,i=n>0?s[0].length:0;let r=0;return e>0&&s[e-1][t]===$.WALL&&(r|=1),t<i-1&&s[e][t+1]===$.WALL&&(r|=2),e<n-1&&s[e+1][t]===$.WALL&&(r|=4),t>0&&s[e][t-1]===$.WALL&&(r|=8),r}u(wn,"buildWallMask");function li(t,e,s,n=0){if(q.length===0)return null;const i=(q[n]??q[0])[wn(t,e,s)];return i?{sprite:i,offsetY:16-i.length}:null}u(li,"getWallSprite");function ci(t,e,s,n,i=0){if(q.length===0)return null;const r=q[i]??q[0],o=wn(t,e,s),a=r[o];if(!a)return null;const l=`wall-${i}-${o}-${n.h}-${n.s}-${n.b}-${n.c}`;return{sprite:Jt(l,a,{...n,colorize:!0}),offsetY:16-a.length}}u(ci,"getColorizedWallSprite");function ui(t,e,s){if(q.length===0)return[];const n=t.length,i=n>0?t[0].length:0,r=s??i,o=[];for(let a=0;a<n;a++)for(let l=0;l<i;l++){if(t[a][l]!==$.WALL)continue;const c=a*r+l,d=e?.[c],m=d?ci(l,a,t,d):li(l,a,t);m&&o.push({sprite:m.sprite,x:l*16,y:a*16+m.offsetY,zY:(a+1)*16})}return o}u(ui,"getWallInstances");function fi(t){const{h:e,s,b:n,c:i}=t;let r=.5;if(i!==0){const y=(100+i)/100;r=.5+(r-.5)*y}n!==0&&(r=r+n/200),r=Math.max(0,Math.min(1,r));const o=s/100,a=(1-Math.abs(2*r-1))*o,l=e/60,c=a*(1-Math.abs(l%2-1));let d=0,m=0,f=0;l<1?(d=a,m=c,f=0):l<2?(d=c,m=a,f=0):l<3?(d=0,m=a,f=c):l<4?(d=0,m=c,f=a):l<5?(d=c,m=0,f=a):(d=a,m=0,f=c);const g=r-a/2,v=u(y=>Math.max(0,Math.min(255,Math.round((y+g)*255))),"clamp");return`#${v(d).toString(16).padStart(2,"0")}${v(m).toString(16).padStart(2,"0")}${v(f).toString(16).padStart(2,"0")}`}u(fi,"wallColorToHex");var ot=16,Tt=32,Lt=7,le=16,ce=16,ue=32,fe=4,di=16,st="/pixels/",jt=null;function de(t){const e=[];for(let d=0;d<t.rows;d++)for(let m=0;m<t.cols;m++)t.tiles[d*t.cols+m]!==255&&e.push({col:m,row:d});if(e.length===0)return t;const s=Math.max(0,Math.min(...e.map(d=>d.col))-1),n=Math.min(t.cols-1,Math.max(...e.map(d=>d.col))+1),i=Math.max(0,Math.min(...e.map(d=>d.row))-1),r=Math.min(t.rows-1,Math.max(...e.map(d=>d.row))+1),o=n-s+1,a=r-i+1,l=[],c=t.tileColors?[]:void 0;for(let d=i;d<=r;d++)for(let m=s;m<=n;m++){const f=d*t.cols+m;l.push(t.tiles[f]),c?.push(t.tileColors?.[f]??null)}return{...t,cols:o,rows:a,tiles:l,tileColors:c,furniture:t.furniture.map(d=>({...d,col:d.col-s,row:d.row-i}))}}u(de,"trimLayoutToVisibleRoom");function hi(t,e,s){return{...t,tileColors:t.tiles.map(n=>n===0?s:n===255?null:e),furniture:t.furniture.map(n=>["DESK_FRONT","TABLE_FRONT","SMALL_TABLE_FRONT","SMALL_TABLE_SIDE","COFFEE_TABLE"].includes(n.type)?{...n,color:{h:150,s:18,b:-10,c:-20}}:n)}}u(hi,"recolorLayout");var he=5,me=[{floor:{h:145,s:16,b:-8,c:-35},wall:{h:270,s:18,b:-20,c:-45}},{floor:{h:60,s:20,b:-6,c:-30},wall:{h:310,s:22,b:-24,c:-40}},{floor:{h:200,s:18,b:-10,c:-32},wall:{h:20,s:20,b:-22,c:-42}},{floor:{h:95,s:22,b:-12,c:-28},wall:{h:240,s:16,b:-18,c:-48}}];function mi(t){const e=new Set;for(const l of t.furniture){const c=Y(l.type);if(c)for(let d=0;d<c.footprintH;d++)for(let m=0;m<c.footprintW;m++)e.add(`${l.col+m},${l.row+d}`)}const s=u((l,c)=>t.tiles[c*t.cols+l],"tileAt");let n=-1;for(let l=0;l<t.rows-1&&n<0;l++)for(let c=0;c<t.cols;c++){const d=s(c,l+1);if(s(c,l)===0&&d!==0&&d!==255){n=l;break}}const i=[];function r(l,c,d,m,f){for(let g=0;g<f;g++)for(let v=0;v<m;v++)e.add(`${c+v},${d+g}`);i.push({uid:`anchor-${l}`,type:l,col:c,row:d})}u(r,"claim");function o(l,c){const d=Y(l);if(n<1||!d)return!1;const m=d.footprintW,f=Array.from({length:t.cols-m+1},(g,v)=>v);c&&f.reverse();for(const g of f){let v=!0;for(let y=0;y<m&&v;y++)s(g+y,n)!==0&&(v=!1),e.has(`${g+y},${n}`)&&(v=!1),e.has(`${g+y},${n-1}`)&&(v=!1);if(v)return r(l,g,n-1,m,2),!0}return!1}u(o,"placeOnWall");function a(l,c){const d=Y(l);if(!d)return!1;const m=d.footprintW,f=d.footprintH;for(let g=t.rows-f;g>n;g--){const v=Array.from({length:t.cols-m+1},(y,p)=>p);c&&v.reverse();for(const y of v){let p=!0;for(let b=0;b<f&&p;b++)for(let x=0;x<m&&p;x++){const T=s(y+x,g+b);(T===0||T===255)&&(p=!1),e.has(`${y+x},${g+b}`)&&(p=!1)}if(p)return r(l,y,g,m,f),!0}}return!1}return u(a,"placeOnFloor"),o("KANBAN_BOARD",!1)||a("KANBAN_BOARD",!1),o("ALARM_LIGHT",!0)||a("ALARM_LIGHT",!0),a("MAILBOX",!1)||o("MAILBOX",!1),a("COIN_STACK",!0)||o("COIN_STACK",!0),i}u(mi,"placeAnchorFurniture");function gi(t,e){const s=qt(t.furniture).size,n=qt(e.furniture).size,i=50-s-n,r=s>0&&i>0?Math.ceil(i/s):1,o=[t,e];for(let A=0;A<r;A++){const w=me[A%me.length];o.push(hi(t,w.floor,w.wall))}const a=Math.max(0,Math.floor((t.rows-e.rows)/2)),l=o.map((A,w)=>({layout:A,offsetCol:0,offsetRow:w===1?a:0}));let c=0;for(const A of l)A.offsetCol=c,c+=A.layout.cols+he;c-=he;const d=Math.max(...l.map(A=>A.offsetRow+A.layout.rows)),m=Array(c*d).fill(255),f=Array(c*d).fill(null),g={h:214,s:30,b:-100,c:-55},v={h:32,s:20,b:-6,c:-42},y=9;for(const{layout:A,offsetCol:w,offsetRow:I}of l)for(let C=0;C<A.rows;C++)for(let k=0;k<A.cols;k++){const R=C*A.cols+k,F=(C+I)*c+k+w;m[F]=A.tiles[R],f[F]=A.tileColors?.[R]??null}const p=Math.floor(d/2),b={col:t.cols-1,row:p};for(let A=1;A<l.length;A++){const w=l[A-1],I=w.offsetCol+w.layout.cols-2,C=l[A].offsetCol+1;for(let k=p-1;k<=p+1;k++)for(let R=I;R<=C;R++){const F=k*c+R;m[F]=y,f[F]=v}for(let k=p-2;k<=p+2;k++){for(const R of[I+1,I+2,C-1,C]){const F=k*c+R;m[F]=y,f[F]=v}for(const R of[I-1,C+1]){const F=k*c+R;m[F]===255&&(m[F]=0,f[F]=g)}}}f[b.row*c+b.col]={h:32,s:20,b:-14,c:-42};const x=l.flatMap(({layout:A,offsetCol:w,offsetRow:I},C)=>A.furniture.map(k=>({...k,uid:`camera${C+1}-${k.uid}`,col:k.col+w,row:k.row+I})));x.push(...mi(t));const T=l.map(({layout:A,offsetCol:w,offsetRow:I})=>{let C=A.rows,k=-1,R=A.cols,F=-1;for(let j=0;j<A.rows;j++)for(let P=0;P<A.cols;P++)A.tiles[j*A.cols+P]!==255&&(j<C&&(C=j),j>k&&(k=j),P<R&&(R=P),P>F&&(F=P));if(k<0)return{col:w,row:I,cols:A.cols,rows:A.rows};const L=C>0?1:0;return{col:w+R,row:I+C-L,cols:F-R+1,rows:k-C+1+L}});return{layout:{version:1,cols:c,rows:d,layoutRevision:1,tiles:m,tileColors:f,spawnTile:b,furniture:x},cameraBounds:{office:T[0],boardroomKitchen:T[1],overflowOffice:T[2],rooms:T}}}u(gi,"combineLayouts");function pi(t,e,s,n){return n<2?"":`#${t.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n===255?"":n.toString(16).padStart(2,"0")}`}u(pi,"rgbaToHex");function wi(t,e,s){const n=(s*t.width+e)*4;return pi(t.data[n],t.data[n+1],t.data[n+2],t.data[n+3])}u(wi,"pixelAt");function dt(t,e,s,n=0,i=0){return Array.from({length:s},(r,o)=>Array.from({length:e},(a,l)=>wi(t,n+l,i+o)))}u(dt,"readSprite");async function Ft(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}`);const s=await createImageBitmap(await e.blob()),n=document.createElement("canvas");n.width=s.width,n.height=s.height;const i=n.getContext("2d");if(!i)throw new Error("Could not decode PNG");i.drawImage(s,0,0),s.close();const r=i.getImageData(0,0,n.width,n.height);return{width:n.width,height:n.height,data:r.data}}u(Ft,"decodePng");async function vi(t){return Promise.all(t.characters.map(async e=>{const s=await Ft(`${st}${e}`);return{down:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,0)),up:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,Tt)),right:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,64))}}))}u(vi,"decodeCharacters");async function xi(t){return Promise.all(t.floors.map(async e=>dt(await Ft(`${st}${e}`),le,le)))}u(xi,"decodeFloors");async function yi(t){return Promise.all(t.walls.map(async e=>{const s=await Ft(`${st}${e}`);return Array.from({length:di},(n,i)=>dt(s,ce,ue,i%fe*ce,Math.floor(i/fe)*ue))}))}u(yi,"decodeWalls");async function bi(t){const e=await Promise.all(t.furniture.map(async s=>{const n=await Ft(`${st}${s.furniturePath}`);return[s.id,dt(n,s.width,s.height)]}));return Object.fromEntries(e)}u(bi,"decodeFurniture");async function Pt(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}`);return await e.json()}u(Pt,"fetchJson");function Ii(){return jt??=(async()=>{const t=await Pt(`${st}pixels-office-assets.json`),e=t.layouts??{office:t.defaultLayout,boardroomKitchen:t.defaultLayout},[s,n,i,r,o,a]=await Promise.all([vi(t),xi(t),yi(t),bi(t),Pt(`${st}${e.office}`).then(de),Pt(`${st}${e.boardroomKitchen}`).then(de)]);ti(s),Rs(n),oi(i),Os({catalog:t.furniture,sprites:r});const l=gi(o,a);return{layouts:{office:o,boardroomKitchen:a,combined:l.layout},cameraBounds:l.cameraBounds}})().catch(t=>{throw jt=null,t}),jt}u(Ii,"loadPixelAssets");var ge={kanban:"KANBAN_BOARD",mailbox:"MAILBOX",clock:"CLOCK",coins:"COIN_STACK",alarm:"ALARM_LIGHT"},Ai=6,pe=.4,we=1.18;function ve(t,e,s,n){return e*2>=n-s?Math.min(s+e,Math.max(n-e,t)):Math.min(n-e,Math.max(s+e,t))}u(ve,"clampAxis");var Ti=class{static{u(this,"Camera")}worldWidth;worldHeight;worldTop;centerX=0;centerY=0;zoom=1;followAgentId=null;viewportWidth=1;viewportHeight=1;dpr=1;offsetX=0;offsetY=0;targetX=0;targetY=0;tweening=!1;constructor(t,e,s=0){this.worldWidth=t,this.worldHeight=e,this.worldTop=s,this.centerX=t/2,this.centerY=(s+e)/2,this.targetX=this.centerX,this.targetY=this.centerY,this.recompute()}get minZoom(){return Math.max(1,Math.ceil(this.dpr))}get maxZoom(){return Math.max(this.minZoom,Math.round(Ai*this.dpr))}setViewport(t,e,s){this.viewportWidth=Math.max(1,t),this.viewportHeight=Math.max(1,e),this.dpr=s>0?s:1,this.setZoom(this.zoom)}setZoom(t){this.zoom=Math.min(this.maxZoom,Math.max(this.minZoom,Math.round(t))),this.recompute()}fitRoom(t){const e=t.cols*16,s=t.rows*16;let n=Math.max(1,Math.floor(Math.min(this.viewportWidth/e,this.viewportHeight/s)));for(;e*(n+1)<=this.viewportWidth*we&&s*(n+1)<=this.viewportHeight*we;)n+=1;this.zoom=Math.min(this.maxZoom,Math.max(this.minZoom,n)),this.centerX=(t.col+t.cols/2)*16,this.centerY=(t.row+t.rows/2)*16,this.targetX=this.centerX,this.targetY=this.centerY,this.tweening=!1,this.recompute()}panBy(t,e){this.followAgentId=null,this.tweening=!1,this.centerX-=t*this.dpr/this.zoom,this.centerY-=e*this.dpr/this.zoom,this.targetX=this.centerX,this.targetY=this.centerY,this.recompute()}zoomAt(t,e,s){if(s===0)return;const n=t*this.dpr,i=e*this.dpr,r=(n-this.offsetX)/this.zoom,o=(i-this.offsetY)/this.zoom,a=Math.min(this.maxZoom,Math.max(this.minZoom,this.zoom+Math.trunc(s)));a!==this.zoom&&(this.zoom=a,this.centerX=r-(n-this.viewportWidth/2)/a,this.centerY=o-(i-this.viewportHeight/2)/a,this.targetX=this.centerX,this.targetY=this.centerY,this.tweening=!1,this.recompute())}centerOn(t,e){this.targetX=t,this.targetY=e,this.tweening=!0}jumpTo(t,e){this.centerX=t,this.centerY=e,this.targetX=t,this.targetY=e,this.tweening=!1,this.recompute()}follow(t){this.followAgentId=t,t===null&&(this.tweening=!1)}update(t,e,s){if(this.followAgentId!==null&&e!==null&&s!==null&&(this.targetX=e,this.targetY=s,this.tweening=!0),!this.tweening)return!1;const n=1-Math.exp(-9*t);this.centerX+=(this.targetX-this.centerX)*n,this.centerY+=(this.targetY-this.centerY)*n;const i=Math.abs(this.targetX-this.centerX)<pe&&Math.abs(this.targetY-this.centerY)<pe;return i&&(this.centerX=this.targetX,this.centerY=this.targetY,this.tweening=this.followAgentId!==null),this.recompute(),!i}recompute(){const t=this.viewportWidth/(2*this.zoom),e=this.viewportHeight/(2*this.zoom);this.centerX=ve(this.centerX,t,0,this.worldWidth),this.centerY=ve(this.centerY,e,this.worldTop,this.worldHeight),this.offsetX=Math.round(this.viewportWidth/2-this.centerX*this.zoom),this.offsetY=Math.round(this.viewportHeight/2-this.centerY*this.zoom)}},vn=Number.POSITIVE_INFINITY,Ci=class{static{u(this,"GameLoop")}options;rafHandle=0;cancelSleep=null;lastTime=0;lastRender=0;plannedSleepSec=0;running=!1;interval;raf;cancelRaf;now;isHidden;frame=u(t=>{if(this.rafHandle=0,!this.running||this.isHidden())return;if(this.lastRender!==0&&t-this.lastRender<this.interval){this.scheduleFrame();return}const e=this.lastTime===0?0:(t-this.lastTime)/1e3,s=Math.max(oe,this.plannedSleepSec+oe);this.lastTime=t,this.lastRender=t,this.plannedSleepSec=0;const n=this.options.step(Math.min(e,s));if(this.options.render(),n<=0){this.scheduleFrame();return}if(n===vn)return;this.plannedSleepSec=n;const i=setTimeout(()=>{this.cancelSleep=null,this.wake()},n*1e3);this.cancelSleep=()=>{clearTimeout(i)}},"frame");constructor(t){this.options=t,this.interval=1e3/(t.fps??30)-1,this.raf=t.raf??(e=>requestAnimationFrame(e)),this.cancelRaf=t.cancelRaf??(e=>cancelAnimationFrame(e)),this.now=t.now??(()=>performance.now()),this.isHidden=t.isHidden??(()=>typeof document<"u"&&document.hidden)}get scheduled(){return this.rafHandle!==0||this.cancelSleep!==null}start(){this.running||(this.running=!0,this.lastTime=0,this.lastRender=0,this.scheduleFrame())}stop(){this.running=!1,this.rafHandle!==0&&(this.cancelRaf(this.rafHandle),this.rafHandle=0),this.cancelSleep?.(),this.cancelSleep=null}wake(){!this.running||this.isHidden()||(this.cancelSleep?.(),this.cancelSleep=null,this.rafHandle===0&&(this.lastRender=0,this.lastTime===0&&(this.lastTime=this.now()),this.scheduleFrame()))}scheduleFrame(){this.rafHandle===0&&(this.rafHandle=this.raf(this.frame))}},xe=16,Si=32;function _i(t,e,s,n){let i=null,r=Number.NEGATIVE_INFINITY;for(const o of s){const a=o.state===E.TYPE?6:0,l=o.x-xe/2,c=o.y+a;if(t<l||t>l+xe||e>c||e<c-Si)continue;const d=o.y+16/2+ln;d<=r||(r=d,i=o.id)}if(i!==null)return{kind:"agent",agentId:i};for(const o of n)if(!(t<o.x||t>o.x+o.width)&&!(e<o.y||e>o.y+o.height))return{kind:"object",object:o.kind};return null}u(_i,"hitTestWorld");var ki="#f5f5f5",Ri="#4ade80",Mi="rgba(255, 255, 255, 0.85)",Fi="rgba(12, 12, 16, 0.9)",Ei=class{static{u(this,"Minimap")}cache=null;cacheSource=null;cacheWidth=0;cacheHeight=0;draw(t,e,s,n,i,r){if(t.clearRect(0,0,e,s),t.fillStyle=Fi,t.fillRect(0,0,e,s),!n||n.width===0||n.height===0)return;const o=Math.min(e/n.width,s/n.height),a=Math.max(1,Math.floor(n.width*o)),l=Math.max(1,Math.floor(n.height*o)),c=Math.floor((e-a)/2),d=Math.floor((s-l)/2);if(!this.cache||this.cacheSource!==n.canvas||this.cacheWidth!==a||this.cacheHeight!==l){const p=this.cache??document.createElement("canvas");p.width=a,p.height=l;const b=p.getContext("2d");b.clearRect(0,0,a,l),b.imageSmoothingEnabled=!0,b.drawImage(n.canvas,0,0,a,l),this.cache=p,this.cacheSource=n.canvas,this.cacheWidth=a,this.cacheHeight=l}t.drawImage(this.cache,c,d);const m=Math.max(1,Math.round(o*6));for(const p of i.characters.values())t.fillStyle=p.isActive&&!p.still?Ri:ki,t.fillRect(c+Math.round(p.x*o)-(m>>1),d+Math.round((p.y-n.originY)*o)-(m>>1),m,m);const f=-r.offsetX/r.zoom,g=-r.offsetY/r.zoom-n.originY,v=r.width/r.zoom,y=r.height/r.zoom;t.strokeStyle=Mi,t.lineWidth=1,t.strokeRect(c+Math.round(f*o)+.5,d+Math.round(g*o)+.5,Math.max(2,Math.round(v*o)),Math.max(2,Math.round(y*o)))}},Oi=4096,Ni=class{static{u(this,"NavGrid")}cols;rows;walkableTiles=[];open;visitedStamp;parent;queue;cache=new Map;stamp=0;constructor(t,e){this.rows=t.length,this.cols=this.rows>0?t[0].length:0;const s=this.cols*this.rows;this.open=new Uint8Array(s),this.visitedStamp=new Int32Array(s),this.parent=new Int32Array(s),this.queue=new Int32Array(s);for(let n=0;n<this.rows;n++){const i=t[n];for(let r=0;r<this.cols;r++){const o=i[r];o===$.WALL||o===$.VOID||e.has(`${r},${n}`)||(this.open[n*this.cols+r]=1,this.walkableTiles.push({col:r,row:n}))}}}inBounds(t,e){return t>=0&&t<this.cols&&e>=0&&e<this.rows}isWalkable(t,e){return this.inBounds(t,e)?this.open[e*this.cols+t]===1:!1}setWalkable(t,e,s){if(!this.inBounds(t,e))return;const n=e*this.cols+t,i=s?1:0;this.open[n]!==i&&(this.open[n]=i,this.cache.clear())}findPath(t,e,s,n,i=!1,r=null){if(!this.inBounds(t,e)||!this.inBounds(s,n))return[];const o=e*this.cols+t,a=n*this.cols+s;if(o===a)return[];if(this.open[a]!==1&&!i)return[];const l=(o*this.open.length+a)*2+(i?1:0);if(r===null){const f=this.cache.get(l);if(f)return this.materialise(f)}if(!this.search(o,a,r))return[];let c=0;for(let f=a;f!==o;f=this.parent[f])c++;const d=new Int32Array(c);let m=c-1;for(let f=a;f!==o;f=this.parent[f])d[m]=f,m--;return r===null&&(this.cache.size>=Oi&&this.cache.clear(),this.cache.set(l,d)),this.materialise(d)}nearestOpen(t,e,s){if(!this.inBounds(t,e))return null;this.stamp++;const{open:n,visitedStamp:i,queue:r,cols:o}=this,a=n.length,l=e*o+t;i[l]=this.stamp,r[0]=l;let c=0,d=1;for(;c<d;){const m=r[c];c++;const f=m%o,g=(m-f)/o;if(n[m]===1&&s(f,g))return{col:f,row:g};for(let v=0;v<4;v++){let y;if(v===0){if(y=m-o,y<0)continue}else if(v===1){if(y=m+o,y>=a)continue}else if(v===2){if(f===0)continue;y=m-1}else{if(f===o-1)continue;y=m+1}i[y]!==this.stamp&&n[y]===1&&(i[y]=this.stamp,r[d]=y,d++)}}return null}search(t,e,s){this.stamp++;const{open:n,visitedStamp:i,parent:r,queue:o,cols:a}=this,l=n.length;i[t]=this.stamp,o[0]=t;let c=0,d=1;for(;c<d;){const m=o[c];if(c++,m===e)return!0;const f=m%a;for(let g=0;g<4;g++){let v;if(g===0){if(v=m-a,v<0)continue}else if(g===1){if(v=m+a,v>=l)continue}else if(g===2){if(f===0)continue;v=m-1}else{if(f===a-1)continue;v=m+1}if(i[v]!==this.stamp&&!(n[v]!==1&&v!==e)&&!(s!==null&&s[v]===1&&v!==e)){if(i[v]=this.stamp,r[v]=m,v===e)return!0;o[d]=v,d++}}}return!1}materialise(t){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]={col:t[s]%this.cols,row:t[s]/this.cols|0};return e}},Li={Read:!0,Grep:!0,Glob:!0,WebFetch:!0,WebSearch:!0};function ji(t){return t!==null&&Li[t]===!0}u(ji,"isReadingTool");function Pi(t,e,s,n){const i=s-t,r=n-e;return i>0?S.RIGHT:i<0?S.LEFT:r>0?S.DOWN:S.UP}u(Pi,"directionBetween");function Bi(t,e,s,n,i=0){const r=n?n.seatCol:1,o=n?n.seatRow:1;return{id:t,state:E.TYPE,dir:n?n.facingDir:S.DOWN,x:r*16+16/2,y:o*16+16/2,tileCol:r,tileRow:o,path:[],moveProgress:0,blockedTimer:0,currentTool:null,palette:e,hueShift:i,frame:0,frameTimer:0,wanderTimer:0,wanderCount:0,wanderLimit:Ut(3,6),isActive:!0,still:!1,pinned:!1,hop:0,seatId:s,bubbleType:null,bubbleTimer:0,seatTimer:0,inputTokens:0,outputTokens:0}}u(Bi,"createCharacter");function Di(t){return t.state===E.WALK?!0:t.state===E.TYPE?!t.still:!1}u(Di,"isCharacterAnimating");function $i(t,e,s,n,i){switch(t.frameTimer+=e,t.state){case E.TYPE:if(t.still?(t.frame=0,t.frameTimer=0):t.frameTimer>=.3&&(t.frameTimer-=xs,t.frame=(t.frame+1)%2),!t.isActive&&!t.pinned){if(t.seatTimer>0){t.seatTimer-=e;break}t.seatTimer=0,t.state=E.IDLE,t.frame=0,t.frameTimer=0,t.wanderTimer=Ct(2,20),t.wanderCount=0,t.wanderLimit=Ut(3,6)}break;case E.IDLE:if(t.frame=0,t.seatTimer<0&&(t.seatTimer=0),t.pinned)break;if(t.isActive){const r=t.seatId?n.get(t.seatId):void 0;if(!r){t.state=E.TYPE,t.frame=0,t.frameTimer=0;break}const o=s.findPath(t.tileCol,t.tileRow,r.seatCol,r.seatRow,!0);o.length>0?(t.path=o,t.moveProgress=0,t.state=E.WALK):(t.state=E.TYPE,t.dir=r.facingDir),t.frame=0,t.frameTimer=0;break}if(t.wanderTimer-=e,t.wanderTimer<=0){t.wanderCount>=t.wanderLimit&&(t.wanderCount=0,t.wanderLimit=Ut(3,6));const r=s.walkableTiles;let o=null;for(let a=0;a<8&&r.length>0;a++){const l=r[Math.floor(Math.random()*r.length)];if(i.isFreeFor(t.id,l.col,l.row)){o=l;break}}if(o){const a=s.findPath(t.tileCol,t.tileRow,o.col,o.row);a.length>0&&(t.path=a,t.moveProgress=0,t.state=E.WALK,t.frame=0,t.frameTimer=0,t.wanderCount++)}t.wanderTimer=Ct(2,20)}break;case E.WALK:{if(t.frameTimer>=.15&&(t.frameTimer-=vs,t.frame=(t.frame+1)%4),t.path.length===0){t.x=t.tileCol*16+16/2,t.y=t.tileRow*16+16/2;const m=t.seatId?n.get(t.seatId):void 0;m&&t.tileCol===m.seatCol&&t.tileRow===m.seatRow&&m?(t.state=E.TYPE,t.dir=m.facingDir):t.isActive&&!t.pinned&&!m?t.state=E.TYPE:t.isActive&&!t.pinned?t.state=E.IDLE:(t.state=E.IDLE,t.wanderTimer=Ct(2,20)),t.frame=0,t.frameTimer=0;break}const r=t.path[0];if(t.dir=Pi(t.tileCol,t.tileRow,r.col,r.row),t.moveProgress===0&&!i.claim(t.id,r.col,r.row)){if(t.blockedTimer+=e,t.frame=1,t.blockedTimer<.6)break;const m=t.path[t.path.length-1],f=t.seatId?n.get(t.seatId):void 0,g=f!==void 0&&f.seatCol===m.col&&f.seatRow===m.row,v=i.isFreeFor(t.id,m.col,m.row)?s.findPath(t.tileCol,t.tileRow,m.col,m.row,g,i.blockedFor(t.id)):[];v.length>0?(t.path=v,t.blockedTimer=0):t.blockedTimer>=3&&(t.path=[],t.blockedTimer=0,t.state=E.IDLE,t.wanderTimer=Ct(.5,2),t.frame=0,t.frameTimer=0);break}t.blockedTimer=0,t.moveProgress+=48/16*e;const o=t.tileCol*16+16/2,a=t.tileRow*16+16/2,l=r.col*16+16/2,c=r.row*16+16/2,d=Math.min(t.moveProgress,1);t.x=o+(l-o)*d,t.y=a+(c-a)*d,t.moveProgress>=1&&(i.release(t.id,t.tileCol,t.tileRow),t.tileCol=r.col,t.tileRow=r.row,t.x=l,t.y=c,t.path.shift(),t.moveProgress=0);break}}}u($i,"updateCharacter");function Wi(t,e){switch(t.state){case E.TYPE:return ji(t.currentTool)?e.reading[t.dir][t.frame%2]:e.typing[t.dir][t.frame%2];case E.WALK:return e.walk[t.dir][t.frame%4];default:return e.walk[t.dir][1]}}u(Wi,"getCharacterSprite");function Ct(t,e){return t+Math.random()*(e-t)}u(Ct,"randomRange");function Ut(t,e){return t+Math.floor(Math.random()*(e-t+1))}u(Ut,"randomInt");var zi=2,at=new Map,ye=new WeakMap;function Hi(t){const e=ye.get(t);if(e)return e;const s=t.length,n=t[0].length,i=[];for(let r=0;r<s+2;r++)i.push(new Array(n+2).fill(""));for(let r=0;r<s;r++)for(let o=0;o<n;o++){if(t[r][o]==="")continue;const a=r+1,l=o+1;i[a-1][l]===""&&(i[a-1][l]="#FFFFFF"),i[a+1][l]===""&&(i[a+1][l]="#FFFFFF"),i[a][l-1]===""&&(i[a][l-1]="#FFFFFF"),i[a][l+1]===""&&(i[a][l+1]="#FFFFFF")}for(let r=0;r<s;r++)for(let o=0;o<n;o++)t[r][o]!==""&&(i[r+1][o+1]="");return ye.set(t,i),i}u(Hi,"getOutlineSprite");function wt(t,e){let s=at.get(e);for(s?at.delete(e):s=new WeakMap,at.set(e,s);at.size>zi;){const l=at.keys().next();if(l.done)break;at.delete(l.value)}const n=s.get(t);if(n)return n;const i=t.length,r=t[0].length,o=document.createElement("canvas");o.width=r*e,o.height=i*e;const a=o.getContext("2d");a.imageSmoothingEnabled=!1;for(let l=0;l<i;l++)for(let c=0;c<r;c++){const d=t[l][c];d!==""&&(a.fillStyle=d,a.fillRect(c*e,l*e,e,e))}return s.set(t,o),o}u(wt,"getCachedSprite");var be=16,Yi=32;function Xi(t,e,s){const n=new Set;for(const r of s)n.add(r.seatRow*e.cols+r.seatCol);const i=new Uint8Array(t.length);for(let r=0;r<t.length;r++){const o=t[r],a=o.x,l=o.x+o.sprite[0].length,c=o.y,d=o.y+o.sprite.length,m=Math.max(0,Math.floor(a/16)-1),f=Math.min(e.cols-1,Math.ceil(l/16)),g=Math.max(0,Math.floor(c/16)-1),v=Math.min(e.rows-1,Math.ceil(d/16)+2);for(let y=g;y<=v&&i[r]===0;y++)for(let p=m;p<=f;p++){if(!e.isWalkable(p,y)&&!n.has(y*e.cols+p)||y*16+16/2+.5>=o.zY)continue;const b=p*16+16/2-be/2,x=y*16+16/2+6,T=x-Yi;if(!(b>=l||b+be<=a)&&!(T>=d||x<=c)){i[r]=1;break}}}return qi(t,i),i}u(Xi,"classifyOccluders");function Gi(t,e){return t.x<e.x+e.sprite[0].length&&e.x<t.x+t.sprite[0].length&&t.y<e.y+e.sprite.length&&e.y<t.y+t.sprite.length}u(Gi,"spriteOverlaps");function qi(t,e){const s=[];for(let n=0;n<t.length;n++)e[n]===1&&s.push(n);for(let n=0;n<s.length;n++){const i=t[s[n]];for(let r=0;r<t.length;r++){if(e[r]===1)continue;const o=t[r];o.zY<=i.zY||!Gi(o,i)||(e[r]=1,s.push(r))}}}u(qi,"liftStackedItems");function Vt(t){let e=0;for(const s of t)s.y<e&&(e=Math.floor(s.y));return e}u(Vt,"drawablesTop");function Ki(t,e,s){const n=Vt(s),i=t.cols*16,r=t.rows*16-n,o=document.createElement("canvas");o.width=i,o.height=r;const a=o.getContext("2d");a.imageSmoothingEnabled=!1,a.translate(0,-n),Ui(a,e,t.tileColors,t.cols);const l=s.map((c,d)=>d);l.sort((c,d)=>s[c].zY-s[d].zY);for(const c of l){const d=s[c],m=wt(d.sprite,1);d.mirrored?(a.save(),a.translate(d.x+m.width,d.y),a.scale(-1,1),a.drawImage(m,0,0),a.restore()):a.drawImage(m,d.x,d.y)}return{canvas:o,width:i,height:r,originY:n}}u(Ki,"buildStaticLayer");function Ui(t,e,s,n){const i=Fs();for(let r=0;r<e.length;r++){const o=e[r];for(let a=0;a<o.length;a++){const l=o[a];if(l===$.VOID)continue;const c=r*n+a;if(l===$.WALL||!i){if(l===$.WALL){const m=s?.[c];t.fillStyle=m?fi(m):As}else t.fillStyle=cn;t.fillRect(a*16,r*16,16,16);continue}const d=s?.[c]??{h:0,s:0,b:0,c:0};t.drawImage(wt(Es(l,d),1),a*16,r*16)}}}u(Ui,"drawTiles");var Vi=class{static{u(this,"TileClaims")}cols;owners=new Map;mask;constructor(t,e){this.cols=t,this.mask=new Uint8Array(t*e)}isFreeFor(t,e,s){const n=this.owners.get(s*this.cols+e);return n===void 0||n===t}claim(t,e,s){const n=s*this.cols+e,i=this.owners.get(n);return i!==void 0&&i!==t?!1:(this.owners.set(n,t),!0)}release(t,e,s){const n=s*this.cols+e;this.owners.get(n)===t&&this.owners.delete(n)}releaseAll(t){for(const[e,s]of this.owners)s===t&&this.owners.delete(e)}blockedFor(t){this.mask.fill(0);for(const[e,s]of this.owners)s!==t&&(this.mask[e]=1);return this.mask}},Zi=class{static{u(this,"OfficeState")}layout;tileMap;seats;blockedTiles;nav;claims;staticFurniture=[];dynamicFurniture=[];switchable=[];characters=new Map;furnitureAnimTimer=0;selectedAgentId=null;hoveredAgentId=null;autoOnTiles=new Set;constructor(t){this.layout=t||Hs(),this.tileMap=Ps(this.layout),this.seats=qt(this.layout.furniture),this.blockedTiles=Ds(this.layout.furniture),this.nav=new Ni(this.tileMap,this.blockedTiles),this.claims=new Vi(this.nav.cols,this.nav.rows),this.buildFurniture()}getLayout(){return this.layout}buildFurniture(){const t=this.layout.furniture,e=[],s=[];for(const c of t){const d=Ns(c.type);if(d===c.type){s.push(null);continue}const m=Ls(d)??[d],f=e.length;for(const g of m)e.push({...c,uid:`${c.uid}:on:${g}`,type:g});s.push({start:f,count:m.length})}const n=Bs([...t,...e]),i=new Array(t.length).fill(null),r=new Array(e.length).fill(null);for(const c of n){const d=c.sourceIndex??0;d<t.length?i[d]=c:r[d-t.length]=c}const o=[];this.switchable=[];for(let c=0;c<t.length;c++){const d=i[c];if(!d)continue;const m=s[c];if(!m){o.push(d);continue}const f=[];for(let g=0;g<m.count;g++){const v=r[m.start+g];v&&f.push(v)}this.switchable.push({off:d,on:f.length>0?f:[d],tiles:this.footprintTiles(t[c])})}const a=ai()?ui(this.tileMap,this.layout.tileColors,this.layout.cols):[];a.length>0&&o.push(...a);const l=Xi(o,this.nav,this.seats.values());this.staticFurniture=[],this.dynamicFurniture=[];for(let c=0;c<o.length;c++)l[c]===1?this.dynamicFurniture.push(o[c]):this.staticFurniture.push(o[c])}footprintTiles(t){const e=Y(t.type),s=[];if(!e)return s;for(let n=0;n<e.footprintH;n++)for(let i=0;i<e.footprintW;i++)s.push((t.row+n)*this.layout.cols+t.col+i);return s}getSpawnTile(){const t=this.layout.spawnTile;return t&&this.nav.isWalkable(t.col,t.row)?t:this.nav.walkableTiles[0]??{col:1,row:1}}findFreeSeat(){const t=new Set;for(const n of this.layout.furniture){const i=Y(n.type);if(!(!i||i.category!=="electronics"))for(let r=0;r<i.footprintH;r++)for(let o=0;o<i.footprintW;o++)t.add(`${n.col+o},${n.row+r}`)}const e=[],s=[];for(const[n,i]of this.seats){if(i.assigned)continue;let r=!1;const o=i.facingDir===S.RIGHT?1:i.facingDir===S.LEFT?-1:0,a=i.facingDir===S.DOWN?1:i.facingDir===S.UP?-1:0;for(let l=1;l<=3&&!r;l++){const c=i.seatCol+o*l,d=i.seatRow+a*l;if(t.has(`${c},${d}`)){r=!0;break}if(o!==0){if(t.has(`${c},${d-1}`)||t.has(`${c},${d+1}`)){r=!0;break}}else if(t.has(`${c-1},${d}`)||t.has(`${c+1},${d}`)){r=!0;break}}(r?e:s).push(n)}return e.length>0?e[Math.floor(Math.random()*e.length)]:s.length>0?s[Math.floor(Math.random()*s.length)]:null}pickDiversePalette(){const t=ei(),e=new Array(t).fill(0);for(const o of this.characters.values())o.palette<t&&e[o.palette]++;const s=Math.min(...e),n=[];for(let o=0;o<t;o++)e[o]===s&&n.push(o);const i=n[Math.floor(Math.random()*n.length)];let r=0;return s>0&&(r=45+Math.floor(Math.random()*271)),{palette:i,hueShift:r}}addAgent(t,e={}){if(this.characters.has(t))return;const s=e.pose;let n,i;if(s)n=s.palette,i=s.hueShift;else if(e.palette!==void 0)n=e.palette,i=e.hueShift??0;else{const d=this.pickDiversePalette();n=d.palette,i=d.hueShift}const r=s?.seatId??e.seatId;let o=null;if(r){const d=this.seats.get(r);d&&!d.assigned&&(o=r)}const a=o!==null;o||(o=this.findFreeSeat());const l=o?this.seats.get(o):null;l&&(l.assigned=!0);const c=Bi(t,n,o,l,i);if(s)c.tileCol=s.tileCol,c.tileRow=s.tileRow,c.x=s.x,c.y=s.y,c.dir=s.dir,c.state=s.state===E.WALK?E.IDLE:s.state,s.state===E.WALK&&this.snapToTile(c,c.tileCol,c.tileRow);else if(!a){const d=this.getSpawnTile();this.snapToTile(c,d.col,d.row),c.state=E.IDLE,c.dir=S.DOWN,c.wanderTimer=Math.random()*3}if(!this.claims.claim(t,c.tileCol,c.tileRow)){const d=this.nav.nearestOpen(c.tileCol,c.tileRow,(m,f)=>this.claims.isFreeFor(t,m,f));d&&(this.snapToTile(c,d.col,d.row),c.state===E.TYPE&&(c.state=E.IDLE),this.claims.claim(t,d.col,d.row))}this.characters.set(t,c)}removeAgent(t){const e=this.characters.get(t);if(e){if(e.seatId){const s=this.seats.get(e.seatId);s&&(s.assigned=!1)}this.selectedAgentId===t&&(this.selectedAgentId=null),this.hoveredAgentId===t&&(this.hoveredAgentId=null),this.claims.releaseAll(t),this.characters.delete(t),this.rebuildAutoOnTiles()}}walkToTile(t,e,s){const n=this.characters.get(t);if(!n)return!1;const i=n.seatId?this.seats.get(n.seatId):void 0,r=i?i.seatCol===e&&i.seatRow===s:!1;if(!this.nav.isWalkable(e,s)&&!r)return!1;let o={col:e,row:s};if(!this.claims.isFreeFor(t,e,s)){const l=this.nav.nearestOpen(e,s,(c,d)=>this.claims.isFreeFor(t,c,d));if(!l)return!1;o=l}const a=this.nav.findPath(n.tileCol,n.tileRow,o.col,o.row,r);return a.length===0?!1:(this.settleClaims(n),n.path=a,n.moveProgress=0,n.state=E.WALK,n.frame=0,n.frameTimer=0,!0)}setAgentActive(t,e){const s=this.characters.get(t);!s||s.isActive===e||(s.isActive=e,e||(s.seatTimer=-1,this.settleClaims(s),s.path=[],s.moveProgress=0),this.rebuildAutoOnTiles())}setAgentStill(t,e){const s=this.characters.get(t);!s||s.still===e||(s.still=e,this.rebuildAutoOnTiles())}snapToTile(t,e,s){t.tileCol=e,t.tileRow=s,t.x=e*16+16/2,t.y=s*16+16/2}settleClaims(t){if(t.moveProgress>0&&t.path.length>0){const e=t.path[0];this.claims.release(t.id,t.tileCol,t.tileRow),this.snapToTile(t,e.col,e.row)}this.claims.releaseAll(t.id),this.claims.claim(t.id,t.tileCol,t.tileRow)}setAgentPinned(t,e){const s=this.characters.get(t);s&&(s.pinned=e)}rebuildAutoOnTiles(){this.autoOnTiles.clear();const t=this.layout.cols;for(const e of this.characters.values()){if(!e.isActive||e.still||!e.seatId)continue;const s=this.seats.get(e.seatId);if(!s)continue;const n=s.facingDir===S.RIGHT?1:s.facingDir===S.LEFT?-1:0,i=s.facingDir===S.DOWN?1:s.facingDir===S.UP?-1:0;for(let r=1;r<=3;r++)this.autoOnTiles.add((s.seatRow+i*r)*t+s.seatCol+n*r);for(let r=1;r<=2;r++){const o=s.seatCol+n*r,a=s.seatRow+i*r;n!==0?(this.autoOnTiles.add((a-1)*t+o),this.autoOnTiles.add((a+1)*t+o)):(this.autoOnTiles.add(a*t+o-1),this.autoOnTiles.add(a*t+o+1))}}}resolveSwitchable(t){const e=this.switchable[t];let s=!1;for(const i of e.tiles)if(this.autoOnTiles.has(i)){s=!0;break}if(!s)return e.off;const n=Math.floor(this.furnitureAnimTimer/Ts);return e.on[n%e.on.length]}isSwitchableAnimating(){return this.autoOnTiles.size>0}setAgentTool(t,e){const s=this.characters.get(t);s&&(s.currentTool=e)}showWaitingBubble(t){const e=this.characters.get(t);e&&(e.bubbleType="waiting",e.bubbleTimer=2)}startHop(t){const e=this.characters.get(t);e&&(e.hop=un)}update(t){this.furnitureAnimTimer+=t;let e=this.isSwitchableAnimating();for(const s of this.characters.values())$i(s,t,this.nav,this.seats,this.claims),Di(s)&&(e=!0),s.hop>0&&(s.hop=Math.max(0,s.hop-t),e=!0),s.bubbleType==="waiting"&&(s.bubbleTimer-=t,e=!0,s.bubbleTimer<=0&&(s.bubbleType=null,s.bubbleTimer=0));return e}nextWakeSeconds(){let t=Number.POSITIVE_INFINITY;for(const e of this.characters.values())e.pinned||(e.state===E.IDLE&&!e.isActive?t=Math.min(t,Math.max(0,e.wanderTimer)):e.state===E.TYPE&&!e.isActive&&(t=Math.min(t,Math.max(0,e.seatTimer))));return t}},xn="pixels-office:v2:",Qi=2e3;function yn(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}u(yn,"storage");function Ji(t){const e=Object.values(E).find(n=>n===t.s),s=Object.values(S).find(n=>n===t.d);return!e||s===void 0||!Number.isFinite(t.x)||!Number.isFinite(t.y)?null:{tileCol:t.c,tileRow:t.r,x:t.x,y:t.y,dir:s,state:e,palette:t.p,hueShift:t.h,seatId:t.seat}}u(Ji,"toRestoredPose");function tr(t){const e=new Map,s=yn();if(!s)return e;const n=s.getItem(xn+t);if(!n)return e;let i;try{i=JSON.parse(n)}catch{return e}if(i?.v!==2||typeof i.poses!="object")return e;for(const[r,o]of Object.entries(i.poses)){const a=Ji(o);a&&e.set(r,a)}return e}u(tr,"loadStoredPoses");function Ie(t,e){const s=yn();if(!s)return;const n={};for(const r of e)n[r.id]={c:r.tileCol,r:r.tileRow,x:r.x,y:r.y,d:r.dir,s:r.state,p:r.palette,h:r.hueShift,seat:r.seatId};const i={v:2,poses:n};try{s.setItem(xn+t,JSON.stringify(i))}catch{return}}u(Ie,"storePoses");var er=class{static{u(this,"PoseFlusher")}companyId;collect;cancelTimer=null;onPageHide=u(()=>{this.flushNow()},"onPageHide");constructor(t,e){this.companyId=t,this.collect=e,typeof window<"u"&&window.addEventListener("pagehide",this.onPageHide)}schedule(){if(this.cancelTimer!==null)return;const t=setTimeout(()=>{this.cancelTimer=null,Ie(this.companyId,this.collect())},Qi);this.cancelTimer=()=>{clearTimeout(t)}}flushNow(){this.cancelTimer?.(),this.cancelTimer=null,Ie(this.companyId,this.collect())}dispose(){this.cancelTimer?.(),this.cancelTimer=null,typeof window<"u"&&window.removeEventListener("pagehide",this.onPageHide)}},nr=class{static{u(this,"SceneRenderer")}capacity=0;sprites=[];drawX=new Float64Array(0);drawY=new Float64Array(0);depth=new Float64Array(0);alpha=new Float64Array(0);mirrored=new Uint8Array(0);order=new Int32Array(0);buckets=new Int32Array(0);count=0;render(t,e,s,n){t.clearRect(0,0,n.width,n.height),s&&sr(t,s,n),this.count=0;for(const i of e.dynamicFurniture)this.pushInstance(i,n);for(let i=0;i<e.switchable.length;i++)this.pushInstance(e.resolveSwitchable(i),n);for(const i of e.characters.values()){const r=Wi(i,ri(i.palette,i.hueShift)),o=wt(r,n.zoom),a=i.state===E.TYPE?6:0,l=i.hop>0?Math.sin((1-i.hop/un)*Math.PI)*7:0,c=Math.round(n.offsetX+i.x*n.zoom-o.width/2),d=Math.round(n.offsetY+(i.y+a-l)*n.zoom-o.height);if(c>n.width||c+o.width<0||d>n.height||d+o.height<0)continue;const m=i.y+16/2+ln,f=e.selectedAgentId===i.id,g=e.hoveredAgentId===i.id;if(f||g){const v=wt(Hi(r),n.zoom);this.push(v,c-n.zoom,d-n.zoom,m-ys,f?1:bs,!1)}this.push(o,c,d,m,1,!1)}this.sortByDepth();for(let i=0;i<this.count;i++){const r=this.order[i],o=this.sprites[r],a=this.alpha[r],l=a<1;l&&(t.save(),t.globalAlpha=a),this.mirrored[r]===1?(t.save(),t.translate(this.drawX[r]+o.width,this.drawY[r]),t.scale(-1,1),t.drawImage(o,0,0),t.restore()):t.drawImage(o,this.drawX[r],this.drawY[r]),l&&t.restore()}}sortByDepth(){const t=this.count;let e=0;for(let n=0;n<t;n++){const i=this.depth[n]|0;i>e&&(e=i)}this.buckets.length<e+2&&(this.buckets=new Int32Array(e+128)),this.order.length<t&&(this.order=new Int32Array(this.capacity));const s=this.buckets;s.fill(0,0,e+2);for(let n=0;n<t;n++)s[(this.depth[n]|0)+1]++;for(let n=1;n<=e+1;n++)s[n]+=s[n-1];for(let n=0;n<t;n++){const i=this.depth[n]|0;this.order[s[i]]=n,s[i]++}}pushInstance(t,e){const s=wt(t.sprite,e.zoom),n=e.offsetX+t.x*e.zoom,i=e.offsetY+t.y*e.zoom;n>e.width||n+s.width<0||i>e.height||i+s.height<0||this.push(s,n,i,t.zY,1,t.mirrored===!0)}push(t,e,s,n,i,r){this.count===this.capacity&&this.grow(),this.sprites[this.count]=t,this.drawX[this.count]=e,this.drawY[this.count]=s,this.depth[this.count]=n,this.alpha[this.count]=i,this.mirrored[this.count]=r?1:0,this.count++}grow(){const t=this.capacity===0?256:this.capacity*2,e=new Float64Array(t),s=new Float64Array(t),n=new Float64Array(t),i=new Float64Array(t),r=new Uint8Array(t);e.set(this.drawX),s.set(this.drawY),n.set(this.depth),i.set(this.alpha),r.set(this.mirrored),this.drawX=e,this.drawY=s,this.depth=n,this.alpha=i,this.mirrored=r,this.sprites.length=t,this.capacity=t}};function sr(t,e,s){const n=s.offsetY+e.originY*s.zoom,i=Math.max(0,Math.floor(-s.offsetX/s.zoom)),r=Math.max(0,Math.floor(-n/s.zoom)),o=Math.min(e.width,Math.ceil((s.width-s.offsetX)/s.zoom)),a=Math.min(e.height,Math.ceil((s.height-n)/s.zoom)),l=o-i,c=a-r;l<=0||c<=0||t.drawImage(e.canvas,i,r,l,c,s.offsetX+i*s.zoom,n+r*s.zoom,l*s.zoom,c*s.zoom)}u(sr,"blitStaticLayer");var ir=3,rr=25,or=class{static{u(this,"OfficeControllerImpl")}companyId;worldWidth;worldHeight;state;cameraState;renderer=new nr;minimap=new Ei;loop;flusher;visuals=new Map;listeners=new Set;visits=new Map;objectBoxes=[];anchors=new Map;officeRoom;view={zoom:1,offsetX:0,offsetY:0,width:0,height:0,nowMs:0};renderedFrames=0;get frameCount(){return this.renderedFrames}poseScratch={agentId:"",x:0,y:0,moving:!1,seated:!1};onVisibilityChange=u(()=>{typeof document<"u"&&!document.hidden&&this.loop.wake()},"onVisibilityChange");overlays=[];canvas=null;ctx=null;resizeObserver=null;staticLayer=null;syncKey="";fitted=!1;rooms;constructor(t,e,s){this.companyId=t,this.state=new Zi(e),this.worldWidth=e.cols*16,this.worldHeight=e.rows*16,this.officeRoom=s.office,this.rooms=s.rooms.map((n,i)=>({id:i===0?"office":i===1?"boardroom":`overflow-${i-1}`,label:i===0?"Office":i===1?"Boardroom & Kitchen":`Overflow ${i-1}`,centerX:(n.col+n.cols/2)*16,centerY:(n.row+n.rows/2)*16})),this.cameraState=new Ti(this.worldWidth,this.worldHeight,Math.min(Vt(this.state.staticFurniture),Vt(this.state.dynamicFurniture))),this.collectObjects(e),this.flusher=new er(t,()=>this.state.characters.values()),this.loop=new Ci({step:u(n=>this.step(n),"step"),render:u(()=>this.render(),"render")})}collectObjects(t){const e=Object.keys(ge);for(const s of e){const n=ge[s],i=t.furniture.find(d=>d.type===n);if(!i)continue;const r=Y(n);if(!r)continue;const o=i.col*16,a=i.row*16,l=r.footprintW*16,c=r.sprite.length;this.objectBoxes.push({kind:s,x:o,y:a,width:l,height:c}),this.anchors.set(s,{x:o+l/2,y:a})}}syncAgents(t,e){let s="";for(const o of t)s+=`${o.agentId}:${o.status}:${o.working?1:0}:${o.activity?.icon??"-"};`;for(const o of e)s+=`${o.agentId}@${o.seatId};`;if(s===this.syncKey){let o=!1;for(const a of t)this.visuals.get(a.agentId)!==a&&(this.visuals.set(a.agentId,a),o=!0);o&&this.loop.wake();return}this.syncKey=s;const n=new Map;for(const o of e)n.set(o.agentId,o);const i=this.visuals.size===0?tr(this.companyId):null,r=new Set;for(const o of t){if(r.add(o.agentId),this.visuals.set(o.agentId,o),!this.state.characters.has(o.agentId)){const a=n.get(o.agentId);this.state.addAgent(o.agentId,{palette:a?.characterIndex,seatId:a?.seatId,pose:i?.get(o.agentId)})}this.applyStatus(o)}for(const o of Array.from(this.state.characters.keys()))r.has(o)||(this.state.removeAgent(o),this.visuals.delete(o),this.visits.delete(o));this.loop.wake()}applyStatus(t){const e=t.status,s=e==="idle"&&!t.working,n=!t.working&&(e==="paused"||e==="budget_paused"||e==="error");this.state.setAgentActive(t.agentId,!s),this.state.setAgentStill(t.agentId,n);const i=t.activity?.icon==="read"&&!s&&!n;this.state.setAgentTool(t.agentId,i?"Read":null)}readPlacements(){const t=[];for(const[e,s]of this.state.characters)s.seatId&&t.push({agentId:e,characterIndex:s.palette,seatId:s.seatId});return t}visual(t){return this.visuals.get(t)}forEachPose(t){for(const e of this.state.characters.values())this.fillPose(this.poseScratch,e),t(this.poseScratch)}pose(t){const e=this.state.characters.get(t);if(e)return{agentId:e.id,x:e.x,y:e.y,moving:e.state===E.WALK,seated:e.state===E.TYPE}}fillPose(t,e){t.agentId=e.id,t.x=e.x,t.y=e.y,t.moving=e.state===E.WALK,t.seated=e.state===E.TYPE}objectAnchor(t){return this.anchors.get(t)}emit(t){if(t.kind==="celebrate")if(t.big)for(const e of this.state.characters.keys())this.state.startHop(e);else this.state.startHop(t.agentId);else t.kind==="visit"&&this.startVisit(t.fromAgentId,t.toAgentId);for(const e of this.listeners)e(t);this.loop.wake()}onEffect(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}setOverlayLayers(t){this.overlays=t,this.loop.wake()}hitTest(t,e){const s=this.cameraState.dpr,n=(t*s-this.view.offsetX)/this.view.zoom,i=(e*s-this.view.offsetY)/this.view.zoom;return _i(n,i,this.state.characters.values(),this.objectBoxes)}select(t){this.state.selectedAgentId=t,this.loop.wake()}get selectedAgentId(){return this.state.selectedAgentId}hover(t){const e=t!==null&&t.kind==="agent"?t.agentId:null;e!==this.state.hoveredAgentId&&(this.state.hoveredAgentId=e,this.loop.wake())}get hoveredAgentId(){return this.state.hoveredAgentId}get camera(){return this.cameraState}panBy(t,e){this.fitted=!0,this.cameraState.panBy(t,e),this.loop.wake()}zoomAt(t,e,s){this.fitted=!0,this.cameraState.zoomAt(t,e,s),this.loop.wake()}centerOn(t,e){this.fitted=!0,this.cameraState.centerOn(t,e),this.loop.wake()}follow(t){this.fitted=!0,this.cameraState.follow(t),this.loop.wake()}drawMinimap(t,e,s){this.minimap.draw(t,e,s,this.staticLayer,this.state,this.view)}attach(t){if(this.canvas===t){this.loop.wake();return}this.canvas&&this.detach(),this.canvas=t,this.ctx=t.getContext("2d"),this.ctx&&(this.ctx.imageSmoothingEnabled=!1),this.staticLayer??=Ki(this.state.getLayout(),this.state.tileMap,this.state.staticFurniture),this.resize(),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.resize(),this.loop.wake()}),this.resizeObserver.observe(t)),typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.loop.start()}detach(){this.loop.stop(),this.resizeObserver?.disconnect(),this.resizeObserver=null,typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange),this.flusher.flushNow(),this.canvas=null,this.ctx=null}wake(){this.loop.wake()}dispose(){this.detach(),this.flusher.dispose(),this.listeners.clear()}resize(){const t=this.canvas;if(!t)return;const e=typeof window<"u"&&window.devicePixelRatio||1,s=t.getBoundingClientRect(),n=Math.max(1,Math.round((s.width||t.clientWidth)*e)),i=Math.max(1,Math.round((s.height||t.clientHeight)*e));t.width!==n&&(t.width=n),t.height!==i&&(t.height=i),this.ctx&&(this.ctx.imageSmoothingEnabled=!1),this.cameraState.setViewport(n,i,e),this.fitted||this.cameraState.fitRoom(this.officeRoom)}startVisit(t,e){if(this.visits.has(t)||t===e)return;const s=this.state.characters.get(e);if(!s)return;const n=this.freeTileNear(s.tileCol,s.tileRow);if(n){if(this.state.setAgentPinned(t,!0),!this.state.walkToTile(t,n.col,n.row)){this.state.setAgentPinned(t,!1);return}this.visits.set(t,{toAgentId:e,phase:"travelling",timer:rr})}}freeTileNear(t,e){const s=this.state.nav;for(let n=1;n<=3;n++)for(let i=-n;i<=n;i++)for(let r=-n;r<=n;r++)if(!(Math.abs(i)!==n&&Math.abs(r)!==n)&&s.isWalkable(t+r,e+i))return{col:t+r,row:e+i};return null}updateVisits(t){if(this.visits.size===0)return!1;for(const[e,s]of this.visits){const n=this.state.characters.get(e);if(!n){this.visits.delete(e);continue}if(s.timer-=t,s.phase==="travelling"){n.state!==E.WALK?(s.phase="lingering",s.timer=ir):s.timer<=0&&this.endVisit(e);continue}s.timer<=0&&this.endVisit(e)}return this.visits.size>0}endVisit(t){this.visits.delete(t),this.state.setAgentPinned(t,!1)}step(t){let e=this.state.update(t);this.updateVisits(t)&&(e=!0);const s=this.cameraState.followAgentId,n=s!==null?this.state.characters.get(s):void 0;this.cameraState.update(t,n?.x??null,n?.y??null)&&(e=!0);for(const r of this.overlays)r.update(t,this)&&(e=!0);if(this.flusher.schedule(),e)return 0;const i=this.state.nextWakeSeconds();return i===Number.POSITIVE_INFINITY?vn:Math.max(.05,i)}render(){const t=this.ctx,e=this.canvas;if(!(!t||!e)){this.renderedFrames+=1,this.view.zoom=this.cameraState.zoom,this.view.offsetX=this.cameraState.offsetX,this.view.offsetY=this.cameraState.offsetY,this.view.width=e.width,this.view.height=e.height,this.view.nowMs=Date.now(),this.renderer.render(t,this.state,this.staticLayer,this.view);for(const s of this.overlays)s.draw(t,this.view,this)}}},ar=3,tt=new Map,St=new Map;function lr(t){const e=tt.get(t);if(e)return Promise.resolve(e);const s=St.get(t);if(s)return s;const n=Ii().then(({layouts:i,cameraBounds:r})=>{St.delete(t);const o=tt.get(t);if(o)return o;const a=new or(t,i.combined,r);for(tt.set(t,a);tt.size>ar;){const l=tt.keys().next();if(l.done||l.value===t)break;tt.get(l.value)?.dispose(),tt.delete(l.value)}return a}).catch(i=>{throw St.delete(t),i});return St.set(t,n),n}u(lr,"getOfficeController");var cr=class{static{u(this,"ParticlePool")}capacity;x;y;vx;vy;life;maxLife;tint;count=0;constructor(t){this.capacity=t,this.x=new Float32Array(t),this.y=new Float32Array(t),this.vx=new Float32Array(t),this.vy=new Float32Array(t),this.life=new Float32Array(t),this.maxLife=new Float32Array(t),this.tint=new Uint8Array(t)}spawn(t,e,s,n,i,r){if(this.count>=this.capacity)return!1;const o=this.count;return this.x[o]=t,this.y[o]=e,this.vx[o]=s,this.vy[o]=n,this.life[o]=i,this.maxLife[o]=i,this.tint[o]=r,this.count+=1,!0}step(t,e,s){let n=0;for(;n<this.count;){const i=this.life[n]-t;if(i<=0){const r=this.count-1;this.x[n]=this.x[r],this.y[n]=this.y[r],this.vx[n]=this.vx[r],this.vy[n]=this.vy[r],this.life[n]=this.life[r],this.maxLife[n]=this.maxLife[r],this.tint[n]=this.tint[r],this.count=r;continue}this.life[n]=i,this.vy[n]+=e*t,this.vx[n]*=s,this.x[n]+=this.vx[n]*t,this.y[n]+=this.vy[n]*t,n+=1}return this.count>0}clear(){this.count=0}};var Ae=1.2,Te=.25;var ur=.985;var bn=["#f87171","#fbbf24","#34d399","#60a5fa","#c084fc","#f9fafb"],fr=class{static{u(this,"OfficeEffectState")}confetti=new cr(180);visits=Array.from({length:12},()=>({fromAgentId:"",toAgentId:"",ttl:0}));mentions=Array.from({length:12},()=>({agentId:"",ttl:0}));smokes=Array.from({length:8},()=>({agentId:"",ttl:0,frame:0,frameTimer:0}));cheers=Array.from({length:40},()=>({agentId:"",ttl:0}));stickyErrors=new Set;visitCount=0;mentionCount=0;smokeCount=0;cheerCount=0;alarmPhase=0;office;unsubscribe;bigCheerPending=!1;constructor(t){this.office=t,this.unsubscribe=t.onEffect(this.handleEffect)}dispose(){this.unsubscribe()}cheerPose=u(t=>{this.pushCheer(t.agentId)},"cheerPose");handleEffect=u(t=>{if(t.kind==="celebrate"){const s=this.office.pose(t.agentId);s&&this.burst(s.x,s.y-24,t.big?72:36),this.pushCheer(t.agentId),t.big&&(this.bigCheerPending=!0);return}if(t.kind==="error"){this.stickyErrors.add(t.agentId);for(let n=0;n<this.smokeCount;n+=1)if(this.smokes[n].agentId===t.agentId){this.smokes[n].ttl=6;return}if(this.smokeCount>=8)return;const s=this.smokes[this.smokeCount];s.agentId=t.agentId,s.ttl=6,s.frame=0,s.frameTimer=0,this.smokeCount+=1;return}if(t.kind==="visit"){for(let n=0;n<this.visitCount;n+=1){const i=this.visits[n];if(i.fromAgentId===t.fromAgentId){i.toAgentId=t.toAgentId,i.ttl=4;return}}if(this.visitCount>=12)return;const s=this.visits[this.visitCount];s.fromAgentId=t.fromAgentId,s.toAgentId=t.toAgentId,s.ttl=4,this.visitCount+=1;return}for(let s=0;s<this.mentionCount;s+=1)if(this.mentions[s].agentId===t.agentId){this.mentions[s].ttl=3;return}if(this.mentionCount>=12)return;const e=this.mentions[this.mentionCount];e.agentId=t.agentId,e.ttl=3,this.mentionCount+=1},"handleEffect");burst(t,e,s){for(let n=0;n<s;n+=1){const i=Math.random()*Math.PI*2,r=20+Math.random()*55;if(!this.confetti.spawn(t,e,Math.cos(i)*r,Math.sin(i)*r-40,.9+Math.random()*.8,Math.random()*bn.length|0))return}}pushCheer(t){for(let s=0;s<this.cheerCount;s+=1)if(this.cheers[s].agentId===t){this.cheers[s].ttl=Ae;return}if(this.cheerCount>=40)return;const e=this.cheers[this.cheerCount];e.agentId=t,e.ttl=Ae,this.cheerCount+=1}mentionTtl(t){for(let e=0;e<this.mentionCount;e+=1)if(this.mentions[e].agentId===t)return this.mentions[e].ttl;return 0}update(t){this.bigCheerPending&&(this.bigCheerPending=!1,this.office.forEachPose(this.cheerPose));const e=this.office.selectedAgentId;e!==null&&this.stickyErrors.delete(e);let s=this.confetti.step(t,90,ur),n=0;for(;n<this.visitCount;){const i=this.visits[n];if(i.ttl-=t,i.ttl<=0){const r=this.visitCount-1;this.visits[n]=this.visits[r],this.visits[r]=i,this.visitCount=r;continue}n+=1}for(this.visitCount>0&&(s=!0),n=0;n<this.mentionCount;){const i=this.mentions[n];if(i.ttl-=t,i.ttl<=0){const r=this.mentionCount-1;this.mentions[n]=this.mentions[r],this.mentions[r]=i,this.mentionCount=r;continue}n+=1}for(this.mentionCount>0&&(s=!0),n=0;n<this.cheerCount;){const i=this.cheers[n];if(i.ttl-=t,i.ttl<=0){const r=this.cheerCount-1;this.cheers[n]=this.cheers[r],this.cheers[r]=i,this.cheerCount=r;continue}n+=1}for(this.cheerCount>0&&(s=!0),n=0;n<this.smokeCount;){const i=this.smokes[n];if(i.ttl-=t,i.ttl<=0){const r=this.smokeCount-1;this.smokes[n]=this.smokes[r],this.smokes[r]=i,this.smokeCount=r;continue}for(i.frameTimer+=t;i.frameTimer>=Te;)i.frameTimer-=Te,i.frame=(i.frame+1)%3;n+=1}return this.smokeCount>0?(this.alarmPhase+=t,s=!0):this.alarmPhase=0,s}},W=new Float32Array([18,24,64,.46,18,24,64,.48,18,24,64,.48,18,24,64,.46,24,30,70,.42,60,45,80,.34,255,150,90,.2,255,180,120,.1,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,170,100,.12,255,130,70,.22,200,90,70,.3,60,50,90,.38,30,32,72,.42,20,26,66,.45,18,24,64,.46]),dr={r:255,g:255,b:255,alpha:0};function hr(t,e=dr){const s=(t%24+24)%24,n=Math.floor(s),i=(n+1)%24,r=s-n,o=n*4,a=i*4;return e.r=W[o]+(W[a]-W[o])*r,e.g=W[o+1]+(W[a+1]-W[o+1])*r,e.b=W[o+2]+(W[a+2]-W[o+2])*r,e.alpha=W[o+3]+(W[a+3]-W[o+3])*r,e}u(hr,"tintForHour");var mr=2.5,gr=2,pr=14,gt=new Map;function wr(t){const e=gt.get(t);if(e!==void 0)return e;let s=null;if(typeof document<"u"){const n=Math.max(8,Math.round(mr*2*16*t)),i=document.createElement("canvas");i.width=n,i.height=n;const r=i.getContext("2d");if(r){const o=n/2,a=r.createRadialGradient(o,o,0,o,o,o);a.addColorStop(0,"rgba(255, 196, 108, 0.42)"),a.addColorStop(.45,"rgba(255, 170, 80, 0.18)"),a.addColorStop(1,"rgba(255, 150, 60, 0)"),r.fillStyle=a,r.fillRect(0,0,n,n),s=i}}if(gt.set(t,s),gt.size>gr){const n=gt.keys().next();n.done||gt.delete(n.value)}return s}u(wr,"glowSprite");var Bt=6e4;function vr(){const t={r:255,g:255,b:255,alpha:0};let e="",s=0,n=-6e4,i=null,r=null,o=null,a=null,l=0,c=0,d=!1;const m=u(f=>{const g=i,v=r,y=o;if(!g||!v||!y||!a)return;const p=y.visual(f.agentId);if(!p||p.status!=="running")return;const b=f.seated?6:0,x=Math.round(g.offsetX+f.x*g.zoom-l/2),T=Math.round(g.offsetY+(f.y+b-pr)*g.zoom-l/2);x+l<0||T+l<0||x>g.width||T>g.height||v.drawImage(a,x,T)},"drawGlow");return{update(f,g){return d||(d=!0,setTimeout(()=>{d=!1,!(typeof document<"u"&&document.hidden)&&g.wake()},Bt)),c+=f*1e3,c<Bt?!1:(c=0,!0)},draw(f,g,v){if(g.nowMs-n>=Bt){n=g.nowMs;const y=new Date(g.nowMs);hr(y.getHours()+y.getMinutes()/60,t),s=t.alpha,e=`rgb(${Math.round(255+(t.r-255)*t.alpha)}, ${Math.round(255+(t.g-255)*t.alpha)}, ${Math.round(255+(t.b-255)*t.alpha)})`}s>.01&&(f.save(),f.globalCompositeOperation="multiply",f.fillStyle=e,f.fillRect(0,0,g.width,g.height),f.restore(),a=wr(Math.max(1,Math.round(g.zoom))),a&&(l=a.width,i=g,r=f,o=v,f.save(),f.globalCompositeOperation="lighter",v.forEachPose(m),f.restore(),i=null,r=null))}}}u(vr,"createAmbienceLayer");var Ce=["/pixels/furniture/SMOKE/SMOKE_1.png","/pixels/furniture/SMOKE/SMOKE_2.png","/pixels/furniture/SMOKE/SMOKE_3.png"],xr="/pixels/furniture/CONFETTI/CONFETTI.png",In=[null,null,null],ut=null,Se=!1;function yr(){if(!(Se||typeof Image>"u")){Se=!0;for(let t=0;t<Ce.length;t+=1){const e=new Image;e.src=Ce[t],In[t]=e}ut=new Image,ut.src=xr}}u(yr,"requestEffectSprites");function br(t){const e=In[t];return e&&e.complete&&e.naturalWidth>0?e:null}u(br,"smokeFrame");function Ir(){return ut&&ut.complete&&ut.naturalWidth>0?ut:null}u(Ir,"confettiPop");var Ar=1.5,Tr=16,_e=30,Cr=32,Sr=.4,_r=.45,kr="rgba(248, 113, 113, 0.55)",Rr="rgba(129, 212, 250, 0.85)",Mr=[3,3],ke=18;function Fr(t){return yr(),{update(e){return t.update(e)},draw(e,s,n){const i=s.zoom,r=t.confetti;if(r.count>0){const o=Math.max(1,Math.round(Ar*i));for(let a=0;a<r.count;a+=1)e.fillStyle=bn[r.tint[a]],e.fillRect(Math.round(s.offsetX+r.x[a]*i),Math.round(s.offsetY+r.y[a]*i),o,o)}for(let o=0;o<t.cheerCount;o+=1){const a=t.cheers[o];if(a.ttl<1.2-Sr)continue;const l=Ir();if(!l)break;const c=n.pose(a.agentId);if(!c)continue;const d=Cr*i;e.drawImage(l,Math.round(s.offsetX+c.x*i-d/2),Math.round(s.offsetY+(c.y-_e)*i-d/2),d,d)}for(let o=0;o<t.smokeCount;o+=1){const a=t.smokes[o],l=n.pose(a.agentId);if(!l)continue;const c=br(a.frame),d=Tr*i,m=Math.round(s.offsetX+l.x*i-d/2),f=Math.round(s.offsetY+(l.y-_e)*i-d);c?e.drawImage(c,m,f,d,d):(e.fillStyle="rgba(226, 232, 240, 0.55)",e.fillRect(m+d/4,f+d/4,d/2,d/2))}if(t.smokeCount>0){const o=n.objectAnchor("alarm");if(o&&Math.floor(t.alarmPhase/_r)%2===0){const a=16*i;e.save(),e.globalCompositeOperation="lighter",e.fillStyle=kr,e.fillRect(Math.round(s.offsetX+o.x*i-a/2),Math.round(s.offsetY+o.y*i-a/2),a,a),e.restore()}}if(t.visitCount>0){e.save(),e.setLineDash(Mr),e.strokeStyle=Rr,e.lineWidth=Math.max(1,Math.round(i/2));for(let o=0;o<t.visitCount;o+=1){const a=t.visits[o],l=n.pose(a.fromAgentId),c=n.pose(a.toAgentId);!l||!c||(e.beginPath(),e.moveTo(s.offsetX+l.x*i,s.offsetY+(l.y-ke)*i),e.lineTo(s.offsetX+c.x*i,s.offsetY+(c.y-ke)*i),e.stroke())}e.restore()}}}}u(Fr,"createEffectsLayer");var Er="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/#!?:+@'(), ",Re=["####.#####.##.#","##.#.###.#.###.",".###..#..#...##","##.#.##.##.###.","####..##.#..###","####..##.#..#..",".###..#.##.#.##","#.##.#####.##.#","###.#..#..#.###","..#..#..##.#.#.","#.##.###.#.##.#","#..#..#..#..###","#.########.##.#","#.###.###.###.#",".#.#.##.##.#.#.","##.#.###.#..#..",".#.#.##.####.##","##.#.###.#.##.#",".###...#...###.","###.#..#..#..#.","#.##.##.##.####","#.##.##.##.#.#.","#.##.########.#","#.##.#.#.#.##.#","#.##.#.#..#..#.","###..#.#.#..###",".#.#.##.##.#.#.",".#.##..#..#.###","##...#.#.#..###","##...#.#...###.","#.##.####..#..#","####..##...###.",".###..####.####","###..#.#..#..#.","####.#####.####","####.####..###.",".............#.","......###......","............###","..#..#.#.#..#..","#.#####.#####.#",".#..#..#.....#.","##...#.#.....#.","....#.....#....","....#.###.#....","####.#####...##",".#..#..........","..#.#..#..#...#","#...#..#..#.#..","..........#.#..","..............."],An=50,yt=new Int16Array(128).fill(-1);for(let t=0;t<51;t+=1)yt[Er.charCodeAt(t)]=t;for(let t=97;t<=122;t+=1)yt[t]=yt[t-32];function te(t){let e=0;for(let s=0;s<t.length;s+=1){const n=t.charCodeAt(s),i=n<128?yt[n]:-1;i<0||(e+=i===An?3:4)}return e>0?e-1:0}u(te,"measureLabelWidth");var Or=4,et=new Map;function Nr(t,e){if(typeof document>"u")return null;const s=document.createElement("canvas");s.width=153*t,s.height=5*t;const n=s.getContext("2d");if(!n)return null;n.fillStyle=e;for(let o=0;o<Re.length;o+=1){const a=Re[o],l=o*3*t;for(let c=0;c<5;c+=1)for(let d=0;d<3;d+=1)a.charCodeAt(c*3+d)===35&&n.fillRect(l+d*t,c*t,t,t)}const i=3*t,r=5*t;return{zoom:t,color:e,height:r,drawText(o,a,l,c){let d=l;for(let m=0;m<a.length;m+=1){const f=a.charCodeAt(m),g=f<128?yt[f]:-1;if(!(g<0)){if(g===An){d+=3*t;continue}o.drawImage(s,g*i,0,i,r,d,c,i,r),d+=4*t}}}}}u(Nr,"createAtlas");function Tn(t,e){const s=Math.max(1,Math.round(t)),n=`${s}|${e}`,i=et.get(n);if(i!==void 0)return et.delete(n),et.set(n,i),i;const r=Nr(s,e);if(et.set(n,r),et.size>Or){const o=et.keys().next();o.done||et.delete(o.value)}return r}u(Tn,"getGlyphAtlas");function Lr(t,e){return t.y-e.y||t.x-e.x}u(Lr,"compareBoxes");function jr(t,e){const s=t.length;if(!(s<2)){t.sort(Lr);for(let n=1;n<s;n+=1){const i=t[n];for(let r=0;r<s;r+=1){let o=!1;for(let a=0;a<n;a+=1){const l=t[a];i.x>=l.x+l.w||l.x>=i.x+i.w||i.y>=l.y+l.h+e||l.y>=i.y+i.h+e||(i.y=l.y+l.h+e,o=!0)}if(!o)break}}}}u(jr,"declutterLabelBoxes");var Cn={read:{rows:".#####..#...#..#ooo#..#...#..#ooo#..#...#..#####.",primary:"#e5e7eb",secondary:"#60a5fa"},write:{rows:".....oo....oo#...oo#...oo#...oo#...oo#....##.....",primary:"#fbbf24",secondary:"#fde68a"},run:{rows:".......#o......#o......#o....#o....#o.......#####",primary:"#34d399",secondary:"#065f46"},web:{rows:"..###...#ooo#.#o#o#o##ooooo##o#o#o#.#ooo#...###..",primary:"#38bdf8",secondary:"#0c4a6e"},think0:{rows:".#####.#.....##o....##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},think1:{rows:".#####.#.....##o.o..##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},think2:{rows:".#####.#.....##o.o.o##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},comment:{rows:"#####..#ooo#..#ooo#..#ooo#..#####....#.....#.....",primary:"#a78bfa",secondary:"#ede9fe"},other:{rows:".........###...#ooo#..#ooo#..#ooo#...###.........",primary:"#9ca3af",secondary:"#d1d5db"},bangRed:{rows:"..###....###....###....###....oo#...........###..",primary:"#f87171",secondary:"#991b1b"},bangYellow:{rows:"..###....###....###....###....oo#...........###..",primary:"#facc15",secondary:"#854d0e"},sleep:{rows:"###......#.....#.....###.###.....#.....#......###",primary:"#93c5fd",secondary:"#93c5fd"},coin:{rows:".........###...#ooo#..#o#o#..#ooo#...###.........",primary:"#fbbf24",secondary:"#fde68a"},mention:{rows:".#####.#.....##.###.##.#.#.##.###.##.......#####.",primary:"#67e8f9",secondary:"#155e75"}},vt=Object.keys(Cn),Sn={};for(let t=0;t<vt.length;t+=1)Sn[vt[t]]=t;var Pr=3,nt=new Map;function Br(t){if(typeof document>"u")return null;const e=7*t,s=document.createElement("canvas");s.width=e*vt.length,s.height=e;const n=s.getContext("2d");if(!n)return null;for(let i=0;i<vt.length;i+=1){const r=Cn[vt[i]],o=i*e;for(let a=0;a<7;a+=1)for(let l=0;l<7;l+=1){const c=r.rows.charCodeAt(a*7+l);c!==46&&(n.fillStyle=c===35?r.primary:r.secondary,n.fillRect(o+l*t,a*t,t,t))}}return{zoom:t,size:e,draw(i,r,o,a){const l=Sn[r];i.drawImage(s,l*e,0,e,e,o,a,e,e)}}}u(Br,"createIconAtlas");function Dr(t){const e=Math.max(1,Math.round(t)),s=nt.get(e);if(s!==void 0)return nt.delete(e),nt.set(e,s),s;const n=Br(e);if(nt.set(e,n),nt.size>Pr){const i=nt.keys().next();i.done||nt.delete(i.value)}return n}u(Dr,"getIconAtlas");var Dt=1,$r=34,Wr=2,Me="rgba(12, 14, 20, 0.8)",Fe="rgba(148, 163, 184, 0.45)",Ee=1e4,Oe=320,zr="#cbd5e1",Hr=22,Yr=2,Xr=2;function Gr(t){let e="";for(const s of t)s!==" "&&s.charCodeAt(0)<128&&te(s)>0?e+=s:e.length>0&&!e.endsWith(" ")&&(e+=" ");return e=e.trim(),e.length<=Hr?e:`${e.slice(0,20).trimEnd()}..`}u(Gr,"progressCaption");var Ne={read:"read",write:"write",run:"run",web:"web",comment:"comment",other:"other"};function qr(t){let e=null,s=0,n=null,i=null,r=null,o=!1,a=null,l=0;const c=new Map,d=u((y,p)=>{const b=c.get(y);if(b&&b.message===p)return b;const x=Gr(p),T={message:p,text:x,width:te(x)};return c.set(y,T),T},"captionFor"),m=u((y,p,b,x)=>{if(!i||!e||!a||x.width===0)return y;const T=e.zoom,A=Dt*T,w=x.width*T+4*T,I=b+A*2;i.fillStyle=Me,i.fillRect(y-A,p-A,w,I),i.strokeStyle=Fe,i.lineWidth=1,i.strokeRect(y-A+.5,p-A+.5,w-1,I-1);const C=p-A+Math.round((I-5*T)/2);return a.drawText(i,x.text,y-A+Yr*T,C),y-A+w},"drawCaption"),f=u((y,p,b,x)=>{if(!i||!e)return;const T=Dt*e.zoom;i.fillStyle=Me,i.fillRect(y-T,p-T,b+T*2,b+T*2),i.strokeStyle=Fe,i.lineWidth=1,i.strokeRect(y-T+.5,p-T+.5,b+T*2-1,b+T*2-1),e.draw(i,x,y,p)},"drawBubble"),g=u(y=>{const p=n,b=r;if(!p||!b||!e||!i)return;const x=b.visual(y.agentId);if(!x)return;const T=y.seated?6:0,A=7*e.zoom,w=y.y+T-$r,I=Math.round(p.offsetX+y.x*p.zoom-A/2),C=Math.round(p.offsetY+w*p.zoom-A);if(I+A<0||C+A<0||I>p.width||C>p.height)return;if(t.mentionTtl(y.agentId)>0){f(I,C,A,"mention"),o=!0;return}const k=x.status==="error"||t.stickyErrors.has(y.agentId);if(x.working){v(y,x.activity,I,C,A,k,x.attention);return}if(k){f(I,C,A,"bangRed");return}if(x.status==="awaiting_board"||x.status==="pending_approval"){f(I,C,A,"bangYellow");return}if(x.status==="budget_paused"){f(I,C,A,"sleep"),f(I+A+Wr*e.zoom,C,A,"coin");return}if(x.status==="paused"){f(I,C,A,"sleep");return}const R=x.activity;if(R&&!(p.nowMs-R.updatedAtMs>Ee)){if(R.icon==="think"){const F=Math.floor(p.nowMs/Oe)%3;f(I,C,A,F===0?"think0":F===1?"think1":"think2"),o=!0;return}f(I,C,A,Ne[R.icon])}},"drawForPose"),v=u((y,p,b,x,T,A,w)=>{const I=n,C=r;if(!I||!C||!e)return;const k=p!==null&&I.nowMs-p.updatedAtMs<=Ee;let R;if(!p||p.icon==="think")if(k){const j=Math.floor(I.nowMs/Oe)%3;R=j===0?"think0":j===1?"think1":"think2",o=!0}else R="think1";else R=Ne[p.icon];f(b,x,T,R);const F=4*e.zoom;let L=b+T+F;k&&p?.message&&(e.zoom>=Xr||y.agentId===C.selectedAgentId||y.agentId===C.hoveredAgentId)&&p?.message&&(L=m(L,x,T,d(y.agentId,p.message))+F-Dt*e.zoom),A?f(L,x,T,"bangRed"):w&&f(L,x,T,"bangYellow")},"drawWorking");return{update(y,p){let b=t.mentionCount>0;if(!b){const x=p.selectedAgentId;b=x!==null&&t.stickyErrors.has(x)}return b||o},draw(y,p,b){const x=Math.max(1,Math.round(p.zoom));(!e||s!==x)&&(e=Dr(x),s=x),e&&((!a||l!==x)&&(a=Tn(x,zr),l=x),i=y,n=p,r=b,o=!1,b.forEachPose(g),i=null,n=null)}}}u(qr,"createBubblesLayer");var Kr="#f3f4f6",Ur="rgba(12, 14, 20, 0.72)",Vr=3,Zr=2,Le=1,Qr=3,Jr=1,to=2,eo={running:"#4ade80",queued:"#facc15",idle:"#9ca3af",paused:"#60a5fa",error:"#f87171",pending_approval:"#c084fc",awaiting_board:"#facc15",budget_paused:"#60a5fa"},no={running:1,queued:2,idle:3,paused:4,error:5,pending_approval:6,awaiting_board:7,budget_paused:8};function so(){const t=[],e=[];let s=null,n=!0,i=0,r=null,o=0,a=!0,l=0,c=0,d=-1,m=null,f=null;const g=u(y=>{const p=s;if(!p)return;const b=p.visual(y.agentId);if(c=c*31+(y.x|0)|0,c=c*31+(y.y|0)|0,!b)return;c=c*31+no[b.status]|0;const x=b.shortName;for(let T=0;T<x.length;T+=1)c=c*31+x.charCodeAt(T)|0},"scan"),v=u(y=>{const p=s;if(!p)return;const b=p.visual(y.agentId);if(!b)return;const x=p.hoveredAgentId;if(!a&&!b.working&&y.agentId!==p.selectedAgentId&&y.agentId!==x)return;let T=t[l];T||(T={x:0,y:0,w:0,h:0,text:"",dot:"",anchorX:0,anchorY:0},t[l]=T),l+=1,T.text=b.shortName,T.dot=eo[b.status],T.w=9+te(b.shortName),T.h=7,T.anchorX=Math.round(y.x-T.w/2),T.anchorY=Math.round(y.y+Qr),T.x=T.anchorX,T.y=T.anchorY},"collect");return{update(y,p){s=p,c=0,p.forEachPose(g);const b=p.hoveredAgentId;return(c!==d||p.selectedAgentId!==m||b!==f)&&(n=!0),n},draw(y,p,b){s=b;const x=Math.max(1,Math.round(p.zoom)),T=x>=to;if(n||x!==i||T!==a){a=T,l=0,b.forEachPose(v),e.length=l;for(let w=0;w<l;w+=1)e[w]=t[w];jr(e,Jr),i=x,d=c,m=b.selectedAgentId,f=b.hoveredAgentId,n=!1}if(e.length===0)return;(!r||o!==x)&&(r=Tn(x,Kr),o=x);const A=Vr*x;for(let w=0;w<e.length;w+=1){const I=e[w],C=Math.round(p.offsetX+I.x*p.zoom),k=Math.round(p.offsetY+I.y*p.zoom),R=I.w*x,F=I.h*x;C+R<0||k+F<0||C>p.width||k>p.height||(y.fillStyle=Ur,y.fillRect(C,k,R,F),y.fillStyle=I.dot,y.fillRect(C+Zr*x,k+Le*x+x,A,A),r&&r.drawText(y,I.text,C+7*x,k+Le*x))}}}}u(so,"createLabelsLayer");var je=new WeakMap;function io(t){const e=je.get(t);if(e)return e;const s=new fr(t),n=[vr(),Fr(s),qr(s),so()];return je.set(t,n),n}u(io,"createOfficeOverlays");var ro=.035,oo=.4,ao=6,lo=.12,co={done:{frequency:660,endFrequency:990,duration:.22,type:"triangle"},ding:{frequency:880,endFrequency:880,duration:.14,type:"sine"},error:{frequency:220,endFrequency:130,duration:.35,type:"sawtooth"}},ht=!1,X=null,U=null,pt=null,V=null,Rt=0,Pe=!1;function _n(){if(!X||!V)return;const t=ht?ro*Math.min(1,Rt/ao):0;V.gain.setTargetAtTime(t,X.currentTime,oo)}u(_n,"applyTypingGain");function uo(){pt&&(pt.stop(),pt.disconnect(),pt=null),V?.disconnect(),V=null,U?.disconnect(),U=null,X&&(X.close(),X=null)}u(uo,"stopAudio");function fo(){typeof document>"u"||!X||(document.hidden?X.suspend():ht&&X.resume())}u(fo,"handleVisibility");function ho(t,e){const s=Math.floor(t.sampleRate*1.5),n=t.createBuffer(1,s,t.sampleRate),i=n.getChannelData(0);let r=0,o=0;for(let c=0;c<s;c+=1)c>=r&&(o=1,r=c+Math.floor(t.sampleRate*(.04+Math.random()*.14))),o*=.9965,i[c]=(Math.random()*2-1)*o*o;const a=t.createBufferSource();a.buffer=n,a.loop=!0;const l=t.createBiquadFilter();l.type="bandpass",l.frequency.value=2400,l.Q.value=.8,a.connect(l),l.connect(e),a.start(),pt=a}u(ho,"startTypingNoise");function ee(){if(!ht)return null;if(X)return X;if(typeof globalThis.AudioContext!="function")return null;const t=new globalThis.AudioContext;return X=t,U=t.createGain(),U.gain.value=1,U.connect(t.destination),V=t.createGain(),V.gain.value=0,V.connect(U),ho(t,V),_n(),!Pe&&typeof document<"u"&&(Pe=!0,document.addEventListener("visibilitychange",fo)),t}u(ee,"ensureContext");function Be(t){if(ht!==t){if(ht=t,!t){uo();return}Rt>0&&ee()}}u(Be,"setAmbientEnabled");function mo(t){Rt=Math.max(0,t),ht&&(Rt>0&&ee(),_n())}u(mo,"setTypingLevel");function go(t){const e=ee();if(!e||!U)return;e.state==="suspended"&&e.resume();const s=co[t],n=e.currentTime,i=e.createOscillator();i.type=s.type,i.frequency.setValueAtTime(s.frequency,n),i.frequency.linearRampToValueAtTime(s.endFrequency,n+s.duration);const r=e.createGain();r.gain.setValueAtTime(0,n),r.gain.linearRampToValueAtTime(lo,n+.01),r.gain.exponentialRampToValueAtTime(1e-4,n+s.duration),i.connect(r),r.connect(U),i.start(n),i.stop(n+s.duration+.02),i.onended=()=>{i.disconnect(),r.disconnect()}}u(go,"playEffectSound");var po=[[/web|http|fetch|browser|crawl|url|scrape|navigate/,"web"],[/comment|reply|message|chat|notify|email|slack|discord|ask_user|respond|mention|interaction/,"comment"],[/think|plan|reason|reflect|sequential|todo|goal/,"think"],[/write|edit|create|update|patch|insert|append|replace|delete|remove|rename|move|upload/,"write"],[/bash|shell|exec|run|command|terminal|test|build|install|deploy|git|docker|script|compile/,"run"],[/read|view|cat|open|glob|grep|search|find|list|ls|inspect|diff|show|get|fetch_file|notebook/,"read"]],wo={ls:"read",cd:"run",task:"think",agent:"think"};function vo(t){return(t.includes("__")?t.slice(t.lastIndexOf("__")+2):t).toLowerCase().replace(/[^a-z0-9]+/g,"_")}u(vo,"normalizeToolName");function ne(t){if(!t)return"think";const e=vo(t);if(!e)return"think";const s=wo[e];if(s)return s;for(const[n,i]of po)if(n.test(e))return i;return"other"}u(ne,"activityIconForTool");function kn(t,e){if(!t||!e)return!1;if(e.source==="local_implicit"||e.isInstanceAdmin)return!0;if(!e.memberships||e.memberships.length===0)return e.companyIds.includes(t);const s=e.memberships.find(n=>n.companyId===t&&n.status==="active");return s?s.membershipRole!=="viewer"&&s.membershipRole!==null:!1}u(kn,"canBoardAssignIssues");var it=Object.freeze({changed:!1,effects:Object.freeze([]),sounds:Object.freeze([]),refetch:!1,ticker:null}),xo={completed:!0,succeeded:!0,cancelled:!0,skipped:!0,done:!0},Rn={failed:!0,timed_out:!0};function yo(){return{agents:new Map,ticker:[],tickerSeq:0}}u(yo,"createLiveOfficeState");function Mn(t,e){return{agentId:t,name:e,status:"idle",activeRunId:null,queuedRunId:null,pendingInteractionCount:0,awaitingBoardCount:0,budgetPaused:!1,errorRunId:null,activityIcon:"other",activityMessage:null,activityAtMs:0}}u(Mn,"blankAgent");function G(t,e){let s=t.agents.get(e);return s||(s=Mn(e,e),t.agents.set(e,s)),s}u(G,"ensureAgent");function De(t,e){const s=new Set;for(const n of e.agents){s.add(n.id);const i=t.agents.get(n.id)??Mn(n.id,n.name);if(i.name=n.name,i.status=n.status,i.activeRunId=n.activeRunId,i.queuedRunId=n.queuedRunId,i.pendingInteractionCount=n.pendingInteractionCount,i.awaitingBoardCount=n.awaitingBoardCount,i.budgetPaused=n.budgetPaused,n.progress&&n.progress.runId===n.activeRunId){const r=Date.parse(n.progress.updatedAt);!Number.isNaN(r)&&r>=i.activityAtMs&&(i.activityIcon=ne(n.progress.toolName),i.activityMessage=Mt(n.progress.message),i.activityAtMs=r)}else n.activeRunId===null&&(i.activityMessage=null,i.activityAtMs=0,i.activityIcon="other");t.agents.set(n.id,i)}for(const n of[...t.agents.keys()])s.has(n)||t.agents.delete(n)}u(De,"seedFromSnapshot");function bo(t,e){for(const s of e){const n=t.agents.get(s.agentId);if(!n)continue;if(s.status==="queued"){n.queuedRunId=s.id;continue}n.activeRunId=s.id;const i=s.currentStatusUpdatedAt?Date.parse(s.currentStatusUpdatedAt):NaN,r=Mt(s.currentStatusMessage??s.lastAssistantSnippet??null);if(r===null)continue;const o=Number.isNaN(i)?0:i;o<n.activityAtMs||(n.activityIcon=ne(s.currentToolName??null),n.activityMessage=r,n.activityAtMs=o)}}u(bo,"seedFromLiveRuns");function Mt(t){if(typeof t!="string")return null;const e=t.trim();return e?e.length>180?`${e.slice(0,179)}…`:e:null}u(Mt,"clampMessage");function Io(t){const e=(t.trim().split(/\s+/)[0]??"")||t.trim();return e.length>10?e.slice(0,10):e}u(Io,"shortAgentName");function Ao(t){return t.errorRunId!==null||t.status==="error"?"error":t.awaitingBoardCount>0?"awaiting_board":t.pendingInteractionCount>0||t.status==="pending_approval"?"pending_approval":t.budgetPaused?"budget_paused":t.status==="paused"?"paused":t.activeRunId!==null||t.status==="running"?"running":t.queuedRunId!==null?"queued":"idle"}u(Ao,"visualStatus");function To(t){const e=[];for(const s of t.agents.values()){const n=Ao(s);e.push({agentId:s.agentId,shortName:Io(s.name),status:n,activity:s.activityMessage===null&&s.activityAtMs===0?null:{icon:s.activityIcon,message:s.activityMessage,updatedAtMs:s.activityAtMs},attention:n==="awaiting_board"||n==="pending_approval"||n==="error",working:s.activeRunId!==null||s.status==="running"})}return e.sort((s,n)=>s.agentId<n.agentId?-1:s.agentId>n.agentId?1:0),e}u(To,"deriveAgentVisuals");function Fn(t){let e="";for(const s of t)e+=`${s.agentId}|${s.shortName}|${s.status}|${s.attention?1:0}|${s.working?1:0}|${s.activity?`${s.activity.icon}:${s.activity.updatedAtMs}:${s.activity.message??""}`:""}
|
|
1
|
+
var zn=Object.defineProperty;var u=(t,e)=>zn(t,"name",{value:e,configurable:!0});import{i as Ke}from"./rolldown-runtime-ZpX3ckPj.js";import{O as Z,jt as Hn,na as Yn,t as Zt,ta as Xn}from"./createLucideIcon-B-uEJvX6.js";import{X as Ue,_ as Ve,g as Qt,r as Ot,t as N,v as D}from"./queryKeys-yuC-YxZI.js";import{tt as Gn}from"./mention-chips-DiRTrrHG.js";import{n as qn}from"./CompanyContext-DDgccGSs.js";import{W as Kn,t as Q,zt as Wt}from"./router-2HX_SyKK.js";import{t as Ze}from"./scroll-area-Drh0SHUe.js";import{t as Un}from"./coins-DOScIoKX.js";import{t as Vn}from"./external-link-CxXijrsp.js";import{t as Zn}from"./inbox-BqqJhYb6.js";import{r as Qn,t as z}from"./button-D3bYvq4T.js";import{t as Qe}from"./pause-Dt9kKzpY.js";import{t as zt}from"./play-BEx2fnvh.js";import{t as Jn}from"./radio-ljY5_vGs.js";import{t as ts}from"./x-hMw21ejo.js";import{r as es}from"./SidebarContext-CQAYTXv1.js";import{t as xt}from"./badge-Dz4tmpgp.js";import{a as ns}from"./ToastContext-BL2cptrZ.js";import{t as At}from"./agents-DjsXf9UL.js";import{t as Je}from"./heartbeats-xPg7ZEsm.js";import{t as tn}from"./access-RvWIoVKp.js";import{t as en}from"./routines-5Q3z9LWd.js";import{n as ss}from"./BreadcrumbContext-_dNLeVnD.js";import{t as is}from"./card-CtkberpO.js";import{Pa as re,Xa as rs,fa as nn,gt as os,no as as,ua as sn,v as ls}from"./index-CSIXA5y5.js";import{r as cs,s as us,t as fs}from"./sheet-_2ap0Qlb.js";import{t as ds}from"./AttentionInteractionResolver-K_Jeu6_2.js";import{t as hs}from"./pipelines-DRMWZLsA.js";import{t as ms}from"./budgets-Dh83JquC.js";var rn={name:"alarm-smoke",size:24,node:[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]};rn.node;var gs=Zt(rn),on={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};on.node;var ps=Zt(on),an={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};an.node;var ws=Zt(an),_=Ke(Yn(),1),Ht={snapshot:u(t=>Ot.get(`/companies/${t}/pixels-office`),"snapshot"),timeline:u((t,e)=>{const s=new URLSearchParams({from:e.from,to:e.to});return e.cursor&&s.set("cursor",e.cursor),Ot.get(`/companies/${t}/pixels-office/timeline?${s.toString()}`)},"timeline"),replaceSeats:u((t,e)=>Ot.put(`/companies/${t}/pixels-office/seats`,{assignments:e}),"replaceSeats")};var vs=.15,xs=.3,ln=.5,ys=.001,bs=.5,cn="#808080",Is="#FF00FF",As="#3A3A5C",Ts=.2,un=.6,oe=.1,Yt=new Map;function Jt(t,e,s){const n=Yt.get(t);if(n)return n;const i=s.colorize?Ss(e,s):mn(e,s);return Yt.set(t,i),i}u(Jt,"getColorizedSprite");function Cs(){Yt.clear()}u(Cs,"clearColorizeCache");function Ss(t,e){const{h:s,s:n,b:i,c:r}=e,o=[];for(const a of t){const l=[];for(const c of a){if(c===""){l.push("");continue}const d=parseInt(c.slice(1,3),16),m=parseInt(c.slice(3,5),16),f=parseInt(c.slice(5,7),16);let g=(.299*d+.587*m+.114*f)/255;if(r!==0){const p=(100+r)/100;g=.5+(g-.5)*p}i!==0&&(g=g+i/200),g=Math.max(0,Math.min(1,g));const v=fn(c),y=hn(s,n/100,g);l.push(dn(y,v))}o.push(l)}return o}u(Ss,"colorizeSprite");function fn(t){return t.length>7?parseInt(t.slice(7,9),16):255}u(fn,"extractAlpha");function dn(t,e){return e>=255?t:`${t}${e.toString(16).padStart(2,"0").toUpperCase()}`}u(dn,"appendAlpha");function hn(t,e,s){const n=(1-Math.abs(2*s-1))*e,i=t/60,r=n*(1-Math.abs(i%2-1));let o=0,a=0,l=0;i<1?(o=n,a=r,l=0):i<2?(o=r,a=n,l=0):i<3?(o=0,a=n,l=r):i<4?(o=0,a=r,l=n):i<5?(o=r,a=0,l=n):(o=n,a=0,l=r);const c=s-n/2,d=Math.round((o+c)*255),m=Math.round((a+c)*255),f=Math.round((l+c)*255);return`#${Nt(d).toString(16).padStart(2,"0")}${Nt(m).toString(16).padStart(2,"0")}${Nt(f).toString(16).padStart(2,"0")}`.toUpperCase()}u(hn,"hslToHex");function Nt(t){return Math.max(0,Math.min(255,t))}u(Nt,"clamp255");function _s(t,e,s){const n=t/255,i=e/255,r=s/255,o=Math.max(n,i,r),a=Math.min(n,i,r),l=(o+a)/2;if(o===a)return[0,0,l];const c=o-a,d=l>.5?c/(2-o-a):c/(o+a);let m=0;return o===n?m=((i-r)/c+(i<r?6:0))*60:o===i?m=((r-n)/c+2)*60:m=((n-i)/c+4)*60,[m,d,l]}u(_s,"rgbToHsl");function mn(t,e){const{h:s,s:n,b:i,c:r}=e,o=[];for(const a of t){const l=[];for(const c of a){if(c===""){l.push("");continue}const d=parseInt(c.slice(1,3),16),m=parseInt(c.slice(3,5),16),f=parseInt(c.slice(5,7),16),g=fn(c),[v,y,p]=_s(d,m,f),b=((v+s)%360+360)%360,x=Math.max(0,Math.min(1,y+n/100));let T=p;if(r!==0){const w=(100+r)/100;T=.5+(T-.5)*w}i!==0&&(T=T+i/200),T=Math.max(0,Math.min(1,T));const A=hn(b,x,T);l.push(dn(A,g))}o.push(l)}return o}u(mn,"adjustSprite");var ks=Array.from({length:16},()=>Array(16).fill(cn)),_t=[];function Rs(t){_t=t,Cs()}u(Rs,"setFloorSprites");function Ms(t){const e=t-1;return e<0?null:e<_t.length?_t[e]:_t.length===0&&t>=1?ks:null}u(Ms,"getFloorSprite");function Fs(){return!0}u(Fs,"hasFloorSprites");function Es(t,e){const s=`floor-${t}-${e.h}-${e.s}-${e.b}-${e.c}`,n=Ms(t);return n?Jt(s,n,{...e,colorize:!0}):Array.from({length:16},()=>Array(16).fill(Is))}u(Es,"getColorizedFloorSprite");var $={WALL:0,FLOOR_1:1,FLOOR_2:2,FLOOR_3:3,FLOOR_4:4,FLOOR_5:5,FLOOR_6:6,FLOOR_7:7,FLOOR_8:8,FLOOR_9:9,VOID:255},E={IDLE:"idle",WALK:"walk",TYPE:"type"},S={DOWN:0,LEFT:1,RIGHT:2,UP:3},K=new Map,rt=new Map,Xt=new Map,ae=new Map,kt=new Map,Gt=null,gn=null;function Os(t){if(!t?.catalog||!t?.sprites)return!1;const e=t.catalog.map(f=>{const g=t.sprites[f.id];return g?{type:f.id,label:f.label,footprintW:f.footprintW,footprintH:f.footprintH,sprite:g,isDesk:f.isDesk,category:f.category,...f.orientation?{orientation:f.orientation}:{},...f.canPlaceOnSurfaces?{canPlaceOnSurfaces:!0}:{},...f.backgroundTiles?{backgroundTiles:f.backgroundTiles}:{},...f.canPlaceOnWalls?{canPlaceOnWalls:!0}:{},...f.mirrorSide?{mirrorSide:!0}:{}}:null}).filter(f=>f!==null);for(const f of t.catalog)if(f.mirrorSide&&f.orientation==="side"){const g=e.find(v=>v.type===f.id);g&&e.push({...g,type:`${f.id}:left`,orientation:"left",mirrorSide:!0})}if(e.length===0)return!1;K.clear(),rt.clear(),Xt.clear(),ae.clear(),kt.clear();const s=new Map;for(const f of t.catalog)if(f.groupId&&f.orientation){if(f.state&&f.state!=="off")continue;let g=s.get(f.groupId);g||(g=new Map,s.set(f.groupId,g)),f.orientation==="side"?(g.set("right",f.id),f.mirrorSide&&g.set("left",`${f.id}:left`)):g.set(f.orientation,f.id)}const n=new Map;for(const f of t.catalog)f.groupId&&f.rotationScheme&&n.set(f.groupId,f.rotationScheme);const i=new Set,r=["front","right","back","left"];for(const[f,g]of s){if(g.size<2)continue;const v=n.get(f);let y=r;v==="2-way"&&(y=["front","right"]);const p=y.filter(A=>g.has(A));if(p.length<2)continue;const b={};for(const A of p)b[A]=g.get(A);const x={orientations:p,members:b},T=new Set;for(const A of Object.values(b))T.has(A)||(K.set(A,x),T.add(A));for(const[A,w]of Object.entries(b))A!=="front"&&i.add(w)}const o=new Map;for(const f of t.catalog)if(f.groupId&&f.state){const g=`${f.groupId}|${f.orientation||""}`;let v=o.get(g);if(v||(v=new Map,o.set(g,v)),f.animationGroup&&f.frame!==void 0&&f.frame>0)continue;v.set(f.state,f.id)}for(const f of o.values()){const g=f.get("on"),v=f.get("off");g&&v&&(rt.set(g,v),rt.set(v,g),Xt.set(v,g),ae.set(g,v))}for(const f of t.catalog)if(f.groupId&&f.orientation&&f.state==="on"){if(f.animationGroup&&f.frame!==void 0&&f.frame>0)continue;const g=rt.get(f.id);if(g){const v=K.get(g);if(v){const y={};for(const b of v.orientations){const x=v.members[b];y[b]=rt.get(x)??x}const p={orientations:v.orientations,members:y};for(const b of Object.values(y))K.has(b)||K.set(b,p)}}}const a=new Map;for(const f of t.catalog)if(f.animationGroup&&f.frame!==void 0){let g=a.get(f.animationGroup);g||(g=[],a.set(f.animationGroup,g)),g.push({id:f.id,frame:f.frame})}for(const[f,g]of a)g.sort((v,y)=>v.frame-y.frame),kt.set(f,g.map(v=>v.id));const l=new Set;for(const f of t.catalog)f.state==="on"&&l.add(f.id);Gt=e;const c=e.filter(f=>!i.has(f.type)&&!l.has(f.type));for(const f of c)(K.has(f.type)||rt.has(f.type))&&(f.label=f.label.replace(/ - Front - Off$/,"").replace(/ - Front$/,"").replace(/ - Off$/,""));gn=c;const d=new Set(Array.from(K.values())).size,m=kt.size;return!0}u(Os,"buildDynamicCatalog");function Y(t){return Gt?Gt.find(e=>e.type===t):gn?.find(e=>e.type===t)}u(Y,"getCatalogEntry");function Ns(t){return Xt.get(t)??t}u(Ns,"getOnStateType");function Ls(t){for(const[,e]of kt)if(e.includes(t))return e;return null}u(Ls,"getAnimationFrames");function js(t){const e=K.get(t);if(e){for(const[s,n]of Object.entries(e.members))if(n===t)return s}}u(js,"getOrientationInGroup");function Ps(t){const e=[];for(let s=0;s<t.rows;s++){const n=[];for(let i=0;i<t.cols;i++)n.push(t.tiles[s*t.cols+i]);e.push(n)}return e}u(Ps,"layoutToTileMap");function Bs(t){const e=new Map;for(const n of t){const i=Y(n.type);if(!i||!i.isDesk)continue;const r=n.row*16+i.sprite.length;for(let o=0;o<i.footprintH;o++)for(let a=0;a<i.footprintW;a++){const l=`${n.col+a},${n.row+o}`,c=e.get(l);(c===void 0||r>c)&&e.set(l,r)}}const s=[];for(let n=0;n<t.length;n++){const i=t[n],r=Y(i.type);if(!r)continue;const o=i.col*16,a=i.row*16;let l=a+r.sprite.length;if(r.category==="chairs"&&(r.orientation==="back"?l=(i.row+r.footprintH)*16+1:l=(i.row+1)*16),r.canPlaceOnSurfaces)for(let m=0;m<r.footprintH;m++)for(let f=0;f<r.footprintW;f++){const g=e.get(`${i.col+f},${i.row+m}`);g!==void 0&&g+.5>l&&(l=g+.5)}let c=r.sprite;if(i.color){const{h:m,s:f,b:g,c:v}=i.color;c=Jt(`furn-${i.type}-${m}-${f}-${g}-${v}-${i.color.colorize?1:0}`,r.sprite,i.color)}let d=!1;r.mirrorSide&&js(i.type)==="left"&&(d=!0),s.push({sprite:c,x:o,y:a,zY:l,sourceIndex:n,...d?{mirrored:!0}:{}})}return s}u(Bs,"layoutToFurnitureInstances");function Ds(t,e){const s=new Set;for(const n of t){const i=Y(n.type);if(!i)continue;const r=i.backgroundTiles||0;for(let o=0;o<i.footprintH;o++)if(!(o<r))for(let a=0;a<i.footprintW;a++){const l=`${n.col+a},${n.row+o}`;e&&e.has(l)||s.add(l)}}return s}u(Ds,"getBlockedTiles");function $s(t){switch(t){case"front":return S.DOWN;case"back":return S.UP;case"left":return S.LEFT;case"right":case"side":return S.RIGHT;default:return S.DOWN}}u($s,"orientationToFacing");function qt(t){const e=new Map,s=new Set;for(const i of t){const r=Y(i.type);if(!(!r||!r.isDesk))for(let o=0;o<r.footprintH;o++)for(let a=0;a<r.footprintW;a++)s.add(`${i.col+a},${i.row+o}`)}const n=[{dc:0,dr:-1,facing:S.UP},{dc:0,dr:1,facing:S.DOWN},{dc:-1,dr:0,facing:S.LEFT},{dc:1,dr:0,facing:S.RIGHT}];for(const i of t){const r=Y(i.type);if(!r||r.category!=="chairs")continue;let o=0;const a=r.backgroundTiles??0;for(let l=a;l<r.footprintH;l++)for(let c=0;c<r.footprintW;c++){const d=i.col+c,m=i.row+l;let f=S.DOWN;if(r.orientation)f=$s(r.orientation);else for(const v of n)if(s.has(`${d+v.dc},${m+v.dr}`)){f=v.facing;break}const g=o===0?i.uid:`${i.uid}:${o}`;e.set(g,{uid:g,seatCol:d,seatRow:m,facingDir:f,assigned:!1}),o++}}return e}u(qt,"layoutToSeats");var Ws={h:35,s:30,b:15,c:0},zs={h:25,s:45,b:5,c:10};function Hs(){const t=$.WALL,e=$.FLOOR_1,s=$.FLOOR_2,n=[],i=[];for(let r=0;r<11;r++)for(let o=0;o<20;o++)r===0||r===10||o===0||o===19?(n.push(t),i.push(null)):o<10?(n.push(e),i.push(Ws)):(n.push(s),i.push(zs));return{version:1,cols:20,rows:11,tiles:n,tileColors:i,furniture:[]}}u(Hs,"createDefaultLayout");var Ys="bubble-permission",Xs="Permission bubble: white square with '...' in amber, and a tail pointer (11x13)";var Gs={_:"",B:"#555566",F:"#EEEEFF",A:"#CCA700"},qs=[["B","B","B","B","B","B","B","B","B","B","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","A","F","A","F","A","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","B","B","B","B","B","B","B","B","B","B"],["_","_","_","_","B","B","B","_","_","_","_"],["_","_","_","_","_","B","_","_","_","_","_"],["_","_","_","_","_","_","_","_","_","_","_"]],Ks={name:Ys,description:Xs,width:11,height:13,palette:Gs,pixels:qs},Us="bubble-waiting",Vs="Waiting bubble: white square with green checkmark, and a tail pointer (11x13)";var Zs={_:"",B:"#555566",F:"#EEEEFF",G:"#44BB66"},Qs=[["_","B","B","B","B","B","B","B","B","B","_"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","G","F","B"],["B","F","F","F","F","F","F","G","F","F","B"],["B","F","F","G","F","F","G","F","F","F","B"],["B","F","F","F","G","G","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["B","F","F","F","F","F","F","F","F","F","B"],["_","B","B","B","B","B","B","B","B","B","_"],["_","_","_","_","B","B","B","_","_","_","_"],["_","_","_","_","_","B","_","_","_","_","_"],["_","_","_","_","_","_","_","_","_","_","_"]],Js={name:Us,description:Vs,width:11,height:13,palette:Zs,pixels:Qs};function pn(t){return t.pixels.map(e=>e.map(s=>t.palette[s]??s))}u(pn,"resolveBubbleSprite");var za=pn(Ks),Ha=pn(Js),ft=null;function ti(t){ft=t,Kt.clear()}u(ti,"setCharacterTemplates");function ei(){return ft?ft.length:6}u(ei,"getLoadedCharacterCount");function ni(t){return t.map(e=>[...e].reverse())}u(ni,"flipSpriteHorizontal");var Kt=new Map;function si(t,e){const s={h:e,s:0,b:0,c:0},n=u(o=>mn(o,s),"shift"),i=u(o=>[n(o[0]),n(o[1]),n(o[2]),n(o[3])],"shiftWalk"),r=u(o=>[n(o[0]),n(o[1])],"shiftPair");return{walk:{[S.DOWN]:i(t.walk[S.DOWN]),[S.UP]:i(t.walk[S.UP]),[S.RIGHT]:i(t.walk[S.RIGHT]),[S.LEFT]:i(t.walk[S.LEFT])},typing:{[S.DOWN]:r(t.typing[S.DOWN]),[S.UP]:r(t.typing[S.UP]),[S.RIGHT]:r(t.typing[S.RIGHT]),[S.LEFT]:r(t.typing[S.LEFT])},reading:{[S.DOWN]:r(t.reading[S.DOWN]),[S.UP]:r(t.reading[S.UP]),[S.RIGHT]:r(t.reading[S.RIGHT]),[S.LEFT]:r(t.reading[S.LEFT])}}}u(si,"hueShiftSprites");function ii(t,e){const s=[];for(let n=0;n<e;n++)s.push(new Array(t).fill(""));return s}u(ii,"emptySprite");function ri(t,e=0){const s=`${t}:${e}`,n=Kt.get(s);if(n)return n;let i;if(ft){const r=ft[t%ft.length],o=r.down,a=r.up,l=r.right,c=ni;i={walk:{[S.DOWN]:[o[0],o[1],o[2],o[1]],[S.UP]:[a[0],a[1],a[2],a[1]],[S.RIGHT]:[l[0],l[1],l[2],l[1]],[S.LEFT]:[c(l[0]),c(l[1]),c(l[2]),c(l[1])]},typing:{[S.DOWN]:[o[3],o[4]],[S.UP]:[a[3],a[4]],[S.RIGHT]:[l[3],l[4]],[S.LEFT]:[c(l[3]),c(l[4])]},reading:{[S.DOWN]:[o[5],o[6]],[S.UP]:[a[5],a[6]],[S.RIGHT]:[l[5],l[6]],[S.LEFT]:[c(l[5]),c(l[6])]}}}else{const r=ii(16,32),o=[r,r,r,r],a=[r,r];i={walk:{[S.DOWN]:o,[S.UP]:o,[S.RIGHT]:o,[S.LEFT]:o},typing:{[S.DOWN]:a,[S.UP]:a,[S.RIGHT]:a,[S.LEFT]:a},reading:{[S.DOWN]:a,[S.UP]:a,[S.RIGHT]:a,[S.LEFT]:a}}}return e!==0&&(i=si(i,e)),Kt.set(s,i),i}u(ri,"getCharacterSprites");var q=[];function oi(t){q=t}u(oi,"setWallSprites");function ai(){return q.length>0}u(ai,"hasWallSprites");function wn(t,e,s){const n=s.length,i=n>0?s[0].length:0;let r=0;return e>0&&s[e-1][t]===$.WALL&&(r|=1),t<i-1&&s[e][t+1]===$.WALL&&(r|=2),e<n-1&&s[e+1][t]===$.WALL&&(r|=4),t>0&&s[e][t-1]===$.WALL&&(r|=8),r}u(wn,"buildWallMask");function li(t,e,s,n=0){if(q.length===0)return null;const i=(q[n]??q[0])[wn(t,e,s)];return i?{sprite:i,offsetY:16-i.length}:null}u(li,"getWallSprite");function ci(t,e,s,n,i=0){if(q.length===0)return null;const r=q[i]??q[0],o=wn(t,e,s),a=r[o];if(!a)return null;const l=`wall-${i}-${o}-${n.h}-${n.s}-${n.b}-${n.c}`;return{sprite:Jt(l,a,{...n,colorize:!0}),offsetY:16-a.length}}u(ci,"getColorizedWallSprite");function ui(t,e,s){if(q.length===0)return[];const n=t.length,i=n>0?t[0].length:0,r=s??i,o=[];for(let a=0;a<n;a++)for(let l=0;l<i;l++){if(t[a][l]!==$.WALL)continue;const c=a*r+l,d=e?.[c],m=d?ci(l,a,t,d):li(l,a,t);m&&o.push({sprite:m.sprite,x:l*16,y:a*16+m.offsetY,zY:(a+1)*16})}return o}u(ui,"getWallInstances");function fi(t){const{h:e,s,b:n,c:i}=t;let r=.5;if(i!==0){const y=(100+i)/100;r=.5+(r-.5)*y}n!==0&&(r=r+n/200),r=Math.max(0,Math.min(1,r));const o=s/100,a=(1-Math.abs(2*r-1))*o,l=e/60,c=a*(1-Math.abs(l%2-1));let d=0,m=0,f=0;l<1?(d=a,m=c,f=0):l<2?(d=c,m=a,f=0):l<3?(d=0,m=a,f=c):l<4?(d=0,m=c,f=a):l<5?(d=c,m=0,f=a):(d=a,m=0,f=c);const g=r-a/2,v=u(y=>Math.max(0,Math.min(255,Math.round((y+g)*255))),"clamp");return`#${v(d).toString(16).padStart(2,"0")}${v(m).toString(16).padStart(2,"0")}${v(f).toString(16).padStart(2,"0")}`}u(fi,"wallColorToHex");var ot=16,Tt=32,Lt=7,le=16,ce=16,ue=32,fe=4,di=16,st="/pixels/",jt=null;function de(t){const e=[];for(let d=0;d<t.rows;d++)for(let m=0;m<t.cols;m++)t.tiles[d*t.cols+m]!==255&&e.push({col:m,row:d});if(e.length===0)return t;const s=Math.max(0,Math.min(...e.map(d=>d.col))-1),n=Math.min(t.cols-1,Math.max(...e.map(d=>d.col))+1),i=Math.max(0,Math.min(...e.map(d=>d.row))-1),r=Math.min(t.rows-1,Math.max(...e.map(d=>d.row))+1),o=n-s+1,a=r-i+1,l=[],c=t.tileColors?[]:void 0;for(let d=i;d<=r;d++)for(let m=s;m<=n;m++){const f=d*t.cols+m;l.push(t.tiles[f]),c?.push(t.tileColors?.[f]??null)}return{...t,cols:o,rows:a,tiles:l,tileColors:c,furniture:t.furniture.map(d=>({...d,col:d.col-s,row:d.row-i}))}}u(de,"trimLayoutToVisibleRoom");function hi(t,e,s){return{...t,tileColors:t.tiles.map(n=>n===0?s:n===255?null:e),furniture:t.furniture.map(n=>["DESK_FRONT","TABLE_FRONT","SMALL_TABLE_FRONT","SMALL_TABLE_SIDE","COFFEE_TABLE"].includes(n.type)?{...n,color:{h:150,s:18,b:-10,c:-20}}:n)}}u(hi,"recolorLayout");var he=5,me=[{floor:{h:145,s:16,b:-8,c:-35},wall:{h:270,s:18,b:-20,c:-45}},{floor:{h:60,s:20,b:-6,c:-30},wall:{h:310,s:22,b:-24,c:-40}},{floor:{h:200,s:18,b:-10,c:-32},wall:{h:20,s:20,b:-22,c:-42}},{floor:{h:95,s:22,b:-12,c:-28},wall:{h:240,s:16,b:-18,c:-48}}];function mi(t){const e=new Set;for(const l of t.furniture){const c=Y(l.type);if(c)for(let d=0;d<c.footprintH;d++)for(let m=0;m<c.footprintW;m++)e.add(`${l.col+m},${l.row+d}`)}const s=u((l,c)=>t.tiles[c*t.cols+l],"tileAt");let n=-1;for(let l=0;l<t.rows-1&&n<0;l++)for(let c=0;c<t.cols;c++){const d=s(c,l+1);if(s(c,l)===0&&d!==0&&d!==255){n=l;break}}const i=[];function r(l,c,d,m,f){for(let g=0;g<f;g++)for(let v=0;v<m;v++)e.add(`${c+v},${d+g}`);i.push({uid:`anchor-${l}`,type:l,col:c,row:d})}u(r,"claim");function o(l,c){const d=Y(l);if(n<1||!d)return!1;const m=d.footprintW,f=Array.from({length:t.cols-m+1},(g,v)=>v);c&&f.reverse();for(const g of f){let v=!0;for(let y=0;y<m&&v;y++)s(g+y,n)!==0&&(v=!1),e.has(`${g+y},${n}`)&&(v=!1),e.has(`${g+y},${n-1}`)&&(v=!1);if(v)return r(l,g,n-1,m,2),!0}return!1}u(o,"placeOnWall");function a(l,c){const d=Y(l);if(!d)return!1;const m=d.footprintW,f=d.footprintH;for(let g=t.rows-f;g>n;g--){const v=Array.from({length:t.cols-m+1},(y,p)=>p);c&&v.reverse();for(const y of v){let p=!0;for(let b=0;b<f&&p;b++)for(let x=0;x<m&&p;x++){const T=s(y+x,g+b);(T===0||T===255)&&(p=!1),e.has(`${y+x},${g+b}`)&&(p=!1)}if(p)return r(l,y,g,m,f),!0}}return!1}return u(a,"placeOnFloor"),o("KANBAN_BOARD",!1)||a("KANBAN_BOARD",!1),o("ALARM_LIGHT",!0)||a("ALARM_LIGHT",!0),a("MAILBOX",!1)||o("MAILBOX",!1),a("COIN_STACK",!0)||o("COIN_STACK",!0),i}u(mi,"placeAnchorFurniture");function gi(t,e){const s=qt(t.furniture).size,n=qt(e.furniture).size,i=50-s-n,r=s>0&&i>0?Math.ceil(i/s):1,o=[t,e];for(let A=0;A<r;A++){const w=me[A%me.length];o.push(hi(t,w.floor,w.wall))}const a=Math.max(0,Math.floor((t.rows-e.rows)/2)),l=o.map((A,w)=>({layout:A,offsetCol:0,offsetRow:w===1?a:0}));let c=0;for(const A of l)A.offsetCol=c,c+=A.layout.cols+he;c-=he;const d=Math.max(...l.map(A=>A.offsetRow+A.layout.rows)),m=Array(c*d).fill(255),f=Array(c*d).fill(null),g={h:214,s:30,b:-100,c:-55},v={h:32,s:20,b:-6,c:-42},y=9;for(const{layout:A,offsetCol:w,offsetRow:I}of l)for(let C=0;C<A.rows;C++)for(let k=0;k<A.cols;k++){const R=C*A.cols+k,F=(C+I)*c+k+w;m[F]=A.tiles[R],f[F]=A.tileColors?.[R]??null}const p=Math.floor(d/2),b={col:t.cols-1,row:p};for(let A=1;A<l.length;A++){const w=l[A-1],I=w.offsetCol+w.layout.cols-2,C=l[A].offsetCol+1;for(let k=p-1;k<=p+1;k++)for(let R=I;R<=C;R++){const F=k*c+R;m[F]=y,f[F]=v}for(let k=p-2;k<=p+2;k++){for(const R of[I+1,I+2,C-1,C]){const F=k*c+R;m[F]=y,f[F]=v}for(const R of[I-1,C+1]){const F=k*c+R;m[F]===255&&(m[F]=0,f[F]=g)}}}f[b.row*c+b.col]={h:32,s:20,b:-14,c:-42};const x=l.flatMap(({layout:A,offsetCol:w,offsetRow:I},C)=>A.furniture.map(k=>({...k,uid:`camera${C+1}-${k.uid}`,col:k.col+w,row:k.row+I})));x.push(...mi(t));const T=l.map(({layout:A,offsetCol:w,offsetRow:I})=>{let C=A.rows,k=-1,R=A.cols,F=-1;for(let j=0;j<A.rows;j++)for(let P=0;P<A.cols;P++)A.tiles[j*A.cols+P]!==255&&(j<C&&(C=j),j>k&&(k=j),P<R&&(R=P),P>F&&(F=P));if(k<0)return{col:w,row:I,cols:A.cols,rows:A.rows};const L=C>0?1:0;return{col:w+R,row:I+C-L,cols:F-R+1,rows:k-C+1+L}});return{layout:{version:1,cols:c,rows:d,layoutRevision:1,tiles:m,tileColors:f,spawnTile:b,furniture:x},cameraBounds:{office:T[0],boardroomKitchen:T[1],overflowOffice:T[2],rooms:T}}}u(gi,"combineLayouts");function pi(t,e,s,n){return n<2?"":`#${t.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n===255?"":n.toString(16).padStart(2,"0")}`}u(pi,"rgbaToHex");function wi(t,e,s){const n=(s*t.width+e)*4;return pi(t.data[n],t.data[n+1],t.data[n+2],t.data[n+3])}u(wi,"pixelAt");function dt(t,e,s,n=0,i=0){return Array.from({length:s},(r,o)=>Array.from({length:e},(a,l)=>wi(t,n+l,i+o)))}u(dt,"readSprite");async function Ft(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}`);const s=await createImageBitmap(await e.blob()),n=document.createElement("canvas");n.width=s.width,n.height=s.height;const i=n.getContext("2d");if(!i)throw new Error("Could not decode PNG");i.drawImage(s,0,0),s.close();const r=i.getImageData(0,0,n.width,n.height);return{width:n.width,height:n.height,data:r.data}}u(Ft,"decodePng");async function vi(t){return Promise.all(t.characters.map(async e=>{const s=await Ft(`${st}${e}`);return{down:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,0)),up:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,Tt)),right:Array.from({length:Lt},(n,i)=>dt(s,ot,Tt,i*ot,64))}}))}u(vi,"decodeCharacters");async function xi(t){return Promise.all(t.floors.map(async e=>dt(await Ft(`${st}${e}`),le,le)))}u(xi,"decodeFloors");async function yi(t){return Promise.all(t.walls.map(async e=>{const s=await Ft(`${st}${e}`);return Array.from({length:di},(n,i)=>dt(s,ce,ue,i%fe*ce,Math.floor(i/fe)*ue))}))}u(yi,"decodeWalls");async function bi(t){const e=await Promise.all(t.furniture.map(async s=>{const n=await Ft(`${st}${s.furniturePath}`);return[s.id,dt(n,s.width,s.height)]}));return Object.fromEntries(e)}u(bi,"decodeFurniture");async function Pt(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch ${t}`);return await e.json()}u(Pt,"fetchJson");function Ii(){return jt??=(async()=>{const t=await Pt(`${st}pixels-office-assets.json`),e=t.layouts??{office:t.defaultLayout,boardroomKitchen:t.defaultLayout},[s,n,i,r,o,a]=await Promise.all([vi(t),xi(t),yi(t),bi(t),Pt(`${st}${e.office}`).then(de),Pt(`${st}${e.boardroomKitchen}`).then(de)]);ti(s),Rs(n),oi(i),Os({catalog:t.furniture,sprites:r});const l=gi(o,a);return{layouts:{office:o,boardroomKitchen:a,combined:l.layout},cameraBounds:l.cameraBounds}})().catch(t=>{throw jt=null,t}),jt}u(Ii,"loadPixelAssets");var ge={kanban:"KANBAN_BOARD",mailbox:"MAILBOX",clock:"CLOCK",coins:"COIN_STACK",alarm:"ALARM_LIGHT"},Ai=6,pe=.4,we=1.18;function ve(t,e,s,n){return e*2>=n-s?Math.min(s+e,Math.max(n-e,t)):Math.min(n-e,Math.max(s+e,t))}u(ve,"clampAxis");var Ti=class{static{u(this,"Camera")}worldWidth;worldHeight;worldTop;centerX=0;centerY=0;zoom=1;followAgentId=null;viewportWidth=1;viewportHeight=1;dpr=1;offsetX=0;offsetY=0;targetX=0;targetY=0;tweening=!1;constructor(t,e,s=0){this.worldWidth=t,this.worldHeight=e,this.worldTop=s,this.centerX=t/2,this.centerY=(s+e)/2,this.targetX=this.centerX,this.targetY=this.centerY,this.recompute()}get minZoom(){return Math.max(1,Math.ceil(this.dpr))}get maxZoom(){return Math.max(this.minZoom,Math.round(Ai*this.dpr))}setViewport(t,e,s){this.viewportWidth=Math.max(1,t),this.viewportHeight=Math.max(1,e),this.dpr=s>0?s:1,this.setZoom(this.zoom)}setZoom(t){this.zoom=Math.min(this.maxZoom,Math.max(this.minZoom,Math.round(t))),this.recompute()}fitRoom(t){const e=t.cols*16,s=t.rows*16;let n=Math.max(1,Math.floor(Math.min(this.viewportWidth/e,this.viewportHeight/s)));for(;e*(n+1)<=this.viewportWidth*we&&s*(n+1)<=this.viewportHeight*we;)n+=1;this.zoom=Math.min(this.maxZoom,Math.max(this.minZoom,n)),this.centerX=(t.col+t.cols/2)*16,this.centerY=(t.row+t.rows/2)*16,this.targetX=this.centerX,this.targetY=this.centerY,this.tweening=!1,this.recompute()}panBy(t,e){this.followAgentId=null,this.tweening=!1,this.centerX-=t*this.dpr/this.zoom,this.centerY-=e*this.dpr/this.zoom,this.targetX=this.centerX,this.targetY=this.centerY,this.recompute()}zoomAt(t,e,s){if(s===0)return;const n=t*this.dpr,i=e*this.dpr,r=(n-this.offsetX)/this.zoom,o=(i-this.offsetY)/this.zoom,a=Math.min(this.maxZoom,Math.max(this.minZoom,this.zoom+Math.trunc(s)));a!==this.zoom&&(this.zoom=a,this.centerX=r-(n-this.viewportWidth/2)/a,this.centerY=o-(i-this.viewportHeight/2)/a,this.targetX=this.centerX,this.targetY=this.centerY,this.tweening=!1,this.recompute())}centerOn(t,e){this.targetX=t,this.targetY=e,this.tweening=!0}jumpTo(t,e){this.centerX=t,this.centerY=e,this.targetX=t,this.targetY=e,this.tweening=!1,this.recompute()}follow(t){this.followAgentId=t,t===null&&(this.tweening=!1)}update(t,e,s){if(this.followAgentId!==null&&e!==null&&s!==null&&(this.targetX=e,this.targetY=s,this.tweening=!0),!this.tweening)return!1;const n=1-Math.exp(-9*t);this.centerX+=(this.targetX-this.centerX)*n,this.centerY+=(this.targetY-this.centerY)*n;const i=Math.abs(this.targetX-this.centerX)<pe&&Math.abs(this.targetY-this.centerY)<pe;return i&&(this.centerX=this.targetX,this.centerY=this.targetY,this.tweening=this.followAgentId!==null),this.recompute(),!i}recompute(){const t=this.viewportWidth/(2*this.zoom),e=this.viewportHeight/(2*this.zoom);this.centerX=ve(this.centerX,t,0,this.worldWidth),this.centerY=ve(this.centerY,e,this.worldTop,this.worldHeight),this.offsetX=Math.round(this.viewportWidth/2-this.centerX*this.zoom),this.offsetY=Math.round(this.viewportHeight/2-this.centerY*this.zoom)}},vn=Number.POSITIVE_INFINITY,Ci=class{static{u(this,"GameLoop")}options;rafHandle=0;cancelSleep=null;lastTime=0;lastRender=0;plannedSleepSec=0;running=!1;interval;raf;cancelRaf;now;isHidden;frame=u(t=>{if(this.rafHandle=0,!this.running||this.isHidden())return;if(this.lastRender!==0&&t-this.lastRender<this.interval){this.scheduleFrame();return}const e=this.lastTime===0?0:(t-this.lastTime)/1e3,s=Math.max(oe,this.plannedSleepSec+oe);this.lastTime=t,this.lastRender=t,this.plannedSleepSec=0;const n=this.options.step(Math.min(e,s));if(this.options.render(),n<=0){this.scheduleFrame();return}if(n===vn)return;this.plannedSleepSec=n;const i=setTimeout(()=>{this.cancelSleep=null,this.wake()},n*1e3);this.cancelSleep=()=>{clearTimeout(i)}},"frame");constructor(t){this.options=t,this.interval=1e3/(t.fps??30)-1,this.raf=t.raf??(e=>requestAnimationFrame(e)),this.cancelRaf=t.cancelRaf??(e=>cancelAnimationFrame(e)),this.now=t.now??(()=>performance.now()),this.isHidden=t.isHidden??(()=>typeof document<"u"&&document.hidden)}get scheduled(){return this.rafHandle!==0||this.cancelSleep!==null}start(){this.running||(this.running=!0,this.lastTime=0,this.lastRender=0,this.scheduleFrame())}stop(){this.running=!1,this.rafHandle!==0&&(this.cancelRaf(this.rafHandle),this.rafHandle=0),this.cancelSleep?.(),this.cancelSleep=null}wake(){!this.running||this.isHidden()||(this.cancelSleep?.(),this.cancelSleep=null,this.rafHandle===0&&(this.lastRender=0,this.lastTime===0&&(this.lastTime=this.now()),this.scheduleFrame()))}scheduleFrame(){this.rafHandle===0&&(this.rafHandle=this.raf(this.frame))}},xe=16,Si=32;function _i(t,e,s,n){let i=null,r=Number.NEGATIVE_INFINITY;for(const o of s){const a=o.state===E.TYPE?6:0,l=o.x-xe/2,c=o.y+a;if(t<l||t>l+xe||e>c||e<c-Si)continue;const d=o.y+16/2+ln;d<=r||(r=d,i=o.id)}if(i!==null)return{kind:"agent",agentId:i};for(const o of n)if(!(t<o.x||t>o.x+o.width)&&!(e<o.y||e>o.y+o.height))return{kind:"object",object:o.kind};return null}u(_i,"hitTestWorld");var ki="#f5f5f5",Ri="#4ade80",Mi="rgba(255, 255, 255, 0.85)",Fi="rgba(12, 12, 16, 0.9)",Ei=class{static{u(this,"Minimap")}cache=null;cacheSource=null;cacheWidth=0;cacheHeight=0;draw(t,e,s,n,i,r){if(t.clearRect(0,0,e,s),t.fillStyle=Fi,t.fillRect(0,0,e,s),!n||n.width===0||n.height===0)return;const o=Math.min(e/n.width,s/n.height),a=Math.max(1,Math.floor(n.width*o)),l=Math.max(1,Math.floor(n.height*o)),c=Math.floor((e-a)/2),d=Math.floor((s-l)/2);if(!this.cache||this.cacheSource!==n.canvas||this.cacheWidth!==a||this.cacheHeight!==l){const p=this.cache??document.createElement("canvas");p.width=a,p.height=l;const b=p.getContext("2d");b.clearRect(0,0,a,l),b.imageSmoothingEnabled=!0,b.drawImage(n.canvas,0,0,a,l),this.cache=p,this.cacheSource=n.canvas,this.cacheWidth=a,this.cacheHeight=l}t.drawImage(this.cache,c,d);const m=Math.max(1,Math.round(o*6));for(const p of i.characters.values())t.fillStyle=p.isActive&&!p.still?Ri:ki,t.fillRect(c+Math.round(p.x*o)-(m>>1),d+Math.round((p.y-n.originY)*o)-(m>>1),m,m);const f=-r.offsetX/r.zoom,g=-r.offsetY/r.zoom-n.originY,v=r.width/r.zoom,y=r.height/r.zoom;t.strokeStyle=Mi,t.lineWidth=1,t.strokeRect(c+Math.round(f*o)+.5,d+Math.round(g*o)+.5,Math.max(2,Math.round(v*o)),Math.max(2,Math.round(y*o)))}},Oi=4096,Ni=class{static{u(this,"NavGrid")}cols;rows;walkableTiles=[];open;visitedStamp;parent;queue;cache=new Map;stamp=0;constructor(t,e){this.rows=t.length,this.cols=this.rows>0?t[0].length:0;const s=this.cols*this.rows;this.open=new Uint8Array(s),this.visitedStamp=new Int32Array(s),this.parent=new Int32Array(s),this.queue=new Int32Array(s);for(let n=0;n<this.rows;n++){const i=t[n];for(let r=0;r<this.cols;r++){const o=i[r];o===$.WALL||o===$.VOID||e.has(`${r},${n}`)||(this.open[n*this.cols+r]=1,this.walkableTiles.push({col:r,row:n}))}}}inBounds(t,e){return t>=0&&t<this.cols&&e>=0&&e<this.rows}isWalkable(t,e){return this.inBounds(t,e)?this.open[e*this.cols+t]===1:!1}setWalkable(t,e,s){if(!this.inBounds(t,e))return;const n=e*this.cols+t,i=s?1:0;this.open[n]!==i&&(this.open[n]=i,this.cache.clear())}findPath(t,e,s,n,i=!1,r=null){if(!this.inBounds(t,e)||!this.inBounds(s,n))return[];const o=e*this.cols+t,a=n*this.cols+s;if(o===a)return[];if(this.open[a]!==1&&!i)return[];const l=(o*this.open.length+a)*2+(i?1:0);if(r===null){const f=this.cache.get(l);if(f)return this.materialise(f)}if(!this.search(o,a,r))return[];let c=0;for(let f=a;f!==o;f=this.parent[f])c++;const d=new Int32Array(c);let m=c-1;for(let f=a;f!==o;f=this.parent[f])d[m]=f,m--;return r===null&&(this.cache.size>=Oi&&this.cache.clear(),this.cache.set(l,d)),this.materialise(d)}nearestOpen(t,e,s){if(!this.inBounds(t,e))return null;this.stamp++;const{open:n,visitedStamp:i,queue:r,cols:o}=this,a=n.length,l=e*o+t;i[l]=this.stamp,r[0]=l;let c=0,d=1;for(;c<d;){const m=r[c];c++;const f=m%o,g=(m-f)/o;if(n[m]===1&&s(f,g))return{col:f,row:g};for(let v=0;v<4;v++){let y;if(v===0){if(y=m-o,y<0)continue}else if(v===1){if(y=m+o,y>=a)continue}else if(v===2){if(f===0)continue;y=m-1}else{if(f===o-1)continue;y=m+1}i[y]!==this.stamp&&n[y]===1&&(i[y]=this.stamp,r[d]=y,d++)}}return null}search(t,e,s){this.stamp++;const{open:n,visitedStamp:i,parent:r,queue:o,cols:a}=this,l=n.length;i[t]=this.stamp,o[0]=t;let c=0,d=1;for(;c<d;){const m=o[c];if(c++,m===e)return!0;const f=m%a;for(let g=0;g<4;g++){let v;if(g===0){if(v=m-a,v<0)continue}else if(g===1){if(v=m+a,v>=l)continue}else if(g===2){if(f===0)continue;v=m-1}else{if(f===a-1)continue;v=m+1}if(i[v]!==this.stamp&&!(n[v]!==1&&v!==e)&&!(s!==null&&s[v]===1&&v!==e)){if(i[v]=this.stamp,r[v]=m,v===e)return!0;o[d]=v,d++}}}return!1}materialise(t){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]={col:t[s]%this.cols,row:t[s]/this.cols|0};return e}},Li={Read:!0,Grep:!0,Glob:!0,WebFetch:!0,WebSearch:!0};function ji(t){return t!==null&&Li[t]===!0}u(ji,"isReadingTool");function Pi(t,e,s,n){const i=s-t,r=n-e;return i>0?S.RIGHT:i<0?S.LEFT:r>0?S.DOWN:S.UP}u(Pi,"directionBetween");function Bi(t,e,s,n,i=0){const r=n?n.seatCol:1,o=n?n.seatRow:1;return{id:t,state:E.TYPE,dir:n?n.facingDir:S.DOWN,x:r*16+16/2,y:o*16+16/2,tileCol:r,tileRow:o,path:[],moveProgress:0,blockedTimer:0,currentTool:null,palette:e,hueShift:i,frame:0,frameTimer:0,wanderTimer:0,wanderCount:0,wanderLimit:Ut(3,6),isActive:!0,still:!1,pinned:!1,hop:0,seatId:s,bubbleType:null,bubbleTimer:0,seatTimer:0,inputTokens:0,outputTokens:0}}u(Bi,"createCharacter");function Di(t){return t.state===E.WALK?!0:t.state===E.TYPE?!t.still:!1}u(Di,"isCharacterAnimating");function $i(t,e,s,n,i){switch(t.frameTimer+=e,t.state){case E.TYPE:if(t.still?(t.frame=0,t.frameTimer=0):t.frameTimer>=.3&&(t.frameTimer-=xs,t.frame=(t.frame+1)%2),!t.isActive&&!t.pinned){if(t.seatTimer>0){t.seatTimer-=e;break}t.seatTimer=0,t.state=E.IDLE,t.frame=0,t.frameTimer=0,t.wanderTimer=Ct(2,20),t.wanderCount=0,t.wanderLimit=Ut(3,6)}break;case E.IDLE:if(t.frame=0,t.seatTimer<0&&(t.seatTimer=0),t.pinned)break;if(t.isActive){const r=t.seatId?n.get(t.seatId):void 0;if(!r){t.state=E.TYPE,t.frame=0,t.frameTimer=0;break}const o=s.findPath(t.tileCol,t.tileRow,r.seatCol,r.seatRow,!0);o.length>0?(t.path=o,t.moveProgress=0,t.state=E.WALK):(t.state=E.TYPE,t.dir=r.facingDir),t.frame=0,t.frameTimer=0;break}if(t.wanderTimer-=e,t.wanderTimer<=0){t.wanderCount>=t.wanderLimit&&(t.wanderCount=0,t.wanderLimit=Ut(3,6));const r=s.walkableTiles;let o=null;for(let a=0;a<8&&r.length>0;a++){const l=r[Math.floor(Math.random()*r.length)];if(i.isFreeFor(t.id,l.col,l.row)){o=l;break}}if(o){const a=s.findPath(t.tileCol,t.tileRow,o.col,o.row);a.length>0&&(t.path=a,t.moveProgress=0,t.state=E.WALK,t.frame=0,t.frameTimer=0,t.wanderCount++)}t.wanderTimer=Ct(2,20)}break;case E.WALK:{if(t.frameTimer>=.15&&(t.frameTimer-=vs,t.frame=(t.frame+1)%4),t.path.length===0){t.x=t.tileCol*16+16/2,t.y=t.tileRow*16+16/2;const m=t.seatId?n.get(t.seatId):void 0;m&&t.tileCol===m.seatCol&&t.tileRow===m.seatRow&&m?(t.state=E.TYPE,t.dir=m.facingDir):t.isActive&&!t.pinned&&!m?t.state=E.TYPE:t.isActive&&!t.pinned?t.state=E.IDLE:(t.state=E.IDLE,t.wanderTimer=Ct(2,20)),t.frame=0,t.frameTimer=0;break}const r=t.path[0];if(t.dir=Pi(t.tileCol,t.tileRow,r.col,r.row),t.moveProgress===0&&!i.claim(t.id,r.col,r.row)){if(t.blockedTimer+=e,t.frame=1,t.blockedTimer<.6)break;const m=t.path[t.path.length-1],f=t.seatId?n.get(t.seatId):void 0,g=f!==void 0&&f.seatCol===m.col&&f.seatRow===m.row,v=i.isFreeFor(t.id,m.col,m.row)?s.findPath(t.tileCol,t.tileRow,m.col,m.row,g,i.blockedFor(t.id)):[];v.length>0?(t.path=v,t.blockedTimer=0):t.blockedTimer>=3&&(t.path=[],t.blockedTimer=0,t.state=E.IDLE,t.wanderTimer=Ct(.5,2),t.frame=0,t.frameTimer=0);break}t.blockedTimer=0,t.moveProgress+=48/16*e;const o=t.tileCol*16+16/2,a=t.tileRow*16+16/2,l=r.col*16+16/2,c=r.row*16+16/2,d=Math.min(t.moveProgress,1);t.x=o+(l-o)*d,t.y=a+(c-a)*d,t.moveProgress>=1&&(i.release(t.id,t.tileCol,t.tileRow),t.tileCol=r.col,t.tileRow=r.row,t.x=l,t.y=c,t.path.shift(),t.moveProgress=0);break}}}u($i,"updateCharacter");function Wi(t,e){switch(t.state){case E.TYPE:return ji(t.currentTool)?e.reading[t.dir][t.frame%2]:e.typing[t.dir][t.frame%2];case E.WALK:return e.walk[t.dir][t.frame%4];default:return e.walk[t.dir][1]}}u(Wi,"getCharacterSprite");function Ct(t,e){return t+Math.random()*(e-t)}u(Ct,"randomRange");function Ut(t,e){return t+Math.floor(Math.random()*(e-t+1))}u(Ut,"randomInt");var zi=2,at=new Map,ye=new WeakMap;function Hi(t){const e=ye.get(t);if(e)return e;const s=t.length,n=t[0].length,i=[];for(let r=0;r<s+2;r++)i.push(new Array(n+2).fill(""));for(let r=0;r<s;r++)for(let o=0;o<n;o++){if(t[r][o]==="")continue;const a=r+1,l=o+1;i[a-1][l]===""&&(i[a-1][l]="#FFFFFF"),i[a+1][l]===""&&(i[a+1][l]="#FFFFFF"),i[a][l-1]===""&&(i[a][l-1]="#FFFFFF"),i[a][l+1]===""&&(i[a][l+1]="#FFFFFF")}for(let r=0;r<s;r++)for(let o=0;o<n;o++)t[r][o]!==""&&(i[r+1][o+1]="");return ye.set(t,i),i}u(Hi,"getOutlineSprite");function wt(t,e){let s=at.get(e);for(s?at.delete(e):s=new WeakMap,at.set(e,s);at.size>zi;){const l=at.keys().next();if(l.done)break;at.delete(l.value)}const n=s.get(t);if(n)return n;const i=t.length,r=t[0].length,o=document.createElement("canvas");o.width=r*e,o.height=i*e;const a=o.getContext("2d");a.imageSmoothingEnabled=!1;for(let l=0;l<i;l++)for(let c=0;c<r;c++){const d=t[l][c];d!==""&&(a.fillStyle=d,a.fillRect(c*e,l*e,e,e))}return s.set(t,o),o}u(wt,"getCachedSprite");var be=16,Yi=32;function Xi(t,e,s){const n=new Set;for(const r of s)n.add(r.seatRow*e.cols+r.seatCol);const i=new Uint8Array(t.length);for(let r=0;r<t.length;r++){const o=t[r],a=o.x,l=o.x+o.sprite[0].length,c=o.y,d=o.y+o.sprite.length,m=Math.max(0,Math.floor(a/16)-1),f=Math.min(e.cols-1,Math.ceil(l/16)),g=Math.max(0,Math.floor(c/16)-1),v=Math.min(e.rows-1,Math.ceil(d/16)+2);for(let y=g;y<=v&&i[r]===0;y++)for(let p=m;p<=f;p++){if(!e.isWalkable(p,y)&&!n.has(y*e.cols+p)||y*16+16/2+.5>=o.zY)continue;const b=p*16+16/2-be/2,x=y*16+16/2+6,T=x-Yi;if(!(b>=l||b+be<=a)&&!(T>=d||x<=c)){i[r]=1;break}}}return qi(t,i),i}u(Xi,"classifyOccluders");function Gi(t,e){return t.x<e.x+e.sprite[0].length&&e.x<t.x+t.sprite[0].length&&t.y<e.y+e.sprite.length&&e.y<t.y+t.sprite.length}u(Gi,"spriteOverlaps");function qi(t,e){const s=[];for(let n=0;n<t.length;n++)e[n]===1&&s.push(n);for(let n=0;n<s.length;n++){const i=t[s[n]];for(let r=0;r<t.length;r++){if(e[r]===1)continue;const o=t[r];o.zY<=i.zY||!Gi(o,i)||(e[r]=1,s.push(r))}}}u(qi,"liftStackedItems");function Vt(t){let e=0;for(const s of t)s.y<e&&(e=Math.floor(s.y));return e}u(Vt,"drawablesTop");function Ki(t,e,s){const n=Vt(s),i=t.cols*16,r=t.rows*16-n,o=document.createElement("canvas");o.width=i,o.height=r;const a=o.getContext("2d");a.imageSmoothingEnabled=!1,a.translate(0,-n),Ui(a,e,t.tileColors,t.cols);const l=s.map((c,d)=>d);l.sort((c,d)=>s[c].zY-s[d].zY);for(const c of l){const d=s[c],m=wt(d.sprite,1);d.mirrored?(a.save(),a.translate(d.x+m.width,d.y),a.scale(-1,1),a.drawImage(m,0,0),a.restore()):a.drawImage(m,d.x,d.y)}return{canvas:o,width:i,height:r,originY:n}}u(Ki,"buildStaticLayer");function Ui(t,e,s,n){const i=Fs();for(let r=0;r<e.length;r++){const o=e[r];for(let a=0;a<o.length;a++){const l=o[a];if(l===$.VOID)continue;const c=r*n+a;if(l===$.WALL||!i){if(l===$.WALL){const m=s?.[c];t.fillStyle=m?fi(m):As}else t.fillStyle=cn;t.fillRect(a*16,r*16,16,16);continue}const d=s?.[c]??{h:0,s:0,b:0,c:0};t.drawImage(wt(Es(l,d),1),a*16,r*16)}}}u(Ui,"drawTiles");var Vi=class{static{u(this,"TileClaims")}cols;owners=new Map;mask;constructor(t,e){this.cols=t,this.mask=new Uint8Array(t*e)}isFreeFor(t,e,s){const n=this.owners.get(s*this.cols+e);return n===void 0||n===t}claim(t,e,s){const n=s*this.cols+e,i=this.owners.get(n);return i!==void 0&&i!==t?!1:(this.owners.set(n,t),!0)}release(t,e,s){const n=s*this.cols+e;this.owners.get(n)===t&&this.owners.delete(n)}releaseAll(t){for(const[e,s]of this.owners)s===t&&this.owners.delete(e)}blockedFor(t){this.mask.fill(0);for(const[e,s]of this.owners)s!==t&&(this.mask[e]=1);return this.mask}},Zi=class{static{u(this,"OfficeState")}layout;tileMap;seats;blockedTiles;nav;claims;staticFurniture=[];dynamicFurniture=[];switchable=[];characters=new Map;furnitureAnimTimer=0;selectedAgentId=null;hoveredAgentId=null;autoOnTiles=new Set;constructor(t){this.layout=t||Hs(),this.tileMap=Ps(this.layout),this.seats=qt(this.layout.furniture),this.blockedTiles=Ds(this.layout.furniture),this.nav=new Ni(this.tileMap,this.blockedTiles),this.claims=new Vi(this.nav.cols,this.nav.rows),this.buildFurniture()}getLayout(){return this.layout}buildFurniture(){const t=this.layout.furniture,e=[],s=[];for(const c of t){const d=Ns(c.type);if(d===c.type){s.push(null);continue}const m=Ls(d)??[d],f=e.length;for(const g of m)e.push({...c,uid:`${c.uid}:on:${g}`,type:g});s.push({start:f,count:m.length})}const n=Bs([...t,...e]),i=new Array(t.length).fill(null),r=new Array(e.length).fill(null);for(const c of n){const d=c.sourceIndex??0;d<t.length?i[d]=c:r[d-t.length]=c}const o=[];this.switchable=[];for(let c=0;c<t.length;c++){const d=i[c];if(!d)continue;const m=s[c];if(!m){o.push(d);continue}const f=[];for(let g=0;g<m.count;g++){const v=r[m.start+g];v&&f.push(v)}this.switchable.push({off:d,on:f.length>0?f:[d],tiles:this.footprintTiles(t[c])})}const a=ai()?ui(this.tileMap,this.layout.tileColors,this.layout.cols):[];a.length>0&&o.push(...a);const l=Xi(o,this.nav,this.seats.values());this.staticFurniture=[],this.dynamicFurniture=[];for(let c=0;c<o.length;c++)l[c]===1?this.dynamicFurniture.push(o[c]):this.staticFurniture.push(o[c])}footprintTiles(t){const e=Y(t.type),s=[];if(!e)return s;for(let n=0;n<e.footprintH;n++)for(let i=0;i<e.footprintW;i++)s.push((t.row+n)*this.layout.cols+t.col+i);return s}getSpawnTile(){const t=this.layout.spawnTile;return t&&this.nav.isWalkable(t.col,t.row)?t:this.nav.walkableTiles[0]??{col:1,row:1}}findFreeSeat(){const t=new Set;for(const n of this.layout.furniture){const i=Y(n.type);if(!(!i||i.category!=="electronics"))for(let r=0;r<i.footprintH;r++)for(let o=0;o<i.footprintW;o++)t.add(`${n.col+o},${n.row+r}`)}const e=[],s=[];for(const[n,i]of this.seats){if(i.assigned)continue;let r=!1;const o=i.facingDir===S.RIGHT?1:i.facingDir===S.LEFT?-1:0,a=i.facingDir===S.DOWN?1:i.facingDir===S.UP?-1:0;for(let l=1;l<=3&&!r;l++){const c=i.seatCol+o*l,d=i.seatRow+a*l;if(t.has(`${c},${d}`)){r=!0;break}if(o!==0){if(t.has(`${c},${d-1}`)||t.has(`${c},${d+1}`)){r=!0;break}}else if(t.has(`${c-1},${d}`)||t.has(`${c+1},${d}`)){r=!0;break}}(r?e:s).push(n)}return e.length>0?e[Math.floor(Math.random()*e.length)]:s.length>0?s[Math.floor(Math.random()*s.length)]:null}pickDiversePalette(){const t=ei(),e=new Array(t).fill(0);for(const o of this.characters.values())o.palette<t&&e[o.palette]++;const s=Math.min(...e),n=[];for(let o=0;o<t;o++)e[o]===s&&n.push(o);const i=n[Math.floor(Math.random()*n.length)];let r=0;return s>0&&(r=45+Math.floor(Math.random()*271)),{palette:i,hueShift:r}}addAgent(t,e={}){if(this.characters.has(t))return;const s=e.pose;let n,i;if(s)n=s.palette,i=s.hueShift;else if(e.palette!==void 0)n=e.palette,i=e.hueShift??0;else{const d=this.pickDiversePalette();n=d.palette,i=d.hueShift}const r=s?.seatId??e.seatId;let o=null;if(r){const d=this.seats.get(r);d&&!d.assigned&&(o=r)}const a=o!==null;o||(o=this.findFreeSeat());const l=o?this.seats.get(o):null;l&&(l.assigned=!0);const c=Bi(t,n,o,l,i);if(s)c.tileCol=s.tileCol,c.tileRow=s.tileRow,c.x=s.x,c.y=s.y,c.dir=s.dir,c.state=s.state===E.WALK?E.IDLE:s.state,s.state===E.WALK&&this.snapToTile(c,c.tileCol,c.tileRow);else if(!a){const d=this.getSpawnTile();this.snapToTile(c,d.col,d.row),c.state=E.IDLE,c.dir=S.DOWN,c.wanderTimer=Math.random()*3}if(!this.claims.claim(t,c.tileCol,c.tileRow)){const d=this.nav.nearestOpen(c.tileCol,c.tileRow,(m,f)=>this.claims.isFreeFor(t,m,f));d&&(this.snapToTile(c,d.col,d.row),c.state===E.TYPE&&(c.state=E.IDLE),this.claims.claim(t,d.col,d.row))}this.characters.set(t,c)}removeAgent(t){const e=this.characters.get(t);if(e){if(e.seatId){const s=this.seats.get(e.seatId);s&&(s.assigned=!1)}this.selectedAgentId===t&&(this.selectedAgentId=null),this.hoveredAgentId===t&&(this.hoveredAgentId=null),this.claims.releaseAll(t),this.characters.delete(t),this.rebuildAutoOnTiles()}}walkToTile(t,e,s){const n=this.characters.get(t);if(!n)return!1;const i=n.seatId?this.seats.get(n.seatId):void 0,r=i?i.seatCol===e&&i.seatRow===s:!1;if(!this.nav.isWalkable(e,s)&&!r)return!1;let o={col:e,row:s};if(!this.claims.isFreeFor(t,e,s)){const l=this.nav.nearestOpen(e,s,(c,d)=>this.claims.isFreeFor(t,c,d));if(!l)return!1;o=l}const a=this.nav.findPath(n.tileCol,n.tileRow,o.col,o.row,r);return a.length===0?!1:(this.settleClaims(n),n.path=a,n.moveProgress=0,n.state=E.WALK,n.frame=0,n.frameTimer=0,!0)}setAgentActive(t,e){const s=this.characters.get(t);!s||s.isActive===e||(s.isActive=e,e||(s.seatTimer=-1,this.settleClaims(s),s.path=[],s.moveProgress=0),this.rebuildAutoOnTiles())}setAgentStill(t,e){const s=this.characters.get(t);!s||s.still===e||(s.still=e,this.rebuildAutoOnTiles())}snapToTile(t,e,s){t.tileCol=e,t.tileRow=s,t.x=e*16+16/2,t.y=s*16+16/2}settleClaims(t){if(t.moveProgress>0&&t.path.length>0){const e=t.path[0];this.claims.release(t.id,t.tileCol,t.tileRow),this.snapToTile(t,e.col,e.row)}this.claims.releaseAll(t.id),this.claims.claim(t.id,t.tileCol,t.tileRow)}setAgentPinned(t,e){const s=this.characters.get(t);s&&(s.pinned=e)}rebuildAutoOnTiles(){this.autoOnTiles.clear();const t=this.layout.cols;for(const e of this.characters.values()){if(!e.isActive||e.still||!e.seatId)continue;const s=this.seats.get(e.seatId);if(!s)continue;const n=s.facingDir===S.RIGHT?1:s.facingDir===S.LEFT?-1:0,i=s.facingDir===S.DOWN?1:s.facingDir===S.UP?-1:0;for(let r=1;r<=3;r++)this.autoOnTiles.add((s.seatRow+i*r)*t+s.seatCol+n*r);for(let r=1;r<=2;r++){const o=s.seatCol+n*r,a=s.seatRow+i*r;n!==0?(this.autoOnTiles.add((a-1)*t+o),this.autoOnTiles.add((a+1)*t+o)):(this.autoOnTiles.add(a*t+o-1),this.autoOnTiles.add(a*t+o+1))}}}resolveSwitchable(t){const e=this.switchable[t];let s=!1;for(const i of e.tiles)if(this.autoOnTiles.has(i)){s=!0;break}if(!s)return e.off;const n=Math.floor(this.furnitureAnimTimer/Ts);return e.on[n%e.on.length]}isSwitchableAnimating(){return this.autoOnTiles.size>0}setAgentTool(t,e){const s=this.characters.get(t);s&&(s.currentTool=e)}showWaitingBubble(t){const e=this.characters.get(t);e&&(e.bubbleType="waiting",e.bubbleTimer=2)}startHop(t){const e=this.characters.get(t);e&&(e.hop=un)}update(t){this.furnitureAnimTimer+=t;let e=this.isSwitchableAnimating();for(const s of this.characters.values())$i(s,t,this.nav,this.seats,this.claims),Di(s)&&(e=!0),s.hop>0&&(s.hop=Math.max(0,s.hop-t),e=!0),s.bubbleType==="waiting"&&(s.bubbleTimer-=t,e=!0,s.bubbleTimer<=0&&(s.bubbleType=null,s.bubbleTimer=0));return e}nextWakeSeconds(){let t=Number.POSITIVE_INFINITY;for(const e of this.characters.values())e.pinned||(e.state===E.IDLE&&!e.isActive?t=Math.min(t,Math.max(0,e.wanderTimer)):e.state===E.TYPE&&!e.isActive&&(t=Math.min(t,Math.max(0,e.seatTimer))));return t}},xn="pixels-office:v2:",Qi=2e3;function yn(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}u(yn,"storage");function Ji(t){const e=Object.values(E).find(n=>n===t.s),s=Object.values(S).find(n=>n===t.d);return!e||s===void 0||!Number.isFinite(t.x)||!Number.isFinite(t.y)?null:{tileCol:t.c,tileRow:t.r,x:t.x,y:t.y,dir:s,state:e,palette:t.p,hueShift:t.h,seatId:t.seat}}u(Ji,"toRestoredPose");function tr(t){const e=new Map,s=yn();if(!s)return e;const n=s.getItem(xn+t);if(!n)return e;let i;try{i=JSON.parse(n)}catch{return e}if(i?.v!==2||typeof i.poses!="object")return e;for(const[r,o]of Object.entries(i.poses)){const a=Ji(o);a&&e.set(r,a)}return e}u(tr,"loadStoredPoses");function Ie(t,e){const s=yn();if(!s)return;const n={};for(const r of e)n[r.id]={c:r.tileCol,r:r.tileRow,x:r.x,y:r.y,d:r.dir,s:r.state,p:r.palette,h:r.hueShift,seat:r.seatId};const i={v:2,poses:n};try{s.setItem(xn+t,JSON.stringify(i))}catch{return}}u(Ie,"storePoses");var er=class{static{u(this,"PoseFlusher")}companyId;collect;cancelTimer=null;onPageHide=u(()=>{this.flushNow()},"onPageHide");constructor(t,e){this.companyId=t,this.collect=e,typeof window<"u"&&window.addEventListener("pagehide",this.onPageHide)}schedule(){if(this.cancelTimer!==null)return;const t=setTimeout(()=>{this.cancelTimer=null,Ie(this.companyId,this.collect())},Qi);this.cancelTimer=()=>{clearTimeout(t)}}flushNow(){this.cancelTimer?.(),this.cancelTimer=null,Ie(this.companyId,this.collect())}dispose(){this.cancelTimer?.(),this.cancelTimer=null,typeof window<"u"&&window.removeEventListener("pagehide",this.onPageHide)}},nr=class{static{u(this,"SceneRenderer")}capacity=0;sprites=[];drawX=new Float64Array(0);drawY=new Float64Array(0);depth=new Float64Array(0);alpha=new Float64Array(0);mirrored=new Uint8Array(0);order=new Int32Array(0);buckets=new Int32Array(0);count=0;render(t,e,s,n){t.clearRect(0,0,n.width,n.height),s&&sr(t,s,n),this.count=0;for(const i of e.dynamicFurniture)this.pushInstance(i,n);for(let i=0;i<e.switchable.length;i++)this.pushInstance(e.resolveSwitchable(i),n);for(const i of e.characters.values()){const r=Wi(i,ri(i.palette,i.hueShift)),o=wt(r,n.zoom),a=i.state===E.TYPE?6:0,l=i.hop>0?Math.sin((1-i.hop/un)*Math.PI)*7:0,c=Math.round(n.offsetX+i.x*n.zoom-o.width/2),d=Math.round(n.offsetY+(i.y+a-l)*n.zoom-o.height);if(c>n.width||c+o.width<0||d>n.height||d+o.height<0)continue;const m=i.y+16/2+ln,f=e.selectedAgentId===i.id,g=e.hoveredAgentId===i.id;if(f||g){const v=wt(Hi(r),n.zoom);this.push(v,c-n.zoom,d-n.zoom,m-ys,f?1:bs,!1)}this.push(o,c,d,m,1,!1)}this.sortByDepth();for(let i=0;i<this.count;i++){const r=this.order[i],o=this.sprites[r],a=this.alpha[r],l=a<1;l&&(t.save(),t.globalAlpha=a),this.mirrored[r]===1?(t.save(),t.translate(this.drawX[r]+o.width,this.drawY[r]),t.scale(-1,1),t.drawImage(o,0,0),t.restore()):t.drawImage(o,this.drawX[r],this.drawY[r]),l&&t.restore()}}sortByDepth(){const t=this.count;let e=0;for(let n=0;n<t;n++){const i=this.depth[n]|0;i>e&&(e=i)}this.buckets.length<e+2&&(this.buckets=new Int32Array(e+128)),this.order.length<t&&(this.order=new Int32Array(this.capacity));const s=this.buckets;s.fill(0,0,e+2);for(let n=0;n<t;n++)s[(this.depth[n]|0)+1]++;for(let n=1;n<=e+1;n++)s[n]+=s[n-1];for(let n=0;n<t;n++){const i=this.depth[n]|0;this.order[s[i]]=n,s[i]++}}pushInstance(t,e){const s=wt(t.sprite,e.zoom),n=e.offsetX+t.x*e.zoom,i=e.offsetY+t.y*e.zoom;n>e.width||n+s.width<0||i>e.height||i+s.height<0||this.push(s,n,i,t.zY,1,t.mirrored===!0)}push(t,e,s,n,i,r){this.count===this.capacity&&this.grow(),this.sprites[this.count]=t,this.drawX[this.count]=e,this.drawY[this.count]=s,this.depth[this.count]=n,this.alpha[this.count]=i,this.mirrored[this.count]=r?1:0,this.count++}grow(){const t=this.capacity===0?256:this.capacity*2,e=new Float64Array(t),s=new Float64Array(t),n=new Float64Array(t),i=new Float64Array(t),r=new Uint8Array(t);e.set(this.drawX),s.set(this.drawY),n.set(this.depth),i.set(this.alpha),r.set(this.mirrored),this.drawX=e,this.drawY=s,this.depth=n,this.alpha=i,this.mirrored=r,this.sprites.length=t,this.capacity=t}};function sr(t,e,s){const n=s.offsetY+e.originY*s.zoom,i=Math.max(0,Math.floor(-s.offsetX/s.zoom)),r=Math.max(0,Math.floor(-n/s.zoom)),o=Math.min(e.width,Math.ceil((s.width-s.offsetX)/s.zoom)),a=Math.min(e.height,Math.ceil((s.height-n)/s.zoom)),l=o-i,c=a-r;l<=0||c<=0||t.drawImage(e.canvas,i,r,l,c,s.offsetX+i*s.zoom,n+r*s.zoom,l*s.zoom,c*s.zoom)}u(sr,"blitStaticLayer");var ir=3,rr=25,or=class{static{u(this,"OfficeControllerImpl")}companyId;worldWidth;worldHeight;state;cameraState;renderer=new nr;minimap=new Ei;loop;flusher;visuals=new Map;listeners=new Set;visits=new Map;objectBoxes=[];anchors=new Map;officeRoom;view={zoom:1,offsetX:0,offsetY:0,width:0,height:0,nowMs:0};renderedFrames=0;get frameCount(){return this.renderedFrames}poseScratch={agentId:"",x:0,y:0,moving:!1,seated:!1};onVisibilityChange=u(()=>{typeof document<"u"&&!document.hidden&&this.loop.wake()},"onVisibilityChange");overlays=[];canvas=null;ctx=null;resizeObserver=null;staticLayer=null;syncKey="";fitted=!1;rooms;constructor(t,e,s){this.companyId=t,this.state=new Zi(e),this.worldWidth=e.cols*16,this.worldHeight=e.rows*16,this.officeRoom=s.office,this.rooms=s.rooms.map((n,i)=>({id:i===0?"office":i===1?"boardroom":`overflow-${i-1}`,label:i===0?"Office":i===1?"Boardroom & Kitchen":`Overflow ${i-1}`,centerX:(n.col+n.cols/2)*16,centerY:(n.row+n.rows/2)*16})),this.cameraState=new Ti(this.worldWidth,this.worldHeight,Math.min(Vt(this.state.staticFurniture),Vt(this.state.dynamicFurniture))),this.collectObjects(e),this.flusher=new er(t,()=>this.state.characters.values()),this.loop=new Ci({step:u(n=>this.step(n),"step"),render:u(()=>this.render(),"render")})}collectObjects(t){const e=Object.keys(ge);for(const s of e){const n=ge[s],i=t.furniture.find(d=>d.type===n);if(!i)continue;const r=Y(n);if(!r)continue;const o=i.col*16,a=i.row*16,l=r.footprintW*16,c=r.sprite.length;this.objectBoxes.push({kind:s,x:o,y:a,width:l,height:c}),this.anchors.set(s,{x:o+l/2,y:a})}}syncAgents(t,e){let s="";for(const o of t)s+=`${o.agentId}:${o.status}:${o.working?1:0}:${o.activity?.icon??"-"};`;for(const o of e)s+=`${o.agentId}@${o.seatId};`;if(s===this.syncKey){let o=!1;for(const a of t)this.visuals.get(a.agentId)!==a&&(this.visuals.set(a.agentId,a),o=!0);o&&this.loop.wake();return}this.syncKey=s;const n=new Map;for(const o of e)n.set(o.agentId,o);const i=this.visuals.size===0?tr(this.companyId):null,r=new Set;for(const o of t){if(r.add(o.agentId),this.visuals.set(o.agentId,o),!this.state.characters.has(o.agentId)){const a=n.get(o.agentId);this.state.addAgent(o.agentId,{palette:a?.characterIndex,seatId:a?.seatId,pose:i?.get(o.agentId)})}this.applyStatus(o)}for(const o of Array.from(this.state.characters.keys()))r.has(o)||(this.state.removeAgent(o),this.visuals.delete(o),this.visits.delete(o));this.loop.wake()}applyStatus(t){const e=t.status,s=e==="idle"&&!t.working,n=!t.working&&(e==="paused"||e==="budget_paused"||e==="error");this.state.setAgentActive(t.agentId,!s),this.state.setAgentStill(t.agentId,n);const i=t.activity?.icon==="read"&&!s&&!n;this.state.setAgentTool(t.agentId,i?"Read":null)}readPlacements(){const t=[];for(const[e,s]of this.state.characters)s.seatId&&t.push({agentId:e,characterIndex:s.palette,seatId:s.seatId});return t}visual(t){return this.visuals.get(t)}forEachPose(t){for(const e of this.state.characters.values())this.fillPose(this.poseScratch,e),t(this.poseScratch)}pose(t){const e=this.state.characters.get(t);if(e)return{agentId:e.id,x:e.x,y:e.y,moving:e.state===E.WALK,seated:e.state===E.TYPE}}fillPose(t,e){t.agentId=e.id,t.x=e.x,t.y=e.y,t.moving=e.state===E.WALK,t.seated=e.state===E.TYPE}objectAnchor(t){return this.anchors.get(t)}emit(t){if(t.kind==="celebrate")if(t.big)for(const e of this.state.characters.keys())this.state.startHop(e);else this.state.startHop(t.agentId);else t.kind==="visit"&&this.startVisit(t.fromAgentId,t.toAgentId);for(const e of this.listeners)e(t);this.loop.wake()}onEffect(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}setOverlayLayers(t){this.overlays=t,this.loop.wake()}hitTest(t,e){const s=this.cameraState.dpr,n=(t*s-this.view.offsetX)/this.view.zoom,i=(e*s-this.view.offsetY)/this.view.zoom;return _i(n,i,this.state.characters.values(),this.objectBoxes)}select(t){this.state.selectedAgentId=t,this.loop.wake()}get selectedAgentId(){return this.state.selectedAgentId}hover(t){const e=t!==null&&t.kind==="agent"?t.agentId:null;e!==this.state.hoveredAgentId&&(this.state.hoveredAgentId=e,this.loop.wake())}get hoveredAgentId(){return this.state.hoveredAgentId}get camera(){return this.cameraState}panBy(t,e){this.fitted=!0,this.cameraState.panBy(t,e),this.loop.wake()}zoomAt(t,e,s){this.fitted=!0,this.cameraState.zoomAt(t,e,s),this.loop.wake()}centerOn(t,e){this.fitted=!0,this.cameraState.centerOn(t,e),this.loop.wake()}follow(t){this.fitted=!0,this.cameraState.follow(t),this.loop.wake()}drawMinimap(t,e,s){this.minimap.draw(t,e,s,this.staticLayer,this.state,this.view)}attach(t){if(this.canvas===t){this.loop.wake();return}this.canvas&&this.detach(),this.canvas=t,this.ctx=t.getContext("2d"),this.ctx&&(this.ctx.imageSmoothingEnabled=!1),this.staticLayer??=Ki(this.state.getLayout(),this.state.tileMap,this.state.staticFurniture),this.resize(),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.resize(),this.loop.wake()}),this.resizeObserver.observe(t)),typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.loop.start()}detach(){this.loop.stop(),this.resizeObserver?.disconnect(),this.resizeObserver=null,typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange),this.flusher.flushNow(),this.canvas=null,this.ctx=null}wake(){this.loop.wake()}dispose(){this.detach(),this.flusher.dispose(),this.listeners.clear()}resize(){const t=this.canvas;if(!t)return;const e=typeof window<"u"&&window.devicePixelRatio||1,s=t.getBoundingClientRect(),n=Math.max(1,Math.round((s.width||t.clientWidth)*e)),i=Math.max(1,Math.round((s.height||t.clientHeight)*e));t.width!==n&&(t.width=n),t.height!==i&&(t.height=i),this.ctx&&(this.ctx.imageSmoothingEnabled=!1),this.cameraState.setViewport(n,i,e),this.fitted||this.cameraState.fitRoom(this.officeRoom)}startVisit(t,e){if(this.visits.has(t)||t===e)return;const s=this.state.characters.get(e);if(!s)return;const n=this.freeTileNear(s.tileCol,s.tileRow);if(n){if(this.state.setAgentPinned(t,!0),!this.state.walkToTile(t,n.col,n.row)){this.state.setAgentPinned(t,!1);return}this.visits.set(t,{toAgentId:e,phase:"travelling",timer:rr})}}freeTileNear(t,e){const s=this.state.nav;for(let n=1;n<=3;n++)for(let i=-n;i<=n;i++)for(let r=-n;r<=n;r++)if(!(Math.abs(i)!==n&&Math.abs(r)!==n)&&s.isWalkable(t+r,e+i))return{col:t+r,row:e+i};return null}updateVisits(t){if(this.visits.size===0)return!1;for(const[e,s]of this.visits){const n=this.state.characters.get(e);if(!n){this.visits.delete(e);continue}if(s.timer-=t,s.phase==="travelling"){n.state!==E.WALK?(s.phase="lingering",s.timer=ir):s.timer<=0&&this.endVisit(e);continue}s.timer<=0&&this.endVisit(e)}return this.visits.size>0}endVisit(t){this.visits.delete(t),this.state.setAgentPinned(t,!1)}step(t){let e=this.state.update(t);this.updateVisits(t)&&(e=!0);const s=this.cameraState.followAgentId,n=s!==null?this.state.characters.get(s):void 0;this.cameraState.update(t,n?.x??null,n?.y??null)&&(e=!0);for(const r of this.overlays)r.update(t,this)&&(e=!0);if(this.flusher.schedule(),e)return 0;const i=this.state.nextWakeSeconds();return i===Number.POSITIVE_INFINITY?vn:Math.max(.05,i)}render(){const t=this.ctx,e=this.canvas;if(!(!t||!e)){this.renderedFrames+=1,this.view.zoom=this.cameraState.zoom,this.view.offsetX=this.cameraState.offsetX,this.view.offsetY=this.cameraState.offsetY,this.view.width=e.width,this.view.height=e.height,this.view.nowMs=Date.now(),this.renderer.render(t,this.state,this.staticLayer,this.view);for(const s of this.overlays)s.draw(t,this.view,this)}}},ar=3,tt=new Map,St=new Map;function lr(t){const e=tt.get(t);if(e)return Promise.resolve(e);const s=St.get(t);if(s)return s;const n=Ii().then(({layouts:i,cameraBounds:r})=>{St.delete(t);const o=tt.get(t);if(o)return o;const a=new or(t,i.combined,r);for(tt.set(t,a);tt.size>ar;){const l=tt.keys().next();if(l.done||l.value===t)break;tt.get(l.value)?.dispose(),tt.delete(l.value)}return a}).catch(i=>{throw St.delete(t),i});return St.set(t,n),n}u(lr,"getOfficeController");var cr=class{static{u(this,"ParticlePool")}capacity;x;y;vx;vy;life;maxLife;tint;count=0;constructor(t){this.capacity=t,this.x=new Float32Array(t),this.y=new Float32Array(t),this.vx=new Float32Array(t),this.vy=new Float32Array(t),this.life=new Float32Array(t),this.maxLife=new Float32Array(t),this.tint=new Uint8Array(t)}spawn(t,e,s,n,i,r){if(this.count>=this.capacity)return!1;const o=this.count;return this.x[o]=t,this.y[o]=e,this.vx[o]=s,this.vy[o]=n,this.life[o]=i,this.maxLife[o]=i,this.tint[o]=r,this.count+=1,!0}step(t,e,s){let n=0;for(;n<this.count;){const i=this.life[n]-t;if(i<=0){const r=this.count-1;this.x[n]=this.x[r],this.y[n]=this.y[r],this.vx[n]=this.vx[r],this.vy[n]=this.vy[r],this.life[n]=this.life[r],this.maxLife[n]=this.maxLife[r],this.tint[n]=this.tint[r],this.count=r;continue}this.life[n]=i,this.vy[n]+=e*t,this.vx[n]*=s,this.x[n]+=this.vx[n]*t,this.y[n]+=this.vy[n]*t,n+=1}return this.count>0}clear(){this.count=0}};var Ae=1.2,Te=.25;var ur=.985;var bn=["#f87171","#fbbf24","#34d399","#60a5fa","#c084fc","#f9fafb"],fr=class{static{u(this,"OfficeEffectState")}confetti=new cr(180);visits=Array.from({length:12},()=>({fromAgentId:"",toAgentId:"",ttl:0}));mentions=Array.from({length:12},()=>({agentId:"",ttl:0}));smokes=Array.from({length:8},()=>({agentId:"",ttl:0,frame:0,frameTimer:0}));cheers=Array.from({length:40},()=>({agentId:"",ttl:0}));stickyErrors=new Set;visitCount=0;mentionCount=0;smokeCount=0;cheerCount=0;alarmPhase=0;office;unsubscribe;bigCheerPending=!1;constructor(t){this.office=t,this.unsubscribe=t.onEffect(this.handleEffect)}dispose(){this.unsubscribe()}cheerPose=u(t=>{this.pushCheer(t.agentId)},"cheerPose");handleEffect=u(t=>{if(t.kind==="celebrate"){const s=this.office.pose(t.agentId);s&&this.burst(s.x,s.y-24,t.big?72:36),this.pushCheer(t.agentId),t.big&&(this.bigCheerPending=!0);return}if(t.kind==="error"){this.stickyErrors.add(t.agentId);for(let n=0;n<this.smokeCount;n+=1)if(this.smokes[n].agentId===t.agentId){this.smokes[n].ttl=6;return}if(this.smokeCount>=8)return;const s=this.smokes[this.smokeCount];s.agentId=t.agentId,s.ttl=6,s.frame=0,s.frameTimer=0,this.smokeCount+=1;return}if(t.kind==="visit"){for(let n=0;n<this.visitCount;n+=1){const i=this.visits[n];if(i.fromAgentId===t.fromAgentId){i.toAgentId=t.toAgentId,i.ttl=4;return}}if(this.visitCount>=12)return;const s=this.visits[this.visitCount];s.fromAgentId=t.fromAgentId,s.toAgentId=t.toAgentId,s.ttl=4,this.visitCount+=1;return}for(let s=0;s<this.mentionCount;s+=1)if(this.mentions[s].agentId===t.agentId){this.mentions[s].ttl=3;return}if(this.mentionCount>=12)return;const e=this.mentions[this.mentionCount];e.agentId=t.agentId,e.ttl=3,this.mentionCount+=1},"handleEffect");burst(t,e,s){for(let n=0;n<s;n+=1){const i=Math.random()*Math.PI*2,r=20+Math.random()*55;if(!this.confetti.spawn(t,e,Math.cos(i)*r,Math.sin(i)*r-40,.9+Math.random()*.8,Math.random()*bn.length|0))return}}pushCheer(t){for(let s=0;s<this.cheerCount;s+=1)if(this.cheers[s].agentId===t){this.cheers[s].ttl=Ae;return}if(this.cheerCount>=40)return;const e=this.cheers[this.cheerCount];e.agentId=t,e.ttl=Ae,this.cheerCount+=1}mentionTtl(t){for(let e=0;e<this.mentionCount;e+=1)if(this.mentions[e].agentId===t)return this.mentions[e].ttl;return 0}update(t){this.bigCheerPending&&(this.bigCheerPending=!1,this.office.forEachPose(this.cheerPose));const e=this.office.selectedAgentId;e!==null&&this.stickyErrors.delete(e);let s=this.confetti.step(t,90,ur),n=0;for(;n<this.visitCount;){const i=this.visits[n];if(i.ttl-=t,i.ttl<=0){const r=this.visitCount-1;this.visits[n]=this.visits[r],this.visits[r]=i,this.visitCount=r;continue}n+=1}for(this.visitCount>0&&(s=!0),n=0;n<this.mentionCount;){const i=this.mentions[n];if(i.ttl-=t,i.ttl<=0){const r=this.mentionCount-1;this.mentions[n]=this.mentions[r],this.mentions[r]=i,this.mentionCount=r;continue}n+=1}for(this.mentionCount>0&&(s=!0),n=0;n<this.cheerCount;){const i=this.cheers[n];if(i.ttl-=t,i.ttl<=0){const r=this.cheerCount-1;this.cheers[n]=this.cheers[r],this.cheers[r]=i,this.cheerCount=r;continue}n+=1}for(this.cheerCount>0&&(s=!0),n=0;n<this.smokeCount;){const i=this.smokes[n];if(i.ttl-=t,i.ttl<=0){const r=this.smokeCount-1;this.smokes[n]=this.smokes[r],this.smokes[r]=i,this.smokeCount=r;continue}for(i.frameTimer+=t;i.frameTimer>=Te;)i.frameTimer-=Te,i.frame=(i.frame+1)%3;n+=1}return this.smokeCount>0?(this.alarmPhase+=t,s=!0):this.alarmPhase=0,s}},W=new Float32Array([18,24,64,.46,18,24,64,.48,18,24,64,.48,18,24,64,.46,24,30,70,.42,60,45,80,.34,255,150,90,.2,255,180,120,.1,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,255,170,100,.12,255,130,70,.22,200,90,70,.3,60,50,90,.38,30,32,72,.42,20,26,66,.45,18,24,64,.46]),dr={r:255,g:255,b:255,alpha:0};function hr(t,e=dr){const s=(t%24+24)%24,n=Math.floor(s),i=(n+1)%24,r=s-n,o=n*4,a=i*4;return e.r=W[o]+(W[a]-W[o])*r,e.g=W[o+1]+(W[a+1]-W[o+1])*r,e.b=W[o+2]+(W[a+2]-W[o+2])*r,e.alpha=W[o+3]+(W[a+3]-W[o+3])*r,e}u(hr,"tintForHour");var mr=2.5,gr=2,pr=14,gt=new Map;function wr(t){const e=gt.get(t);if(e!==void 0)return e;let s=null;if(typeof document<"u"){const n=Math.max(8,Math.round(mr*2*16*t)),i=document.createElement("canvas");i.width=n,i.height=n;const r=i.getContext("2d");if(r){const o=n/2,a=r.createRadialGradient(o,o,0,o,o,o);a.addColorStop(0,"rgba(255, 196, 108, 0.42)"),a.addColorStop(.45,"rgba(255, 170, 80, 0.18)"),a.addColorStop(1,"rgba(255, 150, 60, 0)"),r.fillStyle=a,r.fillRect(0,0,n,n),s=i}}if(gt.set(t,s),gt.size>gr){const n=gt.keys().next();n.done||gt.delete(n.value)}return s}u(wr,"glowSprite");var Bt=6e4;function vr(){const t={r:255,g:255,b:255,alpha:0};let e="",s=0,n=-6e4,i=null,r=null,o=null,a=null,l=0,c=0,d=!1;const m=u(f=>{const g=i,v=r,y=o;if(!g||!v||!y||!a)return;const p=y.visual(f.agentId);if(!p||p.status!=="running")return;const b=f.seated?6:0,x=Math.round(g.offsetX+f.x*g.zoom-l/2),T=Math.round(g.offsetY+(f.y+b-pr)*g.zoom-l/2);x+l<0||T+l<0||x>g.width||T>g.height||v.drawImage(a,x,T)},"drawGlow");return{update(f,g){return d||(d=!0,setTimeout(()=>{d=!1,!(typeof document<"u"&&document.hidden)&&g.wake()},Bt)),c+=f*1e3,c<Bt?!1:(c=0,!0)},draw(f,g,v){if(g.nowMs-n>=Bt){n=g.nowMs;const y=new Date(g.nowMs);hr(y.getHours()+y.getMinutes()/60,t),s=t.alpha,e=`rgb(${Math.round(255+(t.r-255)*t.alpha)}, ${Math.round(255+(t.g-255)*t.alpha)}, ${Math.round(255+(t.b-255)*t.alpha)})`}s>.01&&(f.save(),f.globalCompositeOperation="multiply",f.fillStyle=e,f.fillRect(0,0,g.width,g.height),f.restore(),a=wr(Math.max(1,Math.round(g.zoom))),a&&(l=a.width,i=g,r=f,o=v,f.save(),f.globalCompositeOperation="lighter",v.forEachPose(m),f.restore(),i=null,r=null))}}}u(vr,"createAmbienceLayer");var Ce=["/pixels/furniture/SMOKE/SMOKE_1.png","/pixels/furniture/SMOKE/SMOKE_2.png","/pixels/furniture/SMOKE/SMOKE_3.png"],xr="/pixels/furniture/CONFETTI/CONFETTI.png",In=[null,null,null],ut=null,Se=!1;function yr(){if(!(Se||typeof Image>"u")){Se=!0;for(let t=0;t<Ce.length;t+=1){const e=new Image;e.src=Ce[t],In[t]=e}ut=new Image,ut.src=xr}}u(yr,"requestEffectSprites");function br(t){const e=In[t];return e&&e.complete&&e.naturalWidth>0?e:null}u(br,"smokeFrame");function Ir(){return ut&&ut.complete&&ut.naturalWidth>0?ut:null}u(Ir,"confettiPop");var Ar=1.5,Tr=16,_e=30,Cr=32,Sr=.4,_r=.45,kr="rgba(248, 113, 113, 0.55)",Rr="rgba(129, 212, 250, 0.85)",Mr=[3,3],ke=18;function Fr(t){return yr(),{update(e){return t.update(e)},draw(e,s,n){const i=s.zoom,r=t.confetti;if(r.count>0){const o=Math.max(1,Math.round(Ar*i));for(let a=0;a<r.count;a+=1)e.fillStyle=bn[r.tint[a]],e.fillRect(Math.round(s.offsetX+r.x[a]*i),Math.round(s.offsetY+r.y[a]*i),o,o)}for(let o=0;o<t.cheerCount;o+=1){const a=t.cheers[o];if(a.ttl<1.2-Sr)continue;const l=Ir();if(!l)break;const c=n.pose(a.agentId);if(!c)continue;const d=Cr*i;e.drawImage(l,Math.round(s.offsetX+c.x*i-d/2),Math.round(s.offsetY+(c.y-_e)*i-d/2),d,d)}for(let o=0;o<t.smokeCount;o+=1){const a=t.smokes[o],l=n.pose(a.agentId);if(!l)continue;const c=br(a.frame),d=Tr*i,m=Math.round(s.offsetX+l.x*i-d/2),f=Math.round(s.offsetY+(l.y-_e)*i-d);c?e.drawImage(c,m,f,d,d):(e.fillStyle="rgba(226, 232, 240, 0.55)",e.fillRect(m+d/4,f+d/4,d/2,d/2))}if(t.smokeCount>0){const o=n.objectAnchor("alarm");if(o&&Math.floor(t.alarmPhase/_r)%2===0){const a=16*i;e.save(),e.globalCompositeOperation="lighter",e.fillStyle=kr,e.fillRect(Math.round(s.offsetX+o.x*i-a/2),Math.round(s.offsetY+o.y*i-a/2),a,a),e.restore()}}if(t.visitCount>0){e.save(),e.setLineDash(Mr),e.strokeStyle=Rr,e.lineWidth=Math.max(1,Math.round(i/2));for(let o=0;o<t.visitCount;o+=1){const a=t.visits[o],l=n.pose(a.fromAgentId),c=n.pose(a.toAgentId);!l||!c||(e.beginPath(),e.moveTo(s.offsetX+l.x*i,s.offsetY+(l.y-ke)*i),e.lineTo(s.offsetX+c.x*i,s.offsetY+(c.y-ke)*i),e.stroke())}e.restore()}}}}u(Fr,"createEffectsLayer");var Er="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/#!?:+@'(), ",Re=["####.#####.##.#","##.#.###.#.###.",".###..#..#...##","##.#.##.##.###.","####..##.#..###","####..##.#..#..",".###..#.##.#.##","#.##.#####.##.#","###.#..#..#.###","..#..#..##.#.#.","#.##.###.#.##.#","#..#..#..#..###","#.########.##.#","#.###.###.###.#",".#.#.##.##.#.#.","##.#.###.#..#..",".#.#.##.####.##","##.#.###.#.##.#",".###...#...###.","###.#..#..#..#.","#.##.##.##.####","#.##.##.##.#.#.","#.##.########.#","#.##.#.#.#.##.#","#.##.#.#..#..#.","###..#.#.#..###",".#.#.##.##.#.#.",".#.##..#..#.###","##...#.#.#..###","##...#.#...###.","#.##.####..#..#","####..##...###.",".###..####.####","###..#.#..#..#.","####.#####.####","####.####..###.",".............#.","......###......","............###","..#..#.#.#..#..","#.#####.#####.#",".#..#..#.....#.","##...#.#.....#.","....#.....#....","....#.###.#....","####.#####...##",".#..#..........","..#.#..#..#...#","#...#..#..#.#..","..........#.#..","..............."],An=50,yt=new Int16Array(128).fill(-1);for(let t=0;t<51;t+=1)yt[Er.charCodeAt(t)]=t;for(let t=97;t<=122;t+=1)yt[t]=yt[t-32];function te(t){let e=0;for(let s=0;s<t.length;s+=1){const n=t.charCodeAt(s),i=n<128?yt[n]:-1;i<0||(e+=i===An?3:4)}return e>0?e-1:0}u(te,"measureLabelWidth");var Or=4,et=new Map;function Nr(t,e){if(typeof document>"u")return null;const s=document.createElement("canvas");s.width=153*t,s.height=5*t;const n=s.getContext("2d");if(!n)return null;n.fillStyle=e;for(let o=0;o<Re.length;o+=1){const a=Re[o],l=o*3*t;for(let c=0;c<5;c+=1)for(let d=0;d<3;d+=1)a.charCodeAt(c*3+d)===35&&n.fillRect(l+d*t,c*t,t,t)}const i=3*t,r=5*t;return{zoom:t,color:e,height:r,drawText(o,a,l,c){let d=l;for(let m=0;m<a.length;m+=1){const f=a.charCodeAt(m),g=f<128?yt[f]:-1;if(!(g<0)){if(g===An){d+=3*t;continue}o.drawImage(s,g*i,0,i,r,d,c,i,r),d+=4*t}}}}}u(Nr,"createAtlas");function Tn(t,e){const s=Math.max(1,Math.round(t)),n=`${s}|${e}`,i=et.get(n);if(i!==void 0)return et.delete(n),et.set(n,i),i;const r=Nr(s,e);if(et.set(n,r),et.size>Or){const o=et.keys().next();o.done||et.delete(o.value)}return r}u(Tn,"getGlyphAtlas");function Lr(t,e){return t.y-e.y||t.x-e.x}u(Lr,"compareBoxes");function jr(t,e){const s=t.length;if(!(s<2)){t.sort(Lr);for(let n=1;n<s;n+=1){const i=t[n];for(let r=0;r<s;r+=1){let o=!1;for(let a=0;a<n;a+=1){const l=t[a];i.x>=l.x+l.w||l.x>=i.x+i.w||i.y>=l.y+l.h+e||l.y>=i.y+i.h+e||(i.y=l.y+l.h+e,o=!0)}if(!o)break}}}}u(jr,"declutterLabelBoxes");var Cn={read:{rows:".#####..#...#..#ooo#..#...#..#ooo#..#...#..#####.",primary:"#e5e7eb",secondary:"#60a5fa"},write:{rows:".....oo....oo#...oo#...oo#...oo#...oo#....##.....",primary:"#fbbf24",secondary:"#fde68a"},run:{rows:".......#o......#o......#o....#o....#o.......#####",primary:"#34d399",secondary:"#065f46"},web:{rows:"..###...#ooo#.#o#o#o##ooooo##o#o#o#.#ooo#...###..",primary:"#38bdf8",secondary:"#0c4a6e"},think0:{rows:".#####.#.....##o....##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},think1:{rows:".#####.#.....##o.o..##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},think2:{rows:".#####.#.....##o.o.o##.....#.####....#.....#.....",primary:"#cbd5f5",secondary:"#f9fafb"},comment:{rows:"#####..#ooo#..#ooo#..#ooo#..#####....#.....#.....",primary:"#a78bfa",secondary:"#ede9fe"},other:{rows:".........###...#ooo#..#ooo#..#ooo#...###.........",primary:"#9ca3af",secondary:"#d1d5db"},bangRed:{rows:"..###....###....###....###....oo#...........###..",primary:"#f87171",secondary:"#991b1b"},bangYellow:{rows:"..###....###....###....###....oo#...........###..",primary:"#facc15",secondary:"#854d0e"},sleep:{rows:"###......#.....#.....###.###.....#.....#......###",primary:"#93c5fd",secondary:"#93c5fd"},coin:{rows:".........###...#ooo#..#o#o#..#ooo#...###.........",primary:"#fbbf24",secondary:"#fde68a"},mention:{rows:".#####.#.....##.###.##.#.#.##.###.##.......#####.",primary:"#67e8f9",secondary:"#155e75"}},vt=Object.keys(Cn),Sn={};for(let t=0;t<vt.length;t+=1)Sn[vt[t]]=t;var Pr=3,nt=new Map;function Br(t){if(typeof document>"u")return null;const e=7*t,s=document.createElement("canvas");s.width=e*vt.length,s.height=e;const n=s.getContext("2d");if(!n)return null;for(let i=0;i<vt.length;i+=1){const r=Cn[vt[i]],o=i*e;for(let a=0;a<7;a+=1)for(let l=0;l<7;l+=1){const c=r.rows.charCodeAt(a*7+l);c!==46&&(n.fillStyle=c===35?r.primary:r.secondary,n.fillRect(o+l*t,a*t,t,t))}}return{zoom:t,size:e,draw(i,r,o,a){const l=Sn[r];i.drawImage(s,l*e,0,e,e,o,a,e,e)}}}u(Br,"createIconAtlas");function Dr(t){const e=Math.max(1,Math.round(t)),s=nt.get(e);if(s!==void 0)return nt.delete(e),nt.set(e,s),s;const n=Br(e);if(nt.set(e,n),nt.size>Pr){const i=nt.keys().next();i.done||nt.delete(i.value)}return n}u(Dr,"getIconAtlas");var Dt=1,$r=34,Wr=2,Me="rgba(12, 14, 20, 0.8)",Fe="rgba(148, 163, 184, 0.45)",Ee=1e4,Oe=320,zr="#cbd5e1",Hr=22,Yr=2,Xr=2;function Gr(t){let e="";for(const s of t)s!==" "&&s.charCodeAt(0)<128&&te(s)>0?e+=s:e.length>0&&!e.endsWith(" ")&&(e+=" ");return e=e.trim(),e.length<=Hr?e:`${e.slice(0,20).trimEnd()}..`}u(Gr,"progressCaption");var Ne={read:"read",write:"write",run:"run",web:"web",comment:"comment",other:"other"};function qr(t){let e=null,s=0,n=null,i=null,r=null,o=!1,a=null,l=0;const c=new Map,d=u((y,p)=>{const b=c.get(y);if(b&&b.message===p)return b;const x=Gr(p),T={message:p,text:x,width:te(x)};return c.set(y,T),T},"captionFor"),m=u((y,p,b,x)=>{if(!i||!e||!a||x.width===0)return y;const T=e.zoom,A=Dt*T,w=x.width*T+4*T,I=b+A*2;i.fillStyle=Me,i.fillRect(y-A,p-A,w,I),i.strokeStyle=Fe,i.lineWidth=1,i.strokeRect(y-A+.5,p-A+.5,w-1,I-1);const C=p-A+Math.round((I-5*T)/2);return a.drawText(i,x.text,y-A+Yr*T,C),y-A+w},"drawCaption"),f=u((y,p,b,x)=>{if(!i||!e)return;const T=Dt*e.zoom;i.fillStyle=Me,i.fillRect(y-T,p-T,b+T*2,b+T*2),i.strokeStyle=Fe,i.lineWidth=1,i.strokeRect(y-T+.5,p-T+.5,b+T*2-1,b+T*2-1),e.draw(i,x,y,p)},"drawBubble"),g=u(y=>{const p=n,b=r;if(!p||!b||!e||!i)return;const x=b.visual(y.agentId);if(!x)return;const T=y.seated?6:0,A=7*e.zoom,w=y.y+T-$r,I=Math.round(p.offsetX+y.x*p.zoom-A/2),C=Math.round(p.offsetY+w*p.zoom-A);if(I+A<0||C+A<0||I>p.width||C>p.height)return;if(t.mentionTtl(y.agentId)>0){f(I,C,A,"mention"),o=!0;return}const k=x.status==="error"||t.stickyErrors.has(y.agentId);if(x.working){v(y,x.activity,I,C,A,k,x.attention);return}if(k){f(I,C,A,"bangRed");return}if(x.status==="awaiting_board"||x.status==="pending_approval"){f(I,C,A,"bangYellow");return}if(x.status==="budget_paused"){f(I,C,A,"sleep"),f(I+A+Wr*e.zoom,C,A,"coin");return}if(x.status==="paused"){f(I,C,A,"sleep");return}const R=x.activity;if(R&&!(p.nowMs-R.updatedAtMs>Ee)){if(R.icon==="think"){const F=Math.floor(p.nowMs/Oe)%3;f(I,C,A,F===0?"think0":F===1?"think1":"think2"),o=!0;return}f(I,C,A,Ne[R.icon])}},"drawForPose"),v=u((y,p,b,x,T,A,w)=>{const I=n,C=r;if(!I||!C||!e)return;const k=p!==null&&I.nowMs-p.updatedAtMs<=Ee;let R;if(!p||p.icon==="think")if(k){const j=Math.floor(I.nowMs/Oe)%3;R=j===0?"think0":j===1?"think1":"think2",o=!0}else R="think1";else R=Ne[p.icon];f(b,x,T,R);const F=4*e.zoom;let L=b+T+F;k&&p?.message&&(e.zoom>=Xr||y.agentId===C.selectedAgentId||y.agentId===C.hoveredAgentId)&&p?.message&&(L=m(L,x,T,d(y.agentId,p.message))+F-Dt*e.zoom),A?f(L,x,T,"bangRed"):w&&f(L,x,T,"bangYellow")},"drawWorking");return{update(y,p){let b=t.mentionCount>0;if(!b){const x=p.selectedAgentId;b=x!==null&&t.stickyErrors.has(x)}return b||o},draw(y,p,b){const x=Math.max(1,Math.round(p.zoom));(!e||s!==x)&&(e=Dr(x),s=x),e&&((!a||l!==x)&&(a=Tn(x,zr),l=x),i=y,n=p,r=b,o=!1,b.forEachPose(g),i=null,n=null)}}}u(qr,"createBubblesLayer");var Kr="#f3f4f6",Ur="rgba(12, 14, 20, 0.72)",Vr=3,Zr=2,Le=1,Qr=3,Jr=1,to=2,eo={running:"#4ade80",queued:"#facc15",idle:"#9ca3af",paused:"#60a5fa",error:"#f87171",pending_approval:"#c084fc",awaiting_board:"#facc15",budget_paused:"#60a5fa"},no={running:1,queued:2,idle:3,paused:4,error:5,pending_approval:6,awaiting_board:7,budget_paused:8};function so(){const t=[],e=[];let s=null,n=!0,i=0,r=null,o=0,a=!0,l=0,c=0,d=-1,m=null,f=null;const g=u(y=>{const p=s;if(!p)return;const b=p.visual(y.agentId);if(c=c*31+(y.x|0)|0,c=c*31+(y.y|0)|0,!b)return;c=c*31+no[b.status]|0;const x=b.shortName;for(let T=0;T<x.length;T+=1)c=c*31+x.charCodeAt(T)|0},"scan"),v=u(y=>{const p=s;if(!p)return;const b=p.visual(y.agentId);if(!b)return;const x=p.hoveredAgentId;if(!a&&!b.working&&y.agentId!==p.selectedAgentId&&y.agentId!==x)return;let T=t[l];T||(T={x:0,y:0,w:0,h:0,text:"",dot:"",anchorX:0,anchorY:0},t[l]=T),l+=1,T.text=b.shortName,T.dot=eo[b.status],T.w=9+te(b.shortName),T.h=7,T.anchorX=Math.round(y.x-T.w/2),T.anchorY=Math.round(y.y+Qr),T.x=T.anchorX,T.y=T.anchorY},"collect");return{update(y,p){s=p,c=0,p.forEachPose(g);const b=p.hoveredAgentId;return(c!==d||p.selectedAgentId!==m||b!==f)&&(n=!0),n},draw(y,p,b){s=b;const x=Math.max(1,Math.round(p.zoom)),T=x>=to;if(n||x!==i||T!==a){a=T,l=0,b.forEachPose(v),e.length=l;for(let w=0;w<l;w+=1)e[w]=t[w];jr(e,Jr),i=x,d=c,m=b.selectedAgentId,f=b.hoveredAgentId,n=!1}if(e.length===0)return;(!r||o!==x)&&(r=Tn(x,Kr),o=x);const A=Vr*x;for(let w=0;w<e.length;w+=1){const I=e[w],C=Math.round(p.offsetX+I.x*p.zoom),k=Math.round(p.offsetY+I.y*p.zoom),R=I.w*x,F=I.h*x;C+R<0||k+F<0||C>p.width||k>p.height||(y.fillStyle=Ur,y.fillRect(C,k,R,F),y.fillStyle=I.dot,y.fillRect(C+Zr*x,k+Le*x+x,A,A),r&&r.drawText(y,I.text,C+7*x,k+Le*x))}}}}u(so,"createLabelsLayer");var je=new WeakMap;function io(t){const e=je.get(t);if(e)return e;const s=new fr(t),n=[vr(),Fr(s),qr(s),so()];return je.set(t,n),n}u(io,"createOfficeOverlays");var ro=.035,oo=.4,ao=6,lo=.12,co={done:{frequency:660,endFrequency:990,duration:.22,type:"triangle"},ding:{frequency:880,endFrequency:880,duration:.14,type:"sine"},error:{frequency:220,endFrequency:130,duration:.35,type:"sawtooth"}},ht=!1,X=null,U=null,pt=null,V=null,Rt=0,Pe=!1;function _n(){if(!X||!V)return;const t=ht?ro*Math.min(1,Rt/ao):0;V.gain.setTargetAtTime(t,X.currentTime,oo)}u(_n,"applyTypingGain");function uo(){pt&&(pt.stop(),pt.disconnect(),pt=null),V?.disconnect(),V=null,U?.disconnect(),U=null,X&&(X.close(),X=null)}u(uo,"stopAudio");function fo(){typeof document>"u"||!X||(document.hidden?X.suspend():ht&&X.resume())}u(fo,"handleVisibility");function ho(t,e){const s=Math.floor(t.sampleRate*1.5),n=t.createBuffer(1,s,t.sampleRate),i=n.getChannelData(0);let r=0,o=0;for(let c=0;c<s;c+=1)c>=r&&(o=1,r=c+Math.floor(t.sampleRate*(.04+Math.random()*.14))),o*=.9965,i[c]=(Math.random()*2-1)*o*o;const a=t.createBufferSource();a.buffer=n,a.loop=!0;const l=t.createBiquadFilter();l.type="bandpass",l.frequency.value=2400,l.Q.value=.8,a.connect(l),l.connect(e),a.start(),pt=a}u(ho,"startTypingNoise");function ee(){if(!ht)return null;if(X)return X;if(typeof globalThis.AudioContext!="function")return null;const t=new globalThis.AudioContext;return X=t,U=t.createGain(),U.gain.value=1,U.connect(t.destination),V=t.createGain(),V.gain.value=0,V.connect(U),ho(t,V),_n(),!Pe&&typeof document<"u"&&(Pe=!0,document.addEventListener("visibilitychange",fo)),t}u(ee,"ensureContext");function Be(t){if(ht!==t){if(ht=t,!t){uo();return}Rt>0&&ee()}}u(Be,"setAmbientEnabled");function mo(t){Rt=Math.max(0,t),ht&&(Rt>0&&ee(),_n())}u(mo,"setTypingLevel");function go(t){const e=ee();if(!e||!U)return;e.state==="suspended"&&e.resume();const s=co[t],n=e.currentTime,i=e.createOscillator();i.type=s.type,i.frequency.setValueAtTime(s.frequency,n),i.frequency.linearRampToValueAtTime(s.endFrequency,n+s.duration);const r=e.createGain();r.gain.setValueAtTime(0,n),r.gain.linearRampToValueAtTime(lo,n+.01),r.gain.exponentialRampToValueAtTime(1e-4,n+s.duration),i.connect(r),r.connect(U),i.start(n),i.stop(n+s.duration+.02),i.onended=()=>{i.disconnect(),r.disconnect()}}u(go,"playEffectSound");var po=[[/web|http|fetch|browser|crawl|url|scrape|navigate/,"web"],[/comment|reply|message|chat|notify|email|slack|discord|ask_user|respond|mention|interaction/,"comment"],[/think|plan|reason|reflect|sequential|todo|goal/,"think"],[/write|edit|create|update|patch|insert|append|replace|delete|remove|rename|move|upload/,"write"],[/bash|shell|exec|run|command|terminal|test|build|install|deploy|git|docker|script|compile/,"run"],[/read|view|cat|open|glob|grep|search|find|list|ls|inspect|diff|show|get|fetch_file|notebook/,"read"]],wo={ls:"read",cd:"run",task:"think",agent:"think"};function vo(t){return(t.includes("__")?t.slice(t.lastIndexOf("__")+2):t).toLowerCase().replace(/[^a-z0-9]+/g,"_")}u(vo,"normalizeToolName");function ne(t){if(!t)return"think";const e=vo(t);if(!e)return"think";const s=wo[e];if(s)return s;for(const[n,i]of po)if(n.test(e))return i;return"other"}u(ne,"activityIconForTool");function kn(t,e){if(!t||!e)return!1;if(e.source==="local_implicit"||e.isInstanceAdmin)return!0;if(!e.memberships||e.memberships.length===0)return e.companyIds.includes(t);const s=e.memberships.find(n=>n.companyId===t&&n.status==="active");return s?s.membershipRole!=="viewer"&&s.membershipRole!==null:!1}u(kn,"canBoardAssignIssues");var it=Object.freeze({changed:!1,effects:Object.freeze([]),sounds:Object.freeze([]),refetch:!1,ticker:null}),xo={completed:!0,succeeded:!0,cancelled:!0,skipped:!0,done:!0},Rn={failed:!0,timed_out:!0};function yo(){return{agents:new Map,ticker:[],tickerSeq:0}}u(yo,"createLiveOfficeState");function Mn(t,e){return{agentId:t,name:e,status:"idle",activeRunId:null,queuedRunId:null,pendingInteractionCount:0,awaitingBoardCount:0,budgetPaused:!1,errorRunId:null,activityIcon:"other",activityMessage:null,activityAtMs:0}}u(Mn,"blankAgent");function G(t,e){let s=t.agents.get(e);return s||(s=Mn(e,e),t.agents.set(e,s)),s}u(G,"ensureAgent");function De(t,e){const s=new Set;for(const n of e.agents){s.add(n.id);const i=t.agents.get(n.id)??Mn(n.id,n.name);if(i.name=n.name,i.status=n.status,i.activeRunId=n.activeRunId,i.queuedRunId=n.queuedRunId,i.pendingInteractionCount=n.pendingInteractionCount,i.awaitingBoardCount=n.awaitingBoardCount,i.budgetPaused=n.budgetPaused,n.progress&&n.progress.runId===n.activeRunId){const r=Date.parse(n.progress.updatedAt);!Number.isNaN(r)&&r>=i.activityAtMs&&(i.activityIcon=ne(n.progress.toolName),i.activityMessage=Mt(n.progress.message),i.activityAtMs=r)}else n.activeRunId===null&&(i.activityMessage=null,i.activityAtMs=0,i.activityIcon="other");t.agents.set(n.id,i)}for(const n of[...t.agents.keys()])s.has(n)||t.agents.delete(n)}u(De,"seedFromSnapshot");function bo(t,e){for(const s of e){const n=t.agents.get(s.agentId);if(!n)continue;if(s.status==="queued"){n.queuedRunId=s.id;continue}n.activeRunId=s.id;const i=s.currentStatusUpdatedAt?Date.parse(s.currentStatusUpdatedAt):NaN,r=Mt(s.currentStatusMessage??s.lastAssistantSnippet??null);if(r===null)continue;const o=Number.isNaN(i)?0:i;o<n.activityAtMs||(n.activityIcon=ne(s.currentToolName??null),n.activityMessage=r,n.activityAtMs=o)}}u(bo,"seedFromLiveRuns");function Mt(t){if(typeof t!="string")return null;const e=t.trim();return e?e.length>180?`${e.slice(0,179)}…`:e:null}u(Mt,"clampMessage");function Io(t){const e=(t.trim().split(/\s+/)[0]??"")||t.trim();return e.length>10?e.slice(0,10):e}u(Io,"shortAgentName");function Ao(t){return t.errorRunId!==null||t.status==="error"?"error":t.awaitingBoardCount>0?"awaiting_board":t.pendingInteractionCount>0||t.status==="pending_approval"?"pending_approval":t.budgetPaused?"budget_paused":t.status==="paused"?"paused":t.activeRunId!==null||t.status==="running"?"running":t.queuedRunId!==null?"queued":"idle"}u(Ao,"visualStatus");function To(t){const e=[];for(const s of t.agents.values()){const n=Ao(s);e.push({agentId:s.agentId,shortName:Io(s.name),status:n,activity:s.activityMessage===null&&s.activityAtMs===0?null:{icon:s.activityIcon,message:s.activityMessage,updatedAtMs:s.activityAtMs},attention:n==="awaiting_board"||n==="pending_approval"||n==="error",working:s.activeRunId!==null||s.status==="running"})}return e.sort((s,n)=>s.agentId<n.agentId?-1:s.agentId>n.agentId?1:0),e}u(To,"deriveAgentVisuals");function Fn(t){let e="";for(const s of t)e+=`${s.agentId}|${s.shortName}|${s.status}|${s.attention?1:0}|${s.working?1:0}|${s.activity?`${s.activity.icon}:${s.activity.updatedAtMs}:${s.activity.message??""}`:""}
|
|
2
2
|
`;return e}u(Fn,"agentVisualsKey");function O(t){return typeof t=="string"&&t.length>0?t:null}u(O,"readString");function Co(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}u(Co,"readRecord");function So(t){if(!t)return null;for(const e of["body","content","markdown","commentBody","text"]){const s=t[e];if(typeof s=="string"&&s.length>0)return s}return null}u(So,"readCommentBody");function _o(t,e){t.tickerSeq+=1;const s={id:t.tickerSeq,...e};return t.ticker.push(s),t.ticker.length>50&&t.ticker.splice(0,t.ticker.length-50),s}u(_o,"pushTicker");function ko(t,e){const s=O(e?.identifier),n=O(e?.title),i=O(e?.status),r=t.replace(/^[a-z_]+\./,"").replaceAll("_"," "),o=s??n??i;return o?`${r} · ${o}`:r}u(ko,"tickerText");function mt(t,e,s,n,i){return{changed:t,effects:e,sounds:s,refetch:n,ticker:i}}u(mt,"result");function Ro(t,e,s){const n=O(e.agentId);if(!n)return it;const i=G(t,n),r=O(e.runId);r&&(i.activeRunId=r,i.queuedRunId===r&&(i.queuedRunId=null),i.errorRunId===r&&(i.errorRunId=null));const o=O(e.updatedAt)??O(e.lastEventAt),a=o?Date.parse(o):NaN;return i.activityAtMs=Number.isNaN(a)?s:a,i.activityIcon=ne(O(e.currentToolName)),i.activityMessage=Mt(O(e.message))??Mt(O(e.lastAssistantSnippet)),mt(!0,[],[],!1,null)}u(Ro,"applyRunProgress");function Mo(t,e){const s=O(e.agentId),n=O(e.runId);if(!s)return it;const i=G(t,s);return i.queuedRunId=n,mt(!0,[],[],!0,null)}u(Mo,"applyRunQueued");function Fo(t,e){const s=O(e.agentId),n=O(e.runId),i=O(e.status);if(!s||!i)return it;const r=G(t,s),o=[],a=[];return i==="running"?(n&&(r.activeRunId=n),r.queuedRunId===n&&(r.queuedRunId=null),r.errorRunId=null):i==="queued"?r.queuedRunId=n:Rn[i]?(n&&(r.errorRunId=n,o.push({kind:"error",agentId:s,runId:n}),a.push("error")),r.activeRunId===n&&(r.activeRunId=null),r.activityMessage=null):xo[i]&&(r.activeRunId===n&&(r.activeRunId=null),r.queuedRunId===n&&(r.queuedRunId=null),r.activityMessage=null,r.activityAtMs=0,r.activityIcon="other"),mt(!0,o,a,!0,null)}u(Fo,"applyRunStatus");function Eo(t,e){const s=O(e.agentId),n=O(e.status);if(!s||!n)return it;const i=G(t,s);return i.status=n,n!=="error"&&(i.errorRunId=null),mt(!0,[],[],!0,null)}u(Eo,"applyAgentStatus");function Oo(t,e,s){const n=O(e.action);if(!n)return it;const i=Co(e.details),r=O(e.agentId)??(e.actorType==="agent"?O(e.actorId):null),o=[],a=[];let l=!1,c=!1;if(n==="issue.updated")O(i?.status)==="done"&&r&&(o.push({kind:"celebrate",agentId:r,big:No(i)>=3}),a.push("done")),c=!0;else if(n==="issue.child_created"){const m=O(i?.assigneeAgentId)??O(i?.addresseeAgentId);r&&m&&m!==r&&o.push({kind:"visit",fromAgentId:r,toAgentId:m,reason:"delegation"}),c=!0}else if(n==="issue.thread_interaction_created"){const m=O(i?.addresseeAgentId);if(r&&m&&m!==r&&o.push({kind:"visit",fromAgentId:r,toAgentId:m,reason:"interaction"}),r){const f=G(t,r);f.pendingInteractionCount+=1,a.push("ding"),l=!0}c=!0}else if(n.startsWith("issue.comment")){const m=So(i);if(m)for(const f of Gn(m))o.push({kind:"mention",agentId:f});c=!0}else if(n.startsWith("issue.thread_interaction_")){if(r){const m=G(t,r);m.pendingInteractionCount>0&&(m.pendingInteractionCount-=1),l=!0}c=!0}else if(n==="agent.paused"){const m=O(e.entityId)??r;m&&(G(t,m).status="paused",l=!0),c=!0}else if(n==="agent.resumed"||n==="agent.approved"){const m=O(e.entityId)??r;if(m){const f=G(t,m);f.status="active",f.budgetPaused=!1,l=!0}c=!0}else(n.startsWith("issue.")||n.startsWith("approval.")||n.startsWith("budget.")||n.startsWith("routine."))&&(c=!0);const d=_o(t,{atMs:s,action:n,text:ko(n,i),agentId:r});return mt(l,o,a,c,d)}u(Oo,"applyActivity");function No(t){const e=t?.childIssueCount??t?.childCount;return typeof e=="number"&&Number.isFinite(e)?e:0}u(No,"readChildCount");function Lo(t,e,s){switch(e.type){case"heartbeat.run.progress":return Ro(t,e.payload,s);case"heartbeat.run.queued":return Mo(t,e.payload);case"heartbeat.run.status":return Fo(t,e.payload);case"agent.status":return Eo(t,e.payload);case"activity.logged":return Oo(t,e.payload,s);default:return it}}u(Lo,"applyLiveEvent");function jo(t,e){const s=e.agentId;if(!s)return it;const n=G(t,s),i=[];switch(e.kind){case"run_started":n.activeRunId=e.runId??n.activeRunId,n.queuedRunId=null,n.errorRunId=null,n.activityMessage=null;break;case"run_finished":e.status&&Rn[e.status]?(n.errorRunId=e.runId??n.activeRunId,n.errorRunId&&i.push({kind:"error",agentId:s,runId:n.errorRunId})):n.errorRunId=null,n.activeRunId=null,n.activityMessage=null;break;case"issue_status":e.status==="done"&&i.push({kind:"celebrate",agentId:s,big:!1});break;case"interaction":e.otherAgentId&&i.push({kind:"visit",fromAgentId:s,toAgentId:e.otherAgentId,reason:"interaction"});break;case"approval":n.awaitingBoardCount=e.status==="resolved"?0:1;break;case"budget":n.budgetPaused=e.status!=="resolved"}return mt(!0,i,[],!1,null)}u(jo,"applyTimelineEvent");function Po(t){for(const e of t.agents.values())e.activeRunId=null,e.queuedRunId=null,e.errorRunId=null,e.awaitingBoardCount=0,e.budgetPaused=!1,e.activityMessage=null,e.activityAtMs=0,e.activityIcon="other"}u(Po,"resetTimelineAgents");function Bo(t){if(typeof requestAnimationFrame=="function"&&typeof document<"u"&&!document.hidden){requestAnimationFrame(t);return}setTimeout(t,0)}u(Bo,"defaultScheduler");function Do(t,e=Bo){const s=yo(),n=new Set,i=[];let r=[],o="",a=!1,l=!1,c=null;const d=[],m=[];function f(){const p=To(s),b=Fn(p);return b===o?!1:(r=p,o=b,!0)}u(f,"recomputeVisuals");function g(p){for(const b of n)b(p)}u(g,"emit");function v(p,b){const x=f();!x&&!p&&!b&&d.length===0&&m.length===0||(g({visuals:r,visualsChanged:x,ticker:s.ticker,tickerChanged:p,effects:d.slice(),sounds:m.slice(),refetch:b}),d.length=0,m.length=0)}u(v,"publish");function y(){if(a=!1,i.length===0)return;const p=Date.now();let b=!1,x=!1;for(const T of i){const A=Lo(s,T,p);A.ticker&&(b=!0),A.refetch&&(x=!0);for(const w of A.effects)d.push(w);for(const w of A.sounds)m.push(w)}i.length=0,v(b,x)}return u(y,"flush"),{companyId:t,state:s,getVisuals:u(()=>r,"getVisuals"),getTicker:u(()=>s.ticker,"getTicker"),isReplaying:u(()=>l,"isReplaying"),seedSnapshot(p){c=p,!l&&(De(s,p),v(!1,!1))},seedLiveRuns(p){l||(bo(s,p),v(!1,!1))},push(p){l||(i.push(p),!a&&(a=!0,e(y)))},flushNow:y,startReplay(){l=!0,i.length=0},applyTimelineFrame(p,b){if(l){b&&Po(s);for(const x of p){const T=jo(s,x);for(const A of T.effects)d.push(A)}v(!1,!1)}},stopReplay(){l=!1,c&&De(s,c),v(!1,!0)},subscribe(p){return n.add(p),()=>{n.delete(p)}}}}u(Do,"createOfficeLiveStore");var $e=new Map;function $o(t){let e=$e.get(t);return e||(e=Do(t),$e.set(t,e)),e}u($o,"getOfficeLiveStore");var En="application/x-wardmote-issue",On="wardmote.pixelsOffice.ambient",h=Ke(Xn(),1),Wo=3,zo=8,We=1.25;function Ho({companyId:t,visuals:e,assignments:s,store:n,onController:i,onSelectAgent:r,onSelectObject:o,onAssignIssue:a}){const l=(0,_.useRef)(null),c=(0,_.useRef)(null),d=(0,_.useRef)(""),m=(0,_.useRef)(null),f=(0,_.useRef)(new Map),g=(0,_.useRef)(null),[v,y]=(0,_.useState)(null),[p,b]=(0,_.useState)(null),[x,T]=(0,_.useState)(null);(0,_.useEffect)(()=>{let w=!1;return b(null),lr(t).then(I=>{if(w)return;c.current=I,I.setOverlayLayers(io(I));const C=l.current;C&&I.attach(C),d.current="",y(I),i(I)}).catch(I=>{w||b(I instanceof Error?I.message:String(I))}),()=>{w=!0,c.current?.detach(),c.current=null,i(null),y(null)}},[t,i]),(0,_.useEffect)(()=>{if(!v)return;const w=Fn(e);if(w===d.current)return;d.current=w,v.syncAgents(e,s);let I=0;for(const C of e)C.status==="running"&&(I+=1);mo(I)},[s,v,e]),(0,_.useEffect)(()=>{if(v)return n.subscribe(w=>{for(const I of w.effects)v.emit(I);for(const I of w.sounds)go(I)})},[v,n]),(0,_.useEffect)(()=>{const w=l.current;if(!w||!v)return;const I=u(C=>{C.preventDefault();const k=w.getBoundingClientRect();v.zoomAt(C.clientX-k.left,C.clientY-k.top,C.deltaY<0?1:-1)},"onWheel");return w.addEventListener("wheel",I,{passive:!1}),()=>w.removeEventListener("wheel",I)},[v]);const A=u((w,I)=>{const C=l.current,k=c.current;if(!C||!k)return null;const R=C.getBoundingClientRect();return k.hitTest(w-R.left,I-R.top)},"hitAt");return(0,h.jsxs)("div",{className:"relative h-(--sz-pixels-office-mobile-canvas) w-full xl:h-(--sz-calc-44) xl:min-h-(--sz-520px)",children:[(0,h.jsx)("canvas",{ref:l,className:x?"size-full cursor-pointer touch-none":"size-full touch-none",onPointerDown:u(w=>{if(f.current.set(w.pointerId,{x:w.clientX,y:w.clientY}),w.currentTarget.setPointerCapture(w.pointerId),f.current.size===2){const[I,C]=[...f.current.values()];g.current={distance:Math.hypot(I.x-C.x,I.y-C.y)},m.current=null,T(null);return}m.current={x:w.clientX,y:w.clientY,moved:!1,touch:w.pointerType==="touch"}},"onPointerDown"),onPointerMove:u(w=>{const I=c.current;if(!I)return;f.current.has(w.pointerId)&&f.current.set(w.pointerId,{x:w.clientX,y:w.clientY});const C=g.current;if(C&&f.current.size===2){const[j,P]=[...f.current.values()],H=Math.hypot(j.x-P.x,j.y-P.y),J=H/C.distance;if(J>=We||J<=1/We){const bt=w.currentTarget.getBoundingClientRect();I.zoomAt((j.x+P.x)/2-bt.left,(j.y+P.y)/2-bt.top,J>1?1:-1),C.distance=H}return}const k=m.current;if(k){const j=w.clientX-k.x,P=w.clientY-k.y,H=k.touch?zo:Wo;(k.moved||Math.abs(j)>H||Math.abs(P)>H)&&(k.moved=!0,k.x=w.clientX,k.y=w.clientY,I.panBy(j,P));return}if(w.pointerType==="touch")return;const R=A(w.clientX,w.clientY);if(I.hover(R),!R){T(null);return}const F=w.currentTarget.getBoundingClientRect();if(R.kind==="object"){T({x:w.clientX-F.left,y:w.clientY-F.top,title:R.object,body:null,age:null});return}const L=I.visual(R.agentId);T({x:w.clientX-F.left,y:w.clientY-F.top,title:L?.shortName??R.agentId.slice(0,8),body:L?.activity?.message??L?.status??null,age:L?.activity&&L.activity.updatedAtMs>0?Z(new Date(L.activity.updatedAtMs)):null})},"onPointerMove"),onPointerUp:u(w=>{const I=c.current,C=m.current,k=g.current!==null;if(f.current.delete(w.pointerId),f.current.size<2&&(g.current=null),m.current=null,w.currentTarget.releasePointerCapture(w.pointerId),!I||C?.moved||k||!C)return;const R=A(w.clientX,w.clientY);if(!R){I.select(null);return}if(R.kind==="agent"){I.select(R.agentId),r(R.agentId);return}o(R.object)},"onPointerUp"),onPointerCancel:u(w=>{f.current.delete(w.pointerId),g.current=null,m.current=null},"onPointerCancel"),onPointerLeave:u(w=>{w.pointerType!=="touch"&&(m.current=null,c.current?.hover(null),T(null))},"onPointerLeave"),onDoubleClick:u(w=>{const I=A(w.clientX,w.clientY);I?.kind==="agent"&&c.current?.follow(I.agentId)},"onDoubleClick"),onDragOver:u(w=>{w.dataTransfer.types.includes("application/x-wardmote-issue")&&(w.preventDefault(),w.dataTransfer.dropEffect="move",c.current?.hover(A(w.clientX,w.clientY)))},"onDragOver"),onDrop:u(w=>{const I=w.dataTransfer.getData(En);if(!I)return;w.preventDefault();const C=A(w.clientX,w.clientY);c.current?.hover(null),C?.kind==="agent"&&a(I,C.agentId)},"onDrop")}),x?(0,h.jsxs)("div",{role:"tooltip",style:{left:x.x+12,top:x.y+12},className:"pointer-events-none absolute z-10 max-w-(--sz-320px) rounded-md border border-line bg-bg-2 px-2 py-1 text-xs text-ink shadow-md",children:[(0,h.jsx)("p",{className:"font-medium",children:x.title}),x.body?(0,h.jsx)("p",{className:"text-ink-3",children:x.body}):null,x.age?(0,h.jsx)("p",{className:"text-ink-3",children:x.age}):null]}):null,p?(0,h.jsx)("p",{className:"absolute inset-x-0 bottom-2 text-center text-sm text-bad",children:p}):null]})}u(Ho,"PixelsOfficeCanvas");function Nn({title:t,subtitle:e,headerExtra:s,onClose:n,children:i}){return(0,h.jsxs)("aside",{"aria-label":t,className:"flex h-full w-full min-w-0 flex-col overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,h.jsxs)("header",{className:"flex items-start gap-2 border-b border-line px-4 py-3",children:[(0,h.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,h.jsx)("h2",{className:"truncate text-sm font-semibold text-ink",children:t}),e?(0,h.jsx)("p",{className:"truncate text-xs text-ink-3",children:e}):null]}),s,(0,h.jsx)(z,{variant:"ghost",size:"icon","aria-label":"Close panel",onClick:n,children:(0,h.jsx)(ts,{className:"size-4","aria-hidden":!0})})]}),(0,h.jsx)("div",{className:"min-h-0 flex-1",children:i})]})}u(Nn,"OfficePanelShell");var Yo={running:"Running",queued:"Queued",idle:"Idle",paused:"Paused",error:"Error",pending_approval:"Waiting on a person",awaiting_board:"Waiting on the board",budget_paused:"Budget stop"},Xo={running:"default",queued:"secondary",idle:"outline",paused:"secondary",error:"destructive",pending_approval:"secondary",awaiting_board:"secondary",budget_paused:"destructive"};function Go({companyId:t,agent:e,visual:s,onClose:n}){const i=Ue(),[r,o]=(0,_.useState)(null),{data:a}=D({queryKey:N.access.currentBoardAccess,queryFn:u(()=>tn.getCurrentBoardAccess(),"queryFn"),retry:!1}),l=kn(t,a),{data:c}=D({queryKey:N.attention(t),queryFn:u(()=>nn.list(t,{limit:50}),"queryFn"),enabled:e.pendingInteractionCount>0||e.awaitingBoardCount>0}),{data:d}=D({queryKey:N.agents.list(t),queryFn:u(()=>At.list(t),"queryFn")}),m=(0,_.useMemo)(()=>{const x=new Map;for(const T of d??[])x.set(T.id,T);return x},[d]),f=(0,_.useMemo)(()=>(c?.items??[]).filter(x=>x.sourceKind==="issue_thread_interaction"&&(x.resolverAudience?.createdByAgentId===e.id||x.resolverAudience?.addresseeAgentId===e.id)),[c,e.id]),g=u(()=>{i.invalidateQueries({queryKey:N.pixelsOffice.snapshot(t)}),i.invalidateQueries({queryKey:N.attention(t)}),i.invalidateQueries({queryKey:N.agents.list(t)})},"invalidate"),v=Ve({mutationFn:u(x=>x==="pause"?At.pause(e.id,t):x==="resume"?At.resume(e.id,t):At.wakeup(e.id,{source:"on_demand",triggerDetail:"manual"},t),"mutationFn"),onSuccess:u(()=>{o(null),g()},"onSuccess"),onError:u(x=>{o(x instanceof Error?x.message:String(x))},"onError")}),y=s?.status??"idle",p=s?.activity??null,b=e.status==="paused";return(0,h.jsx)(Nn,{title:e.name,subtitle:e.title??e.role,onClose:n,headerExtra:(0,h.jsx)(xt,{variant:Xo[y],children:Yo[y]}),children:(0,h.jsx)(Ze,{className:"h-full",children:(0,h.jsxs)("div",{className:"space-y-4 p-4",children:[p?.message?(0,h.jsxs)("div",{className:"rounded-md border border-line bg-bg-3/40 p-3",children:[(0,h.jsx)("p",{className:"text-sm text-ink",children:p.message}),(0,h.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:p.updatedAtMs>0?Z(new Date(p.updatedAtMs)):"No timestamp"})]}):null,(0,h.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(z,{size:"sm",variant:"secondary",disabled:v.isPending,onClick:u(()=>v.mutate("wake"),"onClick"),children:[v.isPending&&v.variables==="wake"?(0,h.jsx)(Qn,{className:"size-4 motion-safe:animate-spin","aria-hidden":!0}):(0,h.jsx)(Kn,{className:"size-4","aria-hidden":!0}),"Wake"]}),(0,h.jsxs)(z,{size:"sm",variant:"secondary",disabled:v.isPending,onClick:u(()=>v.mutate(b?"resume":"pause"),"onClick"),children:[b?(0,h.jsx)(zt,{className:"size-4","aria-hidden":!0}):(0,h.jsx)(Qe,{className:"size-4","aria-hidden":!0}),b?"Resume":"Pause"]})]}):null,(0,h.jsx)(z,{size:"sm",variant:"ghost",asChild:!0,children:(0,h.jsxs)(Q,{to:`/agents/${e.id}`,children:[(0,h.jsx)(Vn,{className:"size-4","aria-hidden":!0}),"Agent page"]})})]}),r?(0,h.jsx)("p",{className:"text-sm text-bad",children:r}):null,f.length>0?(0,h.jsxs)("section",{className:"space-y-2",children:[(0,h.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-(--tracking-eyebrow) text-ink-3",children:"Waiting on a decision"}),f.map(x=>(0,h.jsx)(ds,{companyId:t,issueId:x.relatedIssue?.id??x.subject.id,interactionId:x.subject.id,agentMap:m,onResolved:g},x.id))]}):null,(0,h.jsxs)("section",{className:"space-y-2",children:[(0,h.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-(--tracking-eyebrow) text-ink-3",children:["Tasks · ",e.activeTaskCount," active / ",e.queuedTaskCount," queued"]}),e.tasks.length===0?(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"No open tasks."}):(0,h.jsx)("ul",{className:"space-y-1",children:e.tasks.map(x=>(0,h.jsx)("li",{children:(0,h.jsxs)(Q,{to:`/issues/${x.identifier}`,className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-bg-3/40",children:[(0,h.jsx)("span",{className:"shrink-0 font-mono text-xs text-ink-3",children:x.identifier}),(0,h.jsx)("span",{className:"min-w-0 flex-1 truncate text-ink",children:x.title}),x.runStatus?(0,h.jsx)(xt,{variant:"secondary",children:x.runStatus}):null]})},x.issueId))})]})]})})})}u(Go,"AgentPanel");var qo={kanban:"Kanban board",mailbox:"Mailbox",clock:"Wall clock",coins:"Coin stack",alarm:"Alarm light"};function Ln(t){let e=null;for(const s of t)for(const n of s.triggers){if(!n.enabled||!n.nextRunAt)continue;const i=new Date(n.nextRunAt).getTime();Number.isNaN(i)||(!e||i<e.atMs)&&(e={routineId:s.id,routineName:s.title,atMs:i})}return e}u(Ln,"nextRoutineRun");var Ko={failed:!0,timed_out:!0};function ze(t){return`$${(t/100).toFixed(2)}`}u(ze,"formatCents");function ct({label:t,value:e}){return(0,h.jsxs)("div",{className:"flex items-baseline justify-between gap-3 text-sm",children:[(0,h.jsx)("span",{className:"text-ink-3",children:t}),(0,h.jsx)("span",{className:"font-medium text-ink",children:e})]})}u(ct,"Row");function Uo({companyId:t}){const{data:e,isLoading:s}=D({queryKey:N.pipelines.list(t),queryFn:u(()=>hs.list(t),"queryFn")});if(s)return(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Loading pipelines…"});const n=(e??[]).filter(i=>!i.archivedAt);return n.length===0?(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"No pipelines yet."}):(0,h.jsx)("ul",{className:"space-y-2",children:n.map(i=>(0,h.jsxs)("li",{className:"rounded-md border border-line p-3",children:[(0,h.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,h.jsx)(Q,{to:`/pipelines/${i.id}`,className:"truncate text-sm font-medium text-ink hover:underline",children:i.name}),(0,h.jsxs)(xt,{variant:"outline",children:[i.stageCount," stages"]})]}),(0,h.jsxs)("div",{className:"mt-1 text-xs text-ink-3",children:[i.openCaseCount," open",typeof i.inMotionCount=="number"?` · ${i.inMotionCount} in motion`:"",typeof i.attentionCount=="number"?` · ${i.attentionCount} need attention`:""]})]},i.id))})}u(Uo,"KanbanBody");function Vo({companyId:t}){const{data:e,isLoading:s}=D({queryKey:N.attention(t),queryFn:u(()=>nn.list(t,{limit:20}),"queryFn")});if(s)return(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Loading decisions…"});const n=e?.items??[];return n.length===0?(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Nothing is waiting."}):(0,h.jsx)("ul",{className:"space-y-2",children:n.map(i=>(0,h.jsxs)("li",{className:"rounded-md border border-line p-3",children:[(0,h.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,h.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-ink",children:i.subject.title??i.whyNow}),(0,h.jsx)(xt,{variant:i.severity==="critical"?"destructive":"secondary",children:i.severity})]}),(0,h.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-xs text-ink-3",children:[(0,h.jsx)("span",{children:i.sourceKind.replaceAll("_"," ")}),(0,h.jsx)("span",{children:"·"}),(0,h.jsx)("span",{children:Z(i.activityAt)}),i.relatedIssue?.identifier?(0,h.jsx)(Q,{to:`/issues/${i.relatedIssue.identifier}`,className:"font-mono hover:underline",children:i.relatedIssue.identifier}):null]})]},i.id))})}u(Vo,"MailboxBody");function Zo({companyId:t}){const{data:e,isLoading:s}=D({queryKey:N.routines.list(t),queryFn:u(()=>en.list(t),"queryFn")}),n=e??[],i=(0,_.useMemo)(()=>Ln(n),[n]);return s?(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Loading routines…"}):(0,h.jsxs)("div",{className:"space-y-3",children:[(0,h.jsx)(ct,{label:"Local time",value:new Date().toLocaleTimeString()}),i?(0,h.jsxs)("div",{className:"rounded-md border border-line p-3",children:[(0,h.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-eyebrow) text-ink-3",children:"Next run"}),(0,h.jsx)(Q,{to:`/routines/${i.routineId}`,className:"text-sm font-medium text-ink hover:underline",children:i.routineName}),(0,h.jsx)("p",{className:"text-xs text-ink-3",children:Z(new Date(i.atMs))})]}):(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"No scheduled routine run."}),(0,h.jsx)("ul",{className:"space-y-1",children:n.slice(0,12).map(r=>(0,h.jsxs)("li",{className:"flex items-center justify-between gap-2 text-sm",children:[(0,h.jsx)(Q,{to:`/routines/${r.id}`,className:"min-w-0 truncate text-ink hover:underline",children:r.title}),(0,h.jsx)("span",{className:"shrink-0 text-xs text-ink-3",children:r.lastRun?Z(r.lastRun.createdAt):"never run"})]},r.id))})]})}u(Zo,"ClockBody");function Qo({companyId:t}){const{data:e}=D({queryKey:N.dashboard(t),queryFn:u(()=>sn.summary(t),"queryFn")}),{data:s}=D({queryKey:N.budgets.overview(t),queryFn:u(()=>ms.overview(t),"queryFn")});return e?(0,h.jsxs)("div",{className:"space-y-3",children:[(0,h.jsx)(ct,{label:"Spent this month",value:ze(e.costs.monthSpendCents)}),(0,h.jsx)(ct,{label:"Budget",value:ze(e.costs.monthBudgetCents)}),(0,h.jsx)(ct,{label:"Utilisation",value:`${e.costs.monthUtilizationPercent}%`}),(0,h.jsx)(ct,{label:"Active budget incidents",value:String(e.budgets.activeIncidents)}),(0,h.jsx)(ct,{label:"Paused by budget",value:`${e.budgets.pausedAgents} agents · ${e.budgets.pausedProjects} projects`}),s?(0,h.jsx)(Q,{to:"/budgets",className:"block text-sm text-accent hover:underline",children:"Budget settings"}):null]}):(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Loading costs…"})}u(Qo,"CoinsBody");function Jo({companyId:t}){const{data:e,isLoading:s}=D({queryKey:N.heartbeats(t),queryFn:u(()=>Je.list(t,void 0,50,{summary:!0}),"queryFn")});if(s)return(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"Loading runs…"});const n=(e??[]).filter(i=>Ko[i.status]).slice(0,10);return n.length===0?(0,h.jsx)("p",{className:"text-sm text-ink-3",children:"No recent failures."}):(0,h.jsx)("ul",{className:"space-y-2",children:n.map(i=>(0,h.jsxs)("li",{className:"rounded-md border border-line p-3",children:[(0,h.jsxs)(Q,{to:`/agents/${i.agentId}/runs/${i.id}`,className:"flex items-center justify-between gap-2 text-sm text-ink hover:underline",children:[(0,h.jsx)("span",{className:"min-w-0 truncate font-mono",children:i.agentId.slice(0,8)}),(0,h.jsx)(xt,{variant:"destructive",children:i.status})]}),(0,h.jsxs)("p",{className:"mt-1 truncate text-xs text-ink-3",children:[i.error??i.errorCode??"No error text",i.finishedAt?` · ${Z(i.finishedAt)}`:""]})]},i.id))})}u(Jo,"AlarmBody");function ta({companyId:t,object:e,onClose:s}){return(0,h.jsx)(Nn,{title:qo[e],onClose:s,children:(0,h.jsx)(Ze,{className:"h-full",children:(0,h.jsxs)("div",{className:"p-4",children:[e==="kanban"?(0,h.jsx)(Uo,{companyId:t}):null,e==="mailbox"?(0,h.jsx)(Vo,{companyId:t}):null,e==="clock"?(0,h.jsx)(Zo,{companyId:t}):null,e==="coins"?(0,h.jsx)(Qo,{companyId:t}):null,e==="alarm"?(0,h.jsx)(Jo,{companyId:t}):null]})})})}u(ta,"ObjectPanel");var ea={todo:!0,backlog:!0},na=20;function sa({companyId:t,canAssign:e,armedIssueId:s,onArmIssue:n}){const{data:i}=D({queryKey:N.pixelsOffice.unassigned(t),queryFn:u(()=>Wt.listCompact(t,{limit:200,sortField:"updated",sortDir:"desc"}),"queryFn"),enabled:e});if(!e)return null;const r=(i??[]).filter(o=>ea[o.status]&&!o.assigneeAgentId&&!o.assigneeUserId).slice(0,na);return(0,h.jsxs)("div",{className:"flex w-full min-w-0 flex-col gap-1 md:w-auto md:max-w-full",children:[(0,h.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-(--tracking-eyebrow) text-ink-3",children:["Unassigned · ",r.length]}),r.length===0?(0,h.jsx)("span",{className:"text-xs text-ink-3",children:"Everything has an owner."}):(0,h.jsx)("ul",{className:"flex max-w-full gap-1 overflow-x-auto pb-1",children:r.map(o=>(0,h.jsx)("li",{className:"shrink-0",children:(0,h.jsxs)("div",{draggable:!0,role:"button",tabIndex:0,title:o.title,"aria-pressed":s===o.id,"data-issue-id":o.id,onClick:u(()=>n(s===o.id?null:o.id),"onClick"),onKeyDown:u(a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),n(s===o.id?null:o.id))},"onKeyDown"),onDragStart:u(a=>{a.dataTransfer.effectAllowed="move",a.dataTransfer.setData(En,o.id),a.dataTransfer.setData("text/plain",o.identifier??o.id)},"onDragStart"),className:s===o.id?"flex min-h-8 cursor-grab items-center gap-1 rounded-md border border-accent bg-accent/10 px-2 py-1 text-xs text-ink active:cursor-grabbing":"flex min-h-8 cursor-grab items-center gap-1 rounded-md border border-line bg-bg-2 px-2 py-1 text-xs text-ink active:cursor-grabbing",children:[(0,h.jsx)(rs,{className:"size-3 shrink-0 text-ink-3","aria-hidden":!0}),(0,h.jsx)("span",{className:"whitespace-nowrap font-mono text-ink-3",children:o.identifier??o.id.slice(0,8)}),(0,h.jsx)("span",{className:"max-w-(--sz-150px) truncate",children:o.title})]})},o.id))})]})}u(sa,"UnassignedTray");var ia=3e4;function lt({icon:t,label:e,value:s,tone:n,onClick:i}){return(0,h.jsxs)("button",{type:"button",onClick:i,className:n==="alert"?"flex min-h-8 shrink-0 items-center gap-1.5 rounded-full border border-bad/50 bg-bad/10 px-3 py-1 text-xs text-ink transition-colors hover:bg-bad/20":"flex min-h-8 shrink-0 items-center gap-1.5 rounded-full border border-line bg-bg-2 px-3 py-1 text-xs text-ink transition-colors hover:bg-bg-3/40",children:[t,(0,h.jsx)("span",{className:"font-medium",children:s}),(0,h.jsx)("span",{className:"text-ink-3",children:e})]})}u(lt,"Chip");function ra({companyId:t,ticker:e,canAssign:s,ambientEnabled:n,onToggleAmbient:i,onOpenObject:r,compact:o=!1,armedIssueId:a,onArmIssue:l}){const c=Qt(),[d,m]=(0,_.useState)(()=>new Date);(0,_.useEffect)(()=>{if(!c.visible)return;m(new Date);const x=setInterval(()=>m(new Date),ia);return()=>clearInterval(x)},[c.visible]);const{data:f}=D({queryKey:N.dashboard(t),queryFn:u(()=>sn.summary(t),"queryFn")}),{data:g}=D({queryKey:N.routines.list(t),queryFn:u(()=>en.list(t),"queryFn")}),v=(0,_.useMemo)(()=>Ln(g??[]),[g]),y=e.length>0?e[e.length-1]:null,p=f?(f.costs.monthSpendCents/100).toFixed(0):"0",b=f?(f.costs.monthBudgetCents/100).toFixed(0):"0";return(0,h.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,h.jsxs)("div",{className:o?"-mx-3 flex items-center gap-2 overflow-x-auto px-3 pb-1":"flex flex-wrap items-center gap-2",children:[(0,h.jsx)(lt,{icon:(0,h.jsx)(re,{className:"size-3.5","aria-hidden":!0}),value:String(f?.agents.running??0),label:"running",onClick:u(()=>r("kanban"),"onClick")}),(0,h.jsx)(lt,{icon:(0,h.jsx)(re,{className:"size-3.5","aria-hidden":!0}),value:String(f?.tasks.open??0),label:"open",onClick:u(()=>r("kanban"),"onClick")}),(0,h.jsx)(lt,{icon:(0,h.jsx)(gs,{className:"size-3.5","aria-hidden":!0}),value:String(f?.tasks.blocked??0),label:"blocked",tone:(f?.tasks.blocked??0)>0?"alert":void 0,onClick:u(()=>r("alarm"),"onClick")}),(0,h.jsx)(lt,{icon:(0,h.jsx)(Zn,{className:"size-3.5","aria-hidden":!0}),value:String(f?.pendingApprovals??0),label:"approvals",tone:(f?.pendingApprovals??0)>0?"alert":void 0,onClick:u(()=>r("mailbox"),"onClick")}),(0,h.jsx)(lt,{icon:(0,h.jsx)(Un,{className:"size-3.5","aria-hidden":!0}),value:`$${p}/$${b}`,label:"this month",onClick:u(()=>r("coins"),"onClick")}),(0,h.jsx)(lt,{icon:(0,h.jsx)(as,{className:"size-3.5","aria-hidden":!0}),value:d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),label:v?`next ${Z(new Date(v.atMs))}`:"no routine queued",onClick:u(()=>r("clock"),"onClick")}),(0,h.jsx)(z,{size:"sm",variant:"ghost",className:"shrink-0","aria-pressed":n,"aria-label":n?"Mute office sound":"Unmute office sound",onClick:u(()=>i(!n),"onClick"),children:n?(0,h.jsx)(ps,{className:"size-4","aria-hidden":!0}):(0,h.jsx)(ws,{className:"size-4","aria-hidden":!0})})]}),(0,h.jsxs)("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-end md:justify-between md:gap-3",children:[(0,h.jsx)(sa,{companyId:t,canAssign:s,armedIssueId:a,onArmIssue:l}),(0,h.jsx)("p",{"aria-live":"polite",className:"min-w-0 flex-1 truncate text-xs text-ink-3 md:text-right",children:y?`${y.text} · ${Z(new Date(y.atMs))}`:"No activity yet."})]})]})}u(ra,"OfficeHud");var He=160,Ye=112,oa=250;function aa({office:t}){const e=(0,_.useRef)(null),s=Qt();return(0,_.useEffect)(()=>{const n=e.current;if(!n||!t||!s.visible)return;const i=n.getContext("2d");if(!i)return;const r=Math.min(2,Math.round(window.devicePixelRatio||1));n.width=He*r,n.height=Ye*r,i.setTransform(r,0,0,r,0,0);let o=-1;const a=u(()=>{t.frameCount!==o&&(o=t.frameCount,t.drawMinimap(i,He,Ye))},"paint");a();const l=setInterval(a,oa);return()=>clearInterval(l)},[t,s.visible]),(0,h.jsx)("canvas",{ref:e,"aria-label":"Office minimap",className:"hidden h-(--sz-7rem) w-(--sz-160px) cursor-pointer rounded-md border border-line bg-bg-2 @2xl:block",onClick:u(n=>{if(!t)return;const i=n.currentTarget.getBoundingClientRect(),r=(n.clientX-i.left)/i.width,o=(n.clientY-i.top)/i.height;t.centerOn(r*t.worldWidth,o*t.worldHeight)},"onClick")})}u(aa,"OfficeMinimap");var la=[1,10,60],Xe=250,$t=3e5;function ca({companyId:t,store:e,onReplayingChange:s}){const n=Qt(),[i,r]=(0,_.useState)(!1),[o,a]=(0,_.useState)(!1),[l,c]=(0,_.useState)(10),[d,m]=(0,_.useState)(0),f=(0,_.useRef)(0),g=(0,_.useMemo)(()=>{const w=Math.ceil(Date.now()/$t)*$t;return{fromMs:w-Hn,toMs:w}},[]),{data:v,isFetching:y,error:p}=D({queryKey:N.pixelsOffice.timeline(t,new Date(g.fromMs).toISOString(),new Date(g.toMs).toISOString()),queryFn:u(()=>Ht.timeline(t,{from:new Date(g.fromMs).toISOString(),to:new Date(g.toMs).toISOString()}),"queryFn"),enabled:i,staleTime:$t}),b=(0,_.useMemo)(()=>v?.events??[],[v]),x=(0,_.useCallback)((w,I)=>{I&&(f.current=0);const C=[];for(;f.current<b.length;){const k=b[f.current];if(!k||Date.parse(k.at)>w)break;C.push(k),f.current+=1}C.length===0&&!I||e.applyTimelineFrame(C,I)},[b,e]),T=(0,_.useCallback)(()=>{e.startReplay(),f.current=0,m(g.fromMs),r(!0),a(!0),s(!0)},[s,e,g.fromMs]),A=(0,_.useCallback)(()=>{a(!1),r(!1),f.current=0,e.stopReplay(),s(!1)},[s,e]);return(0,_.useEffect)(()=>{if(!i||!o||!n.visible||b.length===0)return;const w=setInterval(()=>{m(I=>{const C=I+Xe*l;return C>=g.toMs?(a(!1),g.toMs):C})},Xe);return()=>clearInterval(w)},[b.length,o,i,l,n.visible,g.toMs]),(0,_.useEffect)(()=>{!i||b.length===0||x(d,!1)},[x,d,b.length,i]),(0,_.useEffect)(()=>()=>{e.isReplaying()&&e.stopReplay()},[e]),i?(0,h.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[(0,h.jsxs)(z,{size:"sm",variant:"ghost",onClick:u(()=>a(w=>!w),"onClick"),children:[o?(0,h.jsx)(Qe,{className:"size-4","aria-hidden":!0}):(0,h.jsx)(zt,{className:"size-4","aria-hidden":!0}),o?"Pause":"Play"]}),(0,h.jsx)("input",{type:"range","aria-label":"Replay position",min:g.fromMs,max:g.toMs,step:6e4,value:d,onChange:u(w=>{const I=Number(w.target.value),C=I<d;m(I),x(I,C)},"onChange"),className:"min-w-0 flex-1"}),(0,h.jsx)("span",{className:"shrink-0 font-mono text-xs text-ink-3",children:new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,h.jsx)("div",{className:"flex items-center gap-1",children:la.map(w=>(0,h.jsxs)(z,{size:"sm",variant:l===w?"secondary":"ghost",onClick:u(()=>c(w),"onClick"),children:[w,"x"]},w))}),(0,h.jsxs)(z,{size:"sm",variant:"primary",onClick:A,children:[(0,h.jsx)(Jn,{className:"size-4","aria-hidden":!0}),"Live"]}),y?(0,h.jsx)("span",{className:"text-xs text-ink-3",children:"Loading history…"}):null,p?(0,h.jsx)("span",{className:"text-xs text-bad",children:p instanceof Error?p.message:"Timeline unavailable"}):null]}):(0,h.jsxs)(z,{size:"sm",variant:"secondary",onClick:T,children:[(0,h.jsx)(zt,{className:"size-4","aria-hidden":!0}),"Replay last 24 h"]})}u(ca,"TimelineScrubber");var ua=2e3,Ge="(min-width: 1280px)";function qe(t){return t.map(e=>`${e.agentId}:${e.characterIndex}:${e.seatId}`).sort().join("|")}u(qe,"seatKey");function fa(){try{return localStorage.getItem(On)==="on"}catch{return!1}}u(fa,"readAmbientPreference");function Ya(){const{selectedCompanyId:t}=qn(),{setBreadcrumbs:e}=ss(),{pushToast:s}=ns(),n=Ue(),[i,r]=(0,_.useState)(null),{isMobile:o}=es(),[a,l]=(0,_.useState)(()=>window.matchMedia(Ge).matches);(0,_.useEffect)(()=>{const M=window.matchMedia(Ge),B=u(()=>l(M.matches),"onChange");return M.addEventListener("change",B),()=>M.removeEventListener("change",B)},[]);const[c,d]=(0,_.useState)([]),[m,f]=(0,_.useState)([]),[g,v]=(0,_.useState)(null),[y,p]=(0,_.useState)(!1),[b,x]=(0,_.useState)(fa),T=(0,_.useRef)(void 0),A=(0,_.useRef)(null),w=(0,_.useMemo)(()=>$o(t??"__none__"),[t]);(0,_.useEffect)(()=>{e([{label:"Pixels Office"}])},[e]),(0,_.useEffect)(()=>{Be(b);try{localStorage.setItem(On,b?"on":"off")}catch{return}},[b]),(0,_.useEffect)(()=>()=>Be(!1),[]);const I=D({queryKey:N.pixelsOffice.snapshot(t??""),queryFn:u(()=>Ht.snapshot(t),"queryFn"),enabled:!!t}),C=D({queryKey:N.liveRuns(t??""),queryFn:u(()=>Je.liveRunsForCompany(t,{limit:50}),"queryFn"),enabled:!!t}),{data:k}=D({queryKey:N.access.currentBoardAccess,queryFn:u(()=>tn.getCurrentBoardAccess(),"queryFn"),retry:!1}),R=kn(t,k),F=I.data;(0,_.useEffect)(()=>{F&&(w.seedSnapshot(F),d(w.getVisuals()))},[F,w]),(0,_.useEffect)(()=>{C.data&&(w.seedLiveRuns(C.data),d(w.getVisuals()))},[C.data,w]);const L=(0,_.useCallback)(()=>{T.current===void 0&&(T.current=setTimeout(()=>{T.current=void 0,!(typeof document<"u"&&document.hidden)&&n.invalidateQueries({queryKey:N.pixelsOffice.snapshot(t??"")})},ua))},[n,t]);(0,_.useEffect)(()=>()=>clearTimeout(T.current),[]),(0,_.useEffect)(()=>{if(!g||!F||!R||y)return;const M=g.readPlacements(),B=qe(M);B===qe(F.assignments)||B===A.current||(A.current=B,Ht.replaceSeats(F.companyId,M).then(()=>L()).catch(()=>{}))},[R,g,y,L,F,c]),(0,_.useEffect)(()=>w.subscribe(M=>{M.visualsChanged&&d(M.visuals),M.tickerChanged&&f(M.ticker.slice()),M.refetch&&L()}),[L,w]),os((0,_.useCallback)(M=>w.push(M),[w])),(0,_.useEffect)(()=>{const M=u(B=>{const Et=B.target;if(Et&&(Et.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(Et.tagName)))return;if(B.key==="Escape"){r(null),g?.select(null);return}if(B.key.toLowerCase()!=="f"||!g)return;const Wn=g.camera.followAgentId;g.follow(Wn?null:g.selectedAgentId)},"onKeyDown");return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[g]);const j=Ve({mutationFn:u(M=>Wt.update(M.issueId,{assigneeAgentId:M.agentId}),"mutationFn"),onSuccess:u((M,B)=>{n.invalidateQueries({queryKey:N.pixelsOffice.unassigned(t??"")}),L(),s({title:"Task assigned",tone:"success",action:{label:"Undo",onClick:u(()=>{Wt.update(B.issueId,{assigneeAgentId:B.previous}).then(()=>{n.invalidateQueries({queryKey:N.pixelsOffice.unassigned(t??"")}),L()})},"onClick")}})},"onSuccess"),onError:u(M=>{s({title:"Could not assign the task",body:M instanceof Error?M.message:String(M),tone:"error"})},"onError")}),P=(0,_.useCallback)((M,B)=>{R&&j.mutate({issueId:M,agentId:B,previous:null})},[j,R]),[H,J]=(0,_.useState)(null),bt=(0,_.useCallback)(M=>{if(H){P(H,M),J(null);return}r({kind:"agent",agentId:M})},[H,P]),jn=(0,_.useCallback)(M=>{r({kind:"object",object:M})},[]),Pn=(0,_.useMemo)(()=>F?.assignments??[],[F]),se=(0,_.useMemo)(()=>i?.kind==="agent"?F?.agents.find(M=>M.id===i.agentId)??null:null,[i,F]),Bn=(0,_.useMemo)(()=>i?.kind==="agent"?c.find(M=>M.agentId===i.agentId)??null:null,[i,c]),Dn=(0,_.useMemo)(()=>g?.rooms??[],[g]),$n=(0,_.useCallback)(M=>{r({kind:"object",object:M});const B=g?.objectAnchor(M);B&&g?.centerOn(B.x,B.y)},[g]);if(!t)return(0,h.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select a company to view the office."});if(I.isLoading)return(0,h.jsx)(ls,{});if(I.isError)return(0,h.jsxs)("div",{className:"space-y-3 p-6",children:[(0,h.jsx)("p",{className:"text-sm text-ink-3",children:I.error instanceof Error?I.error.message:"Could not load the office."}),(0,h.jsx)(z,{variant:"secondary",size:"sm",onClick:u(()=>{I.refetch()},"onClick"),children:"Retry"})]});const It=i?.kind==="agent"&&se?(0,h.jsx)(Go,{companyId:t,agent:se,visual:Bn,onClose:u(()=>r(null),"onClose")}):i?.kind==="object"?(0,h.jsx)(ta,{companyId:t,object:i.object,onClose:u(()=>r(null),"onClose")}):null,ie=(0,h.jsx)(ra,{companyId:t,ticker:m,canAssign:R,ambientEnabled:b,onToggleAmbient:x,onOpenObject:$n,compact:o,armedIssueId:H,onArmIssue:J});return(0,h.jsxs)("div",{className:"flex flex-col gap-3 p-3 md:gap-4 md:p-6",children:[(0,h.jsxs)("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center md:justify-between md:gap-3",children:[(0,h.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,h.jsx)("h1",{className:"text-lg font-semibold text-ink",children:"Pixels Office"}),(0,h.jsxs)("span",{className:"text-xs text-ink-3",children:[c.length," agents",y?" · replaying history":""]})]}),(0,h.jsx)("div",{className:"-mx-3 flex items-center gap-1 overflow-x-auto px-3 md:mx-0 md:flex-wrap md:overflow-visible md:px-0",children:Dn.map(M=>(0,h.jsx)(z,{size:"sm",variant:"ghost",className:"shrink-0",onClick:u(()=>g?.centerOn(M.centerX,M.centerY),"onClick"),children:M.label},M.id))})]}),o?null:ie,(0,h.jsxs)("div",{className:"flex min-h-0 flex-col gap-4 xl:flex-row",children:[(0,h.jsxs)(is,{className:"@container relative min-w-0 flex-1 overflow-hidden p-0",children:[H?(0,h.jsxs)("div",{className:"absolute inset-x-2 top-2 z-10 flex items-center justify-between gap-2 rounded-md border border-line bg-bg-2 px-3 py-2 text-xs text-ink shadow-md",children:[(0,h.jsx)("span",{children:"Tap an agent to assign the selected task."}),(0,h.jsx)(z,{size:"sm",variant:"ghost",onClick:u(()=>J(null),"onClick"),children:"Cancel"})]}):null,(0,h.jsx)(Ho,{companyId:t,visuals:c,assignments:Pn,store:w,onController:v,onSelectAgent:bt,onSelectObject:jn,onAssignIssue:P}),(0,h.jsx)("div",{className:"absolute bottom-3 right-3",children:(0,h.jsx)(aa,{office:g})})]}),It&&a?(0,h.jsx)("div",{className:"relative w-full shrink-0 xl:w-(--sz-360px)",children:(0,h.jsx)("div",{className:"absolute inset-0",children:It})}):null]}),o?ie:null,(0,h.jsx)(fs,{open:It!==null&&!a,onOpenChange:u(M=>M?null:r(null),"onOpenChange"),children:(0,h.jsxs)(cs,{side:"bottom",showCloseButton:!1,className:"max-h-(--sz-80vh) gap-0 rounded-t-xl p-0 pb-(--sz-calc-safe-bottom)",children:[(0,h.jsx)(us,{className:"sr-only",children:"Office details"}),(0,h.jsx)("div",{className:"mx-auto mt-2 h-1.5 w-12 shrink-0 rounded-full bg-ink-3/30","aria-hidden":"true"}),(0,h.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:It})]})}),(0,h.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,h.jsx)(ca,{companyId:t,store:w,onReplayingChange:p})})]})}u(Ya,"PixelsOffice");export{Ya as PixelsOffice};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=Object.defineProperty;var p=(n,t)=>M(n,"name",{value:t,configurable:!0});import{i as b}from"./rolldown-runtime-ZpX3ckPj.js";import{na as _,ta as S}from"./createLucideIcon-B-uEJvX6.js";import{v as B}from"./star-BXywPGTx.js";import{t as K,v as q}from"./queryKeys-yuC-YxZI.js";import{n as R}from"./CompanyContext-DDgccGSs.js";import{r as U,t as D}from"./router-2HX_SyKK.js";import{t as k}from"./arrow-left-DbEq2ZQa.js";import{t as w}from"./button-D3bYvq4T.js";import{t as z}from"./plugins-B9j-cGkW.js";import{a as F,t as A}from"./slots-DEaEOBky.js";import{n as L}from"./BreadcrumbContext-_dNLeVnD.js";import{Zt as P}from"./index-
|
|
1
|
+
var M=Object.defineProperty;var p=(n,t)=>M(n,"name",{value:t,configurable:!0});import{i as b}from"./rolldown-runtime-ZpX3ckPj.js";import{na as _,ta as S}from"./createLucideIcon-B-uEJvX6.js";import{v as B}from"./star-BXywPGTx.js";import{t as K,v as q}from"./queryKeys-yuC-YxZI.js";import{n as R}from"./CompanyContext-DDgccGSs.js";import{r as U,t as D}from"./router-2HX_SyKK.js";import{t as k}from"./arrow-left-DbEq2ZQa.js";import{t as w}from"./button-D3bYvq4T.js";import{t as z}from"./plugins-B9j-cGkW.js";import{a as F,t as A}from"./slots-DEaEOBky.js";import{n as L}from"./BreadcrumbContext-_dNLeVnD.js";import{Zt as P}from"./index-CSIXA5y5.js";var m=b(_(),1),s=b(S(),1);function re(){const n=B(),{companyPrefix:t,pluginId:a,pluginRoutePath:r}=n,c=n["*"],{companies:d,selectedCompanyId:N}=R(),{setBreadcrumbs:h}=L(),y=(0,m.useMemo)(()=>{if(!t)return null;const i=t.toUpperCase();return d.find(e=>e.issuePrefix.toUpperCase()===i)??null},[d,t]),C=!!t&&!y,o=(0,m.useMemo)(()=>y?y.id:t?null:N??null,[y,t,N]),x=(0,m.useMemo)(()=>o?d.find(i=>i.id===o)?.issuePrefix??null:null,[d,o]),{data:l}=q({queryKey:K.plugins.uiContributions,queryFn:p(()=>z.listUiContributions(),"queryFn"),enabled:!!o&&(!!a||!!r)}),f=(0,m.useMemo)(()=>{if(!l)return null;if(a){const e=l.find(g=>g.pluginId===a);if(!e)return null;const u=e.slots.find(g=>g.type==="page");return u?{...u,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}:null}if(!r)return null;const i=l.flatMap(e=>{const u=e.slots.find(g=>g.type==="page"&&g.routePath===r);return u?[{...u,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version}]:[]});return i.length!==1?null:i[0]??null},[a,r,l]),I=(0,m.useMemo)(()=>({companyId:o??null,companyPrefix:x}),[o,x]),v=(0,m.useMemo)(()=>{if(!r||!l)return!1;const i=l.flatMap(e=>e.slots.map(u=>({...u,pluginId:e.pluginId,pluginKey:e.pluginKey,pluginDisplayName:e.displayName,pluginVersion:e.version})));return F(i,r)!==null},[l,r]);if((0,m.useEffect)(()=>{if(f){if(v){h([{label:V(f,c)}]);return}h([{label:"Plugins",href:"/company/settings/instance/plugins"},{label:f.pluginDisplayName}])}},[f,c,h,v]),!o)return C?(0,s.jsx)(P,{scope:"invalid_company_prefix",requestedPrefix:t}):(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsx)("p",{className:"text-sm text-ink-3",children:"Select an organization to view this page."})});if(!l)return(0,s.jsx)("div",{className:"text-sm text-ink-3",children:"Loading…"});if(!a&&r&&l.filter(i=>i.slots.some(e=>e.type==="page"&&e.routePath===r)).length>1)return(0,s.jsxs)("div",{className:"rounded-md border border-bad/30 bg-bad/5 px-3 py-2 text-sm text-bad",children:["Multiple plugins declare the route ",(0,s.jsx)("code",{children:r}),". Use the plugin-id route until the conflict is resolved."]});if(!f){if(r)return(0,s.jsx)(P,{scope:"board"});const i=a?`/company/settings/instance/plugins/${a}`:"/company/settings/instance/plugins";return(0,s.jsx)(U,{to:i,replace:!0})}return(0,s.jsxs)("div",{className:"space-y-4",children:[!v&&(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)(w,{variant:"ghost",size:"sm",asChild:!0,children:(0,s.jsxs)(D,{to:x?`/${x}/dashboard`:"/dashboard",children:[(0,s.jsx)(k,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,s.jsx)(A,{slot:f,context:I,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}p(re,"PluginPage");function V(n,t){return $(t)??n.displayName??n.pluginDisplayName}p(V,"resolveRouteSidebarPageTitle");function $(n){const t=(n??"").split("/").filter(Boolean).map(E);return t.length===0?null:t[0]==="page"&&t.length>1?j(t.slice(1).join("/"),{preserveCase:!0}):j(t[0]??null)}p($,"titleFromRouteSplat");function j(n,t={}){const a=n?.trim();if(!a)return null;const r=a.split("/").filter(Boolean).at(-1)??a,c=(r.split("::").at(-1)??r).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return c?t.preserveCase?c:c.replace(/\b\w/g,d=>d.toUpperCase()):null}p(j,"titleFromPath");function E(n){try{return decodeURIComponent(n)}catch{return n}}p(E,"decodeRouteSegment");export{re as PluginPage};
|