thursday-agent 0.21.0 → 0.22.0

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 (397) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  5. package/.next/server/app/_global-error.html +1 -1
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +12 -12
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +12 -12
  15. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +11 -11
  16. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  17. package/.next/server/app/api/artifact/route.js +9 -8
  18. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  19. package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
  20. package/.next/server/app/api/bot/memory/route.js +9 -8
  21. package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
  22. package/.next/server/app/api/bot/route.js +9 -8
  23. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  24. package/.next/server/app/api/bot/thread/[id]/route.js +7 -6
  25. package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
  26. package/.next/server/app/api/bot/thread/file/route.js +17 -16
  27. package/.next/server/app/api/bot/thread/file/route.js.nft.json +1 -1
  28. package/.next/server/app/api/bot/thread/route.js +8 -7
  29. package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
  30. package/.next/server/app/api/config/route.js +5 -4
  31. package/.next/server/app/api/config/route.js.nft.json +1 -1
  32. package/.next/server/app/api/events/route.js.nft.json +1 -1
  33. package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
  34. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  35. package/.next/server/app/api/llm-model/automatic/route.js +8 -7
  36. package/.next/server/app/api/llm-model/automatic/route.js.nft.json +1 -1
  37. package/.next/server/app/api/llm-model/catalog/[provider]/route.js +8 -7
  38. package/.next/server/app/api/llm-model/catalog/[provider]/route.js.nft.json +1 -1
  39. package/.next/server/app/api/llm-model/credits/[provider]/route.js +8 -7
  40. package/.next/server/app/api/llm-model/credits/[provider]/route.js.nft.json +1 -1
  41. package/.next/server/app/api/llm-model/route.js +9 -8
  42. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  43. package/.next/server/app/api/llm-model/subscription/route.js +9 -8
  44. package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
  45. package/.next/server/app/api/mcp/[name]/route.js +6 -5
  46. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  47. package/.next/server/app/api/mcp/oauth/callback/route.js +6 -5
  48. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  49. package/.next/server/app/api/mcp/route.js +6 -5
  50. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  51. package/.next/server/app/api/mcp/tools/route.js +6 -5
  52. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  53. package/.next/server/app/api/memory/edit/route.js +13 -12
  54. package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
  55. package/.next/server/app/api/memory/route.js +6 -5
  56. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  57. package/.next/server/app/api/reach/route.js +19 -18
  58. package/.next/server/app/api/reach/route.js.nft.json +1 -1
  59. package/.next/server/app/api/routine/route.js +9 -8
  60. package/.next/server/app/api/routine/route.js.nft.json +1 -1
  61. package/.next/server/app/api/running/route.js.nft.json +1 -1
  62. package/.next/server/app/api/signins/route.js +5 -4
  63. package/.next/server/app/api/signins/route.js.nft.json +1 -1
  64. package/.next/server/app/api/skills/[source]/[name]/route.js +9 -8
  65. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  66. package/.next/server/app/api/skills/route.js +9 -8
  67. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  68. package/.next/server/app/api/thursday/call/end/route.js +6 -5
  69. package/.next/server/app/api/thursday/call/end/route.js.nft.json +1 -1
  70. package/.next/server/app/api/thursday/call/plan/route.js +15 -14
  71. package/.next/server/app/api/thursday/call/plan/route.js.nft.json +1 -1
  72. package/.next/server/app/api/thursday/call/route.js +7 -6
  73. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  74. package/.next/server/app/api/thursday/settings/route.js +6 -5
  75. package/.next/server/app/api/thursday/settings/route.js.nft.json +1 -1
  76. package/.next/server/app/api/thursday/text/route.js +17 -16
  77. package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
  78. package/.next/server/app/api/thursday/tool-call/route.js +15 -14
  79. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  80. package/.next/server/app/api/workspace/files/route.js +8 -7
  81. package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
  82. package/.next/server/app/api/workspace/route.js +9 -8
  83. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  84. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +11 -11
  85. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  86. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  87. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  88. package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  89. package/.next/server/app/page/react-loadable-manifest.json +15 -1
  90. package/.next/server/app/page/server-reference-manifest.json +63 -63
  91. package/.next/server/app/page.js.nft.json +1 -1
  92. package/.next/server/app/page_client-reference-manifest.js +1 -1
  93. package/.next/server/chunks/[root-of-the-server]__0-5d50l._.js +3 -0
  94. package/.next/server/chunks/[root-of-the-server]__005onk_._.js +3 -0
  95. package/.next/server/chunks/[root-of-the-server]__00dtf7h._.js +3 -0
  96. package/.next/server/chunks/[root-of-the-server]__00f051a._.js +7 -0
  97. package/.next/server/chunks/[root-of-the-server]__019e1fy._.js +2 -2
  98. package/.next/server/chunks/[root-of-the-server]__01jpmcj._.js +1 -1
  99. package/.next/server/chunks/[root-of-the-server]__0340k46._.js +7 -0
  100. package/.next/server/chunks/[root-of-the-server]__03bjojd._.js +1 -1
  101. package/.next/server/chunks/[root-of-the-server]__03vunn6._.js +1 -1
  102. package/.next/server/chunks/[root-of-the-server]__05fq824._.js +3 -0
  103. package/.next/server/chunks/[root-of-the-server]__06kxzw-._.js +1 -1
  104. package/.next/server/chunks/[root-of-the-server]__08922kg._.js +3 -0
  105. package/.next/server/chunks/[root-of-the-server]__0atwstu._.js +1 -1
  106. package/.next/server/chunks/[root-of-the-server]__0btxiu1._.js +3 -0
  107. package/.next/server/chunks/[root-of-the-server]__0d-dfqm._.js +1 -1
  108. package/.next/server/chunks/[root-of-the-server]__0gmxpev._.js +3 -0
  109. package/.next/server/chunks/[root-of-the-server]__0itmdqy._.js +3 -0
  110. package/.next/server/chunks/[root-of-the-server]__0m0qglo._.js +5 -0
  111. package/.next/server/chunks/[root-of-the-server]__0mh1tgg._.js +1 -1
  112. package/.next/server/chunks/[root-of-the-server]__0ncs9uu._.js +1 -1
  113. package/.next/server/chunks/[root-of-the-server]__0ndw2yj._.js +1 -1
  114. package/.next/server/chunks/[root-of-the-server]__0sfx6id._.js +3 -0
  115. package/.next/server/chunks/[root-of-the-server]__0xn7a8p._.js +3 -0
  116. package/.next/server/chunks/[root-of-the-server]__13hng6h._.js +1 -1
  117. package/.next/server/chunks/[root-of-the-server]__1478lu3._.js +1 -1
  118. package/.next/server/chunks/[root-of-the-server]__16y0k92._.js +3 -0
  119. package/.next/server/chunks/[root-of-the-server]__17kdjf6._.js +1 -1
  120. package/.next/server/chunks/[root-of-the-server]__17m7ag9._.js +1 -1
  121. package/.next/server/chunks/[root-of-the-server]__19aqyg-._.js +1 -1
  122. package/.next/server/chunks/[root-of-the-server]__1_04mcf._.js +1 -1
  123. package/.next/server/chunks/[root-of-the-server]__1a0xgyh._.js +1 -1
  124. package/.next/server/chunks/[root-of-the-server]__1ceammd._.js +1 -1
  125. package/.next/server/chunks/{[root-of-the-server]__01y-8gg._.js → [root-of-the-server]__1clkgmj._.js} +3 -3
  126. package/.next/server/chunks/[root-of-the-server]__1dth047._.js +1 -1
  127. package/.next/server/chunks/[root-of-the-server]__1g08s7l._.js +5 -0
  128. package/.next/server/chunks/[root-of-the-server]__1huywqp._.js +1 -1
  129. package/.next/server/chunks/[root-of-the-server]__1ij4h2a._.js +3 -0
  130. package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
  131. package/.next/server/chunks/[root-of-the-server]__1o7z93z._.js +1 -1
  132. package/.next/server/chunks/[root-of-the-server]__1onvx8x._.js +1 -1
  133. package/.next/server/chunks/[root-of-the-server]__1q1s4ls._.js +3 -0
  134. package/.next/server/chunks/[root-of-the-server]__1qa67zs._.js +3 -0
  135. package/.next/server/chunks/[root-of-the-server]__1t-mfa4._.js +5 -0
  136. package/.next/server/chunks/[root-of-the-server]__20ofm9t._.js +3 -0
  137. package/.next/server/chunks/_0-qt5if._.js +1 -1
  138. package/.next/server/chunks/_02mn8d7._.js +1 -1
  139. package/.next/server/chunks/_03p6r2-._.js +1 -1
  140. package/.next/server/chunks/_0483t_f._.js +1 -1
  141. package/.next/server/chunks/_06b5b4-._.js +1 -1
  142. package/.next/server/chunks/_06u9yo-._.js +1 -1
  143. package/.next/server/chunks/_07pkeds._.js +1 -1
  144. package/.next/server/chunks/_08354bn._.js +21 -19
  145. package/.next/server/chunks/_09rtyfn._.js +93 -91
  146. package/.next/server/chunks/_0cq69mm._.js +1 -1
  147. package/.next/server/chunks/_0fau3ya._.js +1 -1
  148. package/.next/server/chunks/_0ggqpiz._.js +1 -1
  149. package/.next/server/chunks/_0gxz_1b._.js +1 -1
  150. package/.next/server/chunks/_0lcthk8._.js +1 -1
  151. package/.next/server/chunks/_0p27in2._.js +1 -1
  152. package/.next/server/chunks/_0ue8nq-._.js +1 -1
  153. package/.next/server/chunks/_0uv1gs1._.js +1 -1
  154. package/.next/server/chunks/_0wyh244._.js +21 -19
  155. package/.next/server/chunks/_0zwjr-g._.js +1 -1
  156. package/.next/server/chunks/_1-wp0r0._.js +1 -1
  157. package/.next/server/chunks/_11y8h29._.js +1 -1
  158. package/.next/server/chunks/_14xuq46._.js +93 -91
  159. package/.next/server/chunks/_17fjc-7._.js +5 -0
  160. package/.next/server/chunks/_1823_7a._.js +4 -4
  161. package/.next/server/chunks/_18z965x._.js +1 -1
  162. package/.next/server/chunks/_1ac33qw._.js +1 -1
  163. package/.next/server/chunks/_1cw6-rv._.js +3 -0
  164. package/.next/server/chunks/_1dcbwn-._.js +1 -1
  165. package/.next/server/chunks/_1evvnbp._.js +18 -0
  166. package/.next/server/chunks/_1gn2r2q._.js +15 -15
  167. package/.next/server/chunks/{_00lwnht._.js → _1hw1ujv._.js} +2 -2
  168. package/.next/server/chunks/_1icgbi8._.js +18 -0
  169. package/.next/server/chunks/{_0txk_9z._.js → _1jtvbp9._.js} +2 -2
  170. package/.next/server/chunks/_1ko5shz._.js +1 -1
  171. package/.next/server/chunks/_1ksyu6r._.js +1 -1
  172. package/.next/server/chunks/{_1ntwp1s._.js → _1mgzs18._.js} +1 -1
  173. package/.next/server/chunks/_1q42187._.js +4 -4
  174. package/.next/server/chunks/_1q6e56i._.js +15 -15
  175. package/.next/server/chunks/_1t43w6q._.js +1 -1
  176. package/.next/server/chunks/_1t8fv7b._.js +18 -0
  177. package/.next/server/chunks/_1tjwvoz._.js +1 -1
  178. package/.next/server/chunks/_1ufbxe1._.js +1 -1
  179. package/.next/server/chunks/_1uu4wjr._.js +1 -1
  180. package/.next/server/chunks/{_0q6gng9._.js → _1v4id5q._.js} +2 -2
  181. package/.next/server/chunks/{_07vwkt7._.js → _1v5qol2._.js} +2 -2
  182. package/.next/server/chunks/_1wg0cqo._.js +1 -1
  183. package/.next/server/chunks/_1wgae1c._.js +3 -0
  184. package/.next/server/chunks/_1x2xiyw._.js +1 -1
  185. package/.next/server/chunks/_1xps4ob._.js +3 -0
  186. package/.next/server/chunks/_201k0ah._.js +1 -1
  187. package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
  188. package/.next/server/chunks/features_bot_08z387_._.js +4 -4
  189. package/.next/server/chunks/node_modules_zod_v4_01bha1c._.js +60 -0
  190. package/.next/server/chunks/node_modules_zod_v4_0b99z6a._.js +60 -0
  191. package/.next/server/chunks/node_modules_zod_v4_0r3ybe4._.js +60 -0
  192. package/.next/server/chunks/node_modules_zod_v4_1t1yj1u._.js +60 -0
  193. package/.next/server/chunks/node_modules_zod_v4_1zz6lo1._.js +60 -0
  194. package/.next/server/chunks/ssr/[root-of-the-server]__0eloa6y._.js +5 -5
  195. package/.next/server/chunks/ssr/[root-of-the-server]__0jjj49d._.js +3 -0
  196. package/.next/server/chunks/ssr/[root-of-the-server]__0yyxgt2._.js +3 -0
  197. package/.next/server/chunks/ssr/[root-of-the-server]__1867koj._.js +1 -1
  198. package/.next/server/chunks/ssr/[root-of-the-server]__203utm3._.js +3 -0
  199. package/.next/server/chunks/ssr/[root-of-the-server]__20t_4l2._.js +1 -1
  200. package/.next/server/chunks/ssr/_0-y08rv._.js +3 -0
  201. package/.next/server/chunks/ssr/_00buy3i._.js +162 -0
  202. package/.next/server/chunks/ssr/_014_wjp._.js +3 -0
  203. package/.next/server/chunks/ssr/_07m4ii5._.js +3 -0
  204. package/.next/server/chunks/ssr/_09a6bpd._.js +1 -1
  205. package/.next/server/chunks/ssr/{_1569s5b._.js → _0gn_i4s._.js} +2 -2
  206. package/.next/server/chunks/ssr/_0iuvjnw._.js +3 -0
  207. package/.next/server/chunks/ssr/_0j6rtjm._.js +6 -0
  208. package/.next/server/chunks/ssr/{_19u7y57._.js → _0ntol64._.js} +2 -2
  209. package/.next/server/chunks/ssr/_0ogkeu-._.js +3 -0
  210. package/.next/server/chunks/ssr/{_1h0hk_h._.js → _0t_e9rd._.js} +2 -2
  211. package/.next/server/chunks/ssr/{_1-zhg63._.js → _0u43zjx._.js} +2 -2
  212. package/.next/server/chunks/ssr/_0ux4i2m._.js +1 -1
  213. package/.next/server/chunks/ssr/{_1iix_k_._.js → _0xurp8n._.js} +2 -2
  214. package/.next/server/chunks/ssr/_10sc7ab._.js +3 -0
  215. package/.next/server/chunks/ssr/_12hdw8x._.js +22 -20
  216. package/.next/server/chunks/ssr/{_02ybodf._.js → _14nwim3._.js} +2 -2
  217. package/.next/server/chunks/ssr/{_2024r5e._.js → _16o81mn._.js} +2 -2
  218. package/.next/server/chunks/ssr/_1bfrntd._.js +2 -2
  219. package/.next/server/chunks/ssr/_1crszf7._.js +1 -1
  220. package/.next/server/chunks/ssr/_1e01b-_._.js +3 -0
  221. package/.next/server/chunks/ssr/{_0y0qnim._.js → _1gz4ov7._.js} +3 -3
  222. package/.next/server/chunks/ssr/_1neoj22._.js +2 -1
  223. package/.next/server/chunks/ssr/{_04ik9s8._.js → _1nfv27b._.js} +2 -2
  224. package/.next/server/chunks/ssr/_1nwey7a._.js +3 -0
  225. package/.next/server/chunks/ssr/_1soynbw._.js +2 -2
  226. package/.next/server/chunks/ssr/features_ai_components_model-picker_tsx_0ucb1y9._.js +1 -1
  227. package/.next/server/chunks/ssr/features_bot_06n7hmd._.js +3 -0
  228. package/.next/server/chunks/ssr/features_bot_0tb4ui-._.js +1 -1
  229. package/.next/server/chunks/ssr/{_07nmtxo._.js → features_bot_1knyan7._.js} +2 -2
  230. package/.next/server/chunks/ssr/{features_config_1l7bn84._.js → features_config_09wq1s9._.js} +3 -3
  231. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  232. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  233. package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
  234. package/.next/server/chunks/ssr/features_thursday_0cf9y0b._.js +3 -0
  235. package/.next/server/chunks/ssr/features_thursday_components_ascii-orb_tsx_1yug8cw._.js +3 -0
  236. package/.next/server/chunks/ssr/features_thursday_components_here-globe_tsx_055duhw._.js +3 -0
  237. package/.next/server/chunks/ssr/{node_modules_1bj1zfp._.js → node_modules_01fukqn._.js} +1 -1
  238. package/.next/server/chunks/ssr/{node_modules_1r-1n7c._.js → node_modules_01v7ybp._.js} +1 -1
  239. package/.next/server/chunks/ssr/{node_modules_0f0lohc._.js → node_modules_0536cp2._.js} +1 -1
  240. package/.next/server/chunks/ssr/{node_modules_13iz-t6._.js → node_modules_056xgci._.js} +1 -1
  241. package/.next/server/chunks/ssr/{node_modules_1rnfv0r._.js → node_modules_06n6ruk._.js} +1 -1
  242. package/.next/server/chunks/ssr/{node_modules_1d5j3h5._.js → node_modules_08m1gvh._.js} +1 -1
  243. package/.next/server/chunks/ssr/{node_modules_1_j-et6._.js → node_modules_0_zk6yd._.js} +1 -1
  244. package/.next/server/chunks/ssr/{node_modules_0c1grmu._.js → node_modules_0cpegwf._.js} +1 -1
  245. package/.next/server/chunks/ssr/{node_modules_107249-._.js → node_modules_0e398ts._.js} +1 -1
  246. package/.next/server/chunks/ssr/{node_modules_0ja2eo8._.js → node_modules_0ie8g6a._.js} +2 -2
  247. package/.next/server/chunks/ssr/{node_modules_074pspl._.js → node_modules_0ksqeyy._.js} +1 -1
  248. package/.next/server/chunks/ssr/{node_modules_0ydatn4._.js → node_modules_0m-dnm-._.js} +1 -1
  249. package/.next/server/chunks/ssr/{node_modules_0eoqrzb._.js → node_modules_0m2oth3._.js} +1 -1
  250. package/.next/server/chunks/ssr/{node_modules_1b6sm1g._.js → node_modules_0yn2z6s._.js} +1 -1
  251. package/.next/server/chunks/ssr/{node_modules_0uuobx8._.js → node_modules_12hh0bx._.js} +1 -1
  252. package/.next/server/chunks/ssr/{node_modules_0q-53p6._.js → node_modules_13dwal5._.js} +1 -1
  253. package/.next/server/chunks/ssr/{node_modules_0efmaot._.js → node_modules_16tn8xu._.js} +1 -1
  254. package/.next/server/chunks/ssr/{node_modules_0x4geuk._.js → node_modules_19r9vjv._.js} +1 -1
  255. package/.next/server/chunks/ssr/{node_modules_0k9lm-f._.js → node_modules_1bvw77g._.js} +1 -1
  256. package/.next/server/chunks/ssr/{node_modules_1dgdpcc._.js → node_modules_1ctm_ju._.js} +1 -1
  257. package/.next/server/chunks/ssr/{node_modules_1oo6jfv._.js → node_modules_1dlue-g._.js} +1 -1
  258. package/.next/server/chunks/ssr/{node_modules_1sbozb5._.js → node_modules_1fqgrh0._.js} +1 -1
  259. package/.next/server/chunks/ssr/{node_modules_17eaxbw._.js → node_modules_1i-g3bz._.js} +1 -1
  260. package/.next/server/chunks/ssr/{node_modules_1b_78mo._.js → node_modules_1jf8aik._.js} +1 -1
  261. package/.next/server/chunks/ssr/{node_modules_0vva828._.js → node_modules_1kfbdfo._.js} +1 -1
  262. package/.next/server/chunks/ssr/{node_modules_0lu90ps._.js → node_modules_1zalmtr._.js} +1 -1
  263. package/.next/server/chunks/ssr/{node_modules_1qgte25._.js → node_modules_1zdz2zf._.js} +1 -1
  264. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0obor-y._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0nj1l8f._.js} +1 -1
  265. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0oip1-o._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_17ok98u._.js} +1 -1
  266. package/.next/server/middleware-build-manifest.js +3 -3
  267. package/.next/server/pages/404.html +1 -1
  268. package/.next/server/pages/500.html +1 -1
  269. package/.next/server/server-reference-manifest.js +1 -1
  270. package/.next/server/server-reference-manifest.json +64 -64
  271. package/.next/static/chunks/01r1uco3ikisc.js +2 -0
  272. package/.next/static/chunks/{33s9l7hkzyylm.js → 052u13mcoxt87.js} +1 -1
  273. package/.next/static/chunks/{023rfhzsxzhh1.js → 05blzta_1i7c2.js} +1 -1
  274. package/.next/static/chunks/09kwsjbmr_z1w.js +1 -0
  275. package/.next/static/chunks/0go5_9zqag7l0.js +1 -0
  276. package/.next/static/chunks/0hpx0--bh7vld.js +1 -0
  277. package/.next/static/chunks/0o0vshni5ny91.js +1 -0
  278. package/.next/static/chunks/0ynv7zu_bguve.js +1 -0
  279. package/.next/static/chunks/0zi59tghmg1lu.js +18 -0
  280. package/.next/static/chunks/1_ftsgxa-sia_.js +1 -0
  281. package/.next/static/chunks/1cg3torc90q5t.js +1 -0
  282. package/.next/static/chunks/{3zhqveam0_kub.js → 1dy5xaxjdsy11.js} +1 -1
  283. package/.next/static/chunks/1qnx1h5c8f93b.js +1 -0
  284. package/.next/static/chunks/1rwn3d9ji5w35.js +1 -0
  285. package/.next/static/chunks/{1tyxz6thgf2w6.js → 1so3f5fi7e5g9.js} +1 -1
  286. package/.next/static/chunks/1ya41wxfmp4s8.js +1 -0
  287. package/.next/static/chunks/27rwkfu7_xvs1.js +4 -0
  288. package/.next/static/chunks/2hueh8masqd91.js +15 -0
  289. package/.next/static/chunks/2jrt_752fqz2f.js +1 -0
  290. package/.next/static/chunks/{3fcnfq383hu-y.js → 2nbj2t9yp8ke9.js} +1 -1
  291. package/.next/static/chunks/2ogme4qydxnaq.js +3 -0
  292. package/.next/static/chunks/2r2tocw2rpvm2.js +1 -0
  293. package/.next/static/chunks/2t4kimg1lt-p7.js +2 -0
  294. package/.next/static/chunks/2w6y71o27my_z.js +1 -0
  295. package/.next/static/chunks/{2-2ts24vi9ete.js → 3146sccz1j76i.js} +1 -1
  296. package/.next/static/chunks/31_am8rtmk_tv.css +1 -0
  297. package/.next/static/chunks/{41iv7b8_3z92h.js → 35ehi-okrfot5.js} +1 -1
  298. package/.next/static/chunks/3866u-edsoyj3.js +1 -0
  299. package/.next/static/chunks/3drvp6w6dqzqg.js +1 -0
  300. package/.next/static/chunks/3qfhjwd9yuijo.js +1 -0
  301. package/.next/static/chunks/{3axovmkkuh1us.js → 3tyacy8fh5_18.js} +2 -2
  302. package/.next/static/chunks/3zv4wiqjl5kex.js +1 -0
  303. package/guide/bots.md +25 -5
  304. package/guide/calls.md +18 -9
  305. package/guide/setup.md +15 -4
  306. package/guide/trouble.md +2 -3
  307. package/package.json +1 -1
  308. package/public/here/NOTICE +43 -0
  309. package/public/here/world.json +1 -0
  310. package/skills/README.md +4 -0
  311. package/skills/artifact/SKILL.md +7 -6
  312. package/skills/artifact/references/motion.md +150 -0
  313. package/skills/artifact/runtime/motion/film.js +866 -0
  314. package/skills/artifact/runtime/motion/fonts/Gaegu-Bold.woff2 +0 -0
  315. package/skills/artifact/runtime/motion/fonts/OFL.txt +92 -0
  316. package/skills/artifact/runtime/motion/kit-core.js +699 -0
  317. package/skills/artifact/runtime/motion/kit-people.js +1305 -0
  318. package/skills/artifact/runtime/motion/kit-places.js +854 -0
  319. package/skills/artifact/runtime/motion/kit-things.js +903 -0
  320. package/skills/artifact/runtime/motion/motion.html +108 -0
  321. package/skills/artifact/runtime/motion/page.mjs +54 -0
  322. package/skills/artifact/runtime/motion/score.js +625 -0
  323. package/skills/artifact/scripts/book-video.mjs +1 -46
  324. package/skills/artifact/scripts/media.mjs +74 -0
  325. package/skills/artifact/scripts/motion.mjs +605 -0
  326. package/skills/artifact/templates/motion/birthday.js +182 -0
  327. package/skills/browser/SKILL.md +4 -1
  328. package/skills/browser/scripts/serve.mjs +26 -3
  329. package/skills/browser/scripts/session.mjs +12 -3
  330. package/.next/server/chunks/[root-of-the-server]__0-fn06g._.js +0 -3
  331. package/.next/server/chunks/[root-of-the-server]__03lc17t._.js +0 -3
  332. package/.next/server/chunks/[root-of-the-server]__06nspyt._.js +0 -3
  333. package/.next/server/chunks/[root-of-the-server]__09c88lb._.js +0 -3
  334. package/.next/server/chunks/[root-of-the-server]__09dxfp5._.js +0 -3
  335. package/.next/server/chunks/[root-of-the-server]__0_0w3ug._.js +0 -3
  336. package/.next/server/chunks/[root-of-the-server]__0ap1nbu._.js +0 -5
  337. package/.next/server/chunks/[root-of-the-server]__0bmtib_._.js +0 -7
  338. package/.next/server/chunks/[root-of-the-server]__0im1m7z._.js +0 -3
  339. package/.next/server/chunks/[root-of-the-server]__0mt72qk._.js +0 -7
  340. package/.next/server/chunks/[root-of-the-server]__0uj9rm-._.js +0 -3
  341. package/.next/server/chunks/[root-of-the-server]__0z5n9xz._.js +0 -5
  342. package/.next/server/chunks/[root-of-the-server]__16e_e0e._.js +0 -5
  343. package/.next/server/chunks/[root-of-the-server]__16gn7zn._.js +0 -3
  344. package/.next/server/chunks/[root-of-the-server]__18k8s-z._.js +0 -3
  345. package/.next/server/chunks/[root-of-the-server]__1aw-1kd._.js +0 -3
  346. package/.next/server/chunks/[root-of-the-server]__1kmnkbk._.js +0 -3
  347. package/.next/server/chunks/[root-of-the-server]__1op8qe5._.js +0 -3
  348. package/.next/server/chunks/[root-of-the-server]__1pkq_1z._.js +0 -3
  349. package/.next/server/chunks/[root-of-the-server]__20w_g71._.js +0 -3
  350. package/.next/server/chunks/_01c32w9._.js +0 -75
  351. package/.next/server/chunks/_02bov6_._.js +0 -75
  352. package/.next/server/chunks/_053bi70._.js +0 -60
  353. package/.next/server/chunks/_08s4vft._.js +0 -75
  354. package/.next/server/chunks/_0fb6dvr._.js +0 -75
  355. package/.next/server/chunks/_0iw19ig._.js +0 -75
  356. package/.next/server/chunks/_0mo_6or._.js +0 -5
  357. package/.next/server/chunks/_0poi1t2._.js +0 -75
  358. package/.next/server/chunks/_1d7og_q._.js +0 -75
  359. package/.next/server/chunks/_1o3fc2d._.js +0 -60
  360. package/.next/server/chunks/_20zp65o._.js +0 -60
  361. package/.next/server/chunks/ssr/[root-of-the-server]__03e9zqg._.js +0 -3
  362. package/.next/server/chunks/ssr/[root-of-the-server]__1hbvuqr._.js +0 -3
  363. package/.next/server/chunks/ssr/[root-of-the-server]__1y8_-v1._.js +0 -3
  364. package/.next/server/chunks/ssr/_00_9573._.js +0 -3
  365. package/.next/server/chunks/ssr/_03vw3u5._.js +0 -3
  366. package/.next/server/chunks/ssr/_0iwsdp7._.js +0 -3
  367. package/.next/server/chunks/ssr/_0llhg-6._.js +0 -3
  368. package/.next/server/chunks/ssr/_0o__2ss._.js +0 -3
  369. package/.next/server/chunks/ssr/_0pbav_w._.js +0 -3
  370. package/.next/server/chunks/ssr/_0yjn4jm._.js +0 -162
  371. package/.next/server/chunks/ssr/_186ifln._.js +0 -3
  372. package/.next/server/chunks/ssr/_1x4lhpf._.js +0 -3
  373. package/.next/server/chunks/ssr/_1xfiate._.js +0 -5
  374. package/.next/server/chunks/ssr/features_bot_1dvvmo3._.js +0 -3
  375. package/.next/server/chunks/ssr/features_thursday_0gbh5j_._.js +0 -3
  376. package/.next/static/chunks/06k2o5zxc3xhv.js +0 -1
  377. package/.next/static/chunks/0_s4z70lx1tgs.js +0 -1
  378. package/.next/static/chunks/0cbitatnyjhz7.js +0 -1
  379. package/.next/static/chunks/0m5-0kx85axzv.js +0 -18
  380. package/.next/static/chunks/0non225e2mzp-.js +0 -1
  381. package/.next/static/chunks/0q9b2n6l4flqb.js +0 -1
  382. package/.next/static/chunks/0uhddock-ik4v.js +0 -1
  383. package/.next/static/chunks/14y1gqfplan8a.js +0 -1
  384. package/.next/static/chunks/1pidafhkyxhqw.js +0 -1
  385. package/.next/static/chunks/1sy7zm5dplzym.css +0 -1
  386. package/.next/static/chunks/1t7u4xfljptkv.js +0 -1
  387. package/.next/static/chunks/2nf3mskfp9cyc.js +0 -15
  388. package/.next/static/chunks/2uraofiaoy32s.js +0 -1
  389. package/.next/static/chunks/2vw9_trh_ntv6.js +0 -2
  390. package/.next/static/chunks/2x6-fpctvucte.js +0 -1
  391. package/.next/static/chunks/33lm6ytc816te.js +0 -1
  392. package/.next/static/chunks/3p5q6rj40jmcy.js +0 -1
  393. package/.next/static/chunks/3p80hsvcabgw_.js +0 -3
  394. package/.next/static/chunks/3qez_j23ikyar.js +0 -1
  395. /package/.next/static/{gx61wKkj9_eBGMdyfbBlr → 8exfHAtcoebYtxjUC4ugl}/_buildManifest.js +0 -0
  396. /package/.next/static/{gx61wKkj9_eBGMdyfbBlr → 8exfHAtcoebYtxjUC4ugl}/_clientMiddlewareManifest.js +0 -0
  397. /package/.next/static/{gx61wKkj9_eBGMdyfbBlr → 8exfHAtcoebYtxjUC4ugl}/_ssgManifest.js +0 -0
