@alquimia-ai/ui 1.9.2 → 2.0.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 (78) hide show
  1. package/dist/components/atoms/index.d.mts +1 -1
  2. package/dist/components/atoms/index.d.ts +1 -1
  3. package/dist/components/atoms/index.js +1848 -1428
  4. package/dist/components/atoms/index.js.map +1 -1
  5. package/dist/components/atoms/index.mjs +1453 -1409
  6. package/dist/components/atoms/index.mjs.map +1 -1
  7. package/dist/components/hooks/index.d.mts +1 -0
  8. package/dist/components/hooks/index.d.ts +1 -0
  9. package/dist/components/hooks/index.js +572 -211
  10. package/dist/components/hooks/index.js.map +1 -1
  11. package/dist/components/hooks/index.mjs +505 -193
  12. package/dist/components/hooks/index.mjs.map +1 -1
  13. package/dist/components/molecules/documents/index.d.mts +1 -0
  14. package/dist/components/molecules/documents/index.d.ts +1 -0
  15. package/dist/components/molecules/documents/index.js +2366 -1884
  16. package/dist/components/molecules/documents/index.js.map +1 -1
  17. package/dist/components/molecules/documents/index.mjs +2207 -1764
  18. package/dist/components/molecules/documents/index.mjs.map +1 -1
  19. package/dist/components/molecules/index.js +2261 -2095
  20. package/dist/components/molecules/index.js.map +1 -1
  21. package/dist/components/molecules/index.mjs +2084 -2075
  22. package/dist/components/molecules/index.mjs.map +1 -1
  23. package/dist/components/molecules/viewers/index.js +1303 -1185
  24. package/dist/components/molecules/viewers/index.js.map +1 -1
  25. package/dist/components/molecules/viewers/index.mjs +1254 -1167
  26. package/dist/components/molecules/viewers/index.mjs.map +1 -1
  27. package/dist/components/organisms/index.d.mts +1 -0
  28. package/dist/components/organisms/index.d.ts +1 -0
  29. package/dist/components/organisms/index.js +3074 -2609
  30. package/dist/components/organisms/index.js.map +1 -1
  31. package/dist/components/organisms/index.mjs +2999 -2586
  32. package/dist/components/organisms/index.mjs.map +1 -1
  33. package/dist/components/templates/index.d.mts +25 -3
  34. package/dist/components/templates/index.d.ts +25 -3
  35. package/dist/components/templates/index.js +1490 -1300
  36. package/dist/components/templates/index.js.map +1 -1
  37. package/dist/components/templates/index.mjs +1413 -1281
  38. package/dist/components/templates/index.mjs.map +1 -1
  39. package/dist/index.d.mts +4 -3
  40. package/dist/index.d.ts +4 -3
  41. package/dist/index.js +3951 -2977
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +3368 -2950
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/lib/index.js +106 -54
  46. package/dist/lib/index.js.map +1 -1
  47. package/dist/lib/index.mjs +42 -43
  48. package/dist/lib/index.mjs.map +1 -1
  49. package/dist/providers/index.d.mts +17 -0
  50. package/dist/providers/index.d.ts +17 -0
  51. package/dist/providers/index.js +177 -0
  52. package/dist/providers/index.js.map +1 -0
  53. package/dist/providers/index.mjs +101 -0
  54. package/dist/providers/index.mjs.map +1 -0
  55. package/dist/styles.css +68 -0
  56. package/dist/styles.css.map +1 -0
  57. package/dist/styles.d.mts +2 -0
  58. package/dist/styles.d.ts +2 -0
  59. package/dist/tailwind.config.js +4 -10
  60. package/dist/types/index.d.mts +5 -5
  61. package/dist/types/index.d.ts +5 -5
  62. package/dist/types/index.js +52 -19
  63. package/dist/types/index.js.map +1 -1
  64. package/dist/types/index.mjs +6 -8
  65. package/dist/types/index.mjs.map +1 -1
  66. package/package.json +8 -7
  67. package/dist/components/index.d.mts +0 -23
  68. package/dist/components/index.d.ts +0 -23
  69. package/dist/components/index.js +0 -1734
  70. package/dist/components/index.js.map +0 -1
  71. package/dist/components/index.mjs +0 -1702
  72. package/dist/components/index.mjs.map +0 -1
  73. package/dist/components/templates/cards/index.d.mts +0 -26
  74. package/dist/components/templates/cards/index.d.ts +0 -26
  75. package/dist/components/templates/cards/index.js +0 -1536
  76. package/dist/components/templates/cards/index.js.map +0 -1
  77. package/dist/components/templates/cards/index.mjs +0 -1504
  78. package/dist/components/templates/cards/index.mjs.map +0 -1
