forge-openclaw-plugin 0.3.16 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/assets/{action-bar-DgrmzFrI.js → action-bar-D3CEYlj4.js} +1 -1
  2. package/dist/assets/{activity-page-CF451ueg.js → activity-page-Ce1pHIu5.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-DtwybxJB.js → ai-surface-workspace-DEliwOjF.js} +1 -1
  4. package/dist/assets/artifacts-page-BgyFVIVM.js +2 -0
  5. package/dist/assets/{atlas-panel-CB3uYk_K.js → atlas-panel-VZOnJa1c.js} +1 -1
  6. package/dist/assets/{board-CuxQRKPJ.js → board-DprRipIG.js} +1 -1
  7. package/dist/assets/{calendar-page-BYsDuLnh.js → calendar-page-Zstsn4uG.js} +1 -1
  8. package/dist/assets/{calendar-rules-DXuOv2J-.js → calendar-rules-BGIBuEDk.js} +1 -1
  9. package/dist/assets/{calendar-week-toolbar-8PJmiUE_.js → calendar-week-toolbar-DXFkMkbq.js} +1 -1
  10. package/dist/assets/{charts-BzT4pUPg.js → charts-C5S0-BL7.js} +1 -1
  11. package/dist/assets/{companion-sync-lab-page-DzWNOaBh.js → companion-sync-lab-page-DIPPLFKt.js} +1 -1
  12. package/dist/assets/{daily-metrics-dashboard-CHcYxDhs.js → daily-metrics-dashboard-CG-OOCJz.js} +1 -1
  13. package/dist/assets/{define-workbench-box-DcI0_QKW.js → define-workbench-box-BEEdtBkQ.js} +1 -1
  14. package/dist/assets/{entity-link-multiselect-C--AiCMb.js → entity-link-multiselect-BfDAROHB.js} +1 -1
  15. package/dist/assets/{entity-note-count-link-xne6mshj.js → entity-note-count-link-BGOiaash.js} +1 -1
  16. package/dist/assets/{entity-notes-surface-jy6Psist.js → entity-notes-surface-DPsJwqQa.js} +1 -1
  17. package/dist/assets/execution-board-Dg-2GSKv.js +1 -0
  18. package/dist/assets/{faceted-token-search-BMQ1Wwzt.js → faceted-token-search-DV7MSVYb.js} +1 -1
  19. package/dist/assets/{flagship-signal-deck-DjcskRwF.js → flagship-signal-deck-D3wVL3bC.js} +1 -1
  20. package/dist/assets/{floating-action-menu-cGhbJ2tc.js → floating-action-menu-BUs382px.js} +1 -1
  21. package/dist/assets/{forms-D1qJ3oOP.js → forms-ByKjodjN.js} +1 -1
  22. package/dist/assets/{generic-node-view-DNVwfqqq.js → generic-node-view-BY5dbPXJ.js} +1 -1
  23. package/dist/assets/{goal-detail-page-dAbyCilO.js → goal-detail-page-MYr6j2B4.js} +1 -1
  24. package/dist/assets/{goal-dialog-DH50D0tP.js → goal-dialog-nkdME5Uy.js} +1 -1
  25. package/dist/assets/goals-page-BsFeBzU1.js +1 -0
  26. package/dist/assets/{graph-BF4IsheG.js → graph-CHVj0Z7n.js} +1 -1
  27. package/dist/assets/habits-page-wO461EVU.js +1 -0
  28. package/dist/assets/{health-boxes-BPTgGM6G.js → health-boxes-BphMeSJj.js} +1 -1
  29. package/dist/assets/index-CSd8ylsy.css +1 -0
  30. package/dist/assets/index-gmPaoLN-.js +2 -0
  31. package/dist/assets/{inline-note-fields-D4mCM1gO.js → inline-note-fields-BvQwmMAv.js} +1 -1
  32. package/dist/assets/{insight-flow-dialog-Btp6bkbV.js → insight-flow-dialog-H_eaOmst.js} +1 -1
  33. package/dist/assets/{insights-page-1qM4mxjS.js → insights-page-DINYe3cB.js} +3 -3
  34. package/dist/assets/{kanban-boxes-u_A-UJG-.js → kanban-boxes-oACOTDYG.js} +1 -1
  35. package/dist/assets/{kanban-page-CKCa_3Qb.js → kanban-page-BGLXH91f.js} +1 -1
  36. package/dist/assets/knowledge-graph-page-VfMvw5jL.js +1 -0
  37. package/dist/assets/{life-force-page-BZlyA144.js → life-force-page-DQPb6UL-.js} +1 -1
  38. package/dist/assets/{life-force-workspace-CtAWZXNw.js → life-force-workspace-BJ1aI3JE.js} +1 -1
  39. package/dist/assets/{maps-BTVHALP8.js → maps-CvEHVkBk.js} +1 -1
  40. package/dist/assets/{metric-tile-Bkx2btO2.js → metric-tile-CbEe19Gd.js} +1 -1
  41. package/dist/assets/{motion-DcgUnXhY.js → motion-BibSzp57.js} +1 -1
  42. package/dist/assets/{movement-boxes-QZ2EIS9q.js → movement-boxes-dtDYhw5c.js} +1 -1
  43. package/dist/assets/{movement-page-B-3ihggI.js → movement-page-BhmwCHjs.js} +1 -1
  44. package/dist/assets/{note-markdown-BWedRE3c.js → note-markdown-CG8u2d6p.js} +1 -1
  45. package/dist/assets/{note-tags-input-DZkCqI1w.js → note-tags-input-D_conqDO.js} +1 -1
  46. package/dist/assets/{notes-boxes-DGFmt7Dp.js → notes-boxes-BLKucFqW.js} +1 -1
  47. package/dist/assets/notes-page-CafVxWjb.js +1 -0
  48. package/dist/assets/{open-in-graph-button-CjvkEj1P.js → open-in-graph-button-DFQ4r6SN.js} +1 -1
  49. package/dist/assets/{orbit-map-CRHSPenk.js → orbit-map-DsEl3ori.js} +1 -1
  50. package/dist/assets/overview-page-BffcX-pM.js +1 -0
  51. package/dist/assets/page-hero-U603l9rQ.js +1 -0
  52. package/dist/assets/pill-cluster-BYVFNppV.js +1 -0
  53. package/dist/assets/{preference-entity-handoff-button-CfCQl3cW.js → preference-entity-handoff-button-cPrTpHsV.js} +1 -1
  54. package/dist/assets/{preferences-page-OltGdsQ2.js → preferences-page-DQjFIOmt.js} +1 -1
  55. package/dist/assets/{project-collections-FfBIVwXu.js → project-collections-B9OGHGqm.js} +1 -1
  56. package/dist/assets/project-detail-page-r1Sw2kcO.js +1 -0
  57. package/dist/assets/{project-dialog-B_J1ESMk.js → project-dialog-B2_PcXAf.js} +1 -1
  58. package/dist/assets/project-management-hierarchy-page-qLNG8hsh.js +1 -0
  59. package/dist/assets/{project-management-section-nav-DBNHt9p5.js → project-management-section-nav-DFUlmMEB.js} +1 -1
  60. package/dist/assets/{projects-boxes-BvlVsO5q.js → projects-boxes-BA7_XaqX.js} +1 -1
  61. package/dist/assets/projects-page-B6ggXWFw.js +1 -0
  62. package/dist/assets/psyche-behaviors-page-ByWpXlLq.js +5 -0
  63. package/dist/assets/{psyche-flashcards-page-05606-97.js → psyche-flashcards-page-B9nSc0mk.js} +1 -1
  64. package/dist/assets/{psyche-goal-map-page-Cw-aqS3Y.js → psyche-goal-map-page-BQU7qI88.js} +1 -1
  65. package/dist/assets/{psyche-graph-0E22QHPe.js → psyche-graph-DCeP7r2b.js} +1 -1
  66. package/dist/assets/{psyche-metrics-page-DBFVPeMa.js → psyche-metrics-page-DD2lOP-J.js} +1 -1
  67. package/dist/assets/psyche-mode-guide-page-DbtZgnjr.js +1 -0
  68. package/dist/assets/psyche-modes-page-3zFJWFQf.js +1 -0
  69. package/dist/assets/psyche-page-D5vXYkfB.js +1 -0
  70. package/dist/assets/psyche-patterns-page-BneAAeKS.js +5 -0
  71. package/dist/assets/{psyche-questionnaire-builder-page-DEt0UDsz.js → psyche-questionnaire-builder-page-BH1la5C9.js} +1 -1
  72. package/dist/assets/{psyche-questionnaire-detail-page-BXQbOE6A.js → psyche-questionnaire-detail-page-DYav634P.js} +1 -1
  73. package/dist/assets/psyche-questionnaire-run-detail-page-9VaijhJm.js +1 -0
  74. package/dist/assets/{psyche-questionnaire-run-page-D_EokOQm.js → psyche-questionnaire-run-page-e1T6k_dS.js} +1 -1
  75. package/dist/assets/{psyche-questionnaires-page-D1Ov2L4n.js → psyche-questionnaires-page-Dyv367z9.js} +1 -1
  76. package/dist/assets/{psyche-report-detail-page-9HyPr8BJ.js → psyche-report-detail-page-hqxHIXw2.js} +3 -3
  77. package/dist/assets/psyche-reports-page-DhIfcGbt.js +1 -0
  78. package/dist/assets/{psyche-schemas-DDol0j-g.js → psyche-schemas-Cg51Ztxz.js} +1 -1
  79. package/dist/assets/psyche-schemas-beliefs-page-Dgb5o9vx.js +9 -0
  80. package/dist/assets/{psyche-screen-time-page-DJMDR5oo.js → psyche-screen-time-page-D6MnJGNa.js} +1 -1
  81. package/dist/assets/{psyche-self-observation-page-DFKXG1Yv.js → psyche-self-observation-page-C1Vyezbv.js} +1 -1
  82. package/dist/assets/{psyche-values-page-TWKth89J.js → psyche-values-page-B_JWVw1Q.js} +2 -2
  83. package/dist/assets/{question-flow-dialog-D-_EvoAt.js → question-flow-dialog-yMYVk998.js} +2 -2
  84. package/dist/assets/{report-chain-fields-Dy-jBQDn.js → report-chain-fields-D4NM9a6I.js} +1 -1
  85. package/dist/assets/rewards-page-B5-bcL4R.js +1 -0
  86. package/dist/assets/{scheduling-rules-editor-CAd290IE.js → scheduling-rules-editor-De72IUax.js} +1 -1
  87. package/dist/assets/{schema-badge-BLaVI1D7.js → schema-badge-jX28kUa6.js} +1 -1
  88. package/dist/assets/{schemas-B0Pa-V-A.js → schemas-BlFy-uPR.js} +1 -1
  89. package/dist/assets/{select-menu-DcS4Ukjf.js → select-menu-BXv1rsVc.js} +1 -1
  90. package/dist/assets/{settings-agents-page-Bt38HhEJ.js → settings-agents-page-DN_np10S.js} +1 -1
  91. package/dist/assets/settings-bin-page-BM5BpK_i.js +1 -0
  92. package/dist/assets/{settings-calendar-page-DPSSZV3s.js → settings-calendar-page-Cg0gSSFs.js} +3 -3
  93. package/dist/assets/{settings-data-page-BdHsD1C_.js → settings-data-page-Dwmp2rLy.js} +1 -1
  94. package/dist/assets/{settings-logs-page-D9OnWoFq.js → settings-logs-page-DQNM21Re.js} +1 -1
  95. package/dist/assets/{settings-mobile-page-DFpsXA4M.js → settings-mobile-page-DQdiRa-a.js} +1 -1
  96. package/dist/assets/settings-models-page-CAEPpuHF.js +1 -0
  97. package/dist/assets/{settings-page-m_3iYPwU.js → settings-page-Cl2KiCFg.js} +1 -1
  98. package/dist/assets/{settings-rewards-page-B2aBm-dA.js → settings-rewards-page-DoIUumhe.js} +1 -1
  99. package/dist/assets/{settings-section-nav-CMeU19Rx.js → settings-section-nav-D_N87IG0.js} +1 -1
  100. package/dist/assets/{settings-users-page-D8jyewJl.js → settings-users-page-CPesR62N.js} +1 -1
  101. package/dist/assets/{settings-wiki-page-DjOgQJAh.js → settings-wiki-page-BxMQM5Vi.js} +1 -1
  102. package/dist/assets/{sleep-page-D8-dA4bE.js → sleep-page-DUYmQKrg.js} +1 -1
  103. package/dist/assets/{sports-page-CK3PgPKB.js → sports-page-Bzi5TF9T.js} +1 -1
  104. package/dist/assets/{state-Bpe5dF3T.js → state-BFyKSULP.js} +1 -1
  105. package/dist/assets/{strategies-page-aFpJath-.js → strategies-page-C-T2MZx4.js} +1 -1
  106. package/dist/assets/{strategy-detail-page-CobF5qLv.js → strategy-detail-page-3tYuSZu-.js} +1 -1
  107. package/dist/assets/{strategy-dialog-Fgoaoob5.js → strategy-dialog-BWm4slo4.js} +1 -1
  108. package/dist/assets/{surface-D0dqgX-k.js → surface-BJObZeRw.js} +1 -1
  109. package/dist/assets/{table-U7otr5go.js → table-CTLroJKN.js} +1 -1
  110. package/dist/assets/task-detail-page-ZZOXSpSF.js +1 -0
  111. package/dist/assets/{task-dialog-eCDTF8xe.js → task-dialog-2wy0xI7f.js} +5 -5
  112. package/dist/assets/timebox-planning-dialog-C6h0Hp71.js +1 -0
  113. package/dist/assets/{today-boxes-CYfskVrM.js → today-boxes-B_TdgSDz.js} +1 -1
  114. package/dist/assets/today-page-Dipns9tl.js +1 -0
  115. package/dist/assets/training-load-page-B78e1-o-.js +1 -0
  116. package/dist/assets/{ui-B9TWEtCx.js → ui-uo_bNP7c.js} +1 -1
  117. package/dist/assets/{use-anchored-overlay-position-BY4kNzPj.js → use-anchored-overlay-position-BSxFX6Hi.js} +1 -1
  118. package/dist/assets/{use-psyche-focus-target-BhNedCZB.js → use-psyche-focus-target-1GLkhYiv.js} +1 -1
  119. package/dist/assets/{user-badge-MEZuJiir.js → user-badge-C4eZu1e_.js} +1 -1
  120. package/dist/assets/{user-select-field-fx129Uh6.js → user-select-field-CmKwcbZt.js} +1 -1
  121. package/dist/assets/{utility-widgets-h5eG2jvc.js → utility-widgets-B06wQFrd.js} +2 -2
  122. package/dist/assets/{vendor-BwL6m4SE.js → vendor-B7FKSwHK.js} +222 -212
  123. package/dist/assets/{vitals-page-eoFnQ3XL.js → vitals-page-BC7QFsm2.js} +1 -1
  124. package/dist/assets/{weekly-review-page-C7BU1gkK.js → weekly-review-page-BjNsNoWj.js} +1 -1
  125. package/dist/assets/{weight-loss-page-Cc7Do3XY.js → weight-loss-page-BOahGY9r.js} +1 -1
  126. package/dist/assets/{wiki-article-markdown-CCKoSptz.js → wiki-article-markdown-DO47HnZf.js} +2 -2
  127. package/dist/assets/{wiki-editor-page-BpbxZrgz.js → wiki-editor-page-OWRUHl4O.js} +5 -5
  128. package/dist/assets/{wiki-ingest-history-page-D5Wfr8pc.js → wiki-ingest-history-page-CuHpg2lZ.js} +1 -1
  129. package/dist/assets/{wiki-ingest-modal-DhRVsEwC.js → wiki-ingest-modal-EZ3kX-vA.js} +1 -1
  130. package/dist/assets/wiki-page-BPV3HIgu.js +1 -0
  131. package/dist/assets/{workbench-flow-page-y9FxDbKO.js → workbench-flow-page-C53KueEz.js} +3 -3
  132. package/dist/assets/{workbench-page-Da16AZvN.js → workbench-page-DJ7nT2JQ.js} +1 -1
  133. package/dist/assets/workout-detail-page-Dhyu0q7o.js +2 -0
  134. package/dist/index.html +8 -8
  135. package/dist/openclaw/parity.d.ts +1 -1
  136. package/dist/openclaw/parity.js +10 -0
  137. package/dist/openclaw/routes.js +78 -0
  138. package/dist/openclaw/tools.js +42 -0
  139. package/dist/server/apps/api/migrations/072_artifact_store.sql +106 -0
  140. package/dist/server/apps/api/src/app.js +364 -3
  141. package/dist/server/apps/api/src/openapi.js +570 -1
  142. package/dist/server/apps/api/src/repositories/entity-links.js +66 -0
  143. package/dist/server/apps/api/src/services/artifacts.js +1059 -0
  144. package/dist/server/apps/api/src/services/entity-crud.js +22 -0
  145. package/dist/server/apps/api/src/services/knowledge-graph.js +45 -0
  146. package/dist/server/apps/api/src/services/psyche-observation-calendar.js +1 -0
  147. package/dist/server/apps/api/src/types.js +2 -0
  148. package/dist/server/apps/web/src/lib/api.js +69 -0
  149. package/dist/server/apps/web/src/lib/entity-visuals.js +10 -1
  150. package/dist/server/apps/web/src/lib/knowledge-graph-types.js +9 -0
  151. package/openclaw.plugin.json +2 -1
  152. package/package.json +1 -1
  153. package/server/migrations/072_artifact_store.sql +106 -0
  154. package/skills/forge-openclaw/SKILL.md +57 -4
  155. package/skills/forge-openclaw/entity_conversation_playbooks.md +212 -14
  156. package/skills/forge-openclaw/psyche_entity_playbooks.md +20 -0
  157. package/dist/assets/execution-board-BSUZCIIx.js +0 -1
  158. package/dist/assets/goals-page-DkMy9mPD.js +0 -1
  159. package/dist/assets/habits-page-CCQR8rg6.js +0 -1
  160. package/dist/assets/index-VzCGTBS_.css +0 -1
  161. package/dist/assets/index-izRKx6JK.js +0 -2
  162. package/dist/assets/knowledge-graph-page-BZOxRv19.js +0 -1
  163. package/dist/assets/notes-page-DYkn04tz.js +0 -1
  164. package/dist/assets/overview-page-D6LsjPWe.js +0 -1
  165. package/dist/assets/page-hero-BLhM8FF3.js +0 -1
  166. package/dist/assets/pill-cluster-B5bYs_e2.js +0 -1
  167. package/dist/assets/project-detail-page-CCm3iZPQ.js +0 -1
  168. package/dist/assets/project-management-hierarchy-page-BNzvtNZj.js +0 -1
  169. package/dist/assets/projects-page-BUf7KV-_.js +0 -1
  170. package/dist/assets/psyche-behaviors-page-jtyhdpJ1.js +0 -5
  171. package/dist/assets/psyche-mode-guide-page-DI-LNEDT.js +0 -1
  172. package/dist/assets/psyche-modes-page-CaMupyfi.js +0 -1
  173. package/dist/assets/psyche-page-CFBq0YKf.js +0 -1
  174. package/dist/assets/psyche-patterns-page-sp4ikoef.js +0 -5
  175. package/dist/assets/psyche-questionnaire-run-detail-page-Cd3ClsSK.js +0 -1
  176. package/dist/assets/psyche-reports-page-BeyJg5fb.js +0 -1
  177. package/dist/assets/psyche-schemas-beliefs-page-DNmf-Vma.js +0 -9
  178. package/dist/assets/rewards-page-D3ymEd2X.js +0 -1
  179. package/dist/assets/settings-bin-page-DqyVI1i1.js +0 -1
  180. package/dist/assets/settings-models-page-DaFXLp-O.js +0 -1
  181. package/dist/assets/task-detail-page-CDK79bzk.js +0 -1
  182. package/dist/assets/timebox-planning-dialog-CNZIGSpd.js +0 -1
  183. package/dist/assets/today-page-Bnh8wopq.js +0 -1
  184. package/dist/assets/training-load-page-C7lq-jqy.js +0 -1
  185. package/dist/assets/wiki-page-1vf-HErs.js +0 -1
  186. package/dist/assets/workout-detail-page-Cq0YamXF.js +0 -2
