@yuriai/web 0.2.28 → 0.2.29-beta.4

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 (255) hide show
  1. package/dist/assets/AgentAvatar-GVufO03R.js +1 -0
  2. package/dist/assets/AssistantContactStatus-AG7iGeRF.js +3 -0
  3. package/dist/assets/{AssistantUnreadBadge-DqThZdCe.js → AssistantUnreadBadge-BMCaH0Cc.js} +1 -1
  4. package/dist/assets/{AssistantView-DPUDCXoY.js → AssistantView-C5ACV-pb.js} +1 -1
  5. package/dist/assets/{DiagramView-CHVLoYrV.js → DiagramView-DJDzscnd.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-Cj3JXYvE.js → FadeInOnReveal-8NiBU75a.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-CBZYeKHb.js → GuiPluginSurface-DfLl4Gd9.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-_Z5wycnH.js → GuiPluginWindow-CW0-Tapi.js} +1 -1
  9. package/dist/assets/{Icon-CeRMtJa8.js → Icon-CLLDJn-P.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-DjLaKB4o.js → ImageLoadingPlaceholder-DTWzB26a.js} +1 -1
  11. package/dist/assets/LoadingImage-B89ghYMH.js +1 -0
  12. package/dist/assets/MarkdownRenderer-YzZqs3v5.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-_plqOlsV.js → MarkdownRendererImpl-BjjAFHTQ.js} +3 -3
  14. package/dist/assets/MarkstreamRendererImpl-D8tam--u.js +3 -0
  15. package/dist/assets/{MobileDetailNavigation-SeT764Ps.js → MobileDetailNavigation-B-AuJG6R.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-BY1-oo_E.js → MobileResizableSheet-CAj4YGtu.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-Dw8gLtJD.js → MobileShareBridge-B8X_MEk1.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-vvveBlBV.js +2 -0
  19. package/dist/assets/MultiRunWindow-C0dOS6fA.js +1 -0
  20. package/dist/assets/{OnboardingScreen-CGqabMbp.js → OnboardingScreen-BdU6Tyax.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-AGSWQKg-.js → OverlayScrollbar-CzQC0JQI.js} +1 -1
  22. package/dist/assets/SettingsView-C0HSdVvS.css +1 -0
  23. package/dist/assets/SettingsView-aWGqxCrZ.js +30 -0
  24. package/dist/assets/SettingsWindow-rX0TNPNO.js +1 -0
  25. package/dist/assets/{TerminalView-OHqpkHzz.js → TerminalView-BArR-jEl.js} +3 -3
  26. package/dist/assets/ToolOutputDialog-Bdwio4o_.js +10 -0
  27. package/dist/assets/YuriLogo-BZC0ckt0.js +1 -0
  28. package/dist/assets/{appThemeRegistry-9j-rCSlE.js → appThemeRegistry-DOuA757r.js} +1 -1
  29. package/dist/assets/appearance--vFosLNi.js +1 -0
  30. package/dist/assets/{assistant-attachment-cache-B_qRvy-k.js → assistant-attachment-cache-DMw2Smc8.js} +1 -1
  31. package/dist/assets/{button-Bjh2BSXh.js → button-BF2cNEuq.js} +1 -1
  32. package/dist/assets/{capgoAdapter-DERfot6h.js → capgoAdapter-BBnW57us.js} +1 -1
  33. package/dist/assets/collapsible-CS5qCQRU.js +1 -0
  34. package/dist/assets/context-menu-C6l4ycZG.js +1 -0
  35. package/dist/assets/desktopRelayRestore-C7pjf6fE.js +1 -0
  36. package/dist/assets/{device-BcRP6Tjd.js → device-DN1GigI_.js} +1 -1
  37. package/dist/assets/{diagram-CXVm2vzI.js → diagram-D9-jif9d.js} +1 -1
  38. package/dist/assets/dialog-r7RRePv5.js +1 -0
  39. package/dist/assets/{dropdown-menu.styles-M78xpvb2.js → dropdown-menu.styles-CX8oXdks.js} +1 -1
  40. package/dist/assets/es-C8kGYKZo.js +15 -0
  41. package/dist/assets/{fileMentionTouchSelection-B9NbPN9D.js → fileMentionTouchSelection-dpFpcetU.js} +2 -2
  42. package/dist/assets/{fileQueries-BeXkd3o6.js → fileQueries-DWj9yB2g.js} +1 -1
  43. package/dist/assets/{fileReferenceActions-CrIAce3K.js → fileReferenceActions-BBLYnGEx.js} +1 -1
  44. package/dist/assets/{fr-CIGqV46N.js → fr-BV_9HcN9.js} +3 -3
  45. package/dist/assets/{gitApi-CY3D5CF0.js → gitApi-b2Mo4rXl.js} +1 -1
  46. package/dist/assets/{gitApiHttp-B7vYwgBh.js → gitApiHttp-DGAlAuET.js} +4 -4
  47. package/dist/assets/host-DB6QzbOw.js +1 -0
  48. package/dist/assets/image-loading-BUouaouB.js +1 -0
  49. package/dist/assets/input-DvF_mp0Y.js +1 -0
  50. package/dist/assets/insertionBoundaries-BviApxnS.js +1 -0
  51. package/dist/assets/{ja-DAhnTq6V.js → ja-CIMpz4Z2.js} +3 -3
  52. package/dist/assets/{ko-FbMgNKcI.js → ko-DPUsuWV1.js} +3 -3
  53. package/dist/assets/magpie-BuRvkGVQ.svg +1 -0
  54. package/dist/assets/main-BchAIbLD.js +2 -0
  55. package/dist/assets/main-Cp31rg32.js +169 -0
  56. package/dist/assets/{markdownHeightCache-DVWGXtAX.js → markdownHeightCache-D02GlOiy.js} +1 -1
  57. package/dist/assets/{markdownTheme-hpURsgju.js → markdownTheme-CHNl6tUv.js} +1 -1
  58. package/dist/assets/{mcpQueries-CdOYmUdO.js → mcpQueries-Cksi876R.js} +1 -1
  59. package/dist/assets/miniChat-BbuRxk9z.js +2 -0
  60. package/dist/assets/mobile-CBiiV7GW.js +2 -0
  61. package/dist/assets/{mobileBackNavigation-CgZndzFA.js → mobileBackNavigation-BsbWBz8h.js} +1 -1
  62. package/dist/assets/multirun-Ce977k1P.js +3 -0
  63. package/dist/assets/native-CILcYDJz.js +1 -0
  64. package/dist/assets/{native-config-BpsFKLGl.js → native-config-5BNfonUF.js} +1 -1
  65. package/dist/assets/persistence-Dta0OwIa.js +3 -0
  66. package/dist/assets/{pl-DzX0cbiQ.js → pl-ChxP5OZm.js} +3 -3
  67. package/dist/assets/projectMeta-KTYl7ter.js +1 -0
  68. package/dist/assets/pt-BR-9N8nJVqC.js +15 -0
  69. package/dist/assets/{queue-abort-optimistic-DCLBpirg.js → queue-abort-optimistic-CJmevpBJ.js} +1 -1
  70. package/dist/assets/{react-DRe85o5s.js → react-Bwr5-XPi.js} +1 -1
  71. package/dist/assets/readiness-CdCOcZnK.js +1 -0
  72. package/dist/assets/renderElectronMiniChatApp-wFpIvOFT.js +2 -0
  73. package/dist/assets/renderMobileApp-QJ2XwXGj.js +28 -0
  74. package/dist/assets/{runtime-file-download-Cf1WxfeW.js → runtime-file-download-o29morT6.js} +1 -1
  75. package/dist/assets/{runtime-file-resource-UJjHUF2C.js → runtime-file-resource-qB_oVdE6.js} +1 -1
  76. package/dist/assets/{runtimeConfig-BBgkLVr_.js → runtimeConfig-IuT6iZ4x.js} +1 -1
  77. package/dist/assets/runtimeEndpointReset-DEWSVYyD.js +149 -0
  78. package/dist/assets/scheduledTaskNavigation-BqkeRfVc.js +1 -0
  79. package/dist/assets/sessionLookup-mvlGQJTe.js +1 -0
  80. package/dist/assets/sortable-tabs-strip-Dc4Jr4ml.js +1 -0
  81. package/dist/assets/{speechSettingsQueries-CBSEAKyj.js → speechSettingsQueries-DEGyglgn.js} +2 -2
  82. package/dist/assets/src-DME3XM8W.css +2 -0
  83. package/dist/assets/{store-DVfZQktm.js → store-BPYoxYhv.js} +4 -4
  84. package/dist/assets/{terminalApi-rl9mZAlB.js → terminalApi-CPVNQ5DH.js} +1 -1
  85. package/dist/assets/{textarea-C6VQ7dHH.js → textarea-CIhiRPB2.js} +1 -1
  86. package/dist/assets/theme-validation-BGYdrOu7.js +1 -0
  87. package/dist/assets/themes-BgDJcxRc.js +1 -0
  88. package/dist/assets/tooltip-BoAbDVNP.js +1 -0
  89. package/dist/assets/{touch-gestures-K2_ZOkKW.js → touch-gestures-CErgaXZ7.js} +1 -1
  90. package/dist/assets/types-COEinOJU.js +2 -0
  91. package/dist/assets/uk-C-aeGNQI.js +15 -0
  92. package/dist/assets/{useAppFontEffects-CEgDiZHu.js → useAppFontEffects-C__cAJlw.js} +43 -43
  93. package/dist/assets/{useAssistantUIStore-CfaQV3ID.js → useAssistantUIStore-CYyXdd5c.js} +1 -1
  94. package/dist/assets/useDesktopWindowControlsLayout-BYt7I5so.js +1 -0
  95. package/dist/assets/{useEffectiveDirectory-BOYMJ6k7.js → useEffectiveDirectory-CcDsvhjq.js} +1 -1
  96. package/dist/assets/{useFontPreferences-DeqW9nRx.js → useFontPreferences-UzjDmx4b.js} +1 -1
  97. package/dist/assets/useMobileNavigationStore-BgM0EvUr.js +17 -0
  98. package/dist/assets/{useThemeSystem-CGF5jnIh.js → useThemeSystem-CNzUUkFn.js} +1 -1
  99. package/dist/assets/useUIStore-BDZCXouA.js +1 -0
  100. package/dist/assets/{useWorkerHighlightedLines-EcJThS4x.js → useWorkerHighlightedLines-ZOArIAed.js} +1 -1
  101. package/dist/assets/vendor-base-ui-CzHs0bHY.js +1 -0
  102. package/dist/assets/{vendor-cmdk-C3oBVL9X.js → vendor-cmdk-C_tivUtr.js} +1 -1
  103. package/dist/assets/vendor-codemirror-autocomplete-C0FrlFqZ.js +12 -0
  104. package/dist/assets/vendor-codemirror-commands-5saeUOVY.js +1 -0
  105. package/dist/assets/vendor-codemirror-lang-angular-Cm7vBE3E.js +23 -0
  106. package/dist/assets/vendor-codemirror-lang-cpp-BjixvwC2.js +1 -0
  107. package/dist/assets/vendor-codemirror-lang-go-DFb2d_8t.js +11 -0
  108. package/dist/assets/vendor-codemirror-lang-java-CHitPigf.js +1 -0
  109. package/dist/assets/vendor-codemirror-lang-jinja-B8yrwpok.js +1 -0
  110. package/dist/assets/{vendor-codemirror-lang-json-mLulNbwB.js → vendor-codemirror-lang-json-DowyFczU.js} +1 -1
  111. package/dist/assets/{vendor-codemirror-lang-less-CNvptX3P.js → vendor-codemirror-lang-less-B1_0-sTl.js} +1 -1
  112. package/dist/assets/vendor-codemirror-lang-liquid-FIsA7YFN.js +1 -0
  113. package/dist/assets/vendor-codemirror-lang-markdown-npWBZIoE.js +6 -0
  114. package/dist/assets/vendor-codemirror-lang-php-wyEc0fdz.js +1 -0
  115. package/dist/assets/vendor-codemirror-lang-python-OPRdU26g.js +9 -0
  116. package/dist/assets/{vendor-codemirror-lang-rust-CtafR0gt.js → vendor-codemirror-lang-rust-DgovszuH.js} +1 -1
  117. package/dist/assets/vendor-codemirror-lang-sass-BdU-i07o.js +1 -0
  118. package/dist/assets/{vendor-codemirror-lang-sql-C6q09UUZ.js → vendor-codemirror-lang-sql-DUutq98l.js} +2 -2
  119. package/dist/assets/{vendor-codemirror-lang-vue-DIB78UsR.js → vendor-codemirror-lang-vue-CuRNbe8H.js} +1 -1
  120. package/dist/assets/{vendor-codemirror-lang-wast-C_JVdOCF.js → vendor-codemirror-lang-wast-CGFAOCoB.js} +1 -1
  121. package/dist/assets/vendor-codemirror-lang-xml-CMKBqGXF.js +1 -0
  122. package/dist/assets/{vendor-codemirror-lang-yaml-BO0hIfQM.js → vendor-codemirror-lang-yaml-CH9a1QiY.js} +1 -1
  123. package/dist/assets/{vendor-codemirror-language-data-Ctd4WxgW.js → vendor-codemirror-language-data-B3pLWvv-.js} +2 -2
  124. package/dist/assets/vendor-codemirror-search-hZY-L2l8.js +2 -0
  125. package/dist/assets/{vendor-dnd-kit-accessibility-DxpFzZhi.js → vendor-dnd-kit-accessibility-BOtnpZt5.js} +1 -1
  126. package/dist/assets/{vendor-dnd-kit-core-B3g3zWQd.js → vendor-dnd-kit-core-DK4OoOTr.js} +1 -1
  127. package/dist/assets/{vendor-dnd-kit-sortable-BKewx0Py.js → vendor-dnd-kit-sortable-Cv69eQm1.js} +1 -1
  128. package/dist/assets/{vendor-framer-motion-C1twy-GF.js → vendor-framer-motion-DDMKlXiP.js} +1 -1
  129. package/dist/assets/vendor-lodash-es-BS45jPoZ.js +1 -0
  130. package/dist/assets/{vendor-markstream-react-BlbOg72y.js → vendor-markstream-react-DfLaSG3W.js} +3 -3
  131. package/dist/assets/vendor-motion-C9oiAdx-.js +1 -0
  132. package/dist/assets/{vendor-pierre-diffs-Bj9Nqn6w.js → vendor-pierre-diffs-BFiZ3IhI.js} +2 -2
  133. package/dist/assets/{vendor-react-D5d-V1vN.js → vendor-react-DlzBev0S.js} +1 -1
  134. package/dist/assets/{vendor-react-drawio-C-iPmmED.js → vendor-react-drawio-Dyg1-39Q.js} +1 -1
  135. package/dist/assets/vendor-reactuses-core-DWo5Wn6R.js +1 -0
  136. package/dist/assets/{vendor-replit-codemirror-vim-DCdAdxvE.js → vendor-replit-codemirror-vim-BmQmU1lR.js} +6 -6
  137. package/dist/assets/{vendor-sonner-r2EJnfoo.js → vendor-sonner-BEHGipm5.js} +1 -1
  138. package/dist/assets/{vendor-stream-diffs-BnLmeqg2.js → vendor-stream-diffs-wcQxoPZk.js} +2 -2
  139. package/dist/assets/{vendor-tanstack-react-query-C4SG3JZB.js → vendor-tanstack-react-query-B2psfNaU.js} +1 -1
  140. package/dist/assets/{vendor-tanstack-react-virtual-BeZn51tF.js → vendor-tanstack-react-virtual-DSFNK3qc.js} +1 -1
  141. package/dist/assets/{vendor-zustand-B43HCgwC.js → vendor-zustand-vDaAPGfl.js} +1 -1
  142. package/dist/assets/zh-CN-DOchDQti.js +15 -0
  143. package/dist/assets/zh-TW-Dtigv2CE.js +15 -0
  144. package/dist/index.html +18 -18
  145. package/dist/mini-chat.html +18 -18
  146. package/dist/mobile.html +18 -18
  147. package/package.json +2 -1
  148. package/server/lib/config-sync/DOCUMENTATION.md +1 -0
  149. package/server/lib/config-sync/config-sync.test.js +22 -0
  150. package/server/lib/config-sync/constants.js +0 -3
  151. package/server/lib/gui-customization/DOCUMENTATION.md +45 -0
  152. package/server/lib/gui-customization/session-skill.js +58 -0
  153. package/server/lib/gui-customization/session-skill.test.js +53 -0
  154. package/server/lib/gui-customization/skill/SKILL.md +33 -0
  155. package/server/lib/gui-customization/skill/references/appearance.md +79 -0
  156. package/server/lib/gui-customization/skill/references/file-previews.md +113 -0
  157. package/server/lib/gui-customization/skill/references/global-pages.md +81 -0
  158. package/server/lib/gui-customization/skill/references/gui-api.md +37 -0
  159. package/server/lib/gui-customization/skill/references/preview-exports.md +74 -0
  160. package/server/lib/gui-customization/skill/references/workflow.md +81 -0
  161. package/server/lib/opencode/DOCUMENTATION.md +74 -1
  162. package/server/lib/opencode/config-entity-routes.js +2 -4
  163. package/server/lib/opencode/config-entity-routes.test.js +16 -13
  164. package/server/lib/opencode/core-routes.js +2 -0
  165. package/server/lib/opencode/core-routes.test.js +2 -2
  166. package/server/lib/opencode/custom-provider-models.d.ts +2 -0
  167. package/server/lib/opencode/custom-provider-models.js +71 -0
  168. package/server/lib/opencode/custom-provider-models.test.js +90 -0
  169. package/server/lib/opencode/custom-provider.d.ts +2 -0
  170. package/server/lib/opencode/custom-provider.js +107 -0
  171. package/server/lib/opencode/custom-provider.test.js +211 -0
  172. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  173. package/server/lib/opencode/provider-catalog.js +14 -0
  174. package/server/lib/opencode/provider-catalog.test.js +15 -0
  175. package/server/lib/opencode/provider-configuration.test.js +64 -0
  176. package/server/lib/opencode/provider-model-config.d.ts +1 -0
  177. package/server/lib/opencode/provider-model-config.js +39 -0
  178. package/server/lib/opencode/provider-model-config.test.js +69 -0
  179. package/server/lib/opencode/provider-sources.d.ts +10 -0
  180. package/server/lib/opencode/provider-sources.js +52 -0
  181. package/server/lib/opencode/provider-sources.test.js +73 -0
  182. package/server/lib/opencode/providers.d.ts +5 -0
  183. package/server/lib/opencode/providers.js +28 -0
  184. package/server/lib/opencode/routes.js +50 -1
  185. package/server/lib/remote-desktop/DOCUMENTATION.md +6 -2
  186. package/server/lib/remote-desktop/runtime.js +3 -2
  187. package/server/lib/remote-desktop/runtime.test.js +20 -0
  188. package/server/lib/scheduled-tasks/session-skill.js +3 -0
  189. package/server/lib/scheduled-tasks/session-skill.test.js +4 -2
  190. package/shared/custom-provider-protocol.d.ts +4 -0
  191. package/shared/custom-provider-protocol.js +32 -0
  192. package/dist/assets/AgentAvatar-BybF1ayP.js +0 -1
  193. package/dist/assets/AssistantContactStatus-BwpxTn0d.js +0 -3
  194. package/dist/assets/LoadingImage-DG3otL5V.js +0 -1
  195. package/dist/assets/MarkdownRenderer-C8rv6z7p.js +0 -2
  196. package/dist/assets/MarkstreamRendererImpl-bs8HZ4Ra.js +0 -3
  197. package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +0 -2
  198. package/dist/assets/MultiRunWindow-C-Qw_g7N.js +0 -1
  199. package/dist/assets/SettingsView-BLfFnnnX.js +0 -29
  200. package/dist/assets/SettingsView-BRIvklfP.css +0 -1
  201. package/dist/assets/SettingsWindow-lyYO8Byy.js +0 -1
  202. package/dist/assets/ToolOutputDialog-DU4Pb1s0.js +0 -10
  203. package/dist/assets/YuriLogo-Bb6yHagP.js +0 -1
  204. package/dist/assets/collapsible-BEAHoxNi.js +0 -1
  205. package/dist/assets/context-menu-BxLcot-3.js +0 -1
  206. package/dist/assets/desktopRelayRestore-D1UX7HW2.js +0 -1
  207. package/dist/assets/dialog-nshKUSE5.js +0 -1
  208. package/dist/assets/es-N9ZkQwG9.js +0 -15
  209. package/dist/assets/host-CnVx34Dh.js +0 -1
  210. package/dist/assets/image-loading-D6kOgU4w.js +0 -1
  211. package/dist/assets/input-3Re4pmHm.js +0 -1
  212. package/dist/assets/insertionBoundaries-DK7XYF8d.js +0 -1
  213. package/dist/assets/main-B_THXYMs.js +0 -2
  214. package/dist/assets/main-CpcudEZb.js +0 -169
  215. package/dist/assets/miniChat-DxZiTnAZ.js +0 -2
  216. package/dist/assets/mobile-BJuATiaC.js +0 -2
  217. package/dist/assets/multirun-BlaYsQi2.js +0 -3
  218. package/dist/assets/native-BYMhr-xH.js +0 -1
  219. package/dist/assets/persistence-CWuLIq1J.js +0 -3
  220. package/dist/assets/projectMeta-CnXHTolN.js +0 -1
  221. package/dist/assets/pt-BR-C5yvwyDK.js +0 -15
  222. package/dist/assets/readiness-U16Qor79.js +0 -1
  223. package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +0 -2
  224. package/dist/assets/renderMobileApp-DBj_7RlD.js +0 -28
  225. package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +0 -149
  226. package/dist/assets/scheduledTaskNavigation-EomDNVu2.js +0 -1
  227. package/dist/assets/sessionLookup-C_CCp7MJ.js +0 -1
  228. package/dist/assets/sortable-tabs-strip-p16Pn6Zz.js +0 -1
  229. package/dist/assets/src-u-YDfCVw.css +0 -2
  230. package/dist/assets/tooltip-Dnc6GA-X.js +0 -1
  231. package/dist/assets/types-DnZw0gLD.js +0 -2
  232. package/dist/assets/uk-zbDcUpBy.js +0 -15
  233. package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +0 -1
  234. package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +0 -17
  235. package/dist/assets/useUIStore-C6CE42oh.js +0 -1
  236. package/dist/assets/vendor-base-ui-BQjbsJ43.js +0 -1
  237. package/dist/assets/vendor-codemirror-autocomplete-7c2L_4dM.js +0 -12
  238. package/dist/assets/vendor-codemirror-commands-B8KrBQ9B.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-angular-DXOgWEVj.js +0 -23
  240. package/dist/assets/vendor-codemirror-lang-cpp-Dh8C3xqP.js +0 -1
  241. package/dist/assets/vendor-codemirror-lang-go-BXAJ1_dh.js +0 -11
  242. package/dist/assets/vendor-codemirror-lang-java-DAyCHRhk.js +0 -1
  243. package/dist/assets/vendor-codemirror-lang-jinja-0TICrMfO.js +0 -1
  244. package/dist/assets/vendor-codemirror-lang-liquid-8g5seytq.js +0 -1
  245. package/dist/assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js +0 -6
  246. package/dist/assets/vendor-codemirror-lang-php-xP7rf28_.js +0 -1
  247. package/dist/assets/vendor-codemirror-lang-python-YM2WVLHF.js +0 -9
  248. package/dist/assets/vendor-codemirror-lang-sass-B4iav_Ps.js +0 -1
  249. package/dist/assets/vendor-codemirror-lang-xml-DIuzY_d4.js +0 -1
  250. package/dist/assets/vendor-codemirror-search-DiPwvA-6.js +0 -2
  251. package/dist/assets/vendor-lodash-es-DfLbG5Af.js +0 -1
  252. package/dist/assets/vendor-motion-BmLx2V78.js +0 -1
  253. package/dist/assets/vendor-reactuses-core-BcebBLwF.js +0 -1
  254. package/dist/assets/zh-CN-BHRJ7CF3.js +0 -15
  255. package/dist/assets/zh-TW-BFI_YFd-.js +0 -15
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-DBn9yahL.js";import{c as a,i as o}from"./runtime-switch-DEZ1K7qW.js";import{n as s}from"./runtime-fetch-D0YWp3FJ.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-UJjHUF2C.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-DBn9yahL.js";import{c as a,i as o}from"./runtime-switch-DEZ1K7qW.js";import{n as s}from"./runtime-fetch-D0YWp3FJ.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-qB_oVdE6.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,v as n,x as r}from"./desktop-JwYqThiw.js";import{at as i,it as a}from"./vendor-base-ui-BQjbsJ43.js";import{n as o}from"./vendor-react-D5d-V1vN.js";import{a as s,i as c,o as l,t as u}from"./store-DVfZQktm.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(i(),1),h=o(),g=async(e,r)=>{if(!t())throw Error(`Desktop runtime is not available`);return n(e,r)},_=async()=>{if(r())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(r())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(r())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},ee=async e=>{if(r())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},b=async()=>{if(!r())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},x=m.createContext(null),S=a(),C=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(w),i=c(te),a=c(T),o=c(ne),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&ee(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let b;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(b={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=b):b=t[15];let C=b,E;return t[16]!==n||t[17]!==C?(E=(0,S.jsx)(x.Provider,{value:C,children:n}),t[16]=n,t[17]=C,t[18]=E):E=t[18],E};function w(e){return e.locale}function te(e){return e.dictionary}function T(e){return e.loadingLocale}function ne(e){return e.setLocale}var E={startingApi:`Starting OpenCode API…`,initializing:`Initializing…`,connecting:`Connecting…`,connected:`Connected!`,connectionError:`Connection error`,disconnected:`Disconnected`,reconnecting:`Reconnecting…`,initialDataLoadFailed:`OpenCode connected, but initial data load failed.`,cliNotFound:`OpenCode CLI not found. Please install it first.`,providersReady:`✓ Providers`,providersLoading:`… Providers`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Starting webview dev server (${e})...`,waitingDevServer:(e,t)=>`Waiting for webview dev server (${e})... attempt ${t}`,loadingData:(e,t)=>`Loading data (${e}, ${t})…`},re={startingApi:`Démarrage de l’API OpenCode…`,initializing:`Initialisation…`,connecting:`Connexion…`,connected:`Connecté !`,connectionError:`Erreur de connexion`,disconnected:`Déconnecté`,reconnecting:`Reconnexion…`,initialDataLoadFailed:`OpenCode est connecté, mais le chargement initial des données a échoué.`,cliNotFound:`L’interface en ligne de commande OpenCode est introuvable. Veuillez l’installer d’abord.`,providersReady:`✓ Fournisseurs`,providersLoading:`… Fournisseurs`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Démarrage du serveur de développement de la webview (${e})...`,waitingDevServer:(e,t)=>`En attente du serveur de développement de la webview (${e})... tentative ${t}`,loadingData:(e,t)=>`Chargement des données (${e}, ${t})…`},D={startingApi:`正在启动 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在连接…`,connected:`已连接!`,connectionError:`连接错误`,disconnected:`已断开连接`,reconnecting:`正在重新连接…`,initialDataLoadFailed:`OpenCode 已连接,但初始数据加载失败。`,cliNotFound:`未找到 OpenCode CLI。请先安装它。`,providersReady:`✓ 提供商`,providersLoading:`… 提供商`,agentsReady:`✓ Agent`,agentsLoading:`… Agent`,startingDevServer:e=>`正在启动 webview 开发服务器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 开发服务器 (${e})... 第 ${t} 次尝试`,loadingData:(e,t)=>`正在加载数据 (${e}, ${t})…`},O={startingApi:`正在啟動 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在連線…`,connected:`已連線!`,connectionError:`連線錯誤`,disconnected:`已中斷連線`,reconnecting:`正在重新連線…`,initialDataLoadFailed:`OpenCode 已連線,但初始資料載入失敗。`,cliNotFound:`找不到 OpenCode CLI。請先安裝。`,providersReady:`✓ 提供者`,providersLoading:`… 提供者`,agentsReady:`✓ 代理`,agentsLoading:`… 代理`,startingDevServer:e=>`正在啟動 webview 開發伺服器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 開發伺服器 (${e})... 第 ${t} 次嘗試`,loadingData:(e,t)=>`正在載入資料 (${e}, ${t})…`},k={startingApi:`Запуск OpenCode API…`,initializing:`Ініціалізація…`,connecting:`Підключення…`,connected:`Підключено!`,connectionError:`Помилка підключення`,disconnected:`Відключено`,reconnecting:`Повторне підключення…`,initialDataLoadFailed:`OpenCode підключено, але початкове завантаження даних не вдалося.`,cliNotFound:`OpenCode CLI не знайдено. Спершу встановіть його.`,providersReady:`✓ Провайдери`,providersLoading:`… Провайдери`,agentsReady:`✓ Агенти`,agentsLoading:`… Агенти`,startingDevServer:e=>`Запуск dev-сервера webview (${e})...`,waitingDevServer:(e,t)=>`Очікування dev-сервера webview (${e})... спроба ${t}`,loadingData:(e,t)=>`Завантаження даних (${e}, ${t})…`},A={startingApi:`Iniciando la API de OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`¡Conectado!`,connectionError:`Error de conexión`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode se conectó, pero falló la carga inicial de datos.`,cliNotFound:`No se encontró OpenCode CLI. Instálalo primero.`,providersReady:`✓ Proveedores`,providersLoading:`… Proveedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando el servidor de desarrollo de webview (${e})...`,waitingDevServer:(e,t)=>`Esperando el servidor de desarrollo de webview (${e})... intento ${t}`,loadingData:(e,t)=>`Cargando datos (${e}, ${t})…`},j={startingApi:`Iniciando a API do OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`Conectado!`,connectionError:`Erro de conexão`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode conectado, mas o carregamento inicial dos dados falhou.`,cliNotFound:`OpenCode CLI não encontrado. Instale-o primeiro.`,providersReady:`✓ Provedores`,providersLoading:`… Provedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando o servidor de desenvolvimento da webview (${e})...`,waitingDevServer:(e,t)=>`Aguardando o servidor de desenvolvimento da webview (${e})... tentativa ${t}`,loadingData:(e,t)=>`Carregando dados (${e}, ${t})…`},M={startingApi:`OpenCode API 시작 중…`,initializing:`초기화 중…`,connecting:`연결 중…`,connected:`연결됨!`,connectionError:`연결 오류`,disconnected:`연결 끊김`,reconnecting:`다시 연결 중…`,initialDataLoadFailed:`OpenCode에 연결되었지만 초기 데이터 로드에 실패했습니다.`,cliNotFound:`OpenCode CLI를 찾을 수 없습니다. 먼저 설치하세요.`,providersReady:`✓ 공급자`,providersLoading:`… 공급자`,agentsReady:`✓ 에이전트`,agentsLoading:`… 에이전트`,startingDevServer:e=>`webview 개발 서버 시작 중 (${e})...`,waitingDevServer:(e,t)=>`webview 개발 서버 대기 중 (${e})... ${t}번째 시도`,loadingData:(e,t)=>`데이터 로드 중 (${e}, ${t})…`},N={startingApi:`Uruchamianie API OpenCode…`,initializing:`Inicjalizacja…`,connecting:`Łączenie…`,connected:`Połączono!`,connectionError:`Błąd połączenia`,disconnected:`Rozłączono`,reconnecting:`Ponowne łączenie…`,initialDataLoadFailed:`OpenCode połączony, ale początkowe ładowanie danych nie powiodło się.`,cliNotFound:`Nie znaleziono OpenCode CLI. Najpierw go zainstaluj.`,providersReady:`✓ Dostawcy`,providersLoading:`… Dostawcy`,agentsReady:`✓ Agenci`,agentsLoading:`… Agenci`,startingDevServer:e=>`Uruchamianie serwera deweloperskiego webview (${e})...`,waitingDevServer:(e,t)=>`Oczekiwanie na serwer deweloperski webview (${e})... próba ${t}`,loadingData:(e,t)=>`Ładowanie danych (${e}, ${t})…`},P={startingApi:`OpenCode API を起動中…`,initializing:`初期化中…`,connecting:`接続中…`,connected:`接続完了!`,connectionError:`接続エラー`,disconnected:`切断されました`,reconnecting:`再接続中…`,initialDataLoadFailed:`OpenCode に接続しましたが、初期データの読み込みに失敗しました。`,cliNotFound:`OpenCode CLI が見つかりません。先にインストールしてください。`,providersReady:`✓ プロバイダ`,providersLoading:`… プロバイダ`,agentsReady:`✓ エージェント`,agentsLoading:`… エージェント`,startingDevServer:e=>`Webview 開発サーバーを起動中 (${e})...`,waitingDevServer:(e,t)=>`Webview 開発サーバーを待機中 (${e})... 試行 ${t}`,loadingData:(e,t)=>`データを読み込み中 (${e}, ${t})…`},F=e=>I[e],I={en:E,fr:re,"zh-CN":D,"zh-TW":O,uk:k,es:A,"pt-BR":j,ko:M,pl:N,ja:P},L={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},R=e=>L[e]??`en-US`,z=()=>R(c.getState().locale);function B(){let e=m.useContext(x);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function V(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function H(...e){return p(d(e))}var U=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),W=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),G=()=>U()?`common.revealPath.finder`:W()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,K=e=>U()&&r()?e.metaKey:e.ctrlKey,q=()=>U()&&r()?`⌘`:`Ctrl`,J=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},Y=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function X(e,t){if(!e)return``;let n=Y(e);if(n===`/`)return`/`;let r=t?Y(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function ie(e,t){if(!e)return`/`;let n=Y(e);if(!n||n===`/`)return`/`;let r=t?Y(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function ae(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function oe(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var Z=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=ae(t,a?a.ref:void 0);if(!a)return null;let s=oe(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),Q=[`bg-[var(--surface-muted)] text-foreground border-0 shadow-none`,`hover:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`active:bg-[color-mix(in_srgb,var(--foreground)_12%,var(--surface-muted))]`,`focus-visible:border-transparent focus-visible:ring-foreground/20`].join(` `),$=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),se=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:Q,destructive:H($,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:Q,outline:Q,mobileGlass:`yuri-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:H(Q,`aria-pressed:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--surface-muted))]`,`aria-pressed:active:bg-[color-mix(in_srgb,var(--foreground)_10%,var(--surface-muted))]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),ce=new Set([`icon`,`mobileIcon`,`xs`]);function le(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?Z:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&ce.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=H(se({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,S.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{g as _,X as a,_ as b,K as c,V as d,B as f,b as g,C as h,ie as i,U as l,F as m,Z as n,q as o,z as p,H as r,G as s,le as t,J as u,y as v,v as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,v as n,x as r}from"./desktop-JwYqThiw.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{a as s,i as c,o as l,t as u}from"./store-BPYoxYhv.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(a(),1),h=o(),g=async(e,r)=>{if(!t())throw Error(`Desktop runtime is not available`);return n(e,r)},_=async()=>{if(r())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(r())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(r())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},ee=async e=>{if(r())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},b=async()=>{if(!r())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},x=m.createContext(null),S=i(),C=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(w),i=c(te),a=c(T),o=c(ne),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&ee(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let b;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(b={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=b):b=t[15];let C=b,E;return t[16]!==n||t[17]!==C?(E=(0,S.jsx)(x.Provider,{value:C,children:n}),t[16]=n,t[17]=C,t[18]=E):E=t[18],E};function w(e){return e.locale}function te(e){return e.dictionary}function T(e){return e.loadingLocale}function ne(e){return e.setLocale}var E={startingApi:`Starting OpenCode API…`,initializing:`Initializing…`,connecting:`Connecting…`,connected:`Connected!`,connectionError:`Connection error`,disconnected:`Disconnected`,reconnecting:`Reconnecting…`,initialDataLoadFailed:`OpenCode connected, but initial data load failed.`,cliNotFound:`OpenCode CLI not found. Please install it first.`,providersReady:`✓ Providers`,providersLoading:`… Providers`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Starting webview dev server (${e})...`,waitingDevServer:(e,t)=>`Waiting for webview dev server (${e})... attempt ${t}`,loadingData:(e,t)=>`Loading data (${e}, ${t})…`},re={startingApi:`Démarrage de l’API OpenCode…`,initializing:`Initialisation…`,connecting:`Connexion…`,connected:`Connecté !`,connectionError:`Erreur de connexion`,disconnected:`Déconnecté`,reconnecting:`Reconnexion…`,initialDataLoadFailed:`OpenCode est connecté, mais le chargement initial des données a échoué.`,cliNotFound:`L’interface en ligne de commande OpenCode est introuvable. Veuillez l’installer d’abord.`,providersReady:`✓ Fournisseurs`,providersLoading:`… Fournisseurs`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Démarrage du serveur de développement de la webview (${e})...`,waitingDevServer:(e,t)=>`En attente du serveur de développement de la webview (${e})... tentative ${t}`,loadingData:(e,t)=>`Chargement des données (${e}, ${t})…`},D={startingApi:`正在启动 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在连接…`,connected:`已连接!`,connectionError:`连接错误`,disconnected:`已断开连接`,reconnecting:`正在重新连接…`,initialDataLoadFailed:`OpenCode 已连接,但初始数据加载失败。`,cliNotFound:`未找到 OpenCode CLI。请先安装它。`,providersReady:`✓ 提供商`,providersLoading:`… 提供商`,agentsReady:`✓ Agent`,agentsLoading:`… Agent`,startingDevServer:e=>`正在启动 webview 开发服务器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 开发服务器 (${e})... 第 ${t} 次尝试`,loadingData:(e,t)=>`正在加载数据 (${e}, ${t})…`},O={startingApi:`正在啟動 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在連線…`,connected:`已連線!`,connectionError:`連線錯誤`,disconnected:`已中斷連線`,reconnecting:`正在重新連線…`,initialDataLoadFailed:`OpenCode 已連線,但初始資料載入失敗。`,cliNotFound:`找不到 OpenCode CLI。請先安裝。`,providersReady:`✓ 提供者`,providersLoading:`… 提供者`,agentsReady:`✓ 代理`,agentsLoading:`… 代理`,startingDevServer:e=>`正在啟動 webview 開發伺服器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 開發伺服器 (${e})... 第 ${t} 次嘗試`,loadingData:(e,t)=>`正在載入資料 (${e}, ${t})…`},k={startingApi:`Запуск OpenCode API…`,initializing:`Ініціалізація…`,connecting:`Підключення…`,connected:`Підключено!`,connectionError:`Помилка підключення`,disconnected:`Відключено`,reconnecting:`Повторне підключення…`,initialDataLoadFailed:`OpenCode підключено, але початкове завантаження даних не вдалося.`,cliNotFound:`OpenCode CLI не знайдено. Спершу встановіть його.`,providersReady:`✓ Провайдери`,providersLoading:`… Провайдери`,agentsReady:`✓ Агенти`,agentsLoading:`… Агенти`,startingDevServer:e=>`Запуск dev-сервера webview (${e})...`,waitingDevServer:(e,t)=>`Очікування dev-сервера webview (${e})... спроба ${t}`,loadingData:(e,t)=>`Завантаження даних (${e}, ${t})…`},A={startingApi:`Iniciando la API de OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`¡Conectado!`,connectionError:`Error de conexión`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode se conectó, pero falló la carga inicial de datos.`,cliNotFound:`No se encontró OpenCode CLI. Instálalo primero.`,providersReady:`✓ Proveedores`,providersLoading:`… Proveedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando el servidor de desarrollo de webview (${e})...`,waitingDevServer:(e,t)=>`Esperando el servidor de desarrollo de webview (${e})... intento ${t}`,loadingData:(e,t)=>`Cargando datos (${e}, ${t})…`},j={startingApi:`Iniciando a API do OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connected:`Conectado!`,connectionError:`Erro de conexão`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode conectado, mas o carregamento inicial dos dados falhou.`,cliNotFound:`OpenCode CLI não encontrado. Instale-o primeiro.`,providersReady:`✓ Provedores`,providersLoading:`… Provedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando o servidor de desenvolvimento da webview (${e})...`,waitingDevServer:(e,t)=>`Aguardando o servidor de desenvolvimento da webview (${e})... tentativa ${t}`,loadingData:(e,t)=>`Carregando dados (${e}, ${t})…`},M={startingApi:`OpenCode API 시작 중…`,initializing:`초기화 중…`,connecting:`연결 중…`,connected:`연결됨!`,connectionError:`연결 오류`,disconnected:`연결 끊김`,reconnecting:`다시 연결 중…`,initialDataLoadFailed:`OpenCode에 연결되었지만 초기 데이터 로드에 실패했습니다.`,cliNotFound:`OpenCode CLI를 찾을 수 없습니다. 먼저 설치하세요.`,providersReady:`✓ 공급자`,providersLoading:`… 공급자`,agentsReady:`✓ 에이전트`,agentsLoading:`… 에이전트`,startingDevServer:e=>`webview 개발 서버 시작 중 (${e})...`,waitingDevServer:(e,t)=>`webview 개발 서버 대기 중 (${e})... ${t}번째 시도`,loadingData:(e,t)=>`데이터 로드 중 (${e}, ${t})…`},N={startingApi:`Uruchamianie API OpenCode…`,initializing:`Inicjalizacja…`,connecting:`Łączenie…`,connected:`Połączono!`,connectionError:`Błąd połączenia`,disconnected:`Rozłączono`,reconnecting:`Ponowne łączenie…`,initialDataLoadFailed:`OpenCode połączony, ale początkowe ładowanie danych nie powiodło się.`,cliNotFound:`Nie znaleziono OpenCode CLI. Najpierw go zainstaluj.`,providersReady:`✓ Dostawcy`,providersLoading:`… Dostawcy`,agentsReady:`✓ Agenci`,agentsLoading:`… Agenci`,startingDevServer:e=>`Uruchamianie serwera deweloperskiego webview (${e})...`,waitingDevServer:(e,t)=>`Oczekiwanie na serwer deweloperski webview (${e})... próba ${t}`,loadingData:(e,t)=>`Ładowanie danych (${e}, ${t})…`},P={startingApi:`OpenCode API を起動中…`,initializing:`初期化中…`,connecting:`接続中…`,connected:`接続完了!`,connectionError:`接続エラー`,disconnected:`切断されました`,reconnecting:`再接続中…`,initialDataLoadFailed:`OpenCode に接続しましたが、初期データの読み込みに失敗しました。`,cliNotFound:`OpenCode CLI が見つかりません。先にインストールしてください。`,providersReady:`✓ プロバイダ`,providersLoading:`… プロバイダ`,agentsReady:`✓ エージェント`,agentsLoading:`… エージェント`,startingDevServer:e=>`Webview 開発サーバーを起動中 (${e})...`,waitingDevServer:(e,t)=>`Webview 開発サーバーを待機中 (${e})... 試行 ${t}`,loadingData:(e,t)=>`データを読み込み中 (${e}, ${t})…`},F=e=>I[e],I={en:E,fr:re,"zh-CN":D,"zh-TW":O,uk:k,es:A,"pt-BR":j,ko:M,pl:N,ja:P},L={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},R=e=>L[e]??`en-US`,z=()=>R(c.getState().locale);function B(){let e=m.useContext(x);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function V(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function H(...e){return p(d(e))}var U=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),W=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),G=()=>U()?`common.revealPath.finder`:W()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,K=e=>U()&&r()?e.metaKey:e.ctrlKey,q=()=>U()&&r()?`⌘`:`Ctrl`,J=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},Y=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function X(e,t){if(!e)return``;let n=Y(e);if(n===`/`)return`/`;let r=t?Y(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function ie(e,t){if(!e)return`/`;let n=Y(e);if(!n||n===`/`)return`/`;let r=t?Y(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function ae(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function oe(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var Z=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=ae(t,a?a.ref:void 0);if(!a)return null;let s=oe(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),Q=[`bg-[var(--surface-muted)] text-foreground border-0 shadow-none`,`hover:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`active:bg-[color-mix(in_srgb,var(--foreground)_12%,var(--surface-muted))]`,`focus-visible:border-transparent focus-visible:ring-foreground/20`].join(` `),$=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),se=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out outline-none`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:Q,destructive:H($,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:Q,outline:Q,mobileGlass:`yuri-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:H(Q,`aria-pressed:bg-[color-mix(in_srgb,var(--foreground)_6%,var(--surface-muted))]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--foreground)_8%,var(--surface-muted))]`,`aria-pressed:active:bg-[color-mix(in_srgb,var(--foreground)_10%,var(--surface-muted))]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),ce=new Set([`icon`,`mobileIcon`,`xs`]);function le(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?Z:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&ce.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=H(se({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,S.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{g as _,X as a,_ as b,K as c,V as d,B as f,b as g,C as h,ie as i,U as l,F as m,Z as n,q as o,z as p,H as r,G as s,le as t,J as u,y as v,v as y};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-DnZw0gLD.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
1
+ import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-COEinOJU.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,ot as n,r,st as i,t as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{r as s}from"./button-BF2cNEuq.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-hePW80VL.js";import{A as e,B as t,L as n,R as r,a as i,i as a,ot as o,st as s,z as c}from"./vendor-base-ui-CzHs0bHY.js";import{n as l}from"./vendor-react-DlzBev0S.js";import{r as u}from"./button-BF2cNEuq.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-CX8oXdks.js";var m=l();s();var h=o();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(i,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function v(e){let t=(0,m.c)(20),i,a,o,s,l;t[0]===e?(i=t[1],a=t[2],o=t[3],s=t[4],l=t[5]):({className:a,positionerClassName:o,children:i,style:l,...s}=e,t[0]=e,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l);let f;t[6]===o?f=t[7]:(f=u(`app-region-no-drag z-50`,o),t[6]=o,t[7]=f);let p;t[8]===l?p=t[9]:(p={color:`var(--surface-elevated-foreground)`,...l},t[8]=l,t[9]=p);let g;t[10]===a?g=t[11]:(g=u(d,a),t[10]=a,t[11]=g);let _;t[12]!==i||t[13]!==s||t[14]!==p||t[15]!==g?(_=(0,h.jsx)(c,{"data-slot":`dropdown-menu-content`,style:p,className:g,...s,children:i}),t[12]=i,t[13]=s,t[14]=p,t[15]=g,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,h.jsx)(r,{children:(0,h.jsx)(n,{className:f,children:_})}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}function y(e){let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(p,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(t,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
@@ -0,0 +1 @@
1
+ import{b as e}from"./runtime-auth-DBn9yahL.js";import{l as t,n,r,t as i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D0YWp3FJ.js";import{S as o,Y as s}from"./desktop-JwYqThiw.js";import{h as c,i as l,l as u,m as d,n as f,r as p,u as m}from"./desktopHosts-CB0CTcMg.js";var h=e=>e!==`ok`&&e!==`update-recommended`,g=e=>e.id===`local`?`local`:`host:${e.id}`,_=e=>r()===g(e),v=async(n,r)=>{if(!o())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};n=await u(n);let i=d(m(n))||``;if(!i&&!n.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let a=(r,i)=>{i&&e({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),t({apiBaseUrl:T(),clientToken:n.clientToken||null,runtimeKey:g(n),relay:r}),D(n.id)},s=e=>{t({apiBaseUrl:e,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:g(n)})},l={status:`unreachable`,latencyMs:0},p=null,_;if(i){let e=await f(i,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,expectedServerId:n.relay?.serverId||null}).catch(()=>({status:`unreachable`,latencyMs:0}));l={status:e.status,latencyMs:e.latencyMs},h(e.status)||(p=`direct`)}if(!p&&n.relay){let e=await c(n.relay,{keepTunnel:!0,clientToken:n.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));e.status===`ok`?(l={status:e.status,latencyMs:e.latencyMs,via:`relay`},p=`relay`,_=`tunnel`in e?e.tunnel:void 0):(!i||e.status===`auth`)&&(l={status:e.status,latencyMs:e.latencyMs})}return p?p===`relay`&&n.relay?(a(n.relay,_),{ok:!0,via:`relay`,status:l}):(s(i),{ok:!0,via:`direct`,status:l}):{ok:!1,status:l,reason:`unreachable`}},y=5e3,b=1500,x=e=>e===`ok`||e===`update-recommended`,S=!1,C=()=>{if(typeof window>`u`)return``;let e=window.__YURI_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},w=e=>{if(!e||e===`null`)return!1;try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.origin!==`null`}catch{return!1}},T=()=>{if(typeof window>`u`)return``;let e=window.location.origin;if(w(e))return e;let t=C();return w(t)?t:``},E=async e=>{if(!o()||S)return;let i=`host:${e}`;if(r()!==i)return;let s=n(),c=()=>r()===i&&n()===s;S=!0;try{let n=await p().catch(()=>null);if(!c())return;let r=n?.hosts.find(t=>t.id===e);if(!n||!r?.relay)return;let o=r.apiUrl?d(r.apiUrl):null;if(o&&o.startsWith(`https://`))return;let s=await a(`/api/client-auth/connection/candidates`).catch(()=>null);if(!s?.ok)return;let u=await s.json().catch(()=>null);if(!c()||!u||u.serverId!==r.relay.serverId)return;let m=Array.isArray(u.candidates)?u.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=d(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=o&&h.includes(o)?o:h[0];if(g!==o&&await l({hosts:n.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>void 0),!c()||!x((await f(g,{clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,expectedServerId:r.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||!c())return;t({apiBaseUrl:g,clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,runtimeKey:i})}finally{S=!1}},D=e=>{typeof window>`u`||window.setTimeout(()=>{E(e).catch(()=>void 0)},y)},O=async e=>{if(!o())return;let a=r(),c=n(),l=()=>r()===a&&n()===c,u=await p().catch(()=>null);if(!u||!l())return;let h=s(),_=h?.target===`remote`?h.hostId:h?.target===`local`?`local`:null,v=e||_||(u.defaultHostId===`local`?null:u.defaultHostId);if(!v)return;let y=u.hosts.find(e=>e.id===v);if(!y)return;let S=g(y);if(r()===S)return;if(!y.relay){let e=d(m(y));e&&d(i())===e&&(!h||h.status===`ok`)&&t({apiBaseUrl:e,clientToken:y.clientToken||null,requestHeaders:y.requestHeaders||null,runtimeKey:S});return}let C=e=>{t({apiBaseUrl:e,clientToken:y.clientToken||null,requestHeaders:y.requestHeaders||null,runtimeKey:S})},w=()=>{t({apiBaseUrl:T(),clientToken:y.clientToken||null,runtimeKey:S,relay:y.relay??void 0}),D(y.id)},E=y.apiUrl?d(m(y)):null;if(!E){w();return}let O=e=>x(e.status),k=f(E,{clientToken:y.clientToken||null,requestHeaders:y.requestHeaders||null,expectedServerId:y.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),A=await Promise.race([k,new Promise(e=>setTimeout(()=>e(null),b))]);if(l()){if(A){if(O(A)){C(E);return}w();return}w()}};export{v as i,_ as n,g as r,O as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/rolldown-runtime-hePW80VL.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{w as t,x as n}from"./desktop-JwYqThiw.js";import{at as r}from"./vendor-base-ui-BQjbsJ43.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-D5d-V1vN.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as o}from"./platform-DFJEtBlo.js";var s=e(r(),1),c=i(),l=.85,u=1.2,d=10/9*1.05,f=.9,p=1.029,m=p/f,h=`yuri.designPtScale.v9`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(u,Math.max(l,e))}function _(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return p;let r=g(n/t/163);return Math.min(p,r*m)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`yuri.designPtScale.v9`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?!Number.isFinite(e)||e<=0?p:Math.min(p,g(e)):t===`ios`?d:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function x(){if(typeof document>`u`)return 1;b(v());let{Capacitor:e,registerPlugin:t}=await a(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return b(1),1;if(e.getPlatform()===`ios`)return b(d),y(d),d;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`YuriPhysicalScale`))return b(p),y(p),p;try{let e=_(await t(`YuriPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(p),y(p),p}}var S={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},C={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},w=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,T=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},E=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),b(e?1:v(),r)};function D(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,a=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=a?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,u=n()||t()||w(),{isExplicitTablet:d}=T(l),f=s||c||l>0,p=s||c,m=e>S.md&&e<=S.lg,h=e<=S.md,g=f&&h,_=f&&!g&&(m||d),v=!f||!_&&e>S.lg,y=`desktop`;u?(g=!1,_=!1,v=!0,y=`desktop`):o()?(g=!0,_=!1,v=!1,y=`mobile`):g?y=`mobile`:_?y=`tablet`:(v=!0,y=`desktop`),E(u,y,f);let b=`xs`;for(let[t,n]of Object.entries(S))e>=n&&(b=t);return{isMobile:g,isTablet:_,isDesktop:v,deviceType:y,screenWidth:e,breakpoint:b,hasTouchInput:f,hasTouchOnlyPointer:p}}var O=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,k=new Set,A=null,j,M=null,N=()=>typeof window>`u`?C:(A||=D(),A),P=()=>{for(let e of k)e()},F=()=>{j=void 0;let e=D();A&&O(A,e)||(A=e,P())},I=()=>{typeof window>`u`||j!==void 0||(j=window.requestAnimationFrame(F))},L=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},R=()=>{if(typeof window>`u`)return()=>{};A=D(),window.addEventListener(`resize`,I);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=L(e,I),r=L(t,I);return()=>{window.removeEventListener(`resize`,I),n(),r(),j!==void 0&&(window.cancelAnimationFrame(j),j=void 0)}},z=e=>typeof window>`u`?()=>{}:(k.add(e),M||=R(),()=>{k.delete(e),k.size===0&&M&&(M(),M=null,A=null)});function B(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var V=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),H=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return V()&&e>0&&window.innerWidth>S.md};function U(){let e=(0,c.c)(2),[t,n]=s.useState(W),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(H()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function W(){return H()}var G=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function K(){let e=(0,c.c)(2),[t,n]=s.useState(G),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),L(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function q(){return s.useSyncExternalStore(z,N,J)}function J(){return C}export{U as a,K as i,B as n,x as o,q as r,D as t};
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{w as t,x as n}from"./desktop-JwYqThiw.js";import{st as r}from"./vendor-base-ui-CzHs0bHY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as o}from"./platform-DFJEtBlo.js";var s=e(r(),1),c=i(),l=.85,u=1.2,d=10/9*1.05,f=.9,p=1.029,m=p/f,h=`yuri.designPtScale.v9`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(u,Math.max(l,e))}function _(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return p;let r=g(n/t/163);return Math.min(p,r*m)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`yuri.designPtScale.v9`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?!Number.isFinite(e)||e<=0?p:Math.min(p,g(e)):t===`ios`?d:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function x(){if(typeof document>`u`)return 1;b(v());let{Capacitor:e,registerPlugin:t}=await a(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return b(1),1;if(e.getPlatform()===`ios`)return b(d),y(d),d;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`YuriPhysicalScale`))return b(p),y(p),p;try{let e=_(await t(`YuriPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(p),y(p),p}}var S={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},C={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},w=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,T=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},E=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),b(e?1:v(),r)};function D(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,a=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=a?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,u=n()||t()||w(),{isExplicitTablet:d}=T(l),f=s||c||l>0,p=s||c,m=e>S.md&&e<=S.lg,h=e<=S.md,g=f&&h,_=f&&!g&&(m||d),v=!f||!_&&e>S.lg,y=`desktop`;u?(g=!1,_=!1,v=!0,y=`desktop`):o()?(g=!0,_=!1,v=!1,y=`mobile`):g?y=`mobile`:_?y=`tablet`:(v=!0,y=`desktop`),E(u,y,f);let b=`xs`;for(let[t,n]of Object.entries(S))e>=n&&(b=t);return{isMobile:g,isTablet:_,isDesktop:v,deviceType:y,screenWidth:e,breakpoint:b,hasTouchInput:f,hasTouchOnlyPointer:p}}var O=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,k=new Set,A=null,j,M=null,N=()=>typeof window>`u`?C:(A||=D(),A),P=()=>{for(let e of k)e()},F=()=>{j=void 0;let e=D();A&&O(A,e)||(A=e,P())},I=()=>{typeof window>`u`||j!==void 0||(j=window.requestAnimationFrame(F))},L=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},R=()=>{if(typeof window>`u`)return()=>{};A=D(),window.addEventListener(`resize`,I);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=L(e,I),r=L(t,I);return()=>{window.removeEventListener(`resize`,I),n(),r(),j!==void 0&&(window.cancelAnimationFrame(j),j=void 0)}},z=e=>typeof window>`u`?()=>{}:(k.add(e),M||=R(),()=>{k.delete(e),k.size===0&&M&&(M(),M=null,A=null)});function B(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var V=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),H=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return V()&&e>0&&window.innerWidth>S.md};function U(){let e=(0,c.c)(2),[t,n]=s.useState(W),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(H()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function W(){return H()}var G=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function K(){let e=(0,c.c)(2),[t,n]=s.useState(G),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),L(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),s.useEffect(r,i),t}function q(){return s.useSyncExternalStore(z,N,J)}function J(){return C}export{U as a,K as i,B as n,x as o,q as r,D as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{at as t,it as n}from"./vendor-base-ui-BQjbsJ43.js";import{r}from"./button-Bjh2BSXh.js";import{t as i}from"./vendor-react-drawio-C-iPmmED.js";var a=e(t(),1),o=n(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./button-BF2cNEuq.js";import{t as i}from"./vendor-react-drawio-Dyg1-39Q.js";var a=e(n(),1),o=t(),s=`<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>`;function c(){if(typeof document>`u`)return!1;let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||!e&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}var l=a.forwardRef(function({xml:e,readOnly:t,className:n,onChange:l},u){let d=a.useRef(e),f=a.useRef(null),p=a.useRef(!1),[m,h]=a.useState(c),g=a.useRef(e),_=a.useRef(e);_.current!==e&&(_.current=e,g.current=e,d.current=e);let v=a.useRef(m);v.current!==m&&(v.current=m,g.current=d.current);let y=a.useRef(null);a.useEffect(()=>{let e=()=>h(c());e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},[]),a.useEffect(()=>{let e=setTimeout(()=>{y.current?.querySelector(`.diagrams-iframe`)?.focus()},600);return()=>clearTimeout(e)},[]),a.useImperativeHandle(u,()=>({getXml:()=>d.current}));let b=a.useCallback(()=>{!e&&!p.current&&(p.current=!0,setTimeout(()=>{f.current?.template({})},500))},[e]),x=a.useCallback(e=>{d.current=e.xml,l?.(e.xml)},[l]);return(0,o.jsx)(`div`,{ref:y,className:r(`h-full w-full`,n),children:(0,o.jsx)(i,{ref:f,xml:g.current||s,autosave:!0,urlParameters:{ui:t?`simple`:m?`dark`:`kennedy`,spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:x},m?`dark`:`light`)})});export{l as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Q as n,X as r,Z as i,et as a,nt as o,ot as s,rt as c,st as l,tt as u}from"./vendor-base-ui-CzHs0bHY.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{f,r as p}from"./button-BF2cNEuq.js";import{n as m}from"./Icon-CLLDJn-P.js";var h=e(l(),1),g=d(),_=s(),v=0;function y(e,t){return e&&h.isValidElement(t)?{render:t}:{children:t}}function b(e){let t=(0,g.c)(4),r;t[0]===e?r=t[1]:({...r}=e,t[0]=e,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,_.jsx)(n,{...r}),t[2]=r,t[3]=i),i}function x(e){let t=(0,g.c)(10),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({asChild:n,children:i,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o;t[4]!==n||t[5]!==i?(o=y(n,i),t[4]=n,t[5]=i,t[6]=o):o=t[6];let s=o,c;return t[7]!==a||t[8]!==s?(c=(0,_.jsx)(r,{"data-slot":`dialog-trigger`,...a,...s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function S(e){let n=(0,g.c)(4),r;n[0]===e?r=n[1]:({...r}=e,n[0]=e,n[1]=r);let i;return n[2]===r?i=n[3]:(i=(0,_.jsx)(t,{...r}),n[2]=r,n[3]=i),i}var C=h.forwardRef((e,t)=>{let n=(0,g.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],n[3]=a):a=n[3],h.useEffect(A,a);let o=t,s;n[4]===r?s=n[5]:(s=p(`app-region-no-drag fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,r),n[4]=r,n[5]=s);let l;return n[6]!==i||n[7]!==o||n[8]!==s?(l=(0,_.jsx)(c,{ref:o,"data-slot":`dialog-overlay`,className:s,...i}),n[6]=i,n[7]=o,n[8]=s,n[9]=l):l=n[9],l});C.displayName=`DialogOverlay`;function w(e){let t=(0,g.c)(33),n,r,i,s,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],s=t[4],c=t[5],l=t[6],u=t[7]):({className:r,overlayClassName:s,containerClassName:i,children:n,showCloseButton:l,presentation:u,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l,t[7]=u);let d=u===void 0?`default`:u,{t:h}=f(),v=l??d!==`picker`,y=d===`picker`&&`bg-transparent dark:bg-transparent`,b;t[8]!==s||t[9]!==y?(b=p(`rounded-none`,y,s),t[8]=s,t[9]=y,t[10]=b):b=t[10];let x;t[11]===b?x=t[12]:(x=(0,_.jsx)(C,{className:b}),t[11]=b,t[12]=x);let w=i??(d===`picker`?`block p-0`:`items-center p-4`),T;t[13]===w?T=t[14]:(T=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,w),t[13]=w,t[14]=T);let E=d===`picker`&&`yuri-picker-dialog yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent yuri-composer-autocomplete-surface fixed left-1/2 top-[10vh] w-[min(42rem,calc(100vw-3rem))] max-w-none -translate-x-1/2 translate-y-0 gap-0 overflow-hidden rounded-3xl border-0 p-0`,D;t[15]!==r||t[16]!==E?(D=p(`app-region-no-drag relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`,E,r),t[15]=r,t[16]=E,t[17]=D):D=t[17];let O;t[18]!==v||t[19]!==h?(O=v&&(0,_.jsxs)(o,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,_.jsx)(m,{name:`close`}),(0,_.jsx)(`span`,{className:`sr-only`,children:h(`dialog.common.actions.close`)})]}),t[18]=v,t[19]=h,t[20]=O):O=t[20];let k;t[21]!==n||t[22]!==d||t[23]!==c||t[24]!==D||t[25]!==O?(k=(0,_.jsxs)(a,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,"data-presentation":d,className:D,...c,children:[n,O]}),t[21]=n,t[22]=d,t[23]=c,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==k||t[28]!==T?(A=(0,_.jsx)(`div`,{className:T,children:k}),t[27]=k,t[28]=T,t[29]=A):A=t[29];let j;return t[30]!==A||t[31]!==x?(j=(0,_.jsxs)(S,{children:[x,A]}),t[30]=A,t[31]=x,t[32]=j):j=t[32],j}function T(e){let t=(0,g.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E(e){let t=(0,g.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D(e){let t=(0,g.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let a;t[3]===n?a=t[4]:(a=p(`typography-markdown leading-none font-semibold text-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==a?(o=(0,_.jsx)(i,{"data-slot":`dialog-title`,className:a,...r}),t[5]=r,t[6]=a,t[7]=o):o=t[7],o}function O(e){let t=(0,g.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`text-muted-foreground typography-ui-label`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(u,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function k(){v=Math.max(0,v-1),v===0&&document.documentElement.classList.remove(`yuri-dialog-open`)}function A(){return v+=1,document.documentElement.classList.add(`yuri-dialog-open`),k}export{T as a,E as i,w as n,D as o,O as r,x as s,b as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DBn9yahL.js";import{c as n,f as r,i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D0YWp3FJ.js";import{at as o}from"./vendor-base-ui-BQjbsJ43.js";import{yt as s}from"./gitApiHttp-B7vYwgBh.js";import{n as c}from"./vendor-react-D5d-V1vN.js";import{r as l}from"./vendor-reactuses-core-BcebBLwF.js";import{f as u}from"./button-Bjh2BSXh.js";var d=e(o(),1);async function f(e,t){let n=i(),r=await a(`/api/voice/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e}),signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])});if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return await r.body?.cancel(),null;if(!r.ok)throw await r.body?.cancel(),Error(`Unable to create speech session`);let o=await r.json();if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(o?.transport===`host`)return null;if(o?.transport!==`volcengine-direct`||typeof o.token!=`string`||o.token.length>16384||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(o.token)||typeof o.appId!=`string`||!/^[A-Za-z0-9_-]{1,128}$/.test(o.appId)||typeof o.resourceId!=`string`||!/^[A-Za-z0-9._-]{1,128}$/.test(o.resourceId)||!Number.isFinite(o.expiresAt)||o.expiresAt<=Date.now()+5e3||o.expiresAt>Date.now()+36e4||e===`tts`&&(typeof o.voice!=`string`||!/^[A-Za-z0-9_-]{1,200}$/.test(o.voice)||!Number.isFinite(o.speed)||o.speed<.5||o.speed>2||!Number.isFinite(o.pitch)||o.pitch<.5||o.pitch>2||!Number.isFinite(o.volume)||o.volume<0||o.volume>1)||e===`asr`&&o.asrContext!==void 0&&(typeof o.asrContext!=`string`||o.asrContext.length>2e3||/\0/.test(o.asrContext)))throw Error(`Invalid speech session`);return o}function p(e,t){let n=new URL(t===`asr`?`wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`:`wss://openspeech.bytedance.com/api/v3/tts/bidirection`);return n.search=new URLSearchParams({api_app_key:e.appId,api_access_key:`Jwt; ${e.token}`,api_resource_id:e.resourceId}).toString(),n.toString()}var m=new TextEncoder,h=new TextDecoder,g=1048576;function _(e,t=!1,n=!1){let r=new Uint8Array(8+e.length);return r.set([17,(t?2:1)<<4|(n?2:0),t?0:16,0]),new DataView(r.buffer).setUint32(4,e.length),r.set(e,8),r}function v(e,t=``,n={}){let r=m.encode(t),i=m.encode(JSON.stringify(n)),a=new Uint8Array(12+i.length+(t?4+r.length:0));a.set([17,20,16,0]);let o=new DataView(a.buffer);o.setInt32(4,e);let s=8;return t&&(o.setUint32(s,r.length),a.set(r,s+4),s+=4+r.length),o.setUint32(s,i.length),a.set(i,s+4),a}async function y(e,t){if(e.byteLength<8||e.byteLength>g)throw Error(`Invalid speech frame size`);let n=new Uint8Array(e),r=new DataView(e),i=n[1]>>4,a=n[1]&15,o=n[2]&15,s=(n[0]&15)*4;if(n[0]>>4!=1||s<4||s>n.length-4)throw Error(`Invalid speech frame`);let c=()=>{if(s+4>n.length)throw Error(`Truncated speech frame`);let e=r.getUint32(s);return s+=4,e};if(i===15)throw Error(`Speech provider failed (code ${c()})`);if(i!==9&&(t!==`tts`||i!==11))throw Error(`Unexpected speech frame`);a&1&&c();let l=0,u=``;if(a&4&&(l=c(),t===`tts`)){let e=c();if(e>256||s+e>n.length)throw Error(`Invalid speech session ID`);u=h.decode(n.subarray(s,s+e)),s+=e}let d=c();if(s+d!==n.length)throw Error(`Truncated speech payload`);let f=n.slice(s);if(o===1){let e=new Blob([f]).stream().pipeThrough(new DecompressionStream(`gzip`)).getReader(),t=[],n=0;try{for(;;){let r=await e.read();if(r.done)break;if(n+=r.value.length,n>g)throw Error(`Speech payload exceeds size limit`);t.push(r.value)}}finally{await e.cancel().catch(()=>void 0),e.releaseLock()}f=new Uint8Array(n);let r=0;for(let e of t)f.set(e,r),r+=e.length}else if(o!==0)throw Error(`Unsupported speech compression`);return{type:i,event:l,sessionId:u,final:!!(a&2),payload:f}}function b(e){let t=JSON.parse(h.decode(e));if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid speech response`);return t}async function x(e,t){t.throwIfAborted();let n=new WebSocket(e);n.binaryType=`arraybuffer`;let r=[],i=0,a=null,o=null,s=null,c=(e=!0)=>{t.removeEventListener(`abort`,u),n.onmessage=null,n.onclose=null,n.onerror=null,n.onopen=null,e&&(r.length=0,i=0),n.close(),o?.()},l=(e,t=!0)=>{a??=e,s?.(a),c(t)},u=()=>l(new DOMException(`Speech cancelled`,`AbortError`));t.addEventListener(`abort`,u,{once:!0}),n.onmessage=e=>{if(!(e.data instanceof ArrayBuffer)||e.data.byteLength>g){l(Error(`Invalid speech message`));return}if(i+=e.data.byteLength,i>33554432||r.length>=4096){l(Error(`Speech receive buffer exceeded`));return}r.push(e.data),o?.()},n.onerror=()=>l(Error(`Speech connection failed`)),n.onclose=()=>l(Error(`Speech connection ended before completion`),!1);let d=setTimeout(()=>l(Error(`Speech connection timed out`)),1e4);try{await new Promise((e,t)=>{s=t,n.onopen=()=>e()})}finally{clearTimeout(d),s=null}return{send(e){if(t.throwIfAborted(),a)throw a;if(n.readyState!==WebSocket.OPEN||n.bufferedAmount+e.length>g)throw Error(`Speech send buffer exceeded`);n.send(e)},async read(){let e=setTimeout(()=>l(Error(`Speech response timed out`)),6e4);try{for(;!r.length&&!a;)await new Promise(e=>{o=e});if(t.throwIfAborted(),!r.length&&a)throw a;let e=r.shift();return i-=e.byteLength,e}finally{clearTimeout(e),o=null}},close(){a??=new DOMException(`Speech closed`,`AbortError`),c()}}}var S=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await x(p(e,`asr`),this.abort.signal);this.socket=n;try{n.send(_(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(_(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(_(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await y(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=b(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},C=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},w=1e4,T=15e3,E=3e4,D=3e4,O=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=s(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let a=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},w);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(a),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(a),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(a),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await f(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new S(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},T);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},D),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=C(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},E))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{O.cancelAllForRuntimeSwitch()});var k=128,A=`audio/pcm;rate=16000;bits=16`,j=()=>new Promise(e=>setTimeout(e,0)),M=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},N=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??A,this.createDictationId=e.createDictationId??M}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<k;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await j()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},P=c(),F=new Set;function I(e){return F.add(e),()=>{F.delete(e)}}function L(){for(let e of F)e();if(typeof window<`u`&&window.speechSynthesis?.cancel(),typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type=`play-and-record`}catch{}}function R(){if(typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type!==`playback`&&(e.type=`playback`)}catch{}}var z=16e3,B=z/5,V=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},H=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},U=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=H(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=H(e[i]*(1-s)+e[o]*s)}return a},W=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},G=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},K=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),q=e=>{if(e)try{e.disconnect()}catch{}},J=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:V()!==null;function Y(e){let t=(0,P.c)(16),[n,r]=(0,d.useState)(0),i=(0,d.useRef)(e.onPcmSegment),a=(0,d.useRef)(e.onError),o,s;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},s=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,d.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=K(),t[4]=c):c=t[4];let u=(0,d.useRef)(c),f=(0,d.useRef)(0),p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=V();if(!e)throw Error(`AudioContext unavailable`);let t=f.current+=1;L();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==f.current){n.getTracks().forEach(ee);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch($),t!==f.current){n.getTracks().forEach(Q),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=U(n,a.sampleRate,z);for(t.pending=W(t.pending,c);t.pending.length>=B;){let e=t.pending.slice(0,B);t.pending=t.pending.slice(B),i.current(G(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(Z);try{await a.close()}catch{}throw u.current=K(),t instanceof Error?t:Error(String(t))}},t[5]=p):p=t[5];let m=l(p),h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=async()=>{f.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}q(e.processor),q(e.source),q(e.gain),e.stream&&e.stream.getTracks().forEach(X);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(G(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=K())},t[6]=h):h=t[6];let g=l(h),_,v;t[7]===g?(_=t[8],v=t[9]):(_=()=>()=>{g().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},v=[g],t[7]=g,t[8]=_,t[9]=v),(0,d.useEffect)(_,v);let y;t[10]===m?y=t[11]:(y=async()=>{try{await m()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=m,t[11]=y);let b;return t[12]!==g||t[13]!==y||t[14]!==n?(b={start:y,stop:g,volume:n},t[12]=g,t[13]=y,t[14]=n,t[15]=b):b=t[15],b}function X(e){try{e.stop()}catch{}}function Z(e){try{e.stop()}catch{}}function Q(e){return e.stop()}function $(){}function ee(e){return e.stop()}var te=1e3,ne=e=>e instanceof Error?e:Error(String(e));function re(e={}){let{t}=u(),{onTranscript:r,onError:i,canStart:a}=e,[o,s]=(0,d.useState)(`idle`),[c,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(0),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),x=(0,d.useRef)(o);(0,d.useEffect)(()=>{x.current=o},[o]);let S=(0,d.useRef)(``),C=(0,d.useRef)(null),w=(0,d.useRef)({starting:!1,confirming:!1,cancelling:!1}),T=(0,d.useRef)(0),E=(0,d.useRef)(r),D=(0,d.useRef)(i);(0,d.useEffect)(()=>{E.current=r,D.current=i},[r,i]);let k=(0,d.useRef)(null);k.current||=new N({client:O});let A=l(()=>{C.current&&=(clearInterval(C.current),null)}),j=l(()=>{C.current||=setInterval(()=>{g(e=>e+1)},te)}),M=l(e=>{let n=ne(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;v(r.message);let i=n.reasonCode;b(typeof i==`string`?i:null),D.current?.(r)}),P=l(()=>{v(null),b(null)}),F=l(()=>{k.current?.clearAll(),S.current=``,m(``)}),I=l(t=>e.onPartialTranscript?.(t));(0,d.useEffect)(()=>O.onPartial((e,t)=>{let n=k.current?.getDictationId();!n||e!==n||(S.current=t,m(t),I(t))}),[I]),(0,d.useEffect)(()=>O.subscribeConnectionStatus(e=>{if(!e){x.current===`recording`&&k.current?.resetStreamForReplay();return}if(x.current!==`recording`||k.current?.getDictationId())return;let t=T.current;k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}),[M]);let L=Y({onPcmSegment:e=>{x.current===`recording`&&k.current?.enqueueSegment(e)},onError:e=>{D.current?.(e)}}),R=(0,d.useRef)(L.stop);(0,d.useEffect)(()=>{R.current=L.stop},[L.stop]);let z=l(e=>{g(0),s(`idle`),x.current=`idle`;let t=e.trim();return F(),t?(E.current?.(t),t):null}),B=l(e=>{k.current?.hasSegments()?(s(`failed`),x.current=`failed`):(s(`idle`),x.current=`idle`),M(e)}),V=l(async()=>{let e=w.current;if(e.starting||e.confirming||e.cancelling||x.current!==`idle`||a&&!a())return;e.starting=!0,f(!0);let t=++T.current;P(),m(``),g(0),s(`recording`),x.current=`recording`,F();try{if(await L.start(),T.current!==t||x.current!==`recording`)return;f(!1),j(),await k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}catch(e){if(T.current!==t)return;await L.stop().catch(()=>void 0),A(),s(`idle`),x.current=`idle`,M(e)}finally{T.current===t&&f(!1),e.starting=!1}}),H=l(async()=>{let e=w.current;if(!e.cancelling&&(x.current===`recording`||x.current===`uploading`)){e.cancelling=!0,f(!1),T.current+=1,A(),g(0),P(),s(`idle`),x.current=`idle`;try{k.current?.cancel()}catch{}F();try{await L.stop()}catch{}finally{e.cancelling=!1}}}),U=l(async()=>{let e=w.current;if(e.confirming||x.current!==`recording`)return null;e.confirming=!0,f(!1);let t=++T.current;P(),A();try{if(await L.stop(),T.current!==t)return null;s(`uploading`),x.current=`uploading`;let e=k.current?.getFinalSeq()??-1;if(e<0)return k.current?.cancel(),z(``);let n=await k.current.finish(e);return T.current===t?z(n.text):null}catch(e){return T.current===t&&B(e),null}finally{e.confirming=!1}}),W=l(async()=>{if(x.current!==`failed`||!k.current?.hasSegments())return null;P();let e=++T.current;s(`uploading`),x.current=`uploading`;try{k.current.resetStreamForReplay();let t=k.current.getFinalSeq(),n=await k.current.finish(t);return T.current===e?z(n.text):null}catch(t){return T.current===e&&B(t),null}}),G=l(()=>{if(x.current!==`failed`)return null;let e=S.current.trim();g(0),s(`idle`),x.current=`idle`,P();try{k.current?.cancel()}catch{}return F(),e?(E.current?.(e),e):null}),K=l(()=>{g(0),s(`idle`),x.current=`idle`,P(),F()});return(0,d.useEffect)(()=>n(()=>{x.current===`failed`?(T.current+=1,K()):H()}),[H,K]),(0,d.useEffect)(()=>{if(o!==`recording`||y!==`model_download_in_progress`)return;let e=setInterval(()=>{x.current!==`recording`||k.current?.getDictationId()||k.current?.restartStream().then(()=>{P()}).catch(e=>{M(e)})},3e3);return()=>clearInterval(e)},[o,y,P,M]),(0,d.useEffect)(()=>()=>{T.current+=1,A(),R.current().catch(()=>void 0),k.current?.cancel()},[A]),{status:o,isRecording:o===`recording`,isStarting:c,isProcessing:o===`uploading`,partialTranscript:p,volume:L.volume,duration:h,error:_,errorReason:y,startDictation:V,confirmDictation:U,cancelDictation:H,retryFailedDictation:W,acceptPartialTranscript:G,discardFailedDictation:K}}var ie=`yuri-mobile-overlay-surface yuri-popup-surface app-region-no-drag transition-[opacity,transform] duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1`,ae=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,oe=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,se=`yuri-popup-separator -mx-1 my-0.5`;export{re as a,R as c,x as d,b as f,p as h,oe as i,I as l,f as m,ie as n,J as o,v as p,se as r,L as s,ae as t,y as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DBn9yahL.js";import{c as n,f as r,i}from"./runtime-switch-DEZ1K7qW.js";import{n as a}from"./runtime-fetch-D0YWp3FJ.js";import{st as o}from"./vendor-base-ui-CzHs0bHY.js";import{yt as s}from"./gitApiHttp-DGAlAuET.js";import{n as c}from"./vendor-react-DlzBev0S.js";import{i as l}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as u}from"./button-BF2cNEuq.js";var d=e(o(),1);async function f(e,t){let n=i(),r=await a(`/api/voice/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e}),signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])});if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return await r.body?.cancel(),null;if(!r.ok)throw await r.body?.cancel(),Error(`Unable to create speech session`);let o=await r.json();if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(o?.transport===`host`)return null;if(o?.transport!==`volcengine-direct`||typeof o.token!=`string`||o.token.length>16384||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(o.token)||typeof o.appId!=`string`||!/^[A-Za-z0-9_-]{1,128}$/.test(o.appId)||typeof o.resourceId!=`string`||!/^[A-Za-z0-9._-]{1,128}$/.test(o.resourceId)||!Number.isFinite(o.expiresAt)||o.expiresAt<=Date.now()+5e3||o.expiresAt>Date.now()+36e4||e===`tts`&&(typeof o.voice!=`string`||!/^[A-Za-z0-9_-]{1,200}$/.test(o.voice)||!Number.isFinite(o.speed)||o.speed<.5||o.speed>2||!Number.isFinite(o.pitch)||o.pitch<.5||o.pitch>2||!Number.isFinite(o.volume)||o.volume<0||o.volume>1)||e===`asr`&&o.asrContext!==void 0&&(typeof o.asrContext!=`string`||o.asrContext.length>2e3||/\0/.test(o.asrContext)))throw Error(`Invalid speech session`);return o}function p(e,t){let n=new URL(t===`asr`?`wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`:`wss://openspeech.bytedance.com/api/v3/tts/bidirection`);return n.search=new URLSearchParams({api_app_key:e.appId,api_access_key:`Jwt; ${e.token}`,api_resource_id:e.resourceId}).toString(),n.toString()}var m=new TextEncoder,h=new TextDecoder,g=1048576;function _(e,t=!1,n=!1){let r=new Uint8Array(8+e.length);return r.set([17,(t?2:1)<<4|(n?2:0),t?0:16,0]),new DataView(r.buffer).setUint32(4,e.length),r.set(e,8),r}function v(e,t=``,n={}){let r=m.encode(t),i=m.encode(JSON.stringify(n)),a=new Uint8Array(12+i.length+(t?4+r.length:0));a.set([17,20,16,0]);let o=new DataView(a.buffer);o.setInt32(4,e);let s=8;return t&&(o.setUint32(s,r.length),a.set(r,s+4),s+=4+r.length),o.setUint32(s,i.length),a.set(i,s+4),a}async function y(e,t){if(e.byteLength<8||e.byteLength>g)throw Error(`Invalid speech frame size`);let n=new Uint8Array(e),r=new DataView(e),i=n[1]>>4,a=n[1]&15,o=n[2]&15,s=(n[0]&15)*4;if(n[0]>>4!=1||s<4||s>n.length-4)throw Error(`Invalid speech frame`);let c=()=>{if(s+4>n.length)throw Error(`Truncated speech frame`);let e=r.getUint32(s);return s+=4,e};if(i===15)throw Error(`Speech provider failed (code ${c()})`);if(i!==9&&(t!==`tts`||i!==11))throw Error(`Unexpected speech frame`);a&1&&c();let l=0,u=``;if(a&4&&(l=c(),t===`tts`)){let e=c();if(e>256||s+e>n.length)throw Error(`Invalid speech session ID`);u=h.decode(n.subarray(s,s+e)),s+=e}let d=c();if(s+d!==n.length)throw Error(`Truncated speech payload`);let f=n.slice(s);if(o===1){let e=new Blob([f]).stream().pipeThrough(new DecompressionStream(`gzip`)).getReader(),t=[],n=0;try{for(;;){let r=await e.read();if(r.done)break;if(n+=r.value.length,n>g)throw Error(`Speech payload exceeds size limit`);t.push(r.value)}}finally{await e.cancel().catch(()=>void 0),e.releaseLock()}f=new Uint8Array(n);let r=0;for(let e of t)f.set(e,r),r+=e.length}else if(o!==0)throw Error(`Unsupported speech compression`);return{type:i,event:l,sessionId:u,final:!!(a&2),payload:f}}function b(e){let t=JSON.parse(h.decode(e));if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid speech response`);return t}async function x(e,t){t.throwIfAborted();let n=new WebSocket(e);n.binaryType=`arraybuffer`;let r=[],i=0,a=null,o=null,s=null,c=(e=!0)=>{t.removeEventListener(`abort`,u),n.onmessage=null,n.onclose=null,n.onerror=null,n.onopen=null,e&&(r.length=0,i=0),n.close(),o?.()},l=(e,t=!0)=>{a??=e,s?.(a),c(t)},u=()=>l(new DOMException(`Speech cancelled`,`AbortError`));t.addEventListener(`abort`,u,{once:!0}),n.onmessage=e=>{if(!(e.data instanceof ArrayBuffer)||e.data.byteLength>g){l(Error(`Invalid speech message`));return}if(i+=e.data.byteLength,i>33554432||r.length>=4096){l(Error(`Speech receive buffer exceeded`));return}r.push(e.data),o?.()},n.onerror=()=>l(Error(`Speech connection failed`)),n.onclose=()=>l(Error(`Speech connection ended before completion`),!1);let d=setTimeout(()=>l(Error(`Speech connection timed out`)),1e4);try{await new Promise((e,t)=>{s=t,n.onopen=()=>e()})}finally{clearTimeout(d),s=null}return{send(e){if(t.throwIfAborted(),a)throw a;if(n.readyState!==WebSocket.OPEN||n.bufferedAmount+e.length>g)throw Error(`Speech send buffer exceeded`);n.send(e)},async read(){let e=setTimeout(()=>l(Error(`Speech response timed out`)),6e4);try{for(;!r.length&&!a;)await new Promise(e=>{o=e});if(t.throwIfAborted(),!r.length&&a)throw a;let e=r.shift();return i-=e.byteLength,e}finally{clearTimeout(e),o=null}},close(){a??=new DOMException(`Speech closed`,`AbortError`),c()}}}var S=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await x(p(e,`asr`),this.abort.signal);this.socket=n;try{n.send(_(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(_(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(_(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await y(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=b(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},C=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},w=1e4,T=15e3,E=3e4,D=3e4,O=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=s(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let a=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},w);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(a),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(a),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(a),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await f(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new S(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},T);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},D),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=C(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},E))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{O.cancelAllForRuntimeSwitch()});var k=128,A=`audio/pcm;rate=16000;bits=16`,j=()=>new Promise(e=>setTimeout(e,0)),M=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},N=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??A,this.createDictationId=e.createDictationId??M}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<k;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await j()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},P=c(),F=new Set;function I(e){return F.add(e),()=>{F.delete(e)}}function L(){for(let e of F)e();if(typeof window<`u`&&window.speechSynthesis?.cancel(),typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type=`play-and-record`}catch{}}function R(){if(typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type!==`playback`&&(e.type=`playback`)}catch{}}var z=16e3,B=z/5,V=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},H=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},U=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=H(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=H(e[i]*(1-s)+e[o]*s)}return a},W=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},G=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},K=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),q=e=>{if(e)try{e.disconnect()}catch{}},J=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:V()!==null;function Y(e){let t=(0,P.c)(16),[n,r]=(0,d.useState)(0),i=(0,d.useRef)(e.onPcmSegment),a=(0,d.useRef)(e.onError),o,s;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},s=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,d.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=K(),t[4]=c):c=t[4];let u=(0,d.useRef)(c),f=(0,d.useRef)(0),p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=V();if(!e)throw Error(`AudioContext unavailable`);let t=f.current+=1;L();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==f.current){n.getTracks().forEach(ee);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch($),t!==f.current){n.getTracks().forEach(Q),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=U(n,a.sampleRate,z);for(t.pending=W(t.pending,c);t.pending.length>=B;){let e=t.pending.slice(0,B);t.pending=t.pending.slice(B),i.current(G(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(Z);try{await a.close()}catch{}throw u.current=K(),t instanceof Error?t:Error(String(t))}},t[5]=p):p=t[5];let m=l(p),h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=async()=>{f.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}q(e.processor),q(e.source),q(e.gain),e.stream&&e.stream.getTracks().forEach(X);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(G(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=K())},t[6]=h):h=t[6];let g=l(h),_,v;t[7]===g?(_=t[8],v=t[9]):(_=()=>()=>{g().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},v=[g],t[7]=g,t[8]=_,t[9]=v),(0,d.useEffect)(_,v);let y;t[10]===m?y=t[11]:(y=async()=>{try{await m()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=m,t[11]=y);let b;return t[12]!==g||t[13]!==y||t[14]!==n?(b={start:y,stop:g,volume:n},t[12]=g,t[13]=y,t[14]=n,t[15]=b):b=t[15],b}function X(e){try{e.stop()}catch{}}function Z(e){try{e.stop()}catch{}}function Q(e){return e.stop()}function $(){}function ee(e){return e.stop()}var te=1e3,ne=e=>e instanceof Error?e:Error(String(e));function re(e={}){let{t}=u(),{onTranscript:r,onError:i,canStart:a}=e,[o,s]=(0,d.useState)(`idle`),[c,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(0),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),x=(0,d.useRef)(o);(0,d.useEffect)(()=>{x.current=o},[o]);let S=(0,d.useRef)(``),C=(0,d.useRef)(null),w=(0,d.useRef)({starting:!1,confirming:!1,cancelling:!1}),T=(0,d.useRef)(0),E=(0,d.useRef)(r),D=(0,d.useRef)(i);(0,d.useEffect)(()=>{E.current=r,D.current=i},[r,i]);let k=(0,d.useRef)(null);k.current||=new N({client:O});let A=l(()=>{C.current&&=(clearInterval(C.current),null)}),j=l(()=>{C.current||=setInterval(()=>{g(e=>e+1)},te)}),M=l(e=>{let n=ne(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;v(r.message);let i=n.reasonCode;b(typeof i==`string`?i:null),D.current?.(r)}),P=l(()=>{v(null),b(null)}),F=l(()=>{k.current?.clearAll(),S.current=``,m(``)}),I=l(t=>e.onPartialTranscript?.(t));(0,d.useEffect)(()=>O.onPartial((e,t)=>{let n=k.current?.getDictationId();!n||e!==n||(S.current=t,m(t),I(t))}),[I]),(0,d.useEffect)(()=>O.subscribeConnectionStatus(e=>{if(!e){x.current===`recording`&&k.current?.resetStreamForReplay();return}if(x.current!==`recording`||k.current?.getDictationId())return;let t=T.current;k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}),[M]);let L=Y({onPcmSegment:e=>{x.current===`recording`&&k.current?.enqueueSegment(e)},onError:e=>{D.current?.(e)}}),R=(0,d.useRef)(L.stop);(0,d.useEffect)(()=>{R.current=L.stop},[L.stop]);let z=l(e=>{g(0),s(`idle`),x.current=`idle`;let t=e.trim();return F(),t?(E.current?.(t),t):null}),B=l(e=>{k.current?.hasSegments()?(s(`failed`),x.current=`failed`):(s(`idle`),x.current=`idle`),M(e)}),V=l(async()=>{let e=w.current;if(e.starting||e.confirming||e.cancelling||x.current!==`idle`||a&&!a())return;e.starting=!0,f(!0);let t=++T.current;P(),m(``),g(0),s(`recording`),x.current=`recording`,F();try{if(await L.start(),T.current!==t||x.current!==`recording`)return;f(!1),j(),await k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}catch(e){if(T.current!==t)return;await L.stop().catch(()=>void 0),A(),s(`idle`),x.current=`idle`,M(e)}finally{T.current===t&&f(!1),e.starting=!1}}),H=l(async()=>{let e=w.current;if(!e.cancelling&&(x.current===`recording`||x.current===`uploading`)){e.cancelling=!0,f(!1),T.current+=1,A(),g(0),P(),s(`idle`),x.current=`idle`;try{k.current?.cancel()}catch{}F();try{await L.stop()}catch{}finally{e.cancelling=!1}}}),U=l(async()=>{let e=w.current;if(e.confirming||x.current!==`recording`)return null;e.confirming=!0,f(!1);let t=++T.current;P(),A();try{if(await L.stop(),T.current!==t)return null;s(`uploading`),x.current=`uploading`;let e=k.current?.getFinalSeq()??-1;if(e<0)return k.current?.cancel(),z(``);let n=await k.current.finish(e);return T.current===t?z(n.text):null}catch(e){return T.current===t&&B(e),null}finally{e.confirming=!1}}),W=l(async()=>{if(x.current!==`failed`||!k.current?.hasSegments())return null;P();let e=++T.current;s(`uploading`),x.current=`uploading`;try{k.current.resetStreamForReplay();let t=k.current.getFinalSeq(),n=await k.current.finish(t);return T.current===e?z(n.text):null}catch(t){return T.current===e&&B(t),null}}),G=l(()=>{if(x.current!==`failed`)return null;let e=S.current.trim();g(0),s(`idle`),x.current=`idle`,P();try{k.current?.cancel()}catch{}return F(),e?(E.current?.(e),e):null}),K=l(()=>{g(0),s(`idle`),x.current=`idle`,P(),F()});return(0,d.useEffect)(()=>n(()=>{x.current===`failed`?(T.current+=1,K()):H()}),[H,K]),(0,d.useEffect)(()=>{if(o!==`recording`||y!==`model_download_in_progress`)return;let e=setInterval(()=>{x.current!==`recording`||k.current?.getDictationId()||k.current?.restartStream().then(()=>{P()}).catch(e=>{M(e)})},3e3);return()=>clearInterval(e)},[o,y,P,M]),(0,d.useEffect)(()=>()=>{T.current+=1,A(),R.current().catch(()=>void 0),k.current?.cancel()},[A]),{status:o,isRecording:o===`recording`,isStarting:c,isProcessing:o===`uploading`,partialTranscript:p,volume:L.volume,duration:h,error:_,errorReason:y,startDictation:V,confirmDictation:U,cancelDictation:H,retryFailedDictation:W,acceptPartialTranscript:G,discardFailedDictation:K}}var ie=`yuri-mobile-overlay-surface yuri-popup-surface app-region-no-drag transition-[opacity,transform] duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1`,ae=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,oe=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,se=`yuri-popup-separator -mx-1 my-0.5`;export{re as a,R as c,x as d,b as f,p as h,oe as i,I as l,f as m,ie as n,J as o,v as p,se as r,L as s,ae as t,y as u};