@@ -1,220 +1,532 @@
1
1
  "use client";
2
2
  // src/components/hooks/use-toast.ts
3
+ function _array_like_to_array(arr, len) {
4
+ if (len == null || len > arr.length) len = arr.length;
5
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6
+ return arr2;
7
+ }
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr)) return arr;
10
+ }
11
+ function _array_without_holes(arr) {
12
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
13
+ }
14
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
15
+ try {
16
+ var info = gen[key](arg);
17
+ var value = info.value;
18
+ } catch (error) {
19
+ reject(error);
20
+ return;
21
+ }
22
+ if (info.done) {
23
+ resolve(value);
24
+ } else {
25
+ Promise.resolve(value).then(_next, _throw);
26
+ }
27
+ }
28
+ function _async_to_generator(fn) {
29
+ return function() {
30
+ var self = this, args = arguments;
31
+ return new Promise(function(resolve, reject) {
32
+ var gen = fn.apply(self, args);
33
+ function _next(value) {
34
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
35
+ }
36
+ function _throw(err) {
37
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
38
+ }
39
+ _next(undefined);
40
+ });
41
+ };
42
+ }
43
+ function _define_property(obj, key, value) {
44
+ if (key in obj) {
45
+ Object.defineProperty(obj, key, {
46
+ value: value,
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true
50
+ });
51
+ } else {
52
+ obj[key] = value;
53
+ }
54
+ return obj;
55
+ }
56
+ function _extends() {
57
+ _extends = Object.assign || function(target) {
58
+ for(var i = 1; i < arguments.length; i++){
59
+ var source = arguments[i];
60
+ for(var key in source){
61
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
62
+ target[key] = source[key];
63
+ }
64
+ }
65
+ }
66
+ return target;
67
+ };
68
+ return _extends.apply(this, arguments);
69
+ }
70
+ function _iterable_to_array(iter) {
71
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
72
+ }
73
+ function _iterable_to_array_limit(arr, i) {
74
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
75
+ if (_i == null) return;
76
+ var _arr = [];
77
+ var _n = true;
78
+ var _d = false;
79
+ var _s, _e;
80
+ try {
81
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
82
+ _arr.push(_s.value);
83
+ if (i && _arr.length === i) break;
84
+ }
85
+ } catch (err) {
86
+ _d = true;
87
+ _e = err;
88
+ } finally{
89
+ try {
90
+ if (!_n && _i["return"] != null) _i["return"]();
91
+ } finally{
92
+ if (_d) throw _e;
93
+ }
94
+ }
95
+ return _arr;
96
+ }
97
+ function _non_iterable_rest() {
98
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
99
+ }
100
+ function _non_iterable_spread() {
101
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
102
+ }
103
+ function _object_destructuring_empty(o) {
104
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
105
+ return o;
106
+ }
107
+ function _object_spread(target) {
108
+ for(var i = 1; i < arguments.length; i++){
109
+ var source = arguments[i] != null ? arguments[i] : {};
110
+ var ownKeys = Object.keys(source);
111
+ if (typeof Object.getOwnPropertySymbols === "function") {
112
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
113
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
114
+ }));
115
+ }
116
+ ownKeys.forEach(function(key) {
117
+ _define_property(target, key, source[key]);
118
+ });
119
+ }
120
+ return target;
121
+ }
122
+ function ownKeys(object, enumerableOnly) {
123
+ var keys = Object.keys(object);
124
+ if (Object.getOwnPropertySymbols) {
125
+ var symbols = Object.getOwnPropertySymbols(object);
126
+ if (enumerableOnly) {
127
+ symbols = symbols.filter(function(sym) {
128
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
129
+ });
130
+ }
131
+ keys.push.apply(keys, symbols);
132
+ }
133
+ return keys;
134
+ }
135
+ function _object_spread_props(target, source) {
136
+ source = source != null ? source : {};
137
+ if (Object.getOwnPropertyDescriptors) {
138
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
139
+ } else {
140
+ ownKeys(Object(source)).forEach(function(key) {
141
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
142
+ });
143
+ }
144
+ return target;
145
+ }
146
+ function _sliced_to_array(arr, i) {
147
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
148
+ }
149
+ function _to_consumable_array(arr) {
150
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
151
+ }
152
+ function _unsupported_iterable_to_array(o, minLen) {
153
+ if (!o) return;
154
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
155
+ var n = Object.prototype.toString.call(o).slice(8, -1);
156
+ if (n === "Object" && o.constructor) n = o.constructor.name;
157
+ if (n === "Map" || n === "Set") return Array.from(n);
158
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
159
+ }
160
+ function _ts_generator(thisArg, body) {
161
+ var f, y, t, g, _ = {
162
+ label: 0,
163
+ sent: function() {
164
+ if (t[0] & 1) throw t[1];
165
+ return t[1];
166
+ },
167
+ trys: [],
168
+ ops: []
169
+ };
170
+ return g = {
171
+ next: verb(0),
172
+ "throw": verb(1),
173
+ "return": verb(2)
174
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
175
+ return this;
176
+ }), g;
177
+ function verb(n) {
178
+ return function(v) {
179
+ return step([
180
+ n,
181
+ v
182
+ ]);
183
+ };
184
+ }
185
+ function step(op) {
186
+ if (f) throw new TypeError("Generator is already executing.");
187
+ while(_)try {
188
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
189
+ if (y = 0, t) op = [
190
+ op[0] & 2,
191
+ t.value
192
+ ];
193
+ switch(op[0]){
194
+ case 0:
195
+ case 1:
196
+ t = op;
197
+ break;
198
+ case 4:
199
+ _.label++;
200
+ return {
201
+ value: op[1],
202
+ done: false
203
+ };
204
+ case 5:
205
+ _.label++;
206
+ y = op[1];
207
+ op = [
208
+ 0
209
+ ];
210
+ continue;
211
+ case 7:
212
+ op = _.ops.pop();
213
+ _.trys.pop();
214
+ continue;
215
+ default:
216
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
217
+ _ = 0;
218
+ continue;
219
+ }
220
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
221
+ _.label = op[1];
222
+ break;
223
+ }
224
+ if (op[0] === 6 && _.label < t[1]) {
225
+ _.label = t[1];
226
+ t = op;
227
+ break;
228
+ }
229
+ if (t && _.label < t[2]) {
230
+ _.label = t[2];
231
+ _.ops.push(op);
232
+ break;
233
+ }
234
+ if (t[2]) _.ops.pop();
235
+ _.trys.pop();
236
+ continue;
237
+ }
238
+ op = body.call(thisArg, _);
239
+ } catch (e) {
240
+ op = [
241
+ 6,
242
+ e
243
+ ];
244
+ y = 0;
245
+ } finally{
246
+ f = t = 0;
247
+ }
248
+ if (op[0] & 5) throw op[1];
249
+ return {
250
+ value: op[0] ? op[1] : void 0,
251
+ done: true
252
+ };
253
+ }
254
+ }
3
255
  import * as React from "react";
