forge-openclaw-plugin 0.2.98 → 0.2.100

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 (149) hide show
  1. package/dist/assets/activity-copy-Bj4h9OcF.js +1 -0
  2. package/dist/assets/activity-page-5oyCFOns.js +1 -0
  3. package/dist/assets/ai-surface-workspace-qgk_B57-.js +1 -0
  4. package/dist/assets/atlas-panel-rfH2qOez.js +1 -0
  5. package/dist/assets/{board-Ju0h0SeG.js → board-BkDRaMp6.js} +1 -1
  6. package/dist/assets/calendar-display-preferences-Cid-2RnL.js +1 -0
  7. package/dist/assets/calendar-page-Bo2iua-a.js +1 -0
  8. package/dist/assets/calendar-rules-DA1g3QUk.js +1 -0
  9. package/dist/assets/calendar-ui-Cy1XRwzV.js +1 -0
  10. package/dist/assets/calendar-week-toolbar-DU1Q4RYj.js +1 -0
  11. package/dist/assets/charts-P7EVhIog.js +36 -0
  12. package/dist/assets/companion-sync-lab-page-CosNknOK.js +1 -0
  13. package/dist/assets/daily-metrics-dashboard-LjuGAB3f.js +1 -0
  14. package/dist/assets/date-keys-Cj1G3TOn.js +1 -0
  15. package/dist/assets/entity-links-DwpxhW2H.js +1 -0
  16. package/dist/assets/entity-note-count-link-BmGDB572.js +1 -0
  17. package/dist/assets/entity-notes-surface-DgEgicaE.js +1 -0
  18. package/dist/assets/execution-board-CDRXQB85.js +1 -0
  19. package/dist/assets/faceted-token-search-CE1YauRd.js +1 -0
  20. package/dist/assets/flagship-signal-deck-DDds90Gl.js +1 -0
  21. package/dist/assets/floating-action-menu-CJkI2iFy.js +1 -0
  22. package/dist/assets/forms-BFlTgZ3W.js +1 -0
  23. package/dist/assets/goal-detail-page-cJvHaLMQ.js +1 -0
  24. package/dist/assets/goals-page-f_39hvUV.js +1 -0
  25. package/dist/assets/graph-BZV40eAE.css +1 -0
  26. package/dist/assets/graph-D6JLqDbD.js +318 -0
  27. package/dist/assets/habits-page-DKb96_mj.js +1 -0
  28. package/dist/assets/health-link-options-Cpx8w7uM.js +1 -0
  29. package/dist/assets/index-BHTUu_4M.js +19 -0
  30. package/dist/assets/index-CZbuZQjw.css +1 -0
  31. package/dist/assets/insight-flow-dialog-pzAzyayN.js +1 -0
  32. package/dist/assets/insights-page-Dc9oFltJ.js +8 -0
  33. package/dist/assets/kanban-page-JAxerYh6.js +1 -0
  34. package/dist/assets/knowledge-graph-page-UQ3skqEi.js +1 -0
  35. package/dist/assets/life-force-page-BGDbQuVh.js +1 -0
  36. package/dist/assets/life-force-workspace-B1fYSXRC.js +1 -0
  37. package/dist/assets/maps-B-YMMjus.css +1 -0
  38. package/dist/assets/maps-ClgJoCjz.js +803 -0
  39. package/dist/assets/metric-tile-DX6TclqM.js +1 -0
  40. package/dist/assets/{motion-DRPJkN3a.js → motion-BeD44FeG.js} +1 -1
  41. package/dist/assets/movement-page-6HP6nGJx.js +1 -0
  42. package/dist/assets/note-markdown-DiW2-5d3.js +3 -0
  43. package/dist/assets/note-tags-input-DDLXf54U.js +1 -0
  44. package/dist/assets/notes-page-BuguDjhz.js +1 -0
  45. package/dist/assets/open-in-graph-button-Cg5VrKsC.js +1 -0
  46. package/dist/assets/orbit-map-GD05-0oS.js +1 -0
  47. package/dist/assets/overview-page-DuOs2OCB.js +1 -0
  48. package/dist/assets/page-hero-CQWo1Mm_.js +1 -0
  49. package/dist/assets/pill-cluster-BJogDRDJ.js +1 -0
  50. package/dist/assets/preference-entity-handoff-button-D4WAs9pC.js +1 -0
  51. package/dist/assets/preferences-page-BaJTMU1I.js +1 -0
  52. package/dist/assets/project-collections-DvaX20q_.js +1 -0
  53. package/dist/assets/project-detail-page-drPIFZGb.js +1 -0
  54. package/dist/assets/project-management-hierarchy-page-BUbRXvny.js +1 -0
  55. package/dist/assets/project-management-section-nav-C2Ud8Zdd.js +1 -0
  56. package/dist/assets/projects-page-BGzEZUtg.js +1 -0
  57. package/dist/assets/psyche-behaviors-page-Dmm_Io9D.js +5 -0
  58. package/dist/assets/psyche-flashcards-page-BgNKJ6QJ.js +1 -0
  59. package/dist/assets/psyche-goal-map-page-DXJs98Vr.js +1 -0
  60. package/dist/assets/psyche-graph-CFgs_Bqc.js +1 -0
  61. package/dist/assets/psyche-metrics-page-zYTJDbyZ.js +1 -0
  62. package/dist/assets/psyche-mode-guide-page-XPgRfCOf.js +1 -0
  63. package/dist/assets/psyche-modes-page-B-GA8oRF.js +1 -0
  64. package/dist/assets/psyche-page--r6a3e1t.js +1 -0
  65. package/dist/assets/psyche-patterns-page-BM5-3bMm.js +5 -0
  66. package/dist/assets/psyche-questionnaire-builder-page-CJshQ-mg.js +1 -0
  67. package/dist/assets/psyche-questionnaire-detail-page-USmR5G5A.js +1 -0
  68. package/dist/assets/psyche-questionnaire-run-detail-page-D7iBCmTi.js +1 -0
  69. package/dist/assets/psyche-questionnaire-run-page-Cpil-kDh.js +1 -0
  70. package/dist/assets/psyche-questionnaires-page-C-_y3VwS.js +1 -0
  71. package/dist/assets/psyche-report-detail-page--dkSPRaj.js +3 -0
  72. package/dist/assets/psyche-reports-page-CUaOXmIN.js +1 -0
  73. package/dist/assets/psyche-schemas-HFmg37Wj.js +1 -0
  74. package/dist/assets/psyche-schemas-beliefs-page-BX6xaap3.js +9 -0
  75. package/dist/assets/psyche-screen-time-page-CAAI4mD7.js +1 -0
  76. package/dist/assets/psyche-self-observation-page-BZ6FLuwa.js +1 -0
  77. package/dist/assets/psyche-values-page-yEV6MGt8.js +5 -0
  78. package/dist/assets/query-cache-IQ8W-LNC.js +1 -0
  79. package/dist/assets/report-chain-fields-fZ8Xd4H6.js +1 -0
  80. package/dist/assets/rewards-page-C2HQjIAf.js +1 -0
  81. package/dist/assets/scheduling-rules-editor-BHOpHOrV.js +1 -0
  82. package/dist/assets/schema-badge-DyKbxb51.js +1 -0
  83. package/dist/assets/schema-visuals-D6nxjbYC.js +1 -0
  84. package/dist/assets/select-menu-BX-pZNqL.js +1 -0
  85. package/dist/assets/settings-agents-page-VuYXTiyc.js +6 -0
  86. package/dist/assets/settings-bin-page-BNzvYaOk.js +1 -0
  87. package/dist/assets/settings-calendar-page-CjSFB53S.js +5 -0
  88. package/dist/assets/settings-data-page-CGSlryuI.js +1 -0
  89. package/dist/assets/settings-logs-page-BTK5fine.js +1 -0
  90. package/dist/assets/settings-mobile-page-CRaObOGo.js +1 -0
  91. package/dist/assets/settings-models-page-DFshpYF8.js +1 -0
  92. package/dist/assets/settings-page-BP81Mb5R.js +1 -0
  93. package/dist/assets/settings-rewards-page-CDJ1PH2G.js +1 -0
  94. package/dist/assets/settings-section-nav-CCFm27r2.js +1 -0
  95. package/dist/assets/settings-users-page-TdUocFPa.js +1 -0
  96. package/dist/assets/settings-wiki-page-B2zX0QQG.js +1 -0
  97. package/dist/assets/sleep-page-cI1GMVzk.js +1 -0
  98. package/dist/assets/sports-page-06LTqp0V.js +1 -0
  99. package/dist/assets/state-B-4sS1xO.js +1 -0
  100. package/dist/assets/strategies-page-DXP9Kx8s.js +1 -0
  101. package/dist/assets/strategy-detail-page-D6mx_Mik.js +1 -0
  102. package/dist/assets/strategy-dialog-BvzomTaF.js +1 -0
  103. package/dist/assets/{table-DewbFlTh.js → table-WfAPUppN.js} +1 -1
  104. package/dist/assets/task-detail-page-BIWIggdp.js +1 -0
  105. package/dist/assets/timebox-planning-dialog-CaCnoslG.js +1 -0
  106. package/dist/assets/today-page-DO2mRPT2.js +1 -0
  107. package/dist/assets/training-load-page-CyZ0mlEr.js +1 -0
  108. package/dist/assets/{ui-C2IvSrAz.js → ui-C13Nbgas.js} +4 -4
  109. package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +1 -0
  110. package/dist/assets/vendor-CRS-psbw.css +1 -0
  111. package/dist/assets/vendor-DHkYh85p.js +1052 -0
  112. package/dist/assets/vitals-page-BQvEjTc6.js +1 -0
  113. package/dist/assets/weekly-review-page-Tp6Q9CRj.js +1 -0
  114. package/dist/assets/weight-loss-page-BBzlhLVV.js +1 -0
  115. package/dist/assets/wiki-article-markdown-DQYohmW2.js +4 -0
  116. package/dist/assets/wiki-editor-page-Dem_3eZv.js +26 -0
  117. package/dist/assets/wiki-ingest-history-page-BxoOcCoJ.js +1 -0
  118. package/dist/assets/wiki-ingest-modal-DhguKk3J.js +1 -0
  119. package/dist/assets/wiki-page-BLRxVXkl.js +1 -0
  120. package/dist/assets/workbench-flow-page-DqMkCCTy.js +5 -0
  121. package/dist/assets/workbench-page-BWd02wPw.js +1 -0
  122. package/dist/assets/workout-detail-page-BD8u7GyL.js +2 -0
  123. package/dist/index.html +148 -9
  124. package/dist/openclaw/tools.js +340 -0
  125. package/dist/server/server/migrations/065_weight_loss_nutrition_insights.sql +236 -0
  126. package/dist/server/server/migrations/066_watch_action_receipts.sql +20 -0
  127. package/dist/server/server/src/app.js +266 -13
  128. package/dist/server/server/src/health-weight-loss.js +1378 -0
  129. package/dist/server/server/src/health.js +188 -35
  130. package/dist/server/server/src/openapi.js +449 -0
  131. package/dist/server/server/src/services/context.js +6 -7
  132. package/dist/server/server/src/services/doctor.js +39 -4
  133. package/dist/server/server/src/services/gamification.js +146 -34
  134. package/dist/server/server/src/watch-mobile.js +564 -4
  135. package/dist/server/server/src/web.js +18 -5
  136. package/dist/server/src/components/ui/info-tooltip.js +48 -3
  137. package/dist/server/src/lib/api.js +131 -0
  138. package/dist/server/src/lib/weight-loss-types.js +1 -0
  139. package/openclaw.plugin.json +14 -1
  140. package/package.json +1 -1
  141. package/server/migrations/065_weight_loss_nutrition_insights.sql +236 -0
  142. package/server/migrations/066_watch_action_receipts.sql +20 -0
  143. package/skills/forge-openclaw/SKILL.md +26 -5
  144. package/skills/forge-openclaw/entity_conversation_playbooks.md +134 -5
  145. package/skills/forge-openclaw/psyche_entity_playbooks.md +45 -0
  146. package/dist/assets/index-Cn5Wpwau.css +0 -1
  147. package/dist/assets/index-CwvGs8n4.js +0 -91
  148. package/dist/assets/vendor-B-Lq_OG3.css +0 -1
  149. package/dist/assets/vendor-DL2K5ayT.js +0 -2186
