@assistant-ui/react 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. package/dist/api/AssistantRuntime.js +5 -4
  2. package/dist/api/AssistantRuntime.js.map +1 -1
  3. package/dist/api/AttachmentRuntime.js +11 -10
  4. package/dist/api/AttachmentRuntime.js.map +1 -1
  5. package/dist/api/ComposerRuntime.js +16 -15
  6. package/dist/api/ComposerRuntime.js.map +1 -1
  7. package/dist/api/ContentPartRuntime.js +3 -2
  8. package/dist/api/ContentPartRuntime.js.map +1 -1
  9. package/dist/api/MessageRuntime.js +14 -13
  10. package/dist/api/MessageRuntime.js.map +1 -1
  11. package/dist/api/ThreadListItemRuntime.js +3 -2
  12. package/dist/api/ThreadListItemRuntime.js.map +1 -1
  13. package/dist/api/ThreadListRuntime.js +11 -10
  14. package/dist/api/ThreadListRuntime.js.map +1 -1
  15. package/dist/api/ThreadRuntime.js +14 -13
  16. package/dist/api/ThreadRuntime.js.map +1 -1
  17. package/dist/api/subscribable/BaseSubject.js +3 -2
  18. package/dist/api/subscribable/BaseSubject.js.map +1 -1
  19. package/dist/api/subscribable/EventSubscriptionSubject.js +4 -3
  20. package/dist/api/subscribable/EventSubscriptionSubject.js.map +1 -1
  21. package/dist/api/subscribable/LazyMemoizeSubject.js +5 -4
  22. package/dist/api/subscribable/LazyMemoizeSubject.js.map +1 -1
  23. package/dist/api/subscribable/NestedSubscriptionSubject.js +4 -3
  24. package/dist/api/subscribable/NestedSubscriptionSubject.js.map +1 -1
  25. package/dist/api/subscribable/SKIP_UPDATE.js +2 -1
  26. package/dist/api/subscribable/SKIP_UPDATE.js.map +1 -1
  27. package/dist/api/subscribable/ShallowMemoizeSubject.js +6 -5
  28. package/dist/api/subscribable/ShallowMemoizeSubject.js.map +1 -1
  29. package/dist/api/subscribable/shallowEqual.js +1 -0
  30. package/dist/api/subscribable/shallowEqual.js.map +1 -1
  31. package/dist/cloud/AssistantCloud.js +7 -6
  32. package/dist/cloud/AssistantCloud.js.map +1 -1
  33. package/dist/cloud/AssistantCloudAPI.js +6 -5
  34. package/dist/cloud/AssistantCloudAPI.js.map +1 -1
  35. package/dist/cloud/AssistantCloudAuthStrategy.js +9 -8
  36. package/dist/cloud/AssistantCloudAuthStrategy.js.map +1 -1
  37. package/dist/cloud/AssistantCloudAuthTokens.js +3 -2
  38. package/dist/cloud/AssistantCloudAuthTokens.js.map +1 -1
  39. package/dist/cloud/AssistantCloudRuns.js +3 -2
  40. package/dist/cloud/AssistantCloudRuns.js.map +1 -1
  41. package/dist/cloud/AssistantCloudThreadHistoryAdapter.js +6 -5
  42. package/dist/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  43. package/dist/cloud/AssistantCloudThreadMessages.js +3 -2
  44. package/dist/cloud/AssistantCloudThreadMessages.js.map +1 -1
  45. package/dist/cloud/AssistantCloudThreads.js +4 -3
  46. package/dist/cloud/AssistantCloudThreads.js.map +1 -1
  47. package/dist/cloud/auiV0.js +5 -4
  48. package/dist/cloud/auiV0.js.map +1 -1
  49. package/dist/cloud/index.js +3 -2
  50. package/dist/cloud/index.js.map +1 -1
  51. package/dist/cloud/useCloudThreadListRuntime.js +5 -3
  52. package/dist/cloud/useCloudThreadListRuntime.js.map +1 -1
  53. package/dist/context/ReadonlyStore.js +2 -1
  54. package/dist/context/ReadonlyStore.js.map +1 -1
  55. package/dist/context/index.js +4 -3
  56. package/dist/context/index.js.map +1 -1
  57. package/dist/context/providers/AssistantRuntimeProvider.js +13 -11
  58. package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
  59. package/dist/context/providers/AttachmentRuntimeProvider.js +8 -6
  60. package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
  61. package/dist/context/providers/ContentPartRuntimeProvider.js +8 -6
  62. package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
  63. package/dist/context/providers/MessageRuntimeProvider.js +10 -8
  64. package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
  65. package/dist/context/providers/TextContentPartProvider.js +10 -8
  66. package/dist/context/providers/TextContentPartProvider.js.map +1 -1
  67. package/dist/context/providers/ThreadListItemRuntimeProvider.js +8 -6
  68. package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -1
  69. package/dist/context/providers/ThreadRuntimeProvider.js +10 -8
  70. package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
  71. package/dist/context/providers/ThreadViewportProvider.js +8 -6
  72. package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
  73. package/dist/context/providers/index.js +3 -2
  74. package/dist/context/providers/index.js.map +1 -1
  75. package/dist/context/react/AssistantContext.js +10 -8
  76. package/dist/context/react/AssistantContext.js.map +1 -1
  77. package/dist/context/react/AttachmentContext.js +10 -8
  78. package/dist/context/react/AttachmentContext.js.map +1 -1
  79. package/dist/context/react/ComposerContext.js +6 -4
  80. package/dist/context/react/ComposerContext.js.map +1 -1
  81. package/dist/context/react/ContentPartContext.js +7 -5
  82. package/dist/context/react/ContentPartContext.js.map +1 -1
  83. package/dist/context/react/MessageContext.js +11 -9
  84. package/dist/context/react/MessageContext.js.map +1 -1
  85. package/dist/context/react/ThreadContext.js +9 -7
  86. package/dist/context/react/ThreadContext.js.map +1 -1
  87. package/dist/context/react/ThreadListItemContext.js +7 -5
  88. package/dist/context/react/ThreadListItemContext.js.map +1 -1
  89. package/dist/context/react/ThreadViewportContext.js +7 -5
  90. package/dist/context/react/ThreadViewportContext.js.map +1 -1
  91. package/dist/context/react/index.js +11 -9
  92. package/dist/context/react/index.js.map +1 -1
  93. package/dist/context/react/utils/createContextHook.js +2 -0
  94. package/dist/context/react/utils/createContextHook.js.map +1 -1
  95. package/dist/context/react/utils/createContextStoreHook.js +1 -0
  96. package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
  97. package/dist/context/react/utils/createStateHookForRuntime.js +2 -1
  98. package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
  99. package/dist/context/react/utils/ensureBinding.js +2 -21
  100. package/dist/context/react/utils/ensureBinding.js.map +1 -1
  101. package/dist/context/react/utils/useRuntimeState.js +3 -2
  102. package/dist/context/react/utils/useRuntimeState.js.map +1 -1
  103. package/dist/context/stores/AssistantToolUIs.js +2 -1
  104. package/dist/context/stores/AssistantToolUIs.js.map +1 -1
  105. package/dist/context/stores/MessageUtils.js +2 -1
  106. package/dist/context/stores/MessageUtils.js.map +1 -1
  107. package/dist/context/stores/ThreadViewport.js +3 -1
  108. package/dist/context/stores/ThreadViewport.js.map +1 -1
  109. package/dist/index.js +9 -8
  110. package/dist/index.js.map +1 -1
  111. package/dist/internal.js +12 -11
  112. package/dist/internal.js.map +1 -1
  113. package/dist/model-context/ModelContextTypes.js +2 -1
  114. package/dist/model-context/ModelContextTypes.js.map +1 -1
  115. package/dist/model-context/index.js +10 -9
  116. package/dist/model-context/index.js.map +1 -1
  117. package/dist/model-context/makeAssistantTool.js +4 -2
  118. package/dist/model-context/makeAssistantTool.js.map +1 -1
  119. package/dist/model-context/makeAssistantToolUI.js +4 -2
  120. package/dist/model-context/makeAssistantToolUI.js.map +1 -1
  121. package/dist/model-context/makeAssistantVisible.js +9 -7
  122. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  123. package/dist/model-context/tool.d.ts +1 -10
  124. package/dist/model-context/tool.d.ts.map +1 -1
  125. package/dist/model-context/tool.js +1 -0
  126. package/dist/model-context/tool.js.map +1 -1
  127. package/dist/model-context/useAssistantInstructions.js +5 -3
  128. package/dist/model-context/useAssistantInstructions.js.map +1 -1
  129. package/dist/model-context/useAssistantTool.d.ts +0 -1
  130. package/dist/model-context/useAssistantTool.d.ts.map +1 -1
  131. package/dist/model-context/useAssistantTool.js +5 -4
  132. package/dist/model-context/useAssistantTool.js.map +1 -1
  133. package/dist/model-context/useAssistantToolUI.js +4 -2
  134. package/dist/model-context/useAssistantToolUI.js.map +1 -1
  135. package/dist/model-context/useInlineRender.js +3 -1
  136. package/dist/model-context/useInlineRender.js.map +1 -1
  137. package/dist/primitives/actionBar/ActionBarCopy.js +8 -6
  138. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  139. package/dist/primitives/actionBar/ActionBarEdit.js +6 -4
  140. package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
  141. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +7 -5
  142. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
  143. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +6 -4
  144. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
  145. package/dist/primitives/actionBar/ActionBarReload.js +8 -6
  146. package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
  147. package/dist/primitives/actionBar/ActionBarRoot.js +5 -3
  148. package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
  149. package/dist/primitives/actionBar/ActionBarSpeak.js +6 -4
  150. package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
  151. package/dist/primitives/actionBar/ActionBarStopSpeaking.js +6 -4
  152. package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
  153. package/dist/primitives/actionBar/index.js +9 -8
  154. package/dist/primitives/actionBar/index.js.map +1 -1
  155. package/dist/primitives/actionBar/useActionBarFloatStatus.js +6 -4
  156. package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
  157. package/dist/primitives/assistantModal/AssistantModalAnchor.js +5 -3
  158. package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
  159. package/dist/primitives/assistantModal/AssistantModalContent.js +5 -3
  160. package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
  161. package/dist/primitives/assistantModal/AssistantModalRoot.js +7 -5
  162. package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
  163. package/dist/primitives/assistantModal/AssistantModalTrigger.js +4 -3
  164. package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
  165. package/dist/primitives/assistantModal/index.js +5 -4
  166. package/dist/primitives/assistantModal/index.js.map +1 -1
  167. package/dist/primitives/assistantModal/scope.js +2 -1
  168. package/dist/primitives/assistantModal/scope.js.map +1 -1
  169. package/dist/primitives/attachment/AttachmentName.js +4 -2
  170. package/dist/primitives/attachment/AttachmentName.js.map +1 -1
  171. package/dist/primitives/attachment/AttachmentRemove.js +6 -4
  172. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  173. package/dist/primitives/attachment/AttachmentRoot.js +3 -2
  174. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  175. package/dist/primitives/attachment/AttachmentThumb.js +5 -3
  176. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  177. package/dist/primitives/attachment/index.js +5 -4
  178. package/dist/primitives/attachment/index.js.map +1 -1
  179. package/dist/primitives/branchPicker/BranchPickerCount.js +5 -3
  180. package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
  181. package/dist/primitives/branchPicker/BranchPickerNext.js +6 -4
  182. package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
  183. package/dist/primitives/branchPicker/BranchPickerNumber.js +5 -3
  184. package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
  185. package/dist/primitives/branchPicker/BranchPickerPrevious.js +6 -4
  186. package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
  187. package/dist/primitives/branchPicker/BranchPickerRoot.js +4 -3
  188. package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
  189. package/dist/primitives/branchPicker/index.js +6 -5
  190. package/dist/primitives/branchPicker/index.js.map +1 -1
  191. package/dist/primitives/composer/ComposerAddAttachment.js +6 -4
  192. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  193. package/dist/primitives/composer/ComposerAttachments.js +11 -9
  194. package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
  195. package/dist/primitives/composer/ComposerCancel.js +6 -4
  196. package/dist/primitives/composer/ComposerCancel.js.map +1 -1
  197. package/dist/primitives/composer/ComposerIf.js +5 -3
  198. package/dist/primitives/composer/ComposerIf.js.map +1 -1
  199. package/dist/primitives/composer/ComposerInput.js +8 -6
  200. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  201. package/dist/primitives/composer/ComposerRoot.js +5 -3
  202. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  203. package/dist/primitives/composer/ComposerSend.js +8 -6
  204. package/dist/primitives/composer/ComposerSend.js.map +1 -1
  205. package/dist/primitives/composer/index.js +8 -7
  206. package/dist/primitives/composer/index.js.map +1 -1
  207. package/dist/primitives/contentPart/ContentPartImage.js +5 -3
  208. package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
  209. package/dist/primitives/contentPart/ContentPartInProgress.js +4 -2
  210. package/dist/primitives/contentPart/ContentPartInProgress.js.map +1 -1
  211. package/dist/primitives/contentPart/ContentPartText.js +6 -4
  212. package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
  213. package/dist/primitives/contentPart/index.js +4 -3
  214. package/dist/primitives/contentPart/index.js.map +1 -1
  215. package/dist/primitives/contentPart/useContentPartFile.js +4 -2
  216. package/dist/primitives/contentPart/useContentPartFile.js.map +1 -1
  217. package/dist/primitives/contentPart/useContentPartImage.js +4 -2
  218. package/dist/primitives/contentPart/useContentPartImage.js.map +1 -1
  219. package/dist/primitives/contentPart/useContentPartReasoning.js +4 -2
  220. package/dist/primitives/contentPart/useContentPartReasoning.js.map +1 -1
  221. package/dist/primitives/contentPart/useContentPartSource.js +4 -2
  222. package/dist/primitives/contentPart/useContentPartSource.js.map +1 -1
  223. package/dist/primitives/contentPart/useContentPartText.js +4 -2
  224. package/dist/primitives/contentPart/useContentPartText.js.map +1 -1
  225. package/dist/primitives/index.js +17 -16
  226. package/dist/primitives/index.js.map +1 -1
  227. package/dist/primitives/message/MessageAttachments.js +11 -9
  228. package/dist/primitives/message/MessageAttachments.js.map +1 -1
  229. package/dist/primitives/message/MessageContent.js +19 -17
  230. package/dist/primitives/message/MessageContent.js.map +1 -1
  231. package/dist/primitives/message/MessageIf.js +6 -4
  232. package/dist/primitives/message/MessageIf.js.map +1 -1
  233. package/dist/primitives/message/MessageRoot.js +7 -5
  234. package/dist/primitives/message/MessageRoot.js.map +1 -1
  235. package/dist/primitives/message/index.js +5 -4
  236. package/dist/primitives/message/index.js.map +1 -1
  237. package/dist/primitives/thread/ThreadEmpty.js +4 -2
  238. package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
  239. package/dist/primitives/thread/ThreadIf.js +5 -3
  240. package/dist/primitives/thread/ThreadIf.js.map +1 -1
  241. package/dist/primitives/thread/ThreadMessages.js +14 -12
  242. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  243. package/dist/primitives/thread/ThreadRoot.js +3 -2
  244. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  245. package/dist/primitives/thread/ThreadScrollToBottom.js +6 -4
  246. package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
  247. package/dist/primitives/thread/ThreadSuggestion.js +7 -5
  248. package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
  249. package/dist/primitives/thread/ThreadViewport.js +7 -5
  250. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  251. package/dist/primitives/thread/index.js +8 -7
  252. package/dist/primitives/thread/index.js.map +1 -1
  253. package/dist/primitives/thread/useThreadViewportAutoScroll.js +9 -7
  254. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  255. package/dist/primitives/threadList/ThreadListItems.js +8 -6
  256. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  257. package/dist/primitives/threadList/ThreadListNew.js +6 -4
  258. package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
  259. package/dist/primitives/threadList/ThreadListRoot.js +3 -2
  260. package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
  261. package/dist/primitives/threadList/index.js +4 -3
  262. package/dist/primitives/threadList/index.js.map +1 -1
  263. package/dist/primitives/threadListItem/ThreadListItemArchive.js +6 -4
  264. package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
  265. package/dist/primitives/threadListItem/ThreadListItemDelete.js +6 -4
  266. package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
  267. package/dist/primitives/threadListItem/ThreadListItemRoot.js +5 -3
  268. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  269. package/dist/primitives/threadListItem/ThreadListItemTitle.js +4 -2
  270. package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
  271. package/dist/primitives/threadListItem/ThreadListItemTrigger.js +6 -4
  272. package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
  273. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +6 -4
  274. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
  275. package/dist/primitives/threadListItem/index.js +7 -6
  276. package/dist/primitives/threadListItem/index.js.map +1 -1
  277. package/dist/runtimes/adapters/RuntimeAdapterProvider.js +5 -4
  278. package/dist/runtimes/adapters/RuntimeAdapterProvider.js.map +1 -1
  279. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js +3 -2
  280. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
  281. package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js +4 -3
  282. package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js.map +1 -1
  283. package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js +4 -3
  284. package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js.map +1 -1
  285. package/dist/runtimes/adapters/attachment/index.js +4 -3
  286. package/dist/runtimes/adapters/attachment/index.js.map +1 -1
  287. package/dist/runtimes/adapters/index.js +5 -4
  288. package/dist/runtimes/adapters/index.js.map +1 -1
  289. package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js +3 -2
  290. package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js.map +1 -1
  291. package/dist/runtimes/adapters/speech/index.js +2 -1
  292. package/dist/runtimes/adapters/speech/index.js.map +1 -1
  293. package/dist/runtimes/composer/BaseComposerRuntimeCore.js +5 -4
  294. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  295. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +5 -4
  296. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  297. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +4 -3
  298. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
  299. package/dist/runtimes/core/BaseAssistantRuntimeCore.js +4 -3
  300. package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
  301. package/dist/runtimes/core/BaseThreadRuntimeCore.js +7 -6
  302. package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
  303. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +7 -6
  304. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
  305. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +8 -7
  306. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
  307. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +11 -10
  308. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  309. package/dist/runtimes/external-store/ThreadMessageConverter.js +3 -2
  310. package/dist/runtimes/external-store/ThreadMessageConverter.js.map +1 -1
  311. package/dist/runtimes/external-store/ThreadMessageLike.js +3 -2
  312. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  313. package/dist/runtimes/external-store/auto-status.js +5 -4
  314. package/dist/runtimes/external-store/auto-status.js.map +1 -1
  315. package/dist/runtimes/external-store/createMessageConverter.js +6 -4
  316. package/dist/runtimes/external-store/createMessageConverter.js.map +1 -1
  317. package/dist/runtimes/external-store/external-message-converter.js +11 -9
  318. package/dist/runtimes/external-store/external-message-converter.js.map +1 -1
  319. package/dist/runtimes/external-store/getExternalStoreMessage.js +6 -5
  320. package/dist/runtimes/external-store/getExternalStoreMessage.js.map +1 -1
  321. package/dist/runtimes/external-store/index.js +5 -4
  322. package/dist/runtimes/external-store/index.js.map +1 -1
  323. package/dist/runtimes/external-store/useExternalStoreRuntime.js +6 -4
  324. package/dist/runtimes/external-store/useExternalStoreRuntime.js.map +1 -1
  325. package/dist/runtimes/index.js +7 -6
  326. package/dist/runtimes/index.js.map +1 -1
  327. package/dist/runtimes/local/LocalRuntimeCore.js +7 -6
  328. package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
  329. package/dist/runtimes/local/LocalRuntimeOptions.js +2 -1
  330. package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
  331. package/dist/runtimes/local/LocalThreadListRuntimeCore.js +5 -4
  332. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
  333. package/dist/runtimes/local/LocalThreadRuntimeCore.js +6 -5
  334. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  335. package/dist/runtimes/local/index.js +2 -1
  336. package/dist/runtimes/local/index.js.map +1 -1
  337. package/dist/runtimes/local/shouldContinue.js +2 -1
  338. package/dist/runtimes/local/shouldContinue.js.map +1 -1
  339. package/dist/runtimes/local/useLocalRuntime.js +9 -7
  340. package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
  341. package/dist/runtimes/remote-thread-list/BaseSubscribable.js +3 -2
  342. package/dist/runtimes/remote-thread-list/BaseSubscribable.js.map +1 -1
  343. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +3 -2
  344. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
  345. package/dist/runtimes/remote-thread-list/OptimisticState.js +5 -4
  346. package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -1
  347. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -7
  348. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  349. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +13 -11
  350. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  351. package/dist/runtimes/remote-thread-list/adapter/cloud.js +9 -8
  352. package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
  353. package/dist/runtimes/remote-thread-list/adapter/in-memory.js +3 -2
  354. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  355. package/dist/runtimes/remote-thread-list/index.js +3 -2
  356. package/dist/runtimes/remote-thread-list/index.js.map +1 -1
  357. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +8 -6
  358. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  359. package/dist/runtimes/utils/MessageRepository.js +10 -9
  360. package/dist/runtimes/utils/MessageRepository.js.map +1 -1
  361. package/dist/tests/setup.js +2971 -3
  362. package/dist/tests/setup.js.map +1 -1
  363. package/dist/utils/CompositeContextProvider.js +4 -3
  364. package/dist/utils/CompositeContextProvider.js.map +1 -1
  365. package/dist/utils/combined/createCombinedStore.js +3 -1
  366. package/dist/utils/combined/createCombinedStore.js.map +1 -1
  367. package/dist/utils/combined/useCombinedStore.js +4 -2
  368. package/dist/utils/combined/useCombinedStore.js.map +1 -1
  369. package/dist/utils/createActionButton.js +3 -2
  370. package/dist/utils/createActionButton.js.map +1 -1
  371. package/dist/utils/getThreadMessageText.js +2 -1
  372. package/dist/utils/getThreadMessageText.js.map +1 -1
  373. package/dist/utils/hooks/useManagedRef.js +2 -1
  374. package/dist/utils/hooks/useManagedRef.js.map +1 -1
  375. package/dist/utils/hooks/useOnResizeContent.js +3 -2
  376. package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
  377. package/dist/utils/hooks/useOnScrollToBottom.js +4 -2
  378. package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
  379. package/dist/utils/idUtils.js +5 -4
  380. package/dist/utils/idUtils.js.map +1 -1
  381. package/dist/utils/json/is-json.js +1 -0
  382. package/dist/utils/json/is-json.js.map +1 -1
  383. package/dist/utils/smooth/SmoothContext.js +10 -8
  384. package/dist/utils/smooth/SmoothContext.js.map +1 -1
  385. package/dist/utils/smooth/index.js +4 -2
  386. package/dist/utils/smooth/index.js.map +1 -1
  387. package/dist/utils/smooth/useSmooth.js +9 -7
  388. package/dist/utils/smooth/useSmooth.js.map +1 -1
  389. package/dist/utils/useToolArgsFieldStatus.js +4 -3
  390. package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
  391. package/package.json +4 -4
  392. package/src/model-context/tool.ts +3 -16
  393. package/src/model-context/useAssistantTool.tsx +1 -4