4
256
  var TOAST_LIMIT = 1;
5
257
  var TOAST_REMOVE_DELAY = 1e6;
6
258
  var count = 0;
7
259
  function genId() {
8
- count = (count + 1) % Number.MAX_SAFE_INTEGER;
9
- return count.toString();
260
+ count = (count + 1) % Number.MAX_SAFE_INTEGER;
261
+ return count.toString();
10
262
  }
11
263
  var toastTimeouts = /* @__PURE__ */ new Map();
12
- var addToRemoveQueue = (toastId) => {
13
- if (toastTimeouts.has(toastId)) {
14
- return;
15
- }
16
- const timeout = setTimeout(() => {
17
- toastTimeouts.delete(toastId);
18
- dispatch({
19
- type: "REMOVE_TOAST",
20
- toastId
21
- });
22
- }, TOAST_REMOVE_DELAY);
23
- toastTimeouts.set(toastId, timeout);
24
- };
25
- var reducer = (state, action) => {
26
- switch (action.type) {
27
- case "ADD_TOAST":
28
- return {
29
- ...state,
30
- toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
31
- };
32
- case "UPDATE_TOAST":
33
- return {
34
- ...state,
35
- toasts: state.toasts.map(
36
- (t) => t.id === action.toast.id ? { ...t, ...action.toast } : t
37
- )
38
- };
39
- case "DISMISS_TOAST": {
40
- const { toastId } = action;
41
- if (toastId) {
42
- addToRemoveQueue(toastId);
43
- } else {
44
- state.toasts.forEach((toast2) => {
45
- addToRemoveQueue(toast2.id);
264
+ var addToRemoveQueue = function(toastId) {
265
+ if (toastTimeouts.has(toastId)) {
266
+ return;
267
+ }
268
+ var timeout = setTimeout(function() {
269
+ toastTimeouts.delete(toastId);
270
+ dispatch({
271
+ type: "REMOVE_TOAST",
272
+ toastId: toastId
46
273
  });
47
- }
48
- return {
49
- ...state,
50
- toasts: state.toasts.map(
51
- (t) => t.id === toastId || toastId === void 0 ? {
52
- ...t,
53
- open: false
54
- } : t
55
- )
56
- };
274
+ }, TOAST_REMOVE_DELAY);
275
+ toastTimeouts.set(toastId, timeout);
276
+ };
277
+ var reducer = function(state, action) {
278
+ switch(action.type){
279
+ case "ADD_TOAST":
280
+ return _object_spread_props(_object_spread({}, state), {
281
+ toasts: [
282
+ action.toast
283
+ ].concat(_to_consumable_array(state.toasts)).slice(0, TOAST_LIMIT)
284
+ });
285
+ case "UPDATE_TOAST":
286
+ return _object_spread_props(_object_spread({}, state), {
287
+ toasts: state.toasts.map(function(t) {
288
+ return t.id === action.toast.id ? _object_spread({}, t, action.toast) : t;
289
+ })
290
+ });
291
+ case "DISMISS_TOAST":
292
+ {
293
+ var toastId = action.toastId;
294
+ if (toastId) {
295
+ addToRemoveQueue(toastId);
296
+ } else {
297
+ state.toasts.forEach(function(toast2) {
298
+ addToRemoveQueue(toast2.id);
299
+ });
300
+ }
301
+ return _object_spread_props(_object_spread({}, state), {
302
+ toasts: state.toasts.map(function(t) {
303
+ return t.id === toastId || toastId === void 0 ? _object_spread_props(_object_spread({}, t), {
304
+ open: false
305
+ }) : t;
306
+ })
307
+ });
308
+ }
309
+ case "REMOVE_TOAST":
310
+ if (action.toastId === void 0) {
311
+ return _object_spread_props(_object_spread({}, state), {
312
+ toasts: []
313
+ });
314
+ }
315
+ return _object_spread_props(_object_spread({}, state), {
316
+ toasts: state.toasts.filter(function(t) {
317
+ return t.id !== action.toastId;
318
+ })
319
+ });
57
320
  }
58
- case "REMOVE_TOAST":
59
- if (action.toastId === void 0) {
60
- return {
61
- ...state,
62
- toasts: []
63
- };
64
- }
65
- return {
66
- ...state,
67
- toasts: state.toasts.filter((t) => t.id !== action.toastId)
68
- };
69
- }
70
321
  };
71
322
  var listeners = [];
72
- var memoryState = { toasts: [] };
323
+ var memoryState = {
324
+ toasts: []
325
+ };
73
326
  function dispatch(action) {
74
- memoryState = reducer(memoryState, action);
75
- listeners.forEach((listener) => {
76
- listener(memoryState);
77
- });
78
- }
79
- function toast({ ...props }) {
80
- const id = genId();
81
- const update = (props2) => dispatch({
82
- type: "UPDATE_TOAST",
83
- toast: { ...props2, id }
84
- });
85
- const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
86
- dispatch({
87
- type: "ADD_TOAST",
88
- toast: {
89
- ...props,
90
- id,
91
- open: true,
92
- onOpenChange: (open) => {
93
- if (!open) dismiss();
94
- }
95
- }
96
- });
97
- return {
98
- id,
99
- dismiss,
100
- update
101
- };
327
+ memoryState = reducer(memoryState, action);
328
+ listeners.forEach(function(listener) {
329
+ listener(memoryState);
330
+ });
102
331
  }
103
- function useToast() {
104
- const [state, setState] = React.useState(memoryState);
105
- React.useEffect(() => {
106
- listeners.push(setState);
107
- return () => {
108
- const index = listeners.indexOf(setState);
109
- if (index > -1) {
110
- listeners.splice(index, 1);
111
- }
332
+ function toast(_param) {
333
+ var props = _extends({}, _object_destructuring_empty(_param));
334
+ var id = genId();
335
+ var update = function(props2) {
336
+ return dispatch({
337
+ type: "UPDATE_TOAST",
338
+ toast: _object_spread_props(_object_spread({}, props2), {
339
+ id: id
340
+ })
341
+ });
342
+ };
343
+ var dismiss = function() {
344
+ return dispatch({
345
+ type: "DISMISS_TOAST",
346
+ toastId: id
347
+ });
112
348
  };
113
- }, [state]);
114
- return {
115
- ...state,
116
- toast,
117
- dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId })
118
- };
119
- }
120
-
349
+ dispatch({
350
+ type: "ADD_TOAST",
351
+ toast: _object_spread_props(_object_spread({}, props), {
352
+ id: id,
353
+ open: true,
354
+ onOpenChange: function(open) {
355
+ if (!open) dismiss();
356
+ }
357
+ })
358
+ });
359
+ return {
360
+ id: id,
361
+ dismiss: dismiss,
362
+ update: update
363
+ };
364
+ }
365
+ function useToast() {
366
+ var _React_useState = _sliced_to_array(React.useState(memoryState), 2), state = _React_useState[0], setState = _React_useState[1];
367
+ React.useEffect(function() {
368
+ listeners.push(setState);
369
+ return function() {
370
+ var index = listeners.indexOf(setState);
371
+ if (index > -1) {
372
+ listeners.splice(index, 1);
373
+ }
374
+ };
375
+ }, [
376
+ state
377
+ ]);
378
+ return _object_spread_props(_object_spread({}, state), {
379
+ toast: toast,
380
+ dismiss: function(toastId) {
381
+ return dispatch({
382
+ type: "DISMISS_TOAST",
383
+ toastId: toastId
384
+ });
385
+ }
386
+ });
387
+ }
121
388
  // src/components/hooks/use-document.tsx
122
389
  import { useState as useState2 } from "react";
123
- var useDocumentReader = (url, getDocument) => {
124
- const [loading, setLoading] = useState2(true);
125
- const [error, setError] = useState2(null);
126
- const [document, setDocument] = useState2(null);
127
- const handleDocumentError = (error2) => {
128
- const errorMessage = "Hubo un error al obtener el documento. Por favor ponganse en contacto con el administrador.";
129
- setError(errorMessage);
130
- throw new Error(error2?.message || "Unknown error");
131
- };
132
- const resetDocument = () => {
133
- setDocument(null);
134
- };
135
- const fetchDocument = async () => {
136
- setLoading(true);
137
- setError(null);
138
- try {
139
- const res = await getDocument(url);
140
- if (!res.success) {
141
- handleDocumentError(res.error || new Error("Unknown error"));
142
- setLoading(false);
143
- return;
144
- }
145
- res.data && setDocument(res.data);
146
- } catch (error2) {
147
- handleDocumentError(error2);
148
- } finally {
149
- setLoading(false);
150
- }
151
- };
152
- return { document, loading, fetchDocument, resetDocument, error };
390
+ var useDocumentReader = function(url, getDocument) {
391
+ var _useState2 = _sliced_to_array(useState2(true), 2), loading = _useState2[0], setLoading = _useState2[1];
392
+ var _useState21 = _sliced_to_array(useState2(null), 2), error = _useState21[0], setError = _useState21[1];
393
+ var _useState22 = _sliced_to_array(useState2(null), 2), document = _useState22[0], setDocument = _useState22[1];
394
+ var handleDocumentError = function(error2) {
395
+ var errorMessage = "Hubo un error al obtener el documento. Por favor ponganse en contacto con el administrador.";
396
+ setError(errorMessage);
397
+ throw new Error((error2 === null || error2 === void 0 ? void 0 : error2.message) || "Unknown error");
398
+ };
399
+ var resetDocument = function() {
400
+ setDocument(null);
401
+ };
402
+ var fetchDocument = /*#__PURE__*/ function() {
403
+ var _ref = _async_to_generator(function() {
404
+ var res, error2;
405
+ return _ts_generator(this, function(_state) {
406
+ switch(_state.label){
407
+ case 0:
408
+ setLoading(true);
409
+ setError(null);
410
+ _state.label = 1;
411
+ case 1:
412
+ _state.trys.push([
413
+ 1,
414
+ 3,
415
+ 4,
416
+ 5
417
+ ]);
418
+ return [
419
+ 4,
420
+ getDocument(url)
421
+ ];
422
+ case 2:
423
+ res = _state.sent();
424
+ if (!res.success) {
425
+ handleDocumentError(res.error || new Error("Unknown error"));
426
+ setLoading(false);
427
+ return [
428
+ 2
429
+ ];
430
+ }
431
+ res.data && setDocument(res.data);
432
+ return [
433
+ 3,
434
+ 5
435
+ ];
436
+ case 3:
437
+ error2 = _state.sent();
438
+ handleDocumentError(error2);
439
+ return [
440
+ 3,
441
+ 5
442
+ ];
443
+ case 4:
444
+ setLoading(false);
445
+ return [
446
+ 7
447
+ ];
448
+ case 5:
449
+ return [
450
+ 2
451
+ ];
452
+ }
453
+ });
454
+ });
455
+ return function fetchDocument() {
456
+ return _ref.apply(this, arguments);
457
+ };
458
+ }();
459
+ return {
460
+ document: document,
461
+ loading: loading,
462
+ fetchDocument: fetchDocument,
463
+ resetDocument: resetDocument,
464
+ error: error
465
+ };
153
466
  };
154
-
155
467
  // src/components/hooks/use-resize-observer.ts
156
468
  import { useEffect as useEffect2, useRef } from "react";
157
-
158
469
  // src/components/hooks/use-text-streaming.ts
159
470
  import { useState as useState3, useEffect as useEffect3, useRef as useRef2, useCallback } from "react";
160
471
  var CHAR_DELAY = 15;
161
472
  var PUNCTUATION_DELAY = 300;
162
473
  function useTextStreaming(content, shouldStream, handleIsTextStreaming) {
163
- const [displayedText, setDisplayedText] = useState3("");
164
- const contentRef = useRef2(content);
165
- const indexRef = useRef2(0);
166
- const timerRef = useRef2(null);
167
- const hasStartedStreaming = useRef2(false);
168
- useEffect3(() => {
169
- contentRef.current = content;
170
- if (hasStartedStreaming.current && !timerRef.current && indexRef.current < contentRef.current.length) {
171
- typeNext();
172
- }
173
- }, [content]);
174
- const typeNext = useCallback(() => {
175
- if (indexRef.current < contentRef.current.length) {
176
- const nextChar = contentRef.current.charAt(indexRef.current);
177
- setDisplayedText((prev) => prev + nextChar);
178
- indexRef.current++;
179
- const delay = /[.!?;:]/.test(nextChar) ? PUNCTUATION_DELAY : CHAR_DELAY;
180
- timerRef.current = setTimeout(() => {
181
- timerRef.current = null;
182
- typeNext();
183
- }, delay);
184
- } else {
185
- handleIsTextStreaming?.(false);
186
- }
187
- }, []);
188
- useEffect3(() => {
189
- if (!shouldStream && !hasStartedStreaming.current) {
190
- setDisplayedText(contentRef.current);
191
- indexRef.current = contentRef.current.length;
192
- if (timerRef.current) {
193
- clearTimeout(timerRef.current);
194
- timerRef.current = null;
195
- }
196
- handleIsTextStreaming?.(false);
197
- } else {
198
- if (indexRef.current < contentRef.current.length && !timerRef.current) {
199
- handleIsTextStreaming?.(true);
200
- hasStartedStreaming.current = true;
201
- typeNext();
202
- }
203
- }
204
- return () => {
205
- if (timerRef.current) {
206
- clearTimeout(timerRef.current);
207
- timerRef.current = null;
208
- }
209
- };
210
- }, [shouldStream, typeNext]);
211
- return displayedText;
212
- }
213
- export {
214
- reducer,
215
- toast,
216
- useDocumentReader,
217
- useTextStreaming,
218
- useToast
219
- };
474
+ var _useState3 = _sliced_to_array(useState3(""), 2), displayedText = _useState3[0], setDisplayedText = _useState3[1];
475
+ var contentRef = useRef2(content);
476
+ var indexRef = useRef2(0);
477
+ var timerRef = useRef2(null);
478
+ var hasStartedStreaming = useRef2(false);
479
+ useEffect3(function() {
480
+ contentRef.current = content;
481
+ if (hasStartedStreaming.current && !timerRef.current && indexRef.current < contentRef.current.length) {
482
+ typeNext();
483
+ }
484
+ }, [
485
+ content
486
+ ]);
487
+ var typeNext = useCallback(function() {
488
+ if (indexRef.current < contentRef.current.length) {
489
+ var nextChar = contentRef.current.charAt(indexRef.current);
490
+ setDisplayedText(function(prev) {
491
+ return prev + nextChar;
492
+ });
493
+ indexRef.current++;
494
+ var delay = /[.!?;:]/.test(nextChar) ? PUNCTUATION_DELAY : CHAR_DELAY;
495
+ timerRef.current = setTimeout(function() {
496
+ timerRef.current = null;
497
+ typeNext();
498
+ }, delay);
499
+ } else {
500
+ handleIsTextStreaming === null || handleIsTextStreaming === void 0 ? void 0 : handleIsTextStreaming(false);
501
+ }
502
+ }, []);
503
+ useEffect3(function() {
504
+ if (!shouldStream && !hasStartedStreaming.current) {
505
+ setDisplayedText(contentRef.current);
506
+ indexRef.current = contentRef.current.length;
507
+ if (timerRef.current) {
508
+ clearTimeout(timerRef.current);
509
+ timerRef.current = null;
510
+ }
511
+ handleIsTextStreaming === null || handleIsTextStreaming === void 0 ? void 0 : handleIsTextStreaming(false);
512
+ } else {
513
+ if (indexRef.current < contentRef.current.length && !timerRef.current) {
514
+ handleIsTextStreaming === null || handleIsTextStreaming === void 0 ? void 0 : handleIsTextStreaming(true);
515
+ hasStartedStreaming.current = true;
516
+ typeNext();
517
+ }
518
+ }
519
+ return function() {
520
+ if (timerRef.current) {
521
+ clearTimeout(timerRef.current);
522
+ timerRef.current = null;
523
+ }
524
+ };
525
+ }, [
526
+ shouldStream,
527
+ typeNext
528
+ ]);
529
+ return displayedText;
530
+ }
531
+ export { reducer, toast, useDocumentReader, useTextStreaming, useToast };
220
532
  //# sourceMappingURL=index.mjs.map