@@ -1 +1 @@
1
- import{r as g,j as e,aV as it,aG as We,bZ as Ut,b6 as Wt,bY as Qt,b_ as le,b$ as Me,c0 as qt,c1 as _e,c2 as Zt,c3 as Gt,bz as st,c4 as ze,bu as Yt,c5 as nt,b3 as Xt}from"./vendor-BwL6m4SE.js";import{w as Jt,j as Vt,i as ot,k as z}from"./state-Bpe5dF3T.js";import{F as j,a as be,Q as Ze}from"./question-flow-dialog-D-_EvoAt.js";import{E as ea}from"./entity-link-multiselect-C--AiCMb.js";import{g as jt,b as Qe,I as P,T as ta,j as ye,k as S,m as ee,n as ce,o as Ge,p as At,q as St,t as Nt,v as aa,d as ra,S as ia,e as sa,C as Z,w as na,x as oa,B as G,y as la,z as da,A as ca,D as ua,F as ma,G as lt,H as pa,J as ga,i as va,K as ha,M as xa,N as ya,O as ba}from"./index-izRKx6JK.js";import{C as fa}from"./calendar-week-toolbar-8PJmiUE_.js";import{T as ka,a as wa}from"./timebox-planning-dialog-CNZIGSpd.js";import{W as qe,m as dt,a as ja,s as $e,b as Le,c as Aa,f as Re}from"./calendar-ui-Cy1XRwzV.js";import{P as Sa}from"./page-hero-BLhM8FF3.js";import{F as Na}from"./floating-action-menu-cGhbJ2tc.js";import{r as Ca,b as Ta,g as ct}from"./calendar-display-preferences-Cid-2RnL.js";import{g as Ia,f as xe}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./scheduling-rules-editor-CAd290IE.js";const ut="rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",mt="bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",Ke="rounded-[22px] border px-4 py-4 text-left transition",He="border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]",Be="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]";function pt(a,s){const d=new Date(a);return Number.isNaN(d.getTime())?s:d.toISOString()}function de(a){const s=new Date(a);return new Date(s.getTime()-s.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function gt(a,s){var x,y,f,u,N;const d=new Date,b=new Date(d.getTime()+30*6e4),h=new Date(b.getTime()+60*6e4);return{title:(s==null?void 0:s.title)??(a==null?void 0:a.title)??"",description:(s==null?void 0:s.description)??(a==null?void 0:a.description)??"",location:(s==null?void 0:s.location)??(a==null?void 0:a.location)??"",placeAddress:((x=s==null?void 0:s.place)==null?void 0:x.address)??((y=a==null?void 0:a.place)==null?void 0:y.address)??"",placeTimezone:((f=s==null?void 0:s.place)==null?void 0:f.timezone)??((u=a==null?void 0:a.place)==null?void 0:u.timezone)??"",startAtLocal:a?de(a.startAt):s!=null&&s.startAt?de(s.startAt):de(b.toISOString()),endAtLocal:a?de(a.endAt):s!=null&&s.endAt?de(s.endAt):de(h.toISOString()),timezone:(s==null?void 0:s.timezone)??(a==null?void 0:a.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:(s==null?void 0:s.availability)??(a==null?void 0:a.availability)??"busy",activityPresetKey:Nt(a==null?void 0:a.actionProfile),customSustainRateApPerHour:St(a==null?void 0:a.actionProfile),preferredCalendarId:s&&"preferredCalendarId"in s?s.preferredCalendarId:(a==null?void 0:a.calendarId)??void 0,categoriesText:((N=s==null?void 0:s.categories)==null?void 0:N.join(", "))??(a==null?void 0:a.categories.join(", "))??"",linkQuery:"",links:(s==null?void 0:s.links)??(a==null?void 0:a.links.map(E=>({entityType:E.entityType,entityId:E.entityId,relationshipType:E.relationshipType,label:`${E.entityType.replaceAll("_"," ")} · ${E.entityId}`})))??[]}}function Pa({open:a,onOpenChange:s,writableCalendars:d,linkOptions:b,event:h,seed:x,onSubmit:y,pending:f=!1}){const[u,N]=g.useState(()=>gt(h,x)),[E,c]=g.useState(null);g.useEffect(()=>{a&&(N(gt(h,x)),c(null))},[h,a,x]);const A=g.useMemo(()=>b.map(n=>{const v=jt(n.entityType);return{value:`${n.entityType}:${n.entityId}`,label:n.label,description:n.subtitle,searchText:`${n.label} ${n.subtitle} ${n.entityType}`,kind:v??void 0,menuBadge:v?e.jsx(Qe,{kind:v,label:n.label,compact:!0,gradient:!1}):void 0,badge:v?e.jsx(Qe,{kind:v,label:n.label,compact:!0}):void 0}}),[b]),m=g.useMemo(()=>[{id:"identity",eyebrow:"Event",title:h?"Refine the Forge event":"Create a Forge calendar event",description:"This event belongs to Forge first. If you choose a writable calendar, Forge will also project it to the connected provider.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(j,{label:"Title",children:e.jsx(P,{value:n.title,onChange:l=>v({title:l.target.value}),placeholder:"Weekly research supervision"})}),e.jsx(j,{label:"Description",children:e.jsx(ta,{value:n.description,onChange:l=>v({description:l.target.value}),placeholder:"Agenda, context, or outcomes you want this event to carry."})}),e.jsx(j,{label:"Location",children:e.jsx(P,{value:n.location,onChange:l=>v({location:l.target.value}),placeholder:"Clinic room 2 or Zoom"})}),e.jsx(j,{label:"Place address",children:e.jsx(P,{value:n.placeAddress,onChange:l=>v({placeAddress:l.target.value}),placeholder:"Bahnhofstrasse 10, Zurich"})}),e.jsx(j,{label:"Place timezone",children:e.jsx(P,{value:n.placeTimezone,onChange:l=>v({placeTimezone:l.target.value}),placeholder:"Europe/Zurich"})})]})},{id:"timing",eyebrow:"Timing",title:"Set the time and visibility",description:"Forge stores the real event window, timezone, and whether it should behave like a busy or free slot for scheduling rules.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[(()=>{const l=new Date().toISOString(),$=new Date(Date.now()+3600*1e3).toISOString(),M=ye({title:n.title,availability:n.availability,activityPresetKey:n.activityPresetKey,customSustainRateApPerHour:n.customSustainRateApPerHour,startAt:pt(n.startAtLocal,l),endAt:pt(n.endAtLocal,$)});return e.jsxs("div",{className:`${ut} p-4`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:mt,children:ee(M.rateApPerHour)}),e.jsx(S,{className:mt,children:ce(M.totalAp)})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Availability controls whether the event blocks planning. The activity profile controls AP drain, and you can override it with a custom AP per hour."})]})})(),e.jsx(j,{label:"Activity profile",children:e.jsx(be,{value:n.activityPresetKey??(n.availability==="busy"?"meeting":"light_context"),columns:3,onChange:l=>v({activityPresetKey:l}),options:Ge().filter(l=>l.key!=="task_inherited").map(l=>({value:l.key,label:l.label,description:`${ee(l.defaultRateApPerHour)} · ${l.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:n.customSustainRateApPerHour??"",onChange:l=>v({customSustainRateApPerHour:l.target.value.trim()===""?null:Number(l.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Starts",children:e.jsx(P,{type:"datetime-local",value:n.startAtLocal,onChange:l=>v({startAtLocal:l.target.value})})}),e.jsx(j,{label:"Ends",children:e.jsx(P,{type:"datetime-local",value:n.endAtLocal,onChange:l=>v({endAtLocal:l.target.value})})})]}),e.jsx(j,{label:"Timezone",children:e.jsx(P,{value:n.timezone,onChange:l=>v({timezone:l.target.value}),placeholder:"Europe/Zurich"})}),e.jsx(j,{label:"Availability",children:e.jsx(be,{value:n.availability,onChange:l=>v({availability:l}),options:[{value:"busy",label:"Busy",description:"This event should block timebox recommendations and rule checks."},{value:"free",label:"Free",description:"This event stays visible in the calendar without blocking work."}]})})]})},{id:"links",eyebrow:"Meaning",title:"Connect the event to Forge entities",description:"Attach this event to strategies, goals, projects, tasks, or habits so the calendar carries multi-user operating context instead of staying isolated.",render:(n,v)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(j,{label:"Search Forge entities",description:"Search across human and bot-owned entities; the linked records use the same icon, color, and owner system as the rest of Forge.",children:e.jsx(ea,{options:A,selectedValues:n.links.map(l=>`${l.entityType}:${l.entityId}`),onChange:l=>{v({links:l.map($=>{const[M,...L]=$.split(":"),R=L.join(":"),te=b.find(ue=>ue.entityType===M&&ue.entityId===R);return te?{entityType:te.entityType,entityId:te.entityId,relationshipType:"context",label:te.label}:null}).filter($=>$!==null)})},placeholder:"Search strategies, goals, projects, tasks, habits, human, or bot owners",emptyMessage:"No matching Forge entities found."})})})},{id:"projection",eyebrow:"Projection",title:"Choose where this event should live remotely",description:"You can keep the event local to Forge, or choose a writable connected calendar so Forge also keeps a synced remote copy.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[d.length>0?e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:void 0}),className:`${Ke} ${n.preferredCalendarId===void 0?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(it,{className:"size-4"}),"Default synced calendar"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Let Forge use the default writable connected calendar automatically."})]}):null,e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:null}),className:`${Ke} ${n.preferredCalendarId===null?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(We,{className:"size-4"}),"Forge only"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the event in Forge without creating a remote provider copy yet."})]}),d.map(l=>e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:l.id}),className:`${Ke} ${n.preferredCalendarId===l.id?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(it,{className:"size-4"}),At(l)]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:l.description||`${l.timezone} · writable`})]},l.id))]}),e.jsxs("div",{className:`${ut} grid gap-2 p-4 text-sm text-[var(--ui-ink-medium)]`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(Ut,{className:"size-4 text-[var(--primary)]"}),"Categories and filtering"]}),e.jsx(P,{value:n.categoriesText,onChange:l=>v({categoriesText:l.target.value}),placeholder:"meeting, clinic, research"})]})]})}],[h,b,A,d]);return e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:h?"Edit event":"New event",title:h?"Edit calendar event":"Create calendar event",description:"Forge-owned events can stay local or publish to a connected provider calendar.",value:u,onChange:N,draftPersistenceKey:h?`calendar.event.${h.id}`:"calendar.event.new",steps:m,onSubmit:async()=>{if(!u.title.trim()){c("Add an event title before saving.");return}if(!u.startAtLocal||!u.endAtLocal){c("Set both the start and end time before saving.");return}if(new Date(u.endAtLocal).getTime()<=new Date(u.startAtLocal).getTime()){c("The event end time must be after the start time.");return}c(null),await y({title:u.title.trim(),description:u.description.trim(),location:u.location.trim(),place:{label:u.location.trim(),address:u.placeAddress.trim(),timezone:u.placeTimezone.trim(),latitude:null,longitude:null,source:u.placeAddress.trim()?"manual":"",externalPlaceId:""},startAt:new Date(u.startAtLocal).toISOString(),endAt:new Date(u.endAtLocal).toISOString(),timezone:u.timezone.trim()||"UTC",availability:u.availability,activityPresetKey:u.activityPresetKey,customSustainRateApPerHour:u.customSustainRateApPerHour,categories:u.categoriesText.split(",").map(n=>n.trim()).filter(Boolean),links:u.links.map(n=>({entityType:n.entityType,entityId:n.entityId,relationshipType:n.relationshipType})),...u.preferredCalendarId!==void 0?{preferredCalendarId:u.preferredCalendarId}:{}})},submitLabel:h?"Save event":"Create event",pending:f,pendingLabel:h?"Saving":"Creating",error:E})}function Da({open:a,onOpenChange:s,initialTitle:d,pending:b=!1,onSubmit:h}){const[x,y]=g.useState(d),[f,u]=g.useState(null);return g.useEffect(()=>{a&&(y(d),u(null))},[d,a]),e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:"Calendar",title:"Quick rename",description:"Rename the event without reopening the full event guide.",value:{title:x},onChange:N=>y(N.title),draftPersistenceKey:`calendar.quick-rename.${d}`,steps:[{id:"rename",eyebrow:"Rename",title:"Update the event title",description:"Keep the rename fast and direct. Everything else on the event stays unchanged.",render:(N,E)=>e.jsx(j,{label:"Event title",children:e.jsx(P,{value:N.title,onChange:c=>E({title:c.target.value}),placeholder:"Weekly research supervision"})})}],submitLabel:"Save title",pending:b,pendingLabel:"Saving",error:f,onSubmit:async()=>{const N=x.trim();if(!N){u("Add a title before saving.");return}u(null),await h(N),s(!1)}})}function vt(a){if(a)return{title:a.title,kind:a.kind,color:a.color,timezone:a.timezone,weekDays:a.weekDays,startMinute:a.startMinute,endMinute:a.endMinute,startsOn:a.startsOn,endsOn:a.endsOn,blockingState:a.blockingState,activityPresetKey:Nt(a.actionProfile),customSustainRateApPerHour:St(a.actionProfile)};const s=qe[0];return{title:s.title,kind:s.kind,color:s.color,timezone:typeof Intl<"u"&&Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",weekDays:[1,2,3,4,5],startMinute:s.startMinute,endMinute:s.endMinute,startsOn:null,endsOn:null,blockingState:s.blockingState,activityPresetKey:s.kind==="main_activity"?"deep_work":s.kind==="secondary_activity"?"admin":s.kind==="holiday"?"holiday_leisure":s.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null}}function ht(a){return a??""}function Ue({draft:a}){const s=aa({kind:a.kind,startMinute:a.startMinute,endMinute:a.endMinute,activityPresetKey:a.activityPresetKey,customSustainRateApPerHour:a.customSustainRateApPerHour}),d=a.endMinute>a.startMinute?a.endMinute-a.startMinute:1440-a.startMinute+a.endMinute;return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:ee(s.rateApPerHour)}),e.jsxs(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[ce(s.totalAp)," / block"]}),e.jsxs(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[Math.round(d/60),"h ",d%60,"m"]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the default Life Force container drain for each occurrence of the block when no richer task run or timebox already covers that window."})]})}function Oa({open:a,onOpenChange:s,onSubmit:d,pending:b=!1,template:h=null}){const[x,y]=g.useState(()=>vt(h)),[f,u]=g.useState(null),N=h!==null;g.useEffect(()=>{a&&(u(null),y(vt(h)))},[a,h]);const E=g.useMemo(()=>[{id:"preset",eyebrow:"Preset",title:"Start from a recurring block that already matches the rhythm",description:"Use a preset to seed the schedule, then tune the dates and recurrence in the next step.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Activity profile",children:e.jsx(be,{value:c.activityPresetKey??"maintenance",columns:3,onChange:m=>A({activityPresetKey:m,customSustainRateApPerHour:c.customSustainRateApPerHour}),options:Ge().filter(m=>m.key!=="task_inherited").map(m=>({value:m.key,label:m.label,description:`${ee(m.defaultRateApPerHour)} · ${m.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:c.customSustainRateApPerHour??"",onChange:m=>A({customSustainRateApPerHour:m.target.value.trim()===""?null:Number(m.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsx(j,{label:"Block type",children:e.jsx(be,{value:c.kind,columns:3,onChange:m=>{const n=qe.find(v=>v.kind===m);if(n){const v=n.kind==="holiday"?[0,1,2,3,4,5,6]:[1,2,3,4,5];A({kind:n.kind,title:n.title,color:n.color,weekDays:v,startMinute:n.startMinute,endMinute:n.endMinute,blockingState:n.blockingState,activityPresetKey:n.kind==="main_activity"?"deep_work":n.kind==="secondary_activity"?"admin":n.kind==="holiday"?"holiday_leisure":n.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null});return}A({kind:"custom",title:"Custom block",color:"#7dd3fc",activityPresetKey:"maintenance",customSustainRateApPerHour:null})},options:[...qe.map(m=>({value:m.kind,label:m.title,description:`${dt(m.startMinute)}-${dt(m.endMinute)}`})),{value:"custom",label:"Custom",description:"Build a different recurring window."}]})})]})},{id:"shape",eyebrow:"Schedule",title:"Define when this recurring block should exist",description:"Weekdays and times describe the recurring pattern. Optional start and end dates bound when the template is active.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Block title",children:e.jsx(P,{value:c.title,onChange:m=>A({title:m.target.value}),placeholder:"Main Activity"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.startMinute,onChange:m=>A({startMinute:Number(m.target.value)||0})})}),e.jsx(j,{label:"End minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.endMinute,onChange:m=>A({endMinute:Number(m.target.value)||0})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start date",children:e.jsx(P,{type:"date",value:ht(c.startsOn),onChange:m=>A({startsOn:m.target.value.trim()||null})})}),e.jsx(j,{label:"End date",children:e.jsx(P,{type:"date",value:ht(c.endsOn),onChange:m=>A({endsOn:m.target.value.trim()||null})})})]}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Leave the end date empty to keep repeating indefinitely. Holiday blocks work well with all seven weekdays and `0-1440`, and they still carry AP load because leisure and holiday time are real activities."}),e.jsx(j,{label:"Weekdays",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ja.map((m,n)=>{const v=c.weekDays.includes(n);return e.jsx("button",{type:"button",onClick:()=>A({weekDays:v?c.weekDays.filter(l=>l!==n):[...c.weekDays,n].sort((l,$)=>l-$)}),className:`rounded-full px-3 py-2 text-sm transition ${v?"bg-[var(--ui-accent-soft)] text-[var(--primary)] ring-1 ring-[color-mix(in_srgb,var(--primary)_24%,transparent)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,children:m},m)})})})]})},{id:"policy",eyebrow:"Policy",title:"Tell Forge whether this block allows or blocks work",description:"Use blocked mode for time that should normally stop optional work. Use allowed mode for protected focus windows.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Work effect",children:e.jsx(be,{value:c.blockingState,onChange:m=>A({blockingState:m}),options:[{value:"blocked",label:"Blocks work",description:"Starting blocked tasks should require an explicit override."},{value:"allowed",label:"Allows work",description:"Use this for protected windows where the right tasks should fit."}]})}),e.jsx(j,{label:"Color",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("input",{className:"h-10 w-12 rounded-lg border border-[var(--ui-border-subtle)] bg-transparent",type:"color",value:c.color,onChange:m=>A({color:m.target.value})}),e.jsx(P,{className:"border-none bg-transparent px-0 py-0",value:c.color,onChange:m=>A({color:m.target.value})})]})})]})}],[]);return e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:"Calendar",title:N?"Edit work block":"Create a work block",description:N?"Adjust the recurring pattern, date bounds, or work policy for this block.":"Build recurring half-day, holiday, or custom blocks so Forge can understand when work should be protected or blocked.",value:x,onChange:y,draftPersistenceKey:h?`calendar.work-block.${h.id}`:"calendar.work-block.new",steps:E,submitLabel:N?"Save changes":"Save work block",pending:b,pendingLabel:N?"Saving changes":"Saving",error:f,onSubmit:async()=>{if(!x.title.trim()){u("Give the block a title so it stays readable in the calendar.");return}if(x.weekDays.length===0){u("Select at least one weekday for the recurring block.");return}if(x.endMinute<=x.startMinute){u("The end minute needs to be later than the start minute.");return}if(x.startsOn&&x.endsOn&&x.endsOn<x.startsOn){u("The end date needs to be on or after the start date.");return}try{u(null),await d({...x,title:x.title.trim()}),s(!1)}catch(c){u(c instanceof Error?c.message:"Forge could not save this work block.")}}})}const Ne=Jt(a=>({entry:null,setEntry:s=>a({entry:s}),clear:()=>a({entry:null}),completePaste:()=>a(s=>{var d;return{entry:((d=s.entry)==null?void 0:d.mode)==="cut"?null:s.entry}})}));function Ea(a){const s=new Date(a);s.setUTCHours(9,0,0,0);const d=new Date(s.getTime()+3600*1e3);return{startAt:s.toISOString(),endAt:d.toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:"busy"}}function xt(a){var y;const s=Math.max(60,Math.floor((Date.parse(a.endsAt)-Date.parse(a.startsAt))/1e3)),d=((y=Ge().find(f=>f.key===a.activityPresetKey))==null?void 0:y.defaultRateApPerHour)??100/24,b=a.customSustainRateApPerHour??d,h=Number((s/3600*b).toFixed(2)),x=new Date().toISOString();return{id:`preview_${a.entityType}_${a.entityId}`,profileKey:`${String(a.entityType)}_${a.entityId}`,title:a.title,entityType:a.entityType,mode:"container",startupAp:0,totalCostAp:h,expectedDurationSeconds:s,sustainRateApPerHour:b,demandWeights:{activation:.1,focus:.35,vigor:.1,composure:.15,flow:.3},doubleCountPolicy:"container_only",sourceMethod:a.customSustainRateApPerHour!==null&&a.customSustainRateApPerHour!==void 0?"manual":a.activityPresetKey?"seeded":"inferred",costBand:b>=10?"standard":"light",recoveryEffect:0,metadata:{activityPresetKey:a.activityPresetKey??null,customSustainRateApPerHour:a.customSustainRateApPerHour??null},createdAt:x,updatedAt:x}}function yt(a){const s=typeof a.location=="string"?a.location:"",d=a.place??{label:s,address:"",timezone:"",latitude:null,longitude:null,source:"",externalPlaceId:""};return{...a,place:{label:d.label||s,address:d.address??"",timezone:d.timezone??"",latitude:d.latitude??null,longitude:d.longitude??null,source:d.source??"",externalPlaceId:d.externalPlaceId??""}}}function bt(a,s){const d=new Date(a.startAt),h=new Date(a.endAt).getTime()-d.getTime(),x=new Date(s);x.setUTCHours(d.getUTCHours(),d.getUTCMinutes(),0,0);const y=new Date(x.getTime()+h);return{startAt:x.toISOString(),endAt:y.toISOString()}}function ft(a){return{type:"calendar_event",eventId:a.id,title:a.title,description:a.description,location:a.location,startAt:a.startAt,endAt:a.endAt,timezone:a.timezone,availability:a.availability,preferredCalendarId:a.calendarId,categories:a.categories,links:a.links.map(s=>({entityType:s.entityType,entityId:s.entityId,relationshipType:s.relationshipType}))}}function Fa(a){switch(a){case"apple":return"Apple";case"google":return"Google";case"caldav":return"CalDAV";case"native":return"Forge";default:return"Derived"}}function Ma(a,s){var d;if(a.calendarId){const b=(d=s.get(a.calendarId))==null?void 0:d.trim();if(b)return b}return a.originType==="native"?"Forge only":Fa(a.originType)}function kt(a){switch(a){case"main_activity":return"Main activity";case"secondary_activity":return"Secondary activity";case"third_activity":return"Third activity";case"rest":return"Rest";case"holiday":return"Holiday";default:return"Custom"}}function wt(a){return a.startsOn&&a.endsOn?`${a.startsOn} to ${a.endsOn}`:a.startsOn?`From ${a.startsOn}`:a.endsOn?`Until ${a.endsOn}`:"Repeats with no end date"}function er(){var Ve,et,tt,at,rt;const a=Wt(),[s,d]=Qt(),b=ra(),h=Array.isArray(b.selectedUserIds)?b.selectedUserIds:[],x=Ia(h),y=Vt(),f=Ne(t=>t.entry),u=Ne(t=>t.setEntry),N=Ne(t=>t.clear),E=Ne(t=>t.completePaste),[c,A]=g.useState(()=>$e()),[m,n]=g.useState(null),[v,l]=g.useState(null),[$,M]=g.useState(!1),[L,R]=g.useState(null),[te,ue]=g.useState(!1),[Ce,ae]=g.useState(!1),[Y,me]=g.useState(null),[Ct,re]=g.useState(!1),[Te,ie]=g.useState(null),[se,Ie]=g.useState(null),pe=g.useMemo(()=>Ca(),[]),[Tt,ne]=g.useState(null),[w,ge]=g.useState(null),[Pe,K]=g.useState(null),fe=s.get("timeboxId"),H=g.useMemo(()=>{const t=c.toISOString(),i=Le(c,7).toISOString();return{from:t,to:i}},[c]),X=ot({queryKey:["forge-calendar-overview",H.from,H.to,...h],queryFn:()=>ya({...H,userIds:h})}),B=ot({queryKey:["forge-life-force",...h],queryFn:()=>ba(h)}),_=["forge-calendar-overview",H.from,H.to,...h],ke=t=>{if(t.deletedAt)return!1;const i=new Date(t.startAt).getTime();return i>=new Date(H.from).getTime()&&i<new Date(H.to).getTime()},ve=t=>{y.setQueryData(_,i=>i&&t(i))},F=async()=>{await Promise.all([y.invalidateQueries({queryKey:["forge-calendar-overview"]}),va(y),y.invalidateQueries({queryKey:["task-context"]}),y.invalidateQueries({queryKey:["project-board"]})])},Ye=z({mutationFn:t=>pa({...t,userId:t.userId??x}),onSuccess:F}),Xe=z({mutationFn:({templateId:t,patch:i})=>ga(t,i),onSuccess:F}),De=z({mutationFn:ma,onSuccess:F}),It=z({mutationFn:t=>xa({...t,userId:x}),onSuccess:F}),Pt=z({mutationFn:({timeboxId:t,startsAt:i,endsAt:o})=>lt(t,{startsAt:i,endsAt:o}),onSuccess:F}),Dt=z({mutationFn:({timeboxId:t,patch:i})=>lt(t,i),onSuccess:F}),Ot=z({mutationFn:ha,onSuccess:async()=>{me(null),ae(!1),await F()}}),we=z({mutationFn:t=>da({...t,userId:t.userId??x}),onMutate:async t=>{var p,T,U,W,oe,V,D;K({tone:"saving",message:"Saving event changes in the background…"}),await y.cancelQueries({queryKey:_});const i=y.getQueryData(_),o=(i==null?void 0:i.calendar.calendars.find(I=>I.canWrite&&I.selectedForSync))??(i==null?void 0:i.calendar.calendars.find(I=>I.canWrite))??null,C=new Date().toISOString(),O=`calendar_event_optimistic_${Date.now()}`,r={id:O,connectionId:(o==null?void 0:o.connectionId)??null,calendarId:t.preferredCalendarId===void 0?(o==null?void 0:o.id)??null:t.preferredCalendarId,remoteId:null,ownership:"forge",originType:"native",status:"confirmed",title:t.title,description:t.description??"",location:t.location??"",place:{label:((p=t.place)==null?void 0:p.label)??t.location??"",address:((T=t.place)==null?void 0:T.address)??"",timezone:((U=t.place)==null?void 0:U.timezone)??t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",latitude:((W=t.place)==null?void 0:W.latitude)??null,longitude:((oe=t.place)==null?void 0:oe.longitude)??null,source:((V=t.place)==null?void 0:V.source)??"forge",externalPlaceId:((D=t.place)==null?void 0:D.externalPlaceId)??""},startAt:t.startAt,endAt:t.endAt,timezone:t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",isAllDay:t.isAllDay??!1,availability:t.availability??"busy",eventType:t.eventType??"general",categories:t.categories??[],sourceMappings:[],links:(t.links??[]).map((I,Q)=>({id:`calendar_event_link_optimistic_${Date.now()}_${Q}`,entityType:I.entityType,entityId:I.entityId,relationshipType:I.relationshipType??"context",createdAt:C,updatedAt:C})),actionProfile:xt({entityType:"calendar_event",entityId:O,title:t.title,startsAt:t.startAt,endsAt:t.endAt,activityPresetKey:t.activityPresetKey??null,customSustainRateApPerHour:t.customSustainRateApPerHour??null}),remoteUpdatedAt:null,deletedAt:null,createdAt:C,updatedAt:C};return i&&ke(r)&&ve(I=>({...I,calendar:{...I.calendar,events:[r,...I.calendar.events]}})),{previous:i,optimisticEventId:r.id}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t},i,o)=>{K(null),ve(C=>({...C,calendar:{...C.calendar,events:(ke(t)?[t,...C.calendar.events.filter(O=>O.id!==(o==null?void 0:o.optimisticEventId))]:C.calendar.events.filter(O=>O.id!==(o==null?void 0:o.optimisticEventId))).filter((O,r,p)=>p.findIndex(T=>T.id===O.id)===r)}}))},onSettled:F}),J=z({mutationFn:({eventId:t,patch:i})=>ca(t,i),onMutate:async({eventId:t,patch:i})=>{K({tone:"saving",message:"Saving event changes in the background…"}),await y.cancelQueries({queryKey:_});const o=y.getQueryData(_);return o&&ve(C=>{var T,U,W,oe,V;const O=C.calendar.events.find(D=>D.id===t);if(!O)return C;const r=yt(O),p={...r,...i,place:i.place?{...r.place,...i.place}:r.place,calendarId:i.preferredCalendarId===void 0?r.calendarId:i.preferredCalendarId,links:((T=i.links)==null?void 0:T.map((D,I)=>{var Q,Se;return{id:((Q=r.links[I])==null?void 0:Q.id)??`calendar_event_link_optimistic_${Date.now()}_${I}`,entityType:D.entityType,entityId:D.entityId,relationshipType:D.relationshipType??"context",createdAt:((Se=r.links[I])==null?void 0:Se.createdAt)??r.createdAt,updatedAt:new Date().toISOString()}}))??r.links,actionProfile:xt({entityType:"calendar_event",entityId:t,title:i.title??r.title,startsAt:i.startAt??r.startAt,endsAt:i.endAt??r.endAt,activityPresetKey:i.activityPresetKey===void 0?(W=(U=r.actionProfile)==null?void 0:U.metadata)==null?void 0:W.activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour===void 0?typeof((V=(oe=r.actionProfile)==null?void 0:oe.metadata)==null?void 0:V.customSustainRateApPerHour)=="number"?r.actionProfile.metadata.customSustainRateApPerHour:null:i.customSustainRateApPerHour}),updatedAt:new Date().toISOString()};return{...C,calendar:{...C.calendar,events:C.calendar.events.map(D=>D.id===t?p:D).filter(ke)}}}),{previous:o}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t})=>{K(null),ve(i=>({...i,calendar:{...i.calendar,events:i.calendar.events.map(o=>o.id===t.id?t:o).filter(ke)}}))},onSettled:F}),Oe=z({mutationFn:ua,onMutate:async t=>{K({tone:"saving",message:"Removing the event in the background…"}),await y.cancelQueries({queryKey:_});const i=y.getQueryData(_);return i&&ve(o=>({...o,calendar:{...o.calendar,events:o.calendar.events.filter(C=>C.id!==t)}})),{previous:i}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not delete that event."})},onSuccess:()=>{K(null)},onSettled:F}),je=(Ve=X.data)==null?void 0:Ve.calendar,Ae=g.useMemo(()=>Aa(c),[c]),k=g.useMemo(()=>je?{...je,events:je.events.map(yt)}:{generatedAt:"",providers:[],connections:[],calendars:[],events:[],workBlockTemplates:[],workBlockInstances:[],timeboxes:[]},[je]),Et=g.useMemo(()=>new Map(k.calendars.map(t=>[t.id,At(t)])),[k.calendars]),Ee=g.useMemo(()=>Ta(k.calendars,pe.calendarColors),[pe.calendarColors,k.calendars]),Ft=we.isPending||J.isPending||Oe.isPending,Mt=k.timeboxes.filter(t=>t.status==="planned"),_t=k.calendars.filter(t=>t.canWrite),he=(t,i)=>i?`${t} · ${i}`:t,Fe=[...b.snapshot.goals.map(t=>({entityType:"goal",entityId:t.id,label:t.title,subtitle:he("Goal",xe(t.user))})),...b.snapshot.projects.map(t=>({entityType:"project",entityId:t.id,label:t.title,subtitle:he("Project",xe(t.user))})),...b.snapshot.tasks.map(t=>({entityType:"task",entityId:t.id,label:t.title,subtitle:he("Task",xe(t.user))})),...b.snapshot.strategies.map(t=>({entityType:"strategy",entityId:t.id,label:t.title,subtitle:he("Strategy",xe(t.user))})),...b.snapshot.habits.map(t=>({entityType:"habit",entityId:t.id,label:t.title,subtitle:he("Habit",xe(t.user))}))],zt=g.useMemo(()=>new Map(Fe.map(t=>[`${t.entityType}:${t.entityId}`,t.label])),[Fe]),$t=k.connections.length===0?"No providers connected":`${k.connections.filter(t=>t.status==="connected").length}/${k.connections.length} healthy`,q=(f==null?void 0:f.items.filter(t=>t.type==="calendar_event"))??[];g.useEffect(()=>{if(!fe)return;const t=k.timeboxes.find(o=>o.id===fe);if(!t)return;const i=$e(new Date(t.startsAt));if(i.getTime()!==c.getTime()){A(i);return}((Y==null?void 0:Y.id)!==t.id||!Ce)&&(me(t),ae(!0))},[fe,k.timeboxes,Y==null?void 0:Y.id,Ce,c]);const Je=()=>{if(!fe)return;const t=new URLSearchParams(s);t.delete("timeboxId"),d(t,{replace:!0})},Lt=t=>{ae(t),t||(me(null),Je())},Rt=t=>{ie(null),ne(Ea(t)),re(!0)},Kt=async(t,i)=>{const o=bt({startAt:t.startAt,endAt:t.endAt},i);await J.mutateAsync({eventId:t.id,patch:o})},Ht=async t=>{if(q.length!==0){for(const i of q){const o=bt(i,t);(f==null?void 0:f.mode)==="cut"?await J.mutateAsync({eventId:i.eventId,patch:o}):await we.mutateAsync({title:i.title,description:i.description,location:i.location,startAt:o.startAt,endAt:o.endAt,timezone:i.timezone,availability:i.availability,preferredCalendarId:i.preferredCalendarId,categories:i.categories,links:i.links})}E()}},Bt=g.useMemo(()=>{if(!w)return[];if(w.kind==="day"){const i=Ae.find(o=>o.toISOString().slice(0,10)===w.dayKey);return i?[{id:"create-event",label:"Create event",description:"Open the event guide with this day already selected.",icon:le,onSelect:()=>Rt(i)},{id:"create-work-block",label:"Create work block",description:"Open the guided work-block flow while you are looking at this day.",icon:Me,onSelect:()=>{R(null),M(!0)}},{id:"paste",label:(f==null?void 0:f.mode)==="cut"?"Paste moved event":"Paste copied event",description:q.length>0?`${q.length} calendar item${q.length===1?"":"s"} ready to paste here.`:f?"The current clipboard entry does not contain calendar events.":"Copy or cut an event first, then paste it into this day.",icon:qt,disabled:q.length===0,onSelect:()=>void Ht(i)}]:[]}if(w.kind==="work-block"){const i=k.workBlockTemplates.find(o=>o.id===w.templateId);return i?[{id:"edit-work-block",label:"Edit",description:"Adjust the recurring pattern, date bounds, or work policy.",icon:le,onSelect:()=>{R(i),M(!0)}},{id:"delete-work-block",label:"Delete",description:"Remove this recurring work block from Forge.",icon:_e,tone:"danger",onSelect:()=>{(L==null?void 0:L.id)===i.id&&R(null),De.mutateAsync(i.id)}}]:[]}const t=k.events.find(i=>i.id===w.eventId);return t?[{id:"rename",label:"Quick rename",description:"Change the event title without opening the full event flow.",icon:le,onSelect:()=>Ie(t)},{id:"copy",label:"Copy",description:"Put this event on the Forge clipboard so you can paste it into another day.",icon:Zt,onSelect:()=>u({id:`clipboard_${t.id}_${Date.now()}`,mode:"copy",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[ft(t)]})},{id:"cut",label:"Cut",description:"Move this event by pasting it into another day.",icon:Gt,onSelect:()=>u({id:`clipboard_cut_${t.id}_${Date.now()}`,mode:"cut",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[ft(t)]})},{id:"delete",label:"Delete",description:"Remove the event from Forge and delete any connected remote projection.",icon:_e,tone:"danger",onSelect:()=>{(f==null?void 0:f.mode)==="cut"&&q.some(i=>i.eventId===t.id)&&N(),Oe.mutateAsync(t.id)}}]:[]},[N,q,f,Ae,Oe,De,w,k.events,k.workBlockTemplates,L,u]);return X.isLoading?e.jsx(ia,{}):X.isError||!X.data?e.jsx(sa,{eyebrow:"Calendar",error:X.error??new Error("Calendar data is unavailable"),onRetry:()=>void X.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Sa,{entityKind:"project",titleText:"Calendar",title:"Calendar",description:"See the real week first, then open guided flows for work blocks, task rules, timeboxing, and provider setup.",badge:`${k.connections.length} connection${k.connections.length===1?"":"s"}`}),(et=B.data)!=null&&et.lifeForce?e.jsxs(Z,{className:"grid gap-3 rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force today"}),e.jsxs("div",{className:"mt-2 text-3xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(B.data.lifeForce.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-[var(--ui-ink-muted)]",children:["/ ",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:[B.data.lifeForce.instantFreeApPerHour.toFixed(1)," ","AP/h"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Calendar containers now speak the same AP language as live work."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Forecast"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(B.data.lifeForce.forecastAp)," AP"]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Planned remaining"," ",ce(B.data.lifeForce.plannedRemainingAp)]})]})]}):null,e.jsxs(Z,{className:"grid gap-4 rounded-[32px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx(fa,{description:"The calendar is the priority surface here. Connected provider events, recurring work blocks, and owned task timeboxes all stay visible together.",weekStart:c,status:Pe?e.jsx("div",{className:`inline-flex max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-xs ${Pe.tone==="error"?"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":"border border-[var(--primary)]/18 bg-[var(--primary)]/12 text-[var(--primary)]"}`,children:Pe.message}):null,badges:e.jsxs(e.Fragment,{children:[(tt=B.data)!=null&&tt.lifeForce?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[Math.round(B.data.lifeForce.spentTodayAp),"/",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]}):null,Ft?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[e.jsx(st,{className:"mr-1 size-3.5 animate-spin"}),"Syncing changes"]}):null,f?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[f.mode==="cut"?"Cut":"Copied"," ·"," ",f.label]}):null]}),onPrevious:()=>A(Le(c,-7)),onCurrent:()=>A($e()),onNext:()=>A(Le(c,7))}),e.jsx("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(min(100%,17rem),1fr))] 2xl:[grid-template-columns:repeat(7,minmax(0,1fr))]",children:Ae.map(t=>{const i=t.toISOString().slice(0,10),o=k.events.filter(r=>r.startAt.slice(0,10)===i&&!r.deletedAt),C=k.workBlockInstances.filter(r=>r.dateKey===i),O=k.timeboxes.filter(r=>r.startsAt.slice(0,10)===i);return e.jsxs("div",{"data-calendar-day":i,onClick:r=>{r.target.closest("[data-calendar-item='true']")||ge({kind:"day",dayKey:i,position:{x:r.clientX,y:r.clientY}})},onDragOver:r=>{r.preventDefault()},onDrop:r=>{r.preventDefault();const p=r.dataTransfer.getData("text/forge-event-id")||v;if(p){const Q=k.events.find(Se=>Se.id===p);Q&&Kt(Q,t),l(null);return}const T=r.dataTransfer.getData("text/forge-timebox-id")||m;if(!T)return;const U=k.timeboxes.find(Q=>Q.id===T);if(!U)return;const W=new Date(U.startsAt),V=new Date(U.endsAt).getTime()-W.getTime(),D=new Date(t);D.setUTCHours(W.getUTCHours(),W.getUTCMinutes(),0,0);const I=new Date(D.getTime()+V);Pt.mutateAsync({timeboxId:T,startsAt:D.toISOString(),endsAt:I.toISOString()}),n(null)},className:"min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] p-3 transition hover:border-[var(--ui-border-strong)] hover:!bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx("span",{className:"min-w-0 truncate",children:Re(t)}),e.jsx("button",{type:"button","aria-label":`Open actions for ${Re(t)}`,className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:r=>{r.stopPropagation(),ge({kind:"day",dayKey:i,position:{x:r.clientX,y:r.clientY}})},children:e.jsx(ze,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-3 grid min-w-0 gap-2",children:[C.map(r=>e.jsxs("div",{"data-calendar-item":"true",className:"min-w-0 overflow-hidden rounded-[18px] px-3 py-2 text-sm text-[var(--ui-ink-strong)]",style:{backgroundColor:`${r.color}22`,border:`1px solid ${r.color}55`},children:[(()=>{const p=na(r);return e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"min-w-0 [overflow-wrap:anywhere] font-medium",children:r.title}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r.blockingState}),e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:kt(r.kind)}),p.rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--primary)]/14 text-[var(--primary)]",children:ee(p.rateApPerHour)}),e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:ce(p.totalAp)})]}):e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:"Recovery"})]})]}),e.jsx("button",{type:"button","aria-label":`Open actions for ${r.title}`,className:"rounded-full bg-[var(--ui-surface-2)] p-1.5 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:T=>{T.stopPropagation(),ge({kind:"work-block",templateId:r.templateId,position:{x:T.clientX,y:T.clientY}})},children:e.jsx(ze,{className:"size-4"})})]})})(),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[new Date(r.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.jsx("div",{className:"mt-2 text-xs text-[var(--ui-ink-muted)]",children:wt(k.workBlockTemplates.find(p=>p.id===r.templateId)??{id:r.templateId,title:r.title,kind:r.kind,color:r.color,startsOn:null,endsOn:null,blockingState:r.blockingState,createdAt:r.createdAt,updatedAt:r.updatedAt})})]},r.id)),o.map(r=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:p=>{l(r.id),p.dataTransfer.setData("text/forge-event-id",r.id)},onClick:p=>{p.stopPropagation(),ie(r),ne(null),re(!0)},className:`min-w-0 cursor-move overflow-hidden rounded-[18px] px-3 py-2 text-left text-sm text-[var(--ui-ink-strong)] transition ${pe.useCalendarColors?"hover:brightness-110":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:shadow-[var(--ui-shadow-soft)]"}`,style:pe.useCalendarColors?{backgroundColor:`${(r.calendarId?Ee[r.calendarId]:null)??ct(`origin:${r.originType}`)}1f`,border:`1px solid ${(r.calendarId?Ee[r.calendarId]:null)??ct(`origin:${r.originType}`)}55`}:void 0,children:[(ye(r),e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 [overflow-wrap:anywhere] font-medium",children:r.title}),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[new Date(r.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.jsx("button",{type:"button","aria-label":`Open quick actions for ${r.title}`,className:"rounded-full bg-[var(--ui-surface-2)] p-1.5 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:p=>{p.stopPropagation(),ge({kind:"event",eventId:r.id,position:{x:p.clientX,y:p.clientY}})},children:e.jsx(ze,{className:"size-4"})})})]})),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"max-w-full bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:Ma(r,Et)}),ye(r).rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(ye(r).rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:ce(ye(r).totalAp)})]}):null,r.calendarId&&pe.useCalendarColors?e.jsx("span",{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:Ee[r.calendarId]}}):null]}),r.place.address||r.place.timezone?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-muted)]",children:[r.place.address||r.location,r.place.address&&r.place.timezone?" · ":"",r.place.timezone]}):null,r.links.length>0?e.jsx("div",{className:"mt-2 flex min-w-0 flex-wrap gap-1.5",children:r.links.slice(0,3).map(p=>{const T=jt(p.entityType);return T?e.jsx(Qe,{kind:T,label:zt.get(`${p.entityType}:${p.entityId}`)??p.entityType,compact:!0,gradient:!1},p.id):e.jsx(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:p.entityType},p.id)})}):null]},r.id)),O.map(r=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:p=>{n(r.id),p.dataTransfer.setData("text/forge-timebox-id",r.id)},onClick:()=>{me(r),ae(!0)},className:"min-w-0 cursor-move overflow-hidden rounded-[18px] border border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] px-3 py-2 text-left text-sm text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)] transition hover:border-[color-mix(in_srgb,var(--primary)_42%,var(--ui-border-strong)_58%)] hover:bg-[var(--ui-accent-soft-hover)]",children:[(()=>{const p=oa(r);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex min-w-0 items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-5 text-[var(--ui-ink-strong)]",children:r.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[var(--ui-ink-soft)]",children:[e.jsx(Yt,{className:"size-3.5 shrink-0"}),new Date(r.startsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:r.status}),e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(p.rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:ce(p.totalAp)})]})]})})(),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),me(r),ae(!0)},className:"rounded-[999px] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Edit"}),e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),a(`/tasks/${r.taskId}`)},className:"rounded-[999px] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open task"})]})]},r.id)),C.length===0&&o.length===0&&O.length===0?e.jsx("div",{className:"min-h-[10rem] rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-4 text-sm leading-8 text-[var(--ui-ink-muted)]",children:"Nothing scheduled here yet. Click inside this day to create, block, or paste."}):null]})]},i)})})]}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(le,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Create event"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add a native Forge event with linked context."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Create a real calendar event even with no provider connected, then project it remotely whenever you choose."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),ie(null),ne(null),re(!0)},children:[e.jsx(le,{className:"size-4"}),"Open event guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Me,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Create work block"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Block main activity or protect creative windows."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Open the guided flow to create half-day presets, holidays, or custom recurring work blocks."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),M(!0)},children:[e.jsx(Me,{className:"size-4"}),"Open work-block guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(We,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Plan timebox"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Let Forge recommend valid upcoming slots."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Choose a task, review the suggested windows, and schedule directly into the calendar."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>ae(!0),children:[e.jsx(We,{className:"size-4"}),"Open planning guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(nt,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Manage provider settings"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:$t})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Provider connections and setup instructions now live in Settings so the calendar view can stay focused on the week."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar"),children:[e.jsx(Xt,{className:"size-4"}),"Open calendar settings"]}),e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar?intent=connect"),children:[e.jsx(nt,{className:"size-4"}),"Connect provider"]})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"This week"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Quick status for the currently visible week."})]}),e.jsxs(G,{variant:"secondary",onClick:()=>void X.refetch(),children:[e.jsx(st,{className:"size-4"}),"Refresh view"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Provider events"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:k.events.length})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Work blocks"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:k.workBlockInstances.length})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Planned timeboxes"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:Mt.length})]})]})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Guided actions"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>ue(!0),className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4 text-left transition hover:border-[var(--ui-border-strong)] hover:!bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Adjust task blocking rules"}),e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:"Guided"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Decide which work blocks, calendar conditions, and event keywords should block or allow a task."})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Active templates"}),e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:k.workBlockTemplates.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[k.workBlockTemplates.slice(0,4).map(t=>e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[kt(t.kind)," ·"," ",t.weekDays.length," day",t.weekDays.length===1?"":"s"," ·"," ",t.blockingState]}),e.jsx("div",{className:"mt-1 text-[var(--ui-ink-muted)]",children:wt(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>{R(t),M(!0)},children:[e.jsx(le,{className:"size-3.5"}),"Edit"]}),e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>void De.mutateAsync(t.id),children:[e.jsx(_e,{className:"size-3.5"}),"Delete"]})]})]},t.id)),k.workBlockTemplates.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No recurring templates yet. Open the work-block guide to create the first one."}):null]})]})]})]})]})]}),e.jsx(Oa,{open:$,onOpenChange:t=>{M(t),t||R(null)},pending:Ye.isPending||Xe.isPending,template:L,onSubmit:async t=>{if(L){await Xe.mutateAsync({templateId:L.id,patch:t});return}await Ye.mutateAsync(t)}}),e.jsx(ka,{open:te,onOpenChange:ue,tasks:b.snapshot.tasks,onSave:async({taskId:t,schedulingRules:i,plannedDurationSeconds:o})=>{await la(t,{schedulingRules:i,plannedDurationSeconds:o}),await b.refresh(),await F(),await y.invalidateQueries({queryKey:["task-context",t]})}}),e.jsx(wa,{open:Ce,onOpenChange:Lt,tasks:b.snapshot.tasks,editingTimebox:Y,from:H.from,to:H.to,onCreateTimebox:async t=>{await It.mutateAsync(t)},onUpdateTimebox:async(t,i)=>{await Dt.mutateAsync({timeboxId:t,patch:i})},onDeleteTimebox:async t=>{await Ot.mutateAsync(t),Je()}}),e.jsx(Pa,{open:Ct,onOpenChange:t=>{re(t),t||(ie(null),ne(null))},writableCalendars:_t,linkOptions:Fe,event:Te,seed:Tt??void 0,onSubmit:async t=>{if(Te){const i=Te.id;re(!1),ie(null),ne(null),J.mutateAsync({eventId:i,patch:t}).catch(()=>{});return}else{re(!1),ie(null),ne(null),we.mutateAsync(t).catch(()=>{});return}},pending:we.isPending||J.isPending}),e.jsx(Da,{open:se!==null,onOpenChange:t=>{t||Ie(null)},initialTitle:(se==null?void 0:se.title)??"",pending:J.isPending,onSubmit:async t=>{if(!se)return;const i=se.id;Ie(null),J.mutateAsync({eventId:i,patch:{title:t}}).catch(()=>{})}}),e.jsx(Na,{open:w!==null,title:(w==null?void 0:w.kind)==="event"?((at=k.events.find(t=>t.id===w.eventId))==null?void 0:at.title)??"Event actions":(w==null?void 0:w.kind)==="work-block"?((rt=k.workBlockTemplates.find(t=>t.id===w.templateId))==null?void 0:rt.title)??"Work block actions":(w==null?void 0:w.kind)==="day"?Re(Ae.find(t=>t.toISOString().slice(0,10)===w.dayKey)??c):"Calendar actions",subtitle:(w==null?void 0:w.kind)==="day"?"Choose what to create or paste into this day.":(w==null?void 0:w.kind)==="work-block"?"Edit or remove this recurring work block.":f?`Clipboard ready: ${f.label}`:"Quick calendar event actions.",items:Bt,position:(w==null?void 0:w.position)??null,onClose:()=>ge(null)})]})}export{er as CalendarPage};
1
+ import{r as g,j as e,aV as it,aG as We,c3 as Ut,b7 as Wt,bZ as Qt,c4 as le,c5 as Me,c6 as qt,c7 as _e,c8 as Zt,c9 as Gt,bA as st,ca as ze,bv as Yt,c1 as nt,b4 as Xt}from"./vendor-B7FKSwHK.js";import{w as Jt,j as Vt,i as ot,k as z}from"./state-BFyKSULP.js";import{F as j,a as fe,Q as Ze}from"./question-flow-dialog-yMYVk998.js";import{E as ea}from"./entity-link-multiselect-BfDAROHB.js";import{g as jt,b as Qe,I as P,T as ta,x as ye,j as S,y as ee,z as ce,A as Ge,D as At,F as St,G as Nt,H as aa,d as ra,S as ia,e as sa,C as Z,J as na,K as oa,B as G,M as la,N as da,O as ca,P as ua,Q as ma,R as lt,U as pa,V as ga,i as va,W as ha,X as xa,Y as ya,Z as fa}from"./index-gmPaoLN-.js";import{C as ba}from"./calendar-week-toolbar-DXFkMkbq.js";import{T as ka,a as wa}from"./timebox-planning-dialog-C6h0Hp71.js";import{W as qe,m as dt,a as ja,s as $e,b as Le,c as Aa,f as Re}from"./calendar-ui-Cy1XRwzV.js";import{P as Sa}from"./page-hero-U603l9rQ.js";import{F as Na}from"./floating-action-menu-BUs382px.js";import{r as Ca,b as Ta,g as ct}from"./calendar-display-preferences-Cid-2RnL.js";import{g as Ia,f as xe}from"./user-ownership-DJGl4rAj.js";import"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";import"./scheduling-rules-editor-De72IUax.js";const ut="rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",mt="bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",Ke="rounded-[22px] border px-4 py-4 text-left transition",He="border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]",Be="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]";function pt(a,s){const d=new Date(a);return Number.isNaN(d.getTime())?s:d.toISOString()}function de(a){const s=new Date(a);return new Date(s.getTime()-s.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function gt(a,s){var x,y,b,u,N;const d=new Date,f=new Date(d.getTime()+30*6e4),h=new Date(f.getTime()+60*6e4);return{title:(s==null?void 0:s.title)??(a==null?void 0:a.title)??"",description:(s==null?void 0:s.description)??(a==null?void 0:a.description)??"",location:(s==null?void 0:s.location)??(a==null?void 0:a.location)??"",placeAddress:((x=s==null?void 0:s.place)==null?void 0:x.address)??((y=a==null?void 0:a.place)==null?void 0:y.address)??"",placeTimezone:((b=s==null?void 0:s.place)==null?void 0:b.timezone)??((u=a==null?void 0:a.place)==null?void 0:u.timezone)??"",startAtLocal:a?de(a.startAt):s!=null&&s.startAt?de(s.startAt):de(f.toISOString()),endAtLocal:a?de(a.endAt):s!=null&&s.endAt?de(s.endAt):de(h.toISOString()),timezone:(s==null?void 0:s.timezone)??(a==null?void 0:a.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:(s==null?void 0:s.availability)??(a==null?void 0:a.availability)??"busy",activityPresetKey:Nt(a==null?void 0:a.actionProfile),customSustainRateApPerHour:St(a==null?void 0:a.actionProfile),preferredCalendarId:s&&"preferredCalendarId"in s?s.preferredCalendarId:(a==null?void 0:a.calendarId)??void 0,categoriesText:((N=s==null?void 0:s.categories)==null?void 0:N.join(", "))??(a==null?void 0:a.categories.join(", "))??"",linkQuery:"",links:(s==null?void 0:s.links)??(a==null?void 0:a.links.map(E=>({entityType:E.entityType,entityId:E.entityId,relationshipType:E.relationshipType,label:`${E.entityType.replaceAll("_"," ")} · ${E.entityId}`})))??[]}}function Pa({open:a,onOpenChange:s,writableCalendars:d,linkOptions:f,event:h,seed:x,onSubmit:y,pending:b=!1}){const[u,N]=g.useState(()=>gt(h,x)),[E,c]=g.useState(null);g.useEffect(()=>{a&&(N(gt(h,x)),c(null))},[h,a,x]);const A=g.useMemo(()=>f.map(n=>{const v=jt(n.entityType);return{value:`${n.entityType}:${n.entityId}`,label:n.label,description:n.subtitle,searchText:`${n.label} ${n.subtitle} ${n.entityType}`,kind:v??void 0,menuBadge:v?e.jsx(Qe,{kind:v,label:n.label,compact:!0,gradient:!1}):void 0,badge:v?e.jsx(Qe,{kind:v,label:n.label,compact:!0}):void 0}}),[f]),m=g.useMemo(()=>[{id:"identity",eyebrow:"Event",title:h?"Refine the Forge event":"Create a Forge calendar event",description:"This event belongs to Forge first. If you choose a writable calendar, Forge will also project it to the connected provider.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(j,{label:"Title",children:e.jsx(P,{value:n.title,onChange:l=>v({title:l.target.value}),placeholder:"Weekly research supervision"})}),e.jsx(j,{label:"Description",children:e.jsx(ta,{value:n.description,onChange:l=>v({description:l.target.value}),placeholder:"Agenda, context, or outcomes you want this event to carry."})}),e.jsx(j,{label:"Location",children:e.jsx(P,{value:n.location,onChange:l=>v({location:l.target.value}),placeholder:"Clinic room 2 or Zoom"})}),e.jsx(j,{label:"Place address",children:e.jsx(P,{value:n.placeAddress,onChange:l=>v({placeAddress:l.target.value}),placeholder:"Bahnhofstrasse 10, Zurich"})}),e.jsx(j,{label:"Place timezone",children:e.jsx(P,{value:n.placeTimezone,onChange:l=>v({placeTimezone:l.target.value}),placeholder:"Europe/Zurich"})})]})},{id:"timing",eyebrow:"Timing",title:"Set the time and visibility",description:"Forge stores the real event window, timezone, and whether it should behave like a busy or free slot for scheduling rules.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[(()=>{const l=new Date().toISOString(),$=new Date(Date.now()+3600*1e3).toISOString(),M=ye({title:n.title,availability:n.availability,activityPresetKey:n.activityPresetKey,customSustainRateApPerHour:n.customSustainRateApPerHour,startAt:pt(n.startAtLocal,l),endAt:pt(n.endAtLocal,$)});return e.jsxs("div",{className:`${ut} p-4`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:mt,children:ee(M.rateApPerHour)}),e.jsx(S,{className:mt,children:ce(M.totalAp)})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Availability controls whether the event blocks planning. The activity profile controls AP drain, and you can override it with a custom AP per hour."})]})})(),e.jsx(j,{label:"Activity profile",children:e.jsx(fe,{value:n.activityPresetKey??(n.availability==="busy"?"meeting":"light_context"),columns:3,onChange:l=>v({activityPresetKey:l}),options:Ge().filter(l=>l.key!=="task_inherited").map(l=>({value:l.key,label:l.label,description:`${ee(l.defaultRateApPerHour)} · ${l.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:n.customSustainRateApPerHour??"",onChange:l=>v({customSustainRateApPerHour:l.target.value.trim()===""?null:Number(l.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Starts",children:e.jsx(P,{type:"datetime-local",value:n.startAtLocal,onChange:l=>v({startAtLocal:l.target.value})})}),e.jsx(j,{label:"Ends",children:e.jsx(P,{type:"datetime-local",value:n.endAtLocal,onChange:l=>v({endAtLocal:l.target.value})})})]}),e.jsx(j,{label:"Timezone",children:e.jsx(P,{value:n.timezone,onChange:l=>v({timezone:l.target.value}),placeholder:"Europe/Zurich"})}),e.jsx(j,{label:"Availability",children:e.jsx(fe,{value:n.availability,onChange:l=>v({availability:l}),options:[{value:"busy",label:"Busy",description:"This event should block timebox recommendations and rule checks."},{value:"free",label:"Free",description:"This event stays visible in the calendar without blocking work."}]})})]})},{id:"links",eyebrow:"Meaning",title:"Connect the event to Forge entities",description:"Attach this event to strategies, goals, projects, tasks, or habits so the calendar carries multi-user operating context instead of staying isolated.",render:(n,v)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(j,{label:"Search Forge entities",description:"Search across human and bot-owned entities; the linked records use the same icon, color, and owner system as the rest of Forge.",children:e.jsx(ea,{options:A,selectedValues:n.links.map(l=>`${l.entityType}:${l.entityId}`),onChange:l=>{v({links:l.map($=>{const[M,...L]=$.split(":"),R=L.join(":"),te=f.find(ue=>ue.entityType===M&&ue.entityId===R);return te?{entityType:te.entityType,entityId:te.entityId,relationshipType:"context",label:te.label}:null}).filter($=>$!==null)})},placeholder:"Search strategies, goals, projects, tasks, habits, human, or bot owners",emptyMessage:"No matching Forge entities found."})})})},{id:"projection",eyebrow:"Projection",title:"Choose where this event should live remotely",description:"You can keep the event local to Forge, or choose a writable connected calendar so Forge also keeps a synced remote copy.",render:(n,v)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[d.length>0?e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:void 0}),className:`${Ke} ${n.preferredCalendarId===void 0?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(it,{className:"size-4"}),"Default synced calendar"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Let Forge use the default writable connected calendar automatically."})]}):null,e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:null}),className:`${Ke} ${n.preferredCalendarId===null?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(We,{className:"size-4"}),"Forge only"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the event in Forge without creating a remote provider copy yet."})]}),d.map(l=>e.jsxs("button",{type:"button",onClick:()=>v({preferredCalendarId:l.id}),className:`${Ke} ${n.preferredCalendarId===l.id?He:Be}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(it,{className:"size-4"}),At(l)]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:l.description||`${l.timezone} · writable`})]},l.id))]}),e.jsxs("div",{className:`${ut} grid gap-2 p-4 text-sm text-[var(--ui-ink-medium)]`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(Ut,{className:"size-4 text-[var(--primary)]"}),"Categories and filtering"]}),e.jsx(P,{value:n.categoriesText,onChange:l=>v({categoriesText:l.target.value}),placeholder:"meeting, clinic, research"})]})]})}],[h,f,A,d]);return e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:h?"Edit event":"New event",title:h?"Edit calendar event":"Create calendar event",description:"Forge-owned events can stay local or publish to a connected provider calendar.",value:u,onChange:N,draftPersistenceKey:h?`calendar.event.${h.id}`:"calendar.event.new",steps:m,onSubmit:async()=>{if(!u.title.trim()){c("Add an event title before saving.");return}if(!u.startAtLocal||!u.endAtLocal){c("Set both the start and end time before saving.");return}if(new Date(u.endAtLocal).getTime()<=new Date(u.startAtLocal).getTime()){c("The event end time must be after the start time.");return}c(null),await y({title:u.title.trim(),description:u.description.trim(),location:u.location.trim(),place:{label:u.location.trim(),address:u.placeAddress.trim(),timezone:u.placeTimezone.trim(),latitude:null,longitude:null,source:u.placeAddress.trim()?"manual":"",externalPlaceId:""},startAt:new Date(u.startAtLocal).toISOString(),endAt:new Date(u.endAtLocal).toISOString(),timezone:u.timezone.trim()||"UTC",availability:u.availability,activityPresetKey:u.activityPresetKey,customSustainRateApPerHour:u.customSustainRateApPerHour,categories:u.categoriesText.split(",").map(n=>n.trim()).filter(Boolean),links:u.links.map(n=>({entityType:n.entityType,entityId:n.entityId,relationshipType:n.relationshipType})),...u.preferredCalendarId!==void 0?{preferredCalendarId:u.preferredCalendarId}:{}})},submitLabel:h?"Save event":"Create event",pending:b,pendingLabel:h?"Saving":"Creating",error:E})}function Da({open:a,onOpenChange:s,initialTitle:d,pending:f=!1,onSubmit:h}){const[x,y]=g.useState(d),[b,u]=g.useState(null);return g.useEffect(()=>{a&&(y(d),u(null))},[d,a]),e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:"Calendar",title:"Quick rename",description:"Rename the event without reopening the full event guide.",value:{title:x},onChange:N=>y(N.title),draftPersistenceKey:`calendar.quick-rename.${d}`,steps:[{id:"rename",eyebrow:"Rename",title:"Update the event title",description:"Keep the rename fast and direct. Everything else on the event stays unchanged.",render:(N,E)=>e.jsx(j,{label:"Event title",children:e.jsx(P,{value:N.title,onChange:c=>E({title:c.target.value}),placeholder:"Weekly research supervision"})})}],submitLabel:"Save title",pending:f,pendingLabel:"Saving",error:b,onSubmit:async()=>{const N=x.trim();if(!N){u("Add a title before saving.");return}u(null),await h(N),s(!1)}})}function vt(a){if(a)return{title:a.title,kind:a.kind,color:a.color,timezone:a.timezone,weekDays:a.weekDays,startMinute:a.startMinute,endMinute:a.endMinute,startsOn:a.startsOn,endsOn:a.endsOn,blockingState:a.blockingState,activityPresetKey:Nt(a.actionProfile),customSustainRateApPerHour:St(a.actionProfile)};const s=qe[0];return{title:s.title,kind:s.kind,color:s.color,timezone:typeof Intl<"u"&&Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",weekDays:[1,2,3,4,5],startMinute:s.startMinute,endMinute:s.endMinute,startsOn:null,endsOn:null,blockingState:s.blockingState,activityPresetKey:s.kind==="main_activity"?"deep_work":s.kind==="secondary_activity"?"admin":s.kind==="holiday"?"holiday_leisure":s.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null}}function ht(a){return a??""}function Ue({draft:a}){const s=aa({kind:a.kind,startMinute:a.startMinute,endMinute:a.endMinute,activityPresetKey:a.activityPresetKey,customSustainRateApPerHour:a.customSustainRateApPerHour}),d=a.endMinute>a.startMinute?a.endMinute-a.startMinute:1440-a.startMinute+a.endMinute;return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:ee(s.rateApPerHour)}),e.jsxs(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[ce(s.totalAp)," / block"]}),e.jsxs(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[Math.round(d/60),"h ",d%60,"m"]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the default Life Force container drain for each occurrence of the block when no richer task run or timebox already covers that window."})]})}function Oa({open:a,onOpenChange:s,onSubmit:d,pending:f=!1,template:h=null}){const[x,y]=g.useState(()=>vt(h)),[b,u]=g.useState(null),N=h!==null;g.useEffect(()=>{a&&(u(null),y(vt(h)))},[a,h]);const E=g.useMemo(()=>[{id:"preset",eyebrow:"Preset",title:"Start from a recurring block that already matches the rhythm",description:"Use a preset to seed the schedule, then tune the dates and recurrence in the next step.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Activity profile",children:e.jsx(fe,{value:c.activityPresetKey??"maintenance",columns:3,onChange:m=>A({activityPresetKey:m,customSustainRateApPerHour:c.customSustainRateApPerHour}),options:Ge().filter(m=>m.key!=="task_inherited").map(m=>({value:m.key,label:m.label,description:`${ee(m.defaultRateApPerHour)} · ${m.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:c.customSustainRateApPerHour??"",onChange:m=>A({customSustainRateApPerHour:m.target.value.trim()===""?null:Number(m.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsx(j,{label:"Block type",children:e.jsx(fe,{value:c.kind,columns:3,onChange:m=>{const n=qe.find(v=>v.kind===m);if(n){const v=n.kind==="holiday"?[0,1,2,3,4,5,6]:[1,2,3,4,5];A({kind:n.kind,title:n.title,color:n.color,weekDays:v,startMinute:n.startMinute,endMinute:n.endMinute,blockingState:n.blockingState,activityPresetKey:n.kind==="main_activity"?"deep_work":n.kind==="secondary_activity"?"admin":n.kind==="holiday"?"holiday_leisure":n.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null});return}A({kind:"custom",title:"Custom block",color:"#7dd3fc",activityPresetKey:"maintenance",customSustainRateApPerHour:null})},options:[...qe.map(m=>({value:m.kind,label:m.title,description:`${dt(m.startMinute)}-${dt(m.endMinute)}`})),{value:"custom",label:"Custom",description:"Build a different recurring window."}]})})]})},{id:"shape",eyebrow:"Schedule",title:"Define when this recurring block should exist",description:"Weekdays and times describe the recurring pattern. Optional start and end dates bound when the template is active.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Block title",children:e.jsx(P,{value:c.title,onChange:m=>A({title:m.target.value}),placeholder:"Main Activity"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.startMinute,onChange:m=>A({startMinute:Number(m.target.value)||0})})}),e.jsx(j,{label:"End minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.endMinute,onChange:m=>A({endMinute:Number(m.target.value)||0})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start date",children:e.jsx(P,{type:"date",value:ht(c.startsOn),onChange:m=>A({startsOn:m.target.value.trim()||null})})}),e.jsx(j,{label:"End date",children:e.jsx(P,{type:"date",value:ht(c.endsOn),onChange:m=>A({endsOn:m.target.value.trim()||null})})})]}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Leave the end date empty to keep repeating indefinitely. Holiday blocks work well with all seven weekdays and `0-1440`, and they still carry AP load because leisure and holiday time are real activities."}),e.jsx(j,{label:"Weekdays",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ja.map((m,n)=>{const v=c.weekDays.includes(n);return e.jsx("button",{type:"button",onClick:()=>A({weekDays:v?c.weekDays.filter(l=>l!==n):[...c.weekDays,n].sort((l,$)=>l-$)}),className:`rounded-full px-3 py-2 text-sm transition ${v?"bg-[var(--ui-accent-soft)] text-[var(--primary)] ring-1 ring-[color-mix(in_srgb,var(--primary)_24%,transparent)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,children:m},m)})})})]})},{id:"policy",eyebrow:"Policy",title:"Tell Forge whether this block allows or blocks work",description:"Use blocked mode for time that should normally stop optional work. Use allowed mode for protected focus windows.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ue,{draft:c}),e.jsx(j,{label:"Work effect",children:e.jsx(fe,{value:c.blockingState,onChange:m=>A({blockingState:m}),options:[{value:"blocked",label:"Blocks work",description:"Starting blocked tasks should require an explicit override."},{value:"allowed",label:"Allows work",description:"Use this for protected windows where the right tasks should fit."}]})}),e.jsx(j,{label:"Color",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsx("input",{className:"h-10 w-12 rounded-lg border border-[var(--ui-border-subtle)] bg-transparent",type:"color",value:c.color,onChange:m=>A({color:m.target.value})}),e.jsx(P,{className:"border-none bg-transparent px-0 py-0",value:c.color,onChange:m=>A({color:m.target.value})})]})})]})}],[]);return e.jsx(Ze,{open:a,onOpenChange:s,eyebrow:"Calendar",title:N?"Edit work block":"Create a work block",description:N?"Adjust the recurring pattern, date bounds, or work policy for this block.":"Build recurring half-day, holiday, or custom blocks so Forge can understand when work should be protected or blocked.",value:x,onChange:y,draftPersistenceKey:h?`calendar.work-block.${h.id}`:"calendar.work-block.new",steps:E,submitLabel:N?"Save changes":"Save work block",pending:f,pendingLabel:N?"Saving changes":"Saving",error:b,onSubmit:async()=>{if(!x.title.trim()){u("Give the block a title so it stays readable in the calendar.");return}if(x.weekDays.length===0){u("Select at least one weekday for the recurring block.");return}if(x.endMinute<=x.startMinute){u("The end minute needs to be later than the start minute.");return}if(x.startsOn&&x.endsOn&&x.endsOn<x.startsOn){u("The end date needs to be on or after the start date.");return}try{u(null),await d({...x,title:x.title.trim()}),s(!1)}catch(c){u(c instanceof Error?c.message:"Forge could not save this work block.")}}})}const Ne=Jt(a=>({entry:null,setEntry:s=>a({entry:s}),clear:()=>a({entry:null}),completePaste:()=>a(s=>{var d;return{entry:((d=s.entry)==null?void 0:d.mode)==="cut"?null:s.entry}})}));function Ea(a){const s=new Date(a);s.setUTCHours(9,0,0,0);const d=new Date(s.getTime()+3600*1e3);return{startAt:s.toISOString(),endAt:d.toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:"busy"}}function xt(a){var y;const s=Math.max(60,Math.floor((Date.parse(a.endsAt)-Date.parse(a.startsAt))/1e3)),d=((y=Ge().find(b=>b.key===a.activityPresetKey))==null?void 0:y.defaultRateApPerHour)??100/24,f=a.customSustainRateApPerHour??d,h=Number((s/3600*f).toFixed(2)),x=new Date().toISOString();return{id:`preview_${a.entityType}_${a.entityId}`,profileKey:`${String(a.entityType)}_${a.entityId}`,title:a.title,entityType:a.entityType,mode:"container",startupAp:0,totalCostAp:h,expectedDurationSeconds:s,sustainRateApPerHour:f,demandWeights:{activation:.1,focus:.35,vigor:.1,composure:.15,flow:.3},doubleCountPolicy:"container_only",sourceMethod:a.customSustainRateApPerHour!==null&&a.customSustainRateApPerHour!==void 0?"manual":a.activityPresetKey?"seeded":"inferred",costBand:f>=10?"standard":"light",recoveryEffect:0,metadata:{activityPresetKey:a.activityPresetKey??null,customSustainRateApPerHour:a.customSustainRateApPerHour??null},createdAt:x,updatedAt:x}}function yt(a){const s=typeof a.location=="string"?a.location:"",d=a.place??{label:s,address:"",timezone:"",latitude:null,longitude:null,source:"",externalPlaceId:""};return{...a,place:{label:d.label||s,address:d.address??"",timezone:d.timezone??"",latitude:d.latitude??null,longitude:d.longitude??null,source:d.source??"",externalPlaceId:d.externalPlaceId??""}}}function ft(a,s){const d=new Date(a.startAt),h=new Date(a.endAt).getTime()-d.getTime(),x=new Date(s);x.setUTCHours(d.getUTCHours(),d.getUTCMinutes(),0,0);const y=new Date(x.getTime()+h);return{startAt:x.toISOString(),endAt:y.toISOString()}}function bt(a){return{type:"calendar_event",eventId:a.id,title:a.title,description:a.description,location:a.location,startAt:a.startAt,endAt:a.endAt,timezone:a.timezone,availability:a.availability,preferredCalendarId:a.calendarId,categories:a.categories,links:a.links.map(s=>({entityType:s.entityType,entityId:s.entityId,relationshipType:s.relationshipType}))}}function Fa(a){switch(a){case"apple":return"Apple";case"google":return"Google";case"caldav":return"CalDAV";case"native":return"Forge";default:return"Derived"}}function Ma(a,s){var d;if(a.calendarId){const f=(d=s.get(a.calendarId))==null?void 0:d.trim();if(f)return f}return a.originType==="native"?"Forge only":Fa(a.originType)}function kt(a){switch(a){case"main_activity":return"Main activity";case"secondary_activity":return"Secondary activity";case"third_activity":return"Third activity";case"rest":return"Rest";case"holiday":return"Holiday";default:return"Custom"}}function wt(a){return a.startsOn&&a.endsOn?`${a.startsOn} to ${a.endsOn}`:a.startsOn?`From ${a.startsOn}`:a.endsOn?`Until ${a.endsOn}`:"Repeats with no end date"}function er(){var Ve,et,tt,at,rt;const a=Wt(),[s,d]=Qt(),f=ra(),h=Array.isArray(f.selectedUserIds)?f.selectedUserIds:[],x=Ia(h),y=Vt(),b=Ne(t=>t.entry),u=Ne(t=>t.setEntry),N=Ne(t=>t.clear),E=Ne(t=>t.completePaste),[c,A]=g.useState(()=>$e()),[m,n]=g.useState(null),[v,l]=g.useState(null),[$,M]=g.useState(!1),[L,R]=g.useState(null),[te,ue]=g.useState(!1),[Ce,ae]=g.useState(!1),[Y,me]=g.useState(null),[Ct,re]=g.useState(!1),[Te,ie]=g.useState(null),[se,Ie]=g.useState(null),pe=g.useMemo(()=>Ca(),[]),[Tt,ne]=g.useState(null),[w,ge]=g.useState(null),[Pe,K]=g.useState(null),be=s.get("timeboxId"),H=g.useMemo(()=>{const t=c.toISOString(),i=Le(c,7).toISOString();return{from:t,to:i}},[c]),X=ot({queryKey:["forge-calendar-overview",H.from,H.to,...h],queryFn:()=>ya({...H,userIds:h})}),B=ot({queryKey:["forge-life-force",...h],queryFn:()=>fa(h)}),_=["forge-calendar-overview",H.from,H.to,...h],ke=t=>{if(t.deletedAt)return!1;const i=new Date(t.startAt).getTime();return i>=new Date(H.from).getTime()&&i<new Date(H.to).getTime()},ve=t=>{y.setQueryData(_,i=>i&&t(i))},F=async()=>{await Promise.all([y.invalidateQueries({queryKey:["forge-calendar-overview"]}),va(y),y.invalidateQueries({queryKey:["task-context"]}),y.invalidateQueries({queryKey:["project-board"]})])},Ye=z({mutationFn:t=>pa({...t,userId:t.userId??x}),onSuccess:F}),Xe=z({mutationFn:({templateId:t,patch:i})=>ga(t,i),onSuccess:F}),De=z({mutationFn:ma,onSuccess:F}),It=z({mutationFn:t=>xa({...t,userId:x}),onSuccess:F}),Pt=z({mutationFn:({timeboxId:t,startsAt:i,endsAt:o})=>lt(t,{startsAt:i,endsAt:o}),onSuccess:F}),Dt=z({mutationFn:({timeboxId:t,patch:i})=>lt(t,i),onSuccess:F}),Ot=z({mutationFn:ha,onSuccess:async()=>{me(null),ae(!1),await F()}}),we=z({mutationFn:t=>da({...t,userId:t.userId??x}),onMutate:async t=>{var p,T,U,W,oe,V,D;K({tone:"saving",message:"Saving event changes in the background…"}),await y.cancelQueries({queryKey:_});const i=y.getQueryData(_),o=(i==null?void 0:i.calendar.calendars.find(I=>I.canWrite&&I.selectedForSync))??(i==null?void 0:i.calendar.calendars.find(I=>I.canWrite))??null,C=new Date().toISOString(),O=`calendar_event_optimistic_${Date.now()}`,r={id:O,connectionId:(o==null?void 0:o.connectionId)??null,calendarId:t.preferredCalendarId===void 0?(o==null?void 0:o.id)??null:t.preferredCalendarId,remoteId:null,ownership:"forge",originType:"native",status:"confirmed",title:t.title,description:t.description??"",location:t.location??"",place:{label:((p=t.place)==null?void 0:p.label)??t.location??"",address:((T=t.place)==null?void 0:T.address)??"",timezone:((U=t.place)==null?void 0:U.timezone)??t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",latitude:((W=t.place)==null?void 0:W.latitude)??null,longitude:((oe=t.place)==null?void 0:oe.longitude)??null,source:((V=t.place)==null?void 0:V.source)??"forge",externalPlaceId:((D=t.place)==null?void 0:D.externalPlaceId)??""},startAt:t.startAt,endAt:t.endAt,timezone:t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",isAllDay:t.isAllDay??!1,availability:t.availability??"busy",eventType:t.eventType??"general",categories:t.categories??[],sourceMappings:[],links:(t.links??[]).map((I,Q)=>({id:`calendar_event_link_optimistic_${Date.now()}_${Q}`,entityType:I.entityType,entityId:I.entityId,relationshipType:I.relationshipType??"context",createdAt:C,updatedAt:C})),actionProfile:xt({entityType:"calendar_event",entityId:O,title:t.title,startsAt:t.startAt,endsAt:t.endAt,activityPresetKey:t.activityPresetKey??null,customSustainRateApPerHour:t.customSustainRateApPerHour??null}),remoteUpdatedAt:null,deletedAt:null,createdAt:C,updatedAt:C};return i&&ke(r)&&ve(I=>({...I,calendar:{...I.calendar,events:[r,...I.calendar.events]}})),{previous:i,optimisticEventId:r.id}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t},i,o)=>{K(null),ve(C=>({...C,calendar:{...C.calendar,events:(ke(t)?[t,...C.calendar.events.filter(O=>O.id!==(o==null?void 0:o.optimisticEventId))]:C.calendar.events.filter(O=>O.id!==(o==null?void 0:o.optimisticEventId))).filter((O,r,p)=>p.findIndex(T=>T.id===O.id)===r)}}))},onSettled:F}),J=z({mutationFn:({eventId:t,patch:i})=>ca(t,i),onMutate:async({eventId:t,patch:i})=>{K({tone:"saving",message:"Saving event changes in the background…"}),await y.cancelQueries({queryKey:_});const o=y.getQueryData(_);return o&&ve(C=>{var T,U,W,oe,V;const O=C.calendar.events.find(D=>D.id===t);if(!O)return C;const r=yt(O),p={...r,...i,place:i.place?{...r.place,...i.place}:r.place,calendarId:i.preferredCalendarId===void 0?r.calendarId:i.preferredCalendarId,links:((T=i.links)==null?void 0:T.map((D,I)=>{var Q,Se;return{id:((Q=r.links[I])==null?void 0:Q.id)??`calendar_event_link_optimistic_${Date.now()}_${I}`,entityType:D.entityType,entityId:D.entityId,relationshipType:D.relationshipType??"context",createdAt:((Se=r.links[I])==null?void 0:Se.createdAt)??r.createdAt,updatedAt:new Date().toISOString()}}))??r.links,actionProfile:xt({entityType:"calendar_event",entityId:t,title:i.title??r.title,startsAt:i.startAt??r.startAt,endsAt:i.endAt??r.endAt,activityPresetKey:i.activityPresetKey===void 0?(W=(U=r.actionProfile)==null?void 0:U.metadata)==null?void 0:W.activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour===void 0?typeof((V=(oe=r.actionProfile)==null?void 0:oe.metadata)==null?void 0:V.customSustainRateApPerHour)=="number"?r.actionProfile.metadata.customSustainRateApPerHour:null:i.customSustainRateApPerHour}),updatedAt:new Date().toISOString()};return{...C,calendar:{...C.calendar,events:C.calendar.events.map(D=>D.id===t?p:D).filter(ke)}}}),{previous:o}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t})=>{K(null),ve(i=>({...i,calendar:{...i.calendar,events:i.calendar.events.map(o=>o.id===t.id?t:o).filter(ke)}}))},onSettled:F}),Oe=z({mutationFn:ua,onMutate:async t=>{K({tone:"saving",message:"Removing the event in the background…"}),await y.cancelQueries({queryKey:_});const i=y.getQueryData(_);return i&&ve(o=>({...o,calendar:{...o.calendar,events:o.calendar.events.filter(C=>C.id!==t)}})),{previous:i}},onError:(t,i,o)=>{o!=null&&o.previous&&y.setQueryData(_,o.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not delete that event."})},onSuccess:()=>{K(null)},onSettled:F}),je=(Ve=X.data)==null?void 0:Ve.calendar,Ae=g.useMemo(()=>Aa(c),[c]),k=g.useMemo(()=>je?{...je,events:je.events.map(yt)}:{generatedAt:"",providers:[],connections:[],calendars:[],events:[],workBlockTemplates:[],workBlockInstances:[],timeboxes:[]},[je]),Et=g.useMemo(()=>new Map(k.calendars.map(t=>[t.id,At(t)])),[k.calendars]),Ee=g.useMemo(()=>Ta(k.calendars,pe.calendarColors),[pe.calendarColors,k.calendars]),Ft=we.isPending||J.isPending||Oe.isPending,Mt=k.timeboxes.filter(t=>t.status==="planned"),_t=k.calendars.filter(t=>t.canWrite),he=(t,i)=>i?`${t} · ${i}`:t,Fe=[...f.snapshot.goals.map(t=>({entityType:"goal",entityId:t.id,label:t.title,subtitle:he("Goal",xe(t.user))})),...f.snapshot.projects.map(t=>({entityType:"project",entityId:t.id,label:t.title,subtitle:he("Project",xe(t.user))})),...f.snapshot.tasks.map(t=>({entityType:"task",entityId:t.id,label:t.title,subtitle:he("Task",xe(t.user))})),...f.snapshot.strategies.map(t=>({entityType:"strategy",entityId:t.id,label:t.title,subtitle:he("Strategy",xe(t.user))})),...f.snapshot.habits.map(t=>({entityType:"habit",entityId:t.id,label:t.title,subtitle:he("Habit",xe(t.user))}))],zt=g.useMemo(()=>new Map(Fe.map(t=>[`${t.entityType}:${t.entityId}`,t.label])),[Fe]),$t=k.connections.length===0?"No providers connected":`${k.connections.filter(t=>t.status==="connected").length}/${k.connections.length} healthy`,q=(b==null?void 0:b.items.filter(t=>t.type==="calendar_event"))??[];g.useEffect(()=>{if(!be)return;const t=k.timeboxes.find(o=>o.id===be);if(!t)return;const i=$e(new Date(t.startsAt));if(i.getTime()!==c.getTime()){A(i);return}((Y==null?void 0:Y.id)!==t.id||!Ce)&&(me(t),ae(!0))},[be,k.timeboxes,Y==null?void 0:Y.id,Ce,c]);const Je=()=>{if(!be)return;const t=new URLSearchParams(s);t.delete("timeboxId"),d(t,{replace:!0})},Lt=t=>{ae(t),t||(me(null),Je())},Rt=t=>{ie(null),ne(Ea(t)),re(!0)},Kt=async(t,i)=>{const o=ft({startAt:t.startAt,endAt:t.endAt},i);await J.mutateAsync({eventId:t.id,patch:o})},Ht=async t=>{if(q.length!==0){for(const i of q){const o=ft(i,t);(b==null?void 0:b.mode)==="cut"?await J.mutateAsync({eventId:i.eventId,patch:o}):await we.mutateAsync({title:i.title,description:i.description,location:i.location,startAt:o.startAt,endAt:o.endAt,timezone:i.timezone,availability:i.availability,preferredCalendarId:i.preferredCalendarId,categories:i.categories,links:i.links})}E()}},Bt=g.useMemo(()=>{if(!w)return[];if(w.kind==="day"){const i=Ae.find(o=>o.toISOString().slice(0,10)===w.dayKey);return i?[{id:"create-event",label:"Create event",description:"Open the event guide with this day already selected.",icon:le,onSelect:()=>Rt(i)},{id:"create-work-block",label:"Create work block",description:"Open the guided work-block flow while you are looking at this day.",icon:Me,onSelect:()=>{R(null),M(!0)}},{id:"paste",label:(b==null?void 0:b.mode)==="cut"?"Paste moved event":"Paste copied event",description:q.length>0?`${q.length} calendar item${q.length===1?"":"s"} ready to paste here.`:b?"The current clipboard entry does not contain calendar events.":"Copy or cut an event first, then paste it into this day.",icon:qt,disabled:q.length===0,onSelect:()=>void Ht(i)}]:[]}if(w.kind==="work-block"){const i=k.workBlockTemplates.find(o=>o.id===w.templateId);return i?[{id:"edit-work-block",label:"Edit",description:"Adjust the recurring pattern, date bounds, or work policy.",icon:le,onSelect:()=>{R(i),M(!0)}},{id:"delete-work-block",label:"Delete",description:"Remove this recurring work block from Forge.",icon:_e,tone:"danger",onSelect:()=>{(L==null?void 0:L.id)===i.id&&R(null),De.mutateAsync(i.id)}}]:[]}const t=k.events.find(i=>i.id===w.eventId);return t?[{id:"rename",label:"Quick rename",description:"Change the event title without opening the full event flow.",icon:le,onSelect:()=>Ie(t)},{id:"copy",label:"Copy",description:"Put this event on the Forge clipboard so you can paste it into another day.",icon:Zt,onSelect:()=>u({id:`clipboard_${t.id}_${Date.now()}`,mode:"copy",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[bt(t)]})},{id:"cut",label:"Cut",description:"Move this event by pasting it into another day.",icon:Gt,onSelect:()=>u({id:`clipboard_cut_${t.id}_${Date.now()}`,mode:"cut",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[bt(t)]})},{id:"delete",label:"Delete",description:"Remove the event from Forge and delete any connected remote projection.",icon:_e,tone:"danger",onSelect:()=>{(b==null?void 0:b.mode)==="cut"&&q.some(i=>i.eventId===t.id)&&N(),Oe.mutateAsync(t.id)}}]:[]},[N,q,b,Ae,Oe,De,w,k.events,k.workBlockTemplates,L,u]);return X.isLoading?e.jsx(ia,{}):X.isError||!X.data?e.jsx(sa,{eyebrow:"Calendar",error:X.error??new Error("Calendar data is unavailable"),onRetry:()=>void X.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Sa,{entityKind:"project",titleText:"Calendar",title:"Calendar",description:"See the real week first, then open guided flows for work blocks, task rules, timeboxing, and provider setup.",badge:`${k.connections.length} connection${k.connections.length===1?"":"s"}`}),(et=B.data)!=null&&et.lifeForce?e.jsxs(Z,{className:"grid gap-3 rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force today"}),e.jsxs("div",{className:"mt-2 text-3xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(B.data.lifeForce.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-[var(--ui-ink-muted)]",children:["/ ",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:[B.data.lifeForce.instantFreeApPerHour.toFixed(1)," ","AP/h"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Calendar containers now speak the same AP language as live work."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Forecast"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(B.data.lifeForce.forecastAp)," AP"]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Planned remaining"," ",ce(B.data.lifeForce.plannedRemainingAp)]})]})]}):null,e.jsxs(Z,{className:"grid gap-4 rounded-[32px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx(ba,{description:"The calendar is the priority surface here. Connected provider events, recurring work blocks, and owned task timeboxes all stay visible together.",weekStart:c,status:Pe?e.jsx("div",{className:`inline-flex max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-xs ${Pe.tone==="error"?"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":"border border-[var(--primary)]/18 bg-[var(--primary)]/12 text-[var(--primary)]"}`,children:Pe.message}):null,badges:e.jsxs(e.Fragment,{children:[(tt=B.data)!=null&&tt.lifeForce?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[Math.round(B.data.lifeForce.spentTodayAp),"/",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]}):null,Ft?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[e.jsx(st,{className:"mr-1 size-3.5 animate-spin"}),"Syncing changes"]}):null,b?e.jsxs(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[b.mode==="cut"?"Cut":"Copied"," ·"," ",b.label]}):null]}),onPrevious:()=>A(Le(c,-7)),onCurrent:()=>A($e()),onNext:()=>A(Le(c,7))}),e.jsx("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(min(100%,17rem),1fr))] 2xl:[grid-template-columns:repeat(7,minmax(0,1fr))]",children:Ae.map(t=>{const i=t.toISOString().slice(0,10),o=k.events.filter(r=>r.startAt.slice(0,10)===i&&!r.deletedAt),C=k.workBlockInstances.filter(r=>r.dateKey===i),O=k.timeboxes.filter(r=>r.startsAt.slice(0,10)===i);return e.jsxs("div",{"data-calendar-day":i,onClick:r=>{r.target.closest("[data-calendar-item='true']")||ge({kind:"day",dayKey:i,position:{x:r.clientX,y:r.clientY}})},onDragOver:r=>{r.preventDefault()},onDrop:r=>{r.preventDefault();const p=r.dataTransfer.getData("text/forge-event-id")||v;if(p){const Q=k.events.find(Se=>Se.id===p);Q&&Kt(Q,t),l(null);return}const T=r.dataTransfer.getData("text/forge-timebox-id")||m;if(!T)return;const U=k.timeboxes.find(Q=>Q.id===T);if(!U)return;const W=new Date(U.startsAt),V=new Date(U.endsAt).getTime()-W.getTime(),D=new Date(t);D.setUTCHours(W.getUTCHours(),W.getUTCMinutes(),0,0);const I=new Date(D.getTime()+V);Pt.mutateAsync({timeboxId:T,startsAt:D.toISOString(),endsAt:I.toISOString()}),n(null)},className:"min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] p-3 transition hover:border-[var(--ui-border-strong)] hover:!bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx("span",{className:"min-w-0 truncate",children:Re(t)}),e.jsx("button",{type:"button","aria-label":`Open actions for ${Re(t)}`,className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:r=>{r.stopPropagation(),ge({kind:"day",dayKey:i,position:{x:r.clientX,y:r.clientY}})},children:e.jsx(ze,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-3 grid min-w-0 gap-2",children:[C.map(r=>e.jsxs("div",{"data-calendar-item":"true",className:"min-w-0 overflow-hidden rounded-[18px] px-3 py-2 text-sm text-[var(--ui-ink-strong)]",style:{backgroundColor:`${r.color}22`,border:`1px solid ${r.color}55`},children:[(()=>{const p=na(r);return e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"min-w-0 [overflow-wrap:anywhere] font-medium",children:r.title}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r.blockingState}),e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:kt(r.kind)}),p.rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--primary)]/14 text-[var(--primary)]",children:ee(p.rateApPerHour)}),e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:ce(p.totalAp)})]}):e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:"Recovery"})]})]}),e.jsx("button",{type:"button","aria-label":`Open actions for ${r.title}`,className:"rounded-full bg-[var(--ui-surface-2)] p-1.5 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:T=>{T.stopPropagation(),ge({kind:"work-block",templateId:r.templateId,position:{x:T.clientX,y:T.clientY}})},children:e.jsx(ze,{className:"size-4"})})]})})(),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[new Date(r.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.jsx("div",{className:"mt-2 text-xs text-[var(--ui-ink-muted)]",children:wt(k.workBlockTemplates.find(p=>p.id===r.templateId)??{id:r.templateId,title:r.title,kind:r.kind,color:r.color,startsOn:null,endsOn:null,blockingState:r.blockingState,createdAt:r.createdAt,updatedAt:r.updatedAt})})]},r.id)),o.map(r=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:p=>{l(r.id),p.dataTransfer.setData("text/forge-event-id",r.id)},onClick:p=>{p.stopPropagation(),ie(r),ne(null),re(!0)},className:`min-w-0 cursor-move overflow-hidden rounded-[18px] px-3 py-2 text-left text-sm text-[var(--ui-ink-strong)] transition ${pe.useCalendarColors?"hover:brightness-110":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:shadow-[var(--ui-shadow-soft)]"}`,style:pe.useCalendarColors?{backgroundColor:`${(r.calendarId?Ee[r.calendarId]:null)??ct(`origin:${r.originType}`)}1f`,border:`1px solid ${(r.calendarId?Ee[r.calendarId]:null)??ct(`origin:${r.originType}`)}55`}:void 0,children:[(ye(r),e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 [overflow-wrap:anywhere] font-medium",children:r.title}),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[new Date(r.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.jsx("button",{type:"button","aria-label":`Open quick actions for ${r.title}`,className:"rounded-full bg-[var(--ui-surface-2)] p-1.5 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:p=>{p.stopPropagation(),ge({kind:"event",eventId:r.id,position:{x:p.clientX,y:p.clientY}})},children:e.jsx(ze,{className:"size-4"})})})]})),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"max-w-full bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:Ma(r,Et)}),ye(r).rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(ye(r).rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:ce(ye(r).totalAp)})]}):null,r.calendarId&&pe.useCalendarColors?e.jsx("span",{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:Ee[r.calendarId]}}):null]}),r.place.address||r.place.timezone?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-muted)]",children:[r.place.address||r.location,r.place.address&&r.place.timezone?" · ":"",r.place.timezone]}):null,r.links.length>0?e.jsx("div",{className:"mt-2 flex min-w-0 flex-wrap gap-1.5",children:r.links.slice(0,3).map(p=>{const T=jt(p.entityType);return T?e.jsx(Qe,{kind:T,label:zt.get(`${p.entityType}:${p.entityId}`)??p.entityType,compact:!0,gradient:!1},p.id):e.jsx(S,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:p.entityType},p.id)})}):null]},r.id)),O.map(r=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:p=>{n(r.id),p.dataTransfer.setData("text/forge-timebox-id",r.id)},onClick:()=>{me(r),ae(!0)},className:"min-w-0 cursor-move overflow-hidden rounded-[18px] border border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] px-3 py-2 text-left text-sm text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)] transition hover:border-[color-mix(in_srgb,var(--primary)_42%,var(--ui-border-strong)_58%)] hover:bg-[var(--ui-accent-soft-hover)]",children:[(()=>{const p=oa(r);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex min-w-0 items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-5 text-[var(--ui-ink-strong)]",children:r.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[var(--ui-ink-soft)]",children:[e.jsx(Yt,{className:"size-3.5 shrink-0"}),new Date(r.startsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(r.endsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:r.status}),e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(p.rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)]",children:ce(p.totalAp)})]})]})})(),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),me(r),ae(!0)},className:"rounded-[999px] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Edit"}),e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),a(`/tasks/${r.taskId}`)},className:"rounded-[999px] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open task"})]})]},r.id)),C.length===0&&o.length===0&&O.length===0?e.jsx("div",{className:"min-h-[10rem] rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] px-3 py-4 text-sm leading-8 text-[var(--ui-ink-muted)]",children:"Nothing scheduled here yet. Click inside this day to create, block, or paste."}):null]})]},i)})})]}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(le,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Create event"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add a native Forge event with linked context."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Create a real calendar event even with no provider connected, then project it remotely whenever you choose."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),ie(null),ne(null),re(!0)},children:[e.jsx(le,{className:"size-4"}),"Open event guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Me,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Create work block"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Block main activity or protect creative windows."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Open the guided flow to create half-day presets, holidays, or custom recurring work blocks."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),M(!0)},children:[e.jsx(Me,{className:"size-4"}),"Open work-block guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(We,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Plan timebox"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Let Forge recommend valid upcoming slots."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Choose a task, review the suggested windows, and schedule directly into the calendar."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>ae(!0),children:[e.jsx(We,{className:"size-4"}),"Open planning guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(nt,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Manage provider settings"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:$t})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-medium)]",children:"Provider connections and setup instructions now live in Settings so the calendar view can stay focused on the week."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar"),children:[e.jsx(Xt,{className:"size-4"}),"Open calendar settings"]}),e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar?intent=connect"),children:[e.jsx(nt,{className:"size-4"}),"Connect provider"]})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"This week"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Quick status for the currently visible week."})]}),e.jsxs(G,{variant:"secondary",onClick:()=>void X.refetch(),children:[e.jsx(st,{className:"size-4"}),"Refresh view"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Provider events"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:k.events.length})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Work blocks"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:k.workBlockInstances.length})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Planned timeboxes"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:Mt.length})]})]})]}),e.jsxs(Z,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Guided actions"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>ue(!0),className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4 text-left transition hover:border-[var(--ui-border-strong)] hover:!bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Adjust task blocking rules"}),e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:"Guided"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Decide which work blocks, calendar conditions, and event keywords should block or allow a task."})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Active templates"}),e.jsx(S,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:k.workBlockTemplates.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[k.workBlockTemplates.slice(0,4).map(t=>e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsxs("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:[kt(t.kind)," ·"," ",t.weekDays.length," day",t.weekDays.length===1?"":"s"," ·"," ",t.blockingState]}),e.jsx("div",{className:"mt-1 text-[var(--ui-ink-muted)]",children:wt(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>{R(t),M(!0)},children:[e.jsx(le,{className:"size-3.5"}),"Edit"]}),e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>void De.mutateAsync(t.id),children:[e.jsx(_e,{className:"size-3.5"}),"Delete"]})]})]},t.id)),k.workBlockTemplates.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No recurring templates yet. Open the work-block guide to create the first one."}):null]})]})]})]})]})]}),e.jsx(Oa,{open:$,onOpenChange:t=>{M(t),t||R(null)},pending:Ye.isPending||Xe.isPending,template:L,onSubmit:async t=>{if(L){await Xe.mutateAsync({templateId:L.id,patch:t});return}await Ye.mutateAsync(t)}}),e.jsx(ka,{open:te,onOpenChange:ue,tasks:f.snapshot.tasks,onSave:async({taskId:t,schedulingRules:i,plannedDurationSeconds:o})=>{await la(t,{schedulingRules:i,plannedDurationSeconds:o}),await f.refresh(),await F(),await y.invalidateQueries({queryKey:["task-context",t]})}}),e.jsx(wa,{open:Ce,onOpenChange:Lt,tasks:f.snapshot.tasks,editingTimebox:Y,from:H.from,to:H.to,onCreateTimebox:async t=>{await It.mutateAsync(t)},onUpdateTimebox:async(t,i)=>{await Dt.mutateAsync({timeboxId:t,patch:i})},onDeleteTimebox:async t=>{await Ot.mutateAsync(t),Je()}}),e.jsx(Pa,{open:Ct,onOpenChange:t=>{re(t),t||(ie(null),ne(null))},writableCalendars:_t,linkOptions:Fe,event:Te,seed:Tt??void 0,onSubmit:async t=>{if(Te){const i=Te.id;re(!1),ie(null),ne(null),J.mutateAsync({eventId:i,patch:t}).catch(()=>{});return}else{re(!1),ie(null),ne(null),we.mutateAsync(t).catch(()=>{});return}},pending:we.isPending||J.isPending}),e.jsx(Da,{open:se!==null,onOpenChange:t=>{t||Ie(null)},initialTitle:(se==null?void 0:se.title)??"",pending:J.isPending,onSubmit:async t=>{if(!se)return;const i=se.id;Ie(null),J.mutateAsync({eventId:i,patch:{title:t}}).catch(()=>{})}}),e.jsx(Na,{open:w!==null,title:(w==null?void 0:w.kind)==="event"?((at=k.events.find(t=>t.id===w.eventId))==null?void 0:at.title)??"Event actions":(w==null?void 0:w.kind)==="work-block"?((rt=k.workBlockTemplates.find(t=>t.id===w.templateId))==null?void 0:rt.title)??"Work block actions":(w==null?void 0:w.kind)==="day"?Re(Ae.find(t=>t.toISOString().slice(0,10)===w.dayKey)??c):"Calendar actions",subtitle:(w==null?void 0:w.kind)==="day"?"Choose what to create or paste into this day.":(w==null?void 0:w.kind)==="work-block"?"Edit or remove this recurring work block.":b?`Clipboard ready: ${b.label}`:"Quick calendar event actions.",items:Bt,position:(w==null?void 0:w.position)??null,onClose:()=>ge(null)})]})}export{er as CalendarPage};
@@ -1 +1 @@
1
- import{r as v,j as a}from"./vendor-BwL6m4SE.js";import{i as D}from"./state-Bpe5dF3T.js";import{Q as K,F as y,a as C}from"./question-flow-dialog-D-_EvoAt.js";import{I,B,T as R,cm as S}from"./index-izRKx6JK.js";import{w as $}from"./schemas-B0Pa-V-A.js";const W=[10,15,30,45,60];function A(){return{mode:"add",minutes:15,note:""}}function Y({open:s,onOpenChange:t,entityType:p,entityId:u,targetLabel:l,currentCreditedSeconds:m,pending:k=!1,onSubmit:h}){const[c,b]=v.useState(A),[g,f]=v.useState(null);v.useEffect(()=>{s&&(b(A()),f(null))},[s]);const e=D({queryKey:["forge-xp-metrics"],queryFn:S,enabled:s}),d=v.useMemo(()=>{var x;const o=(x=e.data)==null?void 0:x.metrics.rules.find(w=>w.code==="task_run_progress"),i=Math.max(1,Number((o==null?void 0:o.config.intervalMinutes)??10)),n=Number((o==null?void 0:o.config.fixedXp)??4);return{intervalMinutes:i,fixedXp:n,intervalSeconds:i*60}},[e.data]),r=v.useMemo(()=>{const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=Math.max(0,Math.floor(m/60)),x=i>=0?i:-Math.min(Math.abs(i),n),w=Math.max(0,m+x*60),T=Math.floor(Math.max(0,m)/d.intervalSeconds),M=Math.floor(w/d.intervalSeconds)-T;return{requestedDeltaMinutes:i,appliedDeltaMinutes:x,nextCreditedSeconds:w,bucketDelta:M,xpDelta:M*d.fixedXp,maxRemovableMinutes:n}},[d.fixedXp,d.intervalSeconds,m,c.minutes,c.mode]),N=[{id:"adjustment",eyebrow:p==="task"?"Task work":"Project work",title:`Adjust tracked work for ${l}`,description:"Use this for retrospective minute corrections. Forge will add or remove tracked minutes and adjust progress XP automatically when a reward bucket is crossed.",render:(o,i)=>a.jsxs(a.Fragment,{children:[a.jsx(y,{label:"Mode",labelHelp:"Add minutes when work happened off-timer. Remove minutes when the tracked total needs a correction.",children:a.jsx(C,{value:o.mode,onChange:n=>i({mode:n}),options:[{value:"add",label:"Add minutes",description:"Record extra work that already happened."},{value:"remove",label:"Remove minutes",description:"Correct tracked time without deleting the work history."}]})}),a.jsx(y,{label:"Minutes",description:`Currently tracked: ${Math.floor(m/60)} minutes.`,hint:o.mode==="remove"?`You can remove up to ${r.maxRemovableMinutes} whole minutes from the current credited total.`:void 0,children:a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(I,{type:"number",min:1,className:"w-36",value:o.minutes,onChange:n=>i({minutes:Number(n.target.value)||0})}),a.jsx("div",{className:"flex flex-wrap gap-2",children:W.map(n=>a.jsxs(B,{type:"button",variant:o.minutes===n?"primary":"secondary",onClick:()=>i({minutes:n}),children:[n," min"]},n))})]})}),a.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[a.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preview"}),a.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-3",children:[a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Applied minutes"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.appliedDeltaMinutes>0?"+":"",r.appliedDeltaMinutes]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP delta"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.xpDelta>0?"+":"",r.xpDelta]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"New tracked total"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[Math.floor(r.nextCreditedSeconds/60)," min"]})]})]}),a.jsxs("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Reward cadence: ",d.fixedXp," XP every"," ",d.intervalMinutes," credited minutes."," ",r.bucketDelta===0?"This change does not cross a reward bucket.":`This change crosses ${Math.abs(r.bucketDelta)} reward bucket${Math.abs(r.bucketDelta)===1?"":"s"}.`]})]}),a.jsx(y,{label:"Note",description:"Optional context for why this correction is being added. The note stays attached to the adjustment metadata.",children:a.jsx(R,{className:"min-h-28",value:o.note,onChange:n=>i({note:n.target.value}),placeholder:"Captured the review session that happened away from the live timer."})})]})}];return a.jsx(K,{open:s,onOpenChange:t,eyebrow:p==="task"?"Adjust task work":"Adjust project work",title:`Adjust work for ${l}`,description:"Add or remove tracked minutes without creating a live task run.",value:c,onChange:b,draftPersistenceKey:`work-adjustment.${p}.${u}`,steps:N,submitLabel:"Save adjustment",pending:k,pendingLabel:"Saving adjustment...",error:g,onSubmit:async()=>{var x;f(null);const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=$.safeParse({entityType:p,entityId:u,deltaMinutes:i,note:c.note});if(!n.success){f(((x=n.error.issues[0])==null?void 0:x.message)??"Enter a valid minute adjustment.");return}try{await h({entityType:p,entityId:u,deltaMinutes:n.data.deltaMinutes,note:n.data.note||void 0}),t(!1)}catch(w){f(w instanceof Error?w.message:"Could not save the work adjustment right now.")}}})}const E={allowWorkBlockKinds:[],blockWorkBlockKinds:[],allowCalendarIds:[],blockCalendarIds:[],allowEventTypes:[],blockEventTypes:[],allowEventKeywords:[],blockEventKeywords:[],allowAvailability:[],blockAvailability:[]};function X(s){return s.map(t=>t.trim().toLowerCase()).filter(Boolean)}function j(s,t){const p=X(s);if(p.length===0)return!1;const u=t.join(" ").toLowerCase();return p.some(l=>u.includes(l))}function F(s){return s.allowWorkBlockKinds.length>0||s.allowCalendarIds.length>0||s.allowEventTypes.length>0||s.allowEventKeywords.length>0||s.allowAvailability.length>0}function P(s,t){return s??t??E}function G(s){const t=s.rules??E,u=(s.at??new Date).getTime(),l=s.overview,m=(l==null?void 0:l.workBlockInstances.filter(e=>{const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],k=(l==null?void 0:l.events.filter(e=>{if(e.deletedAt)return!1;const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],h=[],c=m.some(e=>t.blockWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)||t.blockEventTypes.includes(e.eventType)||t.blockAvailability.includes(e.availability)||j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]));c&&(m.some(e=>t.blockWorkBlockKinds.includes(e.kind))&&h.push("The current work block is marked as blocked."),k.some(e=>e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)&&h.push("The active calendar belongs to a blocked calendar source."),k.some(e=>t.blockEventTypes.includes(e.eventType))&&h.push("The active calendar event type is blocked."),k.some(e=>t.blockAvailability.includes(e.availability))&&h.push("The active calendar availability is blocked."),k.some(e=>j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]))&&h.push("The active calendar event matches a blocked keyword."));const b=F(t),g=m.some(e=>t.allowWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.allowCalendarIds.includes(e.calendarId):!1)||t.allowEventTypes.includes(e.eventType)||t.allowAvailability.includes(e.availability)||j(t.allowEventKeywords,[e.title,e.description,e.location,...e.categories]));!c&&b&&!g&&h.push("The current calendar context does not match the allowed rules yet.");const f=[...m.map(e=>`${e.title} (${e.kind.replaceAll("_"," ")})`),...k.map(e=>e.title)];return h.length>0?{blocked:!0,label:"Blocked right now",tone:"blocked",conflicts:h,context:f}:f.length>0?{blocked:!1,label:"Allowed right now",tone:"allowed",conflicts:[],context:f}:{blocked:!1,label:b?"Waiting for an allowed calendar context":"No live calendar conflict right now",tone:b?"waiting":"allowed",conflicts:[],context:[]}}function H(s,t){return P(s.schedulingRules,t)}export{Y as W,G as e,H as g};
1
+ import{r as v,j as a}from"./vendor-B7FKSwHK.js";import{i as D}from"./state-BFyKSULP.js";import{Q as K,F as y,a as C}from"./question-flow-dialog-yMYVk998.js";import{I,B,T as R,cv as S}from"./index-gmPaoLN-.js";import{w as $}from"./schemas-BlFy-uPR.js";const W=[10,15,30,45,60];function A(){return{mode:"add",minutes:15,note:""}}function Y({open:s,onOpenChange:t,entityType:p,entityId:u,targetLabel:l,currentCreditedSeconds:m,pending:k=!1,onSubmit:h}){const[c,b]=v.useState(A),[g,f]=v.useState(null);v.useEffect(()=>{s&&(b(A()),f(null))},[s]);const e=D({queryKey:["forge-xp-metrics"],queryFn:S,enabled:s}),d=v.useMemo(()=>{var x;const o=(x=e.data)==null?void 0:x.metrics.rules.find(w=>w.code==="task_run_progress"),i=Math.max(1,Number((o==null?void 0:o.config.intervalMinutes)??10)),n=Number((o==null?void 0:o.config.fixedXp)??4);return{intervalMinutes:i,fixedXp:n,intervalSeconds:i*60}},[e.data]),r=v.useMemo(()=>{const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=Math.max(0,Math.floor(m/60)),x=i>=0?i:-Math.min(Math.abs(i),n),w=Math.max(0,m+x*60),T=Math.floor(Math.max(0,m)/d.intervalSeconds),M=Math.floor(w/d.intervalSeconds)-T;return{requestedDeltaMinutes:i,appliedDeltaMinutes:x,nextCreditedSeconds:w,bucketDelta:M,xpDelta:M*d.fixedXp,maxRemovableMinutes:n}},[d.fixedXp,d.intervalSeconds,m,c.minutes,c.mode]),N=[{id:"adjustment",eyebrow:p==="task"?"Task work":"Project work",title:`Adjust tracked work for ${l}`,description:"Use this for retrospective minute corrections. Forge will add or remove tracked minutes and adjust progress XP automatically when a reward bucket is crossed.",render:(o,i)=>a.jsxs(a.Fragment,{children:[a.jsx(y,{label:"Mode",labelHelp:"Add minutes when work happened off-timer. Remove minutes when the tracked total needs a correction.",children:a.jsx(C,{value:o.mode,onChange:n=>i({mode:n}),options:[{value:"add",label:"Add minutes",description:"Record extra work that already happened."},{value:"remove",label:"Remove minutes",description:"Correct tracked time without deleting the work history."}]})}),a.jsx(y,{label:"Minutes",description:`Currently tracked: ${Math.floor(m/60)} minutes.`,hint:o.mode==="remove"?`You can remove up to ${r.maxRemovableMinutes} whole minutes from the current credited total.`:void 0,children:a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(I,{type:"number",min:1,className:"w-36",value:o.minutes,onChange:n=>i({minutes:Number(n.target.value)||0})}),a.jsx("div",{className:"flex flex-wrap gap-2",children:W.map(n=>a.jsxs(B,{type:"button",variant:o.minutes===n?"primary":"secondary",onClick:()=>i({minutes:n}),children:[n," min"]},n))})]})}),a.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[a.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preview"}),a.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-3",children:[a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Applied minutes"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.appliedDeltaMinutes>0?"+":"",r.appliedDeltaMinutes]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP delta"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.xpDelta>0?"+":"",r.xpDelta]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"New tracked total"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[Math.floor(r.nextCreditedSeconds/60)," min"]})]})]}),a.jsxs("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Reward cadence: ",d.fixedXp," XP every"," ",d.intervalMinutes," credited minutes."," ",r.bucketDelta===0?"This change does not cross a reward bucket.":`This change crosses ${Math.abs(r.bucketDelta)} reward bucket${Math.abs(r.bucketDelta)===1?"":"s"}.`]})]}),a.jsx(y,{label:"Note",description:"Optional context for why this correction is being added. The note stays attached to the adjustment metadata.",children:a.jsx(R,{className:"min-h-28",value:o.note,onChange:n=>i({note:n.target.value}),placeholder:"Captured the review session that happened away from the live timer."})})]})}];return a.jsx(K,{open:s,onOpenChange:t,eyebrow:p==="task"?"Adjust task work":"Adjust project work",title:`Adjust work for ${l}`,description:"Add or remove tracked minutes without creating a live task run.",value:c,onChange:b,draftPersistenceKey:`work-adjustment.${p}.${u}`,steps:N,submitLabel:"Save adjustment",pending:k,pendingLabel:"Saving adjustment...",error:g,onSubmit:async()=>{var x;f(null);const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=$.safeParse({entityType:p,entityId:u,deltaMinutes:i,note:c.note});if(!n.success){f(((x=n.error.issues[0])==null?void 0:x.message)??"Enter a valid minute adjustment.");return}try{await h({entityType:p,entityId:u,deltaMinutes:n.data.deltaMinutes,note:n.data.note||void 0}),t(!1)}catch(w){f(w instanceof Error?w.message:"Could not save the work adjustment right now.")}}})}const E={allowWorkBlockKinds:[],blockWorkBlockKinds:[],allowCalendarIds:[],blockCalendarIds:[],allowEventTypes:[],blockEventTypes:[],allowEventKeywords:[],blockEventKeywords:[],allowAvailability:[],blockAvailability:[]};function X(s){return s.map(t=>t.trim().toLowerCase()).filter(Boolean)}function j(s,t){const p=X(s);if(p.length===0)return!1;const u=t.join(" ").toLowerCase();return p.some(l=>u.includes(l))}function F(s){return s.allowWorkBlockKinds.length>0||s.allowCalendarIds.length>0||s.allowEventTypes.length>0||s.allowEventKeywords.length>0||s.allowAvailability.length>0}function P(s,t){return s??t??E}function G(s){const t=s.rules??E,u=(s.at??new Date).getTime(),l=s.overview,m=(l==null?void 0:l.workBlockInstances.filter(e=>{const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],k=(l==null?void 0:l.events.filter(e=>{if(e.deletedAt)return!1;const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],h=[],c=m.some(e=>t.blockWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)||t.blockEventTypes.includes(e.eventType)||t.blockAvailability.includes(e.availability)||j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]));c&&(m.some(e=>t.blockWorkBlockKinds.includes(e.kind))&&h.push("The current work block is marked as blocked."),k.some(e=>e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)&&h.push("The active calendar belongs to a blocked calendar source."),k.some(e=>t.blockEventTypes.includes(e.eventType))&&h.push("The active calendar event type is blocked."),k.some(e=>t.blockAvailability.includes(e.availability))&&h.push("The active calendar availability is blocked."),k.some(e=>j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]))&&h.push("The active calendar event matches a blocked keyword."));const b=F(t),g=m.some(e=>t.allowWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.allowCalendarIds.includes(e.calendarId):!1)||t.allowEventTypes.includes(e.eventType)||t.allowAvailability.includes(e.availability)||j(t.allowEventKeywords,[e.title,e.description,e.location,...e.categories]));!c&&b&&!g&&h.push("The current calendar context does not match the allowed rules yet.");const f=[...m.map(e=>`${e.title} (${e.kind.replaceAll("_"," ")})`),...k.map(e=>e.title)];return h.length>0?{blocked:!0,label:"Blocked right now",tone:"blocked",conflicts:h,context:f}:f.length>0?{blocked:!1,label:"Allowed right now",tone:"allowed",conflicts:[],context:f}:{blocked:!1,label:b?"Waiting for an allowed calendar context":"No live calendar conflict right now",tone:b?"waiting":"allowed",conflicts:[],context:[]}}function H(s,t){return P(s.schedulingRules,t)}export{Y as W,G as e,H as g};
@@ -1 +1 @@
1
- import{j as e,aV as m}from"./vendor-BwL6m4SE.js";import{k as x,B as a}from"./index-izRKx6JK.js";import{f as d}from"./calendar-ui-Cy1XRwzV.js";function j({eyebrow:s="Week view",description:i,weekStart:n,status:r,badges:t,onPrevious:l,onCurrent:o,onNext:c}){return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s}),e.jsx("p",{className:"mt-2 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i}),r?e.jsx("div",{className:"mt-3",children:r}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsxs(x,{className:"border border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[e.jsx(m,{className:"mr-1 size-3.5"}),"Week of ",d(n)]}),t,e.jsx(a,{variant:"secondary",onClick:l,children:"Previous"}),e.jsx(a,{variant:"secondary",onClick:o,children:"This week"}),e.jsx(a,{variant:"secondary",onClick:c,children:"Next"})]})]})}export{j as C};
1
+ import{j as e,aV as m}from"./vendor-B7FKSwHK.js";import{j as x,B as a}from"./index-gmPaoLN-.js";import{f as d}from"./calendar-ui-Cy1XRwzV.js";function j({eyebrow:s="Week view",description:i,weekStart:n,status:r,badges:t,onPrevious:l,onCurrent:o,onNext:c}){return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s}),e.jsx("p",{className:"mt-2 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i}),r?e.jsx("div",{className:"mt-3",children:r}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsxs(x,{className:"border border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[e.jsx(m,{className:"mr-1 size-3.5"}),"Week of ",d(n)]}),t,e.jsx(a,{variant:"secondary",onClick:l,children:"Previous"}),e.jsx(a,{variant:"secondary",onClick:o,children:"This week"}),e.jsx(a,{variant:"secondary",onClick:c,children:"Next"})]})]})}export{j as C};
@@ -1,4 +1,4 @@
1
- import{r as u,T as R,U as Xr,V as Cv,W as kv,X as Dv,Y as Tv,Z as $v,$ as _v,a0 as Nv,a1 as qu,a2 as io,a3 as Lv,m as x,a4 as Ln,a5 as Mv,a6 as Rv,a7 as Zu,a8 as zv,a9 as Bv,aa as Kv,ab as Wv,ac as F,F as Xa,ad as qt,ae as Fv,af as Gv,ag as Vv,ah as Hv,ai as Xv,aj as Yv,ak as Uv,al as Ju,am as qv,an as Zv,ao as Jv,ap as Qv,aq as ef,ar as rf,as as K,at as ft,au as Qu,av as tf,aw as nf,ax as af,E as of,ay as lf,az as uf,d as cf}from"./vendor-BwL6m4SE.js";import{a as Pe,p as J,b as Me,d as sf,e as kr,f as At,g as df,h as vf,P as ff}from"./state-Bpe5dF3T.js";var pf=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function Ya(e){if(typeof e!="string")return!1;var r=pf;return r.includes(e)}var mf=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],yf=new Set(mf);function ec(e){return typeof e!="string"?!1:yf.has(e)}function rc(e){return typeof e=="string"&&e.startsWith("data-")}function ne(e){if(typeof e!="object"||e===null)return{};var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(ec(t)||rc(t))&&(r[t]=e[t]);return r}function Dr(e){if(e==null)return null;if(u.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var r=e.props;return ne(r)}return typeof e=="object"&&!Array.isArray(e)?ne(e):null}function le(e){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(ec(t)||rc(t)||Ya(t))&&(r[t]=e[t]);return r}function hf(e){return e==null?null:u.isValidElement(e)?le(e.props):typeof e=="object"&&!Array.isArray(e)?le(e):null}var gf=["children","width","height","viewBox","className","style","title","desc"];function Pa(){return Pa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Pa.apply(null,arguments)}function bf(e,r){if(e==null)return{};var t,n,a=xf(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function xf(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var Ua=u.forwardRef((e,r)=>{var{children:t,width:n,height:a,viewBox:i,className:o,style:l,title:c,desc:s}=e,d=bf(e,gf),v=i||{width:n,height:a,x:0,y:0},f=R("recharts-surface",o);return u.createElement("svg",Pa({},le(d),{className:f,width:n,height:a,style:l,viewBox:"".concat(v.x," ").concat(v.y," ").concat(v.width," ").concat(v.height),ref:r}),u.createElement("title",null,c),u.createElement("desc",null,s),t)}),Pf=["children","className"];function Oa(){return Oa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Oa.apply(null,arguments)}function Of(e,r){if(e==null)return{};var t,n,a=wf(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function wf(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var Y=u.forwardRef((e,r)=>{var{children:t,className:n}=e,a=Of(e,Pf),i=R("recharts-layer",n);return u.createElement("g",Oa({className:i},le(a),{ref:r}),t)}),tc=u.createContext(null),Af=()=>u.useContext(tc),Ef=4;function fr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ef,t=10**r,n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function te(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return e.reduce((a,i,o)=>{var l=t[o-1];return typeof l=="string"?a+l+i:l!==void 0?a+fr(l)+i:a+i},"")}var we=e=>e===0?0:e>0?1:-1,ze=e=>typeof e=="number"&&e!=+e,jr=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,T=e=>(typeof e=="number"||e instanceof Number)&&!ze(e),Te=e=>T(e)||typeof e=="string",jf=0,gt=e=>{var r=++jf;return"".concat(e||"").concat(r)},Be=function(r,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!T(r)&&typeof r!="string")return n;var i;if(jr(r)){if(t==null)return n;var o=r.indexOf("%");i=t*parseFloat(r.slice(0,o))/100}else i=+r;return ze(i)&&(i=n),a&&t!=null&&i>t&&(i=t),i},nc=e=>{if(!Array.isArray(e))return!1;for(var r=e.length,t={},n=0;n<r;n++)if(!t[String(e[n])])t[String(e[n])]=!0;else return!0;return!1};function B(e,r,t){return T(e)&&T(r)?fr(e+t*(r-e)):r}function ac(e,r,t){if(!(!e||!e.length))return e.find(n=>n&&(typeof r=="function"?r(n):Xr(n,r))===t)}var Sf=e=>{for(var r=e.length,t=0,n=0,a=0,i=0,o=1/0,l=-1/0,c=0,s=0,d=0;d<r;d++){var v,f;c=((v=e[d])===null||v===void 0?void 0:v.cx)||0,s=((f=e[d])===null||f===void 0?void 0:f.cy)||0,t+=c,n+=s,a+=c*s,i+=c*c,o=Math.min(o,c),l=Math.max(l,c)}var m=r*i!==t*t?(r*a-t*n)/(r*i-t*t):0;return{xmin:o,xmax:l,a:m,b:(n-m*t)/r}},G=e=>e===null||typeof e>"u",Et=e=>G(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function Ae(e){return e!=null}function Ke(){}var If=["type","size","sizeType"];function wa(){return wa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},wa.apply(null,arguments)}function oo(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function lo(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?oo(Object(t),!0).forEach(function(n){Cf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):oo(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Cf(e,r,t){return(r=kf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function kf(e){var r=Df(e,"string");return typeof r=="symbol"?r:r+""}function Df(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Tf(e,r){if(e==null)return{};var t,n,a=$f(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function $f(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var ic={symbolCircle:qu,symbolCross:Nv,symbolDiamond:_v,symbolSquare:$v,symbolStar:Tv,symbolTriangle:Dv,symbolWye:kv},_f=Math.PI/180,Nf=e=>{var r="symbol".concat(Et(e));return ic[r]||qu},Lf=(e,r,t)=>{if(r==="area")return e;switch(t){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*_f;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Mf=(e,r)=>{ic["symbol".concat(Et(e))]=r},Mn=e=>{var{type:r="circle",size:t=64,sizeType:n="area"}=e,a=Tf(e,If),i=lo(lo({},a),{},{type:r,size:t,sizeType:n}),o="circle";typeof r=="string"&&(o=r);var l=()=>{var f=Nf(o),m=Cv().type(f).size(Lf(t,n,o)),p=m();if(p!==null)return p},{className:c,cx:s,cy:d}=i,v=le(i);return T(s)&&T(d)&&T(t)?u.createElement("path",wa({},v,{className:R("recharts-symbols",c),transform:"translate(".concat(s,", ").concat(d,")"),d:l()})):null};Mn.registerSymbol=Mf;var oc=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,qa=(e,r)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var t=e;if(u.isValidElement(e)&&(t=e.props),typeof t!="object"&&typeof t!="function")return null;var n={};return Object.keys(t).forEach(a=>{Ya(a)&&typeof t[a]=="function"&&(n[a]=(i=>t[a](t,i)))}),n},Rf=(e,r,t)=>n=>(e(r,t,n),null),Zr=(e,r,t)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(a=>{var i=e[a];Ya(a)&&typeof i=="function"&&(n||(n={}),n[a]=Rf(i,r,t))}),n},zf=e=>Array.isArray(e)&&e.length>0;function uo(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function Bf(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?uo(Object(t),!0).forEach(function(n){Kf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):uo(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Kf(e,r,t){return(r=Wf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Wf(e){var r=Ff(e,"string");return typeof r=="symbol"?r:r+""}function Ff(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function q(e,r){var t=Bf({},e),n=r,a=Object.keys(r),i=a.reduce((o,l)=>(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),t);return i}function cn(){return cn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},cn.apply(null,arguments)}function co(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function lc(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?co(Object(t),!0).forEach(function(n){Gf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):co(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Gf(e,r,t){return(r=Vf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Vf(e){var r=Hf(e,"string");return typeof r=="symbol"?r:r+""}function Hf(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var ke=32,Xf={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle",labelStyle:{}};function Yf(e){if(typeof e=="object"&&e!==null&&"strokeDasharray"in e)return String(e.strokeDasharray)}function Uf(e){var{data:r,iconType:t,inactiveColor:n}=e,a=ke/2,i=ke/6,o=ke/3,l=r.inactive?n:r.color,c=t??r.type;if(c==="none")return null;if(c==="plainline")return u.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:Yf(r.payload),x1:0,y1:a,x2:ke,y2:a,className:"recharts-legend-icon"});if(c==="line")return u.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(a,"h").concat(o,`
1
+ import{r as u,T as R,U as Xr,V as Cv,W as kv,X as Dv,Y as Tv,Z as $v,$ as _v,a0 as Nv,a1 as qu,a2 as io,a3 as Lv,m as x,a4 as Ln,a5 as Mv,a6 as Rv,a7 as Zu,a8 as zv,a9 as Bv,aa as Kv,ab as Wv,ac as F,F as Xa,ad as qt,ae as Fv,af as Gv,ag as Vv,ah as Hv,ai as Xv,aj as Yv,ak as Uv,al as Ju,am as qv,an as Zv,ao as Jv,ap as Qv,aq as ef,ar as rf,as as K,at as ft,au as Qu,av as tf,aw as nf,ax as af,E as of,ay as lf,az as uf,d as cf}from"./vendor-B7FKSwHK.js";import{a as Pe,p as J,b as Me,d as sf,e as kr,f as At,g as df,h as vf,P as ff}from"./state-BFyKSULP.js";var pf=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function Ya(e){if(typeof e!="string")return!1;var r=pf;return r.includes(e)}var mf=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],yf=new Set(mf);function ec(e){return typeof e!="string"?!1:yf.has(e)}function rc(e){return typeof e=="string"&&e.startsWith("data-")}function ne(e){if(typeof e!="object"||e===null)return{};var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(ec(t)||rc(t))&&(r[t]=e[t]);return r}function Dr(e){if(e==null)return null;if(u.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var r=e.props;return ne(r)}return typeof e=="object"&&!Array.isArray(e)?ne(e):null}function le(e){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(ec(t)||rc(t)||Ya(t))&&(r[t]=e[t]);return r}function hf(e){return e==null?null:u.isValidElement(e)?le(e.props):typeof e=="object"&&!Array.isArray(e)?le(e):null}var gf=["children","width","height","viewBox","className","style","title","desc"];function Pa(){return Pa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Pa.apply(null,arguments)}function bf(e,r){if(e==null)return{};var t,n,a=xf(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function xf(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var Ua=u.forwardRef((e,r)=>{var{children:t,width:n,height:a,viewBox:i,className:o,style:l,title:c,desc:s}=e,d=bf(e,gf),v=i||{width:n,height:a,x:0,y:0},f=R("recharts-surface",o);return u.createElement("svg",Pa({},le(d),{className:f,width:n,height:a,style:l,viewBox:"".concat(v.x," ").concat(v.y," ").concat(v.width," ").concat(v.height),ref:r}),u.createElement("title",null,c),u.createElement("desc",null,s),t)}),Pf=["children","className"];function Oa(){return Oa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Oa.apply(null,arguments)}function Of(e,r){if(e==null)return{};var t,n,a=wf(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function wf(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var Y=u.forwardRef((e,r)=>{var{children:t,className:n}=e,a=Of(e,Pf),i=R("recharts-layer",n);return u.createElement("g",Oa({className:i},le(a),{ref:r}),t)}),tc=u.createContext(null),Af=()=>u.useContext(tc),Ef=4;function fr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ef,t=10**r,n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function te(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return e.reduce((a,i,o)=>{var l=t[o-1];return typeof l=="string"?a+l+i:l!==void 0?a+fr(l)+i:a+i},"")}var we=e=>e===0?0:e>0?1:-1,ze=e=>typeof e=="number"&&e!=+e,jr=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,T=e=>(typeof e=="number"||e instanceof Number)&&!ze(e),Te=e=>T(e)||typeof e=="string",jf=0,gt=e=>{var r=++jf;return"".concat(e||"").concat(r)},Be=function(r,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!T(r)&&typeof r!="string")return n;var i;if(jr(r)){if(t==null)return n;var o=r.indexOf("%");i=t*parseFloat(r.slice(0,o))/100}else i=+r;return ze(i)&&(i=n),a&&t!=null&&i>t&&(i=t),i},nc=e=>{if(!Array.isArray(e))return!1;for(var r=e.length,t={},n=0;n<r;n++)if(!t[String(e[n])])t[String(e[n])]=!0;else return!0;return!1};function B(e,r,t){return T(e)&&T(r)?fr(e+t*(r-e)):r}function ac(e,r,t){if(!(!e||!e.length))return e.find(n=>n&&(typeof r=="function"?r(n):Xr(n,r))===t)}var Sf=e=>{for(var r=e.length,t=0,n=0,a=0,i=0,o=1/0,l=-1/0,c=0,s=0,d=0;d<r;d++){var v,f;c=((v=e[d])===null||v===void 0?void 0:v.cx)||0,s=((f=e[d])===null||f===void 0?void 0:f.cy)||0,t+=c,n+=s,a+=c*s,i+=c*c,o=Math.min(o,c),l=Math.max(l,c)}var m=r*i!==t*t?(r*a-t*n)/(r*i-t*t):0;return{xmin:o,xmax:l,a:m,b:(n-m*t)/r}},G=e=>e===null||typeof e>"u",Et=e=>G(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function Ae(e){return e!=null}function Ke(){}var If=["type","size","sizeType"];function wa(){return wa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},wa.apply(null,arguments)}function oo(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function lo(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?oo(Object(t),!0).forEach(function(n){Cf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):oo(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Cf(e,r,t){return(r=kf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function kf(e){var r=Df(e,"string");return typeof r=="symbol"?r:r+""}function Df(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Tf(e,r){if(e==null)return{};var t,n,a=$f(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function $f(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}var ic={symbolCircle:qu,symbolCross:Nv,symbolDiamond:_v,symbolSquare:$v,symbolStar:Tv,symbolTriangle:Dv,symbolWye:kv},_f=Math.PI/180,Nf=e=>{var r="symbol".concat(Et(e));return ic[r]||qu},Lf=(e,r,t)=>{if(r==="area")return e;switch(t){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var n=18*_f;return 1.25*e*e*(Math.tan(n)-Math.tan(n*2)*Math.tan(n)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Mf=(e,r)=>{ic["symbol".concat(Et(e))]=r},Mn=e=>{var{type:r="circle",size:t=64,sizeType:n="area"}=e,a=Tf(e,If),i=lo(lo({},a),{},{type:r,size:t,sizeType:n}),o="circle";typeof r=="string"&&(o=r);var l=()=>{var f=Nf(o),m=Cv().type(f).size(Lf(t,n,o)),p=m();if(p!==null)return p},{className:c,cx:s,cy:d}=i,v=le(i);return T(s)&&T(d)&&T(t)?u.createElement("path",wa({},v,{className:R("recharts-symbols",c),transform:"translate(".concat(s,", ").concat(d,")"),d:l()})):null};Mn.registerSymbol=Mf;var oc=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,qa=(e,r)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var t=e;if(u.isValidElement(e)&&(t=e.props),typeof t!="object"&&typeof t!="function")return null;var n={};return Object.keys(t).forEach(a=>{Ya(a)&&typeof t[a]=="function"&&(n[a]=(i=>t[a](t,i)))}),n},Rf=(e,r,t)=>n=>(e(r,t,n),null),Zr=(e,r,t)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var n=null;return Object.keys(e).forEach(a=>{var i=e[a];Ya(a)&&typeof i=="function"&&(n||(n={}),n[a]=Rf(i,r,t))}),n},zf=e=>Array.isArray(e)&&e.length>0;function uo(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function Bf(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?uo(Object(t),!0).forEach(function(n){Kf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):uo(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Kf(e,r,t){return(r=Wf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Wf(e){var r=Ff(e,"string");return typeof r=="symbol"?r:r+""}function Ff(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function q(e,r){var t=Bf({},e),n=r,a=Object.keys(r),i=a.reduce((o,l)=>(o[l]===void 0&&n[l]!==void 0&&(o[l]=n[l]),o),t);return i}function cn(){return cn=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},cn.apply(null,arguments)}function co(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function lc(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?co(Object(t),!0).forEach(function(n){Gf(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):co(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Gf(e,r,t){return(r=Vf(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Vf(e){var r=Hf(e,"string");return typeof r=="symbol"?r:r+""}function Hf(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var ke=32,Xf={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle",labelStyle:{}};function Yf(e){if(typeof e=="object"&&e!==null&&"strokeDasharray"in e)return String(e.strokeDasharray)}function Uf(e){var{data:r,iconType:t,inactiveColor:n}=e,a=ke/2,i=ke/6,o=ke/3,l=r.inactive?n:r.color,c=t??r.type;if(c==="none")return null;if(c==="plainline")return u.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:Yf(r.payload),x1:0,y1:a,x2:ke,y2:a,className:"recharts-legend-icon"});if(c==="line")return u.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(a,"h").concat(o,`
2
2
  A`).concat(i,",").concat(i,",0,1,1,").concat(2*o,",").concat(a,`
3
3
  H`).concat(ke,"M").concat(2*o,",").concat(a,`
4
4
  A`).concat(i,",").concat(i,",0,1,1,").concat(o,",").concat(a),className:"recharts-legend-icon"});if(c==="rect")return u.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(ke/8,"h").concat(ke,"v").concat(ke*3/4,"h").concat(-ke,"z"),className:"recharts-legend-icon"});if(u.isValidElement(r.legendIcon)){var s=lc({},r);return delete s.legendIcon,u.cloneElement(r.legendIcon,s)}return u.createElement(Mn,{fill:l,cx:a,cy:a,size:ke,sizeType:"diameter",type:c})}function qf(e){var{payload:r,iconSize:t,layout:n,formatter:a,inactiveColor:i,iconType:o,labelStyle:l}=e,c={x:0,y:0,width:ke,height:ke},s={display:n==="horizontal"?"inline-block":"block",marginRight:10},d={display:"inline-block",verticalAlign:"middle",marginRight:4};return r.map((v,f)=>{var m=v.formatter||a,p=R({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:v.inactive});if(v.type==="none")return null;var h=typeof l=="object"?lc({},l):{};h.color=v.inactive?i:h.color||v.color;var g=m?m(v.value,v,f):v.value;return u.createElement("li",cn({className:p,style:s,key:"legend-item-".concat(f)},Zr(e,v,f)),u.createElement(Ua,{width:t,height:t,viewBox:c,style:d,"aria-label":"".concat(g," legend icon")},u.createElement(Uf,{data:v,iconType:o,inactiveColor:i})),u.createElement("span",{className:"recharts-legend-item-text",style:h},g))})}var Zf=e=>{var r=q(e,Xf),{payload:t,layout:n,align:a}=r;if(!t||!t.length)return null;var i={padding:0,margin:0,textAlign:n==="horizontal"?a:"left"};return u.createElement("ul",{className:"recharts-default-legend",style:i},u.createElement(qf,cn({},r,{payload:t})))};function uc(e,r,t){return r===!0?io(e,t):typeof r=="function"?io(e,r):e}var Za=u.createContext(null),Jf=e=>e,H=()=>{var e=u.useContext(Za);return e?e.store.dispatch:Jf},on=()=>{},Qf=()=>on,ep=(e,r)=>e===r;function k(e){var r=u.useContext(Za),t=u.useMemo(()=>r?n=>{if(n!=null)return e(n)}:on,[r,e]);return Lv.useSyncExternalStoreWithSelector(r?r.subscription.addNestedSub:Qf,r?r.store.getState:on,r?r.store.getState:on,t,ep)}var cc=e=>e.legend.settings,rp=e=>e.legend.size,tp=e=>e.legend.payload,np=x([tp,cc],(e,r)=>{var{itemSorter:t}=r,n=e.flat(1);return t?Ln(n,t):n});function ap(){return k(np)}var Zt=1;function sc(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[r,t]=u.useState({height:0,left:0,top:0,width:0}),n=u.useCallback(a=>{if(a!=null){var i=a.getBoundingClientRect(),o={height:i.height,left:i.left,top:i.top,width:i.width};(Math.abs(o.height-r.height)>Zt||Math.abs(o.left-r.left)>Zt||Math.abs(o.top-r.top)>Zt||Math.abs(o.width-r.width)>Zt)&&t({height:o.height,left:o.left,top:o.top,width:o.width})}},[r.width,r.height,r.top,r.left,...e]);return[r,n]}var ip={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},dc=Pe({name:"chartLayout",initialState:ip,reducers:{setLayout(e,r){e.layoutType=r.payload},setChartSize(e,r){e.width=r.payload.width,e.height=r.payload.height},setMargin(e,r){var t,n,a,i;e.margin.top=(t=r.payload.top)!==null&&t!==void 0?t:0,e.margin.right=(n=r.payload.right)!==null&&n!==void 0?n:0,e.margin.bottom=(a=r.payload.bottom)!==null&&a!==void 0?a:0,e.margin.left=(i=r.payload.left)!==null&&i!==void 0?i:0},setScale(e,r){e.scale=r.payload}}}),{setMargin:op,setLayout:lp,setChartSize:up,setScale:cp}=dc.actions,sp=dc.reducer;function vc(e,r,t){return Array.isArray(e)&&e&&r+t!==0?e.slice(r,t+1):e}function N(e){return Number.isFinite(e)}function Ye(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function so(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function Kr(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?so(Object(t),!0).forEach(function(n){dp(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):so(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function dp(e,r,t){return(r=vp(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function vp(e){var r=fp(e,"string");return typeof r=="symbol"?r:r+""}function fp(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function V(e,r,t){return G(e)||G(r)?t:Te(r)?Xr(e,r,t):typeof r=="function"?r(e):t}var pp=(e,r,t)=>{if(r&&t){var{width:n,height:a}=t,{align:i,verticalAlign:o,layout:l}=r;if((l==="vertical"||l==="horizontal"&&o==="middle")&&i!=="center"&&T(e[i]))return Kr(Kr({},e),{},{[i]:e[i]+(n||0)});if((l==="horizontal"||l==="vertical"&&i==="center")&&o!=="middle"&&T(e[o]))return Kr(Kr({},e),{},{[o]:e[o]+(a||0)})}return e},Ne=(e,r)=>e==="horizontal"&&r==="xAxis"||e==="vertical"&&r==="yAxis"||e==="centric"&&r==="angleAxis"||e==="radial"&&r==="radiusAxis",fc=(e,r,t,n)=>{if(n)return e.map(l=>l.coordinate);var a,i,o=e.map(l=>(l.coordinate===r&&(a=!0),l.coordinate===t&&(i=!0),l.coordinate));return a||o.push(r),i||o.push(t),o},pc=(e,r,t)=>{if(!e)return null;var{duplicateDomain:n,type:a,range:i,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:s,tickCount:d,ticks:v,niceTicks:f,axisType:m}=e;if(!o)return null;var p=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,h=a==="category"&&o.bandwidth?o.bandwidth()/p:0;if(h=m==="angleAxis"&&i&&i.length>=2?we(i[0]-i[1])*2*h:h,v||f){var g=(v||f||[]).map((y,b)=>{var P=n?n.indexOf(y):y,O=o.map(P);return N(O)?{coordinate:O+h,value:y,offset:h,index:b}:null}).filter(Ae);return g}return c&&s?s.map((y,b)=>{var P=o.map(y);return N(P)?{coordinate:P+h,value:y,index:b,offset:h}:null}).filter(Ae):o.ticks&&d!=null?o.ticks(d).map((y,b)=>{var P=o.map(y);return N(P)?{coordinate:P+h,value:y,index:b,offset:h}:null}).filter(Ae):o.domain().map((y,b)=>{var P=o.map(y);return N(P)?{coordinate:P+h,value:n?n[y]:y,index:b,offset:h}:null}).filter(Ae)},mp=(e,r)=>{if(!r||r.length!==2||!T(r[0])||!T(r[1]))return e;var t=Math.min(r[0],r[1]),n=Math.max(r[0],r[1]),a=[e[0],e[1]];return(!T(e[0])||e[0]<t)&&(a[0]=t),(!T(e[1])||e[1]>n)&&(a[1]=n),a[0]>n&&(a[0]=n),a[1]<t&&(a[1]=t),a},yp=e=>{var r,t=e.length;if(!(t<=0)){var n=(r=e[0])===null||r===void 0?void 0:r.length;if(!(n==null||n<=0))for(var a=0;a<n;++a)for(var i=0,o=0,l=0;l<t;++l){var c=e[l],s=c==null?void 0:c[a];if(s!=null){var d=s[1],v=s[0],f=ze(d)?v:d;f>=0?(s[0]=i,i+=f,s[1]=i):(s[0]=o,o+=f,s[1]=o)}}}},hp=e=>{var r,t=e.length;if(!(t<=0)){var n=(r=e[0])===null||r===void 0?void 0:r.length;if(!(n==null||n<=0))for(var a=0;a<n;++a)for(var i=0,o=0;o<t;++o){var l=e[o],c=l==null?void 0:l[a];if(c!=null){var s=ze(c[1])?c[0]:c[1];s>=0?(c[0]=i,i+=s,c[1]=i):(c[0]=0,c[1]=0)}}}},gp={sign:yp,expand:Kv,none:Zu,silhouette:Bv,wiggle:zv,positive:hp},bp=(e,r,t)=>{var n,a=(n=gp[t])!==null&&n!==void 0?n:Zu,i=Mv().keys(r).value((l,c)=>Number(V(l,c,0))).order(Rv).offset(a),o=i(e);return o.forEach((l,c)=>{l.forEach((s,d)=>{var v=V(e[d],r[c],0);Array.isArray(v)&&v.length===2&&T(v[0])&&T(v[1])&&(s[0]=v[0],s[1]=v[1])})}),o};function mc(e){return e==null?void 0:String(e)}function Yr(e){var{axis:r,ticks:t,bandSize:n,entry:a,index:i,dataKey:o}=e;if(r.type==="category"){if(!r.allowDuplicatedCategory&&r.dataKey&&!G(a[r.dataKey])){var l=ac(t,"value",a[r.dataKey]);if(l)return l.coordinate+n/2}return t!=null&&t[i]?t[i].coordinate+n/2:null}var c=V(a,G(o)?r.dataKey:o),s=r.scale.map(c);return T(s)?s:null}var vo=e=>{var{axis:r,ticks:t,offset:n,bandSize:a,entry:i,index:o}=e;if(r.type==="category")return t[o]?t[o].coordinate+n:null;var l=V(i,r.dataKey,r.scale.domain()[o]);if(G(l))return null;var c=r.scale.map(l);return T(c)?c-a/2+n:null},xp=e=>{var{numericAxis:r}=e,t=r.scale.domain();if(r.type==="number"){var n=Math.min(t[0],t[1]),a=Math.max(t[0],t[1]);return n<=0&&a>=0?0:a<0?a:n}return t[0]},Pp=e=>{var r=e.flat(2).filter(T);return[Math.min(...r),Math.max(...r)]},Op=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],wp=(e,r,t)=>{if(e!=null)return Op(Object.keys(e).reduce((n,a)=>{var i=e[a];if(!i)return n;var{stackedData:o}=i,l=o.reduce((c,s)=>{var d=vc(s,r,t),v=Pp(d);return!N(v[0])||!N(v[1])?c:[Math.min(c[0],v[0]),Math.max(c[1],v[1])]},[1/0,-1/0]);return[Math.min(l[0],n[0]),Math.max(l[1],n[1])]},[1/0,-1/0]))},fo=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,po=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ue=(e,r,t)=>{if(e&&e.scale&&e.scale.bandwidth){var n=e.scale.bandwidth();if(!t||n>0)return n}if(e&&r&&r.length>=2){for(var a=Ln(r,d=>d.coordinate),i=1/0,o=1,l=a.length;o<l;o++){var c=a[o],s=a[o-1];i=Math.min(((c==null?void 0:c.coordinate)||0)-((s==null?void 0:s.coordinate)||0),i)}return i===1/0?0:i}return t?void 0:0};function mo(e){var{tooltipEntrySettings:r,dataKey:t,payload:n,value:a,name:i}=e;return Kr(Kr({},r),{},{dataKey:t,payload:n,value:a,name:i})}function qe(e,r){if(e)return String(e);if(typeof r=="string")return r}var Ap=(e,r)=>{if(r==="horizontal")return e.relativeX;if(r==="vertical")return e.relativeY},Ep=(e,r)=>r==="centric"?e.angle:e.radius,ir=e=>e.layout.width,or=e=>e.layout.height,jp=e=>e.layout.scale,yc=e=>e.layout.margin,Rn=x(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),zn=x(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Sp="data-recharts-item-index",hc="data-recharts-item-id",jt=60;function yo(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function Jt(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?yo(Object(t),!0).forEach(function(n){Ip(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):yo(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Ip(e,r,t){return(r=Cp(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Cp(e){var r=kp(e,"string");return typeof r=="symbol"?r:r+""}function kp(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var Dp=e=>e.brush.height;function Tp(e){var r=zn(e);return r.reduce((t,n)=>{if(n.orientation==="left"&&!n.mirror&&!n.hide){var a=typeof n.width=="number"?n.width:jt;return t+a}return t},0)}function $p(e){var r=zn(e);return r.reduce((t,n)=>{if(n.orientation==="right"&&!n.mirror&&!n.hide){var a=typeof n.width=="number"?n.width:jt;return t+a}return t},0)}function _p(e){var r=Rn(e);return r.reduce((t,n)=>n.orientation==="top"&&!n.mirror&&!n.hide?t+n.height:t,0)}function Np(e){var r=Rn(e);return r.reduce((t,n)=>n.orientation==="bottom"&&!n.mirror&&!n.hide?t+n.height:t,0)}var me=x([ir,or,yc,Dp,Tp,$p,_p,Np,cc,rp],(e,r,t,n,a,i,o,l,c,s)=>{var d={left:(t.left||0)+a,right:(t.right||0)+i},v={top:(t.top||0)+o,bottom:(t.bottom||0)+l},f=Jt(Jt({},v),d),m=f.bottom;f.bottom+=n,f=pp(f,c,s);var p=e-f.left-f.right,h=r-f.top-f.bottom;return Jt(Jt({brushBottom:m},f),{},{width:Math.max(p,0),height:Math.max(h,0)})}),Lp=x(me,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Ja=x(ir,or,(e,r)=>({x:0,y:0,width:e,height:r})),Mp=u.createContext(null),ae=()=>u.useContext(Mp)!=null,Bn=e=>e.brush,Kn=x([Bn,me,yc],(e,r,t)=>({height:e.height,x:T(e.x)?e.x:r.left,y:T(e.y)?e.y:r.top+r.height+r.brushBottom-((t==null?void 0:t.bottom)||0),width:T(e.width)?e.width:r.width})),sn=function(r,t){for(var n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];if(typeof console<"u"&&console.warn&&(t===void 0&&console.warn("LogUtils requires an error message argument"),!r))if(t===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(t.replace(/%s/g,()=>a[o++]))}},He={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},gc=(e,r,t)=>{var{width:n=He.width,height:a=He.height,aspect:i,maxHeight:o}=t,l=jr(n)?e:Number(n),c=jr(a)?r:Number(a);return i&&i>0&&(l?c=l/i:c&&(l=c*i),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Rp={width:0,height:0,overflow:"visible"},zp={width:0,overflowX:"visible"},Bp={height:0,overflowY:"visible"},Kp={},Wp=e=>{var{width:r,height:t}=e,n=jr(r),a=jr(t);return n&&a?Rp:n?zp:a?Bp:Kp};function Fp(e){var{width:r,height:t,aspect:n}=e,a=r,i=t;return a===void 0&&i===void 0?(a=He.width,i=He.height):a===void 0?a=n&&n>0?void 0:He.width:i===void 0&&(i=n&&n>0?void 0:He.height),{width:a,height:i}}function Aa(){return Aa=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},Aa.apply(null,arguments)}function ho(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function go(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?ho(Object(t),!0).forEach(function(n){Gp(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ho(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function Gp(e,r,t){return(r=Vp(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Vp(e){var r=Hp(e,"string");return typeof r=="symbol"?r:r+""}function Hp(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var bc=u.createContext(He.initialDimension);function Xp(e){return Ye(e.width)&&Ye(e.height)}function xc(e){var{children:r,width:t,height:n}=e,a=u.useMemo(()=>({width:t,height:n}),[t,n]);return Xp(a)?u.createElement(bc.Provider,{value:a},r):null}var Qa=()=>u.useContext(bc),Yp=u.forwardRef((e,r)=>{var{aspect:t,initialDimension:n=He.initialDimension,width:a,height:i,minWidth:o=He.minWidth,minHeight:l,maxHeight:c,children:s,debounce:d=He.debounce,id:v,className:f,onResize:m,style:p={}}=e,h=u.useRef(null),g=u.useRef();g.current=m,u.useImperativeHandle(r,()=>h.current);var[y,b]=u.useState({containerWidth:n.width,containerHeight:n.height}),P=u.useCallback((j,S)=>{b(I=>{var C=Math.round(j),D=Math.round(S);return I.containerWidth===C&&I.containerHeight===D?I:{containerWidth:C,containerHeight:D}})},[]);u.useEffect(()=>{if(h.current==null||typeof ResizeObserver>"u")return Ke;var j=D=>{var _,$=D[0];if($!=null){var{width:L,height:U}=$.contentRect;P(L,U),(_=g.current)===null||_===void 0||_.call(g,L,U)}};d>0&&(j=Wv(j,d,{trailing:!0,leading:!1}));var S=new ResizeObserver(j),{width:I,height:C}=h.current.getBoundingClientRect();return P(I,C),S.observe(h.current),()=>{S.disconnect()}},[P,d]);var{containerWidth:O,containerHeight:w}=y;sn(!t||t>0,"The aspect(%s) must be greater than zero.",t);var{calculatedWidth:A,calculatedHeight:E}=gc(O,w,{width:a,height:i,aspect:t,maxHeight:c});return sn(A!=null&&A>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,