@chainvibe/components 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/dist/_virtual/config.js +4 -0
  3. package/dist/_virtual/core.js +4 -0
  4. package/dist/_virtual/debug.js +4 -0
  5. package/dist/_virtual/encode.js +4 -0
  6. package/dist/_virtual/helpers.js +4 -0
  7. package/dist/_virtual/index.js +5 -0
  8. package/dist/_virtual/index2.js +4 -0
  9. package/dist/_virtual/memory.js +4 -0
  10. package/dist/_virtual/number.js +4 -0
  11. package/dist/components/NotificationBox/NotificationBox.d.ts +41 -0
  12. package/dist/components/NotificationBox/NotificationBox.d.ts.map +1 -0
  13. package/dist/components/NotificationBox/NotificationBox.js +86 -0
  14. package/dist/components/NotificationBox/NotificationBox.module.css +1 -0
  15. package/dist/components/NotificationBox/NotificationBox.module.css.js +29 -0
  16. package/dist/components/NotificationBox/index.d.ts +3 -0
  17. package/dist/components/NotificationBox/index.d.ts.map +1 -0
  18. package/dist/components/NotificationBoxAmount/NotificationBoxAmount.d.ts +13 -0
  19. package/dist/components/NotificationBoxAmount/NotificationBoxAmount.d.ts.map +1 -0
  20. package/dist/components/NotificationBoxAmount/NotificationBoxAmount.js +45 -0
  21. package/dist/components/NotificationBoxAmount/NotificationBoxAmount.module.css +1 -0
  22. package/dist/components/NotificationBoxAmount/NotificationBoxAmount.module.css.js +11 -0
  23. package/dist/components/NotificationBoxAmount/index.d.ts +2 -0
  24. package/dist/components/NotificationBoxAmount/index.d.ts.map +1 -0
  25. package/dist/components/NotificationBoxStack/NotificationBoxStack.d.ts +14 -0
  26. package/dist/components/NotificationBoxStack/NotificationBoxStack.d.ts.map +1 -0
  27. package/dist/components/NotificationBoxStack/NotificationBoxStack.js +47 -0
  28. package/dist/components/NotificationBoxStack/index.d.ts +3 -0
  29. package/dist/components/NotificationBoxStack/index.d.ts.map +1 -0
  30. package/dist/components/utils/cn.d.ts +2 -0
  31. package/dist/components/utils/cn.d.ts.map +1 -0
  32. package/dist/components/utils/cn.js +4 -0
  33. package/dist/dev/utils.js +55 -0
  34. package/dist/hooks/useChainVibeStream.js +60 -0
  35. package/dist/index.js +10 -0
  36. package/dist/node_modules/@number-flow/react/dist/NumberFlow-client-48rw3j0J.js +111 -0
  37. package/dist/node_modules/compress-json/dist/config.js +16 -0
  38. package/dist/node_modules/compress-json/dist/core.js +92 -0
  39. package/dist/node_modules/compress-json/dist/debug.js +19 -0
  40. package/dist/node_modules/compress-json/dist/encode.js +58 -0
  41. package/dist/node_modules/compress-json/dist/helpers.js +27 -0
  42. package/dist/node_modules/compress-json/dist/index.js +38 -0
  43. package/dist/node_modules/compress-json/dist/memory.js +128 -0
  44. package/dist/node_modules/compress-json/dist/number.js +119 -0
  45. package/dist/node_modules/number-flow/dist/lite-BtgQ9jUv.js +435 -0
  46. package/dist/node_modules/sonner/dist/index.js +744 -0
  47. package/dist/types/events.d.ts +22 -0
  48. package/dist/types/events.d.ts.map +1 -0
  49. package/package.json +67 -0