@@ -1,6 +1,2974 @@
1
- import { vi } from "vitest";
2
- const OriginalDate = global.Date;
3
- const fixedDate = new OriginalDate("2023-01-01");
1
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
2
+ import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from "@vitest/expect.js";
3
+ import { getCurrentTest } from "@vitest/runner.js";
4
+ import { getNames, getTestName } from "@vitest/runner/utils.js";
5
+ import * as chai$1 from "chai.js";
6
+
7
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/utils.CtocqOoE.js
8
+ import { getSafeTimers } from "@vitest/utils.js";
9
+ var NAME_WORKER_STATE = "__vitest_worker__";
10
+ function getWorkerState() {
11
+ const workerState = globalThis[NAME_WORKER_STATE];
12
+ if (!workerState) {
13
+ const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
14
+ throw new Error(errorMsg);
15
+ }
16
+ return workerState;
17
+ }
18
+ function getCurrentEnvironment() {
19
+ const state = getWorkerState();
20
+ return state?.environment.name;
21
+ }
22
+ function isChildProcess() {
23
+ return typeof process !== "undefined" && !!process.send;
24
+ }
25
+ function resetModules(modules, resetMocks = false) {
26
+ const skipPaths = [
27
+ /\/vitest\/dist\//,
28
+ /\/vite-node\/dist\//,
29
+ /vitest-virtual-\w+\/dist/,
30
+ /@vitest\/dist/,
31
+ ...!resetMocks ? [/^mock:/] : []
32
+ ];
33
+ modules.forEach((mod, path) => {
34
+ if (skipPaths.some((re) => re.test(path))) {
35
+ return;
36
+ }
37
+ modules.invalidateModule(mod);
38
+ });
39
+ }
40
+ function waitNextTick() {
41
+ const { setTimeout } = getSafeTimers();
42
+ return new Promise((resolve) => setTimeout(resolve, 0));
43
+ }
44
+ async function waitForImportsToResolve() {
45
+ await waitNextTick();
46
+ const state = getWorkerState();
47
+ const promises = [];
48
+ let resolvingCount = 0;
49
+ for (const mod of state.moduleCache.values()) {
50
+ if (mod.promise && !mod.evaluated) {
51
+ promises.push(mod.promise);
52
+ }
53
+ if (mod.resolving) {
54
+ resolvingCount++;
55
+ }
56
+ }
57
+ if (!promises.length && !resolvingCount) {
58
+ return;
59
+ }
60
+ await Promise.allSettled(promises);
61
+ await waitForImportsToResolve();
62
+ }
63
+
64
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
65
+ import { getSafeTimers as getSafeTimers2, assertTypes, createSimpleStackTrace } from "@vitest/utils.js";
66
+
67
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
68
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
69
+ function getDefaultExportFromCjs(x) {
70
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
71
+ }
72
+
73
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
74
+ import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.js";
75
+ import "@vitest/utils/error.js";
76
+ import { fn, spyOn, mocks, isMockFunction } from "@vitest/spy.js";
77
+ import { parseSingleStack } from "@vitest/utils/source-map.js";
78
+
79
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/date.CDOsz-HY.js
80
+ var RealDate = Date;
81
+ var now = null;
82
+ var MockDate = class _MockDate extends RealDate {
83
+ constructor(y, m, d, h, M, s, ms) {
84
+ super();
85
+ let date;
86
+ switch (arguments.length) {
87
+ case 0:
88
+ if (now !== null) {
89
+ date = new RealDate(now.valueOf());
90
+ } else {
91
+ date = new RealDate();
92
+ }
93
+ break;
94
+ case 1:
95
+ date = new RealDate(y);
96
+ break;
97
+ default:
98
+ d = typeof d === "undefined" ? 1 : d;
99
+ h = h || 0;
100
+ M = M || 0;
101
+ s = s || 0;
102
+ ms = ms || 0;
103
+ date = new RealDate(y, m, d, h, M, s, ms);
104
+ break;
105
+ }
106
+ Object.setPrototypeOf(date, _MockDate.prototype);
107
+ return date;
108
+ }
109
+ };
110
+ MockDate.UTC = RealDate.UTC;
111
+ MockDate.now = function() {
112
+ return new MockDate().valueOf();
113
+ };
114
+ MockDate.parse = function(dateString) {
115
+ return RealDate.parse(dateString);
116
+ };
117
+ MockDate.toString = function() {
118
+ return RealDate.toString();
119
+ };
120
+ function mockDate(date) {
121
+ const dateObj = new RealDate(date.valueOf());
122
+ if (Number.isNaN(dateObj.getTime())) {
123
+ throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
124
+ }
125
+ globalThis.Date = MockDate;
126
+ now = dateObj.valueOf();
127
+ }
128
+ function resetDate() {
129
+ globalThis.Date = RealDate;
130
+ }
131
+
132
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
133
+ var unsupported = [
134
+ "matchSnapshot",
135
+ "toMatchSnapshot",
136
+ "toMatchInlineSnapshot",
137
+ "toThrowErrorMatchingSnapshot",
138
+ "toThrowErrorMatchingInlineSnapshot",
139
+ "throws",
140
+ "Throw",
141
+ "throw",
142
+ "toThrow",
143
+ "toThrowError"
144
+ ];
145
+ function createExpectPoll(expect2) {
146
+ return function poll(fn2, options = {}) {
147
+ const state = getWorkerState();
148
+ const defaults = state.config.expect?.poll ?? {};
149
+ const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
150
+ const assertion = expect2(null, message).withContext({ poll: true });
151
+ fn2 = fn2.bind(assertion);
152
+ const test2 = chai$1.util.flag(assertion, "vitest-test");
153
+ if (!test2) {
154
+ throw new Error("expect.poll() must be called inside a test");
155
+ }
156
+ const proxy = new Proxy(assertion, { get(target, key, receiver) {
157
+ const assertionFunction = Reflect.get(target, key, receiver);
158
+ if (typeof assertionFunction !== "function") {
159
+ return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
160
+ }
161
+ if (key === "assert") {
162
+ return assertionFunction;
163
+ }
164
+ if (typeof key === "string" && unsupported.includes(key)) {
165
+ throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
166
+ }
167
+ return function(...args) {
168
+ const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
169
+ const promise = () => new Promise((resolve, reject) => {
170
+ let intervalId;
171
+ let timeoutId;
172
+ let lastError;
173
+ const { setTimeout, clearTimeout } = getSafeTimers2();
174
+ const check = async () => {
175
+ try {
176
+ chai$1.util.flag(assertion, "_name", key);
177
+ const obj = await fn2();
178
+ chai$1.util.flag(assertion, "object", obj);
179
+ resolve(await assertionFunction.call(assertion, ...args));
180
+ clearTimeout(intervalId);
181
+ clearTimeout(timeoutId);
182
+ } catch (err) {
183
+ lastError = err;
184
+ if (!chai$1.util.flag(assertion, "_isLastPollAttempt")) {
185
+ intervalId = setTimeout(check, interval);
186
+ }
187
+ }
188
+ };
189
+ timeoutId = setTimeout(() => {
190
+ clearTimeout(intervalId);
191
+ chai$1.util.flag(assertion, "_isLastPollAttempt", true);
192
+ const rejectWithCause = (cause) => {
193
+ reject(copyStackTrace$1(new Error("Matcher did not succeed in time.", { cause }), STACK_TRACE_ERROR));
194
+ };
195
+ check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
196
+ }, timeout);
197
+ check();
198
+ });
199
+ let awaited = false;
200
+ test2.onFinished ??= [];
201
+ test2.onFinished.push(() => {
202
+ if (!awaited) {
203
+ const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
204
+ const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
205
+ const assertionString = `expect.${name}.${negated}${String(key)}()`;
206
+ const error = new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
207
+
208
+ await ${assertionString}
209
+ `);
210
+ throw copyStackTrace$1(error, STACK_TRACE_ERROR);
211
+ }
212
+ });
213
+ let resultPromise;
214
+ return {
215
+ then(onFulfilled, onRejected) {
216
+ awaited = true;
217
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
218
+ },
219
+ catch(onRejected) {
220
+ return (resultPromise ||= promise()).catch(onRejected);
221
+ },
222
+ finally(onFinally) {
223
+ return (resultPromise ||= promise()).finally(onFinally);
224
+ },
225
+ [Symbol.toStringTag]: "Promise"
226
+ };
227
+ };
228
+ } });
229
+ return proxy;
230
+ };
231
+ }
232
+ function copyStackTrace$1(target, source) {
233
+ if (source.stack !== void 0) {
234
+ target.stack = source.stack.replace(source.message, target.message);
235
+ }
236
+ return target;
237
+ }
238
+ function commonjsRequire(path) {
239
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
240
+ }
241
+ var chaiSubset$1 = { exports: {} };
242
+ var chaiSubset = chaiSubset$1.exports;
243
+ var hasRequiredChaiSubset;
244
+ function requireChaiSubset() {
245
+ if (hasRequiredChaiSubset) return chaiSubset$1.exports;
246
+ hasRequiredChaiSubset = 1;
247
+ (function(module, exports) {
248
+ (function() {
249
+ (function(chaiSubset2) {
250
+ if (typeof commonjsRequire === "function" && true && true) {
251
+ return module.exports = chaiSubset2;
252
+ } else {
253
+ return chai.use(chaiSubset2);
254
+ }
255
+ })(function(chai3, utils) {
256
+ var Assertion2 = chai3.Assertion;
257
+ var assertionPrototype = Assertion2.prototype;
258
+ Assertion2.addMethod("containSubset", function(expected) {
259
+ var actual = utils.flag(this, "object");
260
+ var showDiff = chai3.config.showDiff;
261
+ assertionPrototype.assert.call(
262
+ this,
263
+ compare(expected, actual),
264
+ "expected #{act} to contain subset #{exp}",
265
+ "expected #{act} to not contain subset #{exp}",
266
+ expected,
267
+ actual,
268
+ showDiff
269
+ );
270
+ });
271
+ chai3.assert.containSubset = function(val, exp, msg) {
272
+ new chai3.Assertion(val, msg).to.be.containSubset(exp);
273
+ };
274
+ function compare(expected, actual) {
275
+ if (expected === actual) {
276
+ return true;
277
+ }
278
+ if (typeof actual !== typeof expected) {
279
+ return false;
280
+ }
281
+ if (typeof expected !== "object" || expected === null) {
282
+ return expected === actual;
283
+ }
284
+ if (!!expected && !actual) {
285
+ return false;
286
+ }
287
+ if (Array.isArray(expected)) {
288
+ if (typeof actual.length !== "number") {
289
+ return false;
290
+ }
291
+ var aa = Array.prototype.slice.call(actual);
292
+ return expected.every(function(exp) {
293
+ return aa.some(function(act) {
294
+ return compare(exp, act);
295
+ });
296
+ });
297
+ }
298
+ if (expected instanceof Date) {
299
+ if (actual instanceof Date) {
300
+ return expected.getTime() === actual.getTime();
301
+ } else {
302
+ return false;
303
+ }
304
+ }
305
+ return Object.keys(expected).every(function(key) {
306
+ var eo = expected[key];
307
+ var ao = actual[key];
308
+ if (typeof eo === "object" && eo !== null && ao !== null) {
309
+ return compare(eo, ao);
310
+ }
311
+ if (typeof eo === "function") {
312
+ return eo(ao);
313
+ }
314
+ return ao === eo;
315
+ });
316
+ }
317
+ });
318
+ }).call(chaiSubset);
319
+ })(chaiSubset$1);
320
+ return chaiSubset$1.exports;
321
+ }
322
+ var chaiSubsetExports = requireChaiSubset();
323
+ var Subset = /* @__PURE__ */ getDefaultExportFromCjs(chaiSubsetExports);
324
+ function createAssertionMessage(util2, assertion, hasArgs) {
325
+ const not = util2.flag(assertion, "negate") ? "not." : "";
326
+ const name = `${util2.flag(assertion, "_name")}(${"expected"})`;
327
+ const promiseName = util2.flag(assertion, "promise");
328
+ const promise = promiseName ? `.${promiseName}` : "";
329
+ return `expect(actual)${promise}.${not}${name}`;
330
+ }
331
+ function recordAsyncExpect(_test, promise, assertion, error) {
332
+ const test2 = _test;
333
+ if (test2 && promise instanceof Promise) {
334
+ promise = promise.finally(() => {
335
+ if (!test2.promises) {
336
+ return;
337
+ }
338
+ const index = test2.promises.indexOf(promise);
339
+ if (index !== -1) {
340
+ test2.promises.splice(index, 1);
341
+ }
342
+ });
343
+ if (!test2.promises) {
344
+ test2.promises = [];
345
+ }
346
+ test2.promises.push(promise);
347
+ let resolved = false;
348
+ test2.onFinished ??= [];
349
+ test2.onFinished.push(() => {
350
+ if (!resolved) {
351
+ const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
352
+ const stack = processor(error.stack);
353
+ console.warn([
354
+ `Promise returned by \`${assertion}\` was not awaited. `,
355
+ "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
356
+ "Please remember to await the assertion.\n",
357
+ stack
358
+ ].join(""));
359
+ }
360
+ });
361
+ return {
362
+ then(onFulfilled, onRejected) {
363
+ resolved = true;
364
+ return promise.then(onFulfilled, onRejected);
365
+ },
366
+ catch(onRejected) {
367
+ return promise.catch(onRejected);
368
+ },
369
+ finally(onFinally) {
370
+ return promise.finally(onFinally);
371
+ },
372
+ [Symbol.toStringTag]: "Promise"
373
+ };
374
+ }
375
+ return promise;
376
+ }
377
+ var _client;
378
+ function getSnapshotClient() {
379
+ if (!_client) {
380
+ _client = new SnapshotClient({ isEqual: (received, expected) => {
381
+ return equals(received, expected, [iterableEquality, subsetEquality]);
382
+ } });
383
+ }
384
+ return _client;
385
+ }
386
+ function getError(expected, promise) {
387
+ if (typeof expected !== "function") {
388
+ if (!promise) {
389
+ throw new Error(`expected must be a function, received ${typeof expected}`);
390
+ }
391
+ return expected;
392
+ }
393
+ try {
394
+ expected();
395
+ } catch (e) {
396
+ return e;
397
+ }
398
+ throw new Error("snapshot function didn't throw");
399
+ }
400
+ function getTestNames(test2) {
401
+ return {
402
+ filepath: test2.file.filepath,
403
+ name: getNames(test2).slice(1).join(" > "),
404
+ testId: test2.id
405
+ };
406
+ }
407
+ var SnapshotPlugin = (chai3, utils) => {
408
+ function getTest(assertionName, obj) {
409
+ const test2 = utils.flag(obj, "vitest-test");
410
+ if (!test2) {
411
+ throw new Error(`'${assertionName}' cannot be used without test context`);
412
+ }
413
+ return test2;
414
+ }
415
+ for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
416
+ utils.addMethod(chai3.Assertion.prototype, key, function(properties, message) {
417
+ utils.flag(this, "_name", key);
418
+ const isNot = utils.flag(this, "negate");
419
+ if (isNot) {
420
+ throw new Error(`${key} cannot be used with "not"`);
421
+ }
422
+ const expected = utils.flag(this, "object");
423
+ const test2 = getTest(key, this);
424
+ if (typeof properties === "string" && typeof message === "undefined") {
425
+ message = properties;
426
+ properties = void 0;
427
+ }
428
+ const errorMessage = utils.flag(this, "message");
429
+ getSnapshotClient().assert({
430
+ received: expected,
431
+ message,
432
+ isInline: false,
433
+ properties,
434
+ errorMessage,
435
+ ...getTestNames(test2)
436
+ });
437
+ });
438
+ }
439
+ utils.addMethod(chai3.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
440
+ utils.flag(this, "_name", "toMatchFileSnapshot");
441
+ const isNot = utils.flag(this, "negate");
442
+ if (isNot) {
443
+ throw new Error('toMatchFileSnapshot cannot be used with "not"');
444
+ }
445
+ const error = new Error("resolves");
446
+ const expected = utils.flag(this, "object");
447
+ const test2 = getTest("toMatchFileSnapshot", this);
448
+ const errorMessage = utils.flag(this, "message");
449
+ const promise = getSnapshotClient().assertRaw({
450
+ received: expected,
451
+ message,
452
+ isInline: false,
453
+ rawSnapshot: { file },
454
+ errorMessage,
455
+ ...getTestNames(test2)
456
+ });
457
+ return recordAsyncExpect(test2, promise, createAssertionMessage(utils, this), error);
458
+ });
459
+ utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
460
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
461
+ const isNot = utils.flag(this, "negate");
462
+ if (isNot) {
463
+ throw new Error('toMatchInlineSnapshot cannot be used with "not"');
464
+ }
465
+ const test2 = getTest("toMatchInlineSnapshot", this);
466
+ const isInsideEach = test2.each || test2.suite?.each;
467
+ if (isInsideEach) {
468
+ throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
469
+ }
470
+ const expected = utils.flag(this, "object");
471
+ const error = utils.flag(this, "error");
472
+ if (typeof properties === "string") {
473
+ message = inlineSnapshot;
474
+ inlineSnapshot = properties;
475
+ properties = void 0;
476
+ }
477
+ if (inlineSnapshot) {
478
+ inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
479
+ }
480
+ const errorMessage = utils.flag(this, "message");
481
+ getSnapshotClient().assert({
482
+ received: expected,
483
+ message,
484
+ isInline: true,
485
+ properties,
486
+ inlineSnapshot,
487
+ error,
488
+ errorMessage,
489
+ ...getTestNames(test2)
490
+ });
491
+ });
492
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
493
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
494
+ const isNot = utils.flag(this, "negate");
495
+ if (isNot) {
496
+ throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
497
+ }
498
+ const expected = utils.flag(this, "object");
499
+ const test2 = getTest("toThrowErrorMatchingSnapshot", this);
500
+ const promise = utils.flag(this, "promise");
501
+ const errorMessage = utils.flag(this, "message");
502
+ getSnapshotClient().assert({
503
+ received: getError(expected, promise),
504
+ message,
505
+ errorMessage,
506
+ ...getTestNames(test2)
507
+ });
508
+ });
509
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
510
+ const isNot = utils.flag(this, "negate");
511
+ if (isNot) {
512
+ throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
513
+ }
514
+ const test2 = getTest("toThrowErrorMatchingInlineSnapshot", this);
515
+ const isInsideEach = test2.each || test2.suite?.each;
516
+ if (isInsideEach) {
517
+ throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
518
+ }
519
+ const expected = utils.flag(this, "object");
520
+ const error = utils.flag(this, "error");
521
+ const promise = utils.flag(this, "promise");
522
+ const errorMessage = utils.flag(this, "message");
523
+ if (inlineSnapshot) {
524
+ inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
525
+ }
526
+ getSnapshotClient().assert({
527
+ received: getError(expected, promise),
528
+ message,
529
+ inlineSnapshot,
530
+ isInline: true,
531
+ error,
532
+ errorMessage,
533
+ ...getTestNames(test2)
534
+ });
535
+ });
536
+ utils.addMethod(chai3.expect, "addSnapshotSerializer", addSerializer);
537
+ };
538
+ chai$1.use(JestExtend);
539
+ chai$1.use(JestChaiExpect);
540
+ chai$1.use(Subset);
541
+ chai$1.use(SnapshotPlugin);
542
+ chai$1.use(JestAsymmetricMatchers);
543
+ function createExpect(test2) {
544
+ const expect2 = (value, message) => {
545
+ const { assertionCalls } = getState(expect2);
546
+ setState({ assertionCalls: assertionCalls + 1 }, expect2);
547
+ const assert3 = chai$1.expect(value, message);
548
+ const _test = test2 || getCurrentTest();
549
+ if (_test) {
550
+ return assert3.withTest(_test);
551
+ } else {
552
+ return assert3;
553
+ }
554
+ };
555
+ Object.assign(expect2, chai$1.expect);
556
+ Object.assign(expect2, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
557
+ expect2.getState = () => getState(expect2);
558
+ expect2.setState = (state) => setState(state, expect2);
559
+ const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
560
+ setState({
561
+ ...globalState,
562
+ assertionCalls: 0,
563
+ isExpectingAssertions: false,
564
+ isExpectingAssertionsError: null,
565
+ expectedAssertionsNumber: null,
566
+ expectedAssertionsNumberErrorGen: null,
567
+ environment: getCurrentEnvironment(),
568
+ get testPath() {
569
+ return getWorkerState().filepath;
570
+ },
571
+ currentTestName: test2 ? getTestName(test2) : globalState.currentTestName
572
+ }, expect2);
573
+ expect2.extend = (matchers) => chai$1.expect.extend(expect2, matchers);
574
+ expect2.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
575
+ expect2.soft = (...args) => {
576
+ return expect2(...args).withContext({ soft: true });
577
+ };
578
+ expect2.poll = createExpectPoll(expect2);
579
+ expect2.unreachable = (message) => {
580
+ chai$1.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
581
+ };
582
+ function assertions(expected) {
583
+ const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect2.getState().assertionCalls}`);
584
+ if (Error.captureStackTrace) {
585
+ Error.captureStackTrace(errorGen(), assertions);
586
+ }
587
+ expect2.setState({
588
+ expectedAssertionsNumber: expected,
589
+ expectedAssertionsNumberErrorGen: errorGen
590
+ });
591
+ }
592
+ function hasAssertions() {
593
+ const error = new Error("expected any number of assertion, but got none");
594
+ if (Error.captureStackTrace) {
595
+ Error.captureStackTrace(error, hasAssertions);
596
+ }
597
+ expect2.setState({
598
+ isExpectingAssertions: true,
599
+ isExpectingAssertionsError: error
600
+ });
601
+ }
602
+ chai$1.util.addMethod(expect2, "assertions", assertions);
603
+ chai$1.util.addMethod(expect2, "hasAssertions", hasAssertions);
604
+ expect2.extend(customMatchers);
605
+ return expect2;
606
+ }
607
+ var globalExpect = createExpect();
608
+ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
609
+ value: globalExpect,
610
+ writable: true,
611
+ configurable: true
612
+ });
613
+ var fakeTimersSrc = {};
614
+ var global2;
615
+ var hasRequiredGlobal;
616
+ function requireGlobal() {
617
+ if (hasRequiredGlobal) return global2;
618
+ hasRequiredGlobal = 1;
619
+ var globalObject;
620
+ if (typeof commonjsGlobal !== "undefined") {
621
+ globalObject = commonjsGlobal;
622
+ } else if (typeof window !== "undefined") {
623
+ globalObject = window;
624
+ } else {
625
+ globalObject = self;
626
+ }
627
+ global2 = globalObject;
628
+ return global2;
629
+ }
630
+ var throwsOnProto_1;
631
+ var hasRequiredThrowsOnProto;
632
+ function requireThrowsOnProto() {
633
+ if (hasRequiredThrowsOnProto) return throwsOnProto_1;
634
+ hasRequiredThrowsOnProto = 1;
635
+ let throwsOnProto;
636
+ try {
637
+ const object2 = {};
638
+ object2.__proto__;
639
+ throwsOnProto = false;
640
+ } catch (_) {
641
+ throwsOnProto = true;
642
+ }
643
+ throwsOnProto_1 = throwsOnProto;
644
+ return throwsOnProto_1;
645
+ }
646
+ var copyPrototypeMethods;
647
+ var hasRequiredCopyPrototypeMethods;
648
+ function requireCopyPrototypeMethods() {
649
+ if (hasRequiredCopyPrototypeMethods) return copyPrototypeMethods;
650
+ hasRequiredCopyPrototypeMethods = 1;
651
+ var call = Function.call;
652
+ var throwsOnProto = requireThrowsOnProto();
653
+ var disallowedProperties = [
654
+ // ignore size because it throws from Map
655
+ "size",
656
+ "caller",
657
+ "callee",
658
+ "arguments"
659
+ ];
660
+ if (throwsOnProto) {
661
+ disallowedProperties.push("__proto__");
662
+ }
663
+ copyPrototypeMethods = function copyPrototypeMethods2(prototype) {
664
+ return Object.getOwnPropertyNames(prototype).reduce(
665
+ function(result, name) {
666
+ if (disallowedProperties.includes(name)) {
667
+ return result;
668
+ }
669
+ if (typeof prototype[name] !== "function") {
670
+ return result;
671
+ }
672
+ result[name] = call.bind(prototype[name]);
673
+ return result;
674
+ },
675
+ /* @__PURE__ */ Object.create(null)
676
+ );
677
+ };
678
+ return copyPrototypeMethods;
679
+ }
680
+ var array;
681
+ var hasRequiredArray;
682
+ function requireArray() {
683
+ if (hasRequiredArray) return array;
684
+ hasRequiredArray = 1;
685
+ var copyPrototype = requireCopyPrototypeMethods();
686
+ array = copyPrototype(Array.prototype);
687
+ return array;
688
+ }
689
+ var calledInOrder_1;
690
+ var hasRequiredCalledInOrder;
691
+ function requireCalledInOrder() {
692
+ if (hasRequiredCalledInOrder) return calledInOrder_1;
693
+ hasRequiredCalledInOrder = 1;
694
+ var every2 = requireArray().every;
695
+ function hasCallsLeft(callMap, spy) {
696
+ if (callMap[spy.id] === void 0) {
697
+ callMap[spy.id] = 0;
698
+ }
699
+ return callMap[spy.id] < spy.callCount;
700
+ }
701
+ function checkAdjacentCalls(callMap, spy, index, spies) {
702
+ var calledBeforeNext = true;
703
+ if (index !== spies.length - 1) {
704
+ calledBeforeNext = spy.calledBefore(spies[index + 1]);
705
+ }
706
+ if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
707
+ callMap[spy.id] += 1;
708
+ return true;
709
+ }
710
+ return false;
711
+ }
712
+ function calledInOrder(spies) {
713
+ var callMap = {};
714
+ var _spies = arguments.length > 1 ? arguments : spies;
715
+ return every2(_spies, checkAdjacentCalls.bind(null, callMap));
716
+ }
717
+ calledInOrder_1 = calledInOrder;
718
+ return calledInOrder_1;
719
+ }
720
+ var className_1;
721
+ var hasRequiredClassName;
722
+ function requireClassName() {
723
+ if (hasRequiredClassName) return className_1;
724
+ hasRequiredClassName = 1;
725
+ function className(value) {
726
+ const name = value.constructor && value.constructor.name;
727
+ return name || null;
728
+ }
729
+ className_1 = className;
730
+ return className_1;
731
+ }
732
+ var deprecated = {};
733
+ var hasRequiredDeprecated;
734
+ function requireDeprecated() {
735
+ if (hasRequiredDeprecated) return deprecated;
736
+ hasRequiredDeprecated = 1;
737
+ (function(exports) {
738
+ exports.wrap = function(func, msg) {
739
+ var wrapped = function() {
740
+ exports.printWarning(msg);
741
+ return func.apply(this, arguments);
742
+ };
743
+ if (func.prototype) {
744
+ wrapped.prototype = func.prototype;
745
+ }
746
+ return wrapped;
747
+ };
748
+ exports.defaultMsg = function(packageName, funcName) {
749
+ return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
750
+ };
751
+ exports.printWarning = function(msg) {
752
+ if (typeof process === "object" && process.emitWarning) {
753
+ process.emitWarning(msg);
754
+ } else if (console.info) {
755
+ console.info(msg);
756
+ } else {
757
+ console.log(msg);
758
+ }
759
+ };
760
+ })(deprecated);
761
+ return deprecated;
762
+ }
763
+ var every;
764
+ var hasRequiredEvery;
765
+ function requireEvery() {
766
+ if (hasRequiredEvery) return every;
767
+ hasRequiredEvery = 1;
768
+ every = function every2(obj, fn2) {
769
+ var pass = true;
770
+ try {
771
+ obj.forEach(function() {
772
+ if (!fn2.apply(this, arguments)) {
773
+ throw new Error();
774
+ }
775
+ });
776
+ } catch (e) {
777
+ pass = false;
778
+ }
779
+ return pass;
780
+ };
781
+ return every;
782
+ }
783
+ var functionName;
784
+ var hasRequiredFunctionName;
785
+ function requireFunctionName() {
786
+ if (hasRequiredFunctionName) return functionName;
787
+ hasRequiredFunctionName = 1;
788
+ functionName = function functionName2(func) {
789
+ if (!func) {
790
+ return "";
791
+ }
792
+ try {
793
+ return func.displayName || func.name || // Use function decomposition as a last resort to get function
794
+ // name. Does not rely on function decomposition to work - if it
795
+ // doesn't debugging will be slightly less informative
796
+ // (i.e. toString will say 'spy' rather than 'myFunc').
797
+ (String(func).match(/function ([^\s(]+)/) || [])[1];
798
+ } catch (e) {
799
+ return "";
800
+ }
801
+ };
802
+ return functionName;
803
+ }
804
+ var orderByFirstCall_1;
805
+ var hasRequiredOrderByFirstCall;
806
+ function requireOrderByFirstCall() {
807
+ if (hasRequiredOrderByFirstCall) return orderByFirstCall_1;
808
+ hasRequiredOrderByFirstCall = 1;
809
+ var sort = requireArray().sort;
810
+ var slice = requireArray().slice;
811
+ function comparator(a, b) {
812
+ var aCall = a.getCall(0);
813
+ var bCall = b.getCall(0);
814
+ var aId = aCall && aCall.callId || -1;
815
+ var bId = bCall && bCall.callId || -1;
816
+ return aId < bId ? -1 : 1;
817
+ }
818
+ function orderByFirstCall(spies) {
819
+ return sort(slice(spies), comparator);
820
+ }
821
+ orderByFirstCall_1 = orderByFirstCall;
822
+ return orderByFirstCall_1;
823
+ }
824
+ var _function;
825
+ var hasRequired_function;
826
+ function require_function() {
827
+ if (hasRequired_function) return _function;
828
+ hasRequired_function = 1;
829
+ var copyPrototype = requireCopyPrototypeMethods();
830
+ _function = copyPrototype(Function.prototype);
831
+ return _function;
832
+ }
833
+ var map;
834
+ var hasRequiredMap;
835
+ function requireMap() {
836
+ if (hasRequiredMap) return map;
837
+ hasRequiredMap = 1;
838
+ var copyPrototype = requireCopyPrototypeMethods();
839
+ map = copyPrototype(Map.prototype);
840
+ return map;
841
+ }
842
+ var object;
843
+ var hasRequiredObject;
844
+ function requireObject() {
845
+ if (hasRequiredObject) return object;
846
+ hasRequiredObject = 1;
847
+ var copyPrototype = requireCopyPrototypeMethods();
848
+ object = copyPrototype(Object.prototype);
849
+ return object;
850
+ }
851
+ var set;
852
+ var hasRequiredSet;
853
+ function requireSet() {
854
+ if (hasRequiredSet) return set;
855
+ hasRequiredSet = 1;
856
+ var copyPrototype = requireCopyPrototypeMethods();
857
+ set = copyPrototype(Set.prototype);
858
+ return set;
859
+ }
860
+ var string;
861
+ var hasRequiredString;
862
+ function requireString() {
863
+ if (hasRequiredString) return string;
864
+ hasRequiredString = 1;
865
+ var copyPrototype = requireCopyPrototypeMethods();
866
+ string = copyPrototype(String.prototype);
867
+ return string;
868
+ }
869
+ var prototypes;
870
+ var hasRequiredPrototypes;
871
+ function requirePrototypes() {
872
+ if (hasRequiredPrototypes) return prototypes;
873
+ hasRequiredPrototypes = 1;
874
+ prototypes = {
875
+ array: requireArray(),
876
+ function: require_function(),
877
+ map: requireMap(),
878
+ object: requireObject(),
879
+ set: requireSet(),
880
+ string: requireString()
881
+ };
882
+ return prototypes;
883
+ }
884
+ var typeDetect$1 = { exports: {} };
885
+ var typeDetect = typeDetect$1.exports;
886
+ var hasRequiredTypeDetect;
887
+ function requireTypeDetect() {
888
+ if (hasRequiredTypeDetect) return typeDetect$1.exports;
889
+ hasRequiredTypeDetect = 1;
890
+ (function(module, exports) {
891
+ (function(global3, factory) {
892
+ module.exports = factory();
893
+ })(typeDetect, function() {
894
+ var promiseExists = typeof Promise === "function";
895
+ var globalObject = typeof self === "object" ? self : commonjsGlobal;
896
+ var symbolExists = typeof Symbol !== "undefined";
897
+ var mapExists = typeof Map !== "undefined";
898
+ var setExists = typeof Set !== "undefined";
899
+ var weakMapExists = typeof WeakMap !== "undefined";
900
+ var weakSetExists = typeof WeakSet !== "undefined";
901
+ var dataViewExists = typeof DataView !== "undefined";
902
+ var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
903
+ var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
904
+ var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
905
+ var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
906
+ var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
907
+ var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
908
+ var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
909
+ var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
910
+ var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
911
+ var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
912
+ var toStringLeftSliceLength = 8;
913
+ var toStringRightSliceLength = -1;
914
+ function typeDetect2(obj) {
915
+ var typeofObj = typeof obj;
916
+ if (typeofObj !== "object") {
917
+ return typeofObj;
918
+ }
919
+ if (obj === null) {
920
+ return "null";
921
+ }
922
+ if (obj === globalObject) {
923
+ return "global";
924
+ }
925
+ if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
926
+ return "Array";
927
+ }
928
+ if (typeof window === "object" && window !== null) {
929
+ if (typeof window.location === "object" && obj === window.location) {
930
+ return "Location";
931
+ }
932
+ if (typeof window.document === "object" && obj === window.document) {
933
+ return "Document";
934
+ }
935
+ if (typeof window.navigator === "object") {
936
+ if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
937
+ return "MimeTypeArray";
938
+ }
939
+ if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
940
+ return "PluginArray";
941
+ }
942
+ }
943
+ if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
944
+ if (obj.tagName === "BLOCKQUOTE") {
945
+ return "HTMLQuoteElement";
946
+ }
947
+ if (obj.tagName === "TD") {
948
+ return "HTMLTableDataCellElement";
949
+ }
950
+ if (obj.tagName === "TH") {
951
+ return "HTMLTableHeaderCellElement";
952
+ }
953
+ }
954
+ }
955
+ var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
956
+ if (typeof stringTag === "string") {
957
+ return stringTag;
958
+ }
959
+ var objPrototype = Object.getPrototypeOf(obj);
960
+ if (objPrototype === RegExp.prototype) {
961
+ return "RegExp";
962
+ }
963
+ if (objPrototype === Date.prototype) {
964
+ return "Date";
965
+ }
966
+ if (promiseExists && objPrototype === Promise.prototype) {
967
+ return "Promise";
968
+ }
969
+ if (setExists && objPrototype === Set.prototype) {
970
+ return "Set";
971
+ }
972
+ if (mapExists && objPrototype === Map.prototype) {
973
+ return "Map";
974
+ }
975
+ if (weakSetExists && objPrototype === WeakSet.prototype) {
976
+ return "WeakSet";
977
+ }
978
+ if (weakMapExists && objPrototype === WeakMap.prototype) {
979
+ return "WeakMap";
980
+ }
981
+ if (dataViewExists && objPrototype === DataView.prototype) {
982
+ return "DataView";
983
+ }
984
+ if (mapExists && objPrototype === mapIteratorPrototype) {
985
+ return "Map Iterator";
986
+ }
987
+ if (setExists && objPrototype === setIteratorPrototype) {
988
+ return "Set Iterator";
989
+ }
990
+ if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
991
+ return "Array Iterator";
992
+ }
993
+ if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
994
+ return "String Iterator";
995
+ }
996
+ if (objPrototype === null) {
997
+ return "Object";
998
+ }
999
+ return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
1000
+ }
1001
+ return typeDetect2;
1002
+ });
1003
+ })(typeDetect$1);
1004
+ return typeDetect$1.exports;
1005
+ }
1006
+ var typeOf;
1007
+ var hasRequiredTypeOf;
1008
+ function requireTypeOf() {
1009
+ if (hasRequiredTypeOf) return typeOf;
1010
+ hasRequiredTypeOf = 1;
1011
+ var type = requireTypeDetect();
1012
+ typeOf = function typeOf2(value) {
1013
+ return type(value).toLowerCase();
1014
+ };
1015
+ return typeOf;
1016
+ }
1017
+ var valueToString_1;
1018
+ var hasRequiredValueToString;
1019
+ function requireValueToString() {
1020
+ if (hasRequiredValueToString) return valueToString_1;
1021
+ hasRequiredValueToString = 1;
1022
+ function valueToString(value) {
1023
+ if (value && value.toString) {
1024
+ return value.toString();
1025
+ }
1026
+ return String(value);
1027
+ }
1028
+ valueToString_1 = valueToString;
1029
+ return valueToString_1;
1030
+ }
1031
+ var lib;
1032
+ var hasRequiredLib;
1033
+ function requireLib() {
1034
+ if (hasRequiredLib) return lib;
1035
+ hasRequiredLib = 1;
1036
+ lib = {
1037
+ global: requireGlobal(),
1038
+ calledInOrder: requireCalledInOrder(),
1039
+ className: requireClassName(),
1040
+ deprecated: requireDeprecated(),
1041
+ every: requireEvery(),
1042
+ functionName: requireFunctionName(),
1043
+ orderByFirstCall: requireOrderByFirstCall(),
1044
+ prototypes: requirePrototypes(),
1045
+ typeOf: requireTypeOf(),
1046
+ valueToString: requireValueToString()
1047
+ };
1048
+ return lib;
1049
+ }
1050
+ var hasRequiredFakeTimersSrc;
1051
+ function requireFakeTimersSrc() {
1052
+ if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
1053
+ hasRequiredFakeTimersSrc = 1;
1054
+ const globalObject = requireLib().global;
1055
+ let timersModule, timersPromisesModule;
1056
+ if (typeof __vitest_required__ !== "undefined") {
1057
+ try {
1058
+ timersModule = __vitest_required__.timers;
1059
+ } catch (e) {
1060
+ }
1061
+ try {
1062
+ timersPromisesModule = __vitest_required__.timersPromises;
1063
+ } catch (e) {
1064
+ }
1065
+ }
1066
+ function withGlobal(_global) {
1067
+ const maxTimeout = Math.pow(2, 31) - 1;
1068
+ const idCounterStart = 1e12;
1069
+ const NOOP = function() {
1070
+ return void 0;
1071
+ };
1072
+ const NOOP_ARRAY = function() {
1073
+ return [];
1074
+ };
1075
+ const isPresent = {};
1076
+ let timeoutResult, addTimerReturnsObject = false;
1077
+ if (_global.setTimeout) {
1078
+ isPresent.setTimeout = true;
1079
+ timeoutResult = _global.setTimeout(NOOP, 0);
1080
+ addTimerReturnsObject = typeof timeoutResult === "object";
1081
+ }
1082
+ isPresent.clearTimeout = Boolean(_global.clearTimeout);
1083
+ isPresent.setInterval = Boolean(_global.setInterval);
1084
+ isPresent.clearInterval = Boolean(_global.clearInterval);
1085
+ isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
1086
+ isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
1087
+ isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
1088
+ const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
1089
+ isPresent.performance = _global.performance && typeof _global.performance.now === "function";
1090
+ const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
1091
+ const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
1092
+ isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
1093
+ isPresent.requestAnimationFrame = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
1094
+ isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
1095
+ isPresent.requestIdleCallback = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
1096
+ isPresent.cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
1097
+ isPresent.setImmediate = _global.setImmediate && typeof _global.setImmediate === "function";
1098
+ isPresent.clearImmediate = _global.clearImmediate && typeof _global.clearImmediate === "function";
1099
+ isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
1100
+ if (_global.clearTimeout) {
1101
+ _global.clearTimeout(timeoutResult);
1102
+ }
1103
+ const NativeDate = _global.Date;
1104
+ const NativeIntl = isPresent.Intl ? Object.defineProperties(
1105
+ /* @__PURE__ */ Object.create(null),
1106
+ Object.getOwnPropertyDescriptors(_global.Intl)
1107
+ ) : void 0;
1108
+ let uniqueTimerId = idCounterStart;
1109
+ if (NativeDate === void 0) {
1110
+ throw new Error(
1111
+ "The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
1112
+ );
1113
+ }
1114
+ isPresent.Date = true;
1115
+ class FakePerformanceEntry {
1116
+ constructor(name, entryType, startTime, duration) {
1117
+ this.name = name;
1118
+ this.entryType = entryType;
1119
+ this.startTime = startTime;
1120
+ this.duration = duration;
1121
+ }
1122
+ toJSON() {
1123
+ return JSON.stringify({ ...this });
1124
+ }
1125
+ }
1126
+ function isNumberFinite(num) {
1127
+ if (Number.isFinite) {
1128
+ return Number.isFinite(num);
1129
+ }
1130
+ return isFinite(num);
1131
+ }
1132
+ let isNearInfiniteLimit = false;
1133
+ function checkIsNearInfiniteLimit(clock, i) {
1134
+ if (clock.loopLimit && i === clock.loopLimit - 1) {
1135
+ isNearInfiniteLimit = true;
1136
+ }
1137
+ }
1138
+ function resetIsNearInfiniteLimit() {
1139
+ isNearInfiniteLimit = false;
1140
+ }
1141
+ function parseTime(str) {
1142
+ if (!str) {
1143
+ return 0;
1144
+ }
1145
+ const strings = str.split(":");
1146
+ const l = strings.length;
1147
+ let i = l;
1148
+ let ms = 0;
1149
+ let parsed;
1150
+ if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
1151
+ throw new Error(
1152
+ "tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits"
1153
+ );
1154
+ }
1155
+ while (i--) {
1156
+ parsed = parseInt(strings[i], 10);
1157
+ if (parsed >= 60) {
1158
+ throw new Error(`Invalid time ${str}`);
1159
+ }
1160
+ ms += parsed * Math.pow(60, l - i - 1);
1161
+ }
1162
+ return ms * 1e3;
1163
+ }
1164
+ function nanoRemainder(msFloat) {
1165
+ const modulo = 1e6;
1166
+ const remainder = msFloat * 1e6 % modulo;
1167
+ const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
1168
+ return Math.floor(positiveRemainder);
1169
+ }
1170
+ function getEpoch(epoch) {
1171
+ if (!epoch) {
1172
+ return 0;
1173
+ }
1174
+ if (typeof epoch.getTime === "function") {
1175
+ return epoch.getTime();
1176
+ }
1177
+ if (typeof epoch === "number") {
1178
+ return epoch;
1179
+ }
1180
+ throw new TypeError("now should be milliseconds since UNIX epoch");
1181
+ }
1182
+ function inRange(from, to, timer) {
1183
+ return timer && timer.callAt >= from && timer.callAt <= to;
1184
+ }
1185
+ function getInfiniteLoopError(clock, job) {
1186
+ const infiniteLoopError = new Error(
1187
+ `Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`
1188
+ );
1189
+ if (!job.error) {
1190
+ return infiniteLoopError;
1191
+ }
1192
+ const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
1193
+ let clockMethodPattern = new RegExp(
1194
+ String(Object.keys(clock).join("|"))
1195
+ );
1196
+ if (addTimerReturnsObject) {
1197
+ clockMethodPattern = new RegExp(
1198
+ `\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`
1199
+ );
1200
+ }
1201
+ let matchedLineIndex = -1;
1202
+ job.error.stack.split("\n").some(function(line, i) {
1203
+ const matchedComputedTarget = line.match(computedTargetPattern);
1204
+ if (matchedComputedTarget) {
1205
+ matchedLineIndex = i;
1206
+ return true;
1207
+ }
1208
+ const matchedClockMethod = line.match(clockMethodPattern);
1209
+ if (matchedClockMethod) {
1210
+ matchedLineIndex = i;
1211
+ return false;
1212
+ }
1213
+ return matchedLineIndex >= 0;
1214
+ });
1215
+ const stack = `${infiniteLoopError}
1216
+ ${job.type || "Microtask"} - ${job.func.name || "anonymous"}
1217
+ ${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
1218
+ try {
1219
+ Object.defineProperty(infiniteLoopError, "stack", {
1220
+ value: stack
1221
+ });
1222
+ } catch (e) {
1223
+ }
1224
+ return infiniteLoopError;
1225
+ }
1226
+ function createDate() {
1227
+ class ClockDate extends NativeDate {
1228
+ /**
1229
+ * @param {number} year
1230
+ * @param {number} month
1231
+ * @param {number} date
1232
+ * @param {number} hour
1233
+ * @param {number} minute
1234
+ * @param {number} second
1235
+ * @param {number} ms
1236
+ * @returns void
1237
+ */
1238
+ // eslint-disable-next-line no-unused-vars
1239
+ constructor(year, month, date, hour, minute, second, ms) {
1240
+ if (arguments.length === 0) {
1241
+ super(ClockDate.clock.now);
1242
+ } else {
1243
+ super(...arguments);
1244
+ }
1245
+ Object.defineProperty(this, "constructor", {
1246
+ value: NativeDate,
1247
+ enumerable: false
1248
+ });
1249
+ }
1250
+ static [Symbol.hasInstance](instance) {
1251
+ return instance instanceof NativeDate;
1252
+ }
1253
+ }
1254
+ ClockDate.isFake = true;
1255
+ if (NativeDate.now) {
1256
+ ClockDate.now = function now2() {
1257
+ return ClockDate.clock.now;
1258
+ };
1259
+ }
1260
+ if (NativeDate.toSource) {
1261
+ ClockDate.toSource = function toSource() {
1262
+ return NativeDate.toSource();
1263
+ };
1264
+ }
1265
+ ClockDate.toString = function toString() {
1266
+ return NativeDate.toString();
1267
+ };
1268
+ const ClockDateProxy = new Proxy(ClockDate, {
1269
+ // handler for [[Call]] invocations (i.e. not using `new`)
1270
+ apply() {
1271
+ if (this instanceof ClockDate) {
1272
+ throw new TypeError(
1273
+ "A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic."
1274
+ );
1275
+ }
1276
+ return new NativeDate(ClockDate.clock.now).toString();
1277
+ }
1278
+ });
1279
+ return ClockDateProxy;
1280
+ }
1281
+ function createIntl() {
1282
+ const ClockIntl = {};
1283
+ Object.getOwnPropertyNames(NativeIntl).forEach(
1284
+ (property) => ClockIntl[property] = NativeIntl[property]
1285
+ );
1286
+ ClockIntl.DateTimeFormat = function(...args) {
1287
+ const realFormatter = new NativeIntl.DateTimeFormat(...args);
1288
+ const formatter = {};
1289
+ ["formatRange", "formatRangeToParts", "resolvedOptions"].forEach(
1290
+ (method) => {
1291
+ formatter[method] = realFormatter[method].bind(realFormatter);
1292
+ }
1293
+ );
1294
+ ["format", "formatToParts"].forEach((method) => {
1295
+ formatter[method] = function(date) {
1296
+ return realFormatter[method](date || ClockIntl.clock.now);
1297
+ };
1298
+ });
1299
+ return formatter;
1300
+ };
1301
+ ClockIntl.DateTimeFormat.prototype = Object.create(
1302
+ NativeIntl.DateTimeFormat.prototype
1303
+ );
1304
+ ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
1305
+ return ClockIntl;
1306
+ }
1307
+ function enqueueJob(clock, job) {
1308
+ if (!clock.jobs) {
1309
+ clock.jobs = [];
1310
+ }
1311
+ clock.jobs.push(job);
1312
+ }
1313
+ function runJobs(clock) {
1314
+ if (!clock.jobs) {
1315
+ return;
1316
+ }
1317
+ for (let i = 0; i < clock.jobs.length; i++) {
1318
+ const job = clock.jobs[i];
1319
+ job.func.apply(null, job.args);
1320
+ checkIsNearInfiniteLimit(clock, i);
1321
+ if (clock.loopLimit && i > clock.loopLimit) {
1322
+ throw getInfiniteLoopError(clock, job);
1323
+ }
1324
+ }
1325
+ resetIsNearInfiniteLimit();
1326
+ clock.jobs = [];
1327
+ }
1328
+ function addTimer(clock, timer) {
1329
+ if (timer.func === void 0) {
1330
+ throw new Error("Callback must be provided to timer calls");
1331
+ }
1332
+ if (addTimerReturnsObject) {
1333
+ if (typeof timer.func !== "function") {
1334
+ throw new TypeError(
1335
+ `[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`
1336
+ );
1337
+ }
1338
+ }
1339
+ if (isNearInfiniteLimit) {
1340
+ timer.error = new Error();
1341
+ }
1342
+ timer.type = timer.immediate ? "Immediate" : "Timeout";
1343
+ if (timer.hasOwnProperty("delay")) {
1344
+ if (typeof timer.delay !== "number") {
1345
+ timer.delay = parseInt(timer.delay, 10);
1346
+ }
1347
+ if (!isNumberFinite(timer.delay)) {
1348
+ timer.delay = 0;
1349
+ }
1350
+ timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
1351
+ timer.delay = Math.max(0, timer.delay);
1352
+ }
1353
+ if (timer.hasOwnProperty("interval")) {
1354
+ timer.type = "Interval";
1355
+ timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
1356
+ }
1357
+ if (timer.hasOwnProperty("animation")) {
1358
+ timer.type = "AnimationFrame";
1359
+ timer.animation = true;
1360
+ }
1361
+ if (timer.hasOwnProperty("idleCallback")) {
1362
+ timer.type = "IdleCallback";
1363
+ timer.idleCallback = true;
1364
+ }
1365
+ if (!clock.timers) {
1366
+ clock.timers = {};
1367
+ }
1368
+ timer.id = uniqueTimerId++;
1369
+ timer.createdAt = clock.now;
1370
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
1371
+ clock.timers[timer.id] = timer;
1372
+ if (addTimerReturnsObject) {
1373
+ const res = {
1374
+ refed: true,
1375
+ ref: function() {
1376
+ this.refed = true;
1377
+ return res;
1378
+ },
1379
+ unref: function() {
1380
+ this.refed = false;
1381
+ return res;
1382
+ },
1383
+ hasRef: function() {
1384
+ return this.refed;
1385
+ },
1386
+ refresh: function() {
1387
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
1388
+ clock.timers[timer.id] = timer;
1389
+ return res;
1390
+ },
1391
+ [Symbol.toPrimitive]: function() {
1392
+ return timer.id;
1393
+ }
1394
+ };
1395
+ return res;
1396
+ }
1397
+ return timer.id;
1398
+ }
1399
+ function compareTimers(a, b) {
1400
+ if (a.callAt < b.callAt) {
1401
+ return -1;
1402
+ }
1403
+ if (a.callAt > b.callAt) {
1404
+ return 1;
1405
+ }
1406
+ if (a.immediate && !b.immediate) {
1407
+ return -1;
1408
+ }
1409
+ if (!a.immediate && b.immediate) {
1410
+ return 1;
1411
+ }
1412
+ if (a.createdAt < b.createdAt) {
1413
+ return -1;
1414
+ }
1415
+ if (a.createdAt > b.createdAt) {
1416
+ return 1;
1417
+ }
1418
+ if (a.id < b.id) {
1419
+ return -1;
1420
+ }
1421
+ if (a.id > b.id) {
1422
+ return 1;
1423
+ }
1424
+ }
1425
+ function firstTimerInRange(clock, from, to) {
1426
+ const timers2 = clock.timers;
1427
+ let timer = null;
1428
+ let id, isInRange;
1429
+ for (id in timers2) {
1430
+ if (timers2.hasOwnProperty(id)) {
1431
+ isInRange = inRange(from, to, timers2[id]);
1432
+ if (isInRange && (!timer || compareTimers(timer, timers2[id]) === 1)) {
1433
+ timer = timers2[id];
1434
+ }
1435
+ }
1436
+ }
1437
+ return timer;
1438
+ }
1439
+ function firstTimer(clock) {
1440
+ const timers2 = clock.timers;
1441
+ let timer = null;
1442
+ let id;
1443
+ for (id in timers2) {
1444
+ if (timers2.hasOwnProperty(id)) {
1445
+ if (!timer || compareTimers(timer, timers2[id]) === 1) {
1446
+ timer = timers2[id];
1447
+ }
1448
+ }
1449
+ }
1450
+ return timer;
1451
+ }
1452
+ function lastTimer(clock) {
1453
+ const timers2 = clock.timers;
1454
+ let timer = null;
1455
+ let id;
1456
+ for (id in timers2) {
1457
+ if (timers2.hasOwnProperty(id)) {
1458
+ if (!timer || compareTimers(timer, timers2[id]) === -1) {
1459
+ timer = timers2[id];
1460
+ }
1461
+ }
1462
+ }
1463
+ return timer;
1464
+ }
1465
+ function callTimer(clock, timer) {
1466
+ if (typeof timer.interval === "number") {
1467
+ clock.timers[timer.id].callAt += timer.interval;
1468
+ } else {
1469
+ delete clock.timers[timer.id];
1470
+ }
1471
+ if (typeof timer.func === "function") {
1472
+ timer.func.apply(null, timer.args);
1473
+ } else {
1474
+ const eval2 = eval;
1475
+ (function() {
1476
+ eval2(timer.func);
1477
+ })();
1478
+ }
1479
+ }
1480
+ function getClearHandler(ttype) {
1481
+ if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
1482
+ return `cancel${ttype}`;
1483
+ }
1484
+ return `clear${ttype}`;
1485
+ }
1486
+ function getScheduleHandler(ttype) {
1487
+ if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
1488
+ return `request${ttype}`;
1489
+ }
1490
+ return `set${ttype}`;
1491
+ }
1492
+ function createWarnOnce() {
1493
+ let calls = 0;
1494
+ return function(msg) {
1495
+ !calls++ && console.warn(msg);
1496
+ };
1497
+ }
1498
+ const warnOnce = createWarnOnce();
1499
+ function clearTimer(clock, timerId, ttype) {
1500
+ if (!timerId) {
1501
+ return;
1502
+ }
1503
+ if (!clock.timers) {
1504
+ clock.timers = {};
1505
+ }
1506
+ const id = Number(timerId);
1507
+ if (Number.isNaN(id) || id < idCounterStart) {
1508
+ const handlerName = getClearHandler(ttype);
1509
+ if (clock.shouldClearNativeTimers === true) {
1510
+ const nativeHandler = clock[`_${handlerName}`];
1511
+ return typeof nativeHandler === "function" ? nativeHandler(timerId) : void 0;
1512
+ }
1513
+ warnOnce(
1514
+ `FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.
1515
+ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1516
+ );
1517
+ }
1518
+ if (clock.timers.hasOwnProperty(id)) {
1519
+ const timer = clock.timers[id];
1520
+ if (timer.type === ttype || timer.type === "Timeout" && ttype === "Interval" || timer.type === "Interval" && ttype === "Timeout") {
1521
+ delete clock.timers[id];
1522
+ } else {
1523
+ const clear = getClearHandler(ttype);
1524
+ const schedule = getScheduleHandler(timer.type);
1525
+ throw new Error(
1526
+ `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`
1527
+ );
1528
+ }
1529
+ }
1530
+ }
1531
+ function uninstall(clock, config) {
1532
+ let method, i, l;
1533
+ const installedHrTime = "_hrtime";
1534
+ const installedNextTick = "_nextTick";
1535
+ for (i = 0, l = clock.methods.length; i < l; i++) {
1536
+ method = clock.methods[i];
1537
+ if (method === "hrtime" && _global.process) {
1538
+ _global.process.hrtime = clock[installedHrTime];
1539
+ } else if (method === "nextTick" && _global.process) {
1540
+ _global.process.nextTick = clock[installedNextTick];
1541
+ } else if (method === "performance") {
1542
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
1543
+ clock,
1544
+ `_${method}`
1545
+ );
1546
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
1547
+ Object.defineProperty(
1548
+ _global,
1549
+ method,
1550
+ originalPerfDescriptor
1551
+ );
1552
+ } else if (originalPerfDescriptor.configurable) {
1553
+ _global[method] = clock[`_${method}`];
1554
+ }
1555
+ } else {
1556
+ if (_global[method] && _global[method].hadOwnProperty) {
1557
+ _global[method] = clock[`_${method}`];
1558
+ } else {
1559
+ try {
1560
+ delete _global[method];
1561
+ } catch (ignore) {
1562
+ }
1563
+ }
1564
+ }
1565
+ if (clock.timersModuleMethods !== void 0) {
1566
+ for (let j = 0; j < clock.timersModuleMethods.length; j++) {
1567
+ const entry = clock.timersModuleMethods[j];
1568
+ timersModule[entry.methodName] = entry.original;
1569
+ }
1570
+ }
1571
+ if (clock.timersPromisesModuleMethods !== void 0) {
1572
+ for (let j = 0; j < clock.timersPromisesModuleMethods.length; j++) {
1573
+ const entry = clock.timersPromisesModuleMethods[j];
1574
+ timersPromisesModule[entry.methodName] = entry.original;
1575
+ }
1576
+ }
1577
+ }
1578
+ if (config.shouldAdvanceTime === true) {
1579
+ _global.clearInterval(clock.attachedInterval);
1580
+ }
1581
+ clock.methods = [];
1582
+ for (const [listener, signal] of clock.abortListenerMap.entries()) {
1583
+ signal.removeEventListener("abort", listener);
1584
+ clock.abortListenerMap.delete(listener);
1585
+ }
1586
+ if (!clock.timers) {
1587
+ return [];
1588
+ }
1589
+ return Object.keys(clock.timers).map(function mapper(key) {
1590
+ return clock.timers[key];
1591
+ });
1592
+ }
1593
+ function hijackMethod(target, method, clock) {
1594
+ clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(
1595
+ target,
1596
+ method
1597
+ );
1598
+ clock[`_${method}`] = target[method];
1599
+ if (method === "Date") {
1600
+ target[method] = clock[method];
1601
+ } else if (method === "Intl") {
1602
+ target[method] = clock[method];
1603
+ } else if (method === "performance") {
1604
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
1605
+ target,
1606
+ method
1607
+ );
1608
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
1609
+ Object.defineProperty(
1610
+ clock,
1611
+ `_${method}`,
1612
+ originalPerfDescriptor
1613
+ );
1614
+ const perfDescriptor = Object.getOwnPropertyDescriptor(
1615
+ clock,
1616
+ method
1617
+ );
1618
+ Object.defineProperty(target, method, perfDescriptor);
1619
+ } else {
1620
+ target[method] = clock[method];
1621
+ }
1622
+ } else {
1623
+ target[method] = function() {
1624
+ return clock[method].apply(clock, arguments);
1625
+ };
1626
+ Object.defineProperties(
1627
+ target[method],
1628
+ Object.getOwnPropertyDescriptors(clock[method])
1629
+ );
1630
+ }
1631
+ target[method].clock = clock;
1632
+ }
1633
+ function doIntervalTick(clock, advanceTimeDelta) {
1634
+ clock.tick(advanceTimeDelta);
1635
+ }
1636
+ const timers = {
1637
+ setTimeout: _global.setTimeout,
1638
+ clearTimeout: _global.clearTimeout,
1639
+ setInterval: _global.setInterval,
1640
+ clearInterval: _global.clearInterval,
1641
+ Date: _global.Date
1642
+ };
1643
+ if (isPresent.setImmediate) {
1644
+ timers.setImmediate = _global.setImmediate;
1645
+ }
1646
+ if (isPresent.clearImmediate) {
1647
+ timers.clearImmediate = _global.clearImmediate;
1648
+ }
1649
+ if (isPresent.hrtime) {
1650
+ timers.hrtime = _global.process.hrtime;
1651
+ }
1652
+ if (isPresent.nextTick) {
1653
+ timers.nextTick = _global.process.nextTick;
1654
+ }
1655
+ if (isPresent.performance) {
1656
+ timers.performance = _global.performance;
1657
+ }
1658
+ if (isPresent.requestAnimationFrame) {
1659
+ timers.requestAnimationFrame = _global.requestAnimationFrame;
1660
+ }
1661
+ if (isPresent.queueMicrotask) {
1662
+ timers.queueMicrotask = _global.queueMicrotask;
1663
+ }
1664
+ if (isPresent.cancelAnimationFrame) {
1665
+ timers.cancelAnimationFrame = _global.cancelAnimationFrame;
1666
+ }
1667
+ if (isPresent.requestIdleCallback) {
1668
+ timers.requestIdleCallback = _global.requestIdleCallback;
1669
+ }
1670
+ if (isPresent.cancelIdleCallback) {
1671
+ timers.cancelIdleCallback = _global.cancelIdleCallback;
1672
+ }
1673
+ if (isPresent.Intl) {
1674
+ timers.Intl = NativeIntl;
1675
+ }
1676
+ const originalSetTimeout = _global.setImmediate || _global.setTimeout;
1677
+ function createClock(start, loopLimit) {
1678
+ start = Math.floor(getEpoch(start));
1679
+ loopLimit = loopLimit || 1e3;
1680
+ let nanos = 0;
1681
+ const adjustedSystemTime = [0, 0];
1682
+ const clock = {
1683
+ now: start,
1684
+ Date: createDate(),
1685
+ loopLimit
1686
+ };
1687
+ clock.Date.clock = clock;
1688
+ function getTimeToNextFrame() {
1689
+ return 16 - (clock.now - start) % 16;
1690
+ }
1691
+ function hrtime(prev) {
1692
+ const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
1693
+ const secsSinceStart = Math.floor(millisSinceStart / 1e3);
1694
+ const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];
1695
+ if (Array.isArray(prev)) {
1696
+ if (prev[1] > 1e9) {
1697
+ throw new TypeError(
1698
+ "Number of nanoseconds can't exceed a billion"
1699
+ );
1700
+ }
1701
+ const oldSecs = prev[0];
1702
+ let nanoDiff = remainderInNanos - prev[1];
1703
+ let secDiff = secsSinceStart - oldSecs;
1704
+ if (nanoDiff < 0) {
1705
+ nanoDiff += 1e9;
1706
+ secDiff -= 1;
1707
+ }
1708
+ return [secDiff, nanoDiff];
1709
+ }
1710
+ return [secsSinceStart, remainderInNanos];
1711
+ }
1712
+ function fakePerformanceNow() {
1713
+ const hrt = hrtime();
1714
+ const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
1715
+ return millis;
1716
+ }
1717
+ if (isPresent.hrtimeBigint) {
1718
+ hrtime.bigint = function() {
1719
+ const parts = hrtime();
1720
+ return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
1721
+ };
1722
+ }
1723
+ if (isPresent.Intl) {
1724
+ clock.Intl = createIntl();
1725
+ clock.Intl.clock = clock;
1726
+ }
1727
+ clock.requestIdleCallback = function requestIdleCallback(func, timeout) {
1728
+ let timeToNextIdlePeriod = 0;
1729
+ if (clock.countTimers() > 0) {
1730
+ timeToNextIdlePeriod = 50;
1731
+ }
1732
+ const result = addTimer(clock, {
1733
+ func,
1734
+ args: Array.prototype.slice.call(arguments, 2),
1735
+ delay: typeof timeout === "undefined" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),
1736
+ idleCallback: true
1737
+ });
1738
+ return Number(result);
1739
+ };
1740
+ clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
1741
+ return clearTimer(clock, timerId, "IdleCallback");
1742
+ };
1743
+ clock.setTimeout = function setTimeout(func, timeout) {
1744
+ return addTimer(clock, {
1745
+ func,
1746
+ args: Array.prototype.slice.call(arguments, 2),
1747
+ delay: timeout
1748
+ });
1749
+ };
1750
+ if (typeof _global.Promise !== "undefined" && utilPromisify) {
1751
+ clock.setTimeout[utilPromisify.custom] = function promisifiedSetTimeout(timeout, arg) {
1752
+ return new _global.Promise(function setTimeoutExecutor(resolve) {
1753
+ addTimer(clock, {
1754
+ func: resolve,
1755
+ args: [arg],
1756
+ delay: timeout
1757
+ });
1758
+ });
1759
+ };
1760
+ }
1761
+ clock.clearTimeout = function clearTimeout(timerId) {
1762
+ return clearTimer(clock, timerId, "Timeout");
1763
+ };
1764
+ clock.nextTick = function nextTick(func) {
1765
+ return enqueueJob(clock, {
1766
+ func,
1767
+ args: Array.prototype.slice.call(arguments, 1),
1768
+ error: isNearInfiniteLimit ? new Error() : null
1769
+ });
1770
+ };
1771
+ clock.queueMicrotask = function queueMicrotask(func) {
1772
+ return clock.nextTick(func);
1773
+ };
1774
+ clock.setInterval = function setInterval(func, timeout) {
1775
+ timeout = parseInt(timeout, 10);
1776
+ return addTimer(clock, {
1777
+ func,
1778
+ args: Array.prototype.slice.call(arguments, 2),
1779
+ delay: timeout,
1780
+ interval: timeout
1781
+ });
1782
+ };
1783
+ clock.clearInterval = function clearInterval(timerId) {
1784
+ return clearTimer(clock, timerId, "Interval");
1785
+ };
1786
+ if (isPresent.setImmediate) {
1787
+ clock.setImmediate = function setImmediate(func) {
1788
+ return addTimer(clock, {
1789
+ func,
1790
+ args: Array.prototype.slice.call(arguments, 1),
1791
+ immediate: true
1792
+ });
1793
+ };
1794
+ if (typeof _global.Promise !== "undefined" && utilPromisify) {
1795
+ clock.setImmediate[utilPromisify.custom] = function promisifiedSetImmediate(arg) {
1796
+ return new _global.Promise(
1797
+ function setImmediateExecutor(resolve) {
1798
+ addTimer(clock, {
1799
+ func: resolve,
1800
+ args: [arg],
1801
+ immediate: true
1802
+ });
1803
+ }
1804
+ );
1805
+ };
1806
+ }
1807
+ clock.clearImmediate = function clearImmediate(timerId) {
1808
+ return clearTimer(clock, timerId, "Immediate");
1809
+ };
1810
+ }
1811
+ clock.countTimers = function countTimers() {
1812
+ return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;
1813
+ };
1814
+ clock.requestAnimationFrame = function requestAnimationFrame(func) {
1815
+ const result = addTimer(clock, {
1816
+ func,
1817
+ delay: getTimeToNextFrame(),
1818
+ get args() {
1819
+ return [fakePerformanceNow()];
1820
+ },
1821
+ animation: true
1822
+ });
1823
+ return Number(result);
1824
+ };
1825
+ clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {
1826
+ return clearTimer(clock, timerId, "AnimationFrame");
1827
+ };
1828
+ clock.runMicrotasks = function runMicrotasks() {
1829
+ runJobs(clock);
1830
+ };
1831
+ function doTick(tickValue, isAsync, resolve, reject) {
1832
+ const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
1833
+ const ms = Math.floor(msFloat);
1834
+ const remainder = nanoRemainder(msFloat);
1835
+ let nanosTotal = nanos + remainder;
1836
+ let tickTo = clock.now + ms;
1837
+ if (msFloat < 0) {
1838
+ throw new TypeError("Negative ticks are not supported");
1839
+ }
1840
+ if (nanosTotal >= 1e6) {
1841
+ tickTo += 1;
1842
+ nanosTotal -= 1e6;
1843
+ }
1844
+ nanos = nanosTotal;
1845
+ let tickFrom = clock.now;
1846
+ let previous = clock.now;
1847
+ let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
1848
+ clock.duringTick = true;
1849
+ oldNow = clock.now;
1850
+ runJobs(clock);
1851
+ if (oldNow !== clock.now) {
1852
+ tickFrom += clock.now - oldNow;
1853
+ tickTo += clock.now - oldNow;
1854
+ }
1855
+ function doTickInner() {
1856
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
1857
+ while (timer && tickFrom <= tickTo) {
1858
+ if (clock.timers[timer.id]) {
1859
+ tickFrom = timer.callAt;
1860
+ clock.now = timer.callAt;
1861
+ oldNow = clock.now;
1862
+ try {
1863
+ runJobs(clock);
1864
+ callTimer(clock, timer);
1865
+ } catch (e) {
1866
+ firstException = firstException || e;
1867
+ }
1868
+ if (isAsync) {
1869
+ originalSetTimeout(nextPromiseTick);
1870
+ return;
1871
+ }
1872
+ compensationCheck();
1873
+ }
1874
+ postTimerCall();
1875
+ }
1876
+ oldNow = clock.now;
1877
+ runJobs(clock);
1878
+ if (oldNow !== clock.now) {
1879
+ tickFrom += clock.now - oldNow;
1880
+ tickTo += clock.now - oldNow;
1881
+ }
1882
+ clock.duringTick = false;
1883
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
1884
+ if (timer) {
1885
+ try {
1886
+ clock.tick(tickTo - clock.now);
1887
+ } catch (e) {
1888
+ firstException = firstException || e;
1889
+ }
1890
+ } else {
1891
+ clock.now = tickTo;
1892
+ nanos = nanosTotal;
1893
+ }
1894
+ if (firstException) {
1895
+ throw firstException;
1896
+ }
1897
+ if (isAsync) {
1898
+ resolve(clock.now);
1899
+ } else {
1900
+ return clock.now;
1901
+ }
1902
+ }
1903
+ nextPromiseTick = isAsync && function() {
1904
+ try {
1905
+ compensationCheck();
1906
+ postTimerCall();
1907
+ doTickInner();
1908
+ } catch (e) {
1909
+ reject(e);
1910
+ }
1911
+ };
1912
+ compensationCheck = function() {
1913
+ if (oldNow !== clock.now) {
1914
+ tickFrom += clock.now - oldNow;
1915
+ tickTo += clock.now - oldNow;
1916
+ previous += clock.now - oldNow;
1917
+ }
1918
+ };
1919
+ postTimerCall = function() {
1920
+ timer = firstTimerInRange(clock, previous, tickTo);
1921
+ previous = tickFrom;
1922
+ };
1923
+ return doTickInner();
1924
+ }
1925
+ clock.tick = function tick(tickValue) {
1926
+ return doTick(tickValue, false);
1927
+ };
1928
+ if (typeof _global.Promise !== "undefined") {
1929
+ clock.tickAsync = function tickAsync(tickValue) {
1930
+ return new _global.Promise(function(resolve, reject) {
1931
+ originalSetTimeout(function() {
1932
+ try {
1933
+ doTick(tickValue, true, resolve, reject);
1934
+ } catch (e) {
1935
+ reject(e);
1936
+ }
1937
+ });
1938
+ });
1939
+ };
1940
+ }
1941
+ clock.next = function next() {
1942
+ runJobs(clock);
1943
+ const timer = firstTimer(clock);
1944
+ if (!timer) {
1945
+ return clock.now;
1946
+ }
1947
+ clock.duringTick = true;
1948
+ try {
1949
+ clock.now = timer.callAt;
1950
+ callTimer(clock, timer);
1951
+ runJobs(clock);
1952
+ return clock.now;
1953
+ } finally {
1954
+ clock.duringTick = false;
1955
+ }
1956
+ };
1957
+ if (typeof _global.Promise !== "undefined") {
1958
+ clock.nextAsync = function nextAsync() {
1959
+ return new _global.Promise(function(resolve, reject) {
1960
+ originalSetTimeout(function() {
1961
+ try {
1962
+ const timer = firstTimer(clock);
1963
+ if (!timer) {
1964
+ resolve(clock.now);
1965
+ return;
1966
+ }
1967
+ let err;
1968
+ clock.duringTick = true;
1969
+ clock.now = timer.callAt;
1970
+ try {
1971
+ callTimer(clock, timer);
1972
+ } catch (e) {
1973
+ err = e;
1974
+ }
1975
+ clock.duringTick = false;
1976
+ originalSetTimeout(function() {
1977
+ if (err) {
1978
+ reject(err);
1979
+ } else {
1980
+ resolve(clock.now);
1981
+ }
1982
+ });
1983
+ } catch (e) {
1984
+ reject(e);
1985
+ }
1986
+ });
1987
+ });
1988
+ };
1989
+ }
1990
+ clock.runAll = function runAll() {
1991
+ let numTimers, i;
1992
+ runJobs(clock);
1993
+ for (i = 0; i < clock.loopLimit; i++) {
1994
+ if (!clock.timers) {
1995
+ resetIsNearInfiniteLimit();
1996
+ return clock.now;
1997
+ }
1998
+ numTimers = Object.keys(clock.timers).length;
1999
+ if (numTimers === 0) {
2000
+ resetIsNearInfiniteLimit();
2001
+ return clock.now;
2002
+ }
2003
+ clock.next();
2004
+ checkIsNearInfiniteLimit(clock, i);
2005
+ }
2006
+ const excessJob = firstTimer(clock);
2007
+ throw getInfiniteLoopError(clock, excessJob);
2008
+ };
2009
+ clock.runToFrame = function runToFrame() {
2010
+ return clock.tick(getTimeToNextFrame());
2011
+ };
2012
+ if (typeof _global.Promise !== "undefined") {
2013
+ clock.runAllAsync = function runAllAsync() {
2014
+ return new _global.Promise(function(resolve, reject) {
2015
+ let i = 0;
2016
+ function doRun() {
2017
+ originalSetTimeout(function() {
2018
+ try {
2019
+ runJobs(clock);
2020
+ let numTimers;
2021
+ if (i < clock.loopLimit) {
2022
+ if (!clock.timers) {
2023
+ resetIsNearInfiniteLimit();
2024
+ resolve(clock.now);
2025
+ return;
2026
+ }
2027
+ numTimers = Object.keys(
2028
+ clock.timers
2029
+ ).length;
2030
+ if (numTimers === 0) {
2031
+ resetIsNearInfiniteLimit();
2032
+ resolve(clock.now);
2033
+ return;
2034
+ }
2035
+ clock.next();
2036
+ i++;
2037
+ doRun();
2038
+ checkIsNearInfiniteLimit(clock, i);
2039
+ return;
2040
+ }
2041
+ const excessJob = firstTimer(clock);
2042
+ reject(getInfiniteLoopError(clock, excessJob));
2043
+ } catch (e) {
2044
+ reject(e);
2045
+ }
2046
+ });
2047
+ }
2048
+ doRun();
2049
+ });
2050
+ };
2051
+ }
2052
+ clock.runToLast = function runToLast() {
2053
+ const timer = lastTimer(clock);
2054
+ if (!timer) {
2055
+ runJobs(clock);
2056
+ return clock.now;
2057
+ }
2058
+ return clock.tick(timer.callAt - clock.now);
2059
+ };
2060
+ if (typeof _global.Promise !== "undefined") {
2061
+ clock.runToLastAsync = function runToLastAsync() {
2062
+ return new _global.Promise(function(resolve, reject) {
2063
+ originalSetTimeout(function() {
2064
+ try {
2065
+ const timer = lastTimer(clock);
2066
+ if (!timer) {
2067
+ runJobs(clock);
2068
+ resolve(clock.now);
2069
+ }
2070
+ resolve(clock.tickAsync(timer.callAt - clock.now));
2071
+ } catch (e) {
2072
+ reject(e);
2073
+ }
2074
+ });
2075
+ });
2076
+ };
2077
+ }
2078
+ clock.reset = function reset() {
2079
+ nanos = 0;
2080
+ clock.timers = {};
2081
+ clock.jobs = [];
2082
+ clock.now = start;
2083
+ };
2084
+ clock.setSystemTime = function setSystemTime(systemTime) {
2085
+ const newNow = getEpoch(systemTime);
2086
+ const difference = newNow - clock.now;
2087
+ let id, timer;
2088
+ adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
2089
+ adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
2090
+ clock.now = newNow;
2091
+ nanos = 0;
2092
+ for (id in clock.timers) {
2093
+ if (clock.timers.hasOwnProperty(id)) {
2094
+ timer = clock.timers[id];
2095
+ timer.createdAt += difference;
2096
+ timer.callAt += difference;
2097
+ }
2098
+ }
2099
+ };
2100
+ clock.jump = function jump(tickValue) {
2101
+ const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
2102
+ const ms = Math.floor(msFloat);
2103
+ for (const timer of Object.values(clock.timers)) {
2104
+ if (clock.now + ms > timer.callAt) {
2105
+ timer.callAt = clock.now + ms;
2106
+ }
2107
+ }
2108
+ clock.tick(ms);
2109
+ };
2110
+ if (isPresent.performance) {
2111
+ clock.performance = /* @__PURE__ */ Object.create(null);
2112
+ clock.performance.now = fakePerformanceNow;
2113
+ }
2114
+ if (isPresent.hrtime) {
2115
+ clock.hrtime = hrtime;
2116
+ }
2117
+ return clock;
2118
+ }
2119
+ function install(config) {
2120
+ if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === "number") {
2121
+ throw new TypeError(
2122
+ `FakeTimers.install called with ${String(
2123
+ config
2124
+ )} install requires an object parameter`
2125
+ );
2126
+ }
2127
+ if (_global.Date.isFake === true) {
2128
+ throw new TypeError(
2129
+ "Can't install fake timers twice on the same global object."
2130
+ );
2131
+ }
2132
+ config = typeof config !== "undefined" ? config : {};
2133
+ config.shouldAdvanceTime = config.shouldAdvanceTime || false;
2134
+ config.advanceTimeDelta = config.advanceTimeDelta || 20;
2135
+ config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
2136
+ if (config.target) {
2137
+ throw new TypeError(
2138
+ "config.target is no longer supported. Use `withGlobal(target)` instead."
2139
+ );
2140
+ }
2141
+ function handleMissingTimer(timer) {
2142
+ if (config.ignoreMissingTimers) {
2143
+ return;
2144
+ }
2145
+ throw new ReferenceError(
2146
+ `non-existent timers and/or objects cannot be faked: '${timer}'`
2147
+ );
2148
+ }
2149
+ let i, l;
2150
+ const clock = createClock(config.now, config.loopLimit);
2151
+ clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
2152
+ clock.uninstall = function() {
2153
+ return uninstall(clock, config);
2154
+ };
2155
+ clock.abortListenerMap = /* @__PURE__ */ new Map();
2156
+ clock.methods = config.toFake || [];
2157
+ if (clock.methods.length === 0) {
2158
+ clock.methods = Object.keys(timers);
2159
+ }
2160
+ if (config.shouldAdvanceTime === true) {
2161
+ const intervalTick = doIntervalTick.bind(
2162
+ null,
2163
+ clock,
2164
+ config.advanceTimeDelta
2165
+ );
2166
+ const intervalId = _global.setInterval(
2167
+ intervalTick,
2168
+ config.advanceTimeDelta
2169
+ );
2170
+ clock.attachedInterval = intervalId;
2171
+ }
2172
+ if (clock.methods.includes("performance")) {
2173
+ const proto = (() => {
2174
+ if (hasPerformanceConstructorPrototype) {
2175
+ return _global.performance.constructor.prototype;
2176
+ }
2177
+ if (hasPerformancePrototype) {
2178
+ return _global.Performance.prototype;
2179
+ }
2180
+ })();
2181
+ if (proto) {
2182
+ Object.getOwnPropertyNames(proto).forEach(function(name) {
2183
+ if (name !== "now") {
2184
+ clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
2185
+ }
2186
+ });
2187
+ clock.performance.mark = (name) => new FakePerformanceEntry(name, "mark", 0, 0);
2188
+ clock.performance.measure = (name) => new FakePerformanceEntry(name, "measure", 0, 100);
2189
+ clock.performance.timeOrigin = getEpoch(config.now);
2190
+ } else if ((config.toFake || []).includes("performance")) {
2191
+ return handleMissingTimer("performance");
2192
+ }
2193
+ }
2194
+ if (_global === globalObject && timersModule) {
2195
+ clock.timersModuleMethods = [];
2196
+ }
2197
+ if (_global === globalObject && timersPromisesModule) {
2198
+ clock.timersPromisesModuleMethods = [];
2199
+ }
2200
+ for (i = 0, l = clock.methods.length; i < l; i++) {
2201
+ const nameOfMethodToReplace = clock.methods[i];
2202
+ if (!isPresent[nameOfMethodToReplace]) {
2203
+ handleMissingTimer(nameOfMethodToReplace);
2204
+ continue;
2205
+ }
2206
+ if (nameOfMethodToReplace === "hrtime") {
2207
+ if (_global.process && typeof _global.process.hrtime === "function") {
2208
+ hijackMethod(_global.process, nameOfMethodToReplace, clock);
2209
+ }
2210
+ } else if (nameOfMethodToReplace === "nextTick") {
2211
+ if (_global.process && typeof _global.process.nextTick === "function") {
2212
+ hijackMethod(_global.process, nameOfMethodToReplace, clock);
2213
+ }
2214
+ } else {
2215
+ hijackMethod(_global, nameOfMethodToReplace, clock);
2216
+ }
2217
+ if (clock.timersModuleMethods !== void 0 && timersModule[nameOfMethodToReplace]) {
2218
+ const original = timersModule[nameOfMethodToReplace];
2219
+ clock.timersModuleMethods.push({
2220
+ methodName: nameOfMethodToReplace,
2221
+ original
2222
+ });
2223
+ timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
2224
+ }
2225
+ if (clock.timersPromisesModuleMethods !== void 0) {
2226
+ if (nameOfMethodToReplace === "setTimeout") {
2227
+ clock.timersPromisesModuleMethods.push({
2228
+ methodName: "setTimeout",
2229
+ original: timersPromisesModule.setTimeout
2230
+ });
2231
+ timersPromisesModule.setTimeout = (delay, value, options = {}) => new Promise((resolve, reject) => {
2232
+ const abort = () => {
2233
+ options.signal.removeEventListener(
2234
+ "abort",
2235
+ abort
2236
+ );
2237
+ clock.abortListenerMap.delete(abort);
2238
+ clock.clearTimeout(handle);
2239
+ reject(options.signal.reason);
2240
+ };
2241
+ const handle = clock.setTimeout(() => {
2242
+ if (options.signal) {
2243
+ options.signal.removeEventListener(
2244
+ "abort",
2245
+ abort
2246
+ );
2247
+ clock.abortListenerMap.delete(abort);
2248
+ }
2249
+ resolve(value);
2250
+ }, delay);
2251
+ if (options.signal) {
2252
+ if (options.signal.aborted) {
2253
+ abort();
2254
+ } else {
2255
+ options.signal.addEventListener(
2256
+ "abort",
2257
+ abort
2258
+ );
2259
+ clock.abortListenerMap.set(
2260
+ abort,
2261
+ options.signal
2262
+ );
2263
+ }
2264
+ }
2265
+ });
2266
+ } else if (nameOfMethodToReplace === "setImmediate") {
2267
+ clock.timersPromisesModuleMethods.push({
2268
+ methodName: "setImmediate",
2269
+ original: timersPromisesModule.setImmediate
2270
+ });
2271
+ timersPromisesModule.setImmediate = (value, options = {}) => new Promise((resolve, reject) => {
2272
+ const abort = () => {
2273
+ options.signal.removeEventListener(
2274
+ "abort",
2275
+ abort
2276
+ );
2277
+ clock.abortListenerMap.delete(abort);
2278
+ clock.clearImmediate(handle);
2279
+ reject(options.signal.reason);
2280
+ };
2281
+ const handle = clock.setImmediate(() => {
2282
+ if (options.signal) {
2283
+ options.signal.removeEventListener(
2284
+ "abort",
2285
+ abort
2286
+ );
2287
+ clock.abortListenerMap.delete(abort);
2288
+ }
2289
+ resolve(value);
2290
+ });
2291
+ if (options.signal) {
2292
+ if (options.signal.aborted) {
2293
+ abort();
2294
+ } else {
2295
+ options.signal.addEventListener(
2296
+ "abort",
2297
+ abort
2298
+ );
2299
+ clock.abortListenerMap.set(
2300
+ abort,
2301
+ options.signal
2302
+ );
2303
+ }
2304
+ }
2305
+ });
2306
+ } else if (nameOfMethodToReplace === "setInterval") {
2307
+ clock.timersPromisesModuleMethods.push({
2308
+ methodName: "setInterval",
2309
+ original: timersPromisesModule.setInterval
2310
+ });
2311
+ timersPromisesModule.setInterval = (delay, value, options = {}) => ({
2312
+ [Symbol.asyncIterator]: () => {
2313
+ const createResolvable = () => {
2314
+ let resolve, reject;
2315
+ const promise = new Promise((res, rej) => {
2316
+ resolve = res;
2317
+ reject = rej;
2318
+ });
2319
+ promise.resolve = resolve;
2320
+ promise.reject = reject;
2321
+ return promise;
2322
+ };
2323
+ let done = false;
2324
+ let hasThrown = false;
2325
+ let returnCall;
2326
+ let nextAvailable = 0;
2327
+ const nextQueue = [];
2328
+ const handle = clock.setInterval(() => {
2329
+ if (nextQueue.length > 0) {
2330
+ nextQueue.shift().resolve();
2331
+ } else {
2332
+ nextAvailable++;
2333
+ }
2334
+ }, delay);
2335
+ const abort = () => {
2336
+ options.signal.removeEventListener(
2337
+ "abort",
2338
+ abort
2339
+ );
2340
+ clock.abortListenerMap.delete(abort);
2341
+ clock.clearInterval(handle);
2342
+ done = true;
2343
+ for (const resolvable of nextQueue) {
2344
+ resolvable.resolve();
2345
+ }
2346
+ };
2347
+ if (options.signal) {
2348
+ if (options.signal.aborted) {
2349
+ done = true;
2350
+ } else {
2351
+ options.signal.addEventListener(
2352
+ "abort",
2353
+ abort
2354
+ );
2355
+ clock.abortListenerMap.set(
2356
+ abort,
2357
+ options.signal
2358
+ );
2359
+ }
2360
+ }
2361
+ return {
2362
+ next: async () => {
2363
+ if (options.signal?.aborted && !hasThrown) {
2364
+ hasThrown = true;
2365
+ throw options.signal.reason;
2366
+ }
2367
+ if (done) {
2368
+ return { done: true, value: void 0 };
2369
+ }
2370
+ if (nextAvailable > 0) {
2371
+ nextAvailable--;
2372
+ return { done: false, value };
2373
+ }
2374
+ const resolvable = createResolvable();
2375
+ nextQueue.push(resolvable);
2376
+ await resolvable;
2377
+ if (returnCall && nextQueue.length === 0) {
2378
+ returnCall.resolve();
2379
+ }
2380
+ if (options.signal?.aborted && !hasThrown) {
2381
+ hasThrown = true;
2382
+ throw options.signal.reason;
2383
+ }
2384
+ if (done) {
2385
+ return { done: true, value: void 0 };
2386
+ }
2387
+ return { done: false, value };
2388
+ },
2389
+ return: async () => {
2390
+ if (done) {
2391
+ return { done: true, value: void 0 };
2392
+ }
2393
+ if (nextQueue.length > 0) {
2394
+ returnCall = createResolvable();
2395
+ await returnCall;
2396
+ }
2397
+ clock.clearInterval(handle);
2398
+ done = true;
2399
+ if (options.signal) {
2400
+ options.signal.removeEventListener(
2401
+ "abort",
2402
+ abort
2403
+ );
2404
+ clock.abortListenerMap.delete(abort);
2405
+ }
2406
+ return { done: true, value: void 0 };
2407
+ }
2408
+ };
2409
+ }
2410
+ });
2411
+ }
2412
+ }
2413
+ }
2414
+ return clock;
2415
+ }
2416
+ return {
2417
+ timers,
2418
+ createClock,
2419
+ install,
2420
+ withGlobal
2421
+ };
2422
+ }
2423
+ const defaultImplementation = withGlobal(globalObject);
2424
+ fakeTimersSrc.timers = defaultImplementation.timers;
2425
+ fakeTimersSrc.createClock = defaultImplementation.createClock;
2426
+ fakeTimersSrc.install = defaultImplementation.install;
2427
+ fakeTimersSrc.withGlobal = withGlobal;
2428
+ return fakeTimersSrc;
2429
+ }
2430
+ var fakeTimersSrcExports = requireFakeTimersSrc();
2431
+ var FakeTimers = class {
2432
+ _global;
2433
+ _clock;
2434
+ _fakingTime;
2435
+ _fakingDate;
2436
+ _fakeTimers;
2437
+ _userConfig;
2438
+ _now = RealDate.now;
2439
+ constructor({ global: global3, config }) {
2440
+ this._userConfig = config;
2441
+ this._fakingDate = null;
2442
+ this._fakingTime = false;
2443
+ this._fakeTimers = fakeTimersSrcExports.withGlobal(global3);
2444
+ this._global = global3;
2445
+ }
2446
+ clearAllTimers() {
2447
+ if (this._fakingTime) {
2448
+ this._clock.reset();
2449
+ }
2450
+ }
2451
+ dispose() {
2452
+ this.useRealTimers();
2453
+ }
2454
+ runAllTimers() {
2455
+ if (this._checkFakeTimers()) {
2456
+ this._clock.runAll();
2457
+ }
2458
+ }
2459
+ async runAllTimersAsync() {
2460
+ if (this._checkFakeTimers()) {
2461
+ await this._clock.runAllAsync();
2462
+ }
2463
+ }
2464
+ runOnlyPendingTimers() {
2465
+ if (this._checkFakeTimers()) {
2466
+ this._clock.runToLast();
2467
+ }
2468
+ }
2469
+ async runOnlyPendingTimersAsync() {
2470
+ if (this._checkFakeTimers()) {
2471
+ await this._clock.runToLastAsync();
2472
+ }
2473
+ }
2474
+ advanceTimersToNextTimer(steps = 1) {
2475
+ if (this._checkFakeTimers()) {
2476
+ for (let i = steps; i > 0; i--) {
2477
+ this._clock.next();
2478
+ this._clock.tick(0);
2479
+ if (this._clock.countTimers() === 0) {
2480
+ break;
2481
+ }
2482
+ }
2483
+ }
2484
+ }
2485
+ async advanceTimersToNextTimerAsync(steps = 1) {
2486
+ if (this._checkFakeTimers()) {
2487
+ for (let i = steps; i > 0; i--) {
2488
+ await this._clock.nextAsync();
2489
+ this._clock.tick(0);
2490
+ if (this._clock.countTimers() === 0) {
2491
+ break;
2492
+ }
2493
+ }
2494
+ }
2495
+ }
2496
+ advanceTimersByTime(msToRun) {
2497
+ if (this._checkFakeTimers()) {
2498
+ this._clock.tick(msToRun);
2499
+ }
2500
+ }
2501
+ async advanceTimersByTimeAsync(msToRun) {
2502
+ if (this._checkFakeTimers()) {
2503
+ await this._clock.tickAsync(msToRun);
2504
+ }
2505
+ }
2506
+ advanceTimersToNextFrame() {
2507
+ if (this._checkFakeTimers()) {
2508
+ this._clock.runToFrame();
2509
+ }
2510
+ }
2511
+ runAllTicks() {
2512
+ if (this._checkFakeTimers()) {
2513
+ this._clock.runMicrotasks();
2514
+ }
2515
+ }
2516
+ useRealTimers() {
2517
+ if (this._fakingDate) {
2518
+ resetDate();
2519
+ this._fakingDate = null;
2520
+ }
2521
+ if (this._fakingTime) {
2522
+ this._clock.uninstall();
2523
+ this._fakingTime = false;
2524
+ }
2525
+ }
2526
+ useFakeTimers() {
2527
+ if (this._fakingDate) {
2528
+ throw new Error('"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.');
2529
+ }
2530
+ if (!this._fakingTime) {
2531
+ const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick" && timer !== "queueMicrotask");
2532
+ if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) {
2533
+ throw new Error("process.nextTick cannot be mocked inside child_process");
2534
+ }
2535
+ this._clock = this._fakeTimers.install({
2536
+ now: Date.now(),
2537
+ ...this._userConfig,
2538
+ toFake: this._userConfig?.toFake || toFake,
2539
+ ignoreMissingTimers: true
2540
+ });
2541
+ this._fakingTime = true;
2542
+ }
2543
+ }
2544
+ reset() {
2545
+ if (this._checkFakeTimers()) {
2546
+ const { now: now2 } = this._clock;
2547
+ this._clock.reset();
2548
+ this._clock.setSystemTime(now2);
2549
+ }
2550
+ }
2551
+ setSystemTime(now2) {
2552
+ const date = typeof now2 === "undefined" || now2 instanceof Date ? now2 : new Date(now2);
2553
+ if (this._fakingTime) {
2554
+ this._clock.setSystemTime(date);
2555
+ } else {
2556
+ this._fakingDate = date ?? new Date(this.getRealSystemTime());
2557
+ mockDate(this._fakingDate);
2558
+ }
2559
+ }
2560
+ getMockedSystemTime() {
2561
+ return this._fakingTime ? new Date(this._clock.now) : this._fakingDate;
2562
+ }
2563
+ getRealSystemTime() {
2564
+ return this._now();
2565
+ }
2566
+ getTimerCount() {
2567
+ if (this._checkFakeTimers()) {
2568
+ return this._clock.countTimers();
2569
+ }
2570
+ return 0;
2571
+ }
2572
+ configure(config) {
2573
+ this._userConfig = config;
2574
+ }
2575
+ isFakeTimers() {
2576
+ return this._fakingTime;
2577
+ }
2578
+ _checkFakeTimers() {
2579
+ if (!this._fakingTime) {
2580
+ throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
2581
+ }
2582
+ return this._fakingTime;
2583
+ }
2584
+ };
2585
+ function copyStackTrace(target, source) {
2586
+ if (source.stack !== void 0) {
2587
+ target.stack = source.stack.replace(source.message, target.message);
2588
+ }
2589
+ return target;
2590
+ }
2591
+ function waitFor(callback, options = {}) {
2592
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
2593
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2594
+ const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
2595
+ return new Promise((resolve, reject) => {
2596
+ let lastError;
2597
+ let promiseStatus = "idle";
2598
+ let timeoutId;
2599
+ let intervalId;
2600
+ const onResolve = (result) => {
2601
+ if (timeoutId) {
2602
+ clearTimeout(timeoutId);
2603
+ }
2604
+ if (intervalId) {
2605
+ clearInterval(intervalId);
2606
+ }
2607
+ resolve(result);
2608
+ };
2609
+ const handleTimeout = () => {
2610
+ if (intervalId) {
2611
+ clearInterval(intervalId);
2612
+ }
2613
+ let error = lastError;
2614
+ if (!error) {
2615
+ error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
2616
+ }
2617
+ reject(error);
2618
+ };
2619
+ const checkCallback = () => {
2620
+ if (vi.isFakeTimers()) {
2621
+ vi.advanceTimersByTime(interval);
2622
+ }
2623
+ if (promiseStatus === "pending") {
2624
+ return;
2625
+ }
2626
+ try {
2627
+ const result = callback();
2628
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
2629
+ const thenable = result;
2630
+ promiseStatus = "pending";
2631
+ thenable.then((resolvedValue) => {
2632
+ promiseStatus = "resolved";
2633
+ onResolve(resolvedValue);
2634
+ }, (rejectedValue) => {
2635
+ promiseStatus = "rejected";
2636
+ lastError = rejectedValue;
2637
+ });
2638
+ } else {
2639
+ onResolve(result);
2640
+ return true;
2641
+ }
2642
+ } catch (error) {
2643
+ lastError = error;
2644
+ }
2645
+ };
2646
+ if (checkCallback() === true) {
2647
+ return;
2648
+ }
2649
+ timeoutId = setTimeout(handleTimeout, timeout);
2650
+ intervalId = setInterval(checkCallback, interval);
2651
+ });
2652
+ }
2653
+ function waitUntil(callback, options = {}) {
2654
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
2655
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2656
+ const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
2657
+ return new Promise((resolve, reject) => {
2658
+ let promiseStatus = "idle";
2659
+ let timeoutId;
2660
+ let intervalId;
2661
+ const onReject = (error) => {
2662
+ if (intervalId) {
2663
+ clearInterval(intervalId);
2664
+ }
2665
+ if (!error) {
2666
+ error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
2667
+ }
2668
+ reject(error);
2669
+ };
2670
+ const onResolve = (result) => {
2671
+ if (!result) {
2672
+ return;
2673
+ }
2674
+ if (timeoutId) {
2675
+ clearTimeout(timeoutId);
2676
+ }
2677
+ if (intervalId) {
2678
+ clearInterval(intervalId);
2679
+ }
2680
+ resolve(result);
2681
+ return true;
2682
+ };
2683
+ const checkCallback = () => {
2684
+ if (vi.isFakeTimers()) {
2685
+ vi.advanceTimersByTime(interval);
2686
+ }
2687
+ if (promiseStatus === "pending") {
2688
+ return;
2689
+ }
2690
+ try {
2691
+ const result = callback();
2692
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
2693
+ const thenable = result;
2694
+ promiseStatus = "pending";
2695
+ thenable.then((resolvedValue) => {
2696
+ promiseStatus = "resolved";
2697
+ onResolve(resolvedValue);
2698
+ }, (rejectedValue) => {
2699
+ promiseStatus = "rejected";
2700
+ onReject(rejectedValue);
2701
+ });
2702
+ } else {
2703
+ return onResolve(result);
2704
+ }
2705
+ } catch (error) {
2706
+ onReject(error);
2707
+ }
2708
+ };
2709
+ if (checkCallback() === true) {
2710
+ return;
2711
+ }
2712
+ timeoutId = setTimeout(onReject, timeout);
2713
+ intervalId = setInterval(checkCallback, interval);
2714
+ });
2715
+ }
2716
+ function createVitest() {
2717
+ let _config = null;
2718
+ const workerState = getWorkerState();
2719
+ let _timers;
2720
+ const timers = () => _timers ||= new FakeTimers({
2721
+ global: globalThis,
2722
+ config: workerState.config.fakeTimers
2723
+ });
2724
+ const _stubsGlobal = /* @__PURE__ */ new Map();
2725
+ const _stubsEnv = /* @__PURE__ */ new Map();
2726
+ const _envBooleans = [
2727
+ "PROD",
2728
+ "DEV",
2729
+ "SSR"
2730
+ ];
2731
+ const utils = {
2732
+ useFakeTimers(config) {
2733
+ if (isChildProcess()) {
2734
+ if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
2735
+ throw new Error('vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.');
2736
+ }
2737
+ }
2738
+ if (config) {
2739
+ timers().configure({
2740
+ ...workerState.config.fakeTimers,
2741
+ ...config
2742
+ });
2743
+ } else {
2744
+ timers().configure(workerState.config.fakeTimers);
2745
+ }
2746
+ timers().useFakeTimers();
2747
+ return utils;
2748
+ },
2749
+ isFakeTimers() {
2750
+ return timers().isFakeTimers();
2751
+ },
2752
+ useRealTimers() {
2753
+ timers().useRealTimers();
2754
+ return utils;
2755
+ },
2756
+ runOnlyPendingTimers() {
2757
+ timers().runOnlyPendingTimers();
2758
+ return utils;
2759
+ },
2760
+ async runOnlyPendingTimersAsync() {
2761
+ await timers().runOnlyPendingTimersAsync();
2762
+ return utils;
2763
+ },
2764
+ runAllTimers() {
2765
+ timers().runAllTimers();
2766
+ return utils;
2767
+ },
2768
+ async runAllTimersAsync() {
2769
+ await timers().runAllTimersAsync();
2770
+ return utils;
2771
+ },
2772
+ runAllTicks() {
2773
+ timers().runAllTicks();
2774
+ return utils;
2775
+ },
2776
+ advanceTimersByTime(ms) {
2777
+ timers().advanceTimersByTime(ms);
2778
+ return utils;
2779
+ },
2780
+ async advanceTimersByTimeAsync(ms) {
2781
+ await timers().advanceTimersByTimeAsync(ms);
2782
+ return utils;
2783
+ },
2784
+ advanceTimersToNextTimer() {
2785
+ timers().advanceTimersToNextTimer();
2786
+ return utils;
2787
+ },
2788
+ async advanceTimersToNextTimerAsync() {
2789
+ await timers().advanceTimersToNextTimerAsync();
2790
+ return utils;
2791
+ },
2792
+ advanceTimersToNextFrame() {
2793
+ timers().advanceTimersToNextFrame();
2794
+ return utils;
2795
+ },
2796
+ getTimerCount() {
2797
+ return timers().getTimerCount();
2798
+ },
2799
+ setSystemTime(time) {
2800
+ timers().setSystemTime(time);
2801
+ return utils;
2802
+ },
2803
+ getMockedSystemTime() {
2804
+ return timers().getMockedSystemTime();
2805
+ },
2806
+ getRealSystemTime() {
2807
+ return timers().getRealSystemTime();
2808
+ },
2809
+ clearAllTimers() {
2810
+ timers().clearAllTimers();
2811
+ return utils;
2812
+ },
2813
+ spyOn,
2814
+ fn,
2815
+ waitFor,
2816
+ waitUntil,
2817
+ hoisted(factory) {
2818
+ assertTypes(factory, '"vi.hoisted" factory', ["function"]);
2819
+ return factory();
2820
+ },
2821
+ mock(path, factory) {
2822
+ if (typeof path !== "string") {
2823
+ throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
2824
+ }
2825
+ const importer = getImporter("mock");
2826
+ _mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
2827
+ },
2828
+ unmock(path) {
2829
+ if (typeof path !== "string") {
2830
+ throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
2831
+ }
2832
+ _mocker().queueUnmock(path, getImporter("unmock"));
2833
+ },
2834
+ doMock(path, factory) {
2835
+ if (typeof path !== "string") {
2836
+ throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
2837
+ }
2838
+ const importer = getImporter("doMock");
2839
+ _mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
2840
+ },
2841
+ doUnmock(path) {
2842
+ if (typeof path !== "string") {
2843
+ throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
2844
+ }
2845
+ _mocker().queueUnmock(path, getImporter("doUnmock"));
2846
+ },
2847
+ async importActual(path) {
2848
+ return _mocker().importActual(path, getImporter("importActual"), _mocker().getMockContext().callstack);
2849
+ },
2850
+ async importMock(path) {
2851
+ return _mocker().importMock(path, getImporter("importMock"));
2852
+ },
2853
+ mocked(item, _options = {}) {
2854
+ return item;
2855
+ },
2856
+ isMockFunction(fn2) {
2857
+ return isMockFunction(fn2);
2858
+ },
2859
+ clearAllMocks() {
2860
+ [...mocks].reverse().forEach((spy) => spy.mockClear());
2861
+ return utils;
2862
+ },
2863
+ resetAllMocks() {
2864
+ [...mocks].reverse().forEach((spy) => spy.mockReset());
2865
+ return utils;
2866
+ },
2867
+ restoreAllMocks() {
2868
+ [...mocks].reverse().forEach((spy) => spy.mockRestore());
2869
+ return utils;
2870
+ },
2871
+ stubGlobal(name, value) {
2872
+ if (!_stubsGlobal.has(name)) {
2873
+ _stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
2874
+ }
2875
+ Object.defineProperty(globalThis, name, {
2876
+ value,
2877
+ writable: true,
2878
+ configurable: true,
2879
+ enumerable: true
2880
+ });
2881
+ return utils;
2882
+ },
2883
+ stubEnv(name, value) {
2884
+ if (!_stubsEnv.has(name)) {
2885
+ _stubsEnv.set(name, process.env[name]);
2886
+ }
2887
+ if (_envBooleans.includes(name)) {
2888
+ process.env[name] = value ? "1" : "";
2889
+ } else if (value === void 0) {
2890
+ delete process.env[name];
2891
+ } else {
2892
+ process.env[name] = String(value);
2893
+ }
2894
+ return utils;
2895
+ },
2896
+ unstubAllGlobals() {
2897
+ _stubsGlobal.forEach((original, name) => {
2898
+ if (!original) {
2899
+ Reflect.deleteProperty(globalThis, name);
2900
+ } else {
2901
+ Object.defineProperty(globalThis, name, original);
2902
+ }
2903
+ });
2904
+ _stubsGlobal.clear();
2905
+ return utils;
2906
+ },
2907
+ unstubAllEnvs() {
2908
+ _stubsEnv.forEach((original, name) => {
2909
+ if (original === void 0) {
2910
+ delete process.env[name];
2911
+ } else {
2912
+ process.env[name] = original;
2913
+ }
2914
+ });
2915
+ _stubsEnv.clear();
2916
+ return utils;
2917
+ },
2918
+ resetModules() {
2919
+ resetModules(workerState.moduleCache);
2920
+ return utils;
2921
+ },
2922
+ async dynamicImportSettled() {
2923
+ return waitForImportsToResolve();
2924
+ },
2925
+ setConfig(config) {
2926
+ if (!_config) {
2927
+ _config = { ...workerState.config };
2928
+ }
2929
+ Object.assign(workerState.config, config);
2930
+ },
2931
+ resetConfig() {
2932
+ if (_config) {
2933
+ Object.assign(workerState.config, _config);
2934
+ }
2935
+ }
2936
+ };
2937
+ return utils;
2938
+ }
2939
+ var vitest = createVitest();
2940
+ var vi = vitest;
2941
+ function _mocker() {
2942
+ return typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, { get(_, name) {
2943
+ throw new Error(`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`);
2944
+ } });
2945
+ }
2946
+ function getImporter(name) {
2947
+ const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 });
2948
+ const stackArray = stackTrace.split("\n");
2949
+ const importerStackIndex = stackArray.findIndex((stack2) => {
2950
+ return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
2951
+ });
2952
+ const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
2953
+ return stack?.file || "";
2954
+ }
2955
+
2956
+ // ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.1_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3/node_modules/vitest/dist/index.js
2957
+ import { expectTypeOf } from "expect-type.js";
2958
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.js";
2959
+ import * as chai2 from "chai.js";
2960
+ import { assert as assert2, should } from "chai.js";
2961
+ import "@vitest/expect.js";
2962
+ import "@vitest/runner/utils.js";
2963
+ import "@vitest/utils.js";
2964
+ import "@vitest/snapshot.js";
2965
+ import "@vitest/utils/error.js";
2966
+ import "@vitest/spy.js";
2967
+ import "@vitest/utils/source-map.js";
2968
+
2969
+ // src/tests/setup.ts
2970
+ var OriginalDate = global.Date;
2971
+ var fixedDate = new OriginalDate("2023-01-01");
4
2972
  global.Date = vi.fn(() => fixedDate);
5
2973
  global.Date.now = vi.fn(() => fixedDate.getTime());
6
2974
  //# sourceMappingURL=setup.js.map