@tamagui/toast 2.7.7 → 3.0.0-beta.637.1

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 (303) hide show
  1. package/dist/cjs/ToastComposable.cjs +773 -882
  2. package/dist/cjs/ToastComposable.native.cjs +924 -0
  3. package/dist/cjs/ToastComposable.native.js +854 -966
  4. package/dist/cjs/ToastComposable.native.js.map +1 -1
  5. package/dist/cjs/ToastItemFrame.cjs +48 -119
  6. package/dist/cjs/ToastItemFrame.native.cjs +76 -0
  7. package/dist/cjs/ToastItemFrame.native.js +50 -120
  8. package/dist/cjs/ToastItemFrame.native.js.map +1 -1
  9. package/dist/cjs/ToastState.cjs +281 -290
  10. package/dist/cjs/ToastState.native.cjs +312 -0
  11. package/dist/cjs/ToastState.native.js +280 -290
  12. package/dist/cjs/ToastState.native.js.map +1 -1
  13. package/dist/cjs/createNativeToast.cjs +38 -44
  14. package/dist/cjs/createNativeToast.native.cjs +54 -0
  15. package/dist/cjs/createNativeToast.native.js +36 -40
  16. package/dist/cjs/createNativeToast.native.js.map +1 -1
  17. package/dist/cjs/dispatchNativeToast.cjs +32 -35
  18. package/dist/cjs/dispatchNativeToast.native.cjs +48 -0
  19. package/dist/cjs/dispatchNativeToast.native.js +34 -36
  20. package/dist/cjs/dispatchNativeToast.native.js.map +1 -1
  21. package/dist/cjs/index.cjs +25 -12
  22. package/dist/cjs/index.native.cjs +35 -0
  23. package/dist/cjs/index.native.js +26 -12
  24. package/dist/cjs/index.native.js.map +1 -1
  25. package/dist/cjs/types.cjs +10 -11
  26. package/dist/cjs/types.native.cjs +19 -0
  27. package/dist/cjs/types.native.js +10 -10
  28. package/dist/cjs/types.native.js.map +1 -1
  29. package/dist/cjs/useAnimatedDragGesture.cjs +197 -194
  30. package/dist/cjs/useAnimatedDragGesture.native.cjs +210 -0
  31. package/dist/cjs/useAnimatedDragGesture.native.js +179 -191
  32. package/dist/cjs/useAnimatedDragGesture.native.js.map +1 -1
  33. package/dist/cjs/useReducedMotion.cjs +47 -55
  34. package/dist/cjs/useReducedMotion.native.cjs +74 -0
  35. package/dist/cjs/useReducedMotion.native.js +53 -60
  36. package/dist/cjs/useReducedMotion.native.js.map +1 -1
  37. package/dist/cjs/useToastAnimations.cjs +198 -270
  38. package/dist/cjs/useToastAnimations.native.cjs +229 -0
  39. package/dist/cjs/useToastAnimations.native.js +205 -276
  40. package/dist/cjs/useToastAnimations.native.js.map +1 -1
  41. package/dist/esm/ToastComposable.mjs +752 -854
  42. package/dist/esm/ToastComposable.mjs.map +1 -1
  43. package/dist/esm/ToastComposable.native.js +834 -940
  44. package/dist/esm/ToastComposable.native.js.map +1 -1
  45. package/dist/esm/ToastItemFrame.mjs +31 -99
  46. package/dist/esm/ToastItemFrame.mjs.map +1 -1
  47. package/dist/esm/ToastItemFrame.native.js +34 -102
  48. package/dist/esm/ToastItemFrame.native.js.map +1 -1
  49. package/dist/esm/ToastState.mjs +266 -273
  50. package/dist/esm/ToastState.mjs.map +1 -1
  51. package/dist/esm/ToastState.native.js +265 -274
  52. package/dist/esm/ToastState.native.js.map +1 -1
  53. package/dist/esm/createNativeToast.mjs +22 -26
  54. package/dist/esm/createNativeToast.mjs.map +1 -1
  55. package/dist/esm/createNativeToast.native.js +21 -23
  56. package/dist/esm/createNativeToast.native.js.map +1 -1
  57. package/dist/esm/dispatchNativeToast.mjs +19 -17
  58. package/dist/esm/dispatchNativeToast.mjs.map +1 -1
  59. package/dist/esm/dispatchNativeToast.native.js +21 -19
  60. package/dist/esm/dispatchNativeToast.native.js.map +1 -1
  61. package/dist/esm/index.js +5 -2
  62. package/dist/esm/index.mjs +5 -2
  63. package/dist/esm/index.native.js +5 -2
  64. package/dist/esm/types.mjs +0 -2
  65. package/dist/esm/types.native.js +0 -2
  66. package/dist/esm/useAnimatedDragGesture.mjs +181 -168
  67. package/dist/esm/useAnimatedDragGesture.mjs.map +1 -1
  68. package/dist/esm/useAnimatedDragGesture.native.js +163 -166
  69. package/dist/esm/useAnimatedDragGesture.native.js.map +1 -1
  70. package/dist/esm/useReducedMotion.mjs +31 -29
  71. package/dist/esm/useReducedMotion.mjs.map +1 -1
  72. package/dist/esm/useReducedMotion.native.js +37 -35
  73. package/dist/esm/useReducedMotion.native.js.map +1 -1
  74. package/dist/esm/useToastAnimations.mjs +183 -245
  75. package/dist/esm/useToastAnimations.mjs.map +1 -1
  76. package/dist/esm/useToastAnimations.native.js +190 -252
  77. package/dist/esm/useToastAnimations.native.js.map +1 -1
  78. package/dist/jsx/ToastComposable.mjs +752 -854
  79. package/dist/jsx/ToastComposable.mjs.map +1 -1
  80. package/dist/jsx/ToastComposable.native.cjs +924 -0
  81. package/dist/jsx/ToastComposable.native.js +854 -966
  82. package/dist/jsx/ToastComposable.native.js.map +1 -1
  83. package/dist/jsx/ToastItemFrame.mjs +31 -99
  84. package/dist/jsx/ToastItemFrame.mjs.map +1 -1
  85. package/dist/jsx/ToastItemFrame.native.cjs +76 -0
  86. package/dist/jsx/ToastItemFrame.native.js +50 -120
  87. package/dist/jsx/ToastItemFrame.native.js.map +1 -1
  88. package/dist/jsx/ToastState.mjs +266 -273
  89. package/dist/jsx/ToastState.mjs.map +1 -1
  90. package/dist/jsx/ToastState.native.cjs +312 -0
  91. package/dist/jsx/ToastState.native.js +280 -290
  92. package/dist/jsx/ToastState.native.js.map +1 -1
  93. package/dist/jsx/createNativeToast.mjs +22 -26
  94. package/dist/jsx/createNativeToast.mjs.map +1 -1
  95. package/dist/jsx/createNativeToast.native.cjs +54 -0
  96. package/dist/jsx/createNativeToast.native.js +36 -40
  97. package/dist/jsx/createNativeToast.native.js.map +1 -1
  98. package/dist/jsx/dispatchNativeToast.mjs +19 -17
  99. package/dist/jsx/dispatchNativeToast.mjs.map +1 -1
  100. package/dist/jsx/dispatchNativeToast.native.cjs +48 -0
  101. package/dist/jsx/dispatchNativeToast.native.js +34 -36
  102. package/dist/jsx/dispatchNativeToast.native.js.map +1 -1
  103. package/dist/jsx/index.js +5 -2
  104. package/dist/jsx/index.mjs +5 -2
  105. package/dist/jsx/index.native.cjs +35 -0
  106. package/dist/jsx/index.native.js +26 -12
  107. package/dist/jsx/index.native.js.map +1 -1
  108. package/dist/jsx/types.mjs +0 -2
  109. package/dist/jsx/types.native.cjs +19 -0
  110. package/dist/jsx/types.native.js +10 -10
  111. package/dist/jsx/types.native.js.map +1 -1
  112. package/dist/jsx/useAnimatedDragGesture.mjs +181 -168
  113. package/dist/jsx/useAnimatedDragGesture.mjs.map +1 -1
  114. package/dist/jsx/useAnimatedDragGesture.native.cjs +210 -0
  115. package/dist/jsx/useAnimatedDragGesture.native.js +179 -191
  116. package/dist/jsx/useAnimatedDragGesture.native.js.map +1 -1
  117. package/dist/jsx/useReducedMotion.mjs +31 -29
  118. package/dist/jsx/useReducedMotion.mjs.map +1 -1
  119. package/dist/jsx/useReducedMotion.native.cjs +74 -0
  120. package/dist/jsx/useReducedMotion.native.js +53 -60
  121. package/dist/jsx/useReducedMotion.native.js.map +1 -1
  122. package/dist/jsx/useToastAnimations.mjs +183 -245
  123. package/dist/jsx/useToastAnimations.mjs.map +1 -1
  124. package/dist/jsx/useToastAnimations.native.cjs +229 -0
  125. package/dist/jsx/useToastAnimations.native.js +205 -276
  126. package/dist/jsx/useToastAnimations.native.js.map +1 -1
  127. package/package.json +20 -37
  128. package/src/ToastComposable.tsx +55 -97
  129. package/src/ToastItemFrame.tsx +22 -81
  130. package/src/ToastState.ts +1 -0
  131. package/src/index.ts +34 -2
  132. package/src/types.ts +11 -0
  133. package/src/useAnimatedDragGesture.native.ts +1 -1
  134. package/src/useAnimatedDragGesture.ts +1 -1
  135. package/src/useToastAnimations.ts +20 -36
  136. package/types/ToastComposable.d.ts +124 -47
  137. package/types/ToastComposable.d.ts.map +1 -1
  138. package/types/ToastItemFrame.d.ts +52 -21
  139. package/types/ToastItemFrame.d.ts.map +1 -1
  140. package/types/ToastState.d.ts +15 -11
  141. package/types/ToastState.d.ts.map +1 -1
  142. package/types/index.d.ts +6 -2
  143. package/types/index.d.ts.map +1 -1
  144. package/types/types.d.ts +1 -0
  145. package/types/types.d.ts.map +1 -1
  146. package/types/useAnimatedDragGesture.d.ts +1 -1
  147. package/types/useAnimatedDragGesture.d.ts.map +1 -1
  148. package/types/useAnimatedDragGesture.native.d.ts +1 -1
  149. package/types/useAnimatedDragGesture.native.d.ts.map +1 -1
  150. package/types/useToastAnimations.d.ts +2 -8
  151. package/types/useToastAnimations.d.ts.map +1 -1
  152. package/dist/cjs/Toast.cjs +0 -178
  153. package/dist/cjs/Toast.native.js +0 -181
  154. package/dist/cjs/Toast.native.js.map +0 -1
  155. package/dist/cjs/ToastAnnounce.cjs +0 -103
  156. package/dist/cjs/ToastAnnounce.native.js +0 -111
  157. package/dist/cjs/ToastAnnounce.native.js.map +0 -1
  158. package/dist/cjs/ToastImperative.cjs +0 -119
  159. package/dist/cjs/ToastImperative.native.js +0 -130
  160. package/dist/cjs/ToastImperative.native.js.map +0 -1
  161. package/dist/cjs/ToastImpl.cjs +0 -354
  162. package/dist/cjs/ToastImpl.native.js +0 -364
  163. package/dist/cjs/ToastImpl.native.js.map +0 -1
  164. package/dist/cjs/ToastPortal.cjs +0 -49
  165. package/dist/cjs/ToastPortal.native.js +0 -52
  166. package/dist/cjs/ToastPortal.native.js.map +0 -1
  167. package/dist/cjs/ToastProvider.cjs +0 -150
  168. package/dist/cjs/ToastProvider.native.js +0 -161
  169. package/dist/cjs/ToastProvider.native.js.map +0 -1
  170. package/dist/cjs/ToastViewport.cjs +0 -319
  171. package/dist/cjs/ToastViewport.native.js +0 -343
  172. package/dist/cjs/ToastViewport.native.js.map +0 -1
  173. package/dist/cjs/Toaster.cjs +0 -87
  174. package/dist/cjs/Toaster.native.js +0 -91
  175. package/dist/cjs/Toaster.native.js.map +0 -1
  176. package/dist/cjs/constants.cjs +0 -30
  177. package/dist/cjs/constants.native.js +0 -33
  178. package/dist/cjs/constants.native.js.map +0 -1
  179. package/dist/cjs/v2.cjs +0 -36
  180. package/dist/cjs/v2.native.js +0 -39
  181. package/dist/cjs/v2.native.js.map +0 -1
  182. package/dist/esm/Toast.mjs +0 -137
  183. package/dist/esm/Toast.mjs.map +0 -1
  184. package/dist/esm/Toast.native.js +0 -137
  185. package/dist/esm/Toast.native.js.map +0 -1
  186. package/dist/esm/ToastAnnounce.mjs +0 -66
  187. package/dist/esm/ToastAnnounce.mjs.map +0 -1
  188. package/dist/esm/ToastAnnounce.native.js +0 -71
  189. package/dist/esm/ToastAnnounce.native.js.map +0 -1
  190. package/dist/esm/ToastImperative.mjs +0 -80
  191. package/dist/esm/ToastImperative.mjs.map +0 -1
  192. package/dist/esm/ToastImperative.native.js +0 -88
  193. package/dist/esm/ToastImperative.native.js.map +0 -1
  194. package/dist/esm/ToastImpl.mjs +0 -316
  195. package/dist/esm/ToastImpl.mjs.map +0 -1
  196. package/dist/esm/ToastImpl.native.js +0 -329
  197. package/dist/esm/ToastImpl.native.js.map +0 -1
  198. package/dist/esm/ToastPortal.mjs +0 -24
  199. package/dist/esm/ToastPortal.mjs.map +0 -1
  200. package/dist/esm/ToastPortal.native.js +0 -24
  201. package/dist/esm/ToastPortal.native.js.map +0 -1
  202. package/dist/esm/ToastProvider.mjs +0 -110
  203. package/dist/esm/ToastProvider.mjs.map +0 -1
  204. package/dist/esm/ToastProvider.native.js +0 -118
  205. package/dist/esm/ToastProvider.native.js.map +0 -1
  206. package/dist/esm/ToastViewport.mjs +0 -280
  207. package/dist/esm/ToastViewport.mjs.map +0 -1
  208. package/dist/esm/ToastViewport.native.js +0 -301
  209. package/dist/esm/ToastViewport.native.js.map +0 -1
  210. package/dist/esm/Toaster.mjs +0 -51
  211. package/dist/esm/Toaster.mjs.map +0 -1
  212. package/dist/esm/Toaster.native.js +0 -52
  213. package/dist/esm/Toaster.native.js.map +0 -1
  214. package/dist/esm/constants.mjs +0 -4
  215. package/dist/esm/constants.mjs.map +0 -1
  216. package/dist/esm/constants.native.js +0 -4
  217. package/dist/esm/constants.native.js.map +0 -1
  218. package/dist/esm/index.js.map +0 -1
  219. package/dist/esm/index.mjs.map +0 -1
  220. package/dist/esm/index.native.js.map +0 -1
  221. package/dist/esm/types.mjs.map +0 -1
  222. package/dist/esm/types.native.js.map +0 -1
  223. package/dist/esm/v2.mjs +0 -6
  224. package/dist/esm/v2.mjs.map +0 -1
  225. package/dist/esm/v2.native.js +0 -6
  226. package/dist/esm/v2.native.js.map +0 -1
  227. package/dist/jsx/Toast.mjs +0 -137
  228. package/dist/jsx/Toast.mjs.map +0 -1
  229. package/dist/jsx/Toast.native.js +0 -181
  230. package/dist/jsx/Toast.native.js.map +0 -1
  231. package/dist/jsx/ToastAnnounce.mjs +0 -66
  232. package/dist/jsx/ToastAnnounce.mjs.map +0 -1
  233. package/dist/jsx/ToastAnnounce.native.js +0 -111
  234. package/dist/jsx/ToastAnnounce.native.js.map +0 -1
  235. package/dist/jsx/ToastImperative.mjs +0 -80
  236. package/dist/jsx/ToastImperative.mjs.map +0 -1
  237. package/dist/jsx/ToastImperative.native.js +0 -130
  238. package/dist/jsx/ToastImperative.native.js.map +0 -1
  239. package/dist/jsx/ToastImpl.mjs +0 -316
  240. package/dist/jsx/ToastImpl.mjs.map +0 -1
  241. package/dist/jsx/ToastImpl.native.js +0 -364
  242. package/dist/jsx/ToastImpl.native.js.map +0 -1
  243. package/dist/jsx/ToastPortal.mjs +0 -24
  244. package/dist/jsx/ToastPortal.mjs.map +0 -1
  245. package/dist/jsx/ToastPortal.native.js +0 -52
  246. package/dist/jsx/ToastPortal.native.js.map +0 -1
  247. package/dist/jsx/ToastProvider.mjs +0 -110
  248. package/dist/jsx/ToastProvider.mjs.map +0 -1
  249. package/dist/jsx/ToastProvider.native.js +0 -161
  250. package/dist/jsx/ToastProvider.native.js.map +0 -1
  251. package/dist/jsx/ToastViewport.mjs +0 -280
  252. package/dist/jsx/ToastViewport.mjs.map +0 -1
  253. package/dist/jsx/ToastViewport.native.js +0 -343
  254. package/dist/jsx/ToastViewport.native.js.map +0 -1
  255. package/dist/jsx/Toaster.mjs +0 -51
  256. package/dist/jsx/Toaster.mjs.map +0 -1
  257. package/dist/jsx/Toaster.native.js +0 -91
  258. package/dist/jsx/Toaster.native.js.map +0 -1
  259. package/dist/jsx/constants.mjs +0 -4
  260. package/dist/jsx/constants.mjs.map +0 -1
  261. package/dist/jsx/constants.native.js +0 -33
  262. package/dist/jsx/constants.native.js.map +0 -1
  263. package/dist/jsx/index.js.map +0 -1
  264. package/dist/jsx/index.mjs.map +0 -1
  265. package/dist/jsx/types.mjs.map +0 -1
  266. package/dist/jsx/v2.mjs +0 -6
  267. package/dist/jsx/v2.mjs.map +0 -1
  268. package/dist/jsx/v2.native.js +0 -39
  269. package/dist/jsx/v2.native.js.map +0 -1
  270. package/src/Toast.tsx +0 -219
  271. package/src/ToastAnnounce.tsx +0 -103
  272. package/src/ToastImperative.tsx +0 -192
  273. package/src/ToastImpl.tsx +0 -514
  274. package/src/ToastPortal.tsx +0 -19
  275. package/src/ToastProvider.tsx +0 -204
  276. package/src/ToastViewport.tsx +0 -430
  277. package/src/Toaster.tsx +0 -181
  278. package/src/constants.ts +0 -2
  279. package/src/v2.ts +0 -31
  280. package/types/Toast.d.ts +0 -84
  281. package/types/Toast.d.ts.map +0 -1
  282. package/types/ToastAnnounce.d.ts +0 -18
  283. package/types/ToastAnnounce.d.ts.map +0 -1
  284. package/types/ToastImperative.d.ts +0 -95
  285. package/types/ToastImperative.d.ts.map +0 -1
  286. package/types/ToastImpl.d.ts +0 -109
  287. package/types/ToastImpl.d.ts.map +0 -1
  288. package/types/ToastPortal.d.ts +0 -8
  289. package/types/ToastPortal.d.ts.map +0 -1
  290. package/types/ToastProvider.d.ts +0 -92
  291. package/types/ToastProvider.d.ts.map +0 -1
  292. package/types/ToastViewport.d.ts +0 -75
  293. package/types/ToastViewport.d.ts.map +0 -1
  294. package/types/Toaster.d.ts +0 -112
  295. package/types/Toaster.d.ts.map +0 -1
  296. package/types/constants.d.ts +0 -3
  297. package/types/constants.d.ts.map +0 -1
  298. package/types/v2.d.ts +0 -10
  299. package/types/v2.d.ts.map +0 -1
  300. package/v2/index.cjs +0 -2
  301. package/v2/index.js +0 -2
  302. package/v2/index.native.cjs +0 -2
  303. package/v2/index.native.js +0 -2