@@ -0,0 +1,744 @@
1
+ import React__default from "react";
2
+ import ReactDOM from "react-dom";
3
+ function __insertCSS(code) {
4
+ if (typeof document > "u") return;
5
+ let head = document.head || document.getElementsByTagName("head")[0], style = document.createElement("style");
6
+ style.type = "text/css", head.appendChild(style), style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
7
+ }
8
+ const getAsset = (type) => {
9
+ switch (type) {
10
+ case "success":
11
+ return SuccessIcon;
12
+ case "info":
13
+ return InfoIcon;
14
+ case "warning":
15
+ return WarningIcon;
16
+ case "error":
17
+ return ErrorIcon;
18
+ default:
19
+ return null;
20
+ }
21
+ }, bars = Array(12).fill(0), Loader = ({ visible, className }) => /* @__PURE__ */ React__default.createElement("div", {
22
+ className: [
23
+ "sonner-loading-wrapper",
24
+ className
25
+ ].filter(Boolean).join(" "),
26
+ "data-visible": visible
27
+ }, /* @__PURE__ */ React__default.createElement("div", {
28
+ className: "sonner-spinner"
29
+ }, bars.map((_, i) => /* @__PURE__ */ React__default.createElement("div", {
30
+ className: "sonner-loading-bar",
31
+ key: `spinner-bar-${i}`
32
+ })))), SuccessIcon = /* @__PURE__ */ React__default.createElement("svg", {
33
+ xmlns: "http://www.w3.org/2000/svg",
34
+ viewBox: "0 0 20 20",
35
+ fill: "currentColor",
36
+ height: "20",
37
+ width: "20"
38
+ }, /* @__PURE__ */ React__default.createElement("path", {
39
+ fillRule: "evenodd",
40
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
41
+ clipRule: "evenodd"
42
+ })), WarningIcon = /* @__PURE__ */ React__default.createElement("svg", {
43
+ xmlns: "http://www.w3.org/2000/svg",
44
+ viewBox: "0 0 24 24",
45
+ fill: "currentColor",
46
+ height: "20",
47
+ width: "20"
48
+ }, /* @__PURE__ */ React__default.createElement("path", {
49
+ fillRule: "evenodd",
50
+ d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
51
+ clipRule: "evenodd"
52
+ })), InfoIcon = /* @__PURE__ */ React__default.createElement("svg", {
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ viewBox: "0 0 20 20",
55
+ fill: "currentColor",
56
+ height: "20",
57
+ width: "20"
58
+ }, /* @__PURE__ */ React__default.createElement("path", {
59
+ fillRule: "evenodd",
60
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
61
+ clipRule: "evenodd"
62
+ })), ErrorIcon = /* @__PURE__ */ React__default.createElement("svg", {
63
+ xmlns: "http://www.w3.org/2000/svg",
64
+ viewBox: "0 0 20 20",
65
+ fill: "currentColor",
66
+ height: "20",
67
+ width: "20"
68
+ }, /* @__PURE__ */ React__default.createElement("path", {
69
+ fillRule: "evenodd",
70
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
71
+ clipRule: "evenodd"
72
+ })), CloseIcon = /* @__PURE__ */ React__default.createElement("svg", {
73
+ xmlns: "http://www.w3.org/2000/svg",
74
+ width: "12",
75
+ height: "12",
76
+ viewBox: "0 0 24 24",
77
+ fill: "none",
78
+ stroke: "currentColor",
79
+ strokeWidth: "1.5",
80
+ strokeLinecap: "round",
81
+ strokeLinejoin: "round"
82
+ }, /* @__PURE__ */ React__default.createElement("line", {
83
+ x1: "18",
84
+ y1: "6",
85
+ x2: "6",
86
+ y2: "18"
87
+ }), /* @__PURE__ */ React__default.createElement("line", {
88
+ x1: "6",
89
+ y1: "6",
90
+ x2: "18",
91
+ y2: "18"
92
+ })), useIsDocumentHidden = () => {
93
+ const [isDocumentHidden, setIsDocumentHidden] = React__default.useState(document.hidden);
94
+ return React__default.useEffect(() => {
95
+ const callback = () => {
96
+ setIsDocumentHidden(document.hidden);
97
+ };
98
+ return document.addEventListener("visibilitychange", callback), () => window.removeEventListener("visibilitychange", callback);
99
+ }, []), isDocumentHidden;
100
+ };
101
+ let toastsCounter = 1;
102
+ class Observer {
103
+ constructor() {
104
+ this.subscribe = (subscriber) => (this.subscribers.push(subscriber), () => {
105
+ const index = this.subscribers.indexOf(subscriber);
106
+ this.subscribers.splice(index, 1);
107
+ }), this.publish = (data) => {
108
+ this.subscribers.forEach((subscriber) => subscriber(data));
109
+ }, this.addToast = (data) => {
110
+ this.publish(data), this.toasts = [
111
+ ...this.toasts,
112
+ data
113
+ ];
114
+ }, this.create = (data) => {
115
+ var _data_id;
116
+ const { message, ...rest } = data, id = typeof data?.id == "number" || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++, alreadyExists = this.toasts.find((toast2) => toast2.id === id), dismissible = data.dismissible === void 0 ? !0 : data.dismissible;
117
+ return this.dismissedToasts.has(id) && this.dismissedToasts.delete(id), alreadyExists ? this.toasts = this.toasts.map((toast2) => toast2.id === id ? (this.publish({
118
+ ...toast2,
119
+ ...data,
120
+ id,
121
+ title: message
122
+ }), {
123
+ ...toast2,
124
+ ...data,
125
+ id,
126
+ dismissible,
127
+ title: message
128
+ }) : toast2) : this.addToast({
129
+ title: message,
130
+ ...rest,
131
+ dismissible,
132
+ id
133
+ }), id;
134
+ }, this.dismiss = (id) => (id ? (this.dismissedToasts.add(id), requestAnimationFrame(() => this.subscribers.forEach((subscriber) => subscriber({
135
+ id,
136
+ dismiss: !0
137
+ })))) : this.toasts.forEach((toast2) => {
138
+ this.subscribers.forEach((subscriber) => subscriber({
139
+ id: toast2.id,
140
+ dismiss: !0
141
+ }));
142
+ }), id), this.message = (message, data) => this.create({
143
+ ...data,
144
+ message
145
+ }), this.error = (message, data) => this.create({
146
+ ...data,
147
+ message,
148
+ type: "error"
149
+ }), this.success = (message, data) => this.create({
150
+ ...data,
151
+ type: "success",
152
+ message
153
+ }), this.info = (message, data) => this.create({
154
+ ...data,
155
+ type: "info",
156
+ message
157
+ }), this.warning = (message, data) => this.create({
158
+ ...data,
159
+ type: "warning",
160
+ message
161
+ }), this.loading = (message, data) => this.create({
162
+ ...data,
163
+ type: "loading",
164
+ message
165
+ }), this.promise = (promise, data) => {
166
+ if (!data)
167
+ return;
168
+ let id;
169
+ data.loading !== void 0 && (id = this.create({
170
+ ...data,
171
+ promise,
172
+ type: "loading",
173
+ message: data.loading,
174
+ description: typeof data.description != "function" ? data.description : void 0
175
+ }));
176
+ const p = Promise.resolve(promise instanceof Function ? promise() : promise);
177
+ let shouldDismiss = id !== void 0, result;
178
+ const originalPromise = p.then(async (response) => {
179
+ if (result = [
180
+ "resolve",
181
+ response
182
+ ], React__default.isValidElement(response))
183
+ shouldDismiss = !1, this.create({
184
+ id,
185
+ type: "default",
186
+ message: response
187
+ });
188
+ else if (isHttpResponse(response) && !response.ok) {
189
+ shouldDismiss = !1;
190
+ const promiseData = typeof data.error == "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error, description = typeof data.description == "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description, toastSettings = typeof promiseData == "object" && !React__default.isValidElement(promiseData) ? promiseData : {
191
+ message: promiseData
192
+ };
193
+ this.create({
194
+ id,
195
+ type: "error",
196
+ description,
197
+ ...toastSettings
198
+ });
199
+ } else if (response instanceof Error) {
200
+ shouldDismiss = !1;
201
+ const promiseData = typeof data.error == "function" ? await data.error(response) : data.error, description = typeof data.description == "function" ? await data.description(response) : data.description, toastSettings = typeof promiseData == "object" && !React__default.isValidElement(promiseData) ? promiseData : {
202
+ message: promiseData
203
+ };
204
+ this.create({
205
+ id,
206
+ type: "error",
207
+ description,
208
+ ...toastSettings
209
+ });
210
+ } else if (data.success !== void 0) {
211
+ shouldDismiss = !1;
212
+ const promiseData = typeof data.success == "function" ? await data.success(response) : data.success, description = typeof data.description == "function" ? await data.description(response) : data.description, toastSettings = typeof promiseData == "object" && !React__default.isValidElement(promiseData) ? promiseData : {
213
+ message: promiseData
214
+ };
215
+ this.create({
216
+ id,
217
+ type: "success",
218
+ description,
219
+ ...toastSettings
220
+ });
221
+ }
222
+ }).catch(async (error) => {
223
+ if (result = [
224
+ "reject",
225
+ error
226
+ ], data.error !== void 0) {
227
+ shouldDismiss = !1;
228
+ const promiseData = typeof data.error == "function" ? await data.error(error) : data.error, description = typeof data.description == "function" ? await data.description(error) : data.description, toastSettings = typeof promiseData == "object" && !React__default.isValidElement(promiseData) ? promiseData : {
229
+ message: promiseData
230
+ };
231
+ this.create({
232
+ id,
233
+ type: "error",
234
+ description,
235
+ ...toastSettings
236
+ });
237
+ }
238
+ }).finally(() => {
239
+ shouldDismiss && (this.dismiss(id), id = void 0), data.finally == null || data.finally.call(data);
240
+ }), unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
241
+ return typeof id != "string" && typeof id != "number" ? {
242
+ unwrap
243
+ } : Object.assign(id, {
244
+ unwrap
245
+ });
246
+ }, this.custom = (jsx, data) => {
247
+ const id = data?.id || toastsCounter++;
248
+ return this.create({
249
+ jsx: jsx(id),
250
+ id,
251
+ ...data
252
+ }), id;
253
+ }, this.getActiveToasts = () => this.toasts.filter((toast2) => !this.dismissedToasts.has(toast2.id)), this.subscribers = [], this.toasts = [], this.dismissedToasts = /* @__PURE__ */ new Set();
254
+ }
255
+ }
256
+ const ToastState = new Observer(), toastFunction = (message, data) => {
257
+ const id = data?.id || toastsCounter++;
258
+ return ToastState.addToast({
259
+ title: message,
260
+ ...data,
261
+ id
262
+ }), id;
263
+ }, isHttpResponse = (data) => data && typeof data == "object" && "ok" in data && typeof data.ok == "boolean" && "status" in data && typeof data.status == "number", basicToast = toastFunction, getHistory = () => ToastState.toasts, getToasts = () => ToastState.getActiveToasts(), toast = Object.assign(basicToast, {
264
+ success: ToastState.success,
265
+ info: ToastState.info,
266
+ warning: ToastState.warning,
267
+ error: ToastState.error,
268
+ custom: ToastState.custom,
269
+ message: ToastState.message,
270
+ promise: ToastState.promise,
271
+ dismiss: ToastState.dismiss,
272
+ loading: ToastState.loading
273
+ }, {
274
+ getHistory,
275
+ getToasts
276
+ });
277
+ __insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
278
+ function isAction(action) {
279
+ return action.label !== void 0;
280
+ }
281
+ const VISIBLE_TOASTS_AMOUNT = 3, VIEWPORT_OFFSET = "24px", MOBILE_VIEWPORT_OFFSET = "16px", TOAST_LIFETIME = 4e3, TOAST_WIDTH = 356, GAP = 14, SWIPE_THRESHOLD = 45, TIME_BEFORE_UNMOUNT = 200;
282
+ function cn(...classes) {
283
+ return classes.filter(Boolean).join(" ");
284
+ }
285
+ function getDefaultSwipeDirections(position) {
286
+ const [y, x] = position.split("-"), directions = [];
287
+ return y && directions.push(y), x && directions.push(x), directions;
288
+ }
289
+ const Toast = (props) => {
290
+ var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
291
+ const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props, [swipeDirection, setSwipeDirection] = React__default.useState(null), [swipeOutDirection, setSwipeOutDirection] = React__default.useState(null), [mounted, setMounted] = React__default.useState(!1), [removed, setRemoved] = React__default.useState(!1), [swiping, setSwiping] = React__default.useState(!1), [swipeOut, setSwipeOut] = React__default.useState(!1), [isSwiped, setIsSwiped] = React__default.useState(!1), [offsetBeforeRemove, setOffsetBeforeRemove] = React__default.useState(0), [initialHeight, setInitialHeight] = React__default.useState(0), remainingTime = React__default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME), dragStartTime = React__default.useRef(null), toastRef = React__default.useRef(null), isFront = index === 0, isVisible = index + 1 <= visibleToasts, toastType = toast2.type, dismissible = toast2.dismissible !== !1, toastClassname = toast2.className || "", toastDescriptionClassname = toast2.descriptionClassName || "", heightIndex = React__default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
292
+ heights,
293
+ toast2.id
294
+ ]), closeButton = React__default.useMemo(() => {
295
+ var _toast_closeButton;
296
+ return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
297
+ }, [
298
+ toast2.closeButton,
299
+ closeButtonFromToaster
300
+ ]), duration = React__default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
301
+ toast2.duration,
302
+ durationFromToaster
303
+ ]), closeTimerStartTimeRef = React__default.useRef(0), offset = React__default.useRef(0), lastCloseTimerStartTimeRef = React__default.useRef(0), pointerStartRef = React__default.useRef(null), [y, x] = position.split("-"), toastsHeightBefore = React__default.useMemo(() => heights.reduce((prev, curr, reducerIndex) => reducerIndex >= heightIndex ? prev : prev + curr.height, 0), [
304
+ heights,
305
+ heightIndex
306
+ ]), isDocumentHidden = useIsDocumentHidden(), invert = toast2.invert || ToasterInvert, disabled = toastType === "loading";
307
+ offset.current = React__default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
308
+ heightIndex,
309
+ toastsHeightBefore
310
+ ]), React__default.useEffect(() => {
311
+ remainingTime.current = duration;
312
+ }, [
313
+ duration
314
+ ]), React__default.useEffect(() => {
315
+ setMounted(!0);
316
+ }, []), React__default.useEffect(() => {
317
+ const toastNode = toastRef.current;
318
+ if (toastNode) {
319
+ const height = toastNode.getBoundingClientRect().height;
320
+ return setInitialHeight(height), setHeights((h) => [
321
+ {
322
+ toastId: toast2.id,
323
+ height,
324
+ position: toast2.position
325
+ },
326
+ ...h
327
+ ]), () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
328
+ }
329
+ }, [
330
+ setHeights,
331
+ toast2.id
332
+ ]), React__default.useLayoutEffect(() => {
333
+ if (!mounted) return;
334
+ const toastNode = toastRef.current, originalHeight = toastNode.style.height;
335
+ toastNode.style.height = "auto";
336
+ const newHeight = toastNode.getBoundingClientRect().height;
337
+ toastNode.style.height = originalHeight, setInitialHeight(newHeight), setHeights((heights2) => heights2.find((height) => height.toastId === toast2.id) ? heights2.map((height) => height.toastId === toast2.id ? {
338
+ ...height,
339
+ height: newHeight
340
+ } : height) : [
341
+ {
342
+ toastId: toast2.id,
343
+ height: newHeight,
344
+ position: toast2.position
345
+ },
346
+ ...heights2
347
+ ]);
348
+ }, [
349
+ mounted,
350
+ toast2.title,
351
+ toast2.description,
352
+ setHeights,
353
+ toast2.id,
354
+ toast2.jsx,
355
+ toast2.action,
356
+ toast2.cancel
357
+ ]);
358
+ const deleteToast = React__default.useCallback(() => {
359
+ setRemoved(!0), setOffsetBeforeRemove(offset.current), setHeights((h) => h.filter((height) => height.toastId !== toast2.id)), setTimeout(() => {
360
+ removeToast(toast2);
361
+ }, TIME_BEFORE_UNMOUNT);
362
+ }, [
363
+ toast2,
364
+ removeToast,
365
+ setHeights,
366
+ offset
367
+ ]);
368
+ React__default.useEffect(() => {
369
+ if (toast2.promise && toastType === "loading" || toast2.duration === 1 / 0 || toast2.type === "loading") return;
370
+ let timeoutId;
371
+ return expanded || interacting || isDocumentHidden ? (() => {
372
+ if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
373
+ const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
374
+ remainingTime.current = remainingTime.current - elapsedTime;
375
+ }
376
+ lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
377
+ })() : remainingTime.current !== 1 / 0 && (closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime(), timeoutId = setTimeout(() => {
378
+ toast2.onAutoClose == null || toast2.onAutoClose.call(toast2, toast2), deleteToast();
379
+ }, remainingTime.current)), () => clearTimeout(timeoutId);
380
+ }, [
381
+ expanded,
382
+ interacting,
383
+ toast2,
384
+ toastType,
385
+ isDocumentHidden,
386
+ deleteToast
387
+ ]), React__default.useEffect(() => {
388
+ toast2.delete && (deleteToast(), toast2.onDismiss == null || toast2.onDismiss.call(toast2, toast2));
389
+ }, [
390
+ deleteToast,
391
+ toast2.delete
392
+ ]);
393
+ function getLoadingIcon() {
394
+ var _toast_classNames9;
395
+ if (icons?.loading) {
396
+ var _toast_classNames12;
397
+ return /* @__PURE__ */ React__default.createElement("div", {
398
+ className: cn(classNames?.loader, toast2 == null || (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
399
+ "data-visible": toastType === "loading"
400
+ }, icons.loading);
401
+ }
402
+ return /* @__PURE__ */ React__default.createElement(Loader, {
403
+ className: cn(classNames?.loader, toast2 == null || (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
404
+ visible: toastType === "loading"
405
+ });
406
+ }
407
+ const icon = toast2.icon || icons?.[toastType] || getAsset(toastType);
408
+ var _toast_richColors, _icons_close;
409
+ return /* @__PURE__ */ React__default.createElement("li", {
410
+ tabIndex: 0,
411
+ ref: toastRef,
412
+ className: cn(className, toastClassname, classNames?.toast, toast2 == null || (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames?.default, classNames?.[toastType], toast2 == null || (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastType]),
413
+ "data-sonner-toast": "",
414
+ "data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
415
+ "data-styled": !(toast2.jsx || toast2.unstyled || unstyled),
416
+ "data-mounted": mounted,
417
+ "data-promise": !!toast2.promise,
418
+ "data-swiped": isSwiped,
419
+ "data-removed": removed,
420
+ "data-visible": isVisible,
421
+ "data-y-position": y,
422
+ "data-x-position": x,
423
+ "data-index": index,
424
+ "data-front": isFront,
425
+ "data-swiping": swiping,
426
+ "data-dismissible": dismissible,
427
+ "data-type": toastType,
428
+ "data-invert": invert,
429
+ "data-swipe-out": swipeOut,
430
+ "data-swipe-direction": swipeOutDirection,
431
+ "data-expanded": !!(expanded || expandByDefault && mounted),
432
+ "data-testid": toast2.testId,
433
+ style: {
434
+ "--index": index,
435
+ "--toasts-before": index,
436
+ "--z-index": toasts.length - index,
437
+ "--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
438
+ "--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
439
+ ...style,
440
+ ...toast2.style
441
+ },
442
+ onDragEnd: () => {
443
+ setSwiping(!1), setSwipeDirection(null), pointerStartRef.current = null;
444
+ },
445
+ onPointerDown: (event) => {
446
+ event.button !== 2 && (disabled || !dismissible || (dragStartTime.current = /* @__PURE__ */ new Date(), setOffsetBeforeRemove(offset.current), event.target.setPointerCapture(event.pointerId), event.target.tagName !== "BUTTON" && (setSwiping(!0), pointerStartRef.current = {
447
+ x: event.clientX,
448
+ y: event.clientY
449
+ })));
450
+ },
451
+ onPointerUp: () => {
452
+ var _toastRef_current, _toastRef_current1, _dragStartTime_current;
453
+ if (swipeOut || !dismissible) return;
454
+ pointerStartRef.current = null;
455
+ const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0), swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0), timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime()), swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY, velocity = Math.abs(swipeAmount) / timeTaken;
456
+ if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
457
+ setOffsetBeforeRemove(offset.current), toast2.onDismiss == null || toast2.onDismiss.call(toast2, toast2), setSwipeOutDirection(swipeDirection === "x" ? swipeAmountX > 0 ? "right" : "left" : swipeAmountY > 0 ? "down" : "up"), deleteToast(), setSwipeOut(!0);
458
+ return;
459
+ } else {
460
+ var _toastRef_current2, _toastRef_current3;
461
+ (_toastRef_current2 = toastRef.current) == null || _toastRef_current2.style.setProperty("--swipe-amount-x", "0px"), (_toastRef_current3 = toastRef.current) == null || _toastRef_current3.style.setProperty("--swipe-amount-y", "0px");
462
+ }
463
+ setIsSwiped(!1), setSwiping(!1), setSwipeDirection(null);
464
+ },
465
+ onPointerMove: (event) => {
466
+ var _window_getSelection, _toastRef_current, _toastRef_current1;
467
+ if (!pointerStartRef.current || !dismissible || ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0) return;
468
+ const yDelta = event.clientY - pointerStartRef.current.y, xDelta = event.clientX - pointerStartRef.current.x;
469
+ var _props_swipeDirections;
470
+ const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
471
+ !swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1) && setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
472
+ let swipeAmount = {
473
+ x: 0,
474
+ y: 0
475
+ };
476
+ const getDampening = (delta) => 1 / (1.5 + Math.abs(delta) / 20);
477
+ if (swipeDirection === "y") {
478
+ if (swipeDirections.includes("top") || swipeDirections.includes("bottom"))
479
+ if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0)
480
+ swipeAmount.y = yDelta;
481
+ else {
482
+ const dampenedDelta = yDelta * getDampening(yDelta);
483
+ swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
484
+ }
485
+ } else if (swipeDirection === "x" && (swipeDirections.includes("left") || swipeDirections.includes("right")))
486
+ if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0)
487
+ swipeAmount.x = xDelta;
488
+ else {
489
+ const dampenedDelta = xDelta * getDampening(xDelta);
490
+ swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
491
+ }
492
+ (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) && setIsSwiped(!0), (_toastRef_current = toastRef.current) == null || _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`), (_toastRef_current1 = toastRef.current) == null || _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
493
+ }
494
+ }, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React__default.createElement("button", {
495
+ "aria-label": closeButtonAriaLabel,
496
+ "data-disabled": disabled,
497
+ "data-close-button": !0,
498
+ onClick: disabled || !dismissible ? () => {
499
+ } : () => {
500
+ deleteToast(), toast2.onDismiss == null || toast2.onDismiss.call(toast2, toast2);
501
+ },
502
+ className: cn(classNames?.closeButton, toast2 == null || (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
503
+ }, (_icons_close = icons?.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && (icons?.[toastType] !== null || toast2.icon) ? /* @__PURE__ */ React__default.createElement("div", {
504
+ "data-icon": "",
505
+ className: cn(classNames?.icon, toast2 == null || (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
506
+ }, toast2.promise || toast2.type === "loading" && !toast2.icon ? toast2.icon || getLoadingIcon() : null, toast2.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React__default.createElement("div", {
507
+ "data-content": "",
508
+ className: cn(classNames?.content, toast2 == null || (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
509
+ }, /* @__PURE__ */ React__default.createElement("div", {
510
+ "data-title": "",
511
+ className: cn(classNames?.title, toast2 == null || (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
512
+ }, toast2.jsx ? toast2.jsx : typeof toast2.title == "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ React__default.createElement("div", {
513
+ "data-description": "",
514
+ className: cn(descriptionClassName, toastDescriptionClassname, classNames?.description, toast2 == null || (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
515
+ }, typeof toast2.description == "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ React__default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ React__default.createElement("button", {
516
+ "data-button": !0,
517
+ "data-cancel": !0,
518
+ style: toast2.cancelButtonStyle || cancelButtonStyle,
519
+ onClick: (event) => {
520
+ isAction(toast2.cancel) && dismissible && (toast2.cancel.onClick == null || toast2.cancel.onClick.call(toast2.cancel, event), deleteToast());
521
+ },
522
+ className: cn(classNames?.cancelButton, toast2 == null || (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
523
+ }, toast2.cancel.label) : null, /* @__PURE__ */ React__default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ React__default.createElement("button", {
524
+ "data-button": !0,
525
+ "data-action": !0,
526
+ style: toast2.actionButtonStyle || actionButtonStyle,
527
+ onClick: (event) => {
528
+ isAction(toast2.action) && (toast2.action.onClick == null || toast2.action.onClick.call(toast2.action, event), !event.defaultPrevented && deleteToast());
529
+ },
530
+ className: cn(classNames?.actionButton, toast2 == null || (_toast_classNames8 = toast2.classNames) == null ? void 0 : _toast_classNames8.actionButton)
531
+ }, toast2.action.label) : null);
532
+ };
533
+ function getDocumentDirection() {
534
+ if (typeof window > "u" || typeof document > "u") return "ltr";
535
+ const dirAttribute = document.documentElement.getAttribute("dir");
536
+ return dirAttribute === "auto" || !dirAttribute ? window.getComputedStyle(document.documentElement).direction : dirAttribute;
537
+ }
538
+ function assignOffset(defaultOffset, mobileOffset) {
539
+ const styles = {};
540
+ return [
541
+ defaultOffset,
542
+ mobileOffset
543
+ ].forEach((offset, index) => {
544
+ const isMobile = index === 1, prefix = isMobile ? "--mobile-offset" : "--offset", defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
545
+ function assignAll(offset2) {
546
+ [
547
+ "top",
548
+ "right",
549
+ "bottom",
550
+ "left"
551
+ ].forEach((key) => {
552
+ styles[`${prefix}-${key}`] = typeof offset2 == "number" ? `${offset2}px` : offset2;
553
+ });
554
+ }
555
+ typeof offset == "number" || typeof offset == "string" ? assignAll(offset) : typeof offset == "object" ? [
556
+ "top",
557
+ "right",
558
+ "bottom",
559
+ "left"
560
+ ].forEach((key) => {
561
+ offset[key] === void 0 ? styles[`${prefix}-${key}`] = defaultValue : styles[`${prefix}-${key}`] = typeof offset[key] == "number" ? `${offset[key]}px` : offset[key];
562
+ }) : assignAll(defaultValue);
563
+ }), styles;
564
+ }
565
+ const Toaster = /* @__PURE__ */ React__default.forwardRef(function(props, ref) {
566
+ const { id, invert, position = "bottom-right", hotkey = [
567
+ "altKey",
568
+ "KeyT"
569
+ ], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props, [toasts, setToasts] = React__default.useState([]), filteredToasts = React__default.useMemo(() => id ? toasts.filter((toast2) => toast2.toasterId === id) : toasts.filter((toast2) => !toast2.toasterId), [
570
+ toasts,
571
+ id
572
+ ]), possiblePositions = React__default.useMemo(() => Array.from(new Set([
573
+ position
574
+ ].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position)))), [
575
+ filteredToasts,
576
+ position
577
+ ]), [heights, setHeights] = React__default.useState([]), [expanded, setExpanded] = React__default.useState(!1), [interacting, setInteracting] = React__default.useState(!1), [actualTheme, setActualTheme] = React__default.useState(theme !== "system" ? theme : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), listRef = React__default.useRef(null), hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, ""), lastFocusedElementRef = React__default.useRef(null), isFocusWithinRef = React__default.useRef(!1), removeToast = React__default.useCallback((toastToRemove) => {
578
+ setToasts((toasts2) => {
579
+ var _toasts_find;
580
+ return (_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) != null && _toasts_find.delete || ToastState.dismiss(toastToRemove.id), toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
581
+ });
582
+ }, []);
583
+ return React__default.useEffect(() => ToastState.subscribe((toast2) => {
584
+ if (toast2.dismiss) {
585
+ requestAnimationFrame(() => {
586
+ setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
587
+ ...t,
588
+ delete: !0
589
+ } : t));
590
+ });
591
+ return;
592
+ }
593
+ setTimeout(() => {
594
+ ReactDOM.flushSync(() => {
595
+ setToasts((toasts2) => {
596
+ const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
597
+ return indexOfExistingToast !== -1 ? [
598
+ ...toasts2.slice(0, indexOfExistingToast),
599
+ {
600
+ ...toasts2[indexOfExistingToast],
601
+ ...toast2
602
+ },
603
+ ...toasts2.slice(indexOfExistingToast + 1)
604
+ ] : [
605
+ toast2,
606
+ ...toasts2
607
+ ];
608
+ });
609
+ });
610
+ });
611
+ }), [
612
+ toasts
613
+ ]), React__default.useEffect(() => {
614
+ if (theme !== "system") {
615
+ setActualTheme(theme);
616
+ return;
617
+ }
618
+ if (theme === "system" && (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? setActualTheme("dark") : setActualTheme("light")), typeof window > "u") return;
619
+ const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
620
+ try {
621
+ darkMediaQuery.addEventListener("change", ({ matches }) => {
622
+ setActualTheme(matches ? "dark" : "light");
623
+ });
624
+ } catch {
625
+ darkMediaQuery.addListener(({ matches }) => {
626
+ try {
627
+ setActualTheme(matches ? "dark" : "light");
628
+ } catch (e) {
629
+ console.error(e);
630
+ }
631
+ });
632
+ }
633
+ }, [
634
+ theme
635
+ ]), React__default.useEffect(() => {
636
+ toasts.length <= 1 && setExpanded(!1);
637
+ }, [
638
+ toasts
639
+ ]), React__default.useEffect(() => {
640
+ const handleKeyDown = (event) => {
641
+ var _listRef_current;
642
+ if (hotkey.every((key) => event[key] || event.code === key)) {
643
+ var _listRef_current1;
644
+ setExpanded(!0), (_listRef_current1 = listRef.current) == null || _listRef_current1.focus();
645
+ }
646
+ event.code === "Escape" && (document.activeElement === listRef.current || (_listRef_current = listRef.current) != null && _listRef_current.contains(document.activeElement)) && setExpanded(!1);
647
+ };
648
+ return document.addEventListener("keydown", handleKeyDown), () => document.removeEventListener("keydown", handleKeyDown);
649
+ }, [
650
+ hotkey
651
+ ]), React__default.useEffect(() => {
652
+ if (listRef.current)
653
+ return () => {
654
+ lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
655
+ preventScroll: !0
656
+ }), lastFocusedElementRef.current = null, isFocusWithinRef.current = !1);
657
+ };
658
+ }, [
659
+ listRef.current
660
+ ]), // Remove item from normal navigation flow, only available via hotkey
661
+ /* @__PURE__ */ React__default.createElement("section", {
662
+ ref,
663
+ "aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
664
+ tabIndex: -1,
665
+ "aria-live": "polite",
666
+ "aria-relevant": "additions text",
667
+ "aria-atomic": "false",
668
+ suppressHydrationWarning: !0
669
+ }, possiblePositions.map((position2, index) => {
670
+ var _heights_;
671
+ const [y, x] = position2.split("-");
672
+ return filteredToasts.length ? /* @__PURE__ */ React__default.createElement("ol", {
673
+ key: position2,
674
+ dir: dir === "auto" ? getDocumentDirection() : dir,
675
+ tabIndex: -1,
676
+ ref: listRef,
677
+ className,
678
+ "data-sonner-toaster": !0,
679
+ "data-sonner-theme": actualTheme,
680
+ "data-y-position": y,
681
+ "data-x-position": x,
682
+ style: {
683
+ "--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
684
+ "--width": `${TOAST_WIDTH}px`,
685
+ "--gap": `${gap}px`,
686
+ ...style,
687
+ ...assignOffset(offset, mobileOffset)
688
+ },
689
+ onBlur: (event) => {
690
+ isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget) && (isFocusWithinRef.current = !1, lastFocusedElementRef.current && (lastFocusedElementRef.current.focus({
691
+ preventScroll: !0
692
+ }), lastFocusedElementRef.current = null));
693
+ },
694
+ onFocus: (event) => {
695
+ event.target instanceof HTMLElement && event.target.dataset.dismissible === "false" || isFocusWithinRef.current || (isFocusWithinRef.current = !0, lastFocusedElementRef.current = event.relatedTarget);
696
+ },
697
+ onMouseEnter: () => setExpanded(!0),
698
+ onMouseMove: () => setExpanded(!0),
699
+ onMouseLeave: () => {
700
+ interacting || setExpanded(!1);
701
+ },
702
+ onDragEnd: () => setExpanded(!1),
703
+ onPointerDown: (event) => {
704
+ event.target instanceof HTMLElement && event.target.dataset.dismissible === "false" || setInteracting(!0);
705
+ },
706
+ onPointerUp: () => setInteracting(!1)
707
+ }, filteredToasts.filter((toast2) => !toast2.position && index === 0 || toast2.position === position2).map((toast2, index2) => {
708
+ var _toastOptions_duration, _toastOptions_closeButton;
709
+ return /* @__PURE__ */ React__default.createElement(Toast, {
710
+ key: toast2.id,
711
+ icons,
712
+ index: index2,
713
+ toast: toast2,
714
+ defaultRichColors: richColors,
715
+ duration: (_toastOptions_duration = toastOptions?.duration) != null ? _toastOptions_duration : duration,
716
+ className: toastOptions?.className,
717
+ descriptionClassName: toastOptions?.descriptionClassName,
718
+ invert,
719
+ visibleToasts,
720
+ closeButton: (_toastOptions_closeButton = toastOptions?.closeButton) != null ? _toastOptions_closeButton : closeButton,
721
+ interacting,
722
+ position: position2,
723
+ style: toastOptions?.style,
724
+ unstyled: toastOptions?.unstyled,
725
+ classNames: toastOptions?.classNames,
726
+ cancelButtonStyle: toastOptions?.cancelButtonStyle,
727
+ actionButtonStyle: toastOptions?.actionButtonStyle,
728
+ closeButtonAriaLabel: toastOptions?.closeButtonAriaLabel,
729
+ removeToast,
730
+ toasts: filteredToasts.filter((t) => t.position == toast2.position),
731
+ heights: heights.filter((h) => h.position == toast2.position),
732
+ setHeights,
733
+ expandByDefault: expand,
734
+ gap,
735
+ expanded,
736
+ swipeDirections: props.swipeDirections
737
+ });
738
+ })) : null;
739
+ }));
740
+ });
741
+ export {
742
+ Toaster,
743
+ toast
744
+ };