@@ -0,0 +1 @@
1
+ import{r as p,j as e,aC as ee}from"./vendor-DHkYh85p.js";import{i as te,k as $}from"./state-B-4sS1xO.js";import{S as se}from"./settings-section-nav-CCFm27r2.js";import{P as ie}from"./page-hero-CQWo1Mm_.js";import{i as ae,C as ne,B as re,M as le}from"./graph-D6JLqDbD.js";import{C as S,aq as ce,c as f,U as C,Q as K,F as M,j as T,I as R,T as oe,W as de,u as he,eu as xe,ev as ue,ew as pe,B as X,ex as ge}from"./index-BHTUu_4M.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";const Q=[{id:"visibility",label:"Discovery and visibility",description:"What the source user can discover, inspect, and pull into read flows on the target side.",rights:[{key:"discoverable",label:"Discoverable",description:"The target appears as a reachable collaborator in the source user's graph and pickers."},{key:"canListUsers",label:"List users",description:"The source user can include the target in directory, comparison, and routing surfaces."},{key:"canReadProfile",label:"Read profile",description:"The source user can inspect the target's identity card, handle, type, and description."},{key:"canReadEntities",label:"Read entities",description:"The source user can read the target's goals, projects, tasks, notes, strategies, and related records."},{key:"canSearchEntities",label:"Search entities",description:"The source user can find the target's work through Forge search and entity pickers."}]},{id:"coordination",label:"Messaging, context, and handoff",description:"What the source user can message, connect, and coordinate on the target side before changing execution.",rights:[{key:"canLinkEntities",label:"Share context",description:"The source user can attach the target's records into shared notes, strategies, calendar context, and cross-owner plans."},{key:"canCoordinate",label:"Message and coordinate",description:"The source user can communicate with the target through Forge, hand off work, and coordinate execution."},{key:"canViewMetrics",label:"View metrics",description:"The source user can inspect the target's XP, alignment, and progress metrics."},{key:"canViewActivity",label:"View activity",description:"The source user can inspect the target's activity stream, evidence, and execution trail."}]},{id:"execution",label:"Plan and execution control",description:"What the source user can actually change on the target side once collaboration is trusted.",rights:[{key:"canManageStrategies",label:"Manage strategies",description:"The source user can draft and update strategies that belong to the target."},{key:"canCreateOnBehalf",label:"Create on behalf",description:"The source user can intentionally create new target-owned entities."},{key:"canAffectEntities",label:"Affect entities",description:"The source user can mutate work that belongs to the target."}]}],me=[{id:"full_collab",label:"Full collaboration",description:"Use when two humans or agents can see, coordinate, plan, and change each other's work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!0,canManageStrategies:!0,canCreateOnBehalf:!0,canViewMetrics:!0,canViewActivity:!0}},{id:"coordination_only",label:"Coordinate only",description:"Use when the source user may see and coordinate with the target but should not directly mutate target-owned work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!1,canManageStrategies:!0,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"observe_only",label:"Observe only",description:"Use when the source user should keep visibility into the target without planning or execution control.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"hidden",label:"Hidden edge",description:"Use when this direction should stop discovering, reading, or acting on the target.",rights:{discoverable:!1,canListUsers:!1,canReadProfile:!1,canReadEntities:!1,canSearchEntities:!1,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!1,canViewActivity:!1}}],I=Q.reduce((t,r)=>t+r.rights.length,0);function F(t){return Object.values(t.config.rights).filter(Boolean).length}function q(t){const r=[];return t.config.rights.canReadEntities&&r.push("See"),t.config.rights.canCoordinate&&r.push("Message"),t.config.rights.canManageStrategies&&r.push("Plan"),t.config.rights.canAffectEntities&&r.push("Affect"),r.join(" · ")||"Hidden"}function be(t){return!t.config.rights.discoverable&&!t.config.rights.canReadEntities?"Hidden":t.config.rights.canAffectEntities&&t.config.rights.canManageStrategies?"Trusted":t.config.rights.canCoordinate||t.config.rights.canLinkEntities?"Coordinated":"Observed"}function Z(t){return[{id:"see",label:"See",enabled:t.config.rights.discoverable&&t.config.rights.canReadEntities&&t.config.rights.canSearchEntities},{id:"message",label:"Message",enabled:t.config.rights.canCoordinate},{id:"share",label:"Share context",enabled:t.config.rights.canLinkEntities},{id:"plan",label:"Plan",enabled:t.config.rights.canManageStrategies},{id:"affect",label:"Affect",enabled:t.config.rights.canAffectEntities||t.config.rights.canCreateOnBehalf}]}function fe(t,r){return Object.entries(r.rights).every(([i,x])=>t.config.rights[i]===x)}function we(t,r){const i=t.filter(a=>a.kind==="human"),x=t.filter(a=>a.kind==="bot"),u={x:560,y:360},g={width:226,height:132},d=i[0]??null,v=[...i.slice(d?1:0).map(a=>({user:a,radius:245,offset:-90})),...x.map(a=>({user:a,radius:390,offset:-90}))],b=v.length,N=[...d?[{user:d,position:{x:u.x-g.width/2,y:u.y-g.height/2}}]:[],...v.map((a,o)=>{const h=(a.offset+360/Math.max(b,1)*o)*Math.PI/180;return{user:a.user,position:{x:u.x+Math.cos(h)*a.radius-g.width/2,y:u.y+Math.sin(h)*a.radius-g.height/2}}})],U=new Set(r.selectedGrant?[r.selectedGrant.subjectUserId,r.selectedGrant.targetUserId]:r.selectedUserId?[r.selectedUserId]:[]);return N.map(({user:a,position:o})=>{const h=U.has(a.id),s=a.id===r.selectedUserId;return{id:a.id,position:o,draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`min-w-[206px] rounded-[22px] border px-4 py-4 shadow-[0_24px_60px_rgba(0,0,0,0.28)] transition ${s?"border-[rgba(244,185,122,0.45)] bg-[rgba(27,16,10,0.92)]":h?"border-white/18 bg-[rgba(14,20,34,0.94)]":"border-white/10 bg-[rgba(9,15,28,0.92)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(C,{user:a}),e.jsx(f,{className:"bg-white/[0.08] text-white/65",children:a.kind})]}),e.jsxs("div",{className:"mt-3 text-xs text-white/52",children:["@",a.handle]}),e.jsx("div",{className:"mt-2 line-clamp-2 text-xs leading-5 text-white/46",children:a.description||"No user description yet."})]})},style:{background:"transparent",border:"none",padding:0}}})}function je(t,r,i){return t.filter(x=>x.subjectUserId!==x.targetUserId).map(x=>{const u=r===x.id,g=i!==null&&(x.subjectUserId===i||x.targetUserId===i),d=F(x),w=u?"#f4b97a":!x.config.rights.discoverable&&!x.config.rights.canReadEntities?"rgba(248,113,113,0.55)":g?"rgba(192,193,255,0.78)":"rgba(255,255,255,0.32)";return{id:x.id,source:x.subjectUserId,target:x.targetUserId,label:`${q(x)} · ${d}/${I}`,markerEnd:{type:le.ArrowClosed,color:w},labelStyle:{fill:u?"#f4b97a":"rgba(255,255,255,0.68)",fontSize:11,fontWeight:600},labelBgStyle:{fill:u?"rgba(34,23,16,0.96)":"rgba(8,13,24,0.94)",stroke:u?"rgba(244,185,122,0.36)":"rgba(255,255,255,0.14)",strokeWidth:1},labelBgPadding:[7,5],labelBgBorderRadius:8,style:{stroke:w,strokeWidth:u?2.5:g?1.8:1.25},animated:u}})}function ve({users:t,grants:r,selectedGrantId:i=null,selectedUserId:x=null,onOpenGrant:u,onOpenUser:g}){const d=r.find(o=>o.id===i)??null,w=p.useMemo(()=>we(t,{selectedUserId:x,selectedGrant:d}),[d,x,t]),v=p.useMemo(()=>je(r,i,x),[r,i,x]),b=p.useMemo(()=>r.filter(o=>o.subjectUserId!==o.targetUserId),[r]),N=b.filter(o=>F(o)===I).length,U=b.filter(o=>o.config.rights.canCoordinate).length,a=b.filter(o=>o.config.rights.canAffectEntities||o.config.rights.canCreateOnBehalf).length;return e.jsxs(S,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"grid gap-4 border-b border-white/8 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Directed relationship graph"}),e.jsx(ce,{content:"Keep Forge, OpenClaw, Hermes, and the browser on the same runtime and storage root when these arrows should describe one shared human and bot system.",label:"Explain the shared runtime rule"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Click a user card to open that user's settings. Click any arrow to open the exact directional relationship flow for that lane."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[b.length," edges"]}),e.jsxs(f,{className:"bg-emerald-500/12 text-emerald-200",children:[N," fully open"]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Full collaboration"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:N}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions still running with the default fully open posture."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination lanes"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:U}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to coordinate directly through Forge."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:a}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to create or mutate target-owned work."})]})]})]}),e.jsx("div",{className:"h-[min(72vh,54rem)] min-h-[34rem] bg-[radial-gradient(circle_at_top,rgba(244,185,122,0.08),transparent_34%),linear-gradient(180deg,rgba(6,10,20,0.97),rgba(8,14,26,0.94))]",children:e.jsxs(ae,{className:"user-relationship-flow",nodes:w,edges:v,fitView:!0,fitViewOptions:{padding:.18,maxZoom:.95},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:(o,h)=>{g(h.id)},onEdgeClick:(o,h)=>{u(h.id)},attributionPosition:"bottom-left",children:[e.jsx(ne,{showInteractive:!1}),e.jsx(re,{gap:28,size:1,color:"rgba(255,255,255,0.06)"})]})})]})}const Ne={kind:"human",handle:"",displayName:"",description:"",accentColor:"#c0c1ff"};function W(t){return t?{kind:t.kind,handle:t.handle,displayName:t.displayName,description:t.description,accentColor:t.accentColor}:Ne}function ye({open:t,onOpenChange:r,user:i,grants:x,ownership:u,xp:g,pending:d=!1,onSubmit:w,onOpenRelationship:v}){const[b,N]=p.useState(()=>W(i)),[U,a]=p.useState(null);p.useEffect(()=>{t&&(N(W(i)),a(null))},[t,i]);const o=p.useMemo(()=>x.filter(c=>c.subjectUserId!==c.targetUserId),[x]),h=p.useMemo(()=>i?o.filter(c=>c.subjectUserId===i.id):[],[o,i]),s=p.useMemo(()=>i?o.filter(c=>c.targetUserId===i.id):[],[o,i]),y=[{id:"identity",eyebrow:i?"Edit user":"Create user",title:i?"Update the user identity":"Add a human or bot user",description:"Set the owner type and the public identity Forge will use across ownership, routing, and collaboration surfaces.",render:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Kind",description:"Humans represent real people. Bots represent agents or automations with their own ownership lane.",children:e.jsx(T,{columns:2,value:c.kind,onChange:k=>m({kind:k}),options:[{value:"human",label:"Human",description:"Use for a real person in the Forge runtime."},{value:"bot",label:"Bot",description:"Use for an agent, assistant, or automation actor."}]})}),e.jsx(M,{label:"Handle",description:"This becomes the stable short id shown as @handle.",hint:"Use lowercase and a durable label, for example forge-operator or planner-bot.",children:e.jsx(R,{value:c.handle,onChange:k=>m({handle:k.target.value}),placeholder:"forge-operator"})}),e.jsx(M,{label:"Display name",description:"This is the human-readable label used across the UI.",children:e.jsx(R,{value:c.displayName,onChange:k=>m({displayName:k.target.value}),placeholder:"Forge Operator"})})]})},{id:"profile",eyebrow:"Profile",title:"Describe the user lane",description:"Capture what this user represents in the shared Forge runtime and pick the accent color that helps the lane stay recognizable.",render:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Description",description:"Explain what this user is responsible for and what side of the system it represents.",children:e.jsx(oe,{value:c.description,onChange:k=>m({description:k.target.value}),className:"min-h-36",placeholder:"Primary human operator for strategy, execution, and review."})}),e.jsx(M,{label:"Accent color",description:"Forge uses this accent to help the user stand out in ownership and collaboration surfaces.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{value:c.accentColor,onChange:k=>m({accentColor:k.target.value}),placeholder:"#c0c1ff"}),e.jsx("div",{className:"size-10 shrink-0 rounded-full border border-white/10",style:{backgroundColor:c.accentColor||"#c0c1ff"}})]})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Owned records"}),e.jsx("div",{className:"mt-2 text-white",children:(u==null?void 0:u.totalOwnedEntities)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Total XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.totalXp)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Weekly XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.weeklyXp)??0})]})]})]})},{id:"relationships",eyebrow:"Relationships",title:"Open directional relationship settings",description:"Each arrow is a separate contract. Open the exact lane you want to adjust and Forge will take you into the relationship flow.",render:()=>i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx(C,{user:i}),e.jsxs("div",{className:"mt-3 text-sm leading-6 text-white/56",children:["@",i.handle," · ",i.description||"No description yet."]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Outbound lanes"}),h.length>0?h.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:q(c)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(c),"/",I," rights"]})]})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No outbound relationship lanes yet."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Inbound lanes"}),s.length>0?s.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z(c).map(m=>e.jsx(f,{className:m.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:m.label},`${c.id}-${m.id}`))})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No inbound relationship lanes yet."})]})]})]}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm leading-6 text-white/52",children:"Create the user first, then Forge will generate the directional relationship lanes you can tune from here."})}];return e.jsx(K,{open:t,onOpenChange:r,eyebrow:i?"User settings":"Create user",title:i?"User settings":"Create user",description:"Edit the user identity, clarify what this lane represents, and jump into relationship settings without crowding the page.",value:b,onChange:N,draftPersistenceKey:i?`users.settings.${i.id}`:"users.settings.new",steps:y,submitLabel:i?"Save user":"Create user",pending:d,pendingLabel:i?"Saving user":"Creating user",error:U,contentClassName:"lg:w-[min(58rem,calc(100vw-1.5rem))]",onSubmit:async()=>{const c=b.handle.trim(),m=b.displayName.trim();if(c.length===0){a("Add a handle before saving this user.");return}if(m.length===0){a("Add a display name before saving this user.");return}await w({userId:i==null?void 0:i.id,input:{kind:b.kind,handle:c,displayName:m,description:b.description.trim(),accentColor:b.accentColor.trim()||"#c0c1ff"}}),r(!1)}})}function z(t,r){return{accessLevel:(t==null?void 0:t.accessLevel)??"manage",applyScope:"this_arrow",rights:{discoverable:(t==null?void 0:t.config.rights.discoverable)??!0,canListUsers:(t==null?void 0:t.config.rights.canListUsers)??!0,canReadProfile:(t==null?void 0:t.config.rights.canReadProfile)??!0,canReadEntities:(t==null?void 0:t.config.rights.canReadEntities)??!0,canSearchEntities:(t==null?void 0:t.config.rights.canSearchEntities)??!0,canLinkEntities:(t==null?void 0:t.config.rights.canLinkEntities)??!0,canCoordinate:(t==null?void 0:t.config.rights.canCoordinate)??!0,canAffectEntities:(t==null?void 0:t.config.rights.canAffectEntities)??!0,canManageStrategies:(t==null?void 0:t.config.rights.canManageStrategies)??!0,canCreateOnBehalf:(t==null?void 0:t.config.rights.canCreateOnBehalf)??!0,canViewMetrics:(t==null?void 0:t.config.rights.canViewMetrics)??!0,canViewActivity:(t==null?void 0:t.config.rights.canViewActivity)??!0}}}function ke({open:t,onOpenChange:r,grant:i,grants:x,pending:u=!1,onSubmit:g}){const d=p.useMemo(()=>i?x.find(a=>a.subjectUserId===i.targetUserId&&a.targetUserId===i.subjectUserId)??null:null,[i,x]),[w,v]=p.useState(()=>z(i,!!d));p.useEffect(()=>{t&&v(z(i,!!d))},[i,t,d]);const b=p.useMemo(()=>Object.values(w.rights).filter(Boolean).length,[w.rights]),N=Math.round(b/I*100),U=[{id:"posture",eyebrow:"Relationship posture",title:"Set the trust mode for this arrow",description:"Each arrow is directional. Decide whether you want to tune only this lane or mirror the same contract onto both directions.",render:(a,o)=>e.jsxs(e.Fragment,{children:[i?e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:i.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:i.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:be(i)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(i),"/",I," rights"]})]})]}):null,e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Access level"}),e.jsx(T,{columns:2,value:a.accessLevel,onChange:h=>o({accessLevel:h}),options:[{value:"view",label:"View",description:"Use when this lane should stay mostly observational."},{value:"manage",label:"Manage",description:"Use when the source side can actively collaborate or act."}]})]}),d?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Apply scope"}),e.jsx(T,{columns:2,value:a.applyScope,onChange:h=>o({applyScope:h}),options:[{value:"this_arrow",label:"This arrow",description:"Only change the exact direction you opened."},{value:"both_arrows",label:"Both arrows",description:"Mirror the same contract onto the reverse direction too."}]})]}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Quick preset"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:me.map(h=>e.jsxs("button",{type:"button",className:`rounded-[22px] border p-4 text-left transition ${i&&fe(i,h)?"border-[rgba(244,185,122,0.35)] bg-[rgba(244,185,122,0.08)]":"border-white/8 bg-white/[0.03] hover:bg-white/[0.05]"}`,onClick:()=>o({rights:{...a.rights,...h.rights}}),children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:h.description})]},h.id))})]})]})},{id:"rights",eyebrow:"Rights",title:"Tune the individual permissions",description:"Use the preset as the starting point, then sharpen the exact boundaries only where this relationship needs them.",render:(a,o)=>e.jsx(e.Fragment,{children:Q.map(h=>e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:h.description})]}),e.jsx("div",{className:"grid gap-2",children:h.rights.map(s=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:s.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/50",children:s.description})]}),e.jsx("input",{type:"checkbox",checked:a.rights[s.key],onChange:y=>o({rights:{...a.rights,[s.key]:y.target.checked}})})]},s.key))})]},h.id))})},{id:"review",eyebrow:"Review",title:"Review the final relationship contract",description:"Check the enabled capabilities, confirm whether both directions should match, and then save the relationship.",render:a=>{var o,h;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Capability coverage"}),e.jsx("div",{className:"mt-4",children:e.jsx(de,{value:N})}),e.jsxs("div",{className:"mt-3 text-sm text-white/62",children:[b,"/",I," rights enabled"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z({...i??{id:"draft",subjectUserId:"",targetUserId:"",accessLevel:a.accessLevel,config:{self:!1,mutable:!0,linkedEntities:!0,rights:a.rights},createdAt:"",updatedAt:"",subjectUser:null,targetUser:null},accessLevel:a.accessLevel,config:{...(i==null?void 0:i.config)??{self:!1,mutable:!0,linkedEntities:!0},rights:a.rights}}).map(s=>e.jsx(f,{className:s.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:s.label},s.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Save scope"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:a.applyScope==="both_arrows"&&d?"Forge will apply the same access level and rights to both directions of this pair.":"Forge will only update the exact arrow you opened."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:["access ",a.accessLevel]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:["scope"," ",a.applyScope==="both_arrows"&&d?"both arrows":"this arrow"]})]}),d?e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/54",children:["Reverse arrow available:"," ",((o=d.subjectUser)==null?void 0:o.displayName)??d.subjectUserId," ","→"," ",((h=d.targetUser)==null?void 0:h.displayName)??d.targetUserId]}):null]})]})})}}];return e.jsx(K,{open:t,onOpenChange:r,eyebrow:"Relationship settings",title:"Relationship settings",description:"Edit the exact directional contract between two users without keeping the full rights editor pinned on the page.",value:w,onChange:v,draftPersistenceKey:i?`users.relationship.${i.id}`:"users.relationship.new",steps:U,submitLabel:"Save relationship",pending:u,pendingLabel:"Saving relationship",contentClassName:"lg:w-[min(62rem,calc(100vw-1.5rem))]",onSubmit:async()=>{i&&(await g({grantId:i.id,patch:{accessLevel:w.accessLevel,rights:w.rights},reverseGrantId:(d==null?void 0:d.id)??null,applyToReverse:w.applyScope==="both_arrows"&&d!==null}),r(!1))}})}function Le(){var P;const t=he(),[r,i]=p.useState(null),[x,u]=p.useState(null),[g,d]=p.useState(!1),[w,v]=p.useState(!1),[b,N]=p.useState(""),U=te({queryKey:["forge-user-directory"],queryFn:ge}),a=async()=>{await Promise.all([t.refresh(),U.refetch()])},o=$({mutationFn:async({input:n,userId:l})=>l?(await xe(l,n)).user:(await ue(n)).user,onSuccess:async()=>{i(null),d(!1),await a()}}),h=$({mutationFn:async({grantId:n,patch:l})=>(await pe(n,l)).grant,onSuccess:a}),s=(P=U.data)==null?void 0:P.directory,y=(s==null?void 0:s.grants.find(n=>n.id===x))??null,c=p.useMemo(()=>new Map(((s==null?void 0:s.ownership)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.ownership]),m=p.useMemo(()=>new Map(((s==null?void 0:s.xp)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.xp]),k=p.useMemo(()=>{const n=new Map;for(const l of(s==null?void 0:s.grants)??[]){if(!l.targetUser||l.subjectUserId===l.targetUserId)continue;const j=n.get(l.subjectUserId)??[];j.push(l.targetUser),n.set(l.subjectUserId,j)}return n},[s==null?void 0:s.grants]),O=p.useMemo(()=>{const n=((s==null?void 0:s.grants)??[]).filter(l=>l.subjectUserId!==l.targetUserId);return{totalEdges:n.length,fullyOpenEdges:n.filter(l=>Object.values(l.config.rights).every(Boolean)).length,coordinationEdges:n.filter(l=>l.config.rights.canCoordinate).length,executionEdges:n.filter(l=>l.config.rights.canAffectEntities||l.config.rights.canCreateOnBehalf).length}},[s==null?void 0:s.grants]),A=b.trim().toLowerCase(),B=p.useMemo(()=>{const l=((s==null?void 0:s.users)??t.snapshot.users).filter(j=>A?[j.displayName,j.handle,j.kind,j.description].join(" ").toLowerCase().includes(A):!0);return{humans:l.filter(j=>j.kind==="human"),bots:l.filter(j=>j.kind==="bot")}},[s==null?void 0:s.users,A,t.snapshot.users]),J=(y==null?void 0:y.subjectUserId)??(r==null?void 0:r.id)??null,Y=(y==null?void 0:y.id)??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ie,{title:"Users",description:"Forge users can be human or bot. Ownership, search, and routing are prepared so work can move across both sides of the system.",badge:`${t.snapshot.users.length} users`}),e.jsx(se,{}),e.jsx(ye,{open:g,onOpenChange:d,user:r,grants:(s==null?void 0:s.grants)??[],ownership:r?c.get(r.id)??null:null,xp:r?m.get(r.id)??null:null,pending:o.isPending,onSubmit:async n=>{await o.mutateAsync(n)},onOpenRelationship:n=>{d(!1),u(n),v(!0)}}),e.jsx(ke,{open:w,onOpenChange:v,grant:y,grants:(s==null?void 0:s.grants)??[],pending:h.isPending,onSubmit:async n=>{await h.mutateAsync({grantId:n.grantId,patch:n.patch}),n.applyToReverse&&n.reverseGrantId&&await h.mutateAsync({grantId:n.reverseGrantId,patch:n.patch})}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Multi-user posture"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:(s==null?void 0:s.posture.summary)??"Forge is preparing modular user access while keeping the current posture permissive."})]}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:(s==null?void 0:s.posture.accessModel)??"permissive"})]}),e.jsx("div",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:e.jsx(R,{value:b,onChange:n=>N(n.target.value),placeholder:"Search human, bot, @handle, or description"})})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(S,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Multi-agent onboarding"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:"Forge now treats the users graph as the collaboration control plane. Create each human or bot here, keep the runtime shared, then narrow only the specific arrows that should stop seeing, coordinating, planning, or affecting another user."})]}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:"default open"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Directional edges"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.totalEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Fully open"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.fullyOpenEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.coordinationEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.executionEdges})]})]}),e.jsxs("div",{className:"grid gap-2 text-sm leading-6 text-white/56",children:[e.jsx("div",{children:"1. Create the human and bot users that should exist in the shared Forge system."}),e.jsx("div",{children:"2. Point OpenClaw, Hermes, and the browser at the same Forge runtime and storage root."}),e.jsx("div",{children:"3. Use the graph below to decide what each direction can see, message, plan, or change."}),e.jsx("div",{children:"4. Keep strategy drafting open while the plan is negotiated, then lock the strategy once it becomes the contract."})]})]}),e.jsx(ve,{users:(s==null?void 0:s.users)??t.snapshot.users,grants:(s==null?void 0:s.grants)??[],selectedGrantId:Y,selectedUserId:J,onOpenUser:n=>{const l=((s==null?void 0:s.users)??t.snapshot.users).find(j=>j.id===n)??null;u(null),i(l),d(!0)},onOpenGrant:n=>{i(null),u(n),v(!0)}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Agent onboarding"}),e.jsx("div",{className:"text-sm leading-6 text-white/60",children:"OpenClaw, Hermes, and the Forge UI all read this same multi-user graph. Keep the defaults open while you are still wiring collaboration, then narrow specific arrows when one user or agent should stop seeing, messaging, planning, or changing another user's work."}),e.jsx("div",{className:"text-sm leading-6 text-white/52",children:"Forge now treats every owner as either human or bot, keeps search cross-user by default, and allows cross-owner links plus explicit coordination lanes between projects, tasks, notes, and strategies."}),e.jsx("div",{children:e.jsx(ee,{to:"/settings/agents",className:"inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-3 py-2 text-[13px] font-medium text-white transition hover:bg-white/12",children:"Open agent onboarding"})})]})]}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"User directory"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:"Open any user to edit its identity and jump into the exact directional relationship lanes from the user settings flow."})]}),e.jsx(X,{onClick:()=>{u(null),i(null),d(!0)},children:"Create user"})]})}),e.jsx("div",{className:"grid gap-5",children:[{title:"Human users",users:B.humans},{title:"Bot users",users:B.bots}].map(n=>e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:n.title}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:n.users.length})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:n.users.map(l=>{var j,D,G,_,H,V;return e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(C,{user:l}),e.jsxs("div",{className:"mt-3 text-sm text-white/58",children:["@",l.handle]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:l.description||"No description yet."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[((j=m.get(l.id))==null?void 0:j.totalXp)??0," XP"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((D=m.get(l.id))==null?void 0:D.weeklyXp)??0," weekly"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((G=m.get(l.id))==null?void 0:G.rewardEventCount)??0," ","rewards"]}),Object.entries(((_=c.get(l.id))==null?void 0:_.entityCounts)??{}).sort((E,L)=>L[1]-E[1]).slice(0,4).map(([E,L])=>e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[L," ",E]},`${l.id}-${E}`)),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((H=c.get(l.id))==null?void 0:H.totalOwnedEntities)??0," ","owned"]})]}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-white/50",children:["Can currently read:"," ",(k.get(l.id)??[]).map(E=>`${E.displayName} (${E.kind})`).join(", ")||"no other users"]}),(V=m.get(l.id))!=null&&V.lastRewardAt?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-white/45",children:["Last XP movement:"," ",new Date(m.get(l.id).lastRewardAt).toLocaleString()]}):null]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(X,{variant:"secondary",onClick:()=>{u(null),i(l),d(!0)},children:"Open settings"})})]})},l.id)})})]},n.title))})]})]})}export{Le as SettingsUsersPage};
@@ -0,0 +1 @@
1
+ import{r,j as e,aC as W,bg as H,c7 as T,cD as Y,cE as Z}from"./vendor-DHkYh85p.js";import{j as X,i as Q,k as x}from"./state-B-4sS1xO.js";import{S as J}from"./settings-section-nav-CCFm27r2.js";import{P as ee}from"./page-hero-CQWo1Mm_.js";import{bV as ie,bW as se,bX as te,bY as ae,bZ as ne,L as re,E as q,B as p,C as w,c as j,aq as de,I as l,b_ as le,b$ as ce}from"./index-BHTUu_4M.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const R=[{value:"gpt-5.4",label:"GPT-5.4",description:"Highest quality drafting for long, connected wiki pages."},{value:"gpt-5.4-mini",label:"GPT-5.4 mini",description:"Balanced speed and quality for regular ingest jobs."},{value:"gpt-5.4-nano",label:"GPT-5.4 nano",description:"Fastest and cheapest option for smaller imports."}];R[1].value;const oe="medium",me="medium";function he(s){const t=s==null?void 0:s.reasoningEffort;return t==="none"||t==="low"||t==="medium"||t==="high"||t==="xhigh"?t:oe}function xe(s){const t=s==null?void 0:s.verbosity;return t==="low"||t==="medium"||t==="high"?t:me}function z(s){var m;return{model:((m=R.find(g=>g.value===s.model))==null?void 0:m.label)??s.model,reasoning:he(s.metadata),verbosity:xe(s.metadata),hasKey:!!s.secretId}}function ke(){var F,O;const s=X(),[t,m]=r.useState(""),[g,y]=r.useState(""),[N,f]=r.useState("personal"),[u,U]=r.useState("Fast wiki search"),[b,B]=r.useState("text-embedding-3-small"),[k,_]=r.useState("https://api.openai.com/v1"),[S,C]=r.useState(""),[L,D]=r.useState("1200"),[P,G]=r.useState("200"),c=Q({queryKey:["forge-wiki-settings"],queryFn:le}),V=Q({queryKey:["forge-settings"],queryFn:ce}),h=async()=>{await Promise.all([s.invalidateQueries({queryKey:["forge-wiki-settings"]}),s.invalidateQueries({queryKey:["forge-wiki-pages"]}),s.invalidateQueries({queryKey:["forge-wiki-page"]}),s.invalidateQueries({queryKey:["forge-wiki-search"]})])},K=x({mutationFn:()=>ie({label:t.trim(),description:g.trim(),visibility:N}),onSuccess:async()=>{m(""),y(""),f("personal"),await h()}}),A=x({mutationFn:()=>se({label:u.trim(),model:b.trim(),baseUrl:k.trim(),apiKey:S.trim()||void 0,chunkSize:Number(L),chunkOverlap:Number(P)}),onSuccess:async()=>{C(""),await h()}}),I=x({mutationFn:({kind:i,profileId:o})=>te(i,o),onSuccess:h}),E=x({mutationFn:()=>ae(),onSuccess:h}),M=x({mutationFn:()=>ne(),onSuccess:h});if(c.isLoading)return e.jsx(re,{eyebrow:"KarpaWiki settings",title:"Loading KarpaWiki controls",description:"Fetching spaces and profile configuration for KarpaWiki."});if(c.isError)return e.jsx(q,{eyebrow:"KarpaWiki settings",error:c.error,onRetry:()=>void c.refetch()});const n=(F=c.data)==null?void 0:F.settings;if(!n)return e.jsx(q,{eyebrow:"KarpaWiki settings",error:new Error("Forge returned an empty KarpaWiki settings payload."),onRetry:()=>void c.refetch()});const d=n.llmProfiles.find(i=>i.enabled)??n.llmProfiles[0]??null,v=d?z(d):null,$="Canonical knowledge lives in SQLite notes, with Forge maintaining metadata, links, search, and optional embedding indexes in the database. Text search and entity-linked search work without embeddings, while semantic search stays additive and profile-driven. Ingest jobs can create pages and media assets now, with room for richer OCR, transcription, and multimodal compilation later.",a=(O=V.data)==null?void 0:O.settings.modelSettings.forgeAgent.wiki;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ee,{eyebrow:"SQLite memory",title:"KarpaWiki Settings",titleText:"KarpaWiki Settings",description:"Configure SQLite-backed spaces, parse models, and embedding profiles for the KarpaWiki memory system.",badge:`${n.spaces.length} spaces · ${n.embeddingProfiles.length} embedding profiles`,actions:e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"secondary",pending:E.isPending,pendingLabel:"Syncing",onClick:()=>void E.mutateAsync(),children:"Refresh indexes"}),e.jsx(p,{pending:M.isPending,pendingLabel:"Reindexing",onClick:()=>void M.mutateAsync(),disabled:n.embeddingProfiles.length===0,children:"Reindex embeddings"})]})}),e.jsx(J,{}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{className:"grid gap-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Auto-ingest model"}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"KarpaWiki ingest now reads its credentials and model slot from the dedicated Models settings page instead of owning the OpenAI setup flow here."})]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.8fr)_minmax(24rem,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-5 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(22,32,49,0.9),rgba(12,18,31,0.9))] p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Current profile"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:(a==null?void 0:a.connectionLabel)??(d==null?void 0:d.label)??"No external KarpaWiki model selected"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:a!=null&&a.connectionLabel?"Forge now resolves wiki ingest through the selected Models connection and syncs the managed wiki profile automatically.":"Pick a Models connection when you want Forge wiki ingest to run through the OpenAI API or a local compatible endpoint."})]}),e.jsx(W,{to:"/settings/models",className:"inline-flex min-h-11 items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:"Open model settings"})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Model"}),e.jsx("div",{className:"mt-2 text-white",children:(a==null?void 0:a.model)??(v==null?void 0:v.model)??"Not set"})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Provider"}),e.jsx("div",{className:"mt-2 text-white",children:(a==null?void 0:a.connectionLabel)??"Not set"})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Endpoint"}),e.jsx("div",{className:"mt-2 flex items-center gap-2 text-white",children:(a==null?void 0:a.baseUrl)??(d==null?void 0:d.baseUrl)??"Not set"})]})]})]}),e.jsxs("div",{className:"grid gap-3 rounded-[28px] border border-white/8 bg-white/[0.03] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Supported controls"}),e.jsxs("div",{className:"text-sm leading-6 text-white/58",children:["OpenAI API and local compatible endpoints are configured under Settings ","->"," Models. OpenAI Codex OAuth lives there as a chat agent path, while Wiki keeps the SQLite memory controls here and consumes the selected ingest model slot."]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["GPT-5.4","GPT-5.4 mini","GPT-5.4 nano"].map(i=>e.jsx(j,{className:"bg-white/[0.06] text-white/78",children:i},i))}),e.jsxs(W,{to:"/settings/models",className:"inline-flex min-h-11 items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:["Open model settings",e.jsx(H,{className:"ml-2 size-4"})]})]})]}),e.jsxs("div",{className:"grid gap-3",children:[n.llmProfiles.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-5 text-sm leading-6 text-white/58",children:"No LLM profile yet. Set up OpenAI once, test it, and Forge will use it for wiki auto-ingest."}):null,n.llmProfiles.map(i=>{const o=z(i);return e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsxs("div",{className:"mt-1 text-xs text-white/46",children:[o.model," · thinking ",o.reasoning," · verbosity ",o.verbosity]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",className:"rounded-full p-2 text-white/48 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>void I.mutateAsync({kind:"llm",profileId:i.id}),children:e.jsx(T,{className:"size-4"})})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-white/58",children:[e.jsx(j,{className:"bg-white/[0.06] text-white/76",children:i.baseUrl}),e.jsx(j,{className:"bg-white/[0.06] text-white/76",children:o.hasKey?"key saved":"key missing"})]})]},i.id)})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm text-white",children:"Spaces"}),e.jsx(de,{content:$,label:"Explain the wiki operating model"})]}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"Personal and shared wiki spaces map to explicit SQLite namespaces."})]})]}),e.jsx("div",{className:"grid gap-3",children:n.spaces.map(i=>e.jsxs("div",{className:"grid gap-1 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:i.visibility})]}),e.jsx("div",{className:"text-xs text-white/46",children:i.slug}),e.jsx("div",{className:"text-sm text-white/60",children:i.description||"No description yet."})]},i.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsx(l,{value:t,onChange:i=>m(i.target.value),placeholder:"New space label"}),e.jsx(l,{value:g,onChange:i=>y(i.target.value),placeholder:"Description"}),e.jsxs("select",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:N,onChange:i=>f(i.target.value),children:[e.jsx("option",{value:"personal",children:"Personal"}),e.jsx("option",{value:"shared",children:"Shared"})]}),e.jsx(p,{pending:K.isPending,pendingLabel:"Creating",disabled:!t.trim(),onClick:()=>void K.mutateAsync(),children:"Create space"})]})]}),e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Embedding profiles"}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"Semantic search stays opt-in. The recommended starter is fast and cheap, with heading-aware chunking for agent memory retrieval."})]})]}),e.jsx("div",{className:"grid gap-3",children:n.embeddingProfiles.map(i=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsx("button",{type:"button",className:"rounded-full p-2 text-white/48 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>void I.mutateAsync({kind:"embedding",profileId:i.id}),children:e.jsx(T,{className:"size-4"})})]}),e.jsxs("div",{className:"text-xs text-white/46",children:[i.model," · ",i.baseUrl]}),e.jsxs("div",{className:"text-sm text-white/60",children:["chunkSize ",i.chunkSize," · overlap"," ",i.chunkOverlap]})]},i.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsx(l,{value:u,onChange:i=>U(i.target.value),placeholder:"Profile label"}),e.jsx(l,{value:b,onChange:i=>B(i.target.value),placeholder:"Model"}),e.jsx(l,{value:k,onChange:i=>_(i.target.value),placeholder:"Base URL"}),e.jsx(l,{value:S,onChange:i=>C(i.target.value),placeholder:"API key (optional)",type:"password"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(l,{value:L,onChange:i=>D(i.target.value),placeholder:"Chunk size",type:"number"}),e.jsx(l,{value:P,onChange:i=>G(i.target.value),placeholder:"Chunk overlap",type:"number"})]}),e.jsx(p,{pending:A.isPending,pendingLabel:"Saving",disabled:!u.trim()||!b.trim(),onClick:()=>void A.mutateAsync(),children:"Save embedding profile"})]})]})]})]})]})}export{ke as SettingsWikiPage};
@@ -0,0 +1 @@
1
+ import{r as g,j as e,aV as te,cq as se,bX as ae}from"./vendor-DHkYh85p.js";import{j as re,i as A,k as ie}from"./state-B-4sS1xO.js";import{u as ne,eC as de,S as le,E as ce,ck as oe,eD as xe,eE as me,C as S,c as p,eF as he,Z as v,B as C,I as Q,T as pe,m as ue,bL as ge,eG as we,bw as be,bx as ve,by as fe,bz as je,bC as ye}from"./index-BHTUu_4M.js";import{P as Ne}from"./page-hero-CQWo1Mm_.js";import{p as Se,b as ke}from"./health-link-options-Cpx8w7uM.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const Ae=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],W={awake:{label:"Awake",strong:"rgba(251, 191, 36, 0.95)",soft:"rgba(251, 191, 36, 0.16)",text:"text-amber-200"},core:{label:"Core",strong:"rgba(165, 180, 252, 0.96)",soft:"rgba(165, 180, 252, 0.18)",text:"text-indigo-100"},deep:{label:"Deep",strong:"rgba(45, 212, 191, 0.96)",soft:"rgba(45, 212, 191, 0.18)",text:"text-teal-100"},rem:{label:"REM",strong:"rgba(96, 165, 250, 0.96)",soft:"rgba(96, 165, 250, 0.18)",text:"text-sky-100"},in_bed:{label:"In bed",strong:"rgba(255, 255, 255, 0.4)",soft:"rgba(255, 255, 255, 0.1)",text:"text-white/72"},asleep_unspecified:{label:"Asleep",strong:"rgba(196, 181, 253, 0.96)",soft:"rgba(196, 181, 253, 0.16)",text:"text-violet-100"}};function I(t){return W[t]??W.asleep_unspecified}function u(t){if(t<=0)return"0m";const s=Math.floor(t/3600),a=Math.round(t%3600/60);return s===0?`${a}m`:a===0?`${s}h`:`${s}h ${a}m`}function Te(t){const s=Math.round(t/60);return s===0?"on baseline":`${s>0?"+":"-"}${Math.abs(s)}m`}function R(t){return`${Math.round(t*100)}%`}function T(t,s){return t?new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",timeZone:s}).format(new Date(t)):"n/a"}function O(t,s){return new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:s}).format(new Date(t))}function q(t,s,a){return`${T(t,a)} - ${T(s,a)}`}function Re(t){const[s,a]=t.split("-").map(Number);return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(s,(a??1)-1,1))}function U(t){const s=new Date(t),a=(t.getDay()+6)%7;return s.setDate(t.getDate()-a),s}function Me(t){const s=U(t);return s.setDate(s.getDate()+6),s}function _e(t){const s=t.getFullYear(),a=`${t.getMonth()+1}`.padStart(2,"0"),r=`${t.getDate()}`.padStart(2,"0");return`${s}-${a}-${r}`}function B(t){return{qualitySummary:typeof t.annotations.qualitySummary=="string"?t.annotations.qualitySummary:"",notes:typeof t.annotations.notes=="string"?t.annotations.notes:"",tagsText:Array.isArray(t.annotations.tags)?t.annotations.tags.join(", "):"",linkValues:Array.isArray(t.links)?t.links.map(s=>`${s.entityType}:${s.entityId}`):[]}}function De(t,s){if(!t)return[];const[a,r]=t.split("-").map(Number),n=new Date(a,(r??1)-1,1),x=new Date(a,r??1,0),d=U(n),h=Me(x),l=new Map(s.map(c=>[c.dateKey,c])),i=[];for(const c=new Date(d);c<=h;c.setDate(c.getDate()+1)){const j=_e(c);i.push({dateKey:j,dayNumber:c.getDate(),outsideMonth:c.getMonth()!==n.getMonth(),sleep:l.get(j)??null})}return i}function Ie(t){return t>0?"text-emerald-200":t<0?"text-rose-200":"text-white/70"}function G(t){return t==="recharged"||t==="recovered"?"bg-emerald-400/16 text-emerald-100":t==="steady"||t==="stable"?"bg-sky-400/16 text-sky-100":t==="fragile"||t==="strained"?"bg-amber-400/16 text-amber-100":t==="depleted"?"bg-rose-400/16 text-rose-100":"bg-white/10 text-white/76"}function Be(t){return t==="provider_raw"?"bg-emerald-400/16 text-emerald-100":t==="historical_raw"?"bg-amber-400/16 text-amber-100":"bg-white/10 text-white/70"}function qe(t){return t==="provider_raw"?"Provider raw data":t==="historical_raw"?"Historical raw data":"Raw data unavailable"}function Ce(t){return t.qualityKind==="provider_native"?"bg-emerald-400/16 text-emerald-100":"bg-amber-400/16 text-amber-100"}function $e(t,s){const a=t.stage;if(typeof a=="string"&&a.trim().length>0)return a;const r=t.sourceType;if(typeof r=="string"&&r.trim().length>0)return r;const n=t.stageBreakdown;if(Array.isArray(n)&&n.length>0){const x=n[0];if(x&&typeof x=="object"&&typeof x.stage=="string")return(x.stage||"asleep_unspecified").trim()}return s.includes("awake")?"awake":"asleep_unspecified"}function Ee(t){const s=t,a=(s==null?void 0:s.segments)??(s==null?void 0:s.rawSegments)??[],r=(s==null?void 0:s.auditLogs)??(s==null?void 0:s.rawLogs)??[],n=s!=null&&s.sourceRecords&&s.sourceRecords.length>0?s.sourceRecords:r.filter(d=>typeof d.startedAt=="string"&&typeof d.endedAt=="string").map(d=>({id:d.id,importRunId:d.importRunId,pairingSessionId:d.pairingSessionId,sleepSessionId:d.sleepSessionId,userId:d.userId,provider:d.source,providerRecordType:d.logType,providerRecordUid:d.externalUid??d.id,sourceDevice:"",sourceTimezone:d.sourceTimezone,localDateKey:d.localDateKey,startedAt:d.startedAt,endedAt:d.endedAt,rawStage:$e(d.payload,d.logType),rawValue:null,qualityKind:"historical_import",payload:d.payload,metadata:d.metadata,ingestedAt:d.createdAt})),x=(s==null?void 0:s.rawDataStatus)??(n.length>0?"historical_raw":"raw_unavailable");return{sourceRecords:n,segments:a,auditLogs:r,rawDataStatus:x}}function J({stages:t}){const s=t.reduce((a,r)=>a+r.seconds,0);return t.length===0||s===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No stage composition was stored for this night yet."}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"flex h-3 overflow-hidden rounded-full bg-white/[0.08]",children:t.map(a=>{const r=I(a.stage);return e.jsx("div",{className:"h-full",style:{width:`${Math.max(4,a.seconds/s*100)}%`,background:r.strong},title:`${r.label} · ${u(a.seconds)}`},a.stage)})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:t.map(a=>{const r=I(a.stage),n="percentage"in a&&typeof a.percentage=="number"?a.percentage:s>0?a.seconds/s:0;return e.jsxs("div",{className:"rounded-[16px] border border-white/8 px-3 py-3",style:{background:r.soft},children:[e.jsx("div",{className:v("text-sm font-medium",r.text),children:r.label}),e.jsx("div",{className:"mt-1 text-lg text-white",children:u(a.seconds)}),e.jsx("div",{className:"text-xs text-white/54",children:R(n)})]},a.stage)})})]})}function H({blocks:t,selectedBlockId:s,onSelect:a}){return e.jsxs("div",{className:"relative h-12 overflow-hidden rounded-[18px] border border-white/8 bg-black/20",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(90deg,rgba(255,255,255,0.06)_1px,transparent_1px)] bg-[length:25%_100%]"}),t.map(r=>{const n=I(r.stage),x=s===r.id;return e.jsx("button",{type:"button",onClick:()=>a(r.id),className:v("absolute inset-y-[5px] rounded-[12px] border transition",x?"border-white/60 shadow-[0_0_0_1px_rgba(255,255,255,0.18)]":"border-white/10"),style:{left:`${r.offsetRatio*100}%`,width:`${Math.max(r.widthRatio*100,1.8)}%`,background:n.strong},title:`${r.label} · ${u(r.durationSeconds)} · ${r.startedAt} - ${r.endedAt}`,children:r.widthRatio>.13?e.jsx("span",{className:"truncate px-2 text-[10px] font-medium text-slate-950/85",children:r.label}):null},r.id)})]})}function Ke({timeline:t,timeZone:s}){var l,i;const a=t.blocks.filter(c=>c.lane==="in_bed"),r=t.blocks.filter(c=>c.lane==="sleep"),n=((l=r[0])==null?void 0:l.id)??((i=a[0])==null?void 0:i.id)??null,[x,d]=g.useState(n);g.useEffect(()=>{d(n)},[n,t.startedAt,t.endedAt,t.totalSeconds]);const h=t.blocks.find(c=>c.id===x)??null;return t.hasRawSegments?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[a.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed window"}),e.jsx(H,{blocks:a,selectedBlockId:x,onSelect:d})]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:t.hasSleepStageData?"Sleep phases":"Recorded sleep coverage"}),e.jsx(H,{blocks:r.length>0?r:a,selectedBlockId:x,onSelect:d})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-white/48",children:[e.jsx("span",{children:T(t.startedAt,s)}),e.jsx("span",{children:u(t.totalSeconds)}),e.jsx("span",{children:T(t.endedAt,s)})]}),h?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:v("text-sm font-medium",I(h.stage).text),children:h.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:[T(h.startedAt,s)," -"," ",T(h.endedAt,s)]})]}),e.jsx(p,{tone:"meta",children:u(h.durationSeconds)})]})}):null]}):e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-5 text-sm text-white/56",children:"Phase timing is unavailable for this night. Forge still keeps the canonical overnight summary, but the companion did not store segment-level timing."})}function Fe({latestNight:t}){return t?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(135deg,rgba(7,17,40,0.96),rgba(16,24,54,0.94))] p-0",children:e.jsxs("div",{className:"relative overflow-hidden px-6 py-6 sm:px-7 sm:py-7",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top_right,rgba(96,165,250,0.22),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(45,212,191,0.14),transparent_34%)]"}),e.jsxs("div",{className:"relative grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(p,{className:v("border-white/0",G(t.recoveryState)),children:t.qualitativeState}),e.jsx(p,{tone:"meta",children:t.sourceTimezone}),t.hasReflection?e.jsx(p,{tone:"meta",children:"Has reflection"}):null,t.hasRawSegments?e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}):null]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Last night"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-end gap-x-4 gap-y-2",children:[e.jsx("div",{className:"text-[clamp(2.5rem,6vw,5rem)] font-medium leading-none text-white",children:u(t.asleepSeconds)}),e.jsxs("div",{className:"pb-2 text-sm text-white/58",children:["asleep across ",q(t.startedAt,t.endedAt,t.sourceTimezone)]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/64",children:O(t.endedAt,t.sourceTimezone)}),t.qualitySummary?e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/72",children:t.qualitySummary}):e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/56",children:"Canonical overnight summary computed from synced sleep segments, with raw evidence still available underneath."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Score"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.score??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Regularity"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.regularity??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(t.efficiency)})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Baseline"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Compared with recent nights"})]}),e.jsx(se,{className:"size-5 text-[var(--primary)]"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"7-night average"}),e.jsx("span",{className:"text-sm text-white",children:u(t.weeklyAverageSleepSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Versus baseline"}),e.jsx("span",{className:v("text-sm",Ie(t.deltaFromWeeklyAverageSeconds)),children:Te(t.deltaFromWeeklyAverageSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Bedtime drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.bedtimeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Wake drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.wakeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Restorative share"}),e.jsx("span",{className:"text-sm text-white",children:R(t.restorativeShare)})]})]})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 px-5 py-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]})]})]})}):e.jsxs(S,{className:"overflow-hidden p-6",children:[e.jsx("div",{className:"text-sm uppercase tracking-[0.18em] text-white/42",children:"Sleep"}),e.jsx("div",{className:"mt-4 text-2xl text-white",children:"No overnight sleep yet"}),e.jsx("div",{className:"mt-3 max-w-2xl text-sm leading-6 text-white/58",children:"The sleep page will switch to a night-first summary once the companion syncs a canonical overnight session."})]})}function F({title:t,value:s,description:a}){return e.jsxs(S,{className:"h-full border-white/8 bg-white/[0.03]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:t}),e.jsx("div",{className:"mt-3 text-3xl text-white",children:s}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/56",children:a})]})}function ze({days:t,selectedSleepId:s,onSelect:a}){const r=g.useMemo(()=>Array.from(new Set(t.map(l=>l.dateKey.slice(0,7)))).sort((l,i)=>l.localeCompare(i)),[t]),[n,x]=g.useState(r[r.length-1]??"");g.useEffect(()=>{if(r.length===0){x("");return}r.includes(n)||x(r[r.length-1]??"")},[n,r]);const d=r.indexOf(n),h=g.useMemo(()=>De(n,t),[t,n]);return n?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(12,20,40,0.96))] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",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-white/42",children:"Sleep calendar"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:Re(n)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d<=0,onClick:()=>x(r[Math.max(0,d-1)]??n),children:"Previous"}),e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d===-1||d>=r.length-1,onClick:()=>x(r[Math.min(r.length-1,d+1)]??n),children:"Next"})]})]}),e.jsx("div",{className:"grid grid-cols-7 gap-2 text-center text-[11px] uppercase tracking-[0.16em] text-white/38",children:Ae.map(l=>e.jsx("div",{children:l},l))}),e.jsx("div",{className:"grid grid-cols-7 gap-2",children:h.map(l=>{const i=l.sleep,c=(i==null?void 0:i.sleepId)===s,j=i&&typeof i.score=="number"?i.score>=80?"rgba(45,212,191,0.22)":i.score>=65?"rgba(96,165,250,0.22)":"rgba(251,191,36,0.18)":"rgba(255,255,255,0.04)";return e.jsxs("button",{type:"button",disabled:!i,"aria-pressed":c,"aria-label":`Select sleep for ${l.dateKey}`,onClick:()=>{i&&(x(i.dateKey.slice(0,7)),a(i.sleepId,i.dateKey.slice(0,7)))},className:v("min-h-[90px] rounded-[18px] border px-2 py-2 text-left transition",i?"border-white/10 hover:border-white/22 hover:bg-white/[0.05]":"border-white/6 bg-white/[0.02]",c&&"border-[var(--primary)] bg-[var(--primary)]/12",l.outsideMonth&&!i&&"opacity-35"),style:i?{background:`linear-gradient(180deg, ${j}, rgba(255,255,255,0.03))`}:void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:v("text-sm",l.outsideMonth?"text-white/40":"text-white/82"),children:l.dayNumber}),i!=null&&i.hasReflection?e.jsx("span",{className:"size-2 rounded-full bg-emerald-300"}):null]}),i?e.jsxs("div",{className:"mt-4 grid gap-1",children:[e.jsxs("div",{className:"text-lg text-white",children:[i.sleepHours.toFixed(1),"h"]}),e.jsxs("div",{className:"text-xs text-white/52",children:[i.score??"n/a"," score"]}),e.jsx("div",{className:"text-xs text-white/40",children:i.hasRawSegments?"phases available":"summary only"})]}):null]},l.dateKey)})})]})}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-5 py-8 text-sm leading-6 text-white/56",children:"No canonical nights are available for the calendar yet."})}function z({active:t,children:s,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:v("rounded-full border px-4 py-2 text-sm transition",t?"border-[var(--primary)] bg-[var(--primary)]/12 text-white":"border-white/8 bg-white/[0.03] text-white/60 hover:text-white"),children:s})}function Le({session:t,draft:s,rawDetail:a,rawDetailLoading:r,pending:n,tab:x,linkOptions:d,onTabChange:h,onDraftChange:l,onSave:i}){const[c,j]=g.useState(null),y=g.useMemo(()=>Ee(a),[a]),$=typeof t.derived.efficiency=="number"?t.derived.efficiency:t.timeInBedSeconds>0?t.asleepSeconds/t.timeInBedSeconds:0,E=typeof t.derived.restorativeShare=="number"?t.derived.restorativeShare:0,M=typeof t.derived.recoveryState=="string"?t.derived.recoveryState:null;return e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(13,20,38,0.96))] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",G(M)),children:M?M.replaceAll("_"," "):"Canonical night"}),e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}),e.jsx(p,{tone:"meta",children:t.sourceTimezone})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Selected night"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:O(t.endedAt,t.sourceTimezone)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:q(t.startedAt,t.endedAt,t.sourceTimezone)})]}),e.jsxs("div",{className:"grid gap-2 text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Summary"}),e.jsx("div",{className:"text-3xl text-white",children:u(t.asleepSeconds)}),e.jsx("div",{className:"text-sm text-white/54",children:"asleep"})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Awake"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.awakeSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R($)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Restorative"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(E)})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(z,{active:x==="summary",onClick:()=>h("summary"),children:"Summary"}),e.jsx(z,{active:x==="reflection",onClick:()=>h("reflection"),children:"Reflection"}),e.jsx(z,{active:x==="raw",onClick:()=>h("raw"),children:"Show raw data"})]}),x==="summary"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Phase timeline"}),e.jsx("div",{className:"mt-4",children:r?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-6 text-sm text-white/56",children:"Loading phase timing from raw sleep segments…"}):e.jsx(Ke,{timeline:(a==null?void 0:a.phaseTimeline)??{startedAt:t.startedAt,endedAt:t.endedAt,totalSeconds:Math.max(0,Math.round((new Date(t.endedAt).getTime()-new Date(t.startedAt).getTime())/1e3)),hasRawSegments:!1,hasSleepStageData:!1,blocks:[]},timeZone:t.sourceTimezone})})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]}):null,x==="reflection"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Quality summary"}),e.jsx(Q,{value:s.qualitySummary,onChange:o=>l({qualitySummary:o.target.value}),placeholder:"Recovered after a late evening, but sleep onset drifted."})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Night notes"}),e.jsx(pe,{className:"min-h-[200px]",value:s.notes,onChange:o=>l({notes:o.target.value}),placeholder:"What shaped this night, and what should we remember about it?"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx(Q,{value:s.tagsText,onChange:o=>l({tagsText:o.target.value}),placeholder:"travel, stress, good-routine, late-caffeine"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Linked context"}),e.jsx(ue,{options:d,selectedValues:s.linkValues,onChange:o=>l({linkValues:o}),placeholder:"Search goals, tasks, habits, beliefs, reports, or patterns…"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{type:"button",pending:n,pendingLabel:"Saving",onClick:i,children:[e.jsx(ae,{className:"size-4"}),"Save reflection"]})})]}):null,x==="raw"?e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4 text-sm leading-6 text-white/56",children:"Forge shows the canonical overnight session by default. This view reveals the evidence stack underneath it: raw provider or historical imported records first, then Forge-normalized sleep segments."}),r?e.jsx("div",{className:"text-sm text-white/56",children:"Loading raw sleep evidence…"}):null,r?null:e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",Be(y.rawDataStatus)),children:qe(y.rawDataStatus)}),y.rawDataStatus==="historical_raw"?e.jsx(p,{tone:"meta",children:"Partial evidence"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Raw data"}),y.sourceRecords.length?y.sourceRecords.map(o=>e.jsxs("div",{className:"rounded-[16px] border border-white/8 bg-black/18 px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",Ce(o)),children:o.qualityKind==="provider_native"?"Provider raw":"Historical raw"}),e.jsx(p,{tone:"meta",className:"capitalize",children:o.rawStage.replaceAll("_"," ")}),e.jsx("span",{className:"text-sm text-white/64",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-white/42",children:o.providerRecordType.replaceAll("_"," ")}),e.jsx(C,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3",onClick:()=>j(_=>_===o.id?null:o.id),children:c===o.id?"Hide JSON":"See JSON"})]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/50",children:u(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))}),c===o.id?e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[14px] border border-white/8 bg-slate-950/70 p-3 text-xs leading-6 text-white/72",children:JSON.stringify({payload:o.payload,metadata:o.metadata},null,2)}):null]},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No raw data was stored for this night."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Sleep segments"}),y.segments.length?y.segments.map(o=>e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-black/18 px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{tone:"meta",className:"capitalize",children:o.stage.replaceAll("_"," ")}),e.jsx(p,{tone:"meta",children:o.qualityKind==="provider_native"?"provider-backed":"historical"}),e.jsx("span",{className:"text-sm text-white/64",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsx("span",{className:"text-sm text-white/50",children:u(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))})]})},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No normalized sleep segments were stored for this night."})]})]})]}):null]})})}function Xe(){var V;const t=ne(),s=re(),[a,r]=g.useState({}),[n,x]=g.useState(null),[d,h]=g.useState("summary"),l=Array.isArray(t==null?void 0:t.selectedUserIds)?t.selectedUserIds:[],i=t==null?void 0:t.snapshot,c=A({queryKey:["forge-sleep",...l],queryFn:async()=>(await ge(l)).sleep}),j=A({queryKey:["forge-sleep-raw",n],enabled:!!n,queryFn:async()=>we(n)}),y=A({queryKey:["forge-sleep-values",...l],queryFn:async()=>(await be(l)).values}),$=A({queryKey:["forge-sleep-patterns",...l],queryFn:async()=>(await ve(l)).patterns}),E=A({queryKey:["forge-sleep-behaviors",...l],queryFn:async()=>(await fe(l)).behaviors}),M=A({queryKey:["forge-sleep-beliefs",...l],queryFn:async()=>(await je(l)).beliefs}),o=A({queryKey:["forge-sleep-reports",...l],queryFn:async()=>(await ye(l)).reports});g.useEffect(()=>{c.data&&r(Object.fromEntries(c.data.sessions.map(m=>[m.id,B(m)])))},[c.data]),g.useEffect(()=>{var N,f,k;if(!((N=c.data)!=null&&N.sessions.length)){x(null);return}c.data.sessions.some(K=>K.id===n)||x(((f=c.data.latestNight)==null?void 0:f.sleepId)??((k=c.data.sessions[0])==null?void 0:k.id)??null)},[n,c.data]),g.useEffect(()=>{h("summary")},[n]);const _=ie({mutationFn:async m=>de(m.sleepId,{qualitySummary:m.qualitySummary,notes:m.notes,tags:m.tagsText.split(",").map(N=>N.trim()).filter(Boolean),links:Se(m.linkValues)}),onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-sleep"]}),await s.invalidateQueries({queryKey:["forge-sleep-raw"]})}});if(c.isLoading)return e.jsx(le,{eyebrow:"Sleep",title:"Loading sleep surface",description:"Reading canonical nights, calendar summaries, and sleep phase detail.",columns:2,blocks:6});if(c.isError||!c.data)return e.jsx(ce,{eyebrow:"Sleep",error:c.error??new Error("Sleep data unavailable"),onRetry:()=>void c.refetch()});const w=c.data,D=w.sessions,L=new Map(D.map(m=>[m.id,m])),b=(n?L.get(n):null)??(w.latestNight?L.get(w.latestNight.sleepId):null)??D[0]??null,P=b?a[b.id]??B(b):null,Y=ke({goals:(i==null?void 0:i.dashboard.goals)??[],projects:(i==null?void 0:i.dashboard.projects)??[],tasks:(i==null?void 0:i.dashboard.tasks)??[],habits:(i==null?void 0:i.dashboard.habits)??[],values:y.data??[],patterns:$.data??[],behaviors:E.data??[],beliefs:M.data??[],reports:o.data??[]});function X(m,N){r(f=>{const k=D.find(ee=>ee.id===m),K=f[m]??(k?B(k):{qualitySummary:"",notes:"",tagsText:"",linkValues:[]});return{...f,[m]:{...K,...N}}})}async function Z(m){const N=D.find(k=>k.id===m);if(!N)return;const f=a[m]??B(N);await _.mutateAsync({sleepId:m,qualitySummary:f.qualitySummary,notes:f.notes,tagsText:f.tagsText,linkValues:f.linkValues})}return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ne,{eyebrow:"Health",title:"Sleep",description:"Canonical overnight sessions first, with last-night recovery, a clickable night calendar, and raw segment evidence only when you ask for it.",badge:`${D.length} nights`}),e.jsx(oe,{}),e.jsx(xe,{children:e.jsx(Fe,{latestNight:w.latestNight})}),e.jsx(me,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)]",children:[e.jsx(F,{title:"Weekly average",value:u(w.summary.averageSleepSeconds),description:"Average overnight sleep duration across the recent week, used as the baseline for the latest-night comparison."}),e.jsx(F,{title:"Regularity",value:`${w.summary.averageRegularityScore}`,description:`Average bedtime drift ${w.summary.averageBedtimeConsistencyMinutes}m and wake drift ${w.summary.averageWakeConsistencyMinutes}m.`}),e.jsx(F,{title:"Restorative share",value:R(w.summary.averageRestorativeShare),description:`Deep + REM share across recent nights, with ${w.summary.reflectiveNightCount} nights already carrying context.`}),e.jsxs(S,{className:"border-white/8 bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Recent stage mix"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:"Average nightly phases"})]}),e.jsx(te,{className:"size-5 text-[var(--primary)]"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:w.stageAverages.length>0?w.stageAverages.slice(0,5).map(m=>e.jsxs(p,{tone:"meta",children:[I(m.stage).label," ",u(m.averageSeconds)]},m.stage)):e.jsx("div",{className:"text-sm text-white/52",children:"Stage averages will appear once nights include phase data."})})]})]})}),e.jsx(he,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ze,{days:w.calendarDays,selectedSleepId:(b==null?void 0:b.id)??null,onSelect:m=>x(m)}),b&&P?e.jsx(Le,{session:b,draft:P,rawDetail:j.data??null,rawDetailLoading:j.isLoading,pending:_.isPending&&((V=_.variables)==null?void 0:V.sleepId)===b.id,tab:d,linkOptions:Y,onTabChange:h,onDraftChange:m=>X(b.id,m),onSave:()=>void Z(b.id)}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-6 py-8 text-sm leading-6 text-white/58",children:"Pick a night from the calendar to inspect its phase timing, stage summary, and reflection context."})]})})]})}export{Xe as SleepPage};
@@ -0,0 +1 @@
1
+ import{r as u,j as e,aC as Ve,bI as Ne,aV as Pe,b8 as ke,bK as qe,bX as Qe}from"./vendor-DHkYh85p.js";import{j as Ze,i as O,k as Ue}from"./state-B-4sS1xO.js";import{u as Ge,eH as Xe,S as Ye,E as Je,eI as et,C as g,eJ as Y,c as o,I as $,eK as tt,aS as at,T as st,m as it,B as ie,bM as rt,bw as nt,bx as lt,by as ct,bz as dt,bC as ot}from"./index-BHTUu_4M.js";import{F as ve}from"./faceted-token-search-CE1YauRd.js";import{P as xt}from"./page-hero-CQWo1Mm_.js";import{f as ht}from"./date-keys-Cj1G3TOn.js";import{p as mt,b as pt}from"./health-link-options-Cpx8w7uM.js";import{R as P,A as ut,C as J,X as q,Y as B,T as Q,a as ye,f as we,B as re,g as gt,e as jt,h as ft,b as ne,S as vt,i as yt}from"./charts-P7EVhIog.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const U={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"},I=["below_z1","zone_1","zone_2","zone_3","zone_4","zone_5"];function z(t){return t?t.replace(/^activity_/i,"").replaceAll("_"," ").replace(/\s+/g," ").replace(/\b\w/g,i=>i.toUpperCase()):"Unknown"}function W(t){return`${Math.round(t/60)}m`}function ce(t){return t?`${(t/1e3).toFixed(1)} km`:"n/a"}function G(t,i){const s=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${s.format(new Date(t))} · ${l.format(new Date(t))} - ${l.format(new Date(i))}`}function te(t){return ht(new Date(t))}function Z(t){return{subjectiveEffort:t.subjectiveEffort!==null?String(t.subjectiveEffort):"",moodBefore:t.moodBefore??"",moodAfter:t.moodAfter??"",meaningText:t.meaningText??"",plannedContext:t.plannedContext??"",socialContext:t.socialContext??"",tagsText:Array.isArray(t.tags)?t.tags.join(", "):"",linkValues:Array.isArray(t.links)?t.links.map(i=>`${i.entityType}:${i.entityId}`):[]}}function Se(t){return t.trim().toLowerCase()}function j(t){var i;return((i=t.workoutTypeLabel)==null?void 0:i.trim())||z(t.workoutType)}function H(t){var i;return((i=t.activityFamilyLabel)==null?void 0:i.trim())||z(t.activityFamily)}function Ae(t){return z(t.sourceSystem??t.source)}function wt(t){return t==null?"n/a":typeof t=="boolean"?t?"Yes":"No":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(1):t}function bt(t){const i=wt(t.value);return!t.unit||t.unit==="count"?i:`${i} ${t.unit}`}function Nt(t,i){return Se([t.workoutType,j(t),t.activityFamily,H(t),t.sourceSystem,Ae(t),t.sourceType,t.sourceDevice,t.reconciliationStatus,t.moodBefore,t.moodAfter,t.meaningText,t.plannedContext,t.socialContext,t.tags.join(" "),i.moodBefore,i.moodAfter,i.meaningText,i.plannedContext,i.socialContext,i.tagsText,G(t.startedAt,t.endedAt)].join(" "))}function kt(t){const i=new Map;for(const s of t)i.set(`workout:${s.workoutType}`,{id:`workout:${s.workoutType}`,label:j(s),description:"Workout type",searchText:`${j(s)} workout`,badge:e.jsx(o,{tone:"meta",children:j(s)})}),i.set(`source:${s.sourceType}`,{id:`source:${s.sourceType}`,label:s.sourceType.replaceAll("_"," "),description:"Source type",searchText:`${s.sourceType} source`,badge:e.jsx(o,{tone:"meta",className:"capitalize",children:s.sourceType.replaceAll("_"," ")})}),i.set(`status:${s.reconciliationStatus}`,{id:`status:${s.reconciliationStatus}`,label:s.reconciliationStatus.replaceAll("_"," "),description:"Reconciliation status",searchText:`${s.reconciliationStatus} status`,badge:e.jsx(o,{tone:"meta",className:"capitalize",children:s.reconciliationStatus.replaceAll("_"," ")})});return i.set("linked:yes",{id:"linked:yes",label:"Linked",description:"Already tied to Forge or Psyche context",badge:e.jsx(o,{tone:"meta",children:"Linked"})}),i.set("linked:no",{id:"linked:no",label:"Needs links",description:"No Forge or Psyche links yet",badge:e.jsx(o,{tone:"meta",children:"Needs links"})}),i.set("habit:yes",{id:"habit:yes",label:"Habit-generated",description:"Created from a habit completion",badge:e.jsx(o,{tone:"meta",children:"Habit-generated"})}),i.set("effort:rated",{id:"effort:rated",label:"Effort rated",description:"Already has a subjective effort score",badge:e.jsx(o,{tone:"meta",children:"Effort rated"})}),Array.from(i.values())}function St(t,i){return i.every(s=>s.startsWith("workout:")?t.workoutType===s.slice(8):s.startsWith("source:")?t.sourceType===s.slice(7):s.startsWith("status:")?t.reconciliationStatus===s.slice(7):s==="linked:yes"?t.links.length>0:s==="linked:no"?t.links.length===0:s==="habit:yes"?!!t.generatedFromHabitId:s==="effort:rated"?t.subjectiveEffort!==null:!0)}function ee(t,i,s){if(!t||t.length===0)return null;const l=[...t].filter(c=>c.dateKey<=i&&c[s]!=null).sort((c,f)=>f.dateKey.localeCompare(c.dateKey))[0];return(l==null?void 0:l[s])??null}function At(t){return[t.workoutType,t.workoutTypeLabel,t.activityFamily,t.activityFamilyLabel].filter(Boolean).join(" ").toLowerCase().includes("kickboxing")}function Ct(t){const i=new Map;for(const s of t){const l=`type:${s.workoutType}`;i.set(l,{id:l,label:j(s),description:H(s),searchText:`${j(s)} ${H(s)} ${s.workoutType}`,badge:e.jsx(o,{tone:"meta",children:j(s)})})}return[...i.values()].sort((s,l)=>s.label.localeCompare(l.label))}function Tt(t,i,s,l,c){const f=i.filter(x=>x.startsWith("type:")).map(x=>x.slice(5)),v=new Set(f),T=te(new Date().toISOString()),w=new Date(`${T}T12:00:00.000Z`);w.setUTCDate(w.getUTCDate()-90);const n=w.toISOString().slice(0,10);return t.filter(x=>{if(v.size>0&&!v.has(x.workoutType))return!1;const h=te(x.startedAt);return s==="recent_90"?h>=n:!(s==="custom"&&(l&&h<l||c&&h>c))}).sort((x,h)=>Date.parse(x.startedAt)-Date.parse(h.startedAt))}function le(t){var s;const i=Object.fromEntries(I.map(l=>[l,0]));for(const l of t)for(const c of((s=l.analytics)==null?void 0:s.zoneDurations)??[])I.includes(c.key)&&(i[c.key]+=c.seconds);return i}function be(t){const i=Object.values(t).reduce((s,l)=>s+l,0);return Object.fromEntries(I.map(s=>[s,i>0?Number((t[s]/i*100).toFixed(1)):0]))}function Mt(t,i,s){const l=typeof(s==null?void 0:s.dataKey)=="string"?s.dataKey:typeof i=="string"?i:"",c=typeof t=="number"?Number(t.toFixed(1)):String(t??"n/a");return l==="restingHeartRate"||i==="Resting HR"?[`${c} bpm`,"Resting HR"]:l==="vo2Max"||i==="VO2max"?[`${c} ml/kg/min`,"VO2max"]:[`${c}%`,z(l)]}function Rt(t,i){const s=t.map((n,x)=>{var y,M,D;const h=te(n.startedAt),N=t.slice(Math.max(0,x-2),x+1),b=le(N),C=be(b);return{id:n.id,dateKey:h,date:h.slice(5),session:j(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((y=n.analytics)==null?void 0:y.confidence)??"unavailable",restingHeartRate:((D=(M=n.analytics)==null?void 0:M.hrSummary)==null?void 0:D.restingHr)??ee(i,h,"restingHeartRate"),vo2Max:ee(i,h,"vo2Max"),...C}}),l=t.map((n,x)=>{var C,y,M;const h=te(n.startedAt),N=le(t.slice(0,x+1)),b=be(N);return{id:n.id,dateKey:h,date:h.slice(5),session:j(n),durationMinutes:Math.round(n.durationSeconds/60),confidence:((C=n.analytics)==null?void 0:C.confidence)??"unavailable",restingHeartRate:((M=(y=n.analytics)==null?void 0:y.hrSummary)==null?void 0:M.restingHr)??ee(i,h,"restingHeartRate"),vo2Max:ee(i,h,"vo2Max"),...b}}),c=le(t),f=Object.values(c).reduce((n,x)=>n+x,0),v=I.map(n=>{var h;const x=((h=t.flatMap(N=>{var b;return((b=N.analytics)==null?void 0:b.zoneDurations)??[]}).find(N=>N.key===n))==null?void 0:h.label)??z(n);return{key:n,zone:x,percentage:f>0?Number((c[n]/f*100).toFixed(1)):0,fill:U[n]??"#f8fafc"}}),T=t.filter(n=>{var x,h;return(((h=(x=n.analytics)==null?void 0:x.dataQuality)==null?void 0:h.heartRateSampleCount)??0)>0}).length,w=[...new Set(t.map(n=>j(n)))];return{sessions:t,lineData:s,expandingLineData:l,averageZoneData:v,rawHrCount:T,exerciseLabels:w}}function Et({session:t,draft:i,linkOptions:s,pending:l,step:c,onStepChange:f,onDraftChange:v,onSave:T}){var n,x,h,N,b,C,y,M,D;const w=[{id:"context",title:"Session context",description:"Quick facts, effort, and how this session happened."},{id:"reflection",title:"Reflection",description:"Mood, meaning, and what the session actually did for you."},{id:"links",title:"Links",description:"Tie the session back to Forge and Psyche context."}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[24px] bg-white/[0.04] p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-lg text-white",children:[e.jsx(Ne,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:j(t)})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:G(t.startedAt,t.endedAt)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{children:W(t.durationSeconds)}),t.totalEnergyKcal?e.jsxs(o,{tone:"meta",children:[Math.round(t.totalEnergyKcal)," kcal"]}):null,t.distanceMeters?e.jsx(o,{tone:"meta",children:ce(t.distanceMeters)}):null,e.jsx(o,{tone:"meta",children:H(t)}),e.jsx(o,{tone:"meta",className:"capitalize",children:t.reconciliationStatus.replaceAll("_"," ")})]})]})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:w.map((r,L)=>e.jsxs("button",{type:"button",onClick:()=>f(L),className:`rounded-[20px] border px-4 py-3 text-left transition ${c===L?"border-[var(--primary)] bg-[var(--primary)]/10 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.06] hover:text-white"}`,children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:["Step ",L+1]}),e.jsx("div",{className:"mt-2 text-sm font-medium",children:r.title})]},r.id))}),e.jsxs("div",{className:"rounded-[24px] bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:w[c].title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:w[c].description}),c===0?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Activity family"}),e.jsx("div",{className:"mt-2 text-lg text-white capitalize",children:H(t)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Source system"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:Ae(t)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Source device"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.sourceDevice||"n/a"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Steps"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.stepCount??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Avg HR"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.averageHeartRate?Math.round(t.averageHeartRate):"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Max HR"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:t.maxHeartRate?Math.round(t.maxHeartRate):"n/a"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Effort"}),e.jsx($,{type:"number",min:1,max:10,value:i.subjectiveEffort,onChange:r=>v({subjectiveEffort:r.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Planned vs spontaneous"}),e.jsx($,{value:i.plannedContext,onChange:r=>v({plannedContext:r.target.value}),placeholder:"Planned recovery block"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Social context"}),e.jsx($,{value:i.socialContext,onChange:r=>v({socialContext:r.target.value}),placeholder:"Solo, coach, group class, partner"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx($,{value:i.tagsText,onChange:r=>v({tagsText:r.target.value}),placeholder:"recovery, interval-block, stress-release"})]})]}):null,c===1?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Mood before"}),e.jsx($,{value:i.moodBefore,onChange:r=>v({moodBefore:r.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Mood after"}),e.jsx($,{value:i.moodAfter,onChange:r=>v({moodAfter:r.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Meaning, impact, and why this session mattered"}),e.jsx(st,{className:"min-h-[160px]",value:i.meaningText,onChange:r=>v({meaningText:r.target.value}),placeholder:"This session was planned as active recovery after a heavy work block and helped reset stress before sleep."})]})]}):null,c===2?e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Search goals, projects, habits, values, beliefs, patterns, or reports and attach the ones that explain this session."}),e.jsx(it,{options:s,selectedValues:i.linkValues,onChange:r=>v({linkValues:r}),placeholder:"Search Forge and Psyche records…"})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 border-t border-white/8 pt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Captured data"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Source-native workout metrics, events, and phases exposed through the adapter layer."})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:[(((n=t.details)==null?void 0:n.metrics)??[]).slice(0,12).map(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:r.label}),e.jsx("div",{className:"mt-2 text-lg text-white",children:bt(r)}),e.jsxs("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-white/38",children:[z(r.category)," · ",z(r.statistic)]})]},`${r.category}:${r.key}:${r.statistic}`)),(((h=(x=t.details)==null?void 0:x.metrics)==null?void 0:h.length)??0)===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/50",children:"No provider metrics were captured for this session yet."}):null]}),(((b=(N=t.details)==null?void 0:N.events)==null?void 0:b.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Workout events"}),e.jsx("div",{className:"grid gap-2",children:(C=t.details)==null?void 0:C.events.map(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-white",children:r.label}),e.jsx(o,{tone:"meta",children:W(r.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:G(r.startedAt,r.endedAt??r.startedAt)})]},`${r.type}:${r.startedAt}`))})]}):null,(((M=(y=t.details)==null?void 0:y.components)==null?void 0:M.length)??0)>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Workout phases"}),e.jsx("div",{className:"grid gap-2",children:(D=t.details)==null?void 0:D.components.map(r=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"text-white",children:r.activity.canonicalLabel}),e.jsx(o,{tone:"meta",children:W(r.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:G(r.startedAt,r.endedAt??r.startedAt)})]},r.externalUid))})]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-white/48",children:c<w.length-1?"Move through the session one step at a time, then save when the context is clean.":"Everything is in place. Save the session metadata back into Forge."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ie,{type:"button",variant:"secondary",onClick:()=>f(Math.max(0,c-1)),disabled:c===0,children:"Back"}),c<w.length-1?e.jsxs(ie,{type:"button",onClick:()=>f(c+1),children:["Next",e.jsx(ke,{className:"size-4"})]}):null,e.jsxs(ie,{type:"button",pending:l,pendingLabel:"Saving",onClick:T,children:[e.jsx(Qe,{className:"size-4"}),"Save session"]})]})]})]})}function Pt(){var je,fe;const t=Ge(),i=Ze(),s=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[l,c]=u.useState({}),[f,v]=u.useState(""),[T,w]=u.useState([]),[n,x]=u.useState([]),[h,N]=u.useState(""),[b,C]=u.useState("all"),[y,M]=u.useState("rolling_stack"),[D,r]=u.useState(""),[L,Ce]=u.useState(""),[de,Te]=u.useState(!1),[oe,ae]=u.useState(null),[Me,X]=u.useState(0),k=O({queryKey:["forge-fitness",...s],queryFn:async()=>(await rt(s)).fitness}),Re=O({queryKey:["forge-health-values",...s],queryFn:async()=>(await nt(s)).values}),Ee=O({queryKey:["forge-health-patterns",...s],queryFn:async()=>(await lt(s)).patterns}),ze=O({queryKey:["forge-health-behaviors",...s],queryFn:async()=>(await ct(s)).behaviors}),De=O({queryKey:["forge-health-beliefs",...s],queryFn:async()=>(await dt(s)).beliefs}),Fe=O({queryKey:["forge-health-reports",...s],queryFn:async()=>(await ot(s)).reports});u.useEffect(()=>{k.data&&c(Object.fromEntries(k.data.sessions.map(a=>[a.id,Z(a)])))},[k.data]),u.useEffect(()=>{if(de||!k.data)return;const d=(k.data.analysisSessions??k.data.sessions).find(At);d&&x([`type:${d.workoutType}`]),Te(!0)},[de,k.data]);const se=Ue({mutationFn:async a=>Xe(a.workoutId,{subjectiveEffort:a.subjectiveEffort.trim().length>0?Number(a.subjectiveEffort):null,moodBefore:a.moodBefore,moodAfter:a.moodAfter,meaningText:a.meaningText,plannedContext:a.plannedContext,socialContext:a.socialContext,tags:a.tagsText.split(",").map(d=>d.trim()).filter(Boolean),links:mt(a.linkValues)}),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-fitness"]})}}),F=k.data,S=(F==null?void 0:F.sessions)??[],K=(F==null?void 0:F.analysisSessions)??S,$e=pt({goals:t.snapshot.dashboard.goals,projects:t.snapshot.dashboard.projects,tasks:t.snapshot.dashboard.tasks,habits:t.snapshot.dashboard.habits,values:Re.data??[],patterns:Ee.data??[],behaviors:ze.data??[],beliefs:De.data??[],reports:Fe.data??[]}),Le=u.useMemo(()=>kt(S),[S]),_e=u.useMemo(()=>Ct(K),[K]),V=u.useMemo(()=>{const a=Se(f);return[...S].sort((d,m)=>new Date(m.startedAt).getTime()-new Date(d.startedAt).getTime()).filter(d=>{const m=l[d.id]??Z(d);return(a.length===0||Nt(d,m).includes(a))&&St(d,T)})},[l,f,T,S]),xe=u.useMemo(()=>Tt(K,n,b,D,L),[b,L,K,D,n]),he=V.length===S.length&&f.trim().length===0&&T.length===0?`${S.length} workout sessions visible`:`${V.length} of ${S.length} workout sessions visible`,R=V.find(a=>a.id===oe)??S.find(a=>a.id===oe)??null,me=R?l[R.id]??Z(R):null;if(k.isLoading)return e.jsx(Ye,{eyebrow:"Sports",title:"Loading sports view",description:"Reading synced workouts and local reflection metadata.",columns:2,blocks:6});if(k.isError||!F)return e.jsx(Je,{eyebrow:"Sports",error:k.error??new Error("Sports data unavailable"),onRetry:()=>void k.refetch()});const{summary:p,weeklyTrend:pe,typeBreakdown:He}=F,ue=p.zoneMix??[],A=Rt(xe,F.vitalsTrend),ge=n.length===0?"All exercise types":A.exerciseLabels.length>0?A.exerciseLabels.join(", "):`${n.length} selected types`,Ke=ue.map(a=>({zone:a.label,minutes:Math.round(a.seconds/60),percentage:Math.round(a.percentage*100),fill:U[a.key]??"#f8fafc"})),Oe=pe.map(a=>{const d=Object.fromEntries((a.zoneDurations??[]).map(m=>[m.key,Math.round(m.seconds/60)]));return{date:a.dateKey.slice(5),duration:a.durationMinutes,load:a.trainingLoad??0,coverage:Math.round((a.heartRateCoverage??0)*100),...d}}),Be=K.map(a=>{var d,m,E,_;return{duration:Math.round(a.durationSeconds/60),intensity:Math.round((((m=(d=a.analytics)==null?void 0:d.load)==null?void 0:m.intensity)??0)*100),load:((_=(E=a.analytics)==null?void 0:E.load)==null?void 0:_.trimp)??0,type:j(a),name:j(a)}});function We(a,d){c(m=>{const E=m[a]??Z(S.find(_=>_.id===a));return{...m,[a]:{...E,...d}}})}async function Ie(a){const d=S.find(E=>E.id===a);if(!d)return;const m=l[a]??Z(d);await se.mutateAsync({workoutId:a,subjectiveEffort:m.subjectiveEffort,moodBefore:m.moodBefore,moodAfter:m.moodAfter,meaningText:m.meaningText,plannedContext:m.plannedContext,socialContext:m.socialContext,tagsText:m.tagsText,linkValues:m.linkValues}),ae(null),X(0)}return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(xt,{entityKind:"project",title:"Sports",description:"A session-first training surface for workout data, subjective meaning, and links back into Forge execution and Psyche.",badge:`${S.length} sessions`}),e.jsx(et,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Weekly volume"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:W(p.weeklyVolumeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Total training time in the recent week."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Exercise minutes"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.exerciseMinutes}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Aggregate exercise minutes from synced sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Energy burned"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.energyBurnedKcal}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Recent weekly kcal."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Training streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.streakDays}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Distinct workout days in the recent week."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Average session"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[p.averageSessionMinutes,"m"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Mean duration across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.totalTrainingLoad??"n/a"}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Forge TRIMP across recent sessions."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Linked sessions"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:p.linkedSessionCount}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Sessions already tied to Forge or Psyche entities."})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[Math.round((p.averageHeartRateCoverage??0)*100),"%"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Average raw HR sample coverage."})]})]})}),e.jsx(Y,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(320px,0.9fr)]",children:[e.jsxs(g,{className:"min-h-[320px]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Load and volume trend"}),e.jsx("div",{className:"mt-4 h-[260px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(ut,{data:Oe,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"sportsLoad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#f97316",stopOpacity:.36}),e.jsx("stop",{offset:"100%",stopColor:"#f97316",stopOpacity:.04})]})}),e.jsx(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(B,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:34}),e.jsx(Q,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ye,{type:"monotone",dataKey:"load",stroke:"#f97316",fill:"url(#sportsLoad)",strokeWidth:2}),e.jsx(ye,{type:"monotone",dataKey:"duration",stroke:"#38bdf8",fill:"rgba(56,189,248,0.10)",strokeWidth:2})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Zone distribution"}),e.jsx("div",{className:"mt-4 grid gap-3",children:ue.map(a=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-white/72",children:a.label}),e.jsxs("span",{className:"text-white",children:[Math.round(a.percentage*100),"% · ",W(a.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,a.percentage*100)}%`,background:U[a.key]??"#f8fafc"}})})]},a.key))}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(we,{data:Ke,children:[e.jsx(q,{dataKey:"zone",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:34}),e.jsx(Q,{contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(re,{dataKey:"minutes",fill:"#f97316",radius:[4,4,0,0]})]})})})]})]})}),e.jsx(Y,{children:e.jsxs("section",{className:"grid gap-4",children:[e.jsxs(g,{className:"grid gap-4 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"HR zone analysis"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Filter all-time workout evidence by exercise type and date."})]}),e.jsxs(o,{tone:"meta",children:[xe.length," of ",K.length," sessions"]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(280px,0.8fr)]",children:[e.jsx(ve,{title:"Exercise types",description:"Select one, many, or none for all exercise types.",query:h,onQueryChange:N,options:_e,selectedOptionIds:n,onSelectedOptionIdsChange:x,resultSummary:ge,placeholder:"Search exercise types",emptyStateMessage:"No exercise type matches."}),e.jsxs("div",{className:"grid gap-3 rounded-[8px] border border-white/8 bg-white/[0.035] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Date range"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[["all","All time"],["recent_90","90 days"],["custom","Custom"]].map(([a,d])=>e.jsx("button",{type:"button",className:`rounded-[8px] border px-3 py-2 text-sm transition ${b===a?"border-[var(--primary)] bg-[var(--primary)]/12 text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07] hover:text-white"}`,onClick:()=>C(a),children:d},a))}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Start"}),e.jsx($,{type:"date",value:D,onChange:a=>{r(a.target.value),C("custom")}})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"End"}),e.jsx($,{type:"date",value:L,onChange:a=>{Ce(a.target.value),C("custom")}})]})]})]})]})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.85fr)_minmax(0,1.15fr)]",children:[e.jsxs(g,{className:"min-h-[330px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Average zones"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Duration-weighted proportion of time in each HR zone."})]}),e.jsx(o,{tone:"meta",children:ge})]}),e.jsx("div",{className:"mt-4 h-[235px]",children:A.sessions.length>0?e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(we,{data:A.averageZoneData,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"zone",interval:0,tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{unit:"%",domain:[0,100],ticks:[0,25,50,75,100],tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:38}),e.jsx(Q,{formatter:a=>[`${a}%`,"Average time"],contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(re,{dataKey:"percentage",radius:[4,4,0,0],children:A.averageZoneData.map(a=>e.jsx(gt,{fill:a.fill},a.key))})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-white/[0.035] p-6 text-center text-sm leading-6 text-white/54",children:"No selected sessions with zone analytics are available yet."})}),A.sessions.length>0?e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/58 sm:grid-cols-3",children:[e.jsxs("div",{children:[A.rawHrCount," sessions have raw HR timelines"]}),e.jsxs("div",{children:["Latest:"," ",((je=A.lineData.at(-1))==null?void 0:je.dateKey)??"n/a"]}),e.jsxs("div",{children:["VO2max points:"," ",A.lineData.filter(a=>a.vo2Max!=null).length]})]}):null]}),e.jsxs(g,{className:"min-h-[330px] overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:y==="expanding_lines"?"Expanding zone lines":"Zone drift"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:y==="expanding_lines"?"Expanding all-session average with resting HR and VO2max overlay.":"Rolling duration-weighted zone mix with resting HR and VO2max overlay."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:items-end",children:[e.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-[8px] border border-white/8 bg-white/[0.035] p-1","aria-label":"Zone chart display",children:[["rolling_stack","Stacked"],["expanding_lines","Lines"]].map(([a,d])=>e.jsx("button",{type:"button",className:`min-h-9 rounded-[6px] px-3 py-1.5 text-xs font-medium transition ${y===a?"bg-[var(--primary)]/18 text-white":"text-white/58 hover:bg-white/[0.06] hover:text-white"}`,onClick:()=>M(a),children:d},a))}),e.jsx(o,{tone:"meta",children:"HRR zones"})]})]}),e.jsx("div",{className:"mt-4 h-[255px]",children:A.lineData.length>0?e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(jt,{data:y==="expanding_lines"?A.expandingLineData:A.lineData,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(q,{dataKey:"date",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10}}),e.jsx(B,{yAxisId:"zones",domain:[0,100],ticks:[0,25,50,75,100],unit:"%",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:38}),e.jsx(B,{yAxisId:"vitals",orientation:"right",tick:{fill:"rgba(255,255,255,0.55)",fontSize:10},width:42}),e.jsx(Q,{formatter:(a,d,m)=>Mt(a,d,m),contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(ft,{wrapperStyle:{color:"rgba(255,255,255,0.7)",fontSize:11}}),y==="expanding_lines"?I.map(a=>e.jsx(ne,{yAxisId:"zones",type:"monotone",dataKey:a,name:z(a),stroke:U[a],strokeWidth:2,dot:{r:2.5},activeDot:{r:4},connectNulls:!0},a)):I.map(a=>e.jsx(re,{yAxisId:"zones",dataKey:a,stackId:"zones",fill:U[a],isAnimationActive:!1},a)),e.jsx(ne,{yAxisId:"vitals",type:"monotone",dataKey:"restingHeartRate",name:"Resting HR",stroke:"#e2e8f0",strokeWidth:2,dot:{r:3},connectNulls:!0}),e.jsx(ne,{yAxisId:"vitals",type:"monotone",dataKey:"vo2Max",name:"VO2max",stroke:"#a78bfa",strokeWidth:2,dot:{r:3},connectNulls:!0})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-white/[0.035] p-6 text-center text-sm leading-6 text-white/54",children:"Select workouts with HR evidence to unlock the time-series plot."})})]})]})]})}),e.jsx(Y,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(g,{className:"min-h-[300px]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Duration vs intensity"}),e.jsx("div",{className:"mt-4 h-[250px]",children:e.jsx(P,{width:"100%",height:"100%",children:e.jsxs(vt,{data:Be,children:[e.jsx(J,{stroke:"rgba(255,255,255,0.08)"}),e.jsx(q,{type:"number",dataKey:"duration",name:"minutes",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11}}),e.jsx(B,{type:"number",dataKey:"intensity",name:"intensity",tick:{fill:"rgba(255,255,255,0.55)",fontSize:11},width:38}),e.jsx(Q,{cursor:{strokeDasharray:"3 3"},contentStyle:{background:"rgba(8,12,22,0.94)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,color:"white"}}),e.jsx(yt,{dataKey:"load",fill:"#f97316"})]})})})]}),e.jsxs(g,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Evidence quality"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Raw HR coverage"}),e.jsxs("div",{className:"mt-2 text-2xl text-white",children:[Math.round((p.averageHeartRateCoverage??0)*100),"%"]})]}),e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Route-backed workouts"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:p.routeWorkoutCount??0})]}),e.jsxs("div",{className:"rounded-[8px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Top sport"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.topWorkoutTypeLabel??p.topWorkoutType??"n/a"})]})]})]})]})}),e.jsx(Y,{children:e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[1.05fr_0.95fr]",children:[e.jsxs(g,{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Recent volume"}),e.jsx("div",{className:"grid gap-3",children:pe.map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-3 md:grid-cols-[110px_150px_minmax(0,1fr)_90px]",children:[e.jsx("div",{className:"text-sm text-white/62",children:a.dateKey}),e.jsx("div",{className:"text-sm text-white",children:a.workoutTypeLabel??z(a.workoutType)}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--primary)]",style:{width:`${Math.min(100,a.durationMinutes/120*100)}%`}})}),e.jsxs("div",{className:"text-sm text-white",children:[a.durationMinutes,"m"]})]}),e.jsxs("div",{className:"text-sm text-white/62",children:[a.energyKcal," kcal"]})]},a.id))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:ce(p.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Planned sessions"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.plannedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Imported / merged"}),e.jsxs("div",{className:"mt-2 text-lg text-white",children:[p.importedSessionCount," / ",p.reconciledSessionCount]})]})]})]}),e.jsxs(g,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Training composition"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Workout type and provenance mix"})]}),e.jsx("div",{className:"grid gap-3",children:He.slice(0,6).map(a=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-3 md:grid-cols-[minmax(0,1fr)_90px_90px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-white",children:a.workoutTypeLabel??z(a.workoutType)}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:[a.sessionCount," sessions · ",a.activityFamilyLabel??"Other"]})]}),e.jsxs("div",{className:"text-sm text-white/72",children:[a.totalMinutes,"m"]}),e.jsxs("div",{className:"text-sm text-white/72",children:[a.energyKcal," kcal"]})]},a.workoutType))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Habit-generated"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.habitGeneratedSessionCount})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Forge-linked"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:p.linkedSessionCount})]})]})]})]})}),e.jsx(tt,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ve,{title:"Session browser",description:"Search past activities by workout type, source, reconciliation state, or whether they still need context.",query:f,onQueryChange:v,options:Le,selectedOptionIds:T,onSelectedOptionIdsChange:w,resultSummary:he,placeholder:"Search workouts, devices, notes, moods, or filter chips",emptyStateMessage:"Keep typing or pick a filter chip to narrow the activity history."}),e.jsxs(g,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Activity history"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Open a workout to add reflection and links in a guided modal."})]}),e.jsx(o,{tone:"meta",children:he})]}),e.jsx("div",{className:"max-h-[34rem] overflow-y-auto rounded-[8px] border border-white/8 bg-white/[0.03] p-3",children:V.length===0?e.jsx("div",{className:"flex min-h-[18rem] items-center justify-center p-6 text-center text-sm leading-6 text-white/50",children:"No workout matches the current search yet. Clear some filters or search by workout type, device, or reflection text."}):e.jsx("div",{className:"grid gap-3",children:V.map(a=>{var m,E,_;const d=a.meaningText.trim().length>0||a.moodBefore.trim().length>0||a.moodAfter.trim().length>0||a.tags.length>0||a.links.length>0;return e.jsxs("div",{className:"grid w-full min-w-0 gap-3 rounded-[8px] border border-white/8 bg-white/[0.04] px-4 py-3 text-left transition hover:bg-white/[0.07]",children:[e.jsxs("div",{className:"grid min-w-0 gap-3 sm:flex sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(Ve,{to:`/sports/workouts/${a.id}`,className:"flex min-w-0 items-center gap-2 text-white transition hover:text-[var(--primary)]",children:[e.jsx(Ne,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:j(a)})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 items-center gap-2 text-sm text-white/56",children:[e.jsx(Pe,{className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate",children:G(a.startedAt,a.endedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/46",children:[H(a)," · ",a.sourceDevice]})]}),e.jsxs("button",{type:"button","aria-label":`Edit ${j(a)} reflection`,className:"inline-flex w-fit max-w-full items-center gap-2 rounded-full bg-white/[0.05] px-3 py-1.5 text-xs text-white/70 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>{ae(a.id),X(0)},children:[e.jsx("span",{className:"truncate",children:d?"Reflected":"Needs reflection"}),e.jsx(ke,{className:"size-3.5 shrink-0"})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(o,{children:W(a.durationSeconds)}),a.totalEnergyKcal?e.jsxs(o,{tone:"meta",children:[Math.round(a.totalEnergyKcal)," kcal"]}):null,a.distanceMeters?e.jsx(o,{tone:"meta",children:ce(a.distanceMeters)}):null,a.averageHeartRate?e.jsxs(o,{tone:"meta",children:[e.jsx(qe,{className:"mr-1 size-3.5"}),Math.round(a.averageHeartRate)," bpm"]}):null,e.jsx(o,{tone:"meta",children:H(a)}),e.jsx(o,{tone:"meta",className:"capitalize",children:a.sourceType.replaceAll("_"," ")}),e.jsx(o,{tone:"meta",className:"capitalize",children:a.reconciliationStatus.replaceAll("_"," ")}),(m=a.analytics)!=null&&m.confidence?e.jsxs(o,{tone:"meta",children:[a.analytics.confidence," zones"]}):null,(_=(E=a.analytics)==null?void 0:E.routeSummary)!=null&&_.hasRoute?e.jsx(o,{tone:"meta",children:"Route"}):null]})]},a.id)})})})]})]})}),R&&me?e.jsx(at,{open:!!R,onOpenChange:a=>{a||(ae(null),X(0))},eyebrow:"Sports session",title:j(R),description:"Add contextual meaning without crowding the main training surface.",children:e.jsx(Et,{session:R,draft:me,linkOptions:$e,pending:se.isPending&&((fe=se.variables)==null?void 0:fe.workoutId)===R.id,step:Me,onStepChange:X,onDraftChange:a=>We(R.id,a),onSave:()=>void Ie(R.id)})}):null]})}export{Pt as SportsPage,Mt as formatZoneTrendTooltipValue};
@@ -0,0 +1 @@
1
+ var cs=Object.defineProperty;var as=(e,t,r)=>t in e?cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ke=(e,t,r)=>as(e,typeof t!="symbol"?t+"":t,r);import{r as Q,j as us,s as pr,n as Mt,a as Jt,e as ls,Q as fs,b as ds,M as hs,I as ps,w as ys,i as yr,c as yt,d as pn,f as gs,g as ms,h as Zt,t as bs,k as vs,l as Ar,m as yn,S as Ss,u as _s,R as Ne}from"./vendor-DHkYh85p.js";var gn=Q.createContext(void 0),Xe=e=>{const t=Q.useContext(gn);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Fo=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),us.jsx(gn.Provider,{value:e,children:t})),mn=Q.createContext(!1),ws=()=>Q.useContext(mn);mn.Provider;function Es(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ps=Q.createContext(Es()),Cs=()=>Q.useContext(Ps),Rs=(e,t,r)=>{const n=r!=null&&r.state.error&&typeof e.throwOnError=="function"?pr(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Ms=e=>{Q.useEffect(()=>{e.clearReset()},[e])},Is=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||pr(r,[e.error,n])),As=e=>{if(e.suspense){const r=s=>s==="static"?s:Math.max(s??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...s)=>r(n(...s)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Os=(e,t)=>e.isLoading&&e.isFetching&&!t,Ts=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Or=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function bn(e,t,r){var A,P,m,R;const n=ws(),s=Cs(),i=Xe(r),o=i.defaultQueryOptions(e);(P=(A=i.getDefaultOptions().queries)==null?void 0:A._experimental_beforeQuery)==null||P.call(A,o);const v=i.getQueryCache().get(o.queryHash);o._optimisticResults=n?"isRestoring":"optimistic",As(o),Rs(o,s,v),Ms(s);const E=!i.getQueryCache().get(o.queryHash),[b]=Q.useState(()=>new t(i,o)),_=b.getOptimisticResult(o),I=!n&&e.subscribed!==!1;if(Q.useSyncExternalStore(Q.useCallback(g=>{const w=I?b.subscribe(Mt.batchCalls(g)):Jt;return b.updateResult(),w},[b,I]),()=>b.getCurrentResult(),()=>b.getCurrentResult()),Q.useEffect(()=>{b.setOptions(o)},[o,b]),Ts(o,_))throw Or(o,b,s);if(Is({result:_,errorResetBoundary:s,throwOnError:o.throwOnError,query:v,suspense:o.suspense}))throw _.error;if((R=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||R.call(m,o,_),o.experimental_prefetchInRender&&!ls.isServer()&&Os(_,n)){const g=E?Or(o,b,s):v==null?void 0:v.promise;g==null||g.catch(Jt).finally(()=>{b.updateResult()})}return o.notifyOnChangeProps?_:b.trackResult(_)}function qo(e,t){return bn(e,fs,t)}function Lo(e,t){const r=Xe(t),n=r.getQueryCache();return Q.useSyncExternalStore(Q.useCallback(s=>n.subscribe(Mt.batchCalls(s)),[n]),()=>r.isFetching(e),()=>r.isFetching(e))}function Uo(e,t){const r=Xe(t);return ks({filters:{...e,status:"pending"}},r).length}function Tr(e,t){return e.findAll(t.filters).map(r=>t.select?t.select(r):r.state)}function ks(e={},t){const r=Xe(t).getMutationCache(),n=Q.useRef(e),s=Q.useRef(null);return s.current===null&&(s.current=Tr(r,e)),Q.useEffect(()=>{n.current=e}),Q.useSyncExternalStore(Q.useCallback(i=>r.subscribe(()=>{const o=ds(s.current,Tr(r,n.current));s.current!==o&&(s.current=o,Mt.schedule(i))}),[r]),()=>s.current,()=>s.current)}function zo(e,t){const r=Xe(t),[n]=Q.useState(()=>new hs(r,e));Q.useEffect(()=>{n.setOptions(e)},[n,e]);const s=Q.useSyncExternalStore(Q.useCallback(o=>n.subscribe(Mt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=Q.useCallback((o,v)=>{n.mutate(o,v).catch(Jt)},[n]);if(s.error&&pr(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}function $o(e,t){return bn(e,ps,t)}function vn(e){e()}function Qs(){let e=null,t=null;return{clear(){e=null,t=null},notify(){vn(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const s=t={callback:r,next:null,prev:t};return s.prev?s.prev.next=s:e=s,function(){!n||e===null||(n=!1,s.next?s.next.prev=s.prev:t=s.prev,s.prev?s.prev.next=s.next:e=s.next)}}}}var kr={notify(){},get:()=>[]};function Ds(e,t){let r,n=kr,s=0,i=!1;function o(R){_();const g=n.subscribe(R);let w=!1;return()=>{w||(w=!0,g(),I())}}function v(){n.notify()}function E(){m.onStateChange&&m.onStateChange()}function b(){return i}function _(){s++,r||(r=e.subscribe(E),n=Qs())}function I(){s--,r&&s===0&&(r(),r=void 0,n.clear(),n=kr)}function A(){i||(i=!0,_())}function P(){i&&(i=!1,I())}const m={addNestedSub:o,notifyNestedSubs:v,handleChangeWrapper:E,isSubscribed:b,trySubscribe:A,tryUnsubscribe:P,getListeners:()=>n};return m}var xs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ns=xs(),Fs=()=>typeof navigator<"u"&&navigator.product==="ReactNative",qs=Fs(),Ls=()=>Ns||qs?Q.useLayoutEffect:Q.useEffect,Us=Ls();function Qr(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Ue(e,t){if(Qr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(t,r[s])||!Qr(e[r[s]],t[r[s]]))return!1;return!0}var jt=Symbol.for("react-redux-context"),Vt=typeof globalThis<"u"?globalThis:{};function zs(){if(!Q.createContext)return{};const e=Vt[jt]??(Vt[jt]=new Map);let t=e.get(Q.createContext);return t||(t=Q.createContext(null),e.set(Q.createContext,t)),t}var he=zs();function $s(e){const{children:t,context:r,serverState:n,store:s}=e,i=Q.useMemo(()=>{const E=Ds(s);return{store:s,subscription:E,getServerState:n?()=>n:void 0}},[s,n]),o=Q.useMemo(()=>s.getState(),[s]);Us(()=>{const{subscription:E}=i;return E.onStateChange=E.notifyNestedSubs,E.trySubscribe(),o!==s.getState()&&E.notifyNestedSubs(),()=>{E.tryUnsubscribe(),E.onStateChange=void 0}},[i,o]);const v=r||he;return Q.createElement(v.Provider,{value:i},t)}var jo=$s;function gr(e=he){return function(){return Q.useContext(e)}}var Sn=gr();function _n(e=he){const t=e===he?Sn:gr(e),r=()=>{const{store:n}=t();return n};return Object.assign(r,{withTypes:()=>r}),r}var wn=_n();function js(e=he){const t=e===he?wn:_n(e),r=()=>t().dispatch;return Object.assign(r,{withTypes:()=>r}),r}var Vs=js(),Hs=(e,t)=>e===t;function Ws(e=he){const t=e===he?Sn:gr(e),r=(n,s={})=>{const{equalityFn:i=Hs}=typeof s=="function"?{equalityFn:s}:s,o=t(),{store:v,subscription:E,getServerState:b}=o;Q.useRef(!0);const _=Q.useCallback({[n.name](A){return n(A)}}[n.name],[n]),I=ys.useSyncExternalStoreWithSelector(E.addNestedSub,v.getState,b||v.getState,_,i);return Q.useDebugValue(I),I};return Object.assign(r,{withTypes:()=>r}),r}var Bs=Ws(),Ks=vn,mr=Symbol.for("immer-nothing"),ze=Symbol.for("immer-draftable"),G=Symbol.for("immer-state");function Y(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var te=Object,ve=te.getPrototypeOf,Ve="constructor",Je="prototype",er="configurable",gt="enumerable",ht="writable",He="value",re=e=>!!e&&!!e[G];function ne(e){var t;return e?En(e)||et(e)||!!e[ze]||!!((t=e[Ve])!=null&&t[ze])||tt(e)||rt(e):!1}var Gs=te[Je][Ve].toString(),Dr=new WeakMap;function En(e){if(!e||!Ae(e))return!1;const t=ve(e);if(t===null||t===te[Je])return!0;const r=te.hasOwnProperty.call(t,Ve)&&t[Ve];if(r===Object)return!0;if(!me(r))return!1;let n=Dr.get(r);return n===void 0&&(n=Function.toString.call(r),Dr.set(r,n)),n===Gs}function Ys(e){return re(e)||Y(15,e),e[G].base_}function Ze(e,t,r=!0){Se(e)===0?(r?Reflect.ownKeys(e):te.keys(e)).forEach(s=>{t(s,e[s],e)}):e.forEach((n,s)=>t(s,n,e))}function Se(e){const t=e[G];return t?t.type_:et(e)?1:tt(e)?2:rt(e)?3:0}var $e=(e,t,r=Se(e))=>r===2?e.has(t):te[Je].hasOwnProperty.call(e,t),ce=(e,t,r=Se(e))=>r===2?e.get(t):e[t],mt=(e,t,r,n=Se(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function Xs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var et=Array.isArray,tt=e=>e instanceof Map,rt=e=>e instanceof Set,Ae=e=>typeof e=="object",me=e=>typeof e=="function",Ht=e=>typeof e=="boolean";function Js(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Zs=e=>Ae(e)?e==null?void 0:e[G]:null,ae=e=>e.copy_||e.base_,br=e=>e.modified_?e.copy_:e.base_;function tr(e,t){if(tt(e))return new Map(e);if(rt(e))return new Set(e);if(et(e))return Array[Je].slice.call(e);const r=En(e);if(t===!0||t==="class_only"&&!r){const n=te.getOwnPropertyDescriptors(e);delete n[G];let s=Reflect.ownKeys(n);for(let i=0;i<s.length;i++){const o=s[i],v=n[o];v[ht]===!1&&(v[ht]=!0,v[er]=!0),(v.get||v.set)&&(n[o]={[er]:!0,[ht]:!0,[gt]:v[gt],[He]:e[o]})}return te.create(ve(e),n)}else{const n=ve(e);if(n!==null&&r)return{...e};const s=te.create(n);return te.assign(s,e)}}function vr(e,t=!1){return It(e)||re(e)||!ne(e)||(Se(e)>1&&te.defineProperties(e,{set:ot,add:ot,clear:ot,delete:ot}),te.freeze(e),t&&Ze(e,(r,n)=>{vr(n,!0)},!1)),e}function ei(){Y(2)}var ot={[He]:ei};function It(e){return e===null||!Ae(e)?!0:te.isFrozen(e)}var bt="MapSet",vt="Patches",xr="ArrayMethods",St={};function _e(e){const t=St[e];return t||Y(0,e),t}var Nr=e=>!!St[e];function ti(e,t){St[e]||(St[e]=t)}var We,Pn=()=>We,ri=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Nr(bt)?_e(bt):void 0,arrayMethodsPlugin_:Nr(xr)?_e(xr):void 0});function Fr(e,t){t&&(e.patchPlugin_=_e(vt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rr(e){nr(e),e.drafts_.forEach(ni),e.drafts_=null}function nr(e){e===We&&(We=e.parent_)}var qr=e=>We=ri(We,e);function ni(e){const t=e[G];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[G].modified_&&(rr(t),Y(4)),ne(e)&&(e=Ur(t,e));const{patchPlugin_:s}=t;s&&s.generateReplacementPatches_(r[G].base_,e,t)}else e=Ur(t,r);return si(t,e,!0),rr(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==mr?e:void 0}function Ur(e,t){if(It(t))return t;const r=t[G];if(!r)return _t(t,e.handledSet_,e);if(!At(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);Mn(r,e)}return r.copy_}function si(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&vr(t,r)}function Cn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var At=(e,t)=>e.scope_===t,ii=[];function Rn(e,t,r,n){const s=ae(e),i=e.type_;if(n!==void 0&&ce(s,n,i)===t){mt(s,n,r,i);return}if(!e.draftLocations_){const v=e.draftLocations_=new Map;Ze(s,(E,b)=>{if(re(b)){const _=v.get(b)||[];_.push(E),v.set(b,_)}})}const o=e.draftLocations_.get(t)??ii;for(const v of o)mt(s,v,r,i)}function oi(e,t,r){e.callbacks_.push(function(s){var v;const i=t;if(!i||!At(i,s))return;(v=s.mapSetPlugin_)==null||v.fixSetContents(i);const o=br(i);Rn(e,i.draft_??i,o,r),Mn(i,s)})}function Mn(e,t){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:s}=t;if(s){const i=s.getPath(e);i&&s.generatePatches_(e,i,t)}Cn(e)}}function ci(e,t,r){const{scope_:n}=e;if(re(r)){const s=r[G];At(s,n)&&s.callbacks_.push(function(){pt(e);const o=br(s);Rn(e,r,o,t)})}else ne(r)&&e.callbacks_.push(function(){const i=ae(e);e.type_===3?i.has(r)&&_t(r,n.handledSet_,n):ce(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&_t(ce(e.copy_,t,e.type_),n.handledSet_,n)})}function _t(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||re(e)||t.has(e)||!ne(e)||It(e)||(t.add(e),Ze(e,(n,s)=>{if(re(s)){const i=s[G];if(At(i,r)){const o=br(i);mt(e,n,o,e.type_),Cn(i)}}else ne(s)&&_t(s,t,r)})),e}function ai(e,t){const r=et(e),n={type_:r?1:0,scope_:t?t.scope_:Pn(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let s=n,i=wt;r&&(s=[n],i=Be);const{revoke:o,proxy:v}=Proxy.revocable(s,i);return n.draft_=v,n.revoke_=o,[v,n]}var wt={get(e,t){if(t===G)return e;let r=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof t=="string";if(n&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const s=ae(e);if(!$e(s,t,e.type_))return ui(e,s,t);const i=s[t];if(e.finalized_||!ne(i)||n&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&Js(t))return i;if(i===Wt(e.base_,t)){pt(e);const o=e.type_===1?+t:t,v=ir(e.scope_,i,e,o);return e.copy_[o]=v}return i},has(e,t){return t in ae(e)},ownKeys(e){return Reflect.ownKeys(ae(e))},set(e,t,r){const n=In(ae(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const s=Wt(ae(e),t),i=s==null?void 0:s[G];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Xs(r,s)&&(r!==void 0||$e(e.base_,t,e.type_)))return!0;pt(e),sr(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),ci(e,t,r)),!0},deleteProperty(e,t){return pt(e),Wt(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),sr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=ae(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[ht]:!0,[er]:e.type_!==1||t!=="length",[gt]:n[gt],[He]:r[t]}},defineProperty(){Y(11)},getPrototypeOf(e){return ve(e.base_)},setPrototypeOf(){Y(12)}},Be={};for(let e in wt){let t=wt[e];Be[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}Be.deleteProperty=function(e,t){return Be.set.call(this,e,t,void 0)};Be.set=function(e,t,r){return wt.set.call(this,e[0],t,r,e[0])};function Wt(e,t){const r=e[G];return(r?ae(r):e)[t]}function ui(e,t,r){var s;const n=In(t,r);return n?He in n?n[He]:(s=n.get)==null?void 0:s.call(e.draft_):void 0}function In(e,t){if(!(t in e))return;let r=ve(e);for(;r;){const n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=ve(r)}}function sr(e){e.modified_||(e.modified_=!0,e.parent_&&sr(e.parent_))}function pt(e){e.copy_||(e.assigned_=new Map,e.copy_=tr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var li=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(me(t)&&!me(r)){const i=r;r=t;const o=this;return function(E=i,...b){return o.produce(E,_=>r.call(this,_,...b))}}me(r)||Y(6),n!==void 0&&!me(n)&&Y(7);let s;if(ne(t)){const i=qr(this),o=ir(i,t,void 0);let v=!0;try{s=r(o),v=!1}finally{v?rr(i):nr(i)}return Fr(i,n),Lr(s,i)}else if(!t||!Ae(t)){if(s=r(t),s===void 0&&(s=t),s===mr&&(s=void 0),this.autoFreeze_&&vr(s,!0),n){const i=[],o=[];_e(vt).generateReplacementPatches_(t,s,{patches_:i,inversePatches_:o}),n(i,o)}return s}else Y(1,t)},this.produceWithPatches=(t,r)=>{if(me(t))return(o,...v)=>this.produceWithPatches(o,E=>t(E,...v));let n,s;return[this.produce(t,r,(o,v)=>{n=o,s=v}),n,s]},Ht(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Ht(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Ht(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ne(e)||Y(8),re(e)&&(e=An(e));const t=qr(this),r=ir(t,e,void 0);return r[G].isManual_=!0,nr(t),r}finishDraft(e,t){const r=e&&e[G];(!r||!r.isManual_)&&Y(9);const{scope_:n}=r;return Fr(n,t),Lr(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const s=t[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(t=t.slice(r+1));const n=_e(vt).applyPatches_;return re(e)?n(e,t):this.produce(e,s=>n(s,t))}};function ir(e,t,r,n){const[s,i]=tt(t)?_e(bt).proxyMap_(t,r):rt(t)?_e(bt).proxySet_(t,r):ai(t,r);return((r==null?void 0:r.scope_)??Pn()).drafts_.push(s),i.callbacks_=(r==null?void 0:r.callbacks_)??[],i.key_=n,r&&n!==void 0?oi(r,i,n):i.callbacks_.push(function(E){var _;(_=E.mapSetPlugin_)==null||_.fixSetContents(i);const{patchPlugin_:b}=E;i.modified_&&b&&b.generatePatches_(i,[],E)}),s}function An(e){return re(e)||Y(10,e),On(e)}function On(e){if(!ne(e)||It(e))return e;const t=e[G];let r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=tr(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=tr(e,!0);return Ze(r,(s,i)=>{mt(r,s,On(i))},n),t&&(t.finalized_=!1),r}function fi(){function t(m,R=[]){if(m.key_!==void 0){const g=m.parent_.copy_??m.parent_.base_,w=Zs(ce(g,m.key_)),O=ce(g,m.key_);if(O===void 0||O!==m.draft_&&O!==m.base_&&O!==m.copy_||w!=null&&w.base_!==m.base_)return null;const y=m.parent_.type_===3;let u;if(y){const a=m.parent_;u=Array.from(a.drafts_.keys()).indexOf(m.key_)}else u=m.key_;if(!(y&&g.size>u||$e(g,u)))return null;R.push(u)}if(m.parent_)return t(m.parent_,R);R.reverse();try{r(m.copy_,R)}catch{return null}return R}function r(m,R){let g=m;for(let w=0;w<R.length-1;w++){const O=R[w];if(g=ce(g,O),!Ae(g)||g===null)throw new Error(`Cannot resolve path at '${R.join("/")}'`)}return g}const n="replace",s="add",i="remove";function o(m,R,g){if(m.scope_.processedForPatches_.has(m))return;m.scope_.processedForPatches_.add(m);const{patches_:w,inversePatches_:O}=g;switch(m.type_){case 0:case 2:return E(m,R,w,O);case 1:return v(m,R,w,O);case 3:return b(m,R,w,O)}}function v(m,R,g,w){let{base_:O,assigned_:y}=m,u=m.copy_;u.length<O.length&&([O,u]=[u,O],[g,w]=[w,g]);const a=m.allIndicesReassigned_===!0;for(let l=0;l<O.length;l++){const p=u[l],M=O[l];if((a||(y==null?void 0:y.get(l.toString())))&&p!==M){const f=p==null?void 0:p[G];if(f&&f.modified_)continue;const c=R.concat([l]);g.push({op:n,path:c,value:P(p)}),w.push({op:n,path:c,value:P(M)})}}for(let l=O.length;l<u.length;l++){const p=R.concat([l]);g.push({op:s,path:p,value:P(u[l])})}for(let l=u.length-1;O.length<=l;--l){const p=R.concat([l]);w.push({op:i,path:p})}}function E(m,R,g,w){const{base_:O,copy_:y,type_:u}=m;Ze(m.assigned_,(a,l)=>{const p=ce(O,a,u),M=ce(y,a,u),h=l?$e(O,a)?n:s:i;if(p===M&&h===n)return;const f=R.concat(a);g.push(h===i?{op:h,path:f}:{op:h,path:f,value:P(M)}),w.push(h===s?{op:i,path:f}:h===i?{op:s,path:f,value:P(p)}:{op:n,path:f,value:P(p)})})}function b(m,R,g,w){let{base_:O,copy_:y}=m,u=0;O.forEach(a=>{if(!y.has(a)){const l=R.concat([u]);g.push({op:i,path:l,value:a}),w.unshift({op:s,path:l,value:a})}u++}),u=0,y.forEach(a=>{if(!O.has(a)){const l=R.concat([u]);g.push({op:s,path:l,value:a}),w.unshift({op:i,path:l,value:a})}u++})}function _(m,R,g){const{patches_:w,inversePatches_:O}=g;w.push({op:n,path:[],value:R===mr?void 0:R}),O.push({op:n,path:[],value:m})}function I(m,R){return R.forEach(g=>{const{path:w,op:O}=g;let y=m;for(let p=0;p<w.length-1;p++){const M=Se(y);let h=w[p];typeof h!="string"&&typeof h!="number"&&(h=""+h),(M===0||M===1)&&(h==="__proto__"||h===Ve)&&Y(19),me(y)&&h===Je&&Y(19),y=ce(y,h),Ae(y)||Y(18,w.join("/"))}const u=Se(y),a=A(g.value),l=w[w.length-1];switch(O){case n:switch(u){case 2:return y.set(l,a);case 3:Y(16);default:return y[l]=a}case s:switch(u){case 1:return l==="-"?y.push(a):y.splice(l,0,a);case 2:return y.set(l,a);case 3:return y.add(a);default:return y[l]=a}case i:switch(u){case 1:return y.splice(l,1);case 2:return y.delete(l);case 3:return y.delete(g.value);default:return delete y[l]}default:Y(17,O)}}),m}function A(m){if(!ne(m))return m;if(et(m))return m.map(A);if(tt(m))return new Map(Array.from(m.entries()).map(([g,w])=>[g,A(w)]));if(rt(m))return new Set(Array.from(m).map(A));const R=Object.create(ve(m));for(const g in m)R[g]=A(m[g]);return $e(m,ze)&&(R[ze]=m[ze]),R}function P(m){return re(m)?A(m):m}ti(vt,{applyPatches_:I,generatePatches_:o,generateReplacementPatches_:_,getPath:t})}var Ke=new li,nt=Ke.produce,Tn=Ke.produceWithPatches.bind(Ke),zr=Ke.applyPatches.bind(Ke),di=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Zt:Zt.apply(null,arguments)},hi=e=>e&&typeof e.match=="function";function J(e,t){function r(...n){if(t){let s=t(...n);if(!s)throw new Error(X(0));return{type:e,payload:s.payload,..."meta"in s&&{meta:s.meta},..."error"in s&&{error:s.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>yr(n)&&n.type===e,r}var kn=class Fe extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Fe.prototype)}static get[Symbol.species](){return Fe}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Fe(...t[0].concat(this)):new Fe(...t.concat(this))}};function $r(e){return ne(e)?nt(e,()=>{}):e}function ct(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function pi(e){return typeof e=="boolean"}var yi=()=>function(t){const{thunk:r=!0,immutableCheck:n=!0,serializableCheck:s=!0,actionCreatorCheck:i=!0}=t??{};let o=new kn;return r&&(pi(r)?o.push(bs):o.push(vs(r.extraArgument))),o},Ot="RTK_autoBatch",Qe=()=>e=>({payload:e,meta:{[Ot]:!0}}),jr=e=>t=>{setTimeout(t,e)},gi=(e={type:"raf"})=>t=>(...r)=>{const n=t(...r);let s=!0,i=!1,o=!1;const v=new Set,E=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:jr(10):e.type==="callback"?e.queueNotification:jr(e.timeout),b=()=>{o=!1,i&&(i=!1,v.forEach(_=>_()))};return Object.assign({},n,{subscribe(_){const I=()=>s&&_(),A=n.subscribe(I);return v.add(_),()=>{A(),v.delete(_)}},dispatch(_){var I;try{return s=!((I=_==null?void 0:_.meta)!=null&&I[Ot]),i=!s,i&&(o||(o=!0,E(b))),n.dispatch(_)}finally{s=!0}}})},mi=e=>function(r){const{autoBatch:n=!0}=r??{};let s=new kn(e);return n&&s.push(gi(typeof n=="object"?n:void 0)),s};function Vo(e){const t=yi(),{reducer:r=void 0,middleware:n,devTools:s=!0,duplicateMiddlewareCheck:i=!0,preloadedState:o=void 0,enhancers:v=void 0}=e||{};let E;if(typeof r=="function")E=r;else if(yt(r))E=pn(r);else throw new Error(X(1));let b;typeof n=="function"?b=n(t):b=t();let _=Zt;s&&(_=di({trace:!1,...typeof s=="object"&&s}));const I=gs(...b),A=mi(I);let P=typeof v=="function"?v(A):A();const m=_(...P);return ms(E,o,m)}function Qn(e){const t={},r=[];let n;const s={addCase(i,o){const v=typeof i=="string"?i:i.type;if(!v)throw new Error(X(28));if(v in t)throw new Error(X(29));return t[v]=o,s},addAsyncThunk(i,o){return o.pending&&(t[i.pending.type]=o.pending),o.rejected&&(t[i.rejected.type]=o.rejected),o.fulfilled&&(t[i.fulfilled.type]=o.fulfilled),o.settled&&r.push({matcher:i.settled,reducer:o.settled}),s},addMatcher(i,o){return r.push({matcher:i,reducer:o}),s},addDefaultCase(i){return n=i,s}};return e(s),[t,r,n]}function bi(e){return typeof e=="function"}function vi(e,t){let[r,n,s]=Qn(t),i;if(bi(e))i=()=>$r(e());else{const v=$r(e);i=()=>v}function o(v=i(),E){let b=[r[E.type],...n.filter(({matcher:_})=>_(E)).map(({reducer:_})=>_)];return b.filter(_=>!!_).length===0&&(b=[s]),b.reduce((_,I)=>{if(I)if(re(_)){const P=I(_,E);return P===void 0?_:P}else{if(ne(_))return nt(_,A=>I(A,E));{const A=I(_,E);if(A===void 0){if(_===null)return _;throw Error("A case reducer on a non-draftable value must not return undefined")}return A}}return _},v)}return o.getInitialState=i,o}var Dn=(e,t)=>hi(e)?e.match(t):e(t);function ue(...e){return t=>e.some(r=>Dn(r,t))}function je(...e){return t=>e.every(r=>Dn(r,t))}function Tt(e,t){if(!e||!e.meta)return!1;const r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function st(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function Sr(...e){return e.length===0?t=>Tt(t,["pending"]):st(e)?ue(...e.map(t=>t.pending)):Sr()(e[0])}function Oe(...e){return e.length===0?t=>Tt(t,["rejected"]):st(e)?ue(...e.map(t=>t.rejected)):Oe()(e[0])}function kt(...e){const t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?je(Oe(...e),t):st(e)?je(Oe(...e),t):kt()(e[0])}function pe(...e){return e.length===0?t=>Tt(t,["fulfilled"]):st(e)?ue(...e.map(t=>t.fulfilled)):pe()(e[0])}function or(...e){return e.length===0?t=>Tt(t,["pending","fulfilled","rejected"]):st(e)?ue(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):or()(e[0])}var Si="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Qt=(e=21)=>{let t="",r=e;for(;r--;)t+=Si[Math.random()*64|0];return t},_i=["name","message","stack","code"],Bt=class{constructor(e,t){ke(this,"_type");this.payload=e,this.meta=t}},Vr=class{constructor(e,t){ke(this,"_type");this.payload=e,this.meta=t}},wi=e=>{if(typeof e=="object"&&e!==null){const t={};for(const r of _i)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},Hr="External signal was aborted",Wr=(()=>{function e(t,r,n){const s=J(t+"/fulfilled",(E,b,_,I)=>({payload:E,meta:{...I||{},arg:_,requestId:b,requestStatus:"fulfilled"}})),i=J(t+"/pending",(E,b,_)=>({payload:void 0,meta:{..._||{},arg:b,requestId:E,requestStatus:"pending"}})),o=J(t+"/rejected",(E,b,_,I,A)=>({payload:I,error:(n&&n.serializeError||wi)(E||"Rejected"),meta:{...A||{},arg:_,requestId:b,rejectedWithValue:!!I,requestStatus:"rejected",aborted:(E==null?void 0:E.name)==="AbortError",condition:(E==null?void 0:E.name)==="ConditionError"}}));function v(E,{signal:b}={}){return(_,I,A)=>{const P=n!=null&&n.idGenerator?n.idGenerator(E):Qt(),m=new AbortController;let R,g;function w(y){g=y,m.abort()}b&&(b.aborted?w(Hr):b.addEventListener("abort",()=>w(Hr),{once:!0}));const O=(async function(){var a,l;let y;try{let p=(a=n==null?void 0:n.condition)==null?void 0:a.call(n,E,{getState:I,extra:A});if(Pi(p)&&(p=await p),p===!1||m.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const M=new Promise((h,f)=>{R=()=>{f({name:"AbortError",message:g||"Aborted"})},m.signal.addEventListener("abort",R,{once:!0})});_(i(P,E,(l=n==null?void 0:n.getPendingMeta)==null?void 0:l.call(n,{requestId:P,arg:E},{getState:I,extra:A}))),y=await Promise.race([M,Promise.resolve(r(E,{dispatch:_,getState:I,extra:A,requestId:P,signal:m.signal,abort:w,rejectWithValue:(h,f)=>new Bt(h,f),fulfillWithValue:(h,f)=>new Vr(h,f)})).then(h=>{if(h instanceof Bt)throw h;return h instanceof Vr?s(h.payload,P,E,h.meta):s(h,P,E)})])}catch(p){y=p instanceof Bt?o(null,P,E,p.payload,p.meta):o(p,P,E)}finally{R&&m.signal.removeEventListener("abort",R)}return n&&!n.dispatchConditionRejection&&o.match(y)&&y.meta.condition||_(y),y})();return Object.assign(O,{abort:w,requestId:P,arg:E,unwrap(){return O.then(Ei)}})}}return Object.assign(v,{pending:i,rejected:o,fulfilled:s,settled:ue(o,s),typePrefix:t})}return e.withTypes=()=>e,e})();function Ei(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function Pi(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var Ci=Symbol.for("rtk-slice-createasyncthunk");function Ri(e,t){return`${e}/${t}`}function Mi({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[Ci];return function(s){const{name:i,reducerPath:o=i}=s;if(!i)throw new Error(X(11));const v=(typeof s.reducers=="function"?s.reducers(Ai()):s.reducers)||{},E=Object.keys(v),b={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},_={addCase(u,a){const l=typeof u=="string"?u:u.type;if(!l)throw new Error(X(12));if(l in b.sliceCaseReducersByType)throw new Error(X(13));return b.sliceCaseReducersByType[l]=a,_},addMatcher(u,a){return b.sliceMatchers.push({matcher:u,reducer:a}),_},exposeAction(u,a){return b.actionCreators[u]=a,_},exposeCaseReducer(u,a){return b.sliceCaseReducersByName[u]=a,_}};E.forEach(u=>{const a=v[u],l={reducerName:u,type:Ri(i,u),createNotation:typeof s.reducers=="function"};Ti(a)?Qi(l,a,_,t):Oi(l,a,_)});function I(){const[u={},a=[],l=void 0]=typeof s.extraReducers=="function"?Qn(s.extraReducers):[s.extraReducers],p={...u,...b.sliceCaseReducersByType};return vi(s.initialState,M=>{for(let h in p)M.addCase(h,p[h]);for(let h of b.sliceMatchers)M.addMatcher(h.matcher,h.reducer);for(let h of a)M.addMatcher(h.matcher,h.reducer);l&&M.addDefaultCase(l)})}const A=u=>u,P=new Map,m=new WeakMap;let R;function g(u,a){return R||(R=I()),R(u,a)}function w(){return R||(R=I()),R.getInitialState()}function O(u,a=!1){function l(M){let h=M[u];return typeof h>"u"&&a&&(h=ct(m,l,w)),h}function p(M=A){const h=ct(P,a,()=>new WeakMap);return ct(h,M,()=>{const f={};for(const[c,d]of Object.entries(s.selectors??{}))f[c]=Ii(d,M,()=>ct(m,M,w),a);return f})}return{reducerPath:u,getSelectors:p,get selectors(){return p(l)},selectSlice:l}}const y={name:i,reducer:g,actions:b.actionCreators,caseReducers:b.sliceCaseReducersByName,getInitialState:w,...O(o),injectInto(u,{reducerPath:a,...l}={}){const p=a??o;return u.inject({reducerPath:p,reducer:g},l),{...y,...O(p,!0)}}};return y}}function Ii(e,t,r,n){function s(i,...o){let v=t(i);return typeof v>"u"&&n&&(v=r()),e(v,...o)}return s.unwrapped=e,s}var Ce=Mi();function Ai(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function Oi({type:e,reducerName:t,createNotation:r},n,s){let i,o;if("reducer"in n){if(r&&!ki(n))throw new Error(X(17));i=n.reducer,o=n.prepare}else i=n;s.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,o?J(e,o):J(e))}function Ti(e){return e._reducerDefinitionType==="asyncThunk"}function ki(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Qi({type:e,reducerName:t},r,n,s){if(!s)throw new Error(X(18));const{payloadCreator:i,fulfilled:o,pending:v,rejected:E,settled:b,options:_}=r,I=s(e,i,_);n.exposeAction(t,I),o&&n.addCase(I.fulfilled,o),v&&n.addCase(I.pending,v),E&&n.addCase(I.rejected,E),b&&n.addMatcher(I.settled,b),n.exposeCaseReducer(t,{fulfilled:o||at,pending:v||at,rejected:E||at,settled:b||at})}function at(){}var Di="task",xn="listener",Nn="completed",_r="cancelled",xi=`task-${_r}`,Ni=`task-${Nn}`,cr=`${xn}-${_r}`,Fi=`${xn}-${Nn}`,Dt=class{constructor(e){ke(this,"name","TaskAbortError");ke(this,"message");this.code=e,this.message=`${Di} ${_r} (reason: ${e})`}},wr=(e,t)=>{if(typeof e!="function")throw new TypeError(X(32))},Et=()=>{},Fn=(e,t=Et)=>(e.catch(t),e),qn=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),be=e=>{if(e.aborted)throw new Dt(e.reason)};function Ln(e,t){let r=Et;return new Promise((n,s)=>{const i=()=>s(new Dt(e.reason));if(e.aborted){i();return}r=qn(e,i),t.finally(()=>r()).then(n,s)}).finally(()=>{r=Et})}var qi=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(r){return{status:r instanceof Dt?"cancelled":"rejected",error:r}}finally{t==null||t()}},Pt=e=>t=>Fn(Ln(e,t).then(r=>(be(e),r))),Un=e=>{const t=Pt(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:Ie}=Object,Br={},xt="listenerMiddleware",Li=(e,t)=>{const r=n=>qn(e,()=>n.abort(e.reason));return(n,s)=>{wr(n);const i=new AbortController;r(i);const o=qi(async()=>{be(e),be(i.signal);const v=await n({pause:Pt(i.signal),delay:Un(i.signal),signal:i.signal});return be(i.signal),v},()=>i.abort(Ni));return s!=null&&s.autoJoin&&t.push(o.catch(Et)),{result:Pt(e)(o),cancel(){i.abort(xi)}}}},Ui=(e,t)=>{const r=async(n,s)=>{be(t);let i=()=>{};const v=[new Promise((E,b)=>{let _=e({predicate:n,effect:(I,A)=>{A.unsubscribe(),E([I,A.getState(),A.getOriginalState()])}});i=()=>{_(),b()}})];s!=null&&v.push(new Promise(E=>setTimeout(E,s,null)));try{const E=await Ln(t,Promise.race(v));return be(t),E}finally{i()}};return(n,s)=>Fn(r(n,s))},zn=e=>{let{type:t,actionCreator:r,matcher:n,predicate:s,effect:i}=e;if(t)s=J(t).match;else if(r)t=r.type,s=r.match;else if(n)s=n;else if(!s)throw new Error(X(21));return wr(i),{predicate:s,type:t,effect:i}},$n=Ie(e=>{const{type:t,predicate:r,effect:n}=zn(e);return{id:Qt(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(X(22))}}},{withTypes:()=>$n}),Kr=(e,t)=>{const{type:r,effect:n,predicate:s}=zn(t);return Array.from(e.values()).find(i=>(typeof r=="string"?i.type===r:i.predicate===s)&&i.effect===n)},ar=e=>{e.pending.forEach(t=>{t.abort(cr)})},zi=(e,t)=>()=>{for(const r of t.keys())ar(r);e.clear()},Gr=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},jn=Ie(J(`${xt}/add`),{withTypes:()=>jn}),$i=J(`${xt}/removeAll`),Vn=Ie(J(`${xt}/remove`),{withTypes:()=>Vn}),ji=(...e)=>{console.error(`${xt}/error`,...e)},Ho=(e={})=>{const t=new Map,r=new Map,n=P=>{const m=r.get(P)??0;r.set(P,m+1)},s=P=>{const m=r.get(P)??1;m===1?r.delete(P):r.set(P,m-1)},{extra:i,onError:o=ji}=e;wr(o);const v=P=>(P.unsubscribe=()=>t.delete(P.id),t.set(P.id,P),m=>{P.unsubscribe(),m!=null&&m.cancelActive&&ar(P)}),E=P=>{const m=Kr(t,P)??$n(P);return v(m)};Ie(E,{withTypes:()=>E});const b=P=>{const m=Kr(t,P);return m&&(m.unsubscribe(),P.cancelActive&&ar(m)),!!m};Ie(b,{withTypes:()=>b});const _=async(P,m,R,g)=>{const w=new AbortController,O=Ui(E,w.signal),y=[];try{P.pending.add(w),n(P),await Promise.resolve(P.effect(m,Ie({},R,{getOriginalState:g,condition:(u,a)=>O(u,a).then(Boolean),take:O,delay:Un(w.signal),pause:Pt(w.signal),extra:i,signal:w.signal,fork:Li(w.signal,y),unsubscribe:P.unsubscribe,subscribe:()=>{t.set(P.id,P)},cancelActiveListeners:()=>{P.pending.forEach((u,a,l)=>{u!==w&&(u.abort(cr),l.delete(u))})},cancel:()=>{w.abort(cr),P.pending.delete(w)},throwIfCancelled:()=>{be(w.signal)}})))}catch(u){u instanceof Dt||Gr(o,u,{raisedBy:"effect"})}finally{await Promise.all(y),w.abort(Fi),s(P),P.pending.delete(w)}},I=zi(t,r);return{middleware:P=>m=>R=>{if(!yr(R))return m(R);if(jn.match(R))return E(R.payload);if($i.match(R)){I();return}if(Vn.match(R))return b(R.payload);let g=P.getState();const w=()=>{if(g===Br)throw new Error(X(23));return g};let O;try{if(O=m(R),t.size>0){const y=P.getState(),u=Array.from(t.values());for(const a of u){let l=!1;try{l=a.predicate(R,y,g)}catch(p){l=!1,Gr(o,p,{raisedBy:"predicate"})}l&&_(a,R,P,w)}}}finally{g=Br}return O},startListening:E,stopListening:b,clearListeners:I}};function X(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Hn=(e=>(e.uninitialized="uninitialized",e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected",e))(Hn||{}),le="uninitialized",ur="pending",qe="fulfilled",Le="rejected";function Yr(e){return{status:e,isUninitialized:e===le,isLoading:e===ur,isSuccess:e===qe,isError:e===Le}}var Xr=yt;function Er(e,t){if(e===t||!(Xr(e)&&Xr(t)||Array.isArray(e)&&Array.isArray(t)))return t;const r=Object.keys(t),n=Object.keys(e);let s=r.length===n.length;const i=Array.isArray(t)?[]:{};for(const o of r)i[o]=Er(e[o],t[o]),s&&(s=e[o]===i[o]);return s?e:i}function lr(e,t,r){return e.reduce((n,s,i)=>(t(s,i)&&n.push(r(s,i)),n),[]).flat()}function Vi(){return typeof document>"u"?!0:document.visibilityState!=="hidden"}function Pr(e){return e!=null}function Jr(e){return[...(e==null?void 0:e.values())??[]].filter(Pr)}function Hi(){return typeof navigator>"u"||navigator.onLine===void 0?!0:navigator.onLine}function Ct(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}var fr=()=>new Map,Zr=class{constructor(e,t=void 0){this.value=e,this.meta=t}},Nt="__rtkq/",Wn="online",Bn="offline",Wi="focus",Kn="focused",Bi="visibilitychange",Ft=J(`${Nt}${Kn}`),Cr=J(`${Nt}un${Kn}`),qt=J(`${Nt}${Wn}`),Rr=J(`${Nt}${Bn}`),ut=!1;function Wo(e,t){function r(){const[n,s,i,o]=[Ft,Cr,qt,Rr].map(b=>()=>e(b())),v=()=>{window.document.visibilityState==="visible"?n():s()};let E=()=>{ut=!1};if(!ut&&typeof window<"u"&&window.addEventListener){let b=function(I){Object.entries(_).forEach(([A,P])=>{I?window.addEventListener(A,P,!1):window.removeEventListener(A,P)})};const _={[Wi]:n,[Bi]:v,[Wn]:i,[Bn]:o};b(!0),ut=!0,E=()=>{b(!1),ut=!1}}return E}return r()}var it="query",Gn="mutation",Yn="infinitequery";function Lt(e){return e.type===it}function Ki(e){return e.type===Gn}function Ut(e){return e.type===Yn}function Rt(e){return Lt(e)||Ut(e)}function Mr(e,t,r,n,s,i){const o=Gi(e)?e(t,r,n,s):e;return o?lr(o,Pr,v=>i(Xn(v))):[]}function Gi(e){return typeof e=="function"}function Xn(e){return typeof e=="string"?{type:e}:e}function Yi(e,t){return e.catch(t)}var Te=(e,t)=>e.endpointDefinitions[t],Ge=Symbol("forceQueryFn"),dr=e=>typeof e[Ge]=="function";function Xi({serializeQueryArgs:e,queryThunk:t,infiniteQueryThunk:r,mutationThunk:n,api:s,context:i,getInternalState:o}){const v=u=>{var a;return(a=o(u))==null?void 0:a.runningQueries},E=u=>{var a;return(a=o(u))==null?void 0:a.runningMutations},{unsubscribeQueryResult:b,removeMutationResult:_,updateSubscriptionOptions:I}=s.internalActions;return{buildInitiateQuery:w,buildInitiateInfiniteQuery:O,buildInitiateMutation:y,getRunningQueryThunk:A,getRunningMutationThunk:P,getRunningQueriesThunk:m,getRunningMutationsThunk:R};function A(u,a){return l=>{var h;const p=Te(i,u),M=e({queryArgs:a,endpointDefinition:p,endpointName:u});return(h=v(l))==null?void 0:h.get(M)}}function P(u,a){return l=>{var p;return(p=E(l))==null?void 0:p.get(a)}}function m(){return u=>Jr(v(u))}function R(){return u=>Jr(E(u))}function g(u,a){const l=(p,{subscribe:M=!0,forceRefetch:h,subscriptionOptions:f,[Ge]:c,...d}={})=>(S,C)=>{var U;const T=e({queryArgs:p,endpointDefinition:a,endpointName:u});let x;const N={...d,type:it,subscribe:M,forceRefetch:h,subscriptionOptions:f,endpointName:u,originalArgs:p,queryCacheKey:T,[Ge]:c};if(Lt(a))x=t(N);else{const{direction:L,initialPageParam:B,refetchCachedPages:Z}=d;x=r({...N,direction:L,initialPageParam:B,refetchCachedPages:Z})}const D=s.endpoints[u].select(p),k=S(x),q=D(C()),{requestId:F,abort:H}=k,W=q.requestId!==F,$=(U=v(S))==null?void 0:U.get(T),K=()=>D(C()),V=Object.assign(c?k.then(K):W&&!$?Promise.resolve(q):Promise.all([$,k]).then(K),{arg:p,requestId:F,subscriptionOptions:f,queryCacheKey:T,abort:H,async unwrap(){const L=await V;if(L.isError)throw L.error;return L.data},refetch:L=>S(l(p,{subscribe:!1,forceRefetch:!0,...L})),unsubscribe(){M&&S(b({queryCacheKey:T,requestId:F}))},updateSubscriptionOptions(L){V.subscriptionOptions=L,S(I({endpointName:u,requestId:F,queryCacheKey:T,options:L}))}});if(!$&&!W&&!c){const L=v(S);L.set(T,V),V.then(()=>{L.delete(T)})}return V};return l}function w(u,a){return g(u,a)}function O(u,a){return g(u,a)}function y(u){return(a,{track:l=!0,fixedCacheKey:p}={})=>(M,h)=>{const f=n({type:"mutation",endpointName:u,originalArgs:a,track:l,fixedCacheKey:p}),c=M(f),{requestId:d,abort:S,unwrap:C}=c,T=Yi(c.unwrap().then(k=>({data:k})),k=>({error:k})),x=()=>{M(_({requestId:d,fixedCacheKey:p}))},N=Object.assign(T,{arg:c.arg,requestId:d,abort:S,unwrap:C,reset:x}),D=E(M);return D.set(d,N),N.then(()=>{D.delete(d)}),p&&(D.set(p,N),N.then(()=>{D.get(p)===N&&D.delete(p)})),N}}}var Jn=class extends Ss{constructor(e,t,r,n){super(e),this.value=t,this.schemaName=r,this._bqMeta=n}},ye=(e,t)=>Array.isArray(e)?e.includes(t):!!e;async function ge(e,t,r,n){const s=await e["~standard"].validate(t);if(s.issues)throw new Jn(s.issues,t,r,n);return s.value}function en(e){return e}var De=(e={})=>({...e,[Ot]:!0});function Ji({reducerPath:e,baseQuery:t,context:{endpointDefinitions:r},serializeQueryArgs:n,api:s,assertTagType:i,selectors:o,onSchemaFailure:v,catchSchemaFailure:E,skipSchemaValidation:b}){const _=(c,d,S,C)=>(T,x)=>{const N=r[c],D=n({queryArgs:d,endpointDefinition:N,endpointName:c});if(T(s.internalActions.queryResultPatched({queryCacheKey:D,patches:S})),!C)return;const k=s.endpoints[c].select(d)(x()),q=Mr(N.providesTags,k.data,void 0,d,{},i);T(s.internalActions.updateProvidedBy([{queryCacheKey:D,providedTags:q}]))};function I(c,d,S=0){const C=[d,...c];return S&&C.length>S?C.slice(0,-1):C}function A(c,d,S=0){const C=[...c,d];return S&&C.length>S?C.slice(1):C}const P=(c,d,S,C=!0)=>(T,x)=>{const D=s.endpoints[c].select(d)(x()),k={patches:[],inversePatches:[],undo:()=>T(s.util.patchQueryData(c,d,k.inversePatches,C))};if(D.status===le)return k;let q;if("data"in D)if(ne(D.data)){const[F,H,W]=Tn(D.data,S);k.patches.push(...H),k.inversePatches.push(...W),q=F}else q=S(D.data),k.patches.push({op:"replace",path:[],value:q}),k.inversePatches.push({op:"replace",path:[],value:D.data});return k.patches.length===0||T(s.util.patchQueryData(c,d,k.patches,C)),k},m=(c,d,S)=>C=>C(s.endpoints[c].initiate(d,{subscribe:!1,forceRefetch:!0,[Ge]:()=>({data:S})})),R=(c,d)=>c.query&&c[d]?c[d]:en,g=async(c,{signal:d,abort:S,rejectWithValue:C,fulfillWithValue:T,dispatch:x,getState:N,extra:D})=>{var W,$;const k=r[c.endpointName],{metaSchema:q,skipSchemaValidation:F=b}=k,H=c.type===it;try{let K=en;const V={signal:d,abort:S,dispatch:x,getState:N,extra:D,endpoint:c.endpointName,type:c.type,forced:H?w(c,N()):void 0,queryCacheKey:H?c.queryCacheKey:void 0},U=H?c[Ge]:void 0;let L;const B=async(z,j,fe,ee)=>{if(j==null&&z.pages.length)return Promise.resolve({data:z});const we={queryArg:c.originalArgs,pageParam:j},se=await Z(we),Ee=ee?I:A;return{data:{pages:Ee(z.pages,se.data,fe),pageParams:Ee(z.pageParams,j,fe)},meta:se.meta}};async function Z(z){let j;const{extraOptions:fe,argSchema:ee,rawResponseSchema:we,responseSchema:se}=k;if(ee&&!ye(F,"arg")&&(z=await ge(ee,z,"argSchema",{})),U?j=U():k.query?(K=R(k,"transformResponse"),j=await t(k.query(z),V,fe)):j=await k.queryFn(z,V,fe,Pe=>t(Pe,V,fe)),typeof process<"u",j.error)throw new Zr(j.error,j.meta);let{data:Ee}=j;we&&!ye(F,"rawResponse")&&(Ee=await ge(we,j.data,"rawResponseSchema",j.meta));let de=await K(Ee,j.meta,z);return se&&!ye(F,"response")&&(de=await ge(se,de,"responseSchema",j.meta)),{...j,data:de}}if(H&&"infiniteQueryOptions"in k){const{infiniteQueryOptions:z}=k,{maxPages:j=1/0}=z,fe=c.refetchCachedPages??z.refetchCachedPages??!0;let ee;const we={pages:[],pageParams:[]},se=(W=o.selectQueryEntry(N(),c.queryCacheKey))==null?void 0:W.data,de=w(c,N())&&!c.direction||!se?we:se;if("direction"in c&&c.direction&&de.pages.length){const Pe=c.direction==="backward",$t=(Pe?Zn:hr)(z,de,c.originalArgs);ee=await B(de,$t,j,Pe)}else{const{initialPageParam:Pe=z.initialPageParam}=c,zt=(se==null?void 0:se.pageParams)??[],$t=zt[0]??Pe,is=zt.length;if(ee=await B(de,$t,j),U&&(ee={data:ee.data.pages[0]}),fe)for(let Ir=1;Ir<is;Ir++){const os=hr(z,ee.data,c.originalArgs);ee=await B(ee.data,os,j)}}L=ee}else L=await Z(c.originalArgs);return q&&!ye(F,"meta")&&L.meta&&(L.meta=await ge(q,L.meta,"metaSchema",L.meta)),T(L.data,De({fulfilledTimeStamp:Date.now(),baseQueryMeta:L.meta}))}catch(K){let V=K;if(V instanceof Zr){let U=R(k,"transformErrorResponse");const{rawErrorResponseSchema:L,errorResponseSchema:B}=k;let{value:Z,meta:z}=V;try{L&&!ye(F,"rawErrorResponse")&&(Z=await ge(L,Z,"rawErrorResponseSchema",z)),q&&!ye(F,"meta")&&(z=await ge(q,z,"metaSchema",z));let j=await U(Z,z,c.originalArgs);return B&&!ye(F,"errorResponse")&&(j=await ge(B,j,"errorResponseSchema",z)),C(j,De({baseQueryMeta:z}))}catch(j){V=j}}try{if(V instanceof Jn){const U={endpoint:c.endpointName,arg:c.originalArgs,type:c.type,queryCacheKey:H?c.queryCacheKey:void 0};($=k.onSchemaFailure)==null||$.call(k,V,U),v==null||v(V,U);const{catchSchemaFailure:L=E}=k;if(L)return C(L(V,U),De({baseQueryMeta:V._bqMeta}))}}catch(U){V=U}throw console.error(V),V}};function w(c,d){const S=o.selectQueryEntry(d,c.queryCacheKey),C=o.selectConfig(d).refetchOnMountOrArgChange,T=S==null?void 0:S.fulfilledTimeStamp,x=c.forceRefetch??(c.subscribe&&C);return x?x===!0||(Number(new Date)-Number(T))/1e3>=x:!1}const O=()=>Wr(`${e}/executeQuery`,g,{getPendingMeta({arg:d}){const S=r[d.endpointName];return De({startedTimeStamp:Date.now(),...Ut(S)?{direction:d.direction}:{}})},condition(d,{getState:S}){var F;const C=S(),T=o.selectQueryEntry(C,d.queryCacheKey),x=T==null?void 0:T.fulfilledTimeStamp,N=d.originalArgs,D=T==null?void 0:T.originalArgs,k=r[d.endpointName],q=d.direction;return dr(d)?!0:(T==null?void 0:T.status)==="pending"?!1:w(d,C)||Lt(k)&&((F=k==null?void 0:k.forceRefetch)!=null&&F.call(k,{currentArg:N,previousArg:D,endpointState:T,state:C}))?!0:!(x&&!q)},dispatchConditionRejection:!0}),y=O(),u=O(),a=Wr(`${e}/executeMutation`,g,{getPendingMeta(){return De({startedTimeStamp:Date.now()})}}),l=c=>"force"in c,p=c=>"ifOlderThan"in c,M=(c,d,S={})=>(C,T)=>{const x=l(S)&&S.force,N=p(S)&&S.ifOlderThan,D=(q=!0)=>{const F={forceRefetch:q,subscribe:!1};return s.endpoints[c].initiate(d,F)},k=s.endpoints[c].select(d)(T());if(x)C(D());else if(N){const q=k==null?void 0:k.fulfilledTimeStamp;if(!q){C(D());return}(Number(new Date)-Number(new Date(q)))/1e3>=N&&C(D())}else C(D(!1))};function h(c){return d=>{var S,C;return((C=(S=d==null?void 0:d.meta)==null?void 0:S.arg)==null?void 0:C.endpointName)===c}}function f(c,d){return{matchPending:je(Sr(c),h(d)),matchFulfilled:je(pe(c),h(d)),matchRejected:je(Oe(c),h(d))}}return{queryThunk:y,mutationThunk:a,infiniteQueryThunk:u,prefetch:M,updateQueryData:P,upsertQueryData:m,patchQueryData:_,buildMatchThunkActions:f}}function hr(e,{pages:t,pageParams:r},n){const s=t.length-1;return e.getNextPageParam(t[s],t,r[s],r,n)}function Zn(e,{pages:t,pageParams:r},n){var s;return(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,r[0],r,n)}function es(e,t,r,n){return Mr(r[e.meta.arg.endpointName][t],pe(e)?e.payload:void 0,kt(e)?e.payload:void 0,e.meta.arg.originalArgs,"baseQueryMeta"in e.meta?e.meta.baseQueryMeta:void 0,n)}function tn(e){return re(e)?An(e):e}function lt(e,t,r){const n=e[t];n&&r(n)}function Ye(e){return("arg"in e?e.arg.fixedCacheKey:e.fixedCacheKey)??e.requestId}function rn(e,t,r){const n=e[Ye(t)];n&&r(n)}var ft={};function Zi({reducerPath:e,queryThunk:t,mutationThunk:r,serializeQueryArgs:n,context:{endpointDefinitions:s,apiUid:i,extractRehydrationInfo:o,hasRehydrationInfo:v},assertTagType:E,config:b}){const _=J(`${e}/resetApiState`);function I(h,f,c,d){var S;h[S=f.queryCacheKey]??(h[S]={status:le,endpointName:f.endpointName}),lt(h,f.queryCacheKey,C=>{C.status=ur,C.requestId=c&&C.requestId?C.requestId:d.requestId,f.originalArgs!==void 0&&(C.originalArgs=f.originalArgs),C.startedTimeStamp=d.startedTimeStamp;const T=s[d.arg.endpointName];Ut(T)&&"direction"in f&&(C.direction=f.direction)})}function A(h,f,c,d){lt(h,f.arg.queryCacheKey,S=>{if(S.requestId!==f.requestId&&!d)return;const{merge:C}=s[f.arg.endpointName];if(S.status=qe,C)if(S.data!==void 0){const{fulfilledTimeStamp:T,arg:x,baseQueryMeta:N,requestId:D}=f;let k=nt(S.data,q=>C(q,c,{arg:x.originalArgs,baseQueryMeta:N,fulfilledTimeStamp:T,requestId:D}));S.data=k}else S.data=c;else S.data=s[f.arg.endpointName].structuralSharing??!0?Er(re(S.data)?Ys(S.data):S.data,c):c;delete S.error,S.fulfilledTimeStamp=f.fulfilledTimeStamp})}const P=Ce({name:`${e}/queries`,initialState:ft,reducers:{removeQueryResult:{reducer(h,{payload:{queryCacheKey:f}}){delete h[f]},prepare:Qe()},cacheEntriesUpserted:{reducer(h,f){for(const c of f.payload){const{queryDescription:d,value:S}=c;I(h,d,!0,{arg:d,requestId:f.meta.requestId,startedTimeStamp:f.meta.timestamp}),A(h,{arg:d,requestId:f.meta.requestId,fulfilledTimeStamp:f.meta.timestamp,baseQueryMeta:{}},S,!0)}},prepare:h=>({payload:h.map(d=>{const{endpointName:S,arg:C,value:T}=d,x=s[S];return{queryDescription:{type:it,endpointName:S,originalArgs:d.arg,queryCacheKey:n({queryArgs:C,endpointDefinition:x,endpointName:S})},value:T}}),meta:{[Ot]:!0,requestId:Qt(),timestamp:Date.now()}})},queryResultPatched:{reducer(h,{payload:{queryCacheKey:f,patches:c}}){lt(h,f,d=>{d.data=zr(d.data,c.concat())})},prepare:Qe()}},extraReducers(h){h.addCase(t.pending,(f,{meta:c,meta:{arg:d}})=>{const S=dr(d);I(f,d,S,c)}).addCase(t.fulfilled,(f,{meta:c,payload:d})=>{const S=dr(c.arg);A(f,c,d,S)}).addCase(t.rejected,(f,{meta:{condition:c,arg:d,requestId:S},error:C,payload:T})=>{lt(f,d.queryCacheKey,x=>{if(!c){if(x.requestId!==S)return;x.status=Le,x.error=T??C}})}).addMatcher(v,(f,c)=>{const{queries:d}=o(c);for(const[S,C]of Object.entries(d))((C==null?void 0:C.status)===qe||(C==null?void 0:C.status)===Le)&&(f[S]=C)})}}),m=Ce({name:`${e}/mutations`,initialState:ft,reducers:{removeMutationResult:{reducer(h,{payload:f}){const c=Ye(f);c in h&&delete h[c]},prepare:Qe()}},extraReducers(h){h.addCase(r.pending,(f,{meta:c,meta:{requestId:d,arg:S,startedTimeStamp:C}})=>{S.track&&(f[Ye(c)]={requestId:d,status:ur,endpointName:S.endpointName,startedTimeStamp:C})}).addCase(r.fulfilled,(f,{payload:c,meta:d})=>{d.arg.track&&rn(f,d,S=>{S.requestId===d.requestId&&(S.status=qe,S.data=c,S.fulfilledTimeStamp=d.fulfilledTimeStamp)})}).addCase(r.rejected,(f,{payload:c,error:d,meta:S})=>{S.arg.track&&rn(f,S,C=>{C.requestId===S.requestId&&(C.status=Le,C.error=c??d)})}).addMatcher(v,(f,c)=>{const{mutations:d}=o(c);for(const[S,C]of Object.entries(d))((C==null?void 0:C.status)===qe||(C==null?void 0:C.status)===Le)&&S!==(C==null?void 0:C.requestId)&&(f[S]=C)})}}),R={tags:{},keys:{}},g=Ce({name:`${e}/invalidation`,initialState:R,reducers:{updateProvidedBy:{reducer(h,f){var c,d,S;for(const{queryCacheKey:C,providedTags:T}of f.payload){w(h,C);for(const{type:x,id:N}of T){const D=(d=(c=h.tags)[x]??(c[x]={}))[S=N||"__internal_without_id"]??(d[S]=[]);D.includes(C)||D.push(C)}h.keys[C]=T}},prepare:Qe()}},extraReducers(h){h.addCase(P.actions.removeQueryResult,(f,{payload:{queryCacheKey:c}})=>{w(f,c)}).addMatcher(v,(f,c)=>{var S,C,T;const{provided:d}=o(c);for(const[x,N]of Object.entries(d.tags??{}))for(const[D,k]of Object.entries(N)){const q=(C=(S=f.tags)[x]??(S[x]={}))[T=D||"__internal_without_id"]??(C[T]=[]);for(const F of k)q.includes(F)||q.push(F),f.keys[F]=d.keys[F]}}).addMatcher(ue(pe(t),kt(t)),(f,c)=>{O(f,[c])}).addMatcher(P.actions.cacheEntriesUpserted.match,(f,c)=>{const d=c.payload.map(({queryDescription:S,value:C})=>({type:"UNKNOWN",payload:C,meta:{requestStatus:"fulfilled",requestId:"UNKNOWN",arg:S}}));O(f,d)})}});function w(h,f){var d;const c=tn(h.keys[f]??[]);for(const S of c){const C=S.type,T=S.id??"__internal_without_id",x=(d=h.tags[C])==null?void 0:d[T];x&&(h.tags[C][T]=tn(x).filter(N=>N!==f))}delete h.keys[f]}function O(h,f){const c=f.map(d=>{const S=es(d,"providesTags",s,E),{queryCacheKey:C}=d.meta.arg;return{queryCacheKey:C,providedTags:S}});g.caseReducers.updateProvidedBy(h,g.actions.updateProvidedBy(c))}const y=Ce({name:`${e}/subscriptions`,initialState:ft,reducers:{updateSubscriptionOptions(h,f){},unsubscribeQueryResult(h,f){},internal_getRTKQSubscriptions(){}}}),u=Ce({name:`${e}/internalSubscriptions`,initialState:ft,reducers:{subscriptionsUpdated:{reducer(h,f){return zr(h,f.payload)},prepare:Qe()}}}),a=Ce({name:`${e}/config`,initialState:{online:Hi(),focused:Vi(),middlewareRegistered:!1,...b},reducers:{middlewareRegistered(h,{payload:f}){h.middlewareRegistered=h.middlewareRegistered==="conflict"||i!==f?"conflict":!0}},extraReducers:h=>{h.addCase(qt,f=>{f.online=!0}).addCase(Rr,f=>{f.online=!1}).addCase(Ft,f=>{f.focused=!0}).addCase(Cr,f=>{f.focused=!1}).addMatcher(v,f=>({...f}))}}),l=pn({queries:P.reducer,mutations:m.reducer,provided:g.reducer,subscriptions:u.reducer,config:a.reducer}),p=(h,f)=>l(_.match(f)?void 0:h,f),M={...a.actions,...P.actions,...y.actions,...u.actions,...m.actions,...g.actions,resetApiState:_};return{reducer:p,actions:M}}var ie=Symbol.for("RTKQ/skipToken"),ts={status:le},nn=nt(ts,()=>{}),sn=nt(ts,()=>{});function eo({serializeQueryArgs:e,reducerPath:t,createSelector:r}){const n=y=>nn,s=y=>sn;return{buildQuerySelector:A,buildInfiniteQuerySelector:P,buildMutationSelector:m,selectInvalidatedBy:R,selectCachedArgsForQuery:g,selectApiState:o,selectQueries:v,selectMutations:b,selectQueryEntry:E,selectConfig:_};function i(y){return{...y,...Yr(y.status)}}function o(y){return y[t]}function v(y){var u;return(u=o(y))==null?void 0:u.queries}function E(y,u){var a;return(a=v(y))==null?void 0:a[u]}function b(y){var u;return(u=o(y))==null?void 0:u.mutations}function _(y){var u;return(u=o(y))==null?void 0:u.config}function I(y,u,a){return l=>{if(l===ie)return r(n,a);const p=e({queryArgs:l,endpointDefinition:u,endpointName:y});return r(h=>E(h,p)??nn,a)}}function A(y,u){return I(y,u,i)}function P(y,u){const{infiniteQueryOptions:a}=u;function l(p){const M={...p,...Yr(p.status)},{isLoading:h,isError:f,direction:c}=M,d=c==="forward",S=c==="backward";return{...M,hasNextPage:w(a,M.data,M.originalArgs),hasPreviousPage:O(a,M.data,M.originalArgs),isFetchingNextPage:h&&d,isFetchingPreviousPage:h&&S,isFetchNextPageError:f&&d,isFetchPreviousPageError:f&&S}}return I(y,u,l)}function m(){return y=>{let u;return typeof y=="object"?u=Ye(y)??ie:u=y,r(u===ie?s:p=>{var M,h;return((h=(M=o(p))==null?void 0:M.mutations)==null?void 0:h[u])??sn},i)}}function R(y,u){const a=y[t],l=new Set,p=lr(u,Pr,Xn);for(const M of p){const h=a.provided.tags[M.type];if(!h)continue;let f=(M.id!==void 0?h[M.id]:Object.values(h).flat())??[];for(const c of f)l.add(c)}return Array.from(l.values()).flatMap(M=>{const h=a.queries[M];return h?{queryCacheKey:M,endpointName:h.endpointName,originalArgs:h.originalArgs}:[]})}function g(y,u){return lr(Object.values(v(y)),a=>(a==null?void 0:a.endpointName)===u&&a.status!==le,a=>a.originalArgs)}function w(y,u,a){return u?hr(y,u,a)!=null:!1}function O(y,u,a){return!u||!y.getPreviousPageParam?!1:Zn(y,u,a)!=null}}var Re=WeakMap?new WeakMap:void 0,on=({endpointName:e,queryArgs:t})=>{let r="";const n=Re==null?void 0:Re.get(t);if(typeof n=="string")r=n;else{const s=JSON.stringify(t,(i,o)=>(o=typeof o=="bigint"?{$bigint:o.toString()}:o,o=yt(o)?Object.keys(o).sort().reduce((v,E)=>(v[E]=o[E],v),{}):o,o));yt(t)&&(Re==null||Re.set(t,s)),r=s}return`${e}(${r})`};function rs(...e){return function(r){const n=Ar(b=>{var _;return(_=r.extractRehydrationInfo)==null?void 0:_.call(r,b,{reducerPath:r.reducerPath??"api"})}),s={reducerPath:"api",keepUnusedDataFor:60,refetchOnMountOrArgChange:!1,refetchOnFocus:!1,refetchOnReconnect:!1,invalidationBehavior:"delayed",...r,extractRehydrationInfo:n,serializeQueryArgs(b){let _=on;if("serializeQueryArgs"in b.endpointDefinition){const I=b.endpointDefinition.serializeQueryArgs;_=A=>{const P=I(A);return typeof P=="string"?P:on({...A,queryArgs:P})}}else r.serializeQueryArgs&&(_=r.serializeQueryArgs);return _(b)},tagTypes:[...r.tagTypes||[]]},i={endpointDefinitions:{},batch(b){b()},apiUid:Qt(),extractRehydrationInfo:n,hasRehydrationInfo:Ar(b=>n(b)!=null)},o={injectEndpoints:E,enhanceEndpoints({addTagTypes:b,endpoints:_}){if(b)for(const I of b)s.tagTypes.includes(I)||s.tagTypes.push(I);if(_)for(const[I,A]of Object.entries(_))typeof A=="function"?A(Te(i,I)):Object.assign(Te(i,I)||{},A);return o}},v=e.map(b=>b.init(o,s,i));function E(b){const _=b.endpoints({query:I=>({...I,type:it}),mutation:I=>({...I,type:Gn}),infiniteQuery:I=>({...I,type:Yn})});for(const[I,A]of Object.entries(_)){if(b.overrideExisting!==!0&&I in i.endpointDefinitions){if(b.overrideExisting==="throw")throw new Error(X(39));continue}i.endpointDefinitions[I]=A;for(const P of v)P.injectEndpoint(I,A)}return o}return o.injectEndpoints({endpoints:r.endpoints})}}function Bo(){return function(){throw new Error(X(33))}}function oe(e,...t){return Object.assign(e,...t)}var to=({api:e,queryThunk:t,internalState:r,mwApi:n})=>{const s=`${e.reducerPath}/subscriptions`;let i=null,o=null;const{updateSubscriptionOptions:v,unsubscribeQueryResult:E}=e.internalActions,b=(R,g)=>{if(v.match(g)){const{queryCacheKey:O,requestId:y,options:u}=g.payload,a=R.get(O);return a!=null&&a.has(y)&&a.set(y,u),!0}if(E.match(g)){const{queryCacheKey:O,requestId:y}=g.payload,u=R.get(O);return u&&u.delete(y),!0}if(e.internalActions.removeQueryResult.match(g))return R.delete(g.payload.queryCacheKey),!0;if(t.pending.match(g)){const{meta:{arg:O,requestId:y}}=g,u=Ct(R,O.queryCacheKey,fr);return O.subscribe&&u.set(y,O.subscriptionOptions??u.get(y)??{}),!0}let w=!1;if(t.rejected.match(g)){const{meta:{condition:O,arg:y,requestId:u}}=g;if(O&&y.subscribe){const a=Ct(R,y.queryCacheKey,fr);a.set(u,y.subscriptionOptions??a.get(u)??{}),w=!0}}return w},_=()=>r.currentSubscriptions,P={getSubscriptions:_,getSubscriptionCount:R=>{const w=_().get(R);return(w==null?void 0:w.size)??0},isRequestSubscribed:(R,g)=>{var O;const w=_();return!!((O=w==null?void 0:w.get(R))!=null&&O.get(g))}};function m(R){return JSON.parse(JSON.stringify(Object.fromEntries([...R].map(([g,w])=>[g,Object.fromEntries(w)]))))}return(R,g)=>{if(i||(i=m(r.currentSubscriptions)),e.util.resetApiState.match(R))return i={},r.currentSubscriptions.clear(),o=null,[!0,!1];if(e.internalActions.internal_getRTKQSubscriptions.match(R))return[!1,P];const w=b(r.currentSubscriptions,R);let O=!0;if(w){o||(o=setTimeout(()=>{const a=m(r.currentSubscriptions),[,l]=Tn(i,()=>a);g.next(e.internalActions.subscriptionsUpdated(l)),i=a,o=null},500));const y=typeof R.type=="string"&&!!R.type.startsWith(s),u=t.rejected.match(R)&&R.meta.condition&&!!R.meta.arg.subscribe;O=!y&&!u}return[O,!1]}},ro=2147483647/1e3-1,no=({reducerPath:e,api:t,queryThunk:r,context:n,internalState:s,selectors:{selectQueryEntry:i,selectConfig:o},getRunningQueryThunk:v,mwApi:E})=>{const{removeQueryResult:b,unsubscribeQueryResult:_,cacheEntriesUpserted:I}=t.internalActions,A=ue(_.match,r.fulfilled,r.rejected,I.match);function P(y){const u=s.currentSubscriptions.get(y);return u?u.size>0:!1}const m={};function R(y){var u;for(const a of y.values())(u=a==null?void 0:a.abort)==null||u.call(a)}const g=(y,u)=>{const a=u.getState(),l=o(a);if(A(y)){let p;if(I.match(y))p=y.payload.map(M=>M.queryDescription.queryCacheKey);else{const{queryCacheKey:M}=_.match(y)?y.payload:y.meta.arg;p=[M]}w(p,u,l)}if(t.util.resetApiState.match(y)){for(const[p,M]of Object.entries(m))M&&clearTimeout(M),delete m[p];R(s.runningQueries),R(s.runningMutations)}if(n.hasRehydrationInfo(y)){const{queries:p}=n.extractRehydrationInfo(y);w(Object.keys(p),u,l)}};function w(y,u,a){const l=u.getState();for(const p of y){const M=i(l,p);M!=null&&M.endpointName&&O(p,M.endpointName,u,a)}}function O(y,u,a,l){const p=Te(n,u),M=(p==null?void 0:p.keepUnusedDataFor)??l.keepUnusedDataFor;if(M===1/0)return;const h=Math.max(0,Math.min(M,ro));if(!P(y)){const f=m[y];f&&clearTimeout(f),m[y]=setTimeout(()=>{if(!P(y)){const c=i(a.getState(),y);if(c!=null&&c.endpointName){const d=a.dispatch(v(c.endpointName,c.originalArgs));d==null||d.abort()}a.dispatch(b({queryCacheKey:y}))}delete m[y]},h*1e3)}}return g},cn=new Error("Promise never resolved before cacheEntryRemoved."),so=({api:e,reducerPath:t,context:r,queryThunk:n,mutationThunk:s,internalState:i,selectors:{selectQueryEntry:o,selectApiState:v}})=>{const E=or(n),b=or(s),_=pe(n,s),I={},{removeQueryResult:A,removeMutationResult:P,cacheEntriesUpserted:m}=e.internalActions;function R(a,l,p){const M=I[a];M!=null&&M.valueResolved&&(M.valueResolved({data:l,meta:p}),delete M.valueResolved)}function g(a){const l=I[a];l&&(delete I[a],l.cacheEntryRemoved())}function w(a){const{arg:l,requestId:p}=a.meta,{endpointName:M,originalArgs:h}=l;return[M,h,p]}const O=(a,l,p)=>{const M=y(a);function h(f,c,d,S){const C=o(p,c),T=o(l.getState(),c);!C&&T&&u(f,S,c,l,d)}if(n.pending.match(a)){const[f,c,d]=w(a);h(f,M,d,c)}else if(m.match(a))for(const{queryDescription:f,value:c}of a.payload){const{endpointName:d,originalArgs:S,queryCacheKey:C}=f;h(d,C,a.meta.requestId,S),R(C,c,{})}else if(s.pending.match(a)){if(l.getState()[t].mutations[M]){const[c,d,S]=w(a);u(c,d,M,l,S)}}else if(_(a))R(M,a.payload,a.meta.baseQueryMeta);else if(A.match(a)||P.match(a))g(M);else if(e.util.resetApiState.match(a))for(const f of Object.keys(I))g(f)};function y(a){return E(a)?a.meta.arg.queryCacheKey:b(a)?a.meta.arg.fixedCacheKey??a.meta.requestId:A.match(a)?a.payload.queryCacheKey:P.match(a)?Ye(a.payload):""}function u(a,l,p,M,h){const f=Te(r,a),c=f==null?void 0:f.onCacheEntryAdded;if(!c)return;const d={},S=new Promise(k=>{d.cacheEntryRemoved=k}),C=Promise.race([new Promise(k=>{d.valueResolved=k}),S.then(()=>{throw cn})]);C.catch(()=>{}),I[p]=d;const T=e.endpoints[a].select(Rt(f)?l:p),x=M.dispatch((k,q,F)=>F),N={...M,getCacheEntry:()=>T(M.getState()),requestId:h,extra:x,updateCachedData:Rt(f)?k=>M.dispatch(e.util.updateQueryData(a,l,k)):void 0,cacheDataLoaded:C,cacheEntryRemoved:S},D=c(l,N);Promise.resolve(D).catch(k=>{if(k!==cn)throw k})}return O},io=({api:e,context:{apiUid:t},reducerPath:r})=>(n,s)=>{e.util.resetApiState.match(n)&&s.dispatch(e.internalActions.middlewareRegistered(t))},oo=({reducerPath:e,context:t,context:{endpointDefinitions:r},mutationThunk:n,queryThunk:s,api:i,assertTagType:o,refetchQuery:v,internalState:E})=>{const{removeQueryResult:b}=i.internalActions,_=ue(pe(n),kt(n)),I=ue(pe(s,n),Oe(s,n));let A=[],P=0;const m=(w,O)=>{(s.pending.match(w)||n.pending.match(w))&&P++,I(w)&&(P=Math.max(0,P-1)),_(w)?g(es(w,"invalidatesTags",r,o),O):I(w)?g([],O):i.util.invalidateTags.match(w)&&g(Mr(w.payload,void 0,void 0,void 0,void 0,o),O)};function R(){return P>0}function g(w,O){const y=O.getState(),u=y[e];if(A.push(...w),u.config.invalidationBehavior==="delayed"&&R())return;const a=A;if(A=[],a.length===0)return;const l=i.util.selectInvalidatedBy(y,a);t.batch(()=>{const p=Array.from(l.values());for(const{queryCacheKey:M}of p){const h=u.queries[M],f=Ct(E.currentSubscriptions,M,fr);h&&(f.size===0?O.dispatch(b({queryCacheKey:M})):h.status!==le&&O.dispatch(v(h)))}})}return m},co=({reducerPath:e,queryThunk:t,api:r,refetchQuery:n,internalState:s})=>{const{currentPolls:i,currentSubscriptions:o}=s,v=new Set;let E=null;const b=(g,w)=>{(r.internalActions.updateSubscriptionOptions.match(g)||r.internalActions.unsubscribeQueryResult.match(g))&&_(g.payload.queryCacheKey,w),(t.pending.match(g)||t.rejected.match(g)&&g.meta.condition)&&_(g.meta.arg.queryCacheKey,w),(t.fulfilled.match(g)||t.rejected.match(g)&&!g.meta.condition)&&I(g.meta.arg,w),r.util.resetApiState.match(g)&&(m(),E&&(clearTimeout(E),E=null),v.clear())};function _(g,w){v.add(g),E||(E=setTimeout(()=>{for(const O of v)A({queryCacheKey:O},w);v.clear(),E=null},0))}function I({queryCacheKey:g},w){const O=w.getState()[e],y=O.queries[g],u=o.get(g);if(!y||y.status===le)return;const{lowestPollingInterval:a,skipPollingIfUnfocused:l}=R(u);if(!Number.isFinite(a))return;const p=i.get(g);p!=null&&p.timeout&&(clearTimeout(p.timeout),p.timeout=void 0);const M=Date.now()+a;i.set(g,{nextPollTimestamp:M,pollingInterval:a,timeout:setTimeout(()=>{(O.config.focused||!l)&&w.dispatch(n(y)),I({queryCacheKey:g},w)},a)})}function A({queryCacheKey:g},w){const y=w.getState()[e].queries[g],u=o.get(g);if(!y||y.status===le)return;const{lowestPollingInterval:a}=R(u);if(!Number.isFinite(a)){P(g);return}const l=i.get(g),p=Date.now()+a;(!l||p<l.nextPollTimestamp)&&I({queryCacheKey:g},w)}function P(g){const w=i.get(g);w!=null&&w.timeout&&clearTimeout(w.timeout),i.delete(g)}function m(){for(const g of i.keys())P(g)}function R(g=new Map){let w=!1,O=Number.POSITIVE_INFINITY;for(const y of g.values())y.pollingInterval&&(O=Math.min(y.pollingInterval,O),w=y.skipPollingIfUnfocused||w);return{lowestPollingInterval:O,skipPollingIfUnfocused:w}}return b},ao=({api:e,context:t,queryThunk:r,mutationThunk:n})=>{const s=Sr(r,n),i=Oe(r,n),o=pe(r,n),v={};return(b,_)=>{var I,A;if(s(b)){const{requestId:P,arg:{endpointName:m,originalArgs:R}}=b.meta,g=Te(t,m),w=g==null?void 0:g.onQueryStarted;if(w){const O={},y=new Promise((p,M)=>{O.resolve=p,O.reject=M});y.catch(()=>{}),v[P]=O;const u=e.endpoints[m].select(Rt(g)?R:P),a=_.dispatch((p,M,h)=>h),l={..._,getCacheEntry:()=>u(_.getState()),requestId:P,extra:a,updateCachedData:Rt(g)?p=>_.dispatch(e.util.updateQueryData(m,R,p)):void 0,queryFulfilled:y};w(R,l)}}else if(o(b)){const{requestId:P,baseQueryMeta:m}=b.meta;(I=v[P])==null||I.resolve({data:b.payload,meta:m}),delete v[P]}else if(i(b)){const{requestId:P,rejectedWithValue:m,baseQueryMeta:R}=b.meta;(A=v[P])==null||A.reject({error:b.payload??b.error,isUnhandledError:!m,meta:R}),delete v[P]}}},uo=({reducerPath:e,context:t,api:r,refetchQuery:n,internalState:s})=>{const{removeQueryResult:i}=r.internalActions,o=(E,b)=>{Ft.match(E)&&v(b,"refetchOnFocus"),qt.match(E)&&v(b,"refetchOnReconnect")};function v(E,b){const _=E.getState()[e],I=_.queries,A=s.currentSubscriptions;t.batch(()=>{for(const P of A.keys()){const m=I[P],R=A.get(P);if(!R||!m)continue;const g=[...R.values()];(g.some(O=>O[b]===!0)||g.every(O=>O[b]===void 0)&&_.config[b])&&(R.size===0?E.dispatch(i({queryCacheKey:P})):m.status!==le&&E.dispatch(n(m)))}})}return o};function lo(e){const{reducerPath:t,queryThunk:r,api:n,context:s,getInternalState:i}=e,{apiUid:o}=s,v={invalidateTags:J(`${t}/invalidateTags`)},E=A=>A.type.startsWith(`${t}/`),b=[io,no,oo,co,so,ao];return{middleware:A=>{let P=!1;const m=i(A.dispatch),R={...e,internalState:m,refetchQuery:I,isThisApiSliceAction:E,mwApi:A},g=b.map(y=>y(R)),w=to(R),O=uo(R);return y=>u=>{if(!yr(u))return y(u);P||(P=!0,A.dispatch(n.internalActions.middlewareRegistered(o)));const a={...A,next:y},l=A.getState(),[p,M]=w(u,a,l);let h;if(p?h=y(u):h=M,A.getState()[t]&&(O(u,a,l),E(u)||s.hasRehydrationInfo(u)))for(const f of g)f(u,a,l);return h}},actions:v};function I(A){return e.api.endpoints[A.endpointName].initiate(A.originalArgs,{subscribe:!1,forceRefetch:!0})}}var an=Symbol(),ns=({createSelector:e=yn}={})=>({name:an,init(t,{baseQuery:r,tagTypes:n,reducerPath:s,serializeQueryArgs:i,keepUnusedDataFor:o,refetchOnMountOrArgChange:v,refetchOnFocus:E,refetchOnReconnect:b,invalidationBehavior:_,onSchemaFailure:I,catchSchemaFailure:A,skipSchemaValidation:P},m){fi();const R=U=>U;Object.assign(t,{reducerPath:s,endpoints:{},internalActions:{onOnline:qt,onOffline:Rr,onFocus:Ft,onFocusLost:Cr},util:{}});const g=eo({serializeQueryArgs:i,reducerPath:s,createSelector:e}),{selectInvalidatedBy:w,selectCachedArgsForQuery:O,buildQuerySelector:y,buildInfiniteQuerySelector:u,buildMutationSelector:a}=g;oe(t.util,{selectInvalidatedBy:w,selectCachedArgsForQuery:O});const{queryThunk:l,infiniteQueryThunk:p,mutationThunk:M,patchQueryData:h,updateQueryData:f,upsertQueryData:c,prefetch:d,buildMatchThunkActions:S}=Ji({baseQuery:r,reducerPath:s,context:m,api:t,serializeQueryArgs:i,assertTagType:R,selectors:g,onSchemaFailure:I,catchSchemaFailure:A,skipSchemaValidation:P}),{reducer:C,actions:T}=Zi({context:m,queryThunk:l,mutationThunk:M,serializeQueryArgs:i,reducerPath:s,assertTagType:R,config:{refetchOnFocus:E,refetchOnReconnect:b,refetchOnMountOrArgChange:v,keepUnusedDataFor:o,reducerPath:s,invalidationBehavior:_}});oe(t.util,{patchQueryData:h,updateQueryData:f,upsertQueryData:c,prefetch:d,resetApiState:T.resetApiState,upsertQueryEntries:T.cacheEntriesUpserted}),oe(t.internalActions,T);const x=new WeakMap,N=U=>Ct(x,U,()=>({currentSubscriptions:new Map,currentPolls:new Map,runningQueries:new Map,runningMutations:new Map})),{buildInitiateQuery:D,buildInitiateInfiniteQuery:k,buildInitiateMutation:q,getRunningMutationThunk:F,getRunningMutationsThunk:H,getRunningQueriesThunk:W,getRunningQueryThunk:$}=Xi({queryThunk:l,mutationThunk:M,infiniteQueryThunk:p,api:t,serializeQueryArgs:i,context:m,getInternalState:N});oe(t.util,{getRunningMutationThunk:F,getRunningMutationsThunk:H,getRunningQueryThunk:$,getRunningQueriesThunk:W});const{middleware:K,actions:V}=lo({reducerPath:s,context:m,queryThunk:l,mutationThunk:M,infiniteQueryThunk:p,api:t,assertTagType:R,selectors:g,getRunningQueryThunk:$,getInternalState:N});return oe(t.util,V),oe(t,{reducer:C,middleware:K}),{name:an,injectEndpoint(U,L){var z;const Z=(z=t.endpoints)[U]??(z[U]={});Lt(L)&&oe(Z,{name:U,select:y(U,L),initiate:D(U,L)},S(l,U)),Ki(L)&&oe(Z,{name:U,select:a(),initiate:q(U)},S(M,U)),Ut(L)&&oe(Z,{name:U,select:u(U,L),initiate:k(U,L)},S(l,U))}}}});ns();function dt(e){return e.replace(e[0],e[0].toUpperCase())}var fo="query",ho="mutation",po="infinitequery";function yo(e){return e.type===fo}function go(e){return e.type===ho}function ss(e){return e.type===po}function xe(e,...t){return Object.assign(e,...t)}var Kt=Symbol();function Gt(e){const t=Q.useRef(e),r=Q.useMemo(()=>Er(t.current,e),[e]);return Q.useEffect(()=>{t.current!==r&&(t.current=r)},[r]),r}function Me(e){const t=Q.useRef(e);return Q.useEffect(()=>{Ue(t.current,e)||(t.current=e)},[e]),Ue(t.current,e)?t.current:e}var mo=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bo=mo(),vo=()=>typeof navigator<"u"&&navigator.product==="ReactNative",So=vo(),_o=()=>bo||So?Q.useLayoutEffect:Q.useEffect,wo=_o(),un=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:e.data===void 0,status:Hn.pending}:e;function Yt(e,...t){const r={};return t.forEach(n=>{r[n]=e[n]}),r}var Xt=["data","status","isLoading","isSuccess","isError","error"];function Eo({api:e,moduleOptions:{batch:t,hooks:{useDispatch:r,useSelector:n,useStore:s},unstable__sideEffectsInRender:i,createSelector:o},serializeQueryArgs:v,context:E}){const b=i?l=>l():Q.useEffect,_=l=>{var p,M;return(M=(p=l.current)==null?void 0:p.unsubscribe)==null?void 0:M.call(p)},I=E.endpointDefinitions;return{buildQueryHooks:y,buildInfiniteQueryHooks:u,buildMutationHook:a,usePrefetch:m};function A(l,p,M){if(p!=null&&p.endpointName&&l.isUninitialized){const{endpointName:C}=p,T=I[C];M!==ie&&v({queryArgs:p.originalArgs,endpointDefinition:T,endpointName:C})===v({queryArgs:M,endpointDefinition:T,endpointName:C})&&(p=void 0)}let h=l.isSuccess?l.data:p==null?void 0:p.data;h===void 0&&(h=l.data);const f=h!==void 0,c=l.isLoading,d=(!p||p.isLoading||p.isUninitialized)&&!f&&c,S=l.isSuccess||f&&(c&&!(p!=null&&p.isError)||l.isUninitialized);return{...l,data:h,currentData:l.data,isFetching:c,isLoading:d,isSuccess:S}}function P(l,p,M){if(p!=null&&p.endpointName&&l.isUninitialized){const{endpointName:C}=p,T=I[C];M!==ie&&v({queryArgs:p.originalArgs,endpointDefinition:T,endpointName:C})===v({queryArgs:M,endpointDefinition:T,endpointName:C})&&(p=void 0)}let h=l.isSuccess?l.data:p==null?void 0:p.data;h===void 0&&(h=l.data);const f=h!==void 0,c=l.isLoading,d=(!p||p.isLoading||p.isUninitialized)&&!f&&c,S=l.isSuccess||c&&f;return{...l,data:h,currentData:l.data,isFetching:c,isLoading:d,isSuccess:S}}function m(l,p){const M=r(),h=Me(p);return Q.useCallback((f,c)=>M(e.util.prefetch(l,f,{...h,...c})),[l,M,h])}function R(l,p,{refetchOnReconnect:M,refetchOnFocus:h,refetchOnMountOrArgChange:f,skip:c=!1,pollingInterval:d=0,skipPollingIfUnfocused:S=!1,...C}={}){const{initiate:T}=e.endpoints[l],x=r(),N=Q.useRef(void 0);if(!N.current){const B=x(e.internalActions.internal_getRTKQSubscriptions());N.current=B}const D=Gt(c?ie:p),k=Me({refetchOnReconnect:M,refetchOnFocus:h,pollingInterval:d,skipPollingIfUnfocused:S}),q=C.initialPageParam,F=Me(q),H=C.refetchCachedPages,W=Me(H),$=Q.useRef(void 0);let{queryCacheKey:K,requestId:V}=$.current||{},U=!1;K&&V&&(U=N.current.isRequestSubscribed(K,V));const L=!U&&$.current!==void 0;return b(()=>{L&&($.current=void 0)},[L]),b(()=>{var z;const B=$.current;if(D===ie){B==null||B.unsubscribe(),$.current=void 0;return}const Z=(z=$.current)==null?void 0:z.subscriptionOptions;if(!B||B.arg!==D){B==null||B.unsubscribe();const j=x(T(D,{subscriptionOptions:k,forceRefetch:f,...ss(I[l])?{initialPageParam:F,refetchCachedPages:W}:{}}));$.current=j}else k!==Z&&B.updateSubscriptionOptions(k)},[x,T,f,D,k,L,F,W,l]),[$,x,T,k]}function g(l,p){return(h,{skip:f=!1,selectFromResult:c}={})=>{const{select:d}=e.endpoints[l],S=Gt(f?ie:h),C=Q.useRef(void 0),T=Q.useMemo(()=>o([d(S),(q,F)=>F,q=>S],p,{memoizeOptions:{resultEqualityCheck:Ue}}),[d,S]),x=Q.useMemo(()=>c?o([T],c,{devModeChecks:{identityFunctionCheck:"never"}}):T,[T,c]),N=n(q=>x(q,C.current),Ue),D=s(),k=T(D.getState(),C.current);return wo(()=>{C.current=k},[k]),N}}function w(l){Q.useEffect(()=>()=>{_(l),l.current=void 0},[l])}function O(l){if(!l.current)throw new Error(X(38));return l.current.refetch()}function y(l){const p=(f,c={})=>{const[d]=R(l,f,c);return w(d),Q.useMemo(()=>({refetch:()=>O(d)}),[d])},M=({refetchOnReconnect:f,refetchOnFocus:c,pollingInterval:d=0,skipPollingIfUnfocused:S=!1}={})=>{const{initiate:C}=e.endpoints[l],T=r(),[x,N]=Q.useState(Kt),D=Q.useRef(void 0),k=Me({refetchOnReconnect:f,refetchOnFocus:c,pollingInterval:d,skipPollingIfUnfocused:S});b(()=>{var $,K;const W=($=D.current)==null?void 0:$.subscriptionOptions;k!==W&&((K=D.current)==null||K.updateSubscriptionOptions(k))},[k]);const q=Q.useRef(k);b(()=>{q.current=k},[k]);const F=Q.useCallback(function(W,$=!1){let K;return t(()=>{_(D),D.current=K=T(C(W,{subscriptionOptions:q.current,forceRefetch:!$})),N(W)}),K},[T,C]),H=Q.useCallback(()=>{var W,$;(W=D.current)!=null&&W.queryCacheKey&&T(e.internalActions.removeQueryResult({queryCacheKey:($=D.current)==null?void 0:$.queryCacheKey}))},[T]);return Q.useEffect(()=>()=>{_(D)},[]),Q.useEffect(()=>{x!==Kt&&!D.current&&F(x,!0)},[x,F]),Q.useMemo(()=>[F,x,{reset:H}],[F,x,H])},h=g(l,A);return{useQueryState:h,useQuerySubscription:p,useLazyQuerySubscription:M,useLazyQuery(f){const[c,d,{reset:S}]=M(f),C=h(d,{...f,skip:d===Kt}),T=Q.useMemo(()=>({lastArg:d}),[d]);return Q.useMemo(()=>[c,{...C,reset:S},T],[c,C,S,T])},useQuery(f,c){const d=p(f,c),S=h(f,{selectFromResult:f===ie||c!=null&&c.skip?void 0:un,...c}),C=Yt(S,...Xt);return Q.useDebugValue(C),Q.useMemo(()=>({...S,...d}),[S,d])}}}function u(l){const p=(h,f={})=>{const[c,d,S,C]=R(l,h,f),T=Q.useRef(C);b(()=>{T.current=C},[C]);const x=f.refetchCachedPages,N=Me(x),D=Q.useCallback(function(F,H){let W;return t(()=>{_(c),c.current=W=d(S(F,{subscriptionOptions:T.current,direction:H}))}),W},[c,d,S]);w(c);const k=Gt(f.skip?ie:h),q=Q.useCallback(F=>{if(!c.current)throw new Error(X(38));const H={refetchCachedPages:(F==null?void 0:F.refetchCachedPages)??N};return c.current.refetch(H)},[c,N]);return Q.useMemo(()=>({trigger:D,refetch:q,fetchNextPage:()=>D(k,"forward"),fetchPreviousPage:()=>D(k,"backward")}),[q,D,k])},M=g(l,P);return{useInfiniteQueryState:M,useInfiniteQuerySubscription:p,useInfiniteQuery(h,f){const{refetch:c,fetchNextPage:d,fetchPreviousPage:S}=p(h,f),C=M(h,{selectFromResult:h===ie||f!=null&&f.skip?void 0:un,...f}),T=Yt(C,...Xt,"hasNextPage","hasPreviousPage");return Q.useDebugValue(T),Q.useMemo(()=>({...C,fetchNextPage:d,fetchPreviousPage:S,refetch:c}),[C,d,S,c])}}}function a(l){return({selectFromResult:p,fixedCacheKey:M}={})=>{const{select:h,initiate:f}=e.endpoints[l],c=r(),[d,S]=Q.useState();Q.useEffect(()=>()=>{d!=null&&d.arg.fixedCacheKey||d==null||d.reset()},[d]);const C=Q.useCallback(function(W){const $=c(f(W,{fixedCacheKey:M}));return S($),$},[c,f,M]),{requestId:T}=d||{},x=Q.useMemo(()=>h({fixedCacheKey:M,requestId:d==null?void 0:d.requestId}),[M,d,h]),N=Q.useMemo(()=>p?o([x],p):x,[p,x]),D=n(N,Ue),k=M==null?d==null?void 0:d.arg.originalArgs:void 0,q=Q.useCallback(()=>{t(()=>{d&&S(void 0),M&&c(e.internalActions.removeMutationResult({requestId:T,fixedCacheKey:M}))})},[c,M,d,T]),F=Yt(D,...Xt,"endpointName");Q.useDebugValue(F);const H=Q.useMemo(()=>({...D,originalArgs:k,reset:q}),[D,k,q]);return Q.useMemo(()=>[C,H],[C,H])}}}var Po=Symbol(),Co=({batch:e=Ks,hooks:t={useDispatch:Vs,useSelector:Bs,useStore:wn},createSelector:r=yn,unstable__sideEffectsInRender:n=!1,...s}={})=>({name:Po,init(i,{serializeQueryArgs:o},v){const E=i,{buildQueryHooks:b,buildInfiniteQueryHooks:_,buildMutationHook:I,usePrefetch:A}=Eo({api:i,moduleOptions:{batch:e,hooks:t,unstable__sideEffectsInRender:n,createSelector:r},serializeQueryArgs:o,context:v});return xe(E,{usePrefetch:A}),xe(v,{batch:e}),{injectEndpoint(P,m){if(yo(m)){const{useQuery:R,useLazyQuery:g,useLazyQuerySubscription:w,useQueryState:O,useQuerySubscription:y}=b(P);xe(E.endpoints[P],{useQuery:R,useLazyQuery:g,useLazyQuerySubscription:w,useQueryState:O,useQuerySubscription:y}),i[`use${dt(P)}Query`]=R,i[`useLazy${dt(P)}Query`]=g}if(go(m)){const R=I(P);xe(E.endpoints[P],{useMutation:R}),i[`use${dt(P)}Mutation`]=R}else if(ss(m)){const{useInfiniteQuery:R,useInfiniteQuerySubscription:g,useInfiniteQueryState:w}=_(P);xe(E.endpoints[P],{useInfiniteQuery:R,useInfiniteQuerySubscription:g,useInfiniteQueryState:w}),i[`use${dt(P)}InfiniteQuery`]=R}}}}}),Ko=rs(ns(),Co());const Ro={},ln=e=>{let t;const r=new Set,n=(_,I)=>{const A=typeof _=="function"?_(t):_;if(!Object.is(A,t)){const P=t;t=I??(typeof A!="object"||A===null)?A:Object.assign({},t,A),r.forEach(m=>m(t,P))}},s=()=>t,E={setState:n,getState:s,getInitialState:()=>b,subscribe:_=>(r.add(_),()=>r.delete(_)),destroy:()=>{(Ro?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},b=t=e(n,s,E);return E},Mo=e=>e?ln(e):ln,{useDebugValue:Io}=Ne,{useSyncExternalStoreWithSelector:Ao}=_s,Oo=e=>e;function To(e,t=Oo,r){const n=Ao(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return Io(n),n}const fn=(e,t)=>{const r=Mo(e),n=(s,i=t)=>To(r,s,i);return Object.assign(n,r),n},Go=(e,t)=>e?fn(e,t):fn;function Yo(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,s]of e)if(!Object.is(s,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(t,n)||!Object.is(e[n],t[n]))return!1;return!0}const dn=e=>{let t;const r=new Set,n=(b,_)=>{const I=typeof b=="function"?b(t):b;if(!Object.is(I,t)){const A=t;t=_??(typeof I!="object"||I===null)?I:Object.assign({},t,I),r.forEach(P=>P(t,A))}},s=()=>t,v={setState:n,getState:s,getInitialState:()=>E,subscribe:b=>(r.add(b),()=>r.delete(b))},E=t=e(n,s,v);return v},ko=(e=>e?dn(e):dn),Qo=e=>e;function Do(e,t=Qo){const r=Ne.useSyncExternalStore(e.subscribe,Ne.useCallback(()=>t(e.getState()),[e,t]),Ne.useCallback(()=>t(e.getInitialState()),[e,t]));return Ne.useDebugValue(r),r}const hn=e=>{const t=ko(e),r=n=>Do(t,n);return Object.assign(r,t),r},Xo=(e=>e?hn(e):hn);export{jo as P,Fo as Q,Ce as a,An as b,Go as c,Ue as d,J as e,Ho as f,Vo as g,gi as h,qo as i,Xe as j,zo as k,Ko as l,Bo as m,ue as n,Wo as o,Qe as p,Vs as q,Bs as r,Yo as s,Lo as t,To as u,Uo as v,Xo as w,$o as x};
@@ -0,0 +1 @@
1
+ import{b5 as U,c2 as z,r,j as e,b4 as A,b3 as O,ce as Q,c7 as $}from"./vendor-DHkYh85p.js";import{j as F,k as I}from"./state-B-4sS1xO.js";import{b as G,S as R}from"./strategy-dialog-BvzomTaF.js";import{P as H}from"./page-hero-CQWo1Mm_.js";import{u as K,s as _,c0 as J,c1 as V,c2 as W,B as d,C as M,I as X,a as Y,U as Z,c as x}from"./index-BHTUu_4M.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function ee(a){return a.trim().toLowerCase()}function xe(){const a=K(),u=U(),B=F(),[j,w]=z(),[E,c]=r.useState(!1),[T,o]=r.useState(null),[m,D]=r.useState(""),L=_(a.selectedUserIds);r.useEffect(()=>{j.get("create")==="1"&&(o(null),c(!0),w(s=>{const t=new URLSearchParams(s);return t.delete("create"),t},{replace:!0}))},[j,w]);const v=async()=>{await B.invalidateQueries({queryKey:["strategy-detail"]}),await a.refresh()},N=I({mutationFn:async({input:s,strategyId:t})=>t?(await J(t,s)).strategy:(await V(s)).strategy,onSuccess:async()=>{await v()}}),p=I({mutationFn:async s=>W(s),onSuccess:async()=>{await v()}}),b=r.useMemo(()=>new Map(a.snapshot.goals.map(s=>[s.id,s])),[a.snapshot.goals]),h=r.useMemo(()=>new Map(a.snapshot.dashboard.projects.map(s=>[s.id,s])),[a.snapshot.dashboard.projects]),f=r.useMemo(()=>new Map(a.snapshot.tasks.map(s=>[s.id,s])),[a.snapshot.tasks]),S=r.useMemo(()=>{const s=ee(m);return s?a.snapshot.strategies.filter(t=>{var k,y,C;const g=t.targetGoalIds.map(l=>{var n;return((n=b.get(l))==null?void 0:n.title)??""}).join(" "),i=t.targetProjectIds.map(l=>{var n;return((n=h.get(l))==null?void 0:n.title)??""}).join(" "),q=t.graph.nodes.map(l=>{var n,P;return l.entityType==="project"?((n=h.get(l.entityId))==null?void 0:n.title)??"":((P=f.get(l.entityId))==null?void 0:P.title)??""}).join(" ");return[t.title,t.overview,t.endStateDescription,t.status,((k=t.user)==null?void 0:k.displayName)??"",((y=t.user)==null?void 0:y.handle)??"",((C=t.user)==null?void 0:C.kind)??"",g,i,q].join(" ").toLowerCase().includes(s)}):a.snapshot.strategies},[b,h,m,a.snapshot.strategies,f]);return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(H,{title:"Strategies",titleText:"Strategies",description:"Strategies connect human and bot work into a directed plan, with explicit end goals, ownership, and live alignment metrics.",badge:`${a.snapshot.strategies.length} strategies`,actions:e.jsxs(d,{onClick:()=>{o(null),c(!0)},children:[e.jsx(A,{className:"size-4"}),"New strategy"]})}),e.jsxs(M,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(O,{className:"size-4 text-white/38"}),e.jsx(X,{value:m,onChange:s=>D(s.target.value),placeholder:"Search strategy title, target, graph node, human, or bot"})]}),e.jsx("div",{className:"text-sm text-white/56",children:"Search includes owners, target goals/projects, and graph nodes so cross-user plans stay discoverable."})]}),S.length===0?e.jsx(Y,{eyebrow:"Strategies",title:"No strategies in this scope",description:"Create a strategy to connect projects and tasks into a non-looping execution plan across human and bot actors.",action:e.jsx(d,{onClick:()=>{o(null),c(!0)},children:"Create strategy"})}):e.jsx("div",{className:"grid gap-4",children:S.map(s=>{const t=s.graph.nodes.filter(i=>s.metrics.activeNodeIds.includes(i.id)),g=G(s.metrics);return e.jsxs(M,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("button",{type:"button",className:"text-left",onClick:()=>u(`/strategies/${s.id}`),children:[e.jsx("div",{className:"font-display text-2xl text-white",children:s.title}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:s.overview||s.endStateDescription})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Z,{user:s.user}),e.jsx(x,{className:s.isLocked?"bg-amber-500/12 text-amber-200":"bg-emerald-500/12 text-emerald-200",children:s.isLocked?"Contract locked":"Editable draft"}),e.jsx(x,{className:"bg-white/[0.08] text-white/78",children:s.status}),e.jsxs(x,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.metrics.alignmentScore,"% aligned"]})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Graph progress"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.startedNodeCount,"/",s.metrics.totalNodeCount]}),e.jsxs("div",{className:"text-xs leading-5 text-white/46",children:[s.metrics.completedNodeCount," completed"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Ready branches"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:s.metrics.readyNodeCount}),e.jsx("div",{className:"text-xs leading-5 text-white/46",children:"Nodes whose prerequisites are already satisfied."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"End targets"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.completedTargetCount,"/",s.metrics.totalTargetCount||0]}),e.jsxs("div",{className:"text-xs leading-5 text-white/46",children:[s.metrics.targetProgressScore,"% target progress"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Sequencing"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[s.metrics.sequencingScore,"%"]})]})]}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(16rem,0.8fr)]",children:[e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Active next nodes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.length===0?e.jsx("div",{className:"text-sm text-white/52",children:"No currently open branch."}):t.map(i=>e.jsx(x,{className:"bg-white/[0.08] text-white/80",children:i.title},i.id))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Alignment breakdown"}),e.jsx("div",{className:"mt-3 grid gap-2 text-sm text-white/58",children:g.map(i=>e.jsxs("div",{children:[i.label," ",i.value,"%"]},i.id))})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-end justify-end gap-2",children:[s.isLocked?null:e.jsxs(d,{variant:"secondary",onClick:()=>{o(s),c(!0)},children:[e.jsx(Q,{className:"size-4"}),"Edit"]}),e.jsxs(d,{variant:"secondary",pending:p.isPending&&p.variables===s.id,pendingLabel:"Deleting strategy",onClick:()=>{window.confirm(`Delete strategy "${s.title}"?`)&&p.mutateAsync(s.id)},children:[e.jsx($,{className:"size-4"}),"Delete"]}),e.jsx(d,{onClick:()=>u(`/strategies/${s.id}`),children:"Open strategy"})]})]})]},s.id)})}),e.jsx(R,{open:E,pending:N.isPending,editingStrategy:T,goals:a.snapshot.dashboard.goals,projects:a.snapshot.dashboard.projects,tasks:a.snapshot.tasks,habits:a.snapshot.habits,strategies:a.snapshot.strategies,users:a.snapshot.users,defaultUserId:L,onOpenChange:c,onSubmit:async(s,t)=>{await N.mutateAsync({input:s,strategyId:t})}})]})}export{xe as StrategiesPage};