@@ -0,0 +1,15 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,302707,e=>{"use strict";var t=e.i(843476),n=e.i(689664),r=e.i(24071),a=e.i(867927),s=e.i(638292),l=e.i(456420);let i={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};i.node;let o=(0,l.default)(i),u={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};u.node;let c=(0,l.default)(u);var d=e.i(618566),h=e.i(271645),p=e.i(798120),m=e.i(167881),f=e.i(660302),g=e.i(319036),x=e.i(728231),y=e.i(146538),w=e.i(265402),b=e.i(609507),v=e.i(463625),k=e.i(635963),j=e.i(6799),S=e.i(393080),N=e.i(283653),T=e.i(647163),E=e.i(820758),_=e.i(805995),M=e.i(616816),A=e.i(665357),C=e.i(98785),L=e.i(992112),R=e.i(218080);let I={hello:"Hi, I'm Thursday. One thing first: this is a recording. You'll hear my real voice on our first call.",key:"First, I need a voice. Sign in with ChatGPT, and I talk on the plan you already have. Or paste an OpenAI key, if you'd rather. Neither one yet? No problem, skip ahead. I'll ask again later.",awake:"There we go — I'm awake. That's all a call needs. The rest is quick: your microphone, who does the work for you, and what they think with.",mic:"Now let me hear you. Your browser will ask before it turns the microphone on. Say yes, then say anything — and watch the line under me move. It's only on during a call, unless you ask for more.",heard:"I hear you — that line is your voice. If you'd rather wake me by saying my name instead of tapping, switch that on here and give it a try.",bots:"Big jobs go to my helper bots, so you and I can keep talking while they work. They work right here on your computer, with a browser and your files. Signing in and paying always stay with you.",models:"Every bot runs on an A.I. model that you pick. Start small: a small one is fast and cheap, and you can move any bot up later. Your ChatGPT plan or your OpenAI key already covers it. One Vercel key opens up a lot more.",style:"One more, and it's the fun one: who I am to you. There are four of me, and the only difference is how I talk. Pick whoever sounds like someone you'd call — you can change your mind anytime.",call:"That's everything. Call me, tell me what to call you, and ask for one thing — anything you'd ask someone sitting next to you. From here on, it's my real voice. I'll show you the rest as we go.",asleep:"I still don't have a voice of my own, so no calls yet — but everything else works. Have a look around. When you sign in, or have a key, tap me, and I'll take it from there.",asleepBare:"I still don't have a voice of my own, and my bots have nothing to think with yet — so no calls and no jobs for now. Have a look around. Add a key, or sign in with ChatGPT, and I'll take it from there."},O=Array(R.SPECTRUM_BANDS).fill(0),D="thursday.intro.muted";var P=e.i(567334),$=e.i(387758),F=e.i(877267),B=e.i(377090),z=e.i(732061),q=e.i(298293),U=e.i(922521);let K=[{radii:5,px:64,density:1.05},{radii:3.2,px:40,density:1.1},{radii:2.1,px:26,density:1.2},{radii:1.45,px:16,density:1.3}],H=[.2,1.6,2.5,3.1,3.55],W=["/sounds/opening-rise.ogg","/sounds/opening-step-1.ogg","/sounds/opening-step-2.ogg","/sounds/opening-step-3.ogg","/sounds/opening-land.ogg"],G=[2,3,1],Y=[[],["🤍"],["🤍","☁️"],["☁️","🤍"],["☁️","🕊️"],["🕊️","☁️"],["🕊️","🦢"],["🦢","🕊️","☁️"],["🦢","🤍"],["🤍","⚪","🦢"],["🤍","⚪"],["⚪","🤍"]],V=[[],["🤍","⚪"],["🤍","⚪","🦢"],["🦢","🤍","🕊️"],["🦢","🕊️","☁️"],["🕊️","🦢","☁️"],["🕊️","☁️"],["☁️","🕊️"],["☁️","🖤"],["⚫","🖤","☁️"],["🖤","⚫"],["🖤","⚫"]],J=K[0].px;function X({anchor:e,onArrive:n,onHello:r,onDone:a}){let s=(0,h.useRef)(null),l=(0,U.useIsDark)(),i=(0,h.useRef)({dark:l,onArrive:n,onHello:r,onDone:a});return i.current={dark:l,onArrive:n,onHello:r,onDone:a},(0,h.useEffect)(()=>{let t=s.current,n=e.current,r={arrive:!1,hello:!1,done:!1},a=e=>{r[e]||(r[e]=!0,"arrive"===e?i.current.onArrive():"hello"===e?i.current.onHello():i.current.onDone())};if(!t||!n||window.matchMedia("(prefers-reduced-motion: reduce)").matches){a("arrive"),a("hello"),a("done");return}let l=t.getContext("2d");if(!l){a("arrive"),a("hello"),a("done");return}let o=H.map((e,t)=>e+(t>0?(Math.random()-.5)*.12:0)),u=!function(){try{return"1"===window.localStorage.getItem(D)}catch{return!1}}()?W.map(e=>{let t=new Audio(e);return t.preload="auto",t}):[],c=0,d=50*Math.random(),h=Math.min(2,window.devicePixelRatio||1),p="letters"===(0,F.faceGlyphs)(),m=p?null:function(e,t){let n=Math.round(J*t),r=Math.ceil(1.3*n),a=document.createElement("canvas");a.width=12*r,a.height=r*Math.ceil(e.length/12);let s=a.getContext("2d");if(!s)return null;s.textAlign="center",s.textBaseline="middle",s.font=(0,$.GLYPH_FONT)(n);let l=new Map;return e.forEach((e,t)=>{l.set(e,t),s.fillText(e,t%12*r+r/2,Math.floor(t/12)*r+r/2)}),{canvas:a,at:l,slot:r,scale:r/t/J}}([...new Set([...P.EMOJI_POOL,...Y.flat(),...V.flat(),...G.flatMap(e=>q.WASH_SETS[e-1].emoji)])],h);if(!p&&!m){a("arrive"),a("hello"),a("done");return}let f=P.LEVELS-1,g=[],x=null,y=()=>{let e=window.innerWidth,r=window.innerHeight;t.width=Math.round(e*h),t.height=Math.round(r*h),l.setTransform(h,0,0,h,0,0),l.textAlign="center",l.textBaseline="middle",x=null;let a=n.getBoundingClientRect(),s=Number.parseFloat(getComputedStyle(n).getPropertyValue("--face-bleed"))/100||0,i=a.width*(1+2*s),o=a.left+a.width/2,u=a.top+a.height/2,c=$.DESIGN/i;g=K.map((t,n)=>{let a=.95*t.px/t.density,s=1.25*t.px/t.density,l=.12*n,i=Math.cos(l),h=Math.sin(l),p=70+26*n,m=[];for(let l=0;l*s<r;l++)for(let r=0;r*a<e;r++){let e=r*a+a/2,f=l*s+s/2,g=(e-o)*c,x=(f-u)*c,y=(g*i-x*h)/$.REST_R/t.radii,w=(g*h+x*i)/$.REST_R/t.radii,b=Math.hypot(y,w);if(b>2.6)continue;let v=Math.floor((Math.atan2(w,y)+Math.PI)/(2*Math.PI)*p),k=(0,P.hash)(v+13*n,3.1+d),j=(0,P.hash)(1.3*v,11.1+d);m.push({x:e,y:f,r:b,dx:y*$.REST_R,dy:w*$.REST_R,drift:.02+.14*k*k,go:.15+.9*(0,P.hash)(v,7.7+n),carry:j<.13?G[Math.floor(23*j)%G.length]:0,nx:g*(8/t.px)*.05,ny:x*(8/t.px)*.05,seed:(0,P.hash)(r+101*n,l),grain:(0,P.hash)(5.7*r+19+n,2.3*l+53),gap:.05+.3*(0,P.hash)(7.3*r+11,3.1*l+5+n)})}let g=m.length;return{px:t.px,cells:m,fast:new Float32Array(g),slow:new Float32Array(g),wasLevel:new Int8Array(g).fill(-9),turn:new Int32Array(g).fill(-9),pick:new Int32Array(g),pool:new Int8Array(g),poolFor:new Float32Array(g),byLevel:Array.from({length:f+1},()=>new Int32Array(g)),inLevel:new Int32Array(f+1),glyph:Array(g),over:!1}})};y(),window.addEventListener("resize",y);let w=(0,z.createSmoke)(),b=90*Math.random(),v={dx:0,dy:0,dist:0},k=performance.now(),j=k,S=0,N=0,T=e=>{let n=(e-k)/1e3,r=Math.min(.05,Math.max(0,(e-j)/1e3));j=e,S+=r;let{dark:s}=i.current,d=s?Y:V;p&&x!==s&&(x=s,l.fillStyle=getComputedStyle(t).color),(0,z.stepSmoke)(w,S,r,0,0,-1);let y=(0,B.windAt)(S,b),E=Math.exp(-r/$.TRAIL_FAST),_=Math.exp(-r/1.4);l.clearRect(0,0,t.width/h,t.height/h);let M=0;for(g.forEach((e,t)=>{let a=o[t],s=o[t+1];if(e.over||n<a)return;let i=n-s,u=i<=0?(0,P.smoothstep)(0,1,(n-a)/(0===t?1.2:.35)):1,c=i>0?(0,P.smoothstep)(0,.3,i):0,h=i>.05,g=S+31*t;e.inLevel.fill(0);let x=0,b=e.cells;for(let t=0;t<b.length;t++){let n=b[t],a=0,s=0;if(i<=0)u>0&&n.r<2.6&&(v.dx=n.dx,v.dy=n.dy,v.dist=n.r*$.REST_R,a=(0,z.restValue)(v,g,0,$.REST_R,u,w,y));else{let e=n.r-n.drift*i**.8,t=(1+(1.5*((0,P.smoothstep)(.6,.88,Math.abs(e))*(1-(0,P.smoothstep)(1.2,1.55,Math.abs(e))))-1)*c)*(1-(0,P.smoothstep)(n.go,n.go+.4,i));if(t>0){let r=n.r>0?e/n.r:0;v.dx=n.dx*r,v.dy=n.dy*r,v.dist=Math.abs(e)*$.REST_R,(a=(0,z.restValue)(v,g,0,$.REST_R,1,w,y)*t)>.04&&c>.5&&(s=n.carry)}}(a*=(.66+.72*n.grain)*(.8+.4*(0,P.hash)(Math.floor(n.nx+.5*S),Math.floor(n.ny-.3*S))))>.3&&(0,P.hash)(31.7*Math.floor(1.6*S),613*n.seed)>.992&&(a=Math.max(a,.9)),s?(e.pool[t]=s,e.poolFor[t]=.35*(.5+n.grain)):e.poolFor[t]>0?(e.poolFor[t]-=r,e.poolFor[t]<=0&&(e.pool[t]=0)):e.pool[t]=0;let l=e.fast[t]=a>e.fast[t]*E?a:e.fast[t]*E,o=e.slow[t]=a>e.slow[t]*_?a:e.slow[t]*_;if((a=l>.55*o?l:.55*o)<n.gap+.05*Math.sin(.28*S+6.283*n.seed))continue;let m=(a>1?1:a)*f|0;if(0===m)continue;x++;let k=S*(p?$.CHURN_LETTERS:$.CHURN_EMOJI)+7*n.seed|0;(k!==e.turn[t]||m-e.wasLevel[t]>=2||e.wasLevel[t]-m>=2)&&(e.turn[t]=k,e.wasLevel[t]=m,e.pick[t]=(997*n.seed|0)+k+m);let j=e.pick[t],N=e.pool[t]?q.WASH_SETS[e.pool[t]-1]:null,T=p?N?.letters??P.RAMP[m]:N?.emoji??(h?d[m]:P.EMOJI_POOL);e.glyph[t]=T[j%T.length],e.byLevel[m][e.inLevel[m]++]=t}M+=x,i>1.45&&0===x&&(e.over=!0),m||(l.font=(0,$.GLYPH_FONT)(e.px));for(let t=1;t<=f;t++){let n=e.inLevel[t];if(0===n)continue;let r=e.byLevel[t];if(!m){l.globalAlpha=P.ALPHA_TOP*(t/f);for(let t=0;t<n;t++){let n=b[r[t]];l.fillText(e.glyph[r[t]],n.x,n.y)}continue}l.globalAlpha=(0,P.emojiAlpha)(t,f);let a=e.px*m.scale*(.5+.5*(0,P.emojiWeight)(t,f));for(let t=0;t<n;t++){let n=b[r[t]],s=m.at.get(e.glyph[r[t]])??0;l.drawImage(m.canvas,s%12*m.slot,Math.floor(s/12)*m.slot,m.slot,m.slot,n.x-a/2,n.y-a/2,a,a)}}}),l.globalAlpha=1;c<u.length&&n>=o[c];c++)u[c].play().catch(()=>{});if(n>=o[4]&&a("arrive"),n>=4.7&&a("hello"),n>o[4]+1.6&&0===M){l.clearRect(0,0,t.width/h,t.height/h),a("done");return}N=requestAnimationFrame(T)};return N=requestAnimationFrame(T),()=>{if(cancelAnimationFrame(N),window.removeEventListener("resize",y),!r.done)for(let e of u)!function(e,t=.4){if(e.paused)return;let n=e.volume,r=performance.now(),a=s=>{let l=Math.max(0,Math.min(1,(s-r)/1e3/t));e.volume=n*(1-l),l<1?requestAnimationFrame(a):e.pause()};requestAnimationFrame(a)}(e)}},[e]),(0,t.jsx)("canvas",{ref:s,"aria-hidden":!0,className:"pointer-events-none absolute inset-0 size-full text-foreground"})}var Z=e.i(95187);let Q=(0,Z.createServerReference)("7fb87c89f9348c91147fc737309dc180f404ea235f",Z.callServer,void 0,Z.findSourceMapURL,"passIntroAction");var ee=e.i(745747),et=e.i(333495),en=e.i(435135),er=e.i(692888),ea=e.i(114923),es=e.i(234916),el=e.i(67045),ei=e.i(297825),eo=e.i(895499),eu=e.i(656572),ec=e.i(609856);let ed=["key","mic","bots","models","style","call"];function eh({children:e}){return(0,t.jsxs)("p",{className:"text-[17px] leading-[1.675] tracking-[0.3px]",children:[(0,t.jsx)("span",{className:"mr-4 inline-block size-2.5 rounded-full bg-foreground align-middle opacity-55"}),e]})}let ep=({children:e})=>(0,t.jsx)("p",{className:"font-mono text-[11px] leading-relaxed text-pretty text-muted-foreground/70",children:e});function em({children:e,tail:r}){return(0,t.jsxs)("p",{className:"flex items-center gap-2.5 text-sm",children:[(0,t.jsx)("span",{className:"grid size-5 shrink-0 animate-in place-items-center rounded-full bg-primary text-primary-foreground duration-300 zoom-in-50",children:(0,t.jsx)(n.Check,{className:"size-3"})}),(0,t.jsx)("span",{className:"animate-in delay-150 duration-300 fill-mode-backwards fade-in slide-in-from-left-1",children:e}),r&&(0,t.jsx)("span",{className:"truncate font-mono text-[11px] text-muted-foreground/70",children:r})]})}function ef({onSaved:e}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"Give her a voice"}),(0,t.jsx)(M.CallLines,{onSaved:e})]})}function eg({mic:e}){let r=(0,el.useThursdayStore)(e=>e.wake),a=(0,el.useThursdayStore)(e=>e.patch),[l,i]=(0,h.useState)(!1),[o,u]=(0,h.useState)(null);return((0,eu.useWakeWord)({enabled:e.on&&r.enabled&&!o,phrases:[r.phrase],onWake:()=>i(!0),onError:u}),e.on)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(em,{children:"Microphone is on"}),(0,t.jsxs)("label",{className:"mt-1.5 flex cursor-pointer items-start gap-3",children:[(0,t.jsxs)("span",{className:"flex flex-1 flex-col gap-0.75",children:[(0,t.jsx)("span",{className:"text-sm",children:"Wake her by voice"}),(0,t.jsxs)(ep,{children:["Say ",(0,t.jsxs)("span",{className:"text-foreground",children:['"',r.phrase,'"']})," and she picks up. The microphone stays open for as long as this tab is, and the browser does the listening: Chrome sends what it hears to Google."]}),r.enabled&&!o&&(l?(0,t.jsxs)("span",{className:"mt-1.5 flex items-center gap-2 text-[13px]",children:[(0,t.jsx)("span",{className:"grid size-5 shrink-0 animate-in place-items-center rounded-full bg-foreground text-background duration-300 zoom-in-50",children:(0,t.jsx)(n.Check,{className:"size-3"})}),"Heard you. That is how you call her."]}):(0,t.jsxs)("span",{className:"mt-1.5 flex items-center gap-2 text-[13px]",children:[(0,t.jsx)(s.Mic,{className:"size-4 shrink-0"}),(0,t.jsx)(f.ShinyText,{text:`Try it now: say "${r.phrase}"`,speed:2.2})]})),o&&(0,t.jsx)(ep,{children:o})]}),(0,t.jsx)(g.Switch,{checked:r.enabled,onCheckedChange:e=>a({wake:{...r,enabled:e}})})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"Turn on the microphone"}),e.failed?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:(0,T.cn)("text-[13px] leading-normal",T.WAITING_INK),children:e.failed.what}),(0,t.jsx)(ep,{children:e.failed.next})]}):(0,t.jsx)(ep,{children:"Used on a call, and nowhere else unless you switch on waking her by voice."})]})}function ex({picked:e,onToggle:n}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"Pick who comes along"}),(0,t.jsx)("div",{className:"flex flex-col",children:v.BOT_SEEDS.map(r=>{let a=!!e[r.name];return(0,t.jsxs)("label",{className:"flex h-9.5 cursor-pointer items-center gap-2.75",children:[(0,t.jsx)(k.BotMark,{size:24,seed:r.name,...r.icon,notify:!1,className:(0,T.cn)("shrink-0 transition-opacity",!a&&"opacity-40")}),(0,t.jsx)("span",{className:(0,T.cn)("w-17.5 shrink-0 text-[13.5px] font-medium",!a&&"text-muted-foreground"),children:r.name}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:r.hint}),(0,t.jsx)(g.Switch,{checked:a,onCheckedChange:()=>n(r.name)})]},r.name)})}),(0,t.jsx)(ep,{children:"Every one comes along. Switch off any you will not use: Settings › Bots has them all, and you can make your own."})]})}function ey(){let{settings:e,patch:n}=(0,ei.useLiveSettings)(),r=Math.max(0,b.PERSONAS.findIndex(t=>t.id===e?.persona)),a=b.PERSONAS[r],s=e=>n({persona:b.PERSONAS[(r+e+b.PERSONAS.length)%b.PERSONAS.length].id});return(0,t.jsxs)("div",{className:"flex w-full max-w-md flex-col gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-2xl font-semibold",children:a.label}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:a.about})]}),(0,t.jsx)("p",{className:"min-h-20 text-left text-sm leading-relaxed text-foreground/80",children:a.lines}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)(m.Button,{variant:"outline",size:"sm",onClick:()=>s(-1),children:"Someone else"}),(0,t.jsx)(m.Button,{variant:"outline",size:"sm",onClick:()=>s(1),children:"Next"})]}),(0,t.jsx)("div",{className:"flex justify-center gap-1.5",children:b.PERSONAS.map((e,n)=>(0,t.jsx)("span",{className:(0,T.cn)("h-0.5 w-5 rounded-full",n===r?"bg-foreground":"bg-border")},e.id))})]})}function ew(){let{data:e}=(0,N.useServerRoute)(p.queryKey.config),n=(0,w.parseTextModel)(e?.find(e=>e.key===L.DEFAULT_MODEL_KEY)?.value),r=e?.find(e=>e.key===L.DEFAULT_EFFORT_KEY)?.value,[a,s]=(0,h.useState)(null),[l]=(0,ec.useServerAction)(C.setConfigAction,{onOk:()=>(0,N.revalidate)(p.queryKey.config)}),[i]=(0,ec.useServerAction)(A.removeConfigAction,{onOk:()=>(0,N.revalidate)(p.queryKey.config)});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eh,{children:"Pick what they think with"}),(0,t.jsx)(_.AccountsSetup,{withoutVoice:!0}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("span",{className:"shrink-0 text-[13px] text-muted-foreground",children:"Bots think with"}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(y.ModelPicker,{provider:a??n?.provider??null,model:a?"":n?.model??"",unset:"Automatic",onChange:e=>{if(!e.model.trim())return s(e.provider);s(null),l(L.DEFAULT_MODEL_KEY,`${e.provider}/${e.model.trim()}`)},onUnset:()=>{s(null),n&&(i(L.DEFAULT_MODEL_KEY),r&&i(L.DEFAULT_EFFORT_KEY))}})})]})]})}function eb({mic:e,bots:r}){let a=["voice",e?"microphone":null,r>0?`${r} ${1===r?"bot":"bots"}`:null].filter(e=>null!==e);return(0,t.jsx)("span",{className:"flex items-center gap-2 text-xs",children:a.map((e,r)=>(0,t.jsxs)("span",{style:{animationDelay:`${300+260*r}ms`},className:"flex animate-in items-center gap-2 duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:[r>0&&(0,t.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(n.Check,{className:"size-3.25"}),e]})]},e))})}let ev={ask:"Find me flights to Osaka in October.",onIt:`On it. ${v.ERRANDS_BOT} is looking. Keep talking, I will say when it is back.`,back:`${v.ERRANDS_BOT} is back. The Tuesday morning flight is the pick. The page is on your screen.`},ek={threadId:"demo",label:"Osaka flights, October",bot:v.ERRANDS_BOT,words:"Three fares compared. The Tuesday morning one is the pick: direct, and the cheapest by a little.",paths:[]};function ej({stage:e}){return(0,t.jsxs)(t.Fragment,{children:["landed"===e&&(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-5 left-5 w-90 text-left",children:(0,t.jsx)(eo.FinishedCard,{row:ek,bot:{icon:(0,v.findBotSeed)(ek.bot)?.icon??null},onOpen:()=>{},onClose:()=>{}})}),(0,t.jsxs)("div",{className:"absolute right-5 bottom-5 flex h-10 items-center gap-2.5 rounded-full bg-background pr-3.5 pl-2.5 ring-1 ring-border",children:[(0,t.jsx)("span",{className:"flex",children:v.BOT_SEEDS.map((n,r)=>(0,t.jsx)(k.BotMark,{size:22,seed:n.name,...n.icon,state:"working"===e&&n.name===v.ERRANDS_BOT?"thinking":"idle",notify:!1,className:(0,T.cn)("shrink-0",r>0&&"-ml-1.5")},n.name))}),(0,t.jsx)("span",{className:"w-40 truncate text-left text-[13px] text-muted-foreground",children:"working"===e?`${v.ERRANDS_BOT} \xb7 reading fares`:"landed"===e?`${v.ERRANDS_BOT} finished`:"Need a hand?"})]})]})}e.s(["Intro",0,function({ready:e,firstRun:n,forced:l}){let i=n||l,u=(0,d.useRouter)(),[f,g]=(0,h.useState)("hello"),[y,w]=(0,h.useState)(!1),[b,k]=(0,h.useState)(!1),[_,A]=(0,h.useState)(e),C=(0,M.useVoiceLine)(),L=_||null!==C.line,P=(0,h.useRef)(L);(0,h.useEffect)(()=>{L&&!P.current&&F((0,ea.awake)()),P.current=L},[L]);let[$,F]=(0,h.useState)(null),[B,z]=(0,h.useState)(()=>Object.fromEntries(v.BOT_SEEDS.map(e=>[e.name,!0]))),[q,U]=(0,h.useState)("echoes"),K="hello"===q||"over"===q,H=(0,h.useRef)(null),W=function(e){let[t,n]=(0,h.useState)("off"),[r,a]=(0,h.useState)(!1),[s,l]=(0,h.useState)(""),i=(0,h.useRef)(null),o=(0,h.useRef)(null),u=(0,h.useRef)(e);u.current=e;let c=(0,h.useCallback)(()=>{for(let e of o.current?.getTracks()??[])e.stop();o.current=null},[]);return(0,h.useEffect)(()=>{e||(c(),n(e=>"on"===e||"asking"===e?"off":e))},[e,c]),(0,h.useEffect)(()=>c,[c]),{on:"on"===t,asking:"asking"===t,failed:"object"==typeof t?t:null,allowed:r,label:s,turnOn:(0,h.useCallback)(async()=>{n("asking");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(!u.current){for(let t of e.getTracks())t.stop();a(!0);return}o.current=e,i.current??=(0,R.createAudioTap)(),i.current.open(),i.current.hear?.(e),l(e.getAudioTracks()[0]?.label??""),n("on"),a(!0)}catch(e){n(function(e){let t=e instanceof DOMException?e.name:"";if("NotAllowedError"===t)return{what:"This page is not allowed the microphone yet.",next:"The icon at the left of the address bar opens the site's settings: set Microphone to Allow and come back. Or just go on."};if("NotFoundError"===t)return{what:"No microphone was found.",next:"Plug one in or switch it on, then turn it on here again. Or just go on."};if("NotReadableError"===t)return{what:"The microphone would not start.",next:"Another app may be using it: close that app and turn it on here again. Or just go on."};let n=e instanceof Error&&e.message||t||String(e);return{what:"The microphone did not open.",next:`The browser said "${n}". Or just go on.`}}(e))}},[]),spectrum:(0,h.useCallback)(()=>i.current?.readMic()??[],[])}}("mic"===f&&!y),G=function(e){let[t,n]=(0,h.useState)(0);(0,h.useEffect)(()=>{if(!e)return;let t=performance.now(),r=setInterval(()=>n((performance.now()-t)%16e3),120);return()=>clearInterval(r)},[e]);let r=(e,t,n)=>({id:e,role:t,text:n}),a=[];t>900&&a.push(r("ask","user",ev.ask)),t>4700&&a.push(r("onIt","assistant",ev.onIt)),t>11500&&a.push(r("back","assistant",ev.back));let s=t>4700&&t<8300||t>11500&&t<14500;return{turns:a,status:s?"speaking":t>900&&t<4700?"listening":"idle",stage:t>9600?"landed":t>5400?"working":t>900?"asked":"rest",saying:s,voice:es.silentVoice}}("hello"===f&&i&&!y&&K),Y=i&&!y;(0,h.useEffect)(()=>(ee.callSignal.hold(Y),()=>ee.callSignal.hold(!1)),[Y]),(0,h.useEffect)(()=>{if(!y)return;let e=setTimeout(()=>k(!0),700);return()=>clearTimeout(e)},[y]);let V=ed.indexOf(f),{data:J}=(0,N.useServerRoute)(p.queryKey.automaticModel),Z=!!J?.ref,el=(0,h.useMemo)(()=>{var e,t,n,r;let a,s;return e=f,t=L,n=W.on,r=Z,a=(e,t)=>({id:e,role:"assistant",text:t}),s=[],"hello"===e||(s.push(a("key","I am Thursday, and the first thing I need is a voice. Sign in with ChatGPT and I talk on your plan, or paste an OpenAI key. Neither yet? Go on without it, and I will ask again when you call.")),t&&s.push(a("awake","There, I am awake, and that is everything a call needs. From here on it is quick: your microphone, who works for you, and what they think with.")),"key"===e||(s.push(a("mic","Now let me hear you. Your browser asks before it opens the microphone: say yes, then say anything at all and watch the line under me move. It is only open on a call, unless you ask for more.")),n&&s.push(a("heard","I hear you: that line is your voice. If you would rather wake me by saying my name than by tapping me, switch it on here and try it once.")),"mic"===e||(s.push(a("bots","Long work goes to bots, so we can keep talking while they are at it. They work on this computer, with a shell, a browser and your files, and signing in or paying always stays with you.")),"bots"===e||(s.push(a("models","Bots think with a model you choose. Start small: a small model is quick and costs little, and any bot can move up later. Your ChatGPT plan or OpenAI key already covers it; one Vercel key opens far more.")),"models"===e||(s.push(a("style","One more, and it is the fun one: who I am to you. Four of them, and the only difference is how I talk — pick whoever sounds like someone you would call, and change your mind whenever you like.")),"style"===e||s.push(t?a("call","That is everything I need. Call me, tell me what to call you, and ask for one thing, anything you would ask a person at the next desk. I will show you the rest as we go."):r?a("asleep","I still have no voice of my own, so there is no call yet, but everything else works. Look around; tap me whenever you sign in or have a key, and I will take it from there."):a("asleepBare","I still have no voice of my own, and my bots have nothing to think with yet, so there is no call and no job for now. Look around; add a key or sign in with ChatGPT whenever you like, and I will take it from there."))))))),s},[f,L,W.on,Z]),ei="hello"===f?G.turns:el,eo=(0,en.useTurnFocus)(ei,Y),eu=function(e){let t=(0,h.useRef)(null),n=(0,h.useRef)(new Set),r=(0,h.useRef)([]),a=(0,h.useRef)(!1),[s,l]=(0,h.useState)(!1),[i,o]=(0,h.useState)(!1),u=(0,h.useRef)(!1);(0,h.useEffect)(()=>{try{let e="1"===window.localStorage.getItem(D);u.current=e,o(e)}catch{}},[]);let c=(0,h.useCallback)(()=>{r.current=[],t.current?.audio.pause()},[]),d=(0,h.useCallback)(()=>{let e=r.current.shift();if(!e||!t.current)return;let{audio:n,clip:a}=t.current;a.resume(),n.src=`/voices/intro/${e}-${function(e){let t=0x811c9dc5;for(let n of`marin|${e}`)t^=n.codePointAt(0)??0,t=Math.imul(t,0x1000193);return(t>>>0).toString(16).padStart(8,"0")}(I[e])}.ogg`,n.play().catch(()=>{})},[]),p=(0,h.useCallback)((...e)=>{let s=e.filter(e=>!n.current.has(e));if(!u.current&&s.length){if(!t.current){let e=new Audio,n=e=>()=>{a.current=e,l(e)};for(let t of(e.addEventListener("playing",n(!0)),["pause","ended","error"]))e.addEventListener(t,n(!1));e.addEventListener("ended",d),e.addEventListener("error",d),t.current={audio:e,clip:(0,R.createClipTap)(e)}}for(let e of s)n.current.add(e);r.current=s,d()}},[d]);(0,h.useEffect)(()=>{e&&t.current&&p(e)},[e,p]),(0,h.useEffect)(()=>()=>{t.current?.audio.pause(),t.current?.clip.close(),t.current=null},[]);let m=(0,h.useCallback)(()=>{let t=!u.current;u.current=t,o(t);try{window.localStorage.setItem(D,t?"1":"0")}catch{}if(t)return c();e&&(n.current.delete(e),p(e))},[c,e,p]);return{say:p,hush:c,speaking:s,muted:i,toggle:m,spectrum:(0,h.useCallback)(()=>t.current&&a.current?t.current.clip.read():O,[])}}(y?null:el.at(-1)?.id??null);if(b||!i)return null;let ec=e=>{if(eu.hush(),w(!0),n){let e;(e=v.BOT_SEEDS.filter(e=>B[e.name]).map(e=>({name:e.name}))??v.BOT_SEEDS.map(e=>({name:e.name}))).length&&(0,E.createSeedBotsAction)(e).then(S.unwrapResult).then(()=>(0,N.revalidate)(p.queryKey.bot)).catch(e=>j.toast.add({type:"warning",title:"Could not set up the bots",description:(0,T.errorToString)(e)})),Q()}e&&ee.callSignal.place(),u.replace("/"),u.refresh()},eh="hello"===f?G.status:eu.speaking?"speaking":"mic"===f&&W.on?"listening":"idle",ep="call"===f,em="hello"!==f;return(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Getting started",className:(0,T.cn)("fixed inset-0 z-40 bg-background transition-opacity duration-700",y&&"pointer-events-none opacity-0"),children:["over"!==q&&(0,t.jsx)(X,{anchor:H,onArrive:()=>U("her"),onHello:()=>U("hello"),onDone:()=>U("over")}),K&&(0,t.jsx)(x.TooltipProvider,{children:(0,t.jsxs)(x.Tooltip,{children:[(0,t.jsx)(x.TooltipTrigger,{render:(0,t.jsx)(m.Button,{size:"icon",variant:"ghost",onClick:eu.toggle,"aria-label":eu.muted?"Let her speak":"Mute her","aria-pressed":eu.muted,className:"absolute top-5 right-5 z-10 text-muted-foreground hover:text-foreground"}),children:eu.muted?(0,t.jsx)(c,{}):(0,t.jsx)(o,{})}),(0,t.jsx)(x.TooltipContent,{side:"bottom",children:eu.muted?"Let her speak":"Mute her voice"})]})}),(0,t.jsxs)("div",{className:(0,T.cn)("flex h-full flex-col items-center justify-center gap-5 pt-[7vh]",em&&"max-[900px]:justify-start max-[900px]:overflow-y-auto max-[900px]:pb-20"),children:[(0,t.jsxs)("div",{ref:H,className:(0,T.cn)("relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",em&&"max-[900px]:flex max-[900px]:w-full max-[900px]:flex-col max-[900px]:items-center max-[900px]:gap-7"),children:[(0,t.jsx)("button",{type:"button",disabled:!ep||!L,onClick:()=>ec(!0),"aria-label":ep&&L?"Call Thursday":void 0,className:(0,T.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50","hello"!==f&&!L&&"opacity-35",em&&"max-[900px]:mt-6 max-[900px]:w-[min(8rem,20vh)]"),children:"echoes"!==q?(0,t.jsx)(et.Face,{status:eh,failed:!1,word:$,getSpectrum:"hello"===f?G.voice:eu.spectrum,waking:!0,className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"}):(0,t.jsx)("div",{className:"aspect-square w-full"})}),(0,t.jsx)("div",{className:(0,T.cn)(em&&"max-[900px]:hidden"),children:(0,t.jsx)(en.SideCaptions,{turns:ei,pinned:eo.pinned,live:"hello"===f?G.saying:eu.speaking,onPick:eo.pick})}),em&&(0,t.jsx)("p",{className:"hidden w-[min(22rem,calc(100vw-2rem))] text-left text-[15px] leading-[1.6] text-foreground max-[900px]:block",children:el.at(-1)?.text}),"hello"!==f&&(0,t.jsxs)("div",{className:"absolute top-1/2 left-full ml-[calc(var(--face-bleed)+0.375rem)] flex w-[min(22rem,26vw)] -translate-y-1/2 animate-in flex-col gap-4 text-left fade-in slide-in-from-bottom-1 duration-300 max-[900px]:static max-[900px]:ml-0 max-[900px]:w-[min(22rem,calc(100vw-2rem))] max-[900px]:translate-y-0",children:["key"===f&&(0,t.jsx)(ef,{onSaved:()=>A(!0)}),"mic"===f&&(0,t.jsx)(eg,{mic:W}),"bots"===f&&(0,t.jsx)(ex,{picked:B,onToggle:e=>z(t=>({...t,[e]:!t[e]}))}),"models"===f&&(0,t.jsx)(ew,{}),"style"===f&&(0,t.jsx)(ey,{})]},f)]}),(0,t.jsxs)("div",{className:"relative flex w-full max-w-3xl flex-col items-center gap-4 px-6 text-center",children:[(0,t.jsx)("div",{className:"flex h-14 items-center gap-2 text-[13px] text-muted-foreground",children:"hello"===f?K&&(0,t.jsx)("p",{className:"max-w-130 animate-in text-[20px] leading-[1.5] text-balance text-foreground duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2",children:"Just talk to her. She gets it done on this computer, and tells you when it is ready."}):"mic"===f&&W.on?(0,t.jsx)(er.Ear,{live:!0,getMicSpectrum:W.spectrum}):L?ep?(0,t.jsx)(eb,{mic:W.allowed,bots:v.BOT_SEEDS.filter(e=>B[e.name]).length}):null:"Asleep"}),"hello"!==f||K?(0,t.jsxs)(m.Button,{variant:"brand",loading:"mic"===f&&W.asking,onClick:()=>{"hello"===f?(eu.say("hello",L?"awake":"key"),g("key")):"mic"!==f||W.on?ep?ec(L):g(ed[V+1]):W.turnOn()},className:(0,T.cn)("h-12 px-7 pl-8 text-[15px]","mic"===f&&!W.on&&"pl-6","hello"===f&&"animate-in delay-300 duration-700 fill-mode-backwards fade-in slide-in-from-bottom-2"),children:["mic"===f&&!W.on&&!W.asking&&(0,t.jsx)(s.Mic,{}),"hello"===f?"Start":"mic"!==f||W.on?ep?L?"Call her":"Look around":"Continue":"Turn on the microphone",(0,t.jsx)(a.ChevronRight,{})]}):(0,t.jsx)("div",{className:"h-12"}),(0,t.jsx)("p",{className:"h-4 font-mono text-[11px] text-muted-foreground/70",children:"hello"===f?K&&(0,t.jsx)("span",{className:"block animate-in delay-500 duration-700 fill-mode-backwards fade-in",children:"two minutes · every step can wait"}):"key"!==f||L?"mic"===f&&W.asking?"your browser is asking — allow it at the top of the window":"mic"!==f||W.on?ep&&L?"or tap her":"":(0,t.jsx)("button",{type:"button",onClick:()=>g(ed[V+1]),className:"rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"not now — allow it when the first call asks"}):"neither is fine — both can wait for the call screen"})]})]}),"hello"===f?K&&(0,t.jsx)(ej,{stage:G.stage}):(0,t.jsxs)("div",{className:"absolute inset-x-0 bottom-6 grid grid-cols-[1fr_auto_1fr] items-center gap-4.5 font-mono text-[11px] text-muted-foreground/70 [@media(max-height:720px)]:bottom-3",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>g(V>0?ed[V-1]:"hello"),className:"flex items-center gap-1 justify-self-end rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)(r.ChevronLeft,{className:"size-3"}),"Back"]}),(0,t.jsxs)("span",{className:"flex items-center gap-4.5",children:[(0,t.jsx)("span",{className:"flex items-center gap-1.75",children:ed.map((e,n)=>(0,t.jsx)("span",{className:(0,T.cn)("h-1.75 rounded-full transition-all duration-300",n===V?"w-5.5 bg-foreground":"w-1.75",n<V&&"bg-foreground/40",n>V&&"bg-border")},e))}),(0,t.jsxs)("span",{children:[V+1," of ",ed.length]})]}),ep&&!L?(0,t.jsx)("span",{}):(0,t.jsx)("button",{type:"button",onClick:()=>ec(!1),className:(0,T.cn)("justify-self-start rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",ep&&"text-muted-foreground"),children:ep?"Look around first":"Skip all"})]})]})}],302707)},756958,e=>{"use strict";var t=e.i(843476),n=e.i(271645),r=e.i(511769),a=e.i(798120),s=e.i(917162),l=e.i(6799),i=e.i(393080),o=e.i(283653),u=e.i(647163),c=e.i(95187);let d=(0,c.createServerReference)("7f651bcf7c070111af7dd71d5b5b3371ef9376d431",c.callServer,void 0,c.findSourceMapURL,"allowReachAction"),h=(0,c.createServerReference)("7f3c34a80a7a7afd738489e64dedaddc155ab7649a",c.callServer,void 0,c.findSourceMapURL,"declineReachAction");var p=e.i(36174);e.s(["ReachAsk",0,function(){let{data:e}=(0,o.useServerRoute)(a.queryKey.reach);(0,r.useAppEvent)({reach:()=>void(0,o.revalidate)(a.queryKey.reach)});let c=(0,n.useRef)(null),m=e?.channels.find(e=>e.asking)??null,f=m?.asking??null,g=m?.name??null,x=f&&g?`${g}:${f.chat}:${f.code}`:null;return(0,n.useEffect)(()=>{if(c.current?.key===x||(c.current?.close.abort(),c.current=null,!x||!f||!g))return;let e=new AbortController;c.current={key:x,close:e};let n={chat:f.chat,code:f.code};s.notify.confirm({title:`Let ${f.name} reach Thursday from a phone?`,description:(0,t.jsxs)("span",{className:"line-clamp-2",children:[[p.REACH_LABEL[g],f.name,f.handle].filter(Boolean).join(" · "),f.said&&` wrote “${f.said}”`]}),body:(0,t.jsxs)("div",{className:"grid gap-4",children:[(0,t.jsxs)("div",{className:"grid place-items-center gap-1.5 rounded-lg bg-muted p-4",children:[(0,t.jsx)("span",{className:"pl-[0.32em] font-mono text-3xl font-medium tracking-[0.32em]",children:f.code}),(0,t.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:"the code their phone was sent"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Allow only if the phone in your hand shows this code. Whoever you let in can talk to Thursday from there — and through her, start work on this computer."})]}),okText:"Allow",cancelText:"Not them",cautious:!0,signal:e.signal}).then(t=>{if(!e.signal.aborted)return(t?d(g,n):h(g,n)).then(i.unwrapResult).catch(e=>l.toast.add({type:"error",title:t?`Could not let ${f.name} in`:`Could not turn ${f.name} away`,description:(0,u.errorToString)(e)}))})},[x,f,g]),null}],756958)},252284,e=>{"use strict";var t=e.i(843476),n=e.i(271645);e.s(["Boot",0,function(){let[e,r]=(0,n.useState)(!1);return((0,n.useEffect)(()=>r(!0),[]),e)?null:(0,t.jsx)("p",{"aria-hidden":!0,className:"pointer-events-none fixed inset-x-0 bottom-16 z-50 animate-stalled text-center text-[13px] text-muted-foreground opacity-0",children:"The page did not start. Reload it."})}])},692888,638292,745747,234916,895499,656572,114923,435135,e=>{"use strict";var t,n,r=e.i(843476),a=e.i(989366),s=e.i(716327),l=e.i(456420);let i={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};i.node;let o=(0,l.default)(i),u={name:"flag",size:24,node:[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]};u.node;let c=(0,l.default)(u),d={name:"mic",size:24,node:[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]};d.node;let h=(0,l.default)(d);e.s(["Mic",0,h],638292);let p={name:"mic-off",size:24,node:[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]};p.node;let m=(0,l.default)(p),f={name:"phone-missed",size:24,node:[["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"m22 2-6 6",key:"6f0sa0"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]};f.node;let g=(0,l.default)(f),x={name:"settings-2",size:24,node:[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]};x.node;let y=(0,l.default)(x);var w=e.i(263676),b=e.i(770703),v=e.i(271645),k=e.i(798120),j=e.i(167881),S=e.i(225913),N=e.i(647163);let T=(0,S.cva)("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-1.5 [&>*]:relative [&>*]:focus-visible:z-10",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function E({className:e,orientation:t="horizontal",...n}){return(0,r.jsx)("div",{"data-slot":"button-group","data-orientation":t,role:"group",className:(0,N.cn)(T({orientation:t}),e),...n})}let _=new Intl.Segmenter(void 0,{granularity:"grapheme"});function M({text:e,wraps:t=[]}){let n=(0,v.useMemo)(()=>Array.from(_.segment(e),e=>e.segment),[e]),a=(0,v.useRef)([]),s=0;for(;s<n.length&&n[s]===a.current[s];)s++;(0,v.useEffect)(()=>{a.current=n},[n]);let l=e=>(0,r.jsx)(A,{wait:25*Math.max(0,e-s),children:n[e]},`${n[e]}${e}`),i=[];for(let e=0;e<n.length;){let a=t.find(t=>t.from===e&&t.to>e);if(!a){i.push(l(e)),e+=1;continue}let s=Math.min(a.to,n.length),o=[];for(let t=e;t<s;t++)o.push(l(t));i.push((0,r.jsx)(v.Fragment,{children:a.render(o)},`wrap${e}`)),e=s}return(0,r.jsx)("span",{children:i})}function A({wait:e,children:t}){let[n]=(0,v.useState)(e);return(0,r.jsx)("span",{style:{animationDelay:`${n}ms`},className:"animate-letter motion-reduce:animate-none",children:t})}var C=e.i(660302),L=e.i(633669),R=e.i(6799),I=e.i(728231),O=e.i(41533),D=e.i(149666),P=e.i(265402),$=e.i(451888),F=e.i(635963),B=e.i(768877),z=e.i(511769);let q={wave:740,done:740,ask:820,took:740,give:900,take:520,stop:1150,read:560},U={wave:{body:"animate-crew-hop",shape:"animate-crew-hop-shape"},took:{body:"animate-crew-hop",shape:"animate-crew-hop-shape"},done:{body:"animate-crew-hop",shape:"animate-crew-hop-shape",turn:"animate-crew-spin"},ask:{body:"animate-crew-hop",shape:"animate-crew-hop-shape",turn:"animate-crew-ask-turn"},give:{turn:"animate-crew-give"},take:{body:"animate-crew-take",shape:"animate-crew-take-shape"},stop:{body:"animate-crew-sink",shape:"animate-crew-sink-shape"},read:{body:"animate-crew-nod",shape:"animate-crew-nod-shape"}},K={key:0,body:"",shape:"animate-crew-breath",turn:"",delayMs:0};var H=e.i(399512),W=e.i(256604),G=e.i(319841),Y=e.i(245629),V=e.i(661504),J=e.i(283653),X=e.i(978411),Z=e.i(351866),Q=e.i(401851),ee=e.i(677241),et=e.i(24708),en=e.i(845110),er=e.i(980797),ea=e.i(383482),es=e.i(24071),el=e.i(931619),ei=e.i(632781),eo=e.i(671428),eu=e.i(127341),ec=e.i(835878),ed=e.i(431594);function eh(){let e=(0,X.useBotThreads)(),t=(0,X.useRingingThreads)();return(0,v.useMemo)(()=>[...e].reverse().filter(e=>!t.includes(e.id)&&(0,$.needsThreadReply)(e)),[e,t])}function ep({tab:e,current:t,onTab:n,onClose:a}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-3 pr-3.5 pb-1.5 pl-2.5",children:[(0,r.jsx)(eu.Tabs,{value:e,onValueChange:e=>n(e),className:"gap-0",children:(0,r.jsxs)(eu.TabsList,{className:"gap-1 rounded-none bg-transparent p-0 group-data-horizontal/tabs:h-auto",children:[(0,r.jsxs)(eu.TabsTrigger,{value:"now",className:Z.TAB,children:["Now",t>0&&(0,r.jsx)("span",{className:"font-mono text-[10px] font-normal text-muted-foreground tabular-nums",children:t})]}),(0,r.jsx)(eu.TabsTrigger,{value:"history",className:Z.TAB,children:"History"})]})}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)(Z.FoldButton,{onClick:a})]})}function em({bots:e}){return(0,r.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:e?.length?"Nothing handed over yet — ask for something that takes a while.":`Thursday hands work to ${$.DEFAULT_BOT.name} until you make bots of your own in Settings › Bots.`})}function ef(){return(0,r.jsx)("p",{className:"px-6 pt-4 pb-5 text-center text-[12px] text-muted-foreground",children:"Nothing running or waiting."})}function eg({pages:e,threads:t,scroll:n,onPick:a}){let s=(0,v.useCallback)(e=>{e&&(e.scrollTop=n.current)},[n]),l=[];for(let e of t){let t=function(e){let t=(0,Y.toDate)(e);return(0,er.isToday)(t)?"today":(0,ea.isYesterday)(t)?"yesterday":(0,Q.format)(t,function(e,t){let[n,r]=(0,en.normalizeDates)(void 0,e,t);return n.getFullYear()===r.getFullYear()}((0,ee.constructFrom)(t,t),(0,et.constructNow)(t))?"MMM d":"MMM d, yyyy").toLowerCase()}(e.updatedAt),n=l.at(-1);n?.day===t?n.rows.push(e):l.push({day:t,rows:[e]})}return(0,r.jsx)("div",{ref:s,onScroll:e=>{n.current=e.currentTarget.scrollTop},className:"flex max-h-[50vh] min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-1 pb-2 scrollbar-none",children:e.error?(0,r.jsx)("p",{className:"px-2.5 py-3 text-[12px] text-destructive",children:e.error.message}):e.isLoading?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"flex h-6 items-center px-2.5 pt-1",children:(0,r.jsx)(eo.Skeleton,{className:"h-2.5 w-16"})}),(0,r.jsx)(ey,{})]}):(0,r.jsxs)(r.Fragment,{children:[l.map((e,t)=>(0,r.jsxs)(v.Fragment,{children:[(0,r.jsxs)("p",{className:(0,N.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===t?"pt-1":"pt-3"),children:[e.day," · ",e.rows.length]}),e.rows.map(e=>(0,r.jsx)(ev,{thread:e,onPick:()=>a(e.id)},e.id))]},e.day)),e.hasMore?(0,r.jsx)("div",{ref:e.sentinelRef,children:(0,r.jsx)(ey,{})}):0===l.length&&(0,r.jsx)("p",{className:"px-6 pt-3 pb-4 text-center text-[12px] text-muted-foreground",children:"Nothing has ended yet."})]})})}function ex({onBack:e,onClose:t}){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[(0,r.jsx)("button",{type:"button",onClick:e,"aria-label":"Back to the list",className:"shrink-0 rounded-md p-1 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsx)(es.ChevronLeft,{className:"size-4"})}),(0,r.jsx)(eo.Skeleton,{className:"size-5.5 shrink-0 rounded-md"}),(0,r.jsx)("span",{className:"flex min-w-0 flex-1",children:(0,r.jsx)(eo.Skeleton,{className:"h-3.5 w-2/5"})}),(0,r.jsx)(Z.FoldButton,{onClick:t})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-4",children:[(0,r.jsx)(eo.Skeleton,{className:"h-3 w-4/5"}),(0,r.jsx)(eo.Skeleton,{className:"h-3 w-3/5"}),(0,r.jsx)(eo.Skeleton,{className:"h-3 w-2/3"})]})]})}function ey(){return(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-2 py-1.5",children:[(0,r.jsx)(eo.Skeleton,{className:"size-8 shrink-0 rounded-[10px]"}),(0,r.jsxs)("span",{className:"flex h-9 min-w-0 flex-1 flex-col justify-center gap-1.5",children:[(0,r.jsx)(eo.Skeleton,{className:"h-3.5 w-2/5"}),(0,r.jsx)(eo.Skeleton,{className:"h-2.5 w-3/5"})]})]})}let ew=[{id:"needsYou",label:"needs you"},{id:"working",label:"working"}];function eb({threads:e,onPick:t}){let n=new Map;for(let t of e){let e=(0,$.standOf)(t),r=n.get(e);r?r.push(t):n.set(e,[t])}return(0,r.jsx)("div",{className:"flex max-h-[50vh] min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pt-1 pb-1 scrollbar-none",children:ew.map((e,a)=>{let s=n.get(e.id)??[];return s.length?(0,r.jsxs)(v.Fragment,{children:[(0,r.jsxs)("p",{className:(0,N.cn)("px-2.5 pb-1 font-mono text-[10px] text-muted-foreground",0===a?"pt-1":"pt-3"),children:[e.label," · ",s.length]}),s.map(e=>(0,r.jsx)(ev,{thread:e,onPick:()=>t(e.id)},e.id))]},e.id):null})})}function ev({thread:e,onPick:t,lines:n=1}){let a=(0,$.needsThreadReply)(e),s=e.lines.at(-1),l=(0,v.useMemo)(()=>(function(e){let t=e.room.questions[0];if(t)return{text:(0,N.plainText)(t.text),tone:"text-foreground"};if("waiting"===e.status&&e.ask)return{text:(0,$.isAppStop)(e.ask)?(0,N.plainText)(e.outcome??e.ask.question):e.ask.question,tone:N.WAITING_INK};let n=e.seen;if("cancelled"===e.status)return{text:"Stopped",tone:"text-muted-foreground"};if("done"===e.status)return{text:(0,N.plainText)(e.outcome??"Done"),tone:n?"text-muted-foreground":"text-foreground"};let r=(0,X.lastSaid)(e);return r?{text:"tool"===r.kind&&r.tool?r.tool.note??`${r.tool.name} \xb7 ${r.tool.input}`:r.text,tone:"text-muted-foreground"}:{text:`${e.bot.name} is taking it on…`,tone:"text-muted-foreground italic"}})(e),[e.status,e.outcome,e.seen,e.ask,e.room.questions,s?.id]),[i,o]=(0,H.useAnswerThread)(),[u,c]=(0,v.useState)(null),d=e.room.questions[0],h=d?d.options??[]:"waiting"===e.status&&(0,$.isAppStop)(e.ask)?e.ask?.options??[]:[];return(0,r.jsxs)("div",{className:"rounded-xl transition-colors hover:bg-muted/60",children:[(0,r.jsxs)("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2.5 rounded-xl px-2 py-1.5 text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("span",{className:"relative flex size-8 shrink-0 items-center justify-center overflow-visible",title:e.bot.name,children:(0,r.jsx)(F.BotMark,{size:32,seed:e.bot.name,color:e.bot.icon?.color,shape:e.bot.icon?.shape,outline:e.bot.icon?.outline,paint:e.bot.icon?.paint,state:"working"===e.status?"thinking":"idle",notify:a||(0,$.isUnread)(e),crossed:"cancelled"===e.status})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[a&&!d&&(0,$.isAppStop)(e.ask)&&(0,r.jsx)("span",{className:"block font-mono text-[10px] tracking-wide text-muted-foreground",children:"Paused"}),(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:(0,N.cn)("min-w-0 truncate text-[14px] leading-5 tracking-[-0.15px]",a?"text-foreground":"text-foreground/80",(a||(0,$.isUnread)(e))&&"font-medium"),children:e.label}),e.routineId&&(0,r.jsx)("span",{title:"Started by a routine",className:"shrink-0",children:(0,r.jsx)(ed.RoutineMark,{className:"size-3 text-muted-foreground/80"})}),(0,r.jsx)(ec.BotRoster,{bots:e.roster}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-[11px] leading-4 text-muted-foreground/70 tabular-nums",children:(0,Y.shortAgo)(e.updatedAt)})]}),(0,r.jsxs)("span",{className:(0,N.cn)("mt-px flex items-center gap-1.5",1===n&&"h-4"),children:["working"===e.status&&(0,r.jsx)(ei.Loader2,{className:"size-3 shrink-0 animate-spin text-muted-foreground/70"}),"working"===e.status||d?(0,r.jsx)(C.ShinyText,{text:l.text,speed:d?3.4:2.2,tone:d?"reading":void 0,className:(0,N.cn)("min-w-0 flex-1 text-[12px] leading-4",1===n?"truncate":"line-clamp-2",l.tone.includes("italic")&&"italic")}):(0,r.jsx)("span",{className:(0,N.cn)("min-w-0 flex-1 text-[12px] leading-4",1===n?"truncate":"line-clamp-2",l.tone),children:l.text})]})]})]}),h.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-0.5 pr-2 pb-2 pl-12.5",children:h.map(t=>(0,r.jsxs)(j.Button,{size:"sm",variant:"secondary",loading:u===t,disabled:o,onClick:async()=>{c(t),await i(e,t,d?.bot,d?.id),c(null)},className:"h-7 gap-1.5 rounded-full px-3 text-[12px]",children:[t===$.THREAD_CONTINUE&&(0,r.jsx)(el.ChevronsRight,{className:"size-3.5"}),t]},t))})]})}var ek=e.i(689664);let ej={name:"circle-pause",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],aliases:["pause-circle"]};ej.node;let eS=(0,l.default)(ej);var eN=e.i(51481),eT=e.i(77071),eE=e.i(825398);function e_({bot:e,icon:t,line:n,children:a}){return(0,r.jsxs)(I.Tooltip,{children:[(0,r.jsx)(I.TooltipTrigger,{render:(0,r.jsx)("span",{}),children:a}),(0,r.jsxs)(I.TooltipContent,{className:"flex items-center gap-2 py-1 pr-2.5 pl-1",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-background/15 py-0.5 pr-2 pl-1",children:[(0,r.jsx)(F.BotMark,{size:15,seed:e,color:t?.color,shape:t?.shape,outline:t?.outline,paint:t?.paint}),(0,r.jsx)("span",{className:"font-medium text-[11px]",children:e})]}),n&&(0,r.jsx)("span",{className:"text-[11.5px] opacity-80",children:n})]})]})}let eM=[[0,[21,117,208]],[.4,[90,157,222]],[.75,[179,210,239]],[1,[252,252,254]]],eA=eM[0][1],eC=[{pace:.075,wide:.75,tall:1.15,seed:3.1,gustWide:.4,gustTall:.2,sky:1},{pace:.16,wide:1.3,tall:2.2,seed:11.7,gustWide:0,gustTall:0,sky:1},{pace:.3,wide:2.4,tall:4,seed:19.3,gustWide:0,gustTall:0,sky:1},{pace:.21,wide:1.65,tall:2.9,seed:27.7,gustWide:0,gustTall:0,sky:1.3}],eL=(e,t,n)=>e<t?t:e>n?n:e,eR=e=>e*e*(3-2*e),eI=(e,t,n)=>eR(eL((n-e)/(t-e),0,1)),eO=(e,t)=>{let n=0x165667b1*e+0x27d4eb2f*t|0;return(((n=(n^n>>>13)*0x4bf19f61)^n>>>16)>>>0)/0xffffffff},eD=(e,t)=>{let n=Math.floor(e),r=Math.floor(t),a=eR(e-n),s=eR(t-r);return(eO(n,r)*(1-a)+eO(n+1,r)*a)*(1-s)+(eO(n,r+1)*(1-a)+eO(n+1,r+1)*a)*s},eP=(e,t,n)=>.74*eD(e+n,t+.7*n)+.26*eD(2.2*e+n,2.2*t+1.3*n);function e$({on:e,className:t}){let n=(0,v.useRef)(null),[a,s]=(0,v.useState)(e),[l,i]=(0,v.useState)(!1);return((0,v.useEffect)(()=>{if(e){s(!0);let e=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(e)}i(!1);let t=setTimeout(()=>s(!1),200);return()=>clearTimeout(t)},[e]),(0,v.useEffect)(()=>{let e=n.current,t=e?.getContext("2d");if(!e||!t)return;e.width=48,e.height=48;let r=t.createImageData(48,48),a=r.data,s=[0,0,0],l=900*Math.random(),i=400*Math.random(),o=e=>{let n=e+l,o=n+1.7*Math.sin(.33*n),u=(.5+.5*Math.sin(.27*n))**2*.72+(.5+.5*Math.sin(.41*n+2.1))**3*.28,c=.1*Math.sin(.19*n),d=eC.map(e=>({seed:e.seed,shift:o*e.pace,wide:e.wide*(1-e.gustWide*u),tall:e.tall*(1+e.gustTall*u),sky:i*e.sky})),h=0;for(let e=0;e<48;e+=1){let t=(e+.5)/48*2-1;for(let e=0;e<48;e+=1,h+=4){let r=(e+.5)/48*2-1,l=eD(.55*r+.03*n,.55*t+i)-.5,o=eD(.55*r+9.1+i,.55*t-.024*n)-.5,u=r+1.15*l,p=t+ +o+c,[m,f,g,x]=d.map(e=>eP((u-e.shift)*e.wide+e.sky,p*e.tall,e.seed)),y=eL((.52-m)/.34,0,1);y*=.7+.6*eL((.56-f)/.4,0,1);let w=.97-.92*(y=eL(y+(.5-g)*.42,0,1))**1.2-.1*eL((.5-g)/.6,0,1)+(x-.5)*.38,b=Math.sqrt(r*r+t*t);!function(e,t){let n=eL(e,0,1),r=1;for(;r<eM.length-1&&n>eM[r][0];)r+=1;let[a,s]=eM[r-1],[l,i]=eM[r],o=(n-a)/(l-a);t[0]=s[0]+(i[0]-s[0])*o,t[1]=s[1]+(i[1]-s[1])*o,t[2]=s[2]+(i[2]-s[2])*o}(w+=.16*eL(1-Math.hypot(r+.42,t+.48)/1.5,0,1)+eI(.84,1,b)*eL(.15+.85*(.8*t+.45*r),0,1)*.45,s);let v=eL(b,0,1)**2.4*.26;a[h]=s[0]+(eA[0]-s[0])*v,a[h+1]=s[1]+(eA[1]-s[1])*v,a[h+2]=s[2]+(eA[2]-s[2])*v,a[h+3]=255*(1-eI(.94,1,b))}}t.putImageData(r,0,0)},u=performance.now();if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void o(6);let c=0,d=0,h=e=>{c=requestAnimationFrame(h),e-d<33||(d=e,o((e-u)/1e3))};return c=requestAnimationFrame(h),()=>cancelAnimationFrame(c)},[a]),a)?(0,r.jsx)("canvas",{ref:n,"aria-hidden":!0,className:(0,N.cn)("pointer-events-none absolute inset-0 size-full transition-opacity",l?"opacity-100":"opacity-0",t),style:{transitionDuration:"200ms"}}):null}var eF=e.i(864723);let eB={done:ek.Check,cancelled:w.X,question:eN.CircleQuestionMark,stopped:eS,resumed:eE.RotateCw},ez={question:N.WAITING_INK,stopped:N.WAITING_INK},eq=e=>{let t=(0,N.plainText)(e).replace(/\s+/g," ").trim();return t.length>28?`${t.slice(0,27)}…`:t};function eU({crew:e,more:t,bubble:n,rows:a,count:s,busy:l,pending:i,playing:o,onPick:u,onOpen:c}){let d=(0,X.useWriteLineUp)(),h=a.length>0&&!d;return(0,r.jsxs)("div",{className:(0,N.cn)("pointer-events-auto w-fit max-w-full bg-background/78 ring-1 ring-border/50 backdrop-blur-md transition-shadow duration-300",h?"w-132 rounded-3xl shadow-lg shadow-black/8":"rounded-full shadow-sm shadow-black/3"),children:[(0,r.jsx)("div",{className:(0,N.cn)("grid overflow-hidden contain-inline-size transition-[grid-template-rows] duration-300 ease-out",h?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:(0,r.jsxs)("div",{className:"min-h-0 overflow-hidden",inert:!h,children:[(0,r.jsxs)("p",{className:"px-3 py-2 font-mono text-[10px] tracking-wide text-muted-foreground",children:[i," ",1===i?"needs":"need"," a reply"]}),(0,r.jsx)("div",{className:"max-h-[34vh] overflow-y-auto px-1.5 pb-2",children:(0,r.jsx)("div",{children:a.map((e,t)=>(0,r.jsx)("div",{style:{animationDelay:`${120+60*t}ms`},className:"animate-in duration-300 fill-mode-backwards fade-in slide-in-from-bottom-1",children:(0,r.jsx)(ev,{thread:e,onPick:()=>u(e.id)})},e.id))},String(h))}),(0,r.jsx)("span",{className:"block h-1.5"})]})}),(0,r.jsx)(eK,{crew:e,more:t,bubble:h?null:n,label:s?`Threads (${s})`:"Bots",onClick:c,playing:o,side:(0,r.jsx)(eH,{busy:l,pending:i,grown:h}),onWrite:X.writeLine.open,writing:d})]})}function eK({crew:e,more:t,bubble:n,playing:a,side:s,label:l,onClick:i,onWrite:o,writing:u}){return(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 py-1.5 pr-3 pl-1.5",children:[(0,r.jsxs)(I.Tooltip,{children:[(0,r.jsxs)(I.TooltipTrigger,{render:(0,r.jsx)("button",{type:"button",onClick:o,"aria-label":"Write to Thursday or a bot","aria-pressed":u,className:(0,N.cn)("relative grid size-7 shrink-0 place-items-center overflow-hidden rounded-full outline-none transition-[background-color,box-shadow] duration-300 focus-visible:ring-3 focus-visible:ring-ring/50",u?"shadow-[0_6px_14px_-7px_color-mix(in_oklab,var(--brand)_60%,transparent)]":"bg-muted text-foreground hover:bg-accent")}),children:[(0,r.jsx)(e$,{on:!!u}),(0,r.jsx)(eT.Plus,{className:(0,N.cn)("size-3.5 transition-opacity duration-200",u?"opacity-0":"opacity-100")})]}),(0,r.jsxs)(I.TooltipContent,{children:["Write to Thursday or a bot",(0,r.jsx)("kbd",{"data-slot":"kbd",className:"bg-background/20 px-1.5 font-mono text-[10px]",children:"/"})]})]}),(0,r.jsxs)("button",{type:"button",onClick:i,"aria-label":l,className:"flex min-w-0 flex-1 items-center gap-2 rounded-full text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(eG,{crew:e,more:t,bubble:n,playing:a}),s]})]})}function eH(e){let t=function({busy:e,pending:t,grown:n}){return t>0?{text:1===t?"waiting on you":`${t} waiting on you`,shine:!0}:e>0?{text:"working",shine:!0,spin:!0}:n?null:{text:"Need a hand?",shine:!1}}(e);return t?(0,r.jsxs)("span",{className:"ml-auto flex h-7 min-w-0 shrink items-center gap-1.5",children:[t.shine?(0,r.jsx)(C.ShinyText,{text:t.text,speed:2.6,className:"block truncate text-[14px] leading-5 tracking-[-0.15px]"}):(0,r.jsx)("span",{className:"block animate-in truncate text-[14px] leading-5 tracking-[-0.15px] text-muted-foreground fade-in duration-300",children:t.text},t.text),t.spin&&(0,r.jsx)(ei.Loader2,{className:"size-4 shrink-0 animate-spin text-muted-foreground/70"})]}):null}let eW=["alto","brio","cinder","delta"].map((e,t,n)=>({name:e,icon:{color:eF.MARK_PALETTE[Math.floor(t*eF.MARK_PALETTE.length/n.length)],shape:eF.MARK_SHAPES[t%eF.MARK_SHAPES.length]},awake:!1,waiting:!1,unread:!1,word:null,standIn:!0}));function eG({crew:e,more:t,bubble:n,playing:a}){return(0,r.jsxs)("span",{className:"flex min-w-0 shrink items-center",children:[e.map((t,s)=>{let l=t.standIn?e.every(e=>e.standIn)?"No bots yet":null:t.waiting?"Waiting on you":t.word?t.word:t.unread?"Left you a result":t.awake?"Working":"Idle",i=(0,r.jsx)("span",{className:(0,N.cn)("flex transition-transform duration-500 ease-out",t.awake&&"-translate-y-0.5 scale-110"),children:(0,r.jsx)(eY,{face:t,motion:function(e,t){if(!e)return{...K,delayMs:-370*t};let n=U[e.gesture];return{key:e.id,body:n.body??"",shape:n.shape??"animate-crew-breath",turn:n.turn??"",delayMs:"wave"===e.gesture?70*t:0}}(a.get(t.name),s)})});return(0,r.jsxs)(v.Fragment,{children:[(0,r.jsxs)("span",{className:(0,N.cn)("relative shrink-0 transition-[margin] duration-500 ease-out",s>0&&!e[s-1].word&&"-ml-2",t.standIn&&"opacity-35"),style:{zIndex:e.length-s},children:[null===l?(0,r.jsx)("span",{children:i}):(0,r.jsx)(e_,{bot:t.name,icon:t.icon,line:l,children:i}),n?.at===t.name&&(0,r.jsx)(eJ,{handoff:n})]}),t.word&&(0,r.jsx)("span",{className:"mx-2.5 min-w-0 shrink truncate",children:(0,r.jsx)(C.ShinyText,{text:t.word,speed:2.6,className:"truncate text-[13px] leading-5 tracking-[-0.1px]"})})]},t.name)}),t>0&&(0,r.jsx)("span",{className:"ml-2 flex h-[18px] shrink-0 items-center rounded-full bg-brand/10 px-2 font-mono text-[10.5px] leading-none font-medium text-brand",title:`${t} more`,children:"+"})]})}function eY({face:e,motion:t}){let n=t.delayMs?{animationDelay:`${t.delayMs}ms`}:void 0;return(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,N.cn)("flex",t.body),style:n,children:(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,N.cn)("flex origin-bottom",t.shape),style:n,children:(0,r.jsx)("span",{"data-crew-motion":!0,className:(0,N.cn)("flex",t.turn),style:n,children:(0,r.jsx)(eV,{face:e})})})},t.key)}function eV({face:e}){return(0,r.jsx)(F.BotMark,{size:28,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:e.waiting||e.unread})}function eJ({handoff:e}){return(0,r.jsxs)("span",{className:"pointer-events-none absolute bottom-[calc(100%+10px)] left-1/2 flex w-max -translate-x-1/2 animate-in flex-col items-center fade-in zoom-in-95 duration-200",children:[(0,r.jsx)("span",{className:"flex rounded-full bg-background py-2 pr-3.5 pl-2.5 shadow-lg shadow-black/10 ring-1 ring-border",children:(0,r.jsx)(eZ,{handoff:e})}),(0,r.jsx)("span",{className:"-mt-px size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-border"}),(0,r.jsx)("span",{className:"-mt-[7.5px] size-0 border-x-[6px] border-t-[7px] border-x-transparent border-t-background"})]})}function eX({handoff:e}){return(0,r.jsx)("span",{className:"ml-auto flex h-7 min-w-0 shrink animate-in items-center pl-4 fade-in duration-200",children:(0,r.jsx)(eZ,{handoff:e})})}function eZ({handoff:e}){let t=e.sign?eB[e.sign]:null,n=e.sign?ez[e.sign]:void 0;return(0,r.jsxs)("span",{className:(0,N.cn)("flex min-w-0 items-center gap-2 text-[13px] leading-[18px] tracking-[-0.1px] whitespace-nowrap",n),children:[(0,r.jsx)(eQ,{from:e.from,to:e.to}),t&&(0,r.jsx)(t,{className:(0,N.cn)("size-3.5 shrink-0",!n&&"text-muted-foreground/70")}),e.shine?(0,r.jsx)(C.ShinyText,{text:e.text,speed:2.2,className:"min-w-0 truncate"}):(0,r.jsx)("span",{className:"min-w-0 truncate",children:e.text})]})}function eQ({from:e,to:t}){let n=[e,...t];return(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:n.map((e,t)=>(0,r.jsx)("span",{className:(0,N.cn)("relative flex",t>0&&"-ml-1.25"),style:{zIndex:n.length-t},children:(0,r.jsx)(e0,{bot:e})},e.name))})}function e0({bot:e}){return e.name===Z.THURSDAY.name?(0,r.jsx)(W.ThursdayMark,{size:18,className:"shrink-0"}):(0,r.jsx)(F.BotMark,{size:18,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:!1,className:"shrink-0"})}let e1=(0,b.default)(()=>e.A(204916).then(e=>e.OfficeView),{loadableGenerated:{modules:[590714]},ssr:!1}),e2=(0,v.memo)(function(){let e=(0,X.useBotThreads)(),t=eh(),{data:n}=(0,J.useServerRoute)(k.queryKey.bot),[a,s]=(0,v.useState)(!1),[l,i]=(0,v.useState)(null),[o,u]=(0,v.useState)(null);null!==o&&o!==l&&u(null);let c=a&&null!==l;(0,v.useEffect)(()=>(X.roomOpen.set(a?c?"thread":"list":null),()=>X.roomOpen.set(null)),[a,c]);let[d,h]=(0,v.useState)({}),[p,m]=(0,v.useState)("now"),f=(0,v.useRef)(0),g=[...e].reverse(),x=g.filter(e=>"finished"!==(0,$.standOf)(e)),y=a&&"history"===p,w=(0,V.useServerPages)({key:(e,t)=>{if(!y)return null;if(0===e)return k.queryKey.threadHistory(null);let n=t?.at(-1);return n?k.queryKey.threadHistory((0,Y.toDate)(n.updatedAt).toISOString()):null},size:O.PAGE_SIZE}),{refresh:b}=w,j=(0,v.useRef)(!1);j.current=w.items.length>0,(0,v.useEffect)(()=>{y&&j.current&&b()},[y,b]);let S=(0,v.useMemo)(()=>w.items.filter(e=>"done"===e.status||"cancelled"===e.status).map(e=>(0,X.threadFromRow)(e,n)),[w.items,n]),T=l?g.find(e=>e.id===l)??S.find(e=>e.id===l)??null:null,{data:E,isLoading:_}=(0,J.useServerRoute)(l?k.queryKey.thread(l):null),M=(0,v.useMemo)(()=>E&&E.id===l?(0,X.threadFromRow)(E,n):null,[E,l,n])??(T?.lines.length?T:null),[A,C]=function(){let[e,t]=(0,v.useState)(null),n=(0,v.useRef)(null);return(0,v.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]),[e,(0,v.useCallback)(e=>{t(e),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{n.current=null,t(null)},3400)},[])]}(),L=(0,v.useMemo)(()=>A??function(e,t){for(let n of e){if("working"!==n.status)continue;let e=n.room.deliveries.find(e=>!e.delivered&&n.room.participants.some(t=>t.bot===e.bot&&"running"===t.state));if(e)return{at:e.bot,from:t(e.bot),to:[],text:"Step-in · waits for its next step",shine:!0}}return null}(e,e=>({name:e,icon:n?.find(t=>t.name===e)?.icon??null})),[A,e,n]),{crew:R,more:I}=(0,v.useMemo)(()=>(function(e,t){let n=new Set(t.filter($.isUnread).map(e=>e.bot.name)),r=function(e){let t=new Map;for(let r of e){let e=new Set(r.room.questions.map(e=>e.bot));for(let a of("waiting"!==r.status||e.size||e.add(r.bot.name),r.room.participants)){var n;if(e.has(a.bot)){t.set(a.bot,{waiting:!0,word:null});continue}if(t.get(a.bot)?.waiting||"running"!==a.state&&"queued"!==a.state)continue;let s="running"===a.state?r.lines.findLast(e=>e.bot.name===a.bot&&"user"!==e.kind&&"note"!==e.kind&&"stop"!==e.kind):null;t.set(a.bot,{waiting:!1,word:(n=s??null,n?.kind==="tool"||n?.kind==="say"?eq((0,Z.stepOf)(n)):null)})}}return t}(t),a=new Map;for(let t of e??[])a.set(t.name,{name:t.name,icon:t.icon,awake:r.has(t.name),waiting:r.get(t.name)?.waiting??!1,unread:n.has(t.name),word:r.get(t.name)?.word??null});for(let[e,t]of r)a.has(e)||a.set(e,{name:e,icon:null,awake:!0,waiting:t.waiting,unread:n.has(e),word:t.word});let s=[...a.values()];if(!s.length)return{crew:eW.slice(0,3),more:0};for(let e of eW){if(s.length>=3)break;a.has(e.name)||s.push(e)}let l=e=>e.waiting?0:e.awake?1:e.unread?2:e.standIn?4:3,i=s.map((e,t)=>({face:e,at:t})).sort((e,t)=>l(e.face)-l(t.face)||e.at-t.at).map(e=>e.face);return{crew:i.slice(0,14),more:Math.max(0,i.length-14)}})(n,e),[n,e]),[D,P]=function(){let[e,t]=(0,v.useState)(new Map),n=(0,v.useRef)(new Map),r=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let e=n.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),[e,(0,v.useCallback)(e=>{e.length&&t(a=>{let s=new Map(a);for(let{bot:a,gesture:l}of e){r.current+=1,s.set(a,{gesture:l,id:r.current});let e=n.current.get(a);e&&clearTimeout(e),n.current.set(a,setTimeout(()=>{n.current.delete(a),t(e=>{let t=new Map(e);return t.delete(a),t})},q[l]+1400*("wave"===l)))}return s})},[])]}(),F=(0,v.useRef)(!1);(0,v.useEffect)(()=>{!F.current&&n?.length&&(F.current=!0,P(n.map(e=>({bot:e.name,gesture:"wave"}))))},[n,P]);let B=(0,v.useRef)(null),U=(0,v.useRef)(new Map),K=(0,v.useRef)(new Set);(0,v.useEffect)(()=>{if(!X.botThreads.primed())return;let t=B.current;B.current=new Map(e.map(e=>[e.id,e.status]));let n=U.current;U.current=function(e){let t=new Map;for(let n of e)for(let e of n.room.participants)t.set(`${n.id}
2
+ ${e.bot}`,e.state);return t}(e);let r=K.current;if(K.current=new Set(e.flatMap(e=>e.lines.map(e=>e.id))),!t)return;let a=null,s=[];for(let l of e){let{moments:e,gestures:i}=function(e,t,n,r,a){let s=e.bot,l=[];if(!t)return"working"===e.status?{moments:[{rank:1,at:s.name,from:Z.THURSDAY,to:[s],text:`took on “${eq(e.label)}”`}],gestures:[{bot:s.name,gesture:"took"}]}:{moments:[],gestures:[]};let i=[],o=e.lines.filter(e=>!n.has(e.id)),u=new Map;for(let e of o)"user"===e.kind?(e.steppedIn?l.push({bot:e.bot.name,gesture:"read"}):l.push({bot:e.bot.name,gesture:"took"}),i.push(e.steppedIn?{rank:1,at:e.bot.name,from:e.bot,to:[],text:"Step-in · read"}:{rank:1,at:e.bot.name,from:Z.THURSDAY,to:[e.bot],text:eq(e.text)})):"stop"===e.kind?(l.push({bot:e.bot.name,gesture:"stop"}),i.push({rank:3,at:e.bot.name,from:e.bot,to:[],sign:"stopped",text:(0,Z.leadOf)(e.text)})):"ask"===e.kind&&e.to?.name===Z.THURSDAY.name?(e.question&&l.push({bot:e.bot.name,gesture:"ask"}),i.push(e.question?{rank:4,at:e.bot.name,from:e.bot,to:[],sign:"question",text:`asks you \xb7 ${eq(e.text)}`}:{rank:2,at:e.bot.name,from:e.bot,to:[Z.THURSDAY],text:eq(e.text)})):"ask"===e.kind&&e.to&&u.set(e.bot.name,[...u.get(e.bot.name)??[],e]);for(let[e,t]of u){let n=new Map;for(let e of t)e.to&&n.set(e.to.name,e.to);for(let t of(l.push({bot:e,gesture:"give"}),n.values()))l.push({bot:t.name,gesture:"take"});i.push({rank:2,at:e,from:t[0].bot,to:[...n.values()],text:1===t.length?eq(t[0].text):`sent ${t.length} parts out`})}for(let t of e.roster){let n=`${e.id}
3
+ ${t.name}`;t.name===s.name||"running"!==r.get(n)||"done"!==a.get(n)||o.some(e=>e.bot.name===t.name&&("ask"===e.kind||"say"===e.kind))||(l.push({bot:t.name,gesture:"done"}),i.push({rank:1,at:t.name,from:t,to:[],sign:"done",text:"finished its part"}))}if(t===e.status)return{moments:i,gestures:l};let c=eq(e.label);return"cancelled"===e.status?(l.push({bot:s.name,gesture:"stop"}),i.push({rank:3,at:s.name,from:s,to:[],sign:"cancelled",text:`stopped \xb7 ${c}`})):"done"===e.status?l.push({bot:s.name,gesture:"done"}):"working"===e.status?o.some(e=>"user"===e.kind)||(l.push({bot:s.name,gesture:"took"}),i.push({rank:1,at:s.name,from:s,to:[],sign:"resumed",text:"picked it back up"})):(0,$.isAppStop)(e.ask)&&!i.some(e=>"question"===e.sign||"stopped"===e.sign)&&(l.push({bot:s.name,gesture:"stop"}),i.push({rank:3,at:s.name,from:s,to:[],sign:"stopped",text:"paused"})),{moments:i,gestures:l}}(l,t.get(l.id),r,n,U.current);for(let t of(s.push(...i),e))(!a||t.rank>=a.rank)&&(a=t)}a&&C(a),P(s)},[e,C,P]),(0,X.useSeenOnDetail)(a?M:null),(0,z.useAppEvent)({showThread:e=>{i(e.threadId),s(!0)}}),(0,v.useEffect)(()=>X.roomOpens.subscribe(e=>{i(e),m("now"),s(!0)}),[]);let W=e.filter(e=>"working"===e.status).length,Q=g.filter($.needsThreadReply).length,ee=(0,v.useMemo)(()=>R.map(e=>({...e,word:null})),[R]),et=()=>{s(!1),u(null),i(null),m("now"),f.current=0},en=(0,X.useCallWaits)();(0,G.useEscape)(a,()=>c?i(null):et());let er=(0,v.useRef)(et);er.current=et,(0,v.useEffect)(()=>X.writeLine.subscribe(()=>er.current()),[]);let ea=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(!c)return;let e=e=>{if("/"!==e.key||e.metaKey||e.ctrlKey||e.altKey||!(0,G.windowKey)(e))return;let t=ea.current?.querySelector("textarea:not(:disabled)");t&&(e.preventDefault(),t.focus())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c]),(0,r.jsx)("div",{className:(0,N.cn)("pointer-events-none flex min-h-0 items-end justify-end",a?"col-span-3 row-start-1 self-stretch":"col-span-3 row-start-2"),children:a?(0,r.jsxs)("div",{ref:ea,"data-room":!0,className:"pointer-events-auto flex max-h-full w-160 max-w-full animate-in flex-col overflow-hidden rounded-3xl bg-background/75 shadow-2xl shadow-black/6 ring-1 ring-border/50 backdrop-blur-xl fade-in slide-in-from-bottom-1 duration-200",children:[en&&(0,r.jsx)(e5,{onBack:et}),!M&&l&&_?(0,r.jsx)(ex,{onBack:()=>i(null),onClose:et}):M?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z.ThreadHeader,{thread:M,onBack:()=>i(null),onClose:et,onOffice:"working"===M.status||"waiting"===M.status?()=>u(M.id):void 0}),o===M.id&&(0,r.jsx)(e1,{thread:M,faces:M.roster,tab:d[M.id]??null,onTab:e=>h(t=>({...t,[M.id]:e})),onClose:()=>u(null)}),(0,r.jsx)(Z.Conversation,{thread:M,tab:d[M.id]??null,onTab:e=>h(t=>({...t,[M.id]:e})),className:"min-h-0 flex-1"}),o!==M.id&&(0,r.jsx)(H.ThreadReply,{thread:{id:M.id,label:M.label,bot:M.bot.name,ask:M.ask,room:M.room},status:"working"===M.status?"running":M.status,faces:M.roster,to:d[M.id]??M.bot.name,className:"mx-3 mb-2 shrink-0"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{tab:p,current:x.length,onTab:m,onClose:et}),"history"===p?(0,r.jsx)(eg,{pages:w,threads:S,scroll:f,onPick:i}):x.length?(0,r.jsx)(eb,{threads:x,onPick:i}):g.length?(0,r.jsx)(ef,{}):(0,r.jsx)(em,{bots:n}),(0,r.jsx)(eK,{crew:ee,more:I,bubble:null,playing:D,label:"Fold the room away",onClick:et,onWrite:X.writeLine.open,side:L?(0,r.jsx)(eX,{handoff:L}):(0,r.jsx)(eH,{busy:W,pending:Q,grown:!0})})]})]}):(0,r.jsx)(eU,{crew:R,more:I,bubble:L,playing:D,rows:t,count:e.length,busy:W,pending:Q,onPick:e=>{i(e),s(!0)},onOpen:()=>s(!0)})})});function e5({onBack:e}){return(0,r.jsxs)("button",{type:"button",onClick:e,className:"group/waits flex shrink-0 items-center gap-2.5 bg-brand/8 py-2.5 pr-3 pl-4 text-left outline-none transition-colors hover:bg-brand/12 focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-brand/14 dark:hover:bg-brand/20",children:[(0,r.jsx)(W.ThursdayMark,{size:22,className:"shrink-0"}),(0,r.jsxs)("span",{className:"min-w-0 flex-1 text-[13px] leading-5",children:[(0,r.jsx)("span",{className:"font-medium",children:"Thursday is still on the line"}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" ","— in writing. She is here when this closes."]})]}),(0,r.jsxs)("span",{className:"flex h-7 shrink-0 items-center gap-1 rounded-full px-2.5 font-medium text-[12.5px] text-brand ring-1 ring-brand/40 transition-colors group-hover/waits:bg-brand/10",children:["Back to her",(0,r.jsx)(B.ArrowRight,{className:"size-3.5"})]})]})}var e3=e.i(222055),e4=e.i(616816),e6=e.i(992112);let e7={name:"app-window-mac",size:24,node:[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]};e7.node;let e9=(0,l.default)(e7);var e8=e.i(375775);let te="thursday.install-asked",tt=null,tn=new Set,tr=()=>{for(let e of tn)e()};function ta(){return(0,v.useSyncExternalStore)(e=>(tn.add(e),()=>tn.delete(e)),()=>tt,()=>null)}async function ts(){let e=tt;e&&(tt=null,tr(),await e.prompt(),await e.userChoice.catch(()=>void 0))}function tl({hidden:e}){let t=null!==ta(),[n,a]=(0,v.useState)(!0);if((0,v.useEffect)(()=>{try{a(null!==window.localStorage.getItem(te))}catch{}},[]),!t||n||e)return null;let s=()=>{a(!0);try{window.localStorage.setItem(te,"1")}catch{}};return(0,r.jsxs)("div",{className:"flex w-76 animate-in items-start gap-3 rounded-2xl bg-background p-3.5 shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] ring-1 ring-border duration-300 fade-in slide-in-from-top-1",children:[(0,r.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-muted",children:(0,r.jsx)(e9,{className:"size-4"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-2.5",children:[(0,r.jsxs)("p",{className:"text-[13px] leading-snug",children:[(0,r.jsx)("span",{className:"block font-medium",children:"Keep her in her own window"}),(0,r.jsx)("span",{className:"block text-muted-foreground",children:"Install Thursday as an app, with its own icon. A closed tab no longer takes her calls with it."})]}),(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)(j.Button,{size:"sm",className:"rounded-full px-3.5",onClick:()=>{s(),ts()},children:"Install"}),(0,r.jsx)(j.Button,{size:"sm",variant:"ghost",className:"rounded-full px-3 text-muted-foreground",onClick:s,children:"Not now"})]})]})]})}function ti(){return null===ta()?null:(0,r.jsx)("button",{type:"button",onClick:()=>void ts(),className:"group/install flex w-full items-start gap-2.5 rounded-xl px-3 py-2.5 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1 text-sm font-medium",children:["Install app",(0,r.jsx)(e8.ArrowUpRight,{className:"ml-auto size-3.5 text-muted-foreground transition-transform group-hover/install:translate-x-px group-hover/install:-translate-y-px"})]}),(0,r.jsx)("span",{className:"block text-xs leading-snug text-muted-foreground",children:"Its own window, apart from your tabs"})]})})}window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),tt=e,tr()}),window.addEventListener("appinstalled",()=>{tt=null,tr()});let to={name:"aperture",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]};to.node;let tu=(0,l.default)(to);var tc=e.i(758925),td=e.i(218964),th=e.i(97923);let tp={name:"monitor",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]};tp.node;let tm=(0,l.default)(tp),tf={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};tf.node;let tg=(0,l.default)(tf),tx={name:"smartphone",size:24,node:[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]};tx.node;let ty=(0,l.default)(tx),tw={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};tw.node;let tb=(0,l.default)(tw);var tv=e.i(630374),tk=e.i(917162),tj=e.i(421429),tS=e.i(895836);function tN(){let{data:e}=(0,J.useServerRoute)(k.queryKey.bot);return e&&0===e.length?"waiting":null}function tT(){let{data:e}=(0,J.useServerRoute)(k.queryKey.threads);return{owed:(e??[]).filter(e=>(0,$.needsThreadReply)(e)||(0,$.isUnread)(e)).length}}var tE=e.i(36174);let t_=Object.values(tE.REACH_KEYS).flat();function tM(){let{data:e,isLoading:t}=(0,J.useServerRoute)(k.queryKey.config),n=(0,e4.useVoiceLine)();if(t)return null;let r=t=>(0,e6.isConfigSet)(e,t),a=e6.CONFIG_GROUPS.some(e=>"keys"===e.section&&!(0,e6.groupSatisfied)(e,e.id===e6.VOICE_GROUP_ID?n.countsForCall:r)),s=!!e?.some(e=>e.unreadable&&!t_.includes(e.key));return a||s?"waiting":null}let tA=e6.CONFIG_GROUPS.filter(e=>"models"===e.section).flatMap(e=>e.entries.filter(e=>e.kind).map(e=>e.key)),tC=Object.keys(e6.MEDIA_MODEL_KEYS);function tL(){let{data:e,isLoading:t}=(0,J.useServerRoute)(k.queryKey.config),{data:n}=(0,J.useServerRoute)(k.queryKey.llmModel);if(t||!e||!n)return null;let r=n.find(e=>e.signIn),a=r?.hasKey?{plan:r.plan??null}:null;return!tC.some(e=>(0,P.planMediaOf)(e,a))&&tA.every(t=>!(0,e6.isConfigSet)(e,t))?"waiting":null}function tR(){let{data:e}=(0,J.useServerRoute)(k.queryKey.mcp);return e?.some(e=>e.lastError)?"red":null}var tI=e.i(991322),tO=e.i(852116);function tD(){let{data:e}=(0,J.useServerRoute)(k.queryKey.reach),{data:t}=(0,J.useServerRoute)(k.queryKey.config),n=Object.values(tE.REACH_KEYS).flat().some(e=>(0,e6.isConfigUnreadable)(t,e));return e?.channels.some(e=>e.refused)||n?"red":null}var tP=e.i(589128);let t$=e.i(569644).FolderOpen;var tF=e.i(922521),tB=e.i(734080),tz=e.i(989409);function tq({d:e,className:t}){return(0,r.jsx)("svg",{viewBox:"-2 -2 28 28","aria-hidden":!0,className:t,children:(0,r.jsx)("path",{d:e,fill:"currentColor"})})}let tU=[{label:"Ask on Discord",href:"https://discord.gg/Qmysdh9Fy8",mark:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"},{label:"GitHub",href:"https://github.com/cgoinglove/thursday",mark:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}];function tK(){return(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:tU.map(e=>(0,r.jsxs)("a",{href:e.href,target:"_blank",rel:"noreferrer",className:(0,N.cn)((0,j.buttonVariants)({variant:"ghost"}),"justify-start text-muted-foreground"),children:[(0,r.jsx)(tq,{d:e.mark,className:"mr-1"}),(0,r.jsx)("span",{className:"truncate text-sm",children:e.label})]},e.href))})}var tH=tS;let tW=(e,t=tH.SettingSkeleton)=>(0,b.default)(e,{loading:()=>(0,r.jsx)(t,{})}),tG=tW(()=>e.A(48663).then(e=>({default:e.MemorySetting}))),tY=tW(()=>e.A(959484).then(e=>({default:e.BotSetting})),tH.SettingPanesSkeleton),tV=tW(()=>e.A(954404).then(e=>({default:e.ThreadSetting}))),tJ=tW(()=>e.A(483782).then(e=>({default:e.RoutineSetting}))),tX=tW(()=>e.A(711454).then(e=>({default:e.ModelsSetting}))),tZ=tW(()=>e.A(711454).then(e=>({default:e.KeysSetting}))),tQ=tW(()=>e.A(711454).then(e=>({default:e.PhoneSetting}))),t0=tW(()=>e.A(17613).then(e=>({default:e.ThursdaySetting}))),t1=tW(()=>e.A(706108).then(e=>({default:e.ArtifactSetting})),tH.SettingPanesSkeleton),t2=tW(()=>e.A(194379).then(e=>({default:e.WorkspaceSetting})),tH.SettingPanesSkeleton),t5=tW(()=>e.A(832663).then(e=>({default:e.SkillsSetting}))),t3=tW(()=>e.A(959108).then(e=>({default:e.McpSetting}))),t4=tW(()=>e.A(663973).then(e=>({default:e.SignInsSetting})));function t6({tabs:e}){let[t,n]=(0,v.useState)(0),a=e[t].Component;return(0,r.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,r.jsx)("div",{className:"shrink-0 px-8 pt-5",children:(0,r.jsx)(tH.SettingColumn,{children:(0,r.jsx)(tj.Segmented,{view:!0,"aria-label":"Screens of this section",options:e.map((e,t)=>({value:String(t),label:e.label})),value:String(t),onChange:e=>n(Number(e))})})}),(0,r.jsx)("div",{className:"min-h-0 flex-1",children:(0,r.jsx)(a,{})})]})}let t7=[{label:"Finished",Component:t1},{label:"All files",Component:t2}],t9=["call","work","app"],t8="px-3 pt-3 pb-1 font-mono text-[10px] text-muted-foreground/60",ne=[{id:"thursday",label:"Thursday",group:"call",hint:"Captions, models, and how a call starts",icon:W.ThursdayMark,Component:t0},{id:"memory",label:"Memory",group:"call",hint:"What Thursday remembers about you",icon:tO.MemoryMark,Component:tG},{id:"bot",label:"Bots",group:"work",hint:"Who Thursday hands work to",icon:F.BotsMark,Component:tY,Badge:function(){return tN()?(0,r.jsx)(tS.NavBadge,{tone:"waiting"}):null}},{id:"threads",label:"Threads",group:"work",hint:"Work the bots were handed",icon:td.ListChecks,Component:tV,Badge:function(){return(0,r.jsx)(tS.NavBadge,{tone:"waiting",count:tT().owed})}},{id:"routines",label:"Routines",group:"work",hint:"Work that starts by itself, on a schedule",icon:ed.RoutineMark,Component:tJ},{id:"files",label:"Files",group:"work",hint:"What the bots finished, and everything else they wrote",icon:t$,Component:()=>(0,r.jsx)(t6,{tabs:t7})},{id:"skills",label:"Skills",group:"work",hint:"Instructions the bots load on demand",icon:tP.SkillsMark,Component:t5},{id:"mcp",label:"Connectors",group:"work",hint:"Apps the bots can use, from MCP servers",icon:tI.McpMark,Component:t3,Badge:function(){return tR()?(0,r.jsx)(tS.NavBadge,{tone:"red"}):null}},{id:"signins",label:"Sign-ins",group:"work",hint:"The sites you signed in to, and the bots that may use each",icon:th.LogIn,Component:t4},{id:"models",label:"Models",group:"app",hint:"What bots think with, and what they draw, film and speak with",icon:tu,Component:tX,Badge:function(){return tL()?(0,r.jsx)(tS.NavBadge,{tone:"waiting"}):null}},{id:"keys",label:"API keys",group:"app",hint:"The accounts the app runs on",icon:tc.KeyRound,Component:tZ,Badge:function(){return tM()?(0,r.jsx)(tS.NavBadge,{tone:"waiting"}):null}},{id:"phone",label:"Phone",group:"app",hint:"Write to Thursday from a chat app",icon:ty,Component:tQ,Badge:function(){return tD()?(0,r.jsx)(tS.NavBadge,{tone:"red"}):null}}],nt={system:{label:"System",icon:tm},light:{label:"Light",icon:tb},dark:{label:"Dark",icon:tg}};function nn(){let e=(0,tF.useTheme)();return(0,r.jsx)(tj.Segmented,{"aria-label":"Theme",className:"w-full gap-0.5 *:flex-1 *:py-1.5",options:tB.THEMES.map(e=>{let{label:t,icon:n}=nt[e];return{value:e,title:t,label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n,{className:"size-3.5"}),(0,r.jsx)("span",{className:"sr-only",children:t})]})}}),value:e,onChange:tF.setTheme})}function nr({children:e}){let t=(0,tz.useSettingsStore)(e=>e.open),n=(0,tz.useSettingsStore)(e=>e.section),a=(0,tz.useSettingsStore)(e=>e.show),s=(0,tz.useSettingsStore)(e=>e.hide),l=(0,tz.useSettingsStore)(e=>e.pick),i=async e=>{let t=tz.useSettingsStore.getState().unsaved;(!t?.()||await tk.notify.discard())&&e()},o=(0,v.useRef)(null),u=ne.find(e=>e.id===n)??ne[0];return(0,v.useEffect)(()=>{if(!t)return;let e=e=>{if(!e.metaKey&&!e.ctrlKey)return;if("k"===e.key){let t=o.current?.querySelector("[data-setting-filter]");if(!t)return;e.preventDefault(),t.focus(),t.select();return}let t=Number(e.key);Number.isInteger(t)&&t>=1&&t<=ne.length&&(e.preventDefault(),i(()=>l(ne[t-1].id)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,l]),(0,r.jsxs)(tv.Dialog,{open:t,onOpenChange:e=>e?a():void i(s),children:[e&&(0,r.jsx)(tv.DialogTrigger,{render:e}),(0,r.jsxs)(tv.DialogContent,{className:"block h-[min(52rem,calc(100vh-3rem))] overflow-hidden p-0 sm:max-w-[min(80rem,calc(100vw-3rem))]",children:[(0,r.jsx)(tv.DialogTitle,{className:"sr-only",children:"Settings"}),(0,r.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,r.jsxs)("nav",{"aria-label":"Settings sections",onKeyDown:e=>{let t,r="ArrowDown"===e.key?1:"ArrowUp"===e.key?-1:0;if(!r)return;e.preventDefault();let a=(t=(ne.findIndex(e=>e.id===n)+r+ne.length)%ne.length,ne[t].id);i(()=>l(a)),e.currentTarget.querySelector(`[data-section="${a}"]`)?.focus()},className:"flex w-52 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border/60 bg-muted/30 p-3",children:[t9.map(e=>(0,r.jsxs)(v.Fragment,{children:[(0,r.jsx)("span",{className:t8,children:e}),ne.filter(t=>t.group===e).map(e=>(0,r.jsxs)(j.Button,{"data-section":e.id,onClick:()=>void i(()=>l(e.id)),variant:e.id===n?"secondary":"ghost",className:(0,N.cn)("justify-start",e.id===n?"text-foreground bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]":"text-muted-foreground"),children:[(0,r.jsx)(e.icon,{className:(0,N.cn)("mr-1")}),(0,r.jsx)("span",{className:"truncate text-sm",children:e.label}),e.Badge&&(0,r.jsx)("span",{className:"ml-auto flex items-center",children:(0,r.jsx)(e.Badge,{})})]},e.id))]},e)),(0,r.jsx)("span",{className:t8,children:"community"}),(0,r.jsx)(tK,{}),(0,r.jsxs)("div",{className:"mt-auto flex flex-col gap-2 pt-3",children:[(0,r.jsx)(ti,{}),(0,r.jsx)("div",{className:"px-1",children:(0,r.jsx)(nn,{})})]})]}),(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"shrink-0 px-8 pt-10",children:(0,r.jsxs)(tH.SettingColumn,{className:"animate-in space-y-0.5 fade-in slide-in-from-bottom-1 duration-300",children:[(0,r.jsx)("p",{className:"truncate text-2xl font-semibold",children:u.label}),(0,r.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:u.hint})]},u.id)}),(0,r.jsx)("div",{ref:o,className:"min-h-0 min-w-0 flex-1",children:(0,r.jsx)(u.Component,{})})]})]})]})]})}function na(e){return e.includes("red")?"red":e.includes("waiting")?"waiting":null}function ns(){let e=tN(),t=tT().owed>0?"waiting":null,n=tR(),r=tM();return{bot:e,threads:t,mcp:n,keys:r,models:tL(),phone:tD()}}let nl=!1,ni=new Set,no=new Set,nu={hold(e){if(e!==nl)for(let t of(nl=e,ni))t()},place(){for(let e of no)e()},onPlace:e=>(no.add(e),()=>{no.delete(e)})};function nc(){return(0,v.useSyncExternalStore)(e=>(ni.add(e),()=>ni.delete(e)),()=>nl,()=>!1)}e.s(["callSignal",0,nu,"useCallHeld",0,nc],745747);let nd=null,nh=0,np=new Set,nm=()=>{for(let e of np)e()},nf=()=>{"hidden"===document.visibilityState&&ng.clear()},ng={show:e=>!nd&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(nd={moment:e,phase:null,id:++nh},document.addEventListener("visibilitychange",nf),nm(),!0),tell(e,t){if(nd&&nd.id===e&&nd.phase!==t){if("done"===t)return ng.clear();nd={...nd,phase:t},nm()}},clear(){nd&&(nd=null,document.removeEventListener("visibilitychange",nf),nm())},current:()=>nd};function nx(){return(0,v.useSyncExternalStore)(e=>(np.add(e),()=>np.delete(e)),()=>nd,()=>null)}let ny=null,nw=null,nb=null,nv=new Set,nk=()=>{for(let e of(nb=ny?{kind:ny.kind,stream:ny.stream}:null,nv))e()};function nj(){return(0,v.useSyncExternalStore)(e=>(nv.add(e),()=>nv.delete(e)),()=>nb,()=>null)}let nS=()=>ny?.kind??null,nN=e=>"u">typeof navigator&&"function"==typeof("screen"===e?navigator.mediaDevices?.getDisplayMedia:navigator.mediaDevices?.getUserMedia);async function nT(e){let t;if(ny||nw)return;let n={wanted:!0};nw=n;try{t="screen"===e?await navigator.mediaDevices.getDisplayMedia({video:{frameRate:O.SHOWING.frameRate},audio:!1}):await navigator.mediaDevices.getUserMedia({video:{frameRate:O.SHOWING.frameRate},audio:!1})}finally{nw=null}if(!n.wanted){for(let e of t.getTracks())e.stop();return}let r=document.createElement("video");for(let e of(r.muted=!0,r.playsInline=!0,r.srcObject=t,t.getVideoTracks()))e.addEventListener("ended",()=>{ny?.stream===t&&nE()});ny={kind:e,stream:t,video:r},nk();try{await r.play()}catch(e){throw nE(),e}}function nE(){if(nw&&(nw.wanted=!1),ny){for(let e of ny.stream.getTracks())e.stop();ny.video.srcObject=null,ny=null,nk()}}async function n_(e){let t,n=ny;if(!n)return{failed:"Nothing is being shown."};let{video:r,kind:a}=n,s=await ((t=()=>!!(r.videoWidth&&r.videoHeight))()?Promise.resolve(!0):new Promise(e=>{let n=()=>{clearTimeout(a),r.removeEventListener("loadeddata",n),r.removeEventListener("resize",n),e(t())},a=setTimeout(n,O.SHOWING.firstFrameMs);r.addEventListener("loadeddata",n),r.addEventListener("resize",n)}));if(ny!==n)return{failed:"Nothing is being shown."};if(!s)return{failed:`Their ${a} has not shown anything yet.`};let l=document.createElement("canvas"),i=l.getContext("2d");if(!i)return{failed:"This browser could not take the picture."};for(let t of O.SHOWING.scales){let n=Math.min(1,O.SHOWING.longestSide*t/Math.max(r.videoWidth,r.videoHeight));for(let t of(l.width=Math.round(r.videoWidth*n),l.height=Math.round(r.videoHeight*n),i.drawImage(r,0,0,l.width,l.height),O.SHOWING.qualities)){let n=l.toDataURL("image/jpeg",t);if(n.length<=e)return{url:n,kind:a}}}return{failed:`The picture of their ${a} would not fit the ${Math.round(e/1024)} KB this connection carries.`}}var nM=e.i(218080);function nA(){let e=performance.now()/1e3;return Array.from({length:nM.SPECTRUM_BANDS},(t,n)=>.18+.16*Math.sin(e*(5+.9*n)+1.7*n)**2)}e.s(["silentVoice",0,nA],234916);var nC=e.i(671228),nL=e.i(67045),nR=e.i(297825),nI=e.i(670097),nO=e.i(640262),nD=e.i(213377),nP=e.i(95187);let n$=(0,nP.createServerReference)("7ff12b600b8e7506e13d8cda53caa05a9be2736bc7",nP.callServer,void 0,nP.findSourceMapURL,"acceptThreadRelaysAction");var nF=e.i(393080),nB=e.i(609856);let nz=new Set,nq=e=>new Set(nG(e).filter(e=>"question"!==e.kind).map(e=>e.key)),nU={message:"says",question:"asks",report:"reports",interrupted:"was cut off"},nK={question:0,stopped:1,done:2,progress:3};function nH(e){let t=(0,N.captionText)(e.replace(/!\[[^\]]*\]\([^)]*\)/g," ")).replace(N.MARKDOWN_LINK,"$1").replace(/^• /gm,"").trim();if(t.length<=O.CALL_RELAY.chars)return t;let n=t.slice(0,O.CALL_RELAY.chars),r=Math.max(n.lastIndexOf("\n\n"),n.lastIndexOf(". "),n.lastIndexOf(".\n"),n.lastIndexOf("。")),a=(r>O.CALL_RELAY.chars/3?n.slice(0,r+1):n).trim();return`${a}
4
+ [The message goes on; the rest is in its thread on screen.]`}let nW=e=>`question:${e}`;function nG(e){let t=[];for(let n of e){let{relays:e,questions:r}=n.room,a=(0,Y.toDate)(n.updatedAt).getTime(),s=(e,t)=>`[${e} → Thursday, thread "${n.label}" (${n.id}), ${t}.]`,l=(e,t)=>({kind:"relay",name:n.label,line:t,done:!0,bot:e});for(let a of r){let r=a.options?.length?` Options: ${a.options.join(" / ")}.`:"";t.push({rank:nK.question,key:nW(a.id),kind:"question",line:`${s(a.bot,"question")}
5
+ ${nH(a.text)}${r}`,relayIds:e.filter(e=>e.messageId===a.id).map(e=>e.id),threadId:n.id,text:a.text,show:l(a.bot,`${a.bot} asks`)})}let i=e.filter(e=>!r.some(t=>t.id===e.messageId)),o="done"===n.status,u="waiting"===n.status&&(0,$.isAppStop)(n.ask);if(o||u){if(n.seen)continue;let e=u?"stopped":"done",r=(u?n.ask?.question:null)??n.outcome??"",o="stopped"===e?`It stopped before finishing. Where it got to: ${nH(r)}`:`Done. Its answer: ${nH(r)}`;t.push({rank:nK[e],key:`${e}:${n.id}@${a}`,kind:"ending",line:`${s(n.bot,e)}
6
+ ${o}`,relayIds:i.map(e=>e.id),threadId:n.id,text:r,show:l(n.bot,"stopped"===e?`${n.bot} stopped`:`${n.bot} finished`)});continue}for(let e of i)t.push({rank:nK.progress,key:`progress:${e.id}`,kind:"progress",line:`${s(e.bot,e.kind)}
7
+ ${nH(e.text)}`,relayIds:[e.id],threadId:n.id,text:e.text,show:l(e.bot,`${e.bot} ${nU[e.kind]}`)})}return t.sort((e,t)=>e.rank-t.rank)}function nY(e){return"answered"===e.kind?`The user sent a message on screen to ${e.recipient??"the coordinator"} in thread "${e.label}" (${e.id})${e.replyTo?`, replying to ${e.replyTo}`:""}: ${e.answer}. It has reached that participant.`:"stopped"===e.kind?`The user stopped thread "${e.label}" on screen. It is no longer running.`:`The user put ${1===e.paths.length?"a file":`${e.paths.length} files`} down on screen, kept on this computer at ${e.paths.join(", ")}.`}let nV=(0,nP.createServerReference)("7f09c9d781b6cac74a6a3187ea7596190a55dfe796",nP.callServer,void 0,nP.findSourceMapURL,"endCallAction"),nJ=(0,nP.createServerReference)("7f84964ccea27e28ee8f9d98f1ff49efd47267d042",nP.callServer,void 0,nP.findSourceMapURL,"openTextCallAction"),nX=(0,nP.createServerReference)("7f9abaf878610c3f0c8b9e163ea68ef0058e5a15e8",nP.callServer,void 0,nP.findSourceMapURL,"tellTextCallAction");var nZ=e.i(561540);let nQ=null;async function n0(e,t){let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`${new URL(e).host} answered ${n.status}`);return n.json()}async function n1(e,t){let n=await n0(`https://api.bigdatacloud.net/data/reverse-geocode-client?${new URLSearchParams({latitude:String(e.latitude),longitude:String(e.longitude),localityLanguage:"en"})}`,t);return{name:[n.city||n.locality,n.countryName].filter(Boolean).join(", ")||null,country:/^[A-Z]{2}$/.test(n.countryCode??"")?n.countryCode:null}}async function n2(e,t){let n=e=>(Math.round(100*e)/100).toString(),r=await n0(`https://api.open-meteo.com/v1/forecast?${new URLSearchParams({latitude:n(e.latitude),longitude:n(e.longitude),current:"temperature_2m,weather_code,wind_gusts_10m",daily:"temperature_2m_max,temperature_2m_min,sunrise,sunset",timezone:"auto",forecast_days:"1"})}`,t),a=r.current.wind_gusts_10m;return{code:r.current.weather_code,temperature:r.current.temperature_2m,low:r.daily.temperature_2m_min[0],high:r.daily.temperature_2m_max[0],sunrise:r.daily.sunrise[0].slice(11,16),sunset:r.daily.sunset[0].slice(11,16),gusts:"number"==typeof a?a:null}}async function n5(e){let t=await new Promise((e,t)=>navigator.geolocation.getCurrentPosition(({coords:t})=>e(t),t,{maximumAge:O.HERE.keptMs})),[n,r]=await Promise.allSettled([n1(t,e),n2(t,e)]);for(let[e,t]of[["place",n],["weather",r]])"rejected"===t.status&&console.warn(`No ${e} for the call: ${(0,N.errorToString)(t.reason)}`);let a="fulfilled"===n.status?n.value:null,s={place:a?.name??null,weather:"fulfilled"===r.status?r.value:null};return s.place||s.weather?{where:s,position:{lat:t.latitude,lon:t.longitude},country:a?.country??null}:null}async function n3(){if(nQ&&Date.now()-nQ.at<O.HERE.keptMs)return nQ.found;if(!navigator.geolocation)return null;let e=new AbortController,t=setTimeout(()=>e.abort(),O.HERE.waitMs);try{let t=await Promise.race([n5(e.signal),new Promise(t=>e.signal.addEventListener("abort",()=>t(null)))]);return t&&(nQ={found:t,at:Date.now()}),t}catch(e){return e?.code!==1&&console.warn(`No position for the call: ${(0,N.errorToString)(e)}`),null}finally{clearTimeout(t)}}let n4=new nO.DefaultChatTransport({api:k.queryKey.textCall}),n6=()=>nL.useThursdayStore.getState().textModel,n7=e=>({type:`data-${nC.TEXT_CALL_NOTE}`,id:e.id,data:e});async function n9(e,t,n,r){try{let a=await fetch(k.queryKey.toolCall,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolCallId:t.id,callId:e,...n,name:t.name,input:t.arguments?JSON.parse(t.arguments):{}}),signal:r}),{output:s}=(0,nF.unwrapResult)(await a.json());return"string"==typeof s?s:JSON.stringify(s??null)}catch(e){return`Error: ${(0,N.errorToString)(e)}`}}var n8=e.i(233771),re=e.i(807038),rt=e.i(83928),rn=e.i(616172),rr=e.i(621285);function ra(){return(0,r.jsx)(rr.FileViewer,{children:(0,r.jsx)(rh,{})})}let rs={2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},rl="thursday.corner-dismissed";function ri(){try{let e=JSON.parse(window.localStorage.getItem(rl)??"[]");return Array.isArray(e)?e:[]}catch{return[]}}function ro(e){try{let t=[...e,...ri().filter(t=>!e.includes(t))].slice(0,50);window.localStorage.setItem(rl,JSON.stringify(t))}catch{}}function ru(){"u"<typeof Notification||"default"===Notification.permission&&Notification.requestPermission().catch(()=>void 0)}function rc(e){return{threadId:e.id,label:e.label,bot:e.bot.name,words:(0,N.plainText)(e.outcome??"").slice(0,O.FINISHED_NOTICE.words),paths:(0,rn.leadFirst)((0,rn.pathsIn)(e.outcome??"")),unchecked:!0}}function rd({row:e,children:t}){let n=e.unchecked&&e.paths.length>0,{data:r}=(0,J.useServerRoute)(n?k.queryKey.workspaceFiles(e.paths):null);if(!n)return t(e);if(!r)return null;let a=new Set(r.map(e=>e.path));return t({...e,paths:(0,rn.leadFirst)(e.paths.filter(e=>a.has(e)))})}function rh(){let[e,t]=(0,v.useState)([]),{data:n}=(0,J.useServerRoute)(k.queryKey.bot),a=(0,X.useBotThreads)(),s=(0,rr.useOpenFile)();(0,v.useEffect)(()=>X.fileOpens.subscribe(e=>{s(e)}),[s]),(0,z.useAppEvent)({showFile:e=>s(e.paths[0],e.paths.filter(e=>"image"===(0,rn.viewKindOf)(e)),!0),finished:e=>{!function(e,t,n){if(!("u"<typeof Notification)&&"granted"===Notification.permission&&!("visible"===document.visibilityState&&document.hasFocus()))try{let r=new Notification(t,{body:n,tag:e,icon:"/icon.svg"});r.onclick=()=>{window.focus(),r.close()}}catch{}}(e.threadId,e.label,e.words),t(t=>[{threadId:e.threadId,label:e.label,bot:e.bot,words:e.words,paths:e.paths},...t.filter(t=>t.threadId!==e.threadId)].slice(0,O.FINISHED_NOTICE.rows))}});let l=(0,v.useRef)(new Set);(0,v.useEffect)(()=>{if(!X.botThreads.primed())return;for(let e of a)("done"===e.status||"cancelled"===e.status)&&l.current.add(e.id);let e=new Set(ri()),n=a.filter(t=>(0,$.isUnread)(t)&&!e.has(t.id)).sort((e,t)=>(0,Y.toDate)(t.updatedAt).getTime()-(0,Y.toDate)(e.updatedAt).getTime()),r=new Set(n.map(e=>e.id));t(e=>{let t=e.filter(e=>!l.current.has(e.threadId)||r.has(e.threadId)),a=[...n.filter(e=>!t.some(t=>t.threadId===e.id)).map(rc),...t].slice(0,O.FINISHED_NOTICE.rows);return a.length===e.length&&a.every((t,n)=>t.threadId===e[n].threadId)?e:a})},[a]);let i=e=>{ro([e]),t(t=>t.filter(t=>t.threadId!==e))};if(!e.length)return null;let o=e.slice(0,O.FINISHED_NOTICE.shown),u=e.slice(O.FINISHED_NOTICE.shown),c=e=>{ro(e),t(t=>t.filter(t=>!e.includes(t.threadId))),(0,n8.markSeenAction)(e).then(nF.unwrapResult).then(()=>(0,J.revalidate)(k.queryKey.threads)).catch(t=>R.toast.add({type:"error",title:e.length>1?"Could not mark the threads as read":"Could not mark the thread as read",description:(0,N.errorToString)(t)}))};return(0,r.jsx)("div",{className:"pointer-events-none relative col-start-1 row-start-2 w-82 max-w-full",children:(0,r.jsxs)("div",{className:"pointer-events-auto absolute bottom-0 left-0 -m-2 flex max-h-[80vh] w-82 max-w-full flex-col-reverse gap-2 overflow-y-auto p-2 scrollbar-none",children:[o.map(e=>(0,r.jsx)(rd,{row:e,children:e=>(0,r.jsx)(rm,{row:e,bot:n?.find(t=>t.name===e.bot),onOpen:t=>{t?(s(t,e.paths.filter(e=>"image"===(0,rn.viewKindOf)(e)),!1,e.threadId),c([e.threadId])):(X.roomOpens.open(e.threadId),i(e.threadId))},onClose:()=>i(e.threadId)})},e.threadId)),u.map(e=>(0,r.jsx)(rd,{row:e,children:e=>(0,r.jsx)(rp,{row:e,bot:n?.find(t=>t.name===e.bot),onOpen:()=>{X.roomOpens.open(e.threadId),i(e.threadId)},onClose:()=>i(e.threadId)})},e.threadId)),e.length>1&&(0,r.jsxs)("p",{className:"flex shrink-0 items-center gap-2 px-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,r.jsxs)("span",{children:[e.length," new"]}),(0,r.jsx)("span",{className:"flex-1"}),(0,r.jsx)("button",{type:"button",onClick:()=>c(e.map(e=>e.threadId)),className:"rounded-md px-1 font-sans text-[11px] outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:"Clear all"})]})]})})}function rp({row:e,bot:t,onOpen:n,onClose:a}){let s=e.paths.length-3;return(0,r.jsxs)("div",{className:"flex shrink-0 animate-in items-center gap-2 rounded-2xl bg-background py-1.5 pr-1.5 pl-2.5 shadow-black/8 shadow-md ring-1 ring-border fade-in slide-in-from-bottom-1 duration-300",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(F.BotMark,{size:18,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1,className:"shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] leading-5",children:e.label}),e.paths.length>0&&(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[e.paths.slice(0,3).map(e=>(0,r.jsx)(rt.FileThumb,{path:e,glyph:"size-2.5",className:"size-5 rounded-[6px] ring-1 ring-border"},e)),s>0&&(0,r.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",s]})]})]}),(0,r.jsx)(j.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:a,className:"shrink-0 text-muted-foreground",children:(0,r.jsx)(w.X,{})})]})}function rm({row:e,bot:t,onOpen:n,onClose:a}){let s,l=(s=e.paths.length)<=2?2:3===s?3:4,i=e.paths.slice(0,l),o=e.paths.length-i.length;return(0,r.jsxs)("div",{className:"flex shrink-0 animate-in gap-2.5 rounded-[20px] bg-background py-2.5 pr-2 pl-2.5 shadow-black/10 shadow-lg ring-1 ring-border fade-in slide-in-from-bottom-2 duration-300",children:[(0,r.jsx)(F.BotMark,{size:32,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1,className:"shrink-0"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e.paths[0]??null),className:"flex min-w-0 flex-1 flex-col gap-1.5 rounded-lg text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsxs)("span",{className:"flex min-h-8 flex-col justify-center",children:[(0,r.jsx)("span",{className:"truncate font-medium text-[14px] leading-5 tracking-[-0.15px]",children:e.label}),(0,r.jsx)("span",{className:"truncate font-mono text-[10px] leading-[13px] text-muted-foreground",children:e.bot})]}),e.words&&(0,r.jsx)("span",{className:"line-clamp-2 break-keep wrap-anywhere text-[12.5px] leading-normal text-muted-foreground",children:(0,re.shortenPaths)(e.words)})]}),(0,r.jsx)(j.Button,{variant:"ghost",size:"icon-sm","aria-label":"Dismiss",onClick:a,className:"shrink-0 text-muted-foreground",children:(0,r.jsx)(w.X,{})})]}),i.length>0&&(0,r.jsx)("div",{className:(0,N.cn)("grid gap-1.5 pt-0.5",rs[l]),children:i.map((e,t)=>(0,r.jsxs)("button",{type:"button",title:e.split("/").pop(),onClick:()=>n(e),className:"relative rounded-[10px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)(rt.FileThumb,{path:e,glyph:2===l?"size-6":"size-4",className:"aspect-square w-full rounded-[10px] ring-1 ring-border"}),o>0&&t===i.length-1&&(0,r.jsxs)("span",{className:"absolute inset-0 grid place-items-center rounded-[10px] bg-black/45 font-medium text-[14px] text-white",children:["+",o]})]},e))})]})]})}e.s(["ArtifactView",0,ra,"FinishedCard",0,rm,"askToNotify",0,ru],895499);let rf={"not-allowed":"The microphone is not allowed","service-not-allowed":"The microphone is not allowed","audio-capture":"There is no microphone","language-not-supported":"This browser cannot listen in that language"},rg=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,"").split(/\s+/).filter(Boolean),rx=(e,t,n)=>Math.abs(e.length-t.length)<=n&&function(e,t){let n=Array.from({length:e.length+1},(e,t)=>t),r=Array(e.length+1).fill(0);for(let a=1;a<=t.length;a++){r[0]=a;for(let s=1;s<=e.length;s++){let l=n[s-1]+ +(t[a-1]!==e[s-1]);r[s]=Math.min(l,n[s]+1,r[s-1]+1)}[n,r]=[r,n]}return n[e.length]}(e,t)<=n;function ry({enabled:e,onWake:t,phrases:n,onError:r}){let a=(0,v.useRef)({onWake:t,onError:r,phrases:n});a.current={onWake:t,onError:r,phrases:n},(0,v.useEffect)(()=>{if(!e)return;let t=window,n=t.SpeechRecognition??t.webkitSpeechRecognition;if(!n)return void a.current.onError?.("This browser cannot listen for a wake word");let r=new n,s=!0,l=!0,i=null,o=300;r.lang="en-US",r.continuous=!0,r.interimResults=!0,r.maxAlternatives=3;let u=()=>{if(s){l=!0;try{r.start()}catch{}}};return r.onresult=({resultIndex:e,results:t})=>{if(!s||!l)return;o=300;let{phrases:n,onWake:i}=a.current,u=n.map(rg).filter(e=>e.length);for(let n=e;n<t.length;n++){let e=t[n];for(let t=0;t<e.length;t++){let n=e[t].transcript,a=rg(n);if(u.some(e=>(function(e,t,n){for(let r=0;r<e.length;r++)if(function e(t,n,r,a,s){if(a===r.length)return!0;if(n>=t.length)return!1;let l=r[a],i=Math.max(1,Math.round(l.length*s));return!!(rx(t[n],l,i)&&e(t,n+1,r,a+1,s))||n+1<t.length&&rx(t[n]+t[n+1],l,i)&&e(t,n+2,r,a+1,s)}(e,r,t,0,n))return!0;return!1})(a,e,O.WAKE_TOLERANCE))){l=!1,r.abort(),i(n.trim());return}}}},r.onerror=({error:e})=>{let t=rf[e];t?(s=!1,a.current.onError?.(t)):"network"===e&&(o=Math.min(2*o,1e4))},r.onend=()=>{s&&(i=setTimeout(u,o))},u(),()=>{s=!1,i&&clearTimeout(i),r.onresult=null,r.onerror=null,r.onend=null,r.abort()}},[e])}e.s(["useWakeWord",0,ry],656572);let rw={silent:{level:-1},fatal:{level:0},error:{level:0},warn:{level:1},log:{level:2},info:{level:3},success:{level:3},fail:{level:3},ready:{level:3},start:{level:3},box:{level:3},debug:{level:4},trace:{level:5},verbose:{level:1/0}};function rb(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.iterator in e)&&(!(Symbol.toStringTag in e)||"[object Module]"===Object.prototype.toString.call(e))}let rv=!1,rk=[];class rj{options;_lastLog;_mockFn;constructor(e={}){const t=e.types||rw;for(const n in this.options=((...e)=>e.reduce((e,t)=>(function e(t,n,r=".",a){if(!rb(n))return e(t,{},r,a);let s=Object.assign({},n);for(let n in t){if("__proto__"===n||"constructor"===n)continue;let l=t[n];null!=l&&(a&&a(s,n,l,r)||(Array.isArray(l)&&Array.isArray(s[n])?s[n]=[...l,...s[n]]:rb(l)&&rb(s[n])?s[n]=e(l,s[n],(r?`${r}.`:"")+n.toString(),a):s[n]=l))}return s})(e,t,"",void 0),{}))({...e,defaults:{...e.defaults},level:rS(e.level,t),reporters:[...e.reporters||[]]},{types:rw,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}}),t){const e={type:n,...this.options.defaults,...t[n]};this[n]=this._wrapLogFn(e),this[n].raw=this._wrapLogFn(e,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=rS(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(e,t)}create(e){let t=new rj({...this.options,...e});return this._mockFn&&t.mockTypes(this._mockFn),t}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(-1!==t)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(e,t){e&&(e.__write||(e.__write=e.write),e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){rv=!0}resumeLogs(){for(let e of(rv=!1,rk.splice(0)))e[0]._logFn(e[1],e[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,"function"==typeof t)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>rv?void rk.push([this,e,n,t]):this._logFn(e,n,t)}_logFn(e,t,n){var r,a;if((e.level||0)>this.level)return!1;let s={date:new Date,args:[],...e,level:rS(e.level,this.options.types)};n||1!==t.length||+(a=r=t[0],"[object Object]"!==Object.prototype.toString.call(a)||!r.message&&!r.args||!!r.stack)?s.args=[...t]:Object.assign(s,t[0]),s.message&&(s.args.unshift(s.message),delete s.message),s.additional&&(Array.isArray(s.additional)||(s.additional=s.additional.split("\n")),s.args.push("\n"+s.additional.join("\n")),delete s.additional),s.type="string"==typeof s.type?s.type.toLowerCase():"log",s.tag="string"==typeof s.tag?s.tag:"";let l=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=s,this._log(s))};clearTimeout(this._lastLog.timeout);let i=this._lastLog.time&&s.date?s.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=s.date,i<this.options.throttle)try{let e=JSON.stringify([s.type,s.tag,s.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(l,this.options.throttle);return}}catch{}l(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}}function rS(e,t={},n=3){return void 0===e?n:"number"==typeof e?e:t[e]&&void 0!==t[e].level?t[e].level:n}rj.prototype.add=rj.prototype.addReporter,rj.prototype.remove=rj.prototype.removeReporter,rj.prototype.clear=rj.prototype.removeReporter,rj.prototype.withScope=rj.prototype.withTag,rj.prototype.mock=rj.prototype.mockTypes,rj.prototype.pause=rj.prototype.pauseLogs,rj.prototype.resume=rj.prototype.resumeLogs;class rN{options;defaultColor;levelColorMap;typeColorMap;constructor(e){this.options={...e},this.defaultColor="#7f8c8d",this.levelColorMap={0:"#c0392b",1:"#f39c12",3:"#00BCD4"},this.typeColorMap={success:"#2ecc71"}}_getLogFn(e){return e<1?console.__error||console.error:1===e?console.__warn||console.warn:console.__log||console.log}log(e){let t=this._getLogFn(e.level),n="log"===e.type?"":e.type,r=e.tag||"",a=this.typeColorMap[e.type]||this.levelColorMap[e.level]||this.defaultColor,s=`
8
+ background: ${a};
9
+ border-radius: 0.5em;
10
+ color: white;
11
+ font-weight: bold;
12
+ padding: 2px 0.5em;
13
+ `,l=`%c${[r,n].filter(Boolean).join(":")}`;"string"==typeof e.args[0]?t(`${l}%c ${e.args[0]}`,s,"",...e.args.slice(1)):t(l,s,...e.args)}}function rT(e={}){return function(e={}){return new rj(e)}({reporters:e.reporters||[new rN({})],prompt:(e,t={})=>"confirm"===t.type?Promise.resolve(confirm(e)):Promise.resolve(prompt(e)),...e})}rT();var rE=e.i(247167),r_=e.i(379227);let{env:rM={},argv:rA=[],platform:rC=""}=void 0===rE.default?{}:rE.default,rL="NO_COLOR"in rM||rA.includes("--no-color"),rR="FORCE_COLOR"in rM||rA.includes("--color"),rI="dumb"===rM.TERM,rO=r_&&r_.isatty&&r_.isatty(1)&&rM.TERM&&!rI,rD="CI"in rM&&("GITHUB_ACTIONS"in rM||"GITLAB_CI"in rM||"CIRCLECI"in rM),rP=!rL&&(rR||"win32"===rC&&!rI||rO||rD);function r$(e,t,n){return function(e,t,n=e,r=e.length+1){return a=>{var s;return a||""!==a&&void 0!==a?(s=(""+a).indexOf(t,r),s<0?e+a+t:e+function e(t,n,r,a,s=n.slice(0,Math.max(0,t))+a,l=n.slice(Math.max(0,t+r.length)),i=l.indexOf(r)){return s+(i<0?l:e(i,l,r,a))}(s,a,t,n)+t):""}}(`\x1b[${e}m`,`\x1b[${t}m`,n)}let rF={reset:r$(0,0),bold:r$(1,22,"\x1b[22m\x1b[1m"),dim:r$(2,22,"\x1b[22m\x1b[2m"),italic:r$(3,23),underline:r$(4,24),inverse:r$(7,27),hidden:r$(8,28),strikethrough:r$(9,29),black:r$(30,39),red:r$(31,39),green:r$(32,39),yellow:r$(33,39),blue:r$(34,39),magenta:r$(35,39),cyan:r$(36,39),white:r$(37,39),gray:r$(90,39),bgBlack:r$(40,49),bgRed:r$(41,49),bgGreen:r$(42,49),bgYellow:r$(43,49),bgBlue:r$(44,49),bgMagenta:r$(45,49),bgCyan:r$(46,49),bgWhite:r$(47,49),blackBright:r$(90,39),redBright:r$(91,39),greenBright:r$(92,39),yellowBright:r$(93,39),blueBright:r$(94,39),magentaBright:r$(95,39),cyanBright:r$(96,39),whiteBright:r$(97,39),bgBlackBright:r$(100,49),bgRedBright:r$(101,49),bgGreenBright:r$(102,49),bgYellowBright:r$(103,49),bgBlueBright:r$(104,49),bgMagentaBright:r$(105,49),bgCyanBright:r$(106,49),bgWhiteBright:r$(107,49)},rB=function(e=rP){return e?rF:Object.fromEntries(Object.keys(rF).map(e=>[e,String]))}();[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");let rz=rT({level:O.IS_DEV?4:3}),rq=(t=O.APP_NAME,rz.withDefaults({message:(n=`${t}: `,(function(e,t="reset"){return rB[e]||rB[t]})("blackBright")(n))}));var rU=e.i(413168);let rK={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},rH=new TextEncoder;async function rW(e){let t=rY(e);try{return await t.connect(),t}catch(e){throw await t.close(),e}}let rG=["response.completed","response.failed","response.incomplete","response.cancelled"],rY=({initialize:e,audio:t,on:n})=>{let r,a,s,l,i,o,u,c,d,h=!1,p=!1,m=!1,f=0,g=0,x="",y=[],w=new Set,b=new Set,v=new Set,k=new Map,j=!1,S=new Map,T=new Map,E=[],_=null,M=-1/0,A=null,C=()=>{clearTimeout(d),!A||A.unmute||m||p||(A.unmute=crypto.randomUUID(),U.send({type:"session.input_audio.unmute",event_id:A.unmute}))},L=()=>{for(let e of(clearTimeout(u),u=void 0,w))n.turn({...e.turn,fragments:[...e.fragments],done:!0});w.clear()},R=()=>{if(!m){for(let e of(m=!0,clearTimeout(i),clearTimeout(c),clearTimeout(d),clearInterval(o),L(),_=null,E.splice(0)))e.settle(!1);U.close(),s?.()}},I=e=>{a?.(Error(e)),R(),h&&!p?n.failed(e):p&&n.warn(e)},D=-1/0,P=()=>{if(m||p)return;let e=performance.now(),r=t.levels?.();r&&r.output>.01&&(M=e);let a={speaking:e-M<300,working:[...k.values()].some(e=>!e.terminal)||T.size>0||e-D<5e3,tools:[...T.values()]},s=JSON.stringify(a);(s!==x||a.speaking||a.working)&&(x=s,n.activity(a))},$=()=>{if(!h||m||p||_||!E.length)return;let[e]=E;_=crypto.randomUUID(),U.send({type:`session.${e.kind}.append`,event_id:_,delegation_id:null,content:e.chunks[0]}),c=setTimeout(()=>{n.warn("Live did not acknowledge the conversation update; delivery is unknown."),F(!1)},O.LIVE_CALL.appendMs)},F=e=>{clearTimeout(c),_=null;let[t]=E;t&&(e&&t.chunks.shift(),e&&t.chunks.length||(E.shift(),t.settle(e)),$())},B=(e,t)=>{if(!e.delta||void 0===e.start_ms||void 0===e.end_ms)return;let r=e.start_ms,a=e.end_ms,s=y.findLast(e=>e.turn.role===t&&r>=e.turn.seq-O.LIVE_CALL.transcriptGapMs&&r<=e.end+O.LIVE_CALL.transcriptGapMs&&("user"===t||!y.some(t=>"user"===t.turn.role&&t.turn.seq>e.turn.seq&&t.turn.seq<r)));s||(s={turn:{id:`live-${g++}`,role:t,text:"",seq:r,done:!1},end:a,fragments:[]},y.push(s)),s.fragments.push({start:r,end:a,text:e.delta}),s.fragments.sort((e,t)=>e.start-t.start),s.end=Math.max(s.end,a),s.turn.text=s.fragments.map(e=>e.text).join(""),n.turn({...s.turn,done:!1}),w.add(s),u??=setTimeout(L,O.LIVE_CALL.transcriptSaveMs)},z=async e=>{if(e.terminal&&!e.continued&&e.calls.size){if(e.continued=!0,await Promise.all(e.calls.values()),!p&&!m){for(let t of e.images.splice(0))q(t);D=performance.now(),U.send({type:"response.create",event_id:crypto.randomUUID()})}P()}},q=e=>{try{U.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"user",content:[{type:"input_image",image_url:e}]}})}catch(r){let t=(0,N.errorToString)(r);rq.warn("Live picture not sent",{reason:t,bytes:e.length}),U.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"developer",content:[{type:"input_text",text:`The picture of what they show did not go through, so nothing on it was seen: ${t}`}]}}),n.warn(`The picture of what you show did not go through: ${t}`)}},U=function({negotiate:e,audio:t,on:n}){let r,a,s,l=null,i=null,o=null,u=!1,c=!1,d=!1,h=null,p=null,m=!1,f=Promise.resolve(),g=!1,x=e=>{for(let t of e?.getTracks()??[])t.stop()},y=e=>{u||d||(d=!0,c?n.dropped(e):a?.(Error(e)))},w=()=>{!c&&g&&(!h||m)&&(c=!0,r?.())};return{async connect(){let c=new RTCPeerConnection;l=c;let d=c.createDataChannel("oai-events");i=d;let f=new Promise((e,t)=>{r=e,a=t});d.onopen=()=>{g=!0,w()},d.onclose=()=>y("The connection to OpenAI Live closed."),d.onerror=()=>y("The connection to OpenAI Live dropped."),c.onconnectionstatechange=()=>{["failed","closed"].includes(c.connectionState)&&y("Could not reach OpenAI Live.")},f.catch(()=>{}),d.onmessage=({data:e})=>{let t;if(!u&&!h&&"string"==typeof e){try{t=JSON.parse(e)}catch{n.dropped("OpenAI Live sent an unreadable event.");return}n.event(t)}},c.ontrack=e=>{if(u)return;let n=e.streams[0]??new MediaStream([e.track]);t.element.srcObject=n,t.listen(n)};let b=await navigator.mediaDevices.getUserMedia({audio:rK});if(u)throw x(b),Error("The call closed before connecting.");for(let e of(o=b,t.hear?.(b),b.getAudioTracks()))c.addTrack(e,b);await c.setLocalDescription(await c.createOffer()),"complete"!==c.iceGatheringState&&await new Promise((e,t)=>{let n=n=>{clearTimeout(a),c.removeEventListener("icegatheringstatechange",r),s=void 0,n?t(n):e()},r=()=>{"complete"===c.iceGatheringState&&n()},a=setTimeout(()=>n(Error("ICE gathering timed out.")),1e4);s=()=>n(Error("The call closed before connecting.")),c.addEventListener("icegatheringstatechange",r),r()});let v=c.localDescription?.sdp;if(!v||u)throw Error("No live SDP offer is available.");let k=await e(v);if(u)throw Error("The call closed before connecting.");if("string"!=typeof k){let e;h=k.relay,await (e=h,new Promise((t,r)=>{let a=new EventSource(e);p=a,a.onopen=()=>t(),a.onmessage=({data:e})=>{let t;if(!u&&"string"==typeof e){try{t=JSON.parse(e)}catch{n.dropped("The call on the plan sent an unreadable event.");return}n.event(t)}},a.onerror=()=>{a.close(),r(Error("Could not follow the call on the plan.")),y("The line to her on the plan dropped.")}})),m=!0}await c.setRemoteDescription({type:"answer",sdp:"string"==typeof k?k:k.sdp}),w(),await f},send(e){if(!u){if(h){let t=h;f=f.then(async()=>{let n=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:[e]})}),r=await n.json().catch(()=>null);if(!n.ok||!(0,nF.isResultOk)(r))throw Error((0,nF.isResultError)(r)&&r.message||`${n.status}`)}).catch(e=>{y(`The call on the plan did not take what was sent: ${e instanceof Error?e.message:String(e)}`)});return}i?.readyState==="open"&&i.send(JSON.stringify(e))}},limit:()=>h?O.PLAN_CALL.pictureBytes:l?.sctp?.maxMessageSize??null,relayed:()=>null!==h,close:()=>{u||(u=!0,a?.(Error("The call closed before connecting.")),s?.(),x(o),o=null,p?.close(),i?.close(),l?.close(),t.element.srcObject=null)}}}({audio:t,negotiate:async t=>{let n=await e(t);if(!("string"==typeof n?n:n.sdp))throw Error("OpenAI Live returned no SDP answer.");return n},on:{event:e=>{if(!m){if(e.event_id){if(b.has(e.event_id))return;b.add(e.event_id)}switch(f=Math.max(f,e.offset_ms??0,e.end_ms??0),e.type){case"session.started":h=!0,r?.(),$();break;case"session.closed":n.finalized?.({reason:e.reason??"closed",seconds:e.usage?.seconds??null}),rq.info("Live session closed",{reason:e.reason,seconds:e.usage?.seconds}),a?.(Error("OpenAI Live closed before startup completed.")),R(),p||n.failed(`The Live call ended (${e.reason??"closed"}).`);break;case"session.input_transcript.delta":B(e,"user");break;case"session.output_transcript.delta":C(),B(e,"assistant");break;case"session.input_audio.unmuted":A&&e.client_event_id===A.unmute&&(A=null);break;case"session.instructions.appended":case"session.commentary.appended":case"session.thinking.appended":_&&e.client_event_id===_&&F(!0);break;case"error":{let t=e.error?.message??"OpenAI Live reported an error.";if(!h){I(t);break}if(A?.unmute&&e.error?.client_event_id===A.unmute){I(`She could not hear the microphone again: ${t}`);break}for(let r of(A&&e.error?.client_event_id===A.mute&&(clearTimeout(d),A=null),n.warn(t),_&&e.error?.client_event_id===_&&F(!1),k.values()))r.terminal||r.calls.size||(r.terminal=!0,r.stale=!0);P();break}case"response.event":{let t=e.event;if(!t||p)break;"response.created"===t.type&&(D=-1/0),"response.created"===t.type&&t.response&&e.delegation_id&&S.set(e.delegation_id,t.response.id);let r=t.response?.id??t.response_id??(e.delegation_id?S.get(e.delegation_id):void 0);if(!r)break;let a=k.get(r);if(a||(a={calls:new Map,images:[],terminal:!1,continued:!1},k.set(r,a)),a.stale&&!rG.includes(t.type)&&(a.stale=!1,a.terminal=!1),"response.reasoning_summary_text.done"===t.type&&n.reasoning?.({id:`${t.item_id}:${t.summary_index??0}`,text:t.text??"",seq:f}),("response.output_item.added"===t.type||"response.output_item.done"===t.type)&&t.item?.type===rU.LIVE_HOSTED_TOOLS.webSearch.item){let e=t.item,a="response.output_item.done"===t.type;a&&rq.debug("Live web search",e),n.search?.({id:e.id,responseId:r,query:(e.action?.query??e.action?.queries?.join(" · "))?.trim()||null,sources:[...new Set((e.action?.sources??[]).flatMap(e=>e.url?[e.url]:[]))].map(e=>({url:e})),done:a,seq:f})}if("response.output_item.done"===t.type&&t.item?.type==="message"){let e=function(e){let t=new Map;for(let n of e??[])for(let e of n.annotations??[])"url_citation"===e.type&&e.url&&!t.has(e.url)&&t.set(e.url,{url:e.url,...e.title?{title:e.title}:{}});return[...t.values()]}(t.item.content);e.length&&n.cited?.(r,e)}if("response.output_item.done"===t.type&&t.item?.type==="function_call"){let e=t.item;if(v.has(e.call_id))break;if(v.add(e.call_id),"incomplete"===e.status){a.terminal=!0,rq.warn("Live backend call cut off; not run",{responseId:r,name:e.name,arguments:e.arguments.slice(0,200)}),a.calls.size&&!j?(j=!0,z(a)):a.continued=!0;break}n.turn({id:e.id,role:"tool",tool:e.name,text:e.arguments,seq:f,done:!0}),L(),T.set(e.call_id,e.name);let s=Promise.resolve().then(()=>n.runTool({id:e.call_id,name:e.name,arguments:e.arguments,item:e.id})).catch(e=>`Error: ${(0,N.errorToString)(e)}`).then(t=>{T.delete(e.call_id);let{output:n,image:r}="string"==typeof t?{output:t}:t;m||p||(U.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"function_call_output",call_id:e.call_id,output:n}}),r&&a.images.push(r)),P()});a.calls.set(e.call_id,s),z(a)}rG.includes(t.type)&&(a.terminal=!0,a.stale=!1,"response.completed"===t.type?(j=!1,rq.debug("Live backend usage",{responseId:r,usage:t.response?.usage}),z(a)):"response.incomplete"===t.type&&a.calls.size&&!j?(j=!0,rq.warn("Live backend response incomplete; continuing once",{responseId:r}),z(a)):(j=!1,a.continued=!0,n.warn(t.response?.error?.message??`The Live backend ${t.type.slice(9)}.`)))}}P()}},dropped:I}});return{async connect(){t.element.muted=!1;let e=new Promise((e,t)=>{r=e,a=t});e.catch(()=>{});let n=setTimeout(()=>I("OpenAI Live did not start in time."),O.LIVE_CALL.startupMs);try{if(await Promise.all([U.connect(),e]),m)throw Error("The Live call closed during startup.");o=setInterval(P,100)}catch(e){throw R(),e}finally{clearTimeout(n),a=void 0}},close:()=>l||(m?Promise.resolve():(p=!0,L(),h)?(l=new Promise(e=>{s=e}),i=setTimeout(()=>{n.warn("Live disconnected without confirming final session usage."),R()},O.LIVE_CALL.closeMs),t.element.muted=!0,U.send({type:"session.close",event_id:crypto.randomUUID()}),l):(R(),Promise.resolve())),append(e,t){let n=function(e){let t=[],n="",r=0,a=e=>{let a=rH.encode(e).length;if(r+a>480&&n&&(t.push(n),n="",r=0),a<=480){n+=e,r+=a;return}for(let a of e){let e=rH.encode(a).length;r+e>480&&(t.push(n),n="",r=0),n+=a,r+=e}};for(let t of e.split(/(?<=\s)/))a(t);return n&&t.push(n),t}(t);return m||p||!n.length?Promise.resolve(!1):new Promise(t=>{E.push({kind:e,chunks:n,settle:t}),$()})},holdInput(e){U.relayed()||!h||m||p||A||e<=0||(A={mute:crypto.randomUUID(),unmute:null},U.send({type:"session.input_audio.mute",event_id:A.mute}),d=setTimeout(C,e))},messageLimit:()=>U.limit(),brief(e){let t=e.trim();m||p||!t||U.send({type:"response.item.create",event_id:crypto.randomUUID(),item:{type:"message",role:"developer",content:[{type:"input_text",text:t}]}})}}};var rV=e.i(567334);let rJ=["NIGHT","G'NIGHT","NITE","SLEEP ♥","ZZZ","BYE"],rX=[[22,rJ],[17,["BYE","SEE YA","LATER","SO LONG","BYE ♥","CIAO"]],[11,["BYE","SEE YA","LATER","CIAO","BYE BYE","PEACE"]],[5,["ENJOY!","SEE YA","BYE","LATER","CIAO"]],[0,rJ]],rZ=(e,t)=>({text:e,at:Date.now(),hold:t});function rQ(e=new Date){let t,n=e.getHours();return rZ((t=rX.find(([e])=>n>=e)?.[1]??["BYE"])[Math.floor(Math.random()*t.length)],1.6)}let r0=()=>rZ("OK",1);e.s(["awake",0,()=>rZ("HI",1.6),"finished",0,r0,"goodbye",0,rQ],114923);let r1="thursday.here.shown",r2=e=>(0,Q.format)(e,"yyyy-MM-dd"),r5=null;var r3=e.i(183414);let r4=(0,nP.createServerReference)("7f86bd55242f0809f4dd59ee78327f2958cb445ee8",nP.callServer,void 0,nP.findSourceMapURL,"openCallAction"),r6=(0,nP.createServerReference)("7f0ae62c0ac368dc5da59339426e6fb44388d47b7a",nP.callServer,void 0,nP.findSourceMapURL,"saveThoughtAction"),r7=(0,nP.createServerReference)("7f6dc4115bfa127be0bebd4d5afaa8cfd1f6576e8c",nP.callServer,void 0,nP.findSourceMapURL,"saveTurnsAction");function r9(e,t){let n="chatgpt"===e?" on your GPT Subscription":"openai"===e?" on your OpenAI key":"";return t?`Could not start the call${n}`:`The call${n} failed`}class r8 extends Error{}let ae=Array(nM.SPECTRUM_BANDS).fill(0),at=!1;function an(e){let t=e.replace(/\[[^\]]*\]?|\]/g,"").trim();return/[\p{L}\p{N}]/u.test(t)?t:""}function ar(e,t,n="This call is not being saved"){e.failures>=O.CALL_PAGE.saveFailures||t().then(e=>(0,nF.unwrapResult)(e)).catch(t=>{e.failures+=1,e.failures===O.CALL_PAGE.saveFailures&&R.toast.add({type:"warning",title:n,description:(0,N.errorToString)(t)})})}var aa=e.i(509461);let as=new Intl.Segmenter(void 0,{granularity:"grapheme"}),al=e=>Array.from(as.segment(e)).length;function ai({text:e,animate:t}){let{shown:n,links:a}=(0,v.useMemo)(()=>{let t=[],n="",r=0;for(let a of e.matchAll(N.MARKDOWN_LINK)){let s=al(n+=e.slice(r,a.index));n+=a[1],t.push({from:s,to:al(n),href:a[2]}),r=a.index+a[0].length}return{shown:n+e.slice(r),links:t}},[e]);if(t)return(0,r.jsx)(M,{text:n,wraps:a.map(e=>({from:e.from,to:e.to,render:t=>(0,r.jsx)(au,{href:e.href,children:t})}))});let s=Array.from(as.segment(n),e=>e.segment),l=[],i=0;for(let e of a)l.push(s.slice(i,e.from).join("")),l.push((0,r.jsx)(au,{href:e.href,children:s.slice(e.from,e.to).join("")},e.from)),i=e.to;return l.push(s.slice(i).join("")),(0,r.jsx)(r.Fragment,{children:l})}let ao="pointer-events-auto underline decoration-current/35 underline-offset-4 transition-colors hover:decoration-current";function au({href:e,children:t}){let[n]=(0,nB.useServerAction)(aa.openFileAction);if(/^https?:\/\//i.test(e))return(0,r.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",className:ao,onClick:e=>e.stopPropagation(),children:t});let a=(0,rn.workspaceRelative)(e);return a?(0,r.jsx)("a",{href:k.queryKey.fileView(a),className:ao,onClick:t=>{t.preventDefault(),t.stopPropagation();let r=(0,rr.fileTarget)(e);"os"===r.how?n(e):X.fileOpens.open(r.path)||window.open(k.queryKey.fileView(r.path),"_blank")},children:t}):t}var ac=e.i(174080),ad=e.i(877267);let ah="700 9px ui-monospace, SFMono-Regular, Menlo, monospace",ap=Math.ceil(13.5);function am(e){let t=document.createElement("canvas");t.width=ap*e.length,t.height=ap;let n=t.getContext("2d");return n?(n.textAlign="center",n.textBaseline="middle",n.font=ah,e.forEach((e,t)=>{n.fillText(e,t*ap+ap/2,ap/2)}),t):null}function af({status:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null),a=(0,v.useRef)(e),[s,l]=(0,v.useState)(!1),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{"emoji"===(0,ad.faceGlyphs)()&&(i.current=am(rV.EMOJI_POOL))},[]),(0,v.useEffect)(()=>{let t=a.current;a.current=e,"connecting"!==t||"connecting"===e||"idle"===e||"ending"===e||window.matchMedia("(prefers-reduced-motion: reduce)").matches||l(!0)},[e]),(0,v.useEffect)(()=>{let e=n.current,r=t.current?.getBoundingClientRect();if(!s||!e||!r)return;let a=window.innerWidth,o=window.innerHeight,u=r.left+r.width/2,c=r.top+r.height/2,d=Math.hypot(Math.max(u,a-u),Math.max(c,o-c)),h=Math.ceil(a/11),p=Math.ceil(o/11),m=[];for(let e=0;e<p;e++)for(let t=0;t<h;t++){if((0,rV.hash)(t+53,e+5)>.4)continue;let n=11*t+5.5,r=11*e+5.5,a=Math.atan2(r-c,n-u),s=(0,rV.hash)(t+31,e+17),l=Math.hypot(n-u,r-c)/d*(1+.1*Math.sin(3*a+1.3)+.05*Math.sin(7*a-.7)+(s-.5)*.1);l<.1||m.push({x:n,y:r,dd:l,seed:(0,rV.hash)(t,e),grain:s,speck:(0,rV.hash)(t+7,e+101)})}m.sort((e,t)=>e.dd-t.dd);let f=e=>{let t=0,n=m.length;for(;t<n;){let r=t+n>>1;m[r].dd<e?t=r+1:n=r}return t};e.width=a,e.height=o;let g=e.getContext("2d"),x="letters"===(0,ad.faceGlyphs)(),y=x?null:i.current??am(rV.EMOJI_POOL);if(!g||!x&&!y)return;x&&(g.textAlign="center",g.textBaseline="middle",g.font=ah,g.fillStyle=getComputedStyle(e).color);let w=rV.LEVELS-1,b=x?rV.CHAR_RATE:rV.EMOJI_CHAR_RATE,v=ap/2,k=performance.now(),j=0,S=0,N=()=>{let e=(performance.now()-k)/1e3;if(e>1.9736842105263157)return l(!1);if(S=requestAnimationFrame(N),j++%2)return;let t=.95*e;g.clearRect(0,0,a,o);for(let n=f(t-.2-.475);n<m.length;n++){let r=m[n],a=t-r.dd;if(a<-.03)break;let s=(0,rV.smoothstep)(-.03,.02,a)*(1-(0,rV.smoothstep)(.02,.2,a))*(.72+.28*Math.sin(46*r.dd-7*e+6.283*r.seed));if(r.speck<.06){let e=.18+.32*r.grain,t=(a-.2)/.95;s=Math.max(s,(.3+.4*r.grain)*(1-(0,rV.smoothstep)(.4*e,e,t)))}let l=Math.round(s*w);if(l<1)continue;let i=Math.floor(e*b+10*r.seed);if(y){g.globalAlpha=(0,rV.emojiAlpha)(l,w);let e=Math.floor((0,rV.hash)(97*r.seed,i)*rV.EMOJI_POOL.length);g.drawImage(y,e*ap,0,ap,ap,r.x-v,r.y-v,ap,ap);continue}g.globalAlpha=rV.ALPHA_TOP*(l/w);let o=rV.RAMP[l];g.fillText(o[Math.floor((0,rV.hash)(131*r.seed,i)*o.length)],r.x,r.y)}g.globalAlpha=1};return S=requestAnimationFrame(N),()=>cancelAnimationFrame(S)},[s]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{ref:t,"aria-hidden":!0,className:"pointer-events-none absolute inset-0"}),s&&(0,ac.createPortal)((0,r.jsx)("canvas",{ref:n,"aria-hidden":!0,className:"pointer-events-none fixed inset-0 z-30 size-full text-foreground"}),document.body)]})}var ag=e.i(333495);function ax(e){let t=[];for(let n of e){let e=t.at(-1);e?.role!==n.role||n.fresh?t.push({id:n.id,role:n.role,text:n.text}):e.text=`${e.text} ${n.text}`}return t}let ay={assistant:null,user:null};function aw(e,t){let[n,r]=(0,v.useState)(ay);return(0,v.useEffect)(()=>{t||r(ay)},[t]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{"ArrowDown"!==e.key||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(0,G.windowKey)(e)&&(e.preventDefault(),r(ay))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),{pinned:n,pick:(0,v.useCallback)((t,n)=>{let a=e.filter(e=>e.role===t).length-1;r(e=>({...e,[t]:n>=a?null:n}))},[e]),back:null!==n.assistant||null!==n.user}}let ab="(under)";function av({turns:e,pinned:t,live:n,onPick:a,under:s=null,ahead:l=!1,workOf:i,typed:o=!1}){let u=e.at(-1);return(0,r.jsx)(r.Fragment,{children:["assistant","user"].map(c=>(0,r.jsx)(ak,{role:c,turns:e.filter(e=>e.role===c),pinned:t[c],saying:n?u?.id:void 0,onPick:e=>a(c,e),under:"assistant"===c?s:null,ahead:"assistant"===c&&l,workOf:"assistant"===c?i:void 0,whole:o&&"user"===c},c))})}function ak({role:e,turns:t,pinned:n,saying:a,onPick:s,under:l,ahead:i,workOf:o,whole:u}){let c="user"===e,[d,h]=(0,v.useState)({}),p=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>p.current?.disconnect(),[]);let m=(0,v.useCallback)(e=>{if(e)return p.current??=new ResizeObserver(e=>{h(t=>{let n=t;for(let r of e){let e=r.target,a=e.dataset.turn;a&&t[a]!==e.offsetHeight&&(n===t&&(n={...t}),n[a]=e.offsetHeight)}return n})}),p.current.observe(e),()=>p.current?.unobserve(e)},[]),f=t.length-1,g=null===n&&(i||!t.length)?t.length:Math.min(n??f,f),x=(0,v.useRef)(null);if((0,v.useEffect)(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[t[g]?.text]),!t.length&&!l)return null;let y=e=>1150/(1150+700*Math.abs(e-g)),w=e=>e===g?1:.78,b=e=>(d[t[e].id]??28.475)*y(e)*w(e),k=g===t.length?l:o?.(t[g].id)??null,j=Array(t.length+1).fill(0);j[g]=-28.475/2;for(let e=g-1;e>=0;e--)j[e]=j[e+1]-49-b(e);let S=k&&g<t.length?(d[ab]??0)+8:0;for(let e=g+1;e<t.length;e++)j[e]=j[e-1]+b(e-1)+49+(e-1===g?S:0);let T=k?g===t.length?j[g]:j[g]+(d[t[g].id]??28.475)+8:null;return(0,r.jsxs)("div",{className:(0,N.cn)("pointer-events-none absolute h-0 w-[min(21.25rem,24vw)]",c?"left-full ml-[calc(var(--face-bleed,0px)+0.375rem)] [perspective-origin:0_0]":"right-full mr-[calc(var(--face-bleed,0px)+0.375rem)] [perspective-origin:100%_0]"),style:{top:"calc(50% + -40px)",perspective:1150},children:[t.map((e,n)=>{let l=Math.abs(n-g),i=n<g?g-n<=2:n-g<=2,o=n===g,d=i?o?1:.56*.6**(l-1):0,h=i&&!o,p=14*l*(c?-1:1)/y(n),f=j[n]/y(n);return(0,r.jsx)("div",{ref:m,"data-turn":e.id,"aria-hidden":!i,onClick:h?()=>s(n):void 0,style:{transform:`translate(${p.toFixed(1)}px, ${f.toFixed(1)}px) translateZ(${-700*l}px) scale(${w(n)})`,"--ink":d,"--lift":Math.max(d,.9)},className:(0,N.cn)("group/turn absolute top-0 w-max max-w-full text-[17px] leading-[1.675] tracking-[0.3px] text-foreground transition-transform duration-[520ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",u&&n===t.length-1&&"animate-in fade-in duration-200 motion-reduce:animate-none",c?"left-0 origin-top-left":"right-0 origin-top-right",!i&&"invisible",h&&"pointer-events-auto cursor-pointer",o&&"pointer-events-auto"),children:(0,r.jsxs)("p",{ref:o?x:void 0,className:(0,N.cn)("break-keep wrap-anywhere text-pretty whitespace-pre-line opacity-(--ink) transition-opacity duration-[520ms] motion-reduce:transition-none",!o&&"line-clamp-4",o&&"overflow-y-auto overscroll-contain scrollbar-none",h&&"group-hover/turn:opacity-(--lift)"),style:o?{maxHeight:284.75}:void 0,children:[o&&(0,r.jsx)("span",{className:(0,N.cn)("mr-4 inline-block size-2.5 rounded-full align-middle",e.id===a?"animate-pulse motion-reduce:animate-none":"opacity-55",c?"bg-foreground":"bg-brand")}),(0,r.jsx)(ai,{text:e.text,animate:n===t.length-1&&!u})]})},e.id)}),k&&(0,r.jsx)("div",{ref:m,"data-turn":ab,style:{transform:`translateY(${(T??0).toFixed(1)}px)`},className:"absolute inset-x-0 top-0 transition-transform duration-[520ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",children:k})]})}e.s(["SideCaptions",0,av,"turnsOf",0,ax,"useTurnFocus",0,aw],435135);var aj=e.i(454263);let aS=["▁▄▇▄","▂▆▆▂","▄▇▄▁","▆▆▂▂","▇▄▁▄","▆▂▂▆","▄▁▄▇","▂▂▆▆"];function aN({live:e,ringing:t}){let{owed:n}=tT(),r=na(Object.values(ns()).map(e=>e??null)),a="waiting"===r?null:r;return(0,v.useEffect)(()=>{let r=t?`${O.APP_NAME} is calling`:O.APP_NAME,a=n>0?`(${n}) ${r}`:r;if(!e){document.title=a;return}let s=0;document.title=`${a} ${aS[s]}`;let l=setInterval(()=>{s=(s+1)%aS.length,document.title=`${a} ${aS[s]}`},100);return()=>clearInterval(l)},[e,n,t]),(0,v.useEffect)(()=>{let e=document.head.querySelector("link[data-tab-icon]");e||((e=document.createElement("link")).rel="icon",e.type="image/svg+xml",e.setAttribute("sizes","any"),e.dataset.tabIcon="",document.head.append(e)),e.href=`data:image/svg+xml,${encodeURIComponent(function(e){let{head:t,eyes:n}=(0,aj.markAtRest)(W.THURSDAY_SEED),r=e?`<circle cx="200" cy="200" r="${66}"/>`:"",a=e?`<circle class="${e}" cx="200" cy="200" r="46"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 252 252"><style>.ink{fill:#0a0a0a}.red{fill:#e7000b}@media (prefers-color-scheme:dark){.ink{fill:#fafafa}.red{fill:#ff6467}}</style><mask id="m" maskUnits="userSpaceOnUse"><path d="${t}" fill="#fff"/><path d="${n[0]}"/><path d="${n[1]}"/>${r}</mask><path class="ink" d="${t}" mask="url(#m)"/>${a}</svg>`}(a))}`},[a]),null}let aT={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]};aT.node;let aE=(0,l.default)(aT);var a_=e.i(96892),aM=e.i(64801),aA=e.i(59377),aC=e.i(184762),aL=e.i(146538);let aR=(0,nP.createServerReference)("7fe0b6a162f209a2fcb2ab586ccbb28b10583f588f",nP.callServer,void 0,nP.findSourceMapURL,"startThreadAction");var aI=e.i(553429),aO=e.i(709190);let aD={name:aI.ROOM_THURSDAY,description:"A call in writing — she answers here"},aP=e=>/^@(\S*)$/.exec(e.split(/\s/,1)[0]);function a$({written:e,onCall:t=!1}){let{data:n}=(0,J.useServerRoute)(k.queryKey.bot),a=(0,v.useMemo)(()=>[...e?[aD]:[],...n?.length?n.filter(e=>!e.disabled).map(({name:e,icon:t,description:n})=>({name:e,icon:t,description:n})):[$.DEFAULT_BOT]],[n,e]),[l,i]=(0,v.useState)(!1),[o,u]=(0,v.useState)(!1),[c,d]=(0,v.useState)(!1),[h,p]=(0,v.useState)(""),m=(0,v.useRef)(t);m.current=t;let f=(0,aO.useGivenFiles)({onKept:e=>{if(m.current)return X.screenActs.announce({kind:"gave",paths:e}),"she knows it is here"}}),g=(0,v.useRef)(null),x=(0,v.useRef)(null),y=!!e?.on,[w,b]=(0,v.useState)(null);(0,v.useEffect)(()=>{y||b(null)},[y]);let S=a.find(e=>e.name===w)??(e?aD:a[0]),T=S===aD,E=nc(),_=(0,v.useCallback)(()=>{E||(i(!0),requestAnimationFrame(()=>g.current?.focus()))},[E]),M=(0,X.useRoomOpen)(),{take:A}=f,C=(0,v.useCallback)(e=>{X.writeLine.open(),A(e)},[A]);(0,v.useEffect)(()=>X.writeLine.subscribe(_),[_]),(0,v.useEffect)(()=>{if("thread"===M)return;let e=e=>{"/"!==e.key||e.metaKey||e.ctrlKey||e.altKey||(0,G.windowKey)(e)&&(e.preventDefault(),X.writeLine.open())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[M]),(0,v.useEffect)(()=>{if(E)return;let e=e=>!!e.dataTransfer?.types.includes("Files"),t=t=>{e(t)&&(t.preventDefault(),d(!0))},n=e=>{null===e.relatedTarget&&d(!1)},r=t=>{if(!e(t))return;t.preventDefault(),d(!1);let n=[...t.dataTransfer?.files??[]];aO.roomDrop.offer(t.target,n)||C(n)};return window.addEventListener("dragover",t),window.addEventListener("dragleave",n),window.addEventListener("drop",r),()=>{window.removeEventListener("dragover",t),window.removeEventListener("dragleave",n),window.removeEventListener("drop",r)}},[C,E]);let[L,R]=(0,nB.useServerAction)(aR,{onOk:({id:e})=>{(0,J.revalidate)(k.queryKey.threads),p(""),f.clear(),i(!1),b(null),X.roomOpens.open(e)}}),[I,O]=(0,v.useState)(0),[D,P]=(0,v.useState)(!1),F=e=>{u(!1),p(e=>aP(e)?e.replace(/^@\S*\s?/,""):e),O(0),g.current?.focus(),b(e.name===aD.name?null:e.name)},B=D?null:aP(h),z=B?a.filter(e=>e.name.toLowerCase().startsWith(B[1].toLowerCase())):a,q=z.length?I%z.length:0,[U,K]=(0,v.useState)(!1),H=R||U,W=!!h.trim()&&!B&&!f.arriving&&!H&&!(T&&!e?.runsOn),Y=()=>{if(!W)return;let t=f.withPaths(h);T?e&&(K(!0),e.say(t).then(()=>{p(""),f.clear()}).catch(()=>{}).finally(()=>K(!1))):L(S.name,t)},V=()=>{if(w)return b(null);y&&e?.end(),i(!1)},Z=(0,v.useRef)(t);(0,v.useEffect)(()=>{let e=t&&!Z.current;Z.current=t,!e||h.trim()||f.files.length||i(!1)},[t,h,f.files.length]);let Q=(l||c||y)&&!M;(0,G.useEscape)(Q,V);let ee=R||U;(0,v.useEffect)(()=>{Q&&!ee&&g.current?.focus()},[Q,ee]),(0,v.useEffect)(()=>(X.writeLine.shown(Q),()=>X.writeLine.shown(!1)),[Q]);let et=y&&!!M;(0,v.useEffect)(()=>(X.writeLine.waits(et),()=>X.writeLine.waits(!1)),[et]);let en=eh(),[er,ea]=(0,v.useState)(Q);return((0,v.useEffect)(()=>{if(Q)return void ea(!0);let e=setTimeout(()=>ea(!1),200);return()=>clearTimeout(e)},[Q]),er)?(0,r.jsxs)(r.Fragment,{children:[c&&(0,r.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-0 bg-background/60",children:(0,r.jsx)("div",{className:"absolute inset-3 rounded-3xl border-[1.5px] border-dashed border-foreground/30"})}),(0,r.jsx)("div",{className:"col-start-2 row-start-1 flex min-w-0 items-end justify-center",children:(0,r.jsxs)("div",{className:(0,N.cn)("flex w-160 max-w-full flex-col gap-2",Q?"pointer-events-auto animate-in duration-200 fade-in slide-in-from-bottom-2":"pointer-events-none animate-out duration-200 fade-out fill-mode-forwards slide-out-to-bottom-2"),children:[en.length>0&&(0,r.jsxs)("div",{className:"rounded-3xl bg-background/78 p-1.5 shadow-sm shadow-black/3 ring-1 ring-border/50 backdrop-blur-md",children:[(0,r.jsxs)("p",{className:"px-3 pt-1 pb-1 font-mono text-[10px] tracking-wide text-muted-foreground",children:[en.length," ",1===en.length?"needs":"need"," a reply"]}),(0,r.jsx)("div",{className:"max-h-[30vh] overflow-y-auto",children:en.map(e=>(0,r.jsx)(ev,{thread:e,lines:2,onPick:()=>X.roomOpens.open(e.id)},e.id))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 rounded-[26px] bg-background p-2 shadow-[0_22px_44px_-20px_rgb(0_0_0/0.22)] ring-1 ring-border",children:[(f.files.length>0||c)&&(0,r.jsx)(aO.GivenFiles,{files:f.files,onRemove:f.remove,className:"px-0.5 pt-0.5",children:c&&(0,r.jsxs)("span",{className:"flex h-13 items-center gap-2 rounded-[14px] border-[1.5px] border-dashed border-foreground/60 px-4 text-[13px]",children:[(0,r.jsx)(aE,{className:"size-4"}),"Let go — it waits here"]})}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),Y()},className:"flex items-end gap-2",children:[(0,r.jsxs)(aA.Popover,{open:o||!!B,onOpenChange:u,children:[(0,r.jsxs)(aA.PopoverTrigger,{render:(0,r.jsx)("button",{type:"button","aria-label":`To ${S.name}. Choose someone else`,className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-muted pr-2.5 pl-1.5 text-[13px] font-medium outline-none transition-colors hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50"}),children:[(0,r.jsx)(aq,{bot:S,size:22}),S.name,(0,r.jsx)(s.ChevronDown,{className:"size-3 text-muted-foreground"})]}),(0,r.jsxs)(aA.PopoverContent,{side:"top",align:"start",sideOffset:14,initialFocus:!B&&void 0,className:"w-90 gap-0 rounded-[18px] p-1.5",children:[(0,r.jsx)("p",{className:"px-2.5 pt-1.5 pb-1 font-mono text-[10px] text-muted-foreground",children:"to"}),z.map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>F(e),className:(0,N.cn)("flex h-11.5 w-full items-center gap-2.5 rounded-xl px-2.5 text-left outline-none hover:bg-muted focus-visible:bg-muted",(B?t===q:e.name===S.name)&&"bg-muted"),children:[(0,r.jsx)(aq,{bot:e,size:24}),(0,r.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsx)("span",{className:"text-[13.5px] leading-4.5 font-medium",children:e.name}),(0,r.jsx)("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:e.description})]})]},e.name)),0===z.length&&(0,r.jsx)("p",{className:"px-2.5 py-2 text-[13px] text-muted-foreground",children:"Nobody by that name."})]})]}),(0,r.jsx)(aC.Textarea,{ref:g,value:h,rows:1,disabled:R||U,onChange:e=>{let t=e.target.value;p(t),O(0),aP(t)||P(!1)},onPaste:e=>{let t=[...e.clipboardData.files];t.length&&(e.preventDefault(),C(t))},onKeyDown:e=>{let t=(0,G.composing)(e);if("Escape"===e.key&&!t)return(e.preventDefault(),B)?P(!0):V();let n="ArrowDown"===e.key||"ArrowUp"===e.key;if(B&&n&&!t){let t;return e.preventDefault(),t="ArrowDown"===e.key?1:-1,O(e=>z.length?(e+t+z.length)%z.length:0)}let r="Tab"===e.key&&!e.shiftKey;if(B&&r&&!t&&z[q]){e.preventDefault(),F(z[q]);return}if("Enter"===e.key&&!e.shiftKey&&!t){if(e.preventDefault(),B){z[q]&&F(z[q]);return}Y()}},placeholder:f.files.length?"Say what to do with them":y&&T?"Write back":T?"Write to her instead of calling":`Say the whole job — ${S.name} cannot hear the call`,"aria-label":`Message for ${S.name}`,className:"max-h-36 min-h-9 flex-1 resize-none border-0 bg-transparent px-0 py-1.5 text-[15px] leading-6 shadow-none focus-visible:ring-0 dark:bg-transparent"}),(0,r.jsx)("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:e=>{C([...e.target.files??[]]),e.target.value=""}}),(0,r.jsx)("button",{type:"button","aria-label":"Add files",onClick:()=>x.current?.click(),className:"grid size-9 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:(0,r.jsx)(aM.Paperclip,{className:"size-4"})}),(0,r.jsx)("button",{type:"submit","aria-label":"Send",disabled:!W,className:(0,N.cn)("grid size-9 shrink-0 place-items-center rounded-full outline-none transition-colors focus-visible:ring-3 focus-visible:ring-ring/50",W?"bg-primary text-primary-foreground hover:bg-primary/85":"bg-muted text-muted-foreground/40"),children:H?(0,r.jsx)("span",{className:"size-3.5 animate-spin rounded-full border-2 border-current/30 border-t-current"}):(0,r.jsx)(a_.ArrowUp,{className:"size-4"})})]})]}),T&&e?.error&&(0,r.jsx)("p",{className:"px-4 text-center text-xs leading-5 text-destructive",children:e.error}),T&&e?.error&&(0,r.jsx)("div",{className:"flex items-center justify-center gap-3",children:(0,r.jsxs)(j.Button,{type:"button",size:"sm",variant:"brand",disabled:e.busy,onClick:()=>{e.fallback&&nL.useThursdayStore.getState().patch({textModel:e.fallback}),e.again()},children:[(0,r.jsx)(eE.RotateCw,{}),e.fallback?"Send it again on your OpenAI key":"Send it again"]})}),(0,r.jsx)("p",{className:"flex flex-wrap items-center justify-center gap-x-2 gap-y-1 font-mono text-[10.5px] text-muted-foreground/70",children:B?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aU,{keys:["↑↓"],children:"walk"}),(0,r.jsx)(aB,{}),(0,r.jsx)(aU,{keys:["Tab","Enter"],children:"take"}),(0,r.jsx)(aB,{}),(0,r.jsx)(aU,{keys:["Esc"],children:"close the list"})]}):(0,r.jsxs)(r.Fragment,{children:[T&&!e?.runsOn?(0,r.jsx)(aF,{runsOn:null}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aU,{keys:["Enter"],children:"send"}),(0,r.jsx)(aB,{}),(0,r.jsx)(aU,{keys:["@"],children:T?"a bot":"pick a bot"}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aB,{}),(0,r.jsx)(aF,{runsOn:e?.runsOn??null})]})]}),(0,r.jsx)(aB,{}),(0,r.jsx)(aU,{keys:["Esc"],children:y?T?"to end":"back to her":"close"})]})})]})})]}):null}function aF({runsOn:e}){let t=P.TEXT_MODEL_PROVIDERS.chatgpt.label,n=(0,r.jsx)(aL.ModelPicker,{compact:!0,provider:e?.provider??null,model:e?.model??"",unset:"pick a model",onChange:e=>nL.useThursdayStore.getState().patch({textModel:e})});return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"runs on"}),n]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{children:["Writing to her needs a ",t,", an OpenAI key, or"]}),n,(0,r.jsx)(aB,{}),(0,r.jsx)(az,{children:"API keys"})]})}let aB=()=>(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"});function az({children:e}){return(0,r.jsx)("button",{type:"button",onClick:()=>(0,tz.openSettings)("keys"),className:"rounded-sm text-foreground/80 underline underline-offset-3 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:e})}function aq({bot:e,size:t}){return e===aD?(0,r.jsx)(W.ThursdayMark,{size:t,className:"shrink-0"}):(0,r.jsx)(F.BotMark,{size:t,seed:e.name,color:e.icon?.color,shape:e.icon?.shape,outline:e.icon?.outline,paint:e.icon?.paint,notify:!1,className:"shrink-0"})}function aU({keys:e,children:t}){return(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.map(e=>(0,r.jsx)(aK,{children:e},e)),t]})}function aK({children:e}){return(0,r.jsx)("kbd",{className:"rounded-md border border-border bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground/80 shadow-[0_1px_0_var(--border)]",children:e})}let aH=(0,b.default)(()=>e.A(326970).then(e=>e.HereGlobe),{loadableGenerated:{modules:[246971]},ssr:!1});function aW({status:e,failed:t=!1,messages:n,tool:a,thinkingSince:s=null,thinkingTitle:l=null,ended:i=null,faceWord:o=null,onTap:u,ringing:c=null,onDecline:d,wakePhrase:h=null,hotkeyLabel:p=null,idleLeft:m=null,since:f=null,getSpectrum:g,getMicSpectrum:x,captionView:y="sides",callable:w=!0,written:b=null}){var k;let[j,S]=(0,v.useState)(!1),T=!w&&"idle"===e,E="connecting"===e||"ending"===e,_=!!b?.on,M="idle"!==e&&!E&&!_,A=n.findLast(e=>"assistant"===e.role)?.text??"",C=(k=aJ,(0,v.useSyncExternalStore)(e=>{let t=window.matchMedia(`(min-width: ${k}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia(`(min-width: ${k}px)`).matches,()=>!0)),L="sides"===y&&"idle"!==e&&C,R=nx(),I=!L||null!==R,D=(0,v.useMemo)(()=>ax(n),[n]),P=aw(D,L),$=D.at(-1)?.role,F=function(e,t){let[n,r]=(0,v.useState)(e),a=(0,v.useRef)(e?[e]:[]),s=(0,v.useRef)(Date.now()),l=(0,v.useRef)(!1),i=(0,v.useRef)(null),o=(0,v.useCallback)(()=>{i.current&&clearTimeout(i.current),i.current=null,(a.current.length>1||l.current)&&a.current.length&&(i.current=setTimeout(()=>{a.current.shift(),s.current=Date.now(),r(a.current[0]??null),o()},Math.max(0,s.current+O.CALL_LINE.dwellMs-Date.now())))},[]);return(0,v.useEffect)(()=>{if(!e){l.current=!0,a.current.length<=1&&(a.current=[],r(null)),o();return}l.current=!1;let t=a.current.findIndex(t=>t.id===e.id);t>=0?(a.current[t]=e,0===t&&r(e)):(a.current=[...a.current.map((e,t)=>0===t?e:{...e,done:!0}),e],1===a.current.length&&(s.current=Date.now(),r(e))),o()},[e,o]),(0,v.useEffect)(()=>{if(!t)return;let e=a.current.at(-1);a.current=e&&!l.current?[e]:[],s.current=Date.now(),r(a.current[0]??null),o()},[t,o]),(0,v.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),n}(a,"speaking"===e),B=function(e,t){let n=null!==e||t,[r,a]=(0,v.useState)([]),[s,l]=(0,v.useState)(n);return(0,v.useEffect)(()=>{a(t=>{let n=t.some(e=>!e.done)?t.map(e=>e.done?e:{...e,done:!0}):t;if(!e)return n;let r=t.findIndex(t=>a7(t)===a7(e));return r>=0?t.map((t,n)=>n===r?e:t):[...n,e].slice(-4)})},[e]),(0,v.useEffect)(()=>{if(n)return void l(!0);let e=setTimeout(()=>{l(!1),a([])},300);return()=>clearTimeout(e)},[n]),{lines:r,on:n,held:s}}(F,null!==s),[z,q]=(0,v.useState)(!1);(0,v.useEffect)(()=>{"user"!==$?q(!1):B.on&&q(!0)},[$,B.on]);let U=function(e,t,n){let[r,a]=(0,v.useState)(a9),s=e.findLast(e=>"assistant"===e.role),l=s?.id??null,i=s?`${s.id}:${s.text.length}`:null,o=!n&&e.at(-1)?.role==="assistant";(0,v.useEffect)(()=>{a(e=>{let n=e;for(let e of t){let t=a7(e),r=n.owner[t];if(void 0===r){let e=t in n.seen?n.seen[t]:i;if(t in n.seen||(n={...n,seen:{...n.seen,[t]:i}}),!l||e===i&&!o)continue;r=l,n={...n,owner:{...n.owner,[t]:r}}}let a=n.turns[r]??[],s=a.findIndex(e=>a7(e)===t);s>=0&&a[s]===e||(n={...n,turns:{...n.turns,[r]:s>=0?a.map((t,n)=>n===s?e:t):[...a,e]}})}return n})},[t,i,l,o]),(0,v.useEffect)(()=>{e.length||a(a9)},[e.length]);let u=(0,v.useMemo)(()=>t.filter(e=>void 0===r.owner[a7(e)]),[t,r.owner]);return{turns:r.turns,pending:u,latest:l}}(D,B.lines,B.on),K="assistant"===$&&"speaking"===e||"user"===$&&"listening"===e&&!_,H=null!==c&&null===c.missedAt,W=function(e){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{n(e?{...se,at:Date.now()}:null)},[e]),t}(H),G=nc();return(0,r.jsxs)("div",{className:"relative flex h-full flex-col",inert:G,children:[(0,r.jsxs)("div",{className:"absolute top-5 right-5 z-10 flex flex-col items-end gap-3",children:[(0,r.jsx)(aX,{}),(0,r.jsx)(tl,{hidden:"idle"!==e||null!==c||_}),(0,r.jsx)(sh,{})]}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-5 pt-[7vh]",children:[(0,r.jsxs)("div",{className:"relative w-[min(20rem,52vw,37.5vh)] [--face-bleed:19.5%]",children:[(0,r.jsx)("button",{type:"button",disabled:E,onClick:T?()=>S(!0):_&&!w?void 0:u,"aria-label":T?"Add a speech key":M?"End the call":H?"Answer Thursday":"Call Thursday",className:(0,N.cn)("block w-full rounded-full outline-none transition-all duration-700 ease-out focus-visible:ring-3 focus-visible:ring-ring/50 enabled:active:scale-[0.99] disabled:opacity-70",T&&"opacity-35"),children:(0,r.jsx)("span",{className:"block",children:(0,r.jsx)(ag.Face,{status:e,failed:t,word:W??o,getSpectrum:g,covered:G||R?.phase==="world",className:"-m-(--face-bleed) w-[calc(100%+2*var(--face-bleed))] max-w-none"})})}),(0,r.jsx)(af,{status:e}),R?.moment.kind==="here"&&(0,r.jsx)(aH,{scene:R.moment.scene,onPhase:e=>ng.tell(R.id,e)},R.id),L&&(0,r.jsx)("div",{className:(0,N.cn)("contents",R&&"*:invisible"),children:(0,r.jsx)(av,{turns:D,pinned:P.pinned,live:K,onPick:P.pick,under:B.held&&U.pending.length>0?(0,r.jsx)(a8,{lines:U.pending,shown:B.on}):null,ahead:z&&B.held&&U.pending.length>0,typed:_,workOf:e=>{let t=[...U.turns[e]??[],...e===U.latest&&"assistant"===$?U.pending:[]];return t.length?(0,r.jsx)(a8,{lines:t,shown:!0}):null}})})]}),(0,r.jsxs)("div",{className:"relative flex w-full max-w-3xl flex-col items-center gap-2 px-6 text-center",children:[c&&(0,r.jsx)(sn,{ringing:c,wakePhrase:h,onAnswer:u,onDecline:()=>d?.()}),(0,r.jsxs)("div",{className:(0,N.cn)("contents",c&&"*:invisible"),children:[(0,r.jsx)(a4,{tool:I?F:null,toolUp:null!==F,thinkingSince:s,thinkingTitle:l,micOpen:!_&&("listening"===e||"working"===e||"delegating"===e),getMicSpectrum:x}),(0,r.jsx)(aZ,{text:I&&"idle"!==e?A:"",fadeIn:!0,className:"w-full max-w-160 text-center text-base"}),(0,r.jsx)("div",{className:(0,N.cn)("flex flex-col items-center","idle"===e&&"order-first"),children:T?(0,r.jsx)(sg,{open:j,onOpen:()=>S(!0),onClose:()=>S(!1)}):_?(0,r.jsx)("span",{className:"h-6"}):(0,r.jsx)(so,{status:e,idleLeft:m,since:f,ended:i,behind:L&&P.back,wakePhrase:h,hotkeyLabel:p})})]})]})]}),(0,r.jsxs)(aG,{children:[(0,r.jsx)(ra,{}),(0,r.jsx)(a$,{written:b,onCall:M}),(0,r.jsx)(e2,{})]})]})}function aG({children:e}){return(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] grid-rows-[minmax(0,1fr)_auto] items-end gap-x-4 gap-y-2 p-5",children:e})}let aY=["thursday","memory","bot"];function aV({alert:e}){return e?(0,r.jsx)("span",{"aria-hidden":!0,className:(0,N.cn)("absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2 ring-background","red"===e?"bg-destructive":"bg-waiting")}):null}let aJ=1e3;function aX(){let e=ns(),t=na(ne.filter(e=>!aY.includes(e.id)).map(t=>e[t.id]??null));return(0,r.jsxs)(I.TooltipProvider,{children:[(0,r.jsxs)(E,{className:"bg-background/75 backdrop-blur-md",children:[(0,r.jsx)(E,{children:aY.map(t=>{let n=ne.find(e=>e.id===t);return n?(0,r.jsxs)(I.Tooltip,{children:[(0,r.jsxs)(I.TooltipTrigger,{render:(0,r.jsx)(j.Button,{size:"icon",variant:"outline","aria-label":n.label,onClick:()=>(0,tz.openSettings)(t)}),children:[(0,r.jsx)(n.icon,{className:"text-muted-foreground"}),(0,r.jsx)(aV,{alert:e[t]??null})]}),(0,r.jsx)(I.TooltipContent,{side:"bottom",children:n.label})]},t):null})}),(0,r.jsx)(E,{children:(0,r.jsxs)(j.Button,{variant:"outline",onClick:()=>(0,tz.openSettings)(),className:"gap-1.5 px-2.5 text-[12.5px] font-normal",children:[(0,r.jsx)(y,{className:"text-muted-foreground"}),"Settings",(0,r.jsx)(aV,{alert:t})]})})]}),(0,r.jsx)(nr,{})]})}function aZ({text:e,lines:t=3,fadeIn:n=!1,className:a}){let l=(0,v.useRef)(null),[i,u]=(0,v.useState)(t),[c,d]=(0,v.useState)(0),[h,p]=(0,v.useState)(e);h!==e&&(p(e),d(0)),(0,v.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{let t=Number.parseFloat(getComputedStyle(e).lineHeight);t&&u(Math.max(1,Math.round(e.scrollHeight/t)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let m=Math.ceil(Math.max(0,i-t)/t),f=Math.max(0,i-t-Math.min(c,m)*t),g=`calc(${t} * 1.625em)`,x=(0,r.jsx)("p",{ref:l,style:{lineHeight:1.625,transform:`translateY(-${1.625*f}em)`},className:"break-keep wrap-anywhere whitespace-pre-line transition-transform duration-200",children:(0,r.jsx)(ai,{text:e,animate:n})});return(0,r.jsxs)("div",{className:"relative flex w-full justify-center",children:[(0,r.jsx)("div",{style:{height:g},onClick:m>0?()=>d(e=>e>=m?0:e+1):void 0,className:(0,N.cn)("overflow-hidden",m>0&&"cursor-pointer",a),children:x}),m>0&&(0,r.jsxs)("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 flex-col items-center gap-0.5",children:[(0,r.jsx)(aQ,{look:o,label:"Earlier lines",shown:c<m,onPick:()=>d(e=>Math.min(m,e+1))}),(0,r.jsx)(aQ,{look:s.ChevronDown,label:"Later lines",shown:c>0,onPick:()=>d(e=>Math.max(0,e-1))})]})]})}function aQ({look:e,label:t,shown:n,onPick:a}){return(0,r.jsx)("button",{type:"button","aria-label":t,"aria-hidden":!n,tabIndex:n?void 0:-1,onClick:e=>{e.stopPropagation(),a()},className:(0,N.cn)("grid size-7 place-items-center rounded-full text-muted-foreground/60 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",!n&&"invisible"),children:(0,r.jsx)(e,{className:"size-3.5"})})}let a0=[{id:"a",from:0,to:1,gain:.8},{id:"b",from:1,to:3,gain:1},{id:"c",from:3,to:5,gain:1.15},{id:"d",from:5,to:6,gain:1.35},{id:"e",from:6,to:8,gain:1.55}];function a1({live:e,getMicSpectrum:t}){let n=(0,v.useRef)({}),a=(0,v.useRef)(a0.map(()=>0));return(0,v.useEffect)(()=>{if(!e||!t)return;let r=requestAnimationFrame(function e(){let s=t();a0.forEach((e,t)=>{let r=0;for(let t=e.from;t<e.to;t++)r=Math.max(r,s[t]??0);let l=Math.min(1,(r*e.gain)**.8),i=a.current[t],o=i+(l-i)*(l>i?.6:.16);a.current[t]=o;let u=n.current[e.id];u&&(u.style.height=`${2+12*o}px`)}),r=requestAnimationFrame(e)});return()=>cancelAnimationFrame(r)},[e,t]),(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-[18px] shrink-0 items-center gap-0.5",children:a0.map(e=>(0,r.jsx)("span",{ref:t=>{n.current[e.id]=t},style:{height:2},className:"w-0.5 rounded-full bg-muted-foreground/70"},e.id))})}function a2({live:e,getMicSpectrum:t}){return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-[13px] leading-5 text-muted-foreground",children:[(0,r.jsx)(a1,{live:e,getMicSpectrum:t}),"Listening"]})}function a5({tool:e}){let t="relay"===e.kind?c:(0,e3.toolIcon)(e.name),n=e.line??e.name,a=e.line?"min-w-0 truncate text-[13px] leading-5 break-keep":"min-w-0 truncate font-mono text-xs leading-5",s=(0,J.useServerRoute)(k.queryKey.bot).data,l=e.bot?s?.find(t=>t.name===e.bot)??null:null;return(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"relative grid size-[18px] shrink-0 place-items-center",children:[(0,r.jsx)(a3,{tool:e,bot:l,icon:t}),!e.done&&(0,r.jsx)("span",{className:"absolute inset-0 grid animate-ink place-items-center",children:(0,r.jsx)(a3,{tool:e,bot:l,icon:t,running:!0})})]}),e.done&&e.sources?.length?(0,r.jsx)(L.SourceChips,{sources:e.sources,limit:2,className:"flex-nowrap"}):e.done?(0,r.jsx)("span",{className:(0,N.cn)(a,"text-muted-foreground"),children:n}):(0,r.jsx)(C.ShinyText,{text:n,className:a})]})}function a3({tool:e,bot:t,icon:n,running:a}){return e.bot?(0,r.jsx)("span",{className:(0,N.cn)("flex",!a&&!e.done&&"opacity-40"),children:(0,r.jsx)(F.BotMark,{size:16,seed:e.bot,color:t?.icon?.color,shape:t?.icon?.shape,outline:t?.icon?.outline,paint:t?.icon?.paint,notify:!1})}):(0,r.jsx)(n,{className:(0,N.cn)("size-3.5",a?"text-foreground":"text-muted-foreground",!a&&!e.done&&"opacity-40")})}function a4({tool:e,toolUp:t,thinkingSince:n,thinkingTitle:a,micOpen:s,getMicSpectrum:l}){let[i,o]=(0,v.useState)(e);(0,v.useEffect)(()=>{e&&o(e)},[e]);let{thought:u,title:c}=function(e,t){let[n,r]=(0,v.useState)(null!==e),[a,s]=(0,v.useState)(t);return(0,v.useEffect)(()=>{null!==e&&(r(!0),s(t))},[e,t]),{thought:n,title:a}}(n,a),d=null!==e,h=null!==n&&!t,p=s&&!d&&!h,m=e=>s&&(0,r.jsx)(a1,{live:e,getMicSpectrum:l});return(0,r.jsx)("div",{className:"flex h-7 max-w-full items-center justify-center",children:(0,r.jsxs)("div",{className:"grid min-w-0 items-center justify-items-center",children:[i&&(0,r.jsx)(sl,{at:"col-start-1 row-start-1 max-w-full",shown:d,children:(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[m(d),(0,r.jsx)(a5,{tool:i})]})}),u&&(0,r.jsx)(sl,{at:"col-start-1 row-start-1 max-w-full",shown:h,children:(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[m(h),(0,r.jsx)(sx,{title:c})]})}),(0,r.jsx)(sl,{at:"col-start-1 row-start-1",shown:p,children:(0,r.jsx)(a2,{live:p,getMicSpectrum:l})})]})})}let a6=[1,.7,.45],a7=e=>e.id??`${e.kind??"tool"}:${e.name}`,a9={turns:{},owner:{},seen:{}};function a8({lines:e,shown:t}){let n=Math.max(0,e.length-3),a=e.length-n;return(0,r.jsx)("div",{"aria-hidden":!t,className:(0,N.cn)("pointer-events-auto relative w-full transition-opacity duration-300 ease-out",!t&&"pointer-events-none opacity-0"),style:{height:26*a},children:e.map((t,a)=>{let s=a-n;return(0,r.jsx)("div",{style:{transform:`translateY(${26*s}px)`,opacity:s<0?0:a6[e.length-1-a],height:26},className:"absolute inset-x-0 top-0 flex items-center transition-[transform,opacity] duration-300 ease-out motion-reduce:transition-none",children:(0,r.jsx)("div",{className:"flex min-w-0 animate-in duration-300 fade-in slide-in-from-bottom-1 motion-reduce:animate-none",children:(0,r.jsx)(a5,{tool:t})})},a7(t))})})}let se={text:"CALL",hold:1/0},st="rounded-md border border-border bg-background px-1.5 py-0.5 font-mono text-[10px] text-foreground/80 shadow-[0_1px_0_var(--border)]";function sn({ringing:e,wakePhrase:t,onAnswer:n,onDecline:a}){let s=(0,J.useServerRoute)(k.queryKey.bot).data,l=(e,t)=>{let n=s?.find(t=>t.name===e.bot)?.icon;return(0,r.jsx)(F.BotMark,{size:t,seed:e.bot,color:n?.color,shape:n?.shape,outline:n?.outline,paint:n?.paint,notify:!1,className:"shrink-0"})},{first:i,others:o,missedAt:u}=e,[c,d]=(0,H.useAnswerThread)(),[h,p]=(0,v.useState)(null);if(null!==u){let e=[i,...o];return(0,r.jsxs)("div",{className:"absolute inset-x-0 -top-20 z-10 flex animate-in flex-col items-center px-6 fade-in duration-300",children:[(0,r.jsxs)("div",{className:"flex w-full max-w-140 flex-col text-left",children:[(0,r.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)(g,{className:"size-3"}),(0,r.jsxs)("span",{children:["Missed · ",(0,r.jsx)(sr,{at:u})]}),(0,r.jsxs)("button",{type:"button",onClick:a,className:"ml-auto flex items-center gap-1.5 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("kbd",{className:st,children:"Esc"}),"clear"]})]}),e.slice(0,3).map(e=>(0,r.jsxs)("div",{className:"flex h-8.5 items-center gap-2.5",children:[l(e,20),(0,r.jsx)("span",{className:"w-32 shrink-0 truncate text-[13.5px]",children:e.label}),(0,r.jsx)("span",{className:"w-14 shrink-0 font-mono text-[10.5px] text-muted-foreground",children:ss[e.kind]}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] text-muted-foreground",children:(0,N.plainText)(e.text)})]},e.id)),e.length>3&&(0,r.jsxs)("p",{className:"mt-1 font-mono text-[10.5px] text-muted-foreground/70",children:["+",e.length-3," more in the room"]})]}),(0,r.jsx)(j.Button,{variant:"brand",onClick:n,className:"mt-5 h-12 px-8 text-[15px]",children:"Call back"}),t&&(0,r.jsxs)("span",{className:"mt-3 flex items-center gap-1.5 font-mono text-[11px] text-muted-foreground/70",children:["or say ",(0,r.jsx)(sa,{phrase:t})]})]})}return(0,r.jsxs)("div",{className:"absolute inset-x-0 -top-20 z-10 flex animate-in flex-col items-center gap-3 px-6 fade-in duration-300",children:[(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-2 text-sm",children:[l(i,18),(0,r.jsx)("span",{children:i.bot}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:i.label})]}),(0,r.jsx)("p",{className:"line-clamp-3 max-w-150 text-base/relaxed text-pretty break-keep wrap-anywhere [@media(min-height:860px)]:line-clamp-5",children:(0,N.plainText)(i.text)}),i.options.length>0&&(0,r.jsx)("span",{className:"flex max-w-full flex-wrap justify-center gap-1.5",children:i.options.map(e=>(0,r.jsx)(j.Button,{size:"sm",variant:"secondary",loading:h===e,disabled:d,onClick:async()=>{p(e),await c(i,e,i.bot,i.questionId??void 0),p(null)},className:"h-7 max-w-60 rounded-full px-3 text-[12.5px]",children:(0,r.jsx)("span",{className:"truncate",children:e})},e))}),(0,r.jsx)(j.Button,{variant:"brand",onClick:n,className:"mt-3 h-12 px-8 text-[15px]",children:"Answer"}),o.length>0&&(0,r.jsxs)("span",{className:"flex max-w-full flex-wrap items-center justify-center gap-x-4.5 gap-y-1 text-[13px] text-muted-foreground",children:[o.slice(0,2).map(e=>(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[l(e,16),(0,r.jsx)("span",{className:"max-w-44 truncate text-foreground",children:e.label}),ss[e.kind]]},e.id)),o.length>2&&(0,r.jsxs)("span",{children:["+",o.length-2]})]}),(0,r.jsxs)("span",{className:"mt-1 flex items-center gap-3 font-mono text-[11px] text-muted-foreground/70",children:[t&&(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:["say ",(0,r.jsx)(sa,{phrase:t})," to answer"]}),(0,r.jsxs)("button",{type:"button",onClick:a,className:"flex items-center gap-2 rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,r.jsx)("kbd",{className:st,children:"Esc"}),"not now"]})]})]})}function sr({at:e}){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(e)},[]),t-e<6e4?"just now":(0,a.formatDistanceStrict)(e,t,{addSuffix:!0})}function sa({phrase:e}){return(0,r.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-foreground/80",children:[(0,r.jsx)(h,{className:"size-3"}),e]})}let ss={question:"asks",done:"finished",stopped:"stopped"};function sl({at:e,shown:t,children:n}){return(0,r.jsx)("span",{"aria-hidden":!t,className:(0,N.cn)("flex transition-opacity duration-300 ease-out",e,t?"opacity-100":"pointer-events-none opacity-0"),children:n})}let si={quiet:`${O.CALL_IDLE.hangUpMs/1e3}s of quiet`,hungUp:"Thursday hung up",closed:"Live closed the call",expired:"the call ran to Live's time limit",dropped:"the connection dropped"};function so({status:e,idleLeft:t,since:n,ended:a,behind:s,wakePhrase:l,hotkeyLabel:i}){let o,u,c="connecting"===e||"ending"===e,d="idle"!==e&&!c;return c?(u=e,o=(0,r.jsx)(C.ShinyText,{text:"connecting"===e?"Connecting…":"Ending…",className:"text-muted-foreground/70"})):d&&null!==t?(u="quiet",o=`Quiet — ending in ${t}s. Say anything to stay.`):d?(u=s?"behind":"live",o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Tap Thursday to end"}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("kbd",{className:st,children:"↓"}),(0,r.jsx)("span",{children:"back to now"})]}):(0,r.jsx)(sy,{since:n}),(0,r.jsx)(sd,{})]})):a?(u=`ended:${a}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{children:["Ended — ",si[a]]}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("span",{children:"Tap to call again"})]})):l?(u=`wake:${l}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{text:"Tap Thursday, or say"}),(0,r.jsx)(sm,{at:500,children:(0,r.jsx)(sa,{phrase:l})}),(0,r.jsx)(sm,{at:sp,children:(0,r.jsx)(sf,{})})]})):i?(u=`key:${i}`,o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{text:"Tap Thursday, or press"}),(0,r.jsx)(sm,{at:550,children:(0,r.jsx)("kbd",{className:st,children:i})}),(0,r.jsx)(sm,{at:sp,children:(0,r.jsx)(sf,{})})]})):(u="tap",o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{text:"Tap Thursday to talk"}),(0,r.jsx)(sm,{at:sp,children:(0,r.jsx)(sf,{})})]})),(0,r.jsx)("span",{className:"flex h-6 animate-in items-center gap-1.5 font-mono text-[11px] text-muted-foreground fade-in duration-700",children:o},u)}let su="rounded-md outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",sc={screen:{press:"Share screen",on:"Sharing screen",refused:"Nothing was shared"},camera:{press:"Camera",on:"Camera on",refused:"The camera did not start"}};function sd(){let e=nj();return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("span",{children:sc[e.kind].on}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("button",{type:"button",onClick:nE,className:su,children:"Stop"})]}):["screen","camera"].filter(nN).map(e=>(0,r.jsxs)(v.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),(0,r.jsx)("button",{type:"button",onClick:()=>nT(e).catch(t=>R.toast.add({type:"warning",title:sc[e].refused,description:(0,N.errorToString)(t)})),className:su,children:sc[e].press})]},e))}function sh(){let e=nj(),t=(0,v.useRef)(null),n=e?.stream??null;if((0,v.useEffect)(()=>{t.current&&(t.current.srcObject=n)},[n]),!e)return null;let a="camera"===e.kind;return(0,r.jsxs)("figure",{className:"flex w-44 animate-in flex-col items-end gap-1.5 fade-in duration-300",children:[(0,r.jsx)("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":a?"Your camera":"The screen you are sharing",className:(0,N.cn)("w-full rounded-lg bg-muted object-contain ring-1 ring-border/60",a?"aspect-[4/3] -scale-x-100":"aspect-video")}),(0,r.jsx)("figcaption",{className:"font-mono text-[11px] text-muted-foreground",children:"Sent only when she looks"})]})}let sp=900;function sm({at:e,children:t}){return(0,r.jsx)("span",{style:{animationDelay:`${e}ms`},className:"flex animate-in items-center gap-1.5 duration-700 fill-mode-backwards fade-in",children:t})}function sf(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"px-1.5 text-muted-foreground/30",children:"·"}),(0,r.jsx)("span",{className:"text-muted-foreground/70",children:"/ to write"})]})}function sg({open:e,onOpen:t,onClose:n}){let{data:a}=(0,J.useServerRoute)(k.queryKey.automaticModel),{data:s}=(0,J.useServerRoute)(k.queryKey.config),l=D.LIVE_LINES.find(e=>(0,e6.isConfigUnreadable)(s,P.TEXT_MODEL_PROVIDERS[e].apiKeyName)),i=(0,e4.useVoiceLine)(),o=i.signedIn&&!i.planCalls;return e?(0,r.jsxs)("div",{className:"w-[min(26rem,84vw)] animate-in space-y-2.5 rounded-2xl bg-background/80 p-3 ring-1 ring-border/60 backdrop-blur-md fade-in duration-300",children:[(0,r.jsxs)("div",{className:"flex h-6 items-center justify-between gap-2 pl-0.5",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium",children:"Give her a voice"}),(0,r.jsx)(j.Button,{type:"button",size:"icon",variant:"ghost","aria-label":"Not now",onClick:n,className:"-my-1 size-6",children:(0,r.jsx)(w.X,{className:"size-3.5"})})]}),(0,r.jsx)(e4.CallLines,{})]}):(0,r.jsxs)("span",{className:"flex animate-in items-center gap-2 rounded-full bg-muted/60 py-1 pr-1 pl-1.5 ring-1 ring-border/60 fade-in duration-500",children:[(0,r.jsxs)("span",{className:"relative flex size-6 shrink-0 items-center justify-center",children:[(0,r.jsx)(F.BotMark,{size:24,seed:$.DEFAULT_BOT.name,color:$.DEFAULT_BOT.icon?.color,shape:$.DEFAULT_BOT.icon?.shape,outline:$.DEFAULT_BOT.icon?.outline,notify:!1}),(0,r.jsx)(m,{className:"absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full bg-muted text-muted-foreground"})]}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground break-keep wrap-anywhere",children:"chatgpt"===l?"The ChatGPT sign-in saved for calls can't be unlocked any more — sign in again.":l?"The key saved for calls can't be unlocked any more — add it again.":o?`Your ${(0,P.planName)(i.plan)?`${(0,P.planName)(i.plan)} `:""}ChatGPT plan has no spoken calls — add an OpenAI key. Bots and writing already run on it.`:a&&!a.ref?"Sign in with ChatGPT and calls and bots run on your plan, or add a key.":"Calls need a GPT Subscription or an OpenAI key. Everything else here already works."}),(0,r.jsx)(j.Button,{size:"sm",variant:"brand",onClick:t,className:"h-7 px-3.5",children:"Set up"})]})}function sx({title:e}){let t=e?`Thinking \xb7 ${e}`:"Thinking";return(0,r.jsx)("span",{className:"flex max-w-full items-center text-[13px] leading-5",children:(0,r.jsx)(C.ShinyText,{text:t,className:"min-w-0 animate-in truncate fade-in duration-300"},t)})}function sy({since:e}){let[t,n]=(0,v.useState)(()=>Date.now());if((0,v.useEffect)(()=>{if(null===e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),null===e)return null;let a=Math.max(0,Math.floor((t-e)/1e3)),s=String(Math.floor(a/60)).padStart(2,"0"),l=String(a%60).padStart(2,"0");return(0,r.jsxs)("span",{className:"tabular-nums",children:[s,":",l]})}e.s(["Ear",0,a2,"Thursday",0,function({ready:t}){let n=function(){let[e,t]=(0,v.useState)(null),n=(0,v.useRef)(e);n.current=e;let r=(0,v.useRef)(new Set),[a]=(0,nB.useServerAction)(nJ),s=(0,v.useRef)(null),l=(0,v.useRef)([]),[i,o]=(0,v.useState)([]),u=(0,v.useCallback)(e=>{l.current=e,o(e)},[]),c=(0,v.useRef)(new Map),d=(0,v.useRef)(0),[h,p]=(0,v.useState)(null),m=(0,v.useRef)(()=>{}),f=(0,v.useRef)(!1),{messages:g,sendMessage:x,setMessages:y,status:w,stop:b,error:j,clearError:S}=(0,nI.useChat)({transport:n4,onFinish:e=>m.current(e),onData:e=>{e.type!==`data-${nC.TEXT_CALL_MOVED}`||f.current||(f.current=!0,R.toast.add({type:"warning",title:"Answering on your OpenAI key",description:e.data.why}))}}),T="submitted"===w||"streaming"===w,E=(0,v.useRef)(g);E.current=g;let _=(0,v.useRef)(j);_.current=j;let M=(0,v.useRef)(""),A=(0,v.useCallback)(e=>{let t=n.current;if(!t)return;let r=l.current;u([]);let a=crypto.randomUUID();s.current=a;let i=n6();M.current=JSON.stringify(i??null);let o=[...r.map(n7),...e?[{type:"text",text:e}]:[]];x(o.length?{parts:o}:void 0,{body:{callId:t.callId,standing:t.standing,runsOn:i,turn:a,where:t.where}})},[x,u]),C=(0,v.useCallback)(()=>{let e=n.current;if(e){for(let e of(n.current=null,t(null),s.current=null,c.current.values()))nz.delete(e.key);c.current.clear(),u([]),d.current=0,f.current=!1,p(null),b(),y([]),S(),nV(e.callId).then(nF.unwrapResult).finally(()=>(0,J.revalidate)(k.queryKey.callHistory(null)))}},[b,y,S,u]),L=(0,v.useRef)(C);L.current=C,(0,v.useEffect)(()=>()=>L.current(),[]);let I=(0,v.useCallback)(e=>{u([...l.current,e]);let t=n.current,r=s.current;t&&r&&nX(t.callId,r,e).then(nF.unwrapResult).catch(()=>{})},[u]);(0,v.useEffect)(()=>X.screenActs.subscribe(e=>{n.current&&I({id:crypto.randomUUID(),text:nY(e),said:!1})}),[I]);let D=(0,v.useCallback)(async e=>{let l=n.current;if(!l){let[e,s]=await Promise.all([a(n6()),n3()]);n.current=l={...e,at:Date.now(),where:s?.where??null},r.current=nq(F.current??[]),t(l)}if(d.current=0,s.current)return I({id:crypto.randomUUID(),text:e,said:!0});S(),A(e)},[a,I,S,A]),P=(0,v.useCallback)(()=>{let e=E.current,t=e.at(-1);if(n.current&&t){if("assistant"===t.role){let n=M.current!==JSON.stringify(n6()??null)?-1:t.parts.findLastIndex(e=>(0,nO.isToolUIPart)(e)&&!e.providerExecuted&&("output-available"===e.state||"output-error"===e.state));u([...(0,nC.notesIn)([{...t,parts:t.parts.slice(n+1)}]),...l.current]),y(n<0?e.slice(0,-1):[...e.slice(0,-1),{...t,parts:t.parts.slice(0,n+1)}])}S(),A(null)}},[A,y,S,u]),{data:$}=(0,J.useServerRoute)(k.queryKey.threads),F=(0,v.useRef)($);F.current=$;let B=(0,v.useCallback)(()=>{if(!n.current||!F.current)return;let e=nG(F.current),t=new Set(e.map(e=>e.key)),a=l.current.filter(e=>{let n=c.current.get(e.id);return void 0!==n&&!t.has(n.key)});if(a.length){for(let e of a){let t=c.current.get(e.id);t&&nz.delete(t.key),c.current.delete(e.id)}u(l.current.filter(e=>!a.includes(e)))}for(let t of e){if(nz.has(t.key)||r.current.has(t.key))continue;nz.add(t.key);let e={id:crypto.randomUUID(),text:t.line,said:!1};c.current.set(e.id,{key:t.key,rows:t.relayIds,show:t.show}),s.current&&p(t.show),I(e)}if(s.current||_.current||d.current>=O.TEXT_CALL.autoTurns)return;let i=l.current.filter(e=>c.current.has(e.id)),o=i.length?c.current.get(i[i.length-1].id):null;o&&(d.current+=1,p(o.show),A(null))},[u,I,A]),z=null!==e;(0,v.useEffect)(()=>{z&&$&&B()},[z,$,B]),m.current=({message:e,messages:t,isAbort:r,isError:a,isDisconnect:i})=>{if(r||!n.current)return;s.current=null;let o=new Set((0,nC.notesIn)([e]).map(e=>e.id));if(u(l.current.filter(e=>!o.has(e.id))),a||i)return;let d=new Set((0,nC.notesIn)(t).map(e=>e.id)),h=[];for(let[e,t]of c.current)d.has(e)&&(h.push(...t.rows),c.current.delete(e));if(h.length&&n$(h).then(nF.unwrapResult).catch(e=>R.toast.add({type:"error",title:"Could not record relay delivery",description:(0,N.errorToString)(e)})),l.current.some(e=>e.said))return A(null);B()},(0,v.useEffect)(()=>{if(T||!h)return;let e=setTimeout(()=>p(null),O.CALL_LINE.lingerMs);return()=>clearTimeout(e)},[T,h]);let q=g.at(-1)?.role==="assistant"?g.at(-1):null,U=q?.parts??[],K=U.at(-1),H=(0,v.useMemo)(()=>{let e=[],t=!1,n=(n,r,a)=>{if(!a)return;let s=t&&"assistant"===r;"assistant"===r&&(t=!1),e.push({id:n,role:r,text:a,...s?{fresh:!0}:{}})};for(let e of g){if("system"===e.role)continue;let r=e.role,a=[],s=0,l=()=>{let t=a.join("\n\n").trim();a=[],n(`${e.id}:${s++}`,r,"assistant"===r?(0,N.captionText)(t):t)};for(let r of e.parts){"text"===r.type&&a.push(r.text);let e=(0,nC.noteOf)(r);e&&(l(),e.said?n(e.id,"user",e.text):t=!0)}l()}let r=new Set((0,nC.notesIn)(g).map(e=>e.id));for(let e of i)e.said&&!r.has(e.id)&&n(e.id,"user",e.text);return e},[g,i]),W=[...U].reverse().find(nO.isToolUIPart),G=W?.toolCallId??null,Y=W?(0,nO.getToolName)(W):null,V=W?.state==="output-available"||W?.state==="output-error",Z=W?.output,Q=(0,v.useMemo)(()=>V&&Y===nD.TOOL_NAMES.web_search?(0,nZ.searchSourcesOf)(JSON.stringify(Z??null)):[],[V,Y,Z]),ee=Z?.action?.query,et=JSON.stringify({..."string"==typeof ee?{query:ee}:{},...W?.input??{}}),en=Y?(0,nZ.toolBot)(Y,et,F.current,void 0===Z?void 0:JSON.stringify(Z)):null,er=Y?(0,nZ.toolLine)(Y,et,en):null,ea=K?.type==="text",es=(0,v.useMemo)(()=>G&&Y&&(!ea||Q.length)?{id:G,name:Y,line:er,bot:en,done:V,...Q.length?{sources:Q}:{}}:null,[G,Y,er,en,V,Q,ea]),[el,ei]=(0,v.useState)(null),eo=es?.done&&!es.sources?es.id:null;(0,v.useEffect)(()=>{if(!eo)return;let e=setTimeout(()=>ei(eo),O.CALL_LINE.lingerMs);return()=>clearTimeout(e)},[eo]);let eu=es&&es.id!==el?es:h,ec=!!T&&K?.type!=="text"&&(!es||!!es.done),[ed,eh]=(0,v.useState)(null);(0,v.useEffect)(()=>{eh(ec?Date.now():null)},[ec]);let ep=[...U].reverse().find(e=>"reasoning"===e.type),em=ec&&ep?.type==="reasoning"&&(0,nZ.reasoningTitle)(ep.text)||null,ef=e?T?K?.type==="text"?"speaking":es&&!es.done&&es.name===nD.TOOL_NAMES.thread_start?"delegating":"working":"listening":"idle";return{on:null!==e,busy:T,status:ef,messages:H,tool:eu,thinkingSince:ed,thinkingTitle:em,since:e?.at??null,error:j?j.message:null,say:D,again:P,end:C}}(),{status:a,failed:s,messages:l,tool:i,thinkingSince:o,thinkingTitle:u,ended:c,faceWord:d,idleLeft:h,since:p,call:m,ringing:f,decline:g,getSpectrum:x,getMicSpectrum:y,wakePhrase:w,hotkey:b}=function(t=!1){let n,r,a=(0,v.useRef)(null),{data:s}=(0,J.useServerRoute)(k.queryKey.thursdaySettings),l=(0,v.useRef)(null);l.current=(0,e4.useVoiceLine)(s?.runsOn??null).line;let i=(0,v.useRef)(null),o=(0,v.useRef)(null),[u,c]=(0,v.useState)("idle"),[d,h]=(0,v.useState)(!1),p=(0,v.useRef)(null),m=(0,v.useCallback)(e=>{p.current&&clearTimeout(p.current),p.current=e?setTimeout(()=>h(!1),6e3):null,h(e)},[]),[f,g]=(0,v.useState)([]),[x,y]=(0,v.useState)(null),[w,b]=(0,v.useState)(null),[j,S]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[_,M]=(0,v.useState)(null),[A,C]=(0,v.useState)(null),[L,I]=(0,v.useState)(null),P=nx(),$=P?.moment.kind==="here"&&null!==P.phase;(0,v.useEffect)(()=>{$&&function(e=new Date){let t=r2(e);try{window.localStorage.setItem(r1,t)}catch{r5=t}}()},[$]);let F=(0,v.useRef)(null),B=(0,v.useRef)(null),q=(0,v.useRef)({on:!1,spoke:!1,giveUp:null}),U=(0,v.useRef)(null),K=(0,v.useRef)(null),H=(0,v.useRef)(0),W=(0,v.useRef)(null),V=(0,v.useRef)(!1),Z=(0,v.useRef)(null),Q=(0,v.useRef)(null),ee=(0,v.useRef)(null),et=(0,v.useRef)(nz),en=(0,v.useRef)(new Set),er=(0,v.useRef)(new Set),ea=(0,v.useRef)([]),es=(0,v.useRef)([]),el=(0,v.useRef)(0),ei=(0,v.useRef)(null),eo=(0,v.useRef)(0),eu=(0,v.useRef)(!1),ec=(0,v.useRef)(!1),ed=(0,v.useRef)(void 0),eh=(0,v.useRef)(null),ep=eh.current??=(n=[],r=null,{send(e){r?r(e):n.push(e)},open(e){r=e;let t=n;for(let r of(n=[],t))e(r)},close(){r=null},clear(){let e=n;return n=[],e}}),em=(0,v.useRef)(!1),ef=(0,v.useRef)(!1),eg=(0,v.useRef)(!1),ex=(0,v.useRef)(0),ey=(0,v.useCallback)(e=>{W.current&&clearTimeout(W.current),V.current=!1;let t=(0,nZ.toolBot)(e.name,e.arguments,ed.current);y({id:e.id,name:e.name,line:(0,nZ.toolLine)(e.name,e.arguments,t),bot:t,done:!1})},[]),ew=(0,v.useCallback)((e,t)=>{let n=(0,nZ.toolBot)(e.name,e.arguments,ed.current,t);n&&y(t=>t?.id===e.id&&t.bot!==n?{...t,bot:n,line:(0,nZ.toolLine)(e.name,e.arguments,n)}:t)},[]),eb=(0,v.useCallback)(e=>{W.current&&clearTimeout(W.current),V.current=!0,y({...e,done:!1})},[]),ev=(0,v.useCallback)(e=>{y(t=>t?.id===e?{...t,done:!0}:t),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>y(e=>e?.done?null:e),O.CALL_LINE.lingerMs)},[]),ek=(0,v.useCallback)(()=>{if(q.current.giveUp&&clearTimeout(q.current.giveUp),q.current.spoke){for(let e of ea.current)en.current.delete(e);let e=es.current;e.length&&n$(e).then(nF.unwrapResult).catch(e=>R.toast.add({type:"error",title:"Could not record relay delivery",description:(0,N.errorToString)(e)}))}es.current=[],ea.current=[],q.current={on:!1,spoke:!1,giveUp:null},U.current?.(),V.current&&(V.current=!1,y(e=>e?.kind==="relay"?{...e,done:!0}:e),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>y(e=>e?.kind==="relay"?null:e),O.CALL_LINE.relayLingerMs))},[]),ej=(0,v.useCallback)(()=>{q.current.giveUp&&clearTimeout(q.current.giveUp),q.current={on:!0,spoke:!1,giveUp:setTimeout(ek,O.CALL_RELAY.readMs)}},[ek]),eS=(0,v.useCallback)(e=>{F.current=e,M(e),C(null)},[]),eN=(0,v.useCallback)((e,t)=>{let n=()=>{B.current&&clearTimeout(B.current),B.current=null};if(t){n(),null!==F.current&&eS(null);return}if(e){n(),null===F.current&&eS(Date.now());return}null===F.current||B.current||(B.current=setTimeout(()=>{B.current=null,eS(null)},O.CALL_LINE.thinkingTailMs))},[eS]),eT=(0,v.useCallback)(()=>{let e=a.current,t=ed.current;if(!e||!t||q.current.on||ec.current||null!==F.current||ei.current)return;let n=eu.current;if(eu.current=!1,!n&&Date.now()-eo.current<O.CALL_RELAY.quietMs)return;let r=nG(t).filter(e=>!et.current.has(e.key)&&!er.current.has(e.key)),s=r[0];if(!s)return;let l=r.filter(e=>e.kind===s.kind).slice(0,O.CALL_RELAY.perTurn),i=l.map(e=>e.line);for(let e of l)et.current.add(e.key),en.current.add(e.key);s.key.startsWith("done:")&&!ng.current()&&I(r0()),ej(),ea.current=l.map(e=>e.key),es.current=l.flatMap(e=>e.relayIds),eb((l.at(-1)??s).show),e.append("commentary",1===i.length?i.join(""):`[${i.length} updates.]
14
+
15
+ ${i.join("\n\n")}`).then(e=>{e||(es.current=[],ek())})},[ej,ek,eb]),eE=(0,v.useRef)(u);(0,v.useEffect)(()=>{eE.current=u},[u]);let e_=(0,v.useRef)("listening"),eM=(0,v.useRef)(null),eA=(0,v.useCallback)(()=>{eM.current&&clearTimeout(eM.current),eM.current=null},[]),eC=(0,v.useCallback)(e=>{eE.current=e,c(e)},[]),eL=(0,v.useCallback)(e=>{e_.current=e;let t=eE.current;if("speaking"===e){eA(),eC(e);return}let n="working"===e||"delegating"===e;if(n&&("working"===t||"delegating"===t)){eA(),eC(e);return}n||"listening"!==t?eM.current||(eM.current=setTimeout(()=>{eM.current=null,eC(e_.current)},n?800:600)):eA()},[eA,eC]),eR="idle"!==u&&"connecting"!==u&&"ending"!==u,{data:eI}=(0,J.useServerRoute)(k.queryKey.threads,{refreshInterval:O.INBOX_POLL_MS}),eO=(0,v.useRef)(!1);(0,z.useAppEvent)({hello:()=>{if(!eO.current){eO.current=!0;return}(0,J.revalidateAll)()},threads:()=>void(0,J.revalidate)(k.queryKey.threads),routines:()=>void(0,J.revalidate)(k.queryKey.routines),memory:()=>void(0,J.revalidate)(k.queryKey.memory),mcp:()=>{(0,J.revalidate)(k.queryKey.mcp),(0,J.revalidate)(k.queryKey.mcpTools)},config:()=>{(0,J.revalidate)(k.queryKey.config),(0,J.revalidate)(k.queryKey.llmModel)}});let{data:eD}=(0,J.useServerRoute)(k.queryKey.bot);(0,v.useEffect)(()=>{eI&&X.botThreads.sync(eI,eD)},[eI,eD]),(0,v.useEffect)(()=>{ed.current=eI},[eI]);let eP=function({threads:e,resting:t,writing:n}){let r=(0,v.useRef)(Date.now()),[a,s]=(0,v.useState)([]),[l,i]=(0,v.useState)(null),o=a.length>0,u=(0,nL.useThursdayStore)(e=>e.callBack);(0,v.useEffect)(()=>{if(!e)return;let a=new Set(e.filter(e=>{let t,n;return t=e,"off"!==(n=u)&&!t.seen&&(t.room.questions.length>0||"any"===n&&"running"!==t.status)}).map(e=>e.id));if(s(e=>e.every(e=>a.has(e))?e:e.filter(e=>a.has(e))),!t||n)return;let l=r.current,o=e.filter(e=>a.has(e.id)&&(0,Y.toDate)(e.updatedAt).getTime()>l);o.length&&(r.current=Math.max(...o.map(e=>(0,Y.toDate)(e.updatedAt).getTime())),i(null),s(e=>[...e,...o.map(e=>e.id).filter(t=>!e.includes(t))]))},[e,u,t,n]),(0,v.useEffect)(()=>{n?(s([]),i(null)):r.current=Date.now()},[n]);let c=(0,v.useCallback)(()=>{s([]),i(null)},[]);(0,G.useEscape)(o,c),(0,v.useEffect)(()=>{if(!o||null!==l)return;let e=setTimeout(()=>i(Date.now()),O.CALL_BACK.ringMs);return()=>clearTimeout(e)},[o,l]),(0,v.useEffect)(()=>{if(o&&null===l){let e;return(e=new Audio("/sounds/ring.ogg")).play().catch(()=>{}),()=>e.pause()}},[o,l]);let d=(0,v.useMemo)(()=>{let[t,...n]=a.flatMap(t=>{let n=e?.find(e=>e.id===t);if(!n)return[];let r=n.room.questions[0];return[{id:n.id,bot:r?.bot??n.bot,kind:r?"question":"done"===n.status?"done":"stopped",label:n.label,text:r?.text??n.outcome??n.ask?.question??n.label,options:r?.options??[],questionId:r?.id??null}]});return t?{first:t,others:n,missedAt:l}:null},[a,e,l]);(0,v.useEffect)(()=>{X.ringingThreads.set(a)},[a]);let h=(0,v.useCallback)(()=>{s([]),i(null)},[]);return{ringing:d,isRinging:o,ringingFor:a,answered:h,unanswered:(0,v.useCallback)(e=>{e.length&&(s(t=>[...e,...t.filter(t=>!e.includes(t))]),i(Date.now()))},[]),settle:(0,v.useCallback)(()=>{r.current=Date.now()},[]),decline:c}}({threads:eI,resting:"idle"===u,writing:t}),{answered:e$,unanswered:eF,settle:eB}=eP;(0,v.useEffect)(()=>X.screenActs.subscribe(e=>{em.current&&ep.send(nY(e))}),[ep]);let ez=(0,v.useRef)(null);(0,v.useEffect)(()=>{var e;let t,n,r=()=>{let e=ez.current;e&&em.current&&!q.current.on&&(ez.current=null,ep.send(e))};U.current=r;let a=(e=(e,t)=>{em.current&&(ez.current=e?`The user started showing you their ${e}. What is on it now is known only by looking at it; what was said about it before may not be what is there.`:`The user stopped showing you their ${t??"screen"}.`,r())},t=nS(),n=()=>{let n=nS();if(n===t)return;let r=t;t=n,e(n,r)},nv.add(n),()=>{nv.delete(n)});return()=>{a(),U.current=null}},[ep]);let eq=(0,v.useCallback)(async(e=null)=>{if(eg.current)return;eg.current=!0,ei.current&&clearInterval(ei.current),ei.current=null,ex.current+=1;let t=a.current,n=Q.current;for(let e of(a.current=null,Q.current=null,em.current=!1,ef.current=!1,ez.current=null,nE(),ng.clear(),eu.current=!1,en.current))et.current.delete(e);en.current.clear(),ep.close(),ep.clear(),Z.current?.abort(),Z.current=null,q.current.spoke=!1,ek(),W.current&&clearTimeout(W.current),eA(),eB(),S(null),b(null),c(t?"ending":"idle"),t&&I(rQ()),g([]),y(null),eS(null),B.current&&clearTimeout(B.current),B.current=null,V.current=!1,await t?.close(),ee.current?.(),ee.current=null;let r=K.current;K.current=null,eg.current=!1,c("idle"),t&&E(e),n&&nV(n,r),t&&o.current&&(o.current.currentTime=0,o.current.play().catch(()=>{}))},[ep,eA,ek,eS]);(0,v.useEffect)(()=>{let e=()=>{let e=Q.current;e&&navigator.sendBeacon(k.queryKey.callEnd,e)};return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[]),(0,v.useEffect)(()=>()=>{ex.current+=1,ee.current?.(),ee.current=null,a.current?.close(),a.current=null;let e=Q.current;for(let t of(Q.current=null,em.current=!1,ef.current=!1,e&&nV(e),en.current))et.current.delete(t);en.current.clear(),Z.current?.abort(),Z.current=null,W.current&&clearTimeout(W.current),eM.current&&clearTimeout(eM.current),q.current.giveUp&&clearTimeout(q.current.giveUp),B.current&&clearTimeout(B.current),p.current&&clearTimeout(p.current),ei.current&&clearInterval(ei.current),nE(),ng.clear()},[]);let eU=(0,v.useCallback)(()=>{if(ei.current)return;let e=Date.now();ei.current=setInterval(()=>{let t=Date.now();((el.current>e-O.CALL_END.unsaidMs?t-Math.max(el.current,e)>=O.CALL_END.quietMs:t-e>=O.CALL_END.unsaidMs)||t-e>=O.CALL_END.maxMs)&&eq("hungUp")},100)},[eq]);(0,v.useEffect)(()=>{if(!eR)return;H.current=Date.now();let e=setInterval(()=>{if(!a.current)return;let e=O.CALL_IDLE.hangUpMs-(Date.now()-H.current);S(e<=O.CALL_IDLE.warnMs?Math.max(0,Math.ceil(e/1e3)):null),e<=0&&!q.current.on&&eq("quiet")},1e3);return()=>clearInterval(e)},[eR,eq]),(0,v.useEffect)(()=>{if(!eR)return;let e=setInterval(eT,1e3);return()=>clearInterval(e)},[eR,eT]);let eK=(0,v.useCallback)(async()=>{let t=eP.isRinging,n=eP.ringingFor;if(ef.current||eg.current)return;if(em.current||"idle"!==u)return eq();e$(),ru(),c("connecting"),E(null),m(!1),ef.current=!0,em.current=!0,K.current=null,ep.clear(),ex.current+=1;let r=ex.current,s=()=>em.current&&ex.current===r,d={server:!1},h=l.current;try{i.current??=(0,nM.createAudioTap)(),function(e){if("suspended"!==e.state||at)return;at=!0;let t=()=>{at=!1,window.removeEventListener("pointerdown",t),window.removeEventListener("keydown",t),e.resume().catch(()=>{})};window.addEventListener("pointerdown",t),window.addEventListener("keydown",t),R.toast.add({type:"warning",title:"Tap anywhere to hear her",description:"This call opened on its own, so the browser is holding the audio."})}(i.current.open().context);let n=new Audio("/sounds/start_voice.ogg");o.current??=new Audio("/sounds/end_voice.ogg");let r=n3(),l=!t&&function(e=new Date){let t=r2(e);if(r5===t)return!1;try{return window.localStorage.getItem(r1)!==t}catch{return!0}}()&&"visible"===document.visibilityState&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.race([r.then(t=>!!t?.where.weather&&Promise.all([(0,r3.loadWorld)(),e.A(5735)]).then(()=>!0,e=>(console.warn(`No globe on this call: ${(0,N.errorToString)(e)}`),!1))),new Promise(e=>setTimeout(()=>e(!1),O.HERE.waitMs))]):null,u=await (!("locks"in navigator)?Promise.resolve(()=>{}):new Promise(e=>{navigator.locks.request("thursday-spoken-call",{ifAvailable:!0},t=>t?new Promise(t=>e(()=>t())):void e(null))}));if(!u)throw new r8("A call is already on in another tab of this app. Hang up there, or go on there.");ee.current=u;let c=new AbortController;Z.current=c;let p={failures:0},f={failures:0},x={callId:"",opening:null,here:null,standing:null,opened:{webSearch:D.LIVE_DEFAULTS.webSearch,readSkills:D.LIVE_DEFAULTS.readSkills}},w=new Map,v=new Map,k=null,j=e=>{let t={query:e.query,sources:e.sources};return ar(p,()=>r7(x.callId,[{id:e.row,role:"tool",tool:nD.TOOL_NAMES.web_search,text:JSON.stringify(t),seq:Math.max(0,Math.round(e.seq)),fragments:null}])),!!e.sources.length&&k===e.id&&(W.current&&clearTimeout(W.current),y(n=>n&&n.id!==e.id?n:{id:e.id,name:nD.TOOL_NAMES.web_search,line:(0,nZ.toolLine)(nD.TOOL_NAMES.web_search,JSON.stringify(t)),done:!0,bot:null,sources:e.sources}),!0)},S=await rW({initialize:async e=>{let n=await r,a=n?.where.weather,i=!!(a&&l&&await l&&"visible"===document.visibilityState);d.server=!0;let o=(0,nF.unwrapResult)(await r4(e,t,n?.where??null,i));if(!s())throw nV(o.callId),Error("The call closed during startup.");return Q.current=o.callId,x.callId=o.callId,x.opening=o.opening,x.here=o.here&&n&&a?{...n.position,code:n.country,weather:a}:null,x.standing=o.standing,x.opened=o.opened,o.relay?{sdp:o.sdp,relay:o.relay}:o.sdp},audio:i.current,on:{runTool:async e=>{if(e.name===nD.TOOL_NAMES.end_call)return eU(),"Ending the call.";if(e.name===nD.TOOL_NAMES.emote){if(ng.current())return"Nothing was shown: their screen is showing where they are for a few seconds more.";let{word:t,reply:n}=function(e){let t="";try{let n=JSON.parse(e);n&&"object"==typeof n&&"text"in n&&(t=String(n.text??"").trim())}catch{t=""}let n=Array.from(t).length;if(!n)return{word:null,reply:"Nothing was shown: text is empty."};if(n>rV.FACE_WORD_MAX)return{word:null,reply:`Too long: ${n} characters, ${rV.FACE_WORD_MAX} at most. Nothing was shown.`};let r=(0,rV.undrawable)(t);return r?{word:null,reply:`Cannot draw "${r}"; use only the characters \`text\` lists. Nothing was shown.`}:{word:t.toUpperCase(),reply:"Shown."}}(e.arguments);return t&&I({text:t,at:Date.now()}),n}if(e.name===nD.TOOL_NAMES.look_at_shared){var t;if(!nS()){let e;return(e=[nN("screen")&&"a screen, a window or a tab with Share screen",nN("camera")&&"their camera with Camera"].filter(Boolean)).length?`Nothing is being shown. They can show you ${e.join(", or ")}, on the line under your face.`:"Nothing is being shown, and this browser can show you neither a screen nor a camera."}let e=await (t=a.current?.messageLimit(),n_((t&&Number.isFinite(t)&&t>2048?t:65536)-1024));return"failed"in e?e.failed:{output:`Their ${e.kind} as it is now follows, as a picture.`,image:e.url}}ey(e);let n=e.name===nD.TOOL_NAMES.web_search;n&&(k=e.id);let r=!1;try{let t=await n9(x.callId,e,x.opened,c.signal);ew(e,t);let a=e.name===nD.TOOL_NAMES.thread_start?function(e){try{let{threadId:t,bot:n,label:r}=JSON.parse(e);return"string"==typeof t&&"string"==typeof n&&"string"==typeof r?{bot:n,label:r}:null}catch{return null}}(t):null;return a&&ep.send((({bot:e,label:t})=>`${e} took "${t}" and is working on it now.`)(a)),n&&(r=j({id:e.id,row:e.item??e.id,query:(0,nZ.searchQueryOf)(e.arguments),sources:(0,nZ.searchSourcesOf)(t),seq:0})),t}finally{r||ev(e.id)}},search:e=>{if(!e.done){k=e.id,ey({id:e.id,name:nD.TOOL_NAMES.web_search,arguments:JSON.stringify({query:e.query})});return}let t={id:e.id,row:e.id,query:e.query,sources:e.sources,seq:e.seq};v.set(e.responseId,t),j(t)||ev(t.id)},cited:(e,t)=>{let n=v.get(e);if(!n)return;let r=new Set(n.sources.map(e=>e.url));n.sources=[...n.sources.map(e=>t.find(t=>t.url===e.url)??e),...t.filter(e=>!r.has(e.url))],j(n)},reasoning:e=>{let t=(0,nZ.reasoningTitle)(e.text);t&&C(t),ar(f,()=>r6(x.callId,{...e,seq:Math.max(0,Math.round(e.seq))}),"The backend's thinking is not being saved")},turn:e=>{let t="tool"===e.role?"":an(e.text),n=!!t&&t!==an(w.get(e.id)?.text??"");if(n&&(eo.current=Date.now()),n&&"user"===e.role&&(H.current=Date.now(),k)){let e=k;k=null,y(t=>t?.id===e?null:t)}"tool"!==e.role&&Q.current===x.callId&&(w.set(e.id,{seq:e.seq,id:e.id,role:e.role,text:e.text}),g([...w.values()].sort((e,t)=>e.seq-t.seq).slice(-O.CALL_PAGE.scrollback))),e.done&&ar(p,()=>r7(x.callId,[{id:e.id,role:e.role,tool:e.tool,text:e.text,seq:Math.max(0,Math.round(e.seq)),fragments:e.fragments??null}]))},activity:e=>{var t;eL((t=e).speaking?"speaking":t.working||t.tools.length?t.tools.includes(nD.TOOL_NAMES.thread_start)?"delegating":"working":"listening");let n=e.working||e.tools.length>0;ec.current=n,eN(n,e.speaking),e.speaking&&(el.current=Date.now()),(e.speaking&&!q.current.on||e.working||e.tools.length)&&(H.current=Date.now()),q.current.on&&(e.speaking?q.current.spoke=!0:q.current.spoke&&ek())},finalized:e=>{K.current=e},warn:e=>R.toast.add({type:"warning",title:"Call warning",description:e}),failed:e=>{let t=K.current?.reason;if("expired"===t||"remote_hangup"===t)return void eq("expired"===t?"expired":"closed");if("content"===t){R.toast.add({type:"warning",title:"Live ended the call",description:"Its safety filter stopped the conversation."}),eq("closed");return}R.toast.add({type:"error",title:r9(h,!1),description:e}),m(!0),eq(K.current?"closed":"dropped")}}});if(!s())return void await S.close();a.current=S,ef.current=!1,eu.current=t,er.current=t?new Set:nq(ed.current??[]),ep.open(e=>void S.append("thinking",e)),eo.current=Date.now(),x.here&&ng.show({kind:"here",scene:x.here}),x.opening&&(ej(),S.holdInput(O.LIVE_CALL.openingHoldMs),S.append("instructions",x.opening).then(e=>{e||ek()})),x.standing&&S.brief(x.standing),eC("listening"),b(Date.now()),n.play().catch(()=>{})}catch(e){if(ee.current?.(),ee.current=null,s()&&e instanceof r8?R.toast.add({type:"warning",title:"One call at a time",description:e.message}):s()&&(R.toast.add({type:"error",description:(0,N.errorToString)(e),title:d.server?r9(h,!0):"Could not start the call"}),m(!0),t&&eF(n)),ex.current!==r)return;Q.current&&nV(Q.current),Q.current=null,ef.current=!1,em.current=!1,Z.current=null,ep.clear(),c("idle")}},[u,eq,ey,ew,ev,eL,eC,ep,ej,ek,eN,m,eU,eP.isRinging,eP.ringingFor,e$,eF]);(0,v.useEffect)(()=>{if(!T)return;let e=setTimeout(()=>E(null),O.CALL_ENDED_MS);return()=>clearTimeout(e)},[T]);let eH=(0,v.useCallback)(()=>i.current?.read()??ae,[]),eW=(0,v.useCallback)(()=>i.current?.readMic()??ae,[]),eG=(0,nL.useThursdayStore)(e=>e.wake),[eY,eV]=(0,v.useState)(!1),eJ=nc();(0,v.useEffect)(()=>nu.onPlace(()=>void eK()),[eK]),ry({enabled:"idle"===u&&eG.enabled&&!eY&&!eJ,phrases:[eG.phrase],onWake:()=>void eK(),onError:e=>{eV(!0),R.toast.add({type:"error",title:"Wake word off",description:e})}});let eX=(0,nL.useThursdayStore)(e=>e.hotkey),eZ="connecting"===u||"ending"===u;return(0,G.useHotkey)({enabled:eX.enabled&&!eZ&&!eJ,combo:eX.enabled&&(0,G.isCombo)(eX.combo)?eX.combo:null,onPress:()=>void eK()}),{status:u,failed:d,messages:f,tool:x,ended:T,thinkingSince:_,thinkingTitle:A,faceWord:L,idleLeft:j,since:w,call:eK,ringing:eP.ringing,decline:eP.decline,getSpectrum:eH,getMicSpectrum:eW,wakePhrase:eG.enabled&&!eY?eG.phrase:null,hotkey:eX.enabled&&(0,G.isCombo)(eX.combo)?eX.combo:null}}(n.on),j=(0,G.useHotkeyLabel)(b),S=(0,nL.useThursdayStore)(e=>e.captionView),{data:T}=(0,J.useServerRoute)(k.queryKey.config),E=(0,e4.useVoiceLine)(),_=E.known?null!==E.line:t,M="idle"!==a,A=n.end;(0,v.useEffect)(()=>{M&&n.on&&A()},[M,n.on,A]);let C=n.on&&!M,L=(0,nL.useThursdayStore)(e=>e.textModel),{settings:I}=(0,nR.useLiveSettings)(),$=I?.backendModel??D.LIVE_DEFAULTS.backendModel,F=(0,v.useMemo)(()=>{let e=e=>(0,e6.isConfigSet)(T,e),t=(0,nC.textCallRunsOn)(e),r=L&&e(P.TEXT_MODEL_PROVIDERS[L.provider].apiKeyName)?L:t?{provider:t,model:$}:null;return{on:C,busy:n.busy,error:n.error,say:n.say,again:n.again,end:n.end,runsOn:r,fallback:r?.provider!=="openai"&&e(P.TEXT_MODEL_PROVIDERS.openai.apiKeyName)?{provider:"openai",model:$}:null}},[C,n.busy,n.error,n.say,n.again,n.end,T,L,$]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aN,{live:"idle"!==a,ringing:null!==f}),(0,r.jsx)(aW,{status:C?n.status:a,failed:C?null!==n.error:s,messages:C?n.messages:l,tool:C?n.tool:i,thinkingSince:C?n.thinkingSince:o,thinkingTitle:C?n.thinkingTitle:u,ended:c,faceWord:d,onTap:m,ringing:_?f:null,onDecline:g,wakePhrase:w,hotkeyLabel:j,idleLeft:h,since:p,getSpectrum:C?nA:x,getMicSpectrum:y,captionView:S,callable:_,written:M?null:F})]})}],692888)},379227,(e,t,n)=>{var r;"u">typeof __nccwpck_require__&&(__nccwpck_require__.ab="/ROOT/node_modules/next/dist/compiled/tty-browserify/"),(r={}).isatty=function(){return!1},r.ReadStream=function(){throw Error("tty.ReadStream is not implemented")},r.WriteStream=function(){throw Error("tty.WriteStream is not implemented")},t.exports=r},90317,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={bindSnapshot:function(){return u},createAsyncLocalStorage:function(){return o},createSnapshot:function(){return c}};for(var a in r)Object.defineProperty(n,a,{enumerable:!0,get:r[a]});let s=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class l{disable(){throw s}getStore(){}run(){throw s}exit(){throw s}enterWith(){throw s}static bind(e){return e}}let i="u">typeof globalThis&&globalThis.AsyncLocalStorage;function o(){return i?new i:new l}function u(e){return i?i.bind(e):l.bind(e)}function c(){return i?i.snapshot():function(e,...t){return e(...t)}}},242344,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,e.r(90317).createAsyncLocalStorage)()},563599,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=e.r(242344)},309885,(e,t,n)=>{"use strict";function r(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return r}})},667585,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return a}});let r=e.r(132061);function a({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new r.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},652157,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return o}});let r=e.r(843476),a=e.r(174080),s=e.r(563599),l=e.r(309885),i=e.r(543369);function o({moduleIds:e}){if("u">typeof window)return null;let t=s.workAsyncStorage.getStore();if(void 0===t)return null;let n=[];if(t.reactLoadableManifest&&e){let r=t.reactLoadableManifest;for(let t of e){if(!r[t])continue;let e=r[t].files;n.push(...e)}}if(0===n.length)return null;let u=(0,i.getAssetTokenQuery)();return(0,r.jsx)(r.Fragment,{children:n.map(e=>{let n=`${t.assetPrefix}/_next/${(0,l.encodeURIPath)(e)}${u}`;return e.endsWith(".css")?(0,r.jsx)("link",{precedence:"dynamic",href:n,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,a.preload)(n,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},869093,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return u}});let r=e.r(843476),a=e.r(271645),s=e.r(667585),l=e.r(652157);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},u=function(e){let t={...o,...e},n=(0,a.lazy)(()=>t.loader().then(i)),u=t.loading;function c(e){let i=u?(0,r.jsx)(u,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,c=o?a.Suspense:a.Fragment,d=t.ssr?(0,r.jsxs)(r.Fragment,{children:["u"<typeof window?(0,r.jsx)(l.PreloadChunks,{moduleIds:t.modules}):null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(c,{...o?{fallback:i}:{},children:d})}return c.displayName="LoadableComponent",c}},770703,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return a}});let r=e.r(555682)._(e.r(869093));function a(e,t){let n={};"function"==typeof e&&(n.loader=e);let a={...n,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},618566,(e,t,n)=>{t.exports=e.r(976562)}]);