@@ -0,0 +1,924 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var ToastComposable_exports = {};
31
+ __export(ToastComposable_exports, {
32
+ Toast: () => Toast,
33
+ useToastItem: () => useToastItem,
34
+ useToasts: () => useToasts
35
+ });
36
+ module.exports = __toCommonJS(ToastComposable_exports);
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_core = require("@tamagui/core");
39
+ var import_animate_presence = require("@tamagui/animate-presence");
40
+ var import_constants = require("@tamagui/constants");
41
+ var import_native = require("@tamagui/native");
42
+ var import_core2 = require("@tamagui/core");
43
+ var import_helpers = require("@tamagui/helpers");
44
+ var import_portal = require("@tamagui/portal");
45
+ var import_stacks = require("@tamagui/stacks");
46
+ var import_text = require("@tamagui/text");
47
+ var React = __toESM(require("react"), 1);
48
+ var import_ToastState = require("./ToastState.native.js");
49
+ var import_dispatchNativeToast = require("./dispatchNativeToast.native.js");
50
+ var import_useAnimatedDragGesture = require("./useAnimatedDragGesture.native.js");
51
+ var import_useToastAnimations = require("./useToastAnimations.native.js");
52
+ var import_useReducedMotion = require("./useReducedMotion.native.js");
53
+ var import_ToastItemFrame = require("./ToastItemFrame.native.js");
54
+ function _type_of(obj) {
55
+ "@swc/helpers - typeof";
56
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
57
+ }
58
+ var VISIBLE_TOASTS_AMOUNT = 4;
59
+ var VIEWPORT_OFFSET = 16;
60
+ var TOAST_GAP = 14;
61
+ var TOAST_LIFETIME = 4e3;
62
+ var FIXED_TOAST_HEIGHT = 72;
63
+ var TIME_BEFORE_UNMOUNT = 200;
64
+ var DEFAULT_HOTKEY = ["altKey", "KeyT"];
65
+ var ToastContext = (0, import_core2.createStyledContext)({}, "Toast__");
66
+ var useToastContextValue = ToastContext.useStyledContext;
67
+ function hasToastContext(ctx) {
68
+ return !!ctx && Array.isArray(ctx.toasts) && typeof ctx.setToastHeight === "function" && typeof ctx.removeToast === "function";
69
+ }
70
+ function useToastContext(consumerName) {
71
+ var ctx = useToastContextValue();
72
+ if (!hasToastContext(ctx)) {
73
+ throw new Error(`\`${consumerName}\` must be used within \`Toast\``);
74
+ }
75
+ return ctx;
76
+ }
77
+ var ToastItemContext = /* @__PURE__ */ React.createContext(null);
78
+ function useToastItemContext() {
79
+ var ctx = React.useContext(ToastItemContext);
80
+ if (!ctx) {
81
+ throw new Error("useToastItemContext must be used within Toast.Item or Toast.List");
82
+ }
83
+ return ctx;
84
+ }
85
+ function resolveSwipeDirection(direction, position) {
86
+ if (direction !== "auto") return direction;
87
+ var [yPosition, xPosition] = position.split("-");
88
+ if (!import_constants.isWeb) {
89
+ return yPosition === "top" ? "up" : "down";
90
+ }
91
+ if (xPosition === "left") return "left";
92
+ if (xPosition === "right") return "right";
93
+ return "horizontal";
94
+ }
95
+ var ToastRoot = (0, import_core.createRefComponent)(function ToastRoot2(props, _ref) {
96
+ var { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, theme: themeProp, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
97
+ var reducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotionProp);
98
+ var [toasts, setToasts] = React.useState([]);
99
+ var [heights, setHeights] = React.useState({});
100
+ var [localExpanded, setExpanded] = React.useState(false);
101
+ var expanded = expand || localExpanded;
102
+ var [interacting, setInteracting] = React.useState(false);
103
+ var heightsLockedRef = React.useRef(false);
104
+ var prevExpandedRef = React.useRef(expanded);
105
+ React.useLayoutEffect(function() {
106
+ if (prevExpandedRef.current !== expanded) {
107
+ heightsLockedRef.current = true;
108
+ prevExpandedRef.current = expanded;
109
+ }
110
+ var timer = setTimeout(function() {
111
+ heightsLockedRef.current = false;
112
+ }, 350);
113
+ return function() {
114
+ return clearTimeout(timer);
115
+ };
116
+ }, [expanded]);
117
+ var setToastHeight = React.useCallback(function(toastId, height) {
118
+ if (heightsLockedRef.current) return;
119
+ var rounded = Math.round(height);
120
+ setHeights(function(prev) {
121
+ var existing = prev[toastId];
122
+ if (existing != null && Math.abs(existing - rounded) <= 2) return prev;
123
+ return {
124
+ ...prev,
125
+ [toastId]: rounded
126
+ };
127
+ });
128
+ }, []);
129
+ var removeToastHeight = React.useCallback(function(toastId) {
130
+ setHeights(function(prev) {
131
+ if (!(toastId in prev)) return prev;
132
+ var next = { ...prev };
133
+ delete next[toastId];
134
+ return next;
135
+ });
136
+ }, []);
137
+ var dismissCooldownRef = React.useRef(false);
138
+ var dismissCooldownTimerRef = React.useRef(null);
139
+ var triggerDismissCooldown = React.useCallback(function() {
140
+ dismissCooldownRef.current = true;
141
+ if (dismissCooldownTimerRef.current) {
142
+ clearTimeout(dismissCooldownTimerRef.current);
143
+ }
144
+ dismissCooldownTimerRef.current = setTimeout(function() {
145
+ dismissCooldownRef.current = false;
146
+ }, 800);
147
+ }, []);
148
+ var isInDismissCooldown = React.useCallback(function() {
149
+ return dismissCooldownRef.current;
150
+ }, []);
151
+ var burntOptionsRef = React.useRef(burntOptions);
152
+ var notificationOptionsRef = React.useRef(notificationOptions);
153
+ React.useEffect(function() {
154
+ burntOptionsRef.current = burntOptions;
155
+ }, [burntOptions]);
156
+ React.useEffect(function() {
157
+ notificationOptionsRef.current = notificationOptions;
158
+ }, [notificationOptions]);
159
+ React.useEffect(function() {
160
+ return import_ToastState.ToastState.subscribe(function(toast) {
161
+ if (toast.dismiss) {
162
+ setToasts(function(toasts2) {
163
+ return toasts2.map(function(t) {
164
+ return t.id === toast.id ? {
165
+ ...t,
166
+ delete: true
167
+ } : t;
168
+ });
169
+ });
170
+ return;
171
+ }
172
+ if (toast.toasterId !== toasterId) {
173
+ return;
174
+ }
175
+ if (native) {
176
+ var handled = (0, import_dispatchNativeToast.dispatchNativeToast)(toast, {
177
+ duration,
178
+ burntOptions: burntOptionsRef.current,
179
+ notificationOptions: notificationOptionsRef.current
180
+ });
181
+ if (handled) return;
182
+ }
183
+ setToasts(function(toasts2) {
184
+ var idx = toasts2.findIndex(function(t) {
185
+ return t.id === toast.id;
186
+ });
187
+ if (idx !== -1) {
188
+ return [
189
+ ...toasts2.slice(0, idx),
190
+ {
191
+ ...toasts2[idx],
192
+ ...toast
193
+ },
194
+ ...toasts2.slice(idx + 1)
195
+ ];
196
+ }
197
+ return [toast, ...toasts2];
198
+ });
199
+ });
200
+ }, [
201
+ native,
202
+ duration,
203
+ toasterId
204
+ ]);
205
+ var prevToastCountRef = React.useRef(toasts.length);
206
+ React.useEffect(function() {
207
+ var prevCount = prevToastCountRef.current;
208
+ prevToastCountRef.current = toasts.length;
209
+ if (toasts.length <= 1 && !dismissCooldownRef.current) {
210
+ setExpanded(false);
211
+ } else if (toasts.length > prevCount && expanded) {
212
+ setExpanded(false);
213
+ }
214
+ }, [toasts.length, expanded]);
215
+ var removeToast = React.useCallback(function(toastToRemove) {
216
+ setToasts(function(toasts2) {
217
+ var _toasts_find;
218
+ if (!((_toasts_find = toasts2.find(function(t) {
219
+ return t.id === toastToRemove.id;
220
+ })) === null || _toasts_find === void 0 ? void 0 : _toasts_find.delete)) {
221
+ import_ToastState.ToastState.dismiss(toastToRemove.id);
222
+ }
223
+ return toasts2.filter(function(param) {
224
+ var { id } = param;
225
+ return id !== toastToRemove.id;
226
+ });
227
+ });
228
+ }, []);
229
+ var swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
230
+ var currentTheme = (0, import_core2.useThemeName)();
231
+ var resolvedTheme = themeProp === "system" || !themeProp ? (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.includes("dark")) ? "dark" : "light" : themeProp;
232
+ var contextValue = {
233
+ toasts,
234
+ heights,
235
+ setToastHeight,
236
+ removeToastHeight,
237
+ expanded,
238
+ setExpanded,
239
+ interacting,
240
+ setInteracting,
241
+ triggerDismissCooldown,
242
+ isInDismissCooldown,
243
+ removeToast,
244
+ position,
245
+ duration,
246
+ gap,
247
+ visibleToasts,
248
+ swipeDirection,
249
+ swipeThreshold,
250
+ toastHeight,
251
+ closeButton,
252
+ reducedMotion,
253
+ native,
254
+ burntOptions,
255
+ notificationOptions,
256
+ icons
257
+ };
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
259
+ ...contextValue,
260
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Theme, {
261
+ name: resolvedTheme,
262
+ children
263
+ })
264
+ });
265
+ });
266
+ var ToastViewportFrame = (0, import_core2.styled)(import_core2.View, {
267
+ displayName: "ToastViewport",
268
+ position: import_constants.isWeb ? "fixed" : "absolute",
269
+ zIndex: 1e5,
270
+ pointerEvents: "box-none",
271
+ maxWidth: "100%",
272
+ ...import_constants.isWeb && { width: 356 },
273
+ minHeight: 1
274
+ });
275
+ var ToastViewport = (0, import_core.createStyledHOC)(ToastViewportFrame, function ToastViewport2(props, ref) {
276
+ var { offset = VIEWPORT_OFFSET, hotkey = DEFAULT_HOTKEY, label = "Notifications", portalToRoot = true, portalZIndex = Number.MAX_SAFE_INTEGER, children, ...rest } = props;
277
+ var ctx = useToastContext("Toast.Viewport");
278
+ var listRef = React.useRef(null);
279
+ var hoverTimeoutRef = React.useRef(null);
280
+ var hoverCooldownRef = React.useRef(false);
281
+ var deferredCollapseRef = React.useRef(null);
282
+ var mouseInsideRef = React.useRef(false);
283
+ var [yPosition, xPosition] = ctx.position.split("-");
284
+ var { insets: safeInsets } = (0, import_core2.useConfiguration)();
285
+ var offsetStyles = React.useMemo(function() {
286
+ var styles = {};
287
+ var defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
288
+ var offsetObj = (typeof offset === "undefined" ? "undefined" : _type_of(offset)) === "object" ? offset : {
289
+ top: defaultOffset,
290
+ right: defaultOffset,
291
+ bottom: defaultOffset,
292
+ left: defaultOffset
293
+ };
294
+ var _safeInsets_top;
295
+ var safeTop = (_safeInsets_top = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.top) !== null && _safeInsets_top !== void 0 ? _safeInsets_top : 0;
296
+ var _safeInsets_bottom;
297
+ var safeBottom = (_safeInsets_bottom = safeInsets === null || safeInsets === void 0 ? void 0 : safeInsets.bottom) !== null && _safeInsets_bottom !== void 0 ? _safeInsets_bottom : 0;
298
+ var _offsetObj_top;
299
+ var topOffset = safeTop > 0 ? safeTop : (_offsetObj_top = offsetObj.top) !== null && _offsetObj_top !== void 0 ? _offsetObj_top : defaultOffset;
300
+ var _offsetObj_bottom;
301
+ var bottomOffset = safeBottom > 0 ? safeBottom : (_offsetObj_bottom = offsetObj.bottom) !== null && _offsetObj_bottom !== void 0 ? _offsetObj_bottom : defaultOffset;
302
+ if (yPosition === "top") styles.top = topOffset;
303
+ else styles.bottom = bottomOffset;
304
+ if (import_constants.isWeb) {
305
+ var _offsetObj_left, _offsetObj_right;
306
+ if (xPosition === "left") styles.left = (_offsetObj_left = offsetObj.left) !== null && _offsetObj_left !== void 0 ? _offsetObj_left : defaultOffset;
307
+ else if (xPosition === "right") styles.right = (_offsetObj_right = offsetObj.right) !== null && _offsetObj_right !== void 0 ? _offsetObj_right : defaultOffset;
308
+ else {
309
+ styles.left = "50%";
310
+ styles.transform = "translateX(-50%)";
311
+ }
312
+ } else {
313
+ var _offsetObj_left1;
314
+ styles.left = (_offsetObj_left1 = offsetObj.left) !== null && _offsetObj_left1 !== void 0 ? _offsetObj_left1 : defaultOffset;
315
+ var _offsetObj_right1;
316
+ styles.right = (_offsetObj_right1 = offsetObj.right) !== null && _offsetObj_right1 !== void 0 ? _offsetObj_right1 : defaultOffset;
317
+ }
318
+ return styles;
319
+ }, [
320
+ offset,
321
+ yPosition,
322
+ xPosition
323
+ ]);
324
+ React.useEffect(function() {
325
+ if (!import_constants.isWeb) return;
326
+ var handleKeyDown = function(event) {
327
+ var isHotkeyPressed = hotkey.length > 0 && hotkey.every(function(key) {
328
+ return event[key] || event.code === key;
329
+ });
330
+ if (isHotkeyPressed) {
331
+ var _listRef_current;
332
+ ctx.setExpanded(true);
333
+ (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current.focus();
334
+ }
335
+ };
336
+ document.addEventListener("keydown", handleKeyDown);
337
+ return function() {
338
+ return document.removeEventListener("keydown", handleKeyDown);
339
+ };
340
+ }, [hotkey]);
341
+ if (ctx.toasts.length === 0) return null;
342
+ var hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
343
+ var content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastViewportFrame, {
344
+ ref: listRef,
345
+ "aria-label": `${label} ${hotkeyLabel}`,
346
+ tabIndex: -1,
347
+ "aria-live": "polite",
348
+ style: offsetStyles,
349
+ "data-y-position": yPosition,
350
+ "data-x-position": xPosition,
351
+ ...import_constants.isWeb ? {
352
+ onMouseEnter: function() {
353
+ mouseInsideRef.current = true;
354
+ if (deferredCollapseRef.current) {
355
+ clearTimeout(deferredCollapseRef.current);
356
+ deferredCollapseRef.current = null;
357
+ }
358
+ if (ctx.toasts.length > 1 && !ctx.interacting && !hoverCooldownRef.current) {
359
+ hoverTimeoutRef.current = setTimeout(function() {
360
+ return ctx.setExpanded(true);
361
+ }, 50);
362
+ }
363
+ },
364
+ onMouseLeave: function() {
365
+ mouseInsideRef.current = false;
366
+ if (hoverTimeoutRef.current) {
367
+ clearTimeout(hoverTimeoutRef.current);
368
+ hoverTimeoutRef.current = null;
369
+ }
370
+ if (!ctx.interacting && !ctx.isInDismissCooldown()) {
371
+ ctx.setExpanded(false);
372
+ } else if (ctx.isInDismissCooldown()) {
373
+ if (deferredCollapseRef.current) {
374
+ clearTimeout(deferredCollapseRef.current);
375
+ }
376
+ deferredCollapseRef.current = setTimeout(function() {
377
+ deferredCollapseRef.current = null;
378
+ if (!mouseInsideRef.current) {
379
+ ctx.setExpanded(false);
380
+ }
381
+ }, 1200);
382
+ }
383
+ },
384
+ onPointerDown: function() {
385
+ if (hoverTimeoutRef.current) {
386
+ clearTimeout(hoverTimeoutRef.current);
387
+ hoverTimeoutRef.current = null;
388
+ }
389
+ ctx.setInteracting(true);
390
+ },
391
+ onPointerUp: function() {
392
+ return ctx.setInteracting(false);
393
+ },
394
+ onPointerCancel: function() {
395
+ return ctx.setInteracting(false);
396
+ }
397
+ } : { onPress: function() {
398
+ if (ctx.toasts.length > 1) {
399
+ ctx.setExpanded(function(prev) {
400
+ return !prev;
401
+ });
402
+ }
403
+ } },
404
+ ...import_constants.isWeb && {
405
+ onFocus: function(event) {
406
+ if (!event.currentTarget.contains(event.relatedTarget)) {
407
+ if (ctx.toasts.length > 1) {
408
+ ctx.setExpanded(true);
409
+ }
410
+ ctx.setInteracting(true);
411
+ }
412
+ },
413
+ onBlur: function(event) {
414
+ if (!event.currentTarget.contains(event.relatedTarget)) {
415
+ ctx.setInteracting(false);
416
+ if (!ctx.isInDismissCooldown()) {
417
+ ctx.setExpanded(false);
418
+ }
419
+ }
420
+ }
421
+ },
422
+ ...rest,
423
+ children
424
+ });
425
+ if (portalToRoot) {
426
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, {
427
+ zIndex: portalZIndex,
428
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContext.Provider, {
429
+ ...ctx,
430
+ children: content
431
+ })
432
+ });
433
+ }
434
+ return content;
435
+ });
436
+ function ToastList(param) {
437
+ var { renderItem } = param;
438
+ var ctx = useToastContext("Toast.List");
439
+ var maxRender = ctx.toasts.length;
440
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: ctx.toasts.slice(0, maxRender).map(function(toast, index) {
441
+ var handleClose = function() {
442
+ var _toast_onDismiss;
443
+ if (toast.dismissible === false) return;
444
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
445
+ ctx.removeToast(toast);
446
+ };
447
+ var itemContextValue = {
448
+ toast,
449
+ handleClose
450
+ };
451
+ if (!renderItem) {
452
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
453
+ value: itemContextValue,
454
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemInner, {
455
+ toast,
456
+ index,
457
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DefaultToastContent, { toast })
458
+ })
459
+ }, toast.id);
460
+ }
461
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
462
+ value: itemContextValue,
463
+ children: renderItem({
464
+ toast,
465
+ index,
466
+ handleClose
467
+ })
468
+ }, toast.id);
469
+ }) });
470
+ }
471
+ function DefaultToastContent(param) {
472
+ var { toast } = param;
473
+ var ctx = useToastContext("Toast.Item");
474
+ var { handleClose } = useToastItemContext();
475
+ var _toast_type;
476
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
477
+ var dismissible = toast.dismissible !== false;
478
+ var title = typeof toast.title === "function" ? toast.title() : toast.title;
479
+ var description = typeof toast.description === "function" ? toast.description() : toast.description;
480
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
481
+ alignItems: "flex-start",
482
+ gap: "3",
483
+ children: [
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastIcon, {}),
485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.YStack, {
486
+ flex: 1,
487
+ gap: "1",
488
+ children: [
489
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastTitle, { children: title }),
490
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastDescription, { children: description }),
491
+ (toast.action || toast.cancel) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.XStack, {
492
+ gap: "2",
493
+ marginTop: "2",
494
+ children: [toast.cancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
495
+ onPress: function(e) {
496
+ var _toast_cancel_onClick, _toast_cancel;
497
+ (_toast_cancel = toast.cancel) === null || _toast_cancel === void 0 ? void 0 : (_toast_cancel_onClick = _toast_cancel.onClick) === null || _toast_cancel_onClick === void 0 ? void 0 : _toast_cancel_onClick.call(_toast_cancel, e);
498
+ handleClose();
499
+ },
500
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.SizableText, {
501
+ size: "2",
502
+ children: toast.cancel.label
503
+ })
504
+ }), toast.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
505
+ onPress: function(e) {
506
+ var _toast_action_onClick, _toast_action;
507
+ (_toast_action = toast.action) === null || _toast_action === void 0 ? void 0 : (_toast_action_onClick = _toast_action.onClick) === null || _toast_action_onClick === void 0 ? void 0 : _toast_action_onClick.call(_toast_action, e);
508
+ if (!e.defaultPrevented) {
509
+ handleClose();
510
+ }
511
+ },
512
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.SizableText, {
513
+ size: "2",
514
+ children: toast.action.label
515
+ })
516
+ })]
517
+ })
518
+ ]
519
+ }),
520
+ ctx.closeButton && dismissible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastClose, {})
521
+ ]
522
+ });
523
+ }
524
+ function DragWrapper(param) {
525
+ var { animatedStyle, gestureHandlers, gesture, AnimatedView, dragRef, children } = param;
526
+ if (import_constants.isWeb) {
527
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
528
+ ref: dragRef,
529
+ style: {
530
+ flex: 1,
531
+ display: "flex",
532
+ flexDirection: "column",
533
+ userSelect: "none",
534
+ WebkitUserSelect: "none",
535
+ touchAction: "none",
536
+ cursor: "default"
537
+ },
538
+ ...gestureHandlers,
539
+ children
540
+ });
541
+ }
542
+ if (gesture) {
543
+ var gh = (0, import_native.getGestureHandler)();
544
+ var GestureDetector = gh.state.GestureDetector;
545
+ if (GestureDetector) {
546
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GestureDetector, {
547
+ gesture,
548
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
549
+ style: { flex: 1 },
550
+ ...{ collapsable: false },
551
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
552
+ style: [{ flex: 1 }, animatedStyle],
553
+ children
554
+ })
555
+ })
556
+ });
557
+ }
558
+ }
559
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
560
+ style: [{ flex: 1 }, animatedStyle],
561
+ ...gestureHandlers,
562
+ children
563
+ });
564
+ }
565
+ var ToastItemInner = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastItemFrame, function ToastItem(props, ref) {
566
+ var { toast, index, children, ...rest } = props;
567
+ var ctx = useToastContext("Toast.Item");
568
+ var [mounted, setMounted] = React.useState(false);
569
+ var [removed, setRemoved] = React.useState(false);
570
+ var [swipeOut, setSwipeOut] = React.useState(false);
571
+ var [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
572
+ var swipeExitYRef = React.useRef(null);
573
+ var closeTimerRef = React.useRef(null);
574
+ var closeTimerStartRef = React.useRef(0);
575
+ var lastPauseTimeRef = React.useRef(0);
576
+ var _toast_duration;
577
+ var remainingTimeRef = React.useRef((_toast_duration = toast.duration) !== null && _toast_duration !== void 0 ? _toast_duration : ctx.duration);
578
+ var isFront = index === 0;
579
+ var isVisible = index < ctx.visibleToasts;
580
+ var _toast_type;
581
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
582
+ var dismissible = toast.dismissible !== false;
583
+ var _toast_duration1;
584
+ var duration = (_toast_duration1 = toast.duration) !== null && _toast_duration1 !== void 0 ? _toast_duration1 : ctx.duration;
585
+ var [yPosition] = ctx.position.split("-");
586
+ var isTop = yPosition === "top";
587
+ var expandedOffset = import_constants.isWeb ? (function() {
588
+ var totalHeight = 0;
589
+ var activeCount = 0;
590
+ for (var i = 0; i < index; i++) {
591
+ var _ctx_toasts_i;
592
+ var toastId = (_ctx_toasts_i = ctx.toasts[i]) === null || _ctx_toasts_i === void 0 ? void 0 : _ctx_toasts_i.id;
593
+ if (toastId == null) continue;
594
+ var h2 = ctx.heights[toastId];
595
+ if (h2 === 0) continue;
596
+ totalHeight += h2 !== null && h2 !== void 0 ? h2 : ctx.toastHeight;
597
+ activeCount++;
598
+ }
599
+ return totalHeight + activeCount * ctx.gap;
600
+ })() : index * (ctx.toastHeight + ctx.gap);
601
+ var expandedOffsetRef = React.useRef(expandedOffset);
602
+ expandedOffsetRef.current = expandedOffset;
603
+ var isExpandedRef = React.useRef(ctx.expanded);
604
+ isExpandedRef.current = ctx.expanded;
605
+ var startTimer = React.useCallback(function() {
606
+ if (duration === Number.POSITIVE_INFINITY || toastType === "loading") return;
607
+ closeTimerStartRef.current = Date.now();
608
+ closeTimerRef.current = setTimeout(function() {
609
+ var _toast_onAutoClose;
610
+ (_toast_onAutoClose = toast.onAutoClose) === null || _toast_onAutoClose === void 0 ? void 0 : _toast_onAutoClose.call(toast, toast);
611
+ setRemoved(true);
612
+ setTimeout(function() {
613
+ return ctx.removeToast(toast);
614
+ }, TIME_BEFORE_UNMOUNT);
615
+ }, remainingTimeRef.current);
616
+ }, [
617
+ duration,
618
+ toastType,
619
+ toast,
620
+ ctx.removeToast
621
+ ]);
622
+ var pauseTimer = (0, import_core2.useEvent)(function() {
623
+ if (closeTimerRef.current) {
624
+ clearTimeout(closeTimerRef.current);
625
+ }
626
+ if (lastPauseTimeRef.current < closeTimerStartRef.current) {
627
+ var elapsed = Date.now() - closeTimerStartRef.current;
628
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
629
+ }
630
+ lastPauseTimeRef.current = Date.now();
631
+ });
632
+ var resumeTimer = (0, import_core2.useEvent)(function() {
633
+ if (ctx.expanded || ctx.interacting) return;
634
+ remainingTimeRef.current = duration;
635
+ startTimer();
636
+ });
637
+ React.useEffect(function() {
638
+ setMounted(true);
639
+ }, []);
640
+ React.useEffect(function() {
641
+ if (toast.delete) {
642
+ setRemoved(true);
643
+ if (isExpandedRef.current) {
644
+ setOffsetBeforeRemove(expandedOffsetRef.current);
645
+ }
646
+ setTimeout(function() {
647
+ return ctx.removeToast(toast);
648
+ }, TIME_BEFORE_UNMOUNT);
649
+ }
650
+ }, [
651
+ toast.delete,
652
+ toast,
653
+ ctx.removeToast
654
+ ]);
655
+ React.useEffect(function() {
656
+ if (ctx.expanded || ctx.interacting) {
657
+ pauseTimer();
658
+ } else {
659
+ startTimer();
660
+ }
661
+ return function() {
662
+ if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
663
+ };
664
+ }, [
665
+ ctx.expanded,
666
+ ctx.interacting,
667
+ startTimer
668
+ ]);
669
+ React.useEffect(function() {
670
+ remainingTimeRef.current = duration;
671
+ }, [duration]);
672
+ var { setDragOffset, springBack, animateOut, animatedStyle, AnimatedView, dragRef } = (0, import_useToastAnimations.useToastAnimations)({ reducedMotion: ctx.reducedMotion });
673
+ var { isDragging, gestureHandlers, gesture } = (0, import_useAnimatedDragGesture.useAnimatedDragGesture)({
674
+ direction: ctx.swipeDirection,
675
+ threshold: ctx.swipeThreshold,
676
+ disabled: !dismissible || toastType === "loading",
677
+ expanded: ctx.expanded,
678
+ onDragStart: pauseTimer,
679
+ onDragMove: setDragOffset,
680
+ onDismiss: function(exitDirection, velocity) {
681
+ var _toast_onDismiss;
682
+ ctx.triggerDismissCooldown();
683
+ setSwipeOut(true);
684
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
685
+ swipeExitYRef.current = isExpandedRef.current ? isTop ? expandedOffsetRef.current : -expandedOffsetRef.current : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
686
+ setRemoved(true);
687
+ ctx.removeToast(toast);
688
+ animateOut(exitDirection, velocity);
689
+ },
690
+ onCancel: function() {
691
+ springBack(function() {
692
+ resumeTimer();
693
+ });
694
+ }
695
+ });
696
+ var handleLayout = React.useCallback(function(event) {
697
+ if (!import_constants.isWeb) return;
698
+ if (removed) return;
699
+ if (!ctx.expanded && index !== 0) return;
700
+ var { height } = event.nativeEvent.layout;
701
+ ctx.setToastHeight(toast.id, height);
702
+ }, [
703
+ toast.id,
704
+ ctx.setToastHeight,
705
+ index,
706
+ ctx.expanded,
707
+ removed
708
+ ]);
709
+ React.useEffect(function() {
710
+ if (!import_constants.isWeb) return;
711
+ return function() {
712
+ ctx.removeToastHeight(toast.id);
713
+ };
714
+ }, [toast.id, ctx.removeToastHeight]);
715
+ var handleClose = React.useCallback(function() {
716
+ var _toast_onDismiss;
717
+ if (!dismissible) return;
718
+ ctx.triggerDismissCooldown();
719
+ (_toast_onDismiss = toast.onDismiss) === null || _toast_onDismiss === void 0 ? void 0 : _toast_onDismiss.call(toast, toast);
720
+ setRemoved(true);
721
+ if (isExpandedRef.current) {
722
+ setOffsetBeforeRemove(expandedOffsetRef.current);
723
+ }
724
+ setTimeout(function() {
725
+ return ctx.removeToast(toast);
726
+ }, TIME_BEFORE_UNMOUNT);
727
+ }, [
728
+ dismissible,
729
+ toast,
730
+ ctx.removeToast,
731
+ ctx.triggerDismissCooldown
732
+ ]);
733
+ var itemContextValue = React.useMemo(function() {
734
+ return {
735
+ toast,
736
+ handleClose
737
+ };
738
+ }, [toast, handleClose]);
739
+ var frontToastHeight = -1;
740
+ if (import_constants.isWeb) {
741
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
742
+ try {
743
+ for (var _iterator = ctx.toasts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
744
+ var t = _step.value;
745
+ var h = ctx.heights[t.id];
746
+ if (h != null && h > 0) {
747
+ frontToastHeight = h;
748
+ break;
749
+ }
750
+ }
751
+ } catch (err) {
752
+ _didIteratorError = true;
753
+ _iteratorError = err;
754
+ } finally {
755
+ try {
756
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
757
+ _iterator.return();
758
+ }
759
+ } finally {
760
+ if (_didIteratorError) {
761
+ throw _iteratorError;
762
+ }
763
+ }
764
+ }
765
+ }
766
+ var stackScale = !ctx.expanded && !isFront ? 1 - index * .05 : 1;
767
+ var activeExpandedOffset = removed ? offsetBeforeRemove : expandedOffset;
768
+ var stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
769
+ var computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
770
+ var computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
771
+ var computedHeight = import_constants.isWeb ? ctx.expanded ? ctx.heights[toast.id] || void 0 : !isFront && frontToastHeight > 0 ? frontToastHeight : void 0 : void 0;
772
+ var computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
773
+ var gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
774
+ var dataAttributes = {
775
+ "data-mounted": mounted ? "true" : "false",
776
+ "data-removed": removed ? "true" : "false",
777
+ "data-swipe-out": swipeOut ? "true" : "false",
778
+ "data-visible": isVisible ? "true" : "false",
779
+ "data-front": isFront ? "true" : "false",
780
+ "data-index": String(index),
781
+ "data-type": toastType,
782
+ "data-expanded": ctx.expanded ? "true" : "false"
783
+ };
784
+ var _swipeExitYRef_current;
785
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastPositionWrapper, {
786
+ ref,
787
+ testID: rest.testID,
788
+ "aria-label": rest["aria-label"],
789
+ ...dataAttributes,
790
+ transition: isDragging || ctx.reducedMotion ? void 0 : removed ? "200ms" : "400ms",
791
+ y: ctx.reducedMotion ? stackY : `${stackY} enter:${isTop ? -80 : 80}px exit:${swipeOut ? (_swipeExitYRef_current = swipeExitYRef.current) !== null && _swipeExitYRef_current !== void 0 ? _swipeExitYRef_current : stackY : stackY}px`,
792
+ scale: stackScale,
793
+ opacity: `${computedOpacity} enter:0 exit:0`,
794
+ zIndex: computedZIndex,
795
+ height: computedHeight,
796
+ overflow: "visible",
797
+ pointerEvents: computedPointerEvents,
798
+ top: isTop ? 0 : void 0,
799
+ bottom: isTop ? void 0 : 0,
800
+ ...import_constants.isWeb && !isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
801
+ animateOnly: import_constants.isWeb ? [
802
+ "transform",
803
+ "opacity",
804
+ "height"
805
+ ] : ["transform", "opacity"],
806
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragWrapper, {
807
+ animatedStyle,
808
+ gestureHandlers,
809
+ gesture,
810
+ AnimatedView,
811
+ dragRef,
812
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ToastItemFrame.ToastItemFrame, {
813
+ role: "status",
814
+ "aria-live": "polite",
815
+ "aria-atomic": true,
816
+ tabIndex: 0,
817
+ onLayout: handleLayout,
818
+ ...import_constants.isWeb && { onKeyDown: function(event) {
819
+ if (event.key === "Escape" && dismissible) {
820
+ var current = event.currentTarget;
821
+ var container = current.closest("[aria-label]");
822
+ if (container) {
823
+ var focusables = container.querySelectorAll("[tabindex=\"0\"]");
824
+ var arr = Array.from(focusables);
825
+ var idx = arr.indexOf(current);
826
+ var next = arr[idx + 1] || arr[idx - 1];
827
+ next === null || next === void 0 ? void 0 : next.focus();
828
+ }
829
+ handleClose();
830
+ }
831
+ } },
832
+ ...rest,
833
+ children: [ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
834
+ position: "absolute",
835
+ left: 0,
836
+ right: 0,
837
+ height: gapFillerHeight,
838
+ pointerEvents: "auto",
839
+ ...isTop ? { top: "100%" } : { bottom: "100%" }
840
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastItemContext.Provider, {
841
+ value: itemContextValue,
842
+ children
843
+ })]
844
+ })
845
+ })
846
+ });
847
+ });
848
+ var ToastTitle = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastTitle" });
849
+ var ToastDescription = (0, import_core2.styled)(import_text.SizableText, { displayName: "ToastDescription" });
850
+ var ToastClose = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastCloseFrame, function ToastClose2(props, ref) {
851
+ var _ctx_icons;
852
+ var handleClose;
853
+ try {
854
+ var itemCtx = useToastItemContext();
855
+ handleClose = itemCtx.handleClose;
856
+ } catch (e) {}
857
+ var ctx = useToastContext("Toast.Close");
858
+ var _props_children, _ref;
859
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastCloseFrame, {
860
+ ref,
861
+ "aria-label": "Close toast",
862
+ onPress: handleClose,
863
+ ...props,
864
+ children: (_ref = (_props_children = props.children) !== null && _props_children !== void 0 ? _props_children : (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons.close) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.DefaultCloseIcon, {})
865
+ });
866
+ });
867
+ var ToastAction = (0, import_core.createStyledHOC)(import_ToastItemFrame.ToastActionFrame, function ToastAction2(props, ref) {
868
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToastItemFrame.ToastActionFrame, {
869
+ ref,
870
+ ...props
871
+ });
872
+ });
873
+ function ToastIcon(props) {
874
+ var _ctx_icons;
875
+ var ctx = useToastContext("Toast.Icon");
876
+ var toast;
877
+ try {
878
+ var itemCtx = useToastItemContext();
879
+ toast = itemCtx.toast;
880
+ } catch (e) {
881
+ return null;
882
+ }
883
+ if (!toast) return null;
884
+ if (toast.icon !== void 0) {
885
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
886
+ flexShrink: 0,
887
+ marginTop: "0-5",
888
+ children: toast.icon
889
+ });
890
+ }
891
+ var _toast_type;
892
+ var toastType = (_toast_type = toast.type) !== null && _toast_type !== void 0 ? _toast_type : "default";
893
+ var _ctx_icons_toastType;
894
+ var icon = (_ctx_icons_toastType = (_ctx_icons = ctx.icons) === null || _ctx_icons === void 0 ? void 0 : _ctx_icons[toastType]) !== null && _ctx_icons_toastType !== void 0 ? _ctx_icons_toastType : null;
895
+ if (!icon) return null;
896
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.View, {
897
+ flexShrink: 0,
898
+ marginTop: "0-5",
899
+ children: icon
900
+ });
901
+ }
902
+ function useToasts() {
903
+ var ctx = useToastContext("useToasts");
904
+ return {
905
+ toasts: ctx.toasts,
906
+ expanded: ctx.expanded,
907
+ position: ctx.position,
908
+ closeButton: ctx.closeButton
909
+ };
910
+ }
911
+ function useToastItem() {
912
+ return useToastItemContext();
913
+ }
914
+ ToastRoot.displayName = "Toast";
915
+ var Toast = (0, import_helpers.withStaticProperties)(ToastRoot, {
916
+ Viewport: ToastViewport,
917
+ List: ToastList,
918
+ Item: ToastItemInner,
919
+ Title: ToastTitle,
920
+ Description: ToastDescription,
921
+ Close: ToastClose,
922
+ Action: ToastAction,
923
+ Icon: ToastIcon
924
+ });