@seip/bluebird-js 0.0.1 → 0.1.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.
- package/.env_example +53 -53
- package/AGENTS.md +426 -403
- package/LICENSE +1 -1
- package/README.md +292 -285
- package/app/routes/api.js +50 -50
- package/app/routes/web.js +55 -53
- package/app/views/about.js +63 -0
- package/app/views/dashboard.js +147 -0
- package/app/views/index.js +80 -0
- package/app/views/layouts/main/view.js +81 -0
- package/app/views/legal/terms.html +19 -0
- package/app/views/login.js +80 -0
- package/core/app.d.ts +18 -18
- package/core/app.js +684 -644
- package/core/auth.d.ts +13 -13
- package/core/auth.js +326 -326
- package/core/cache.d.ts +17 -17
- package/core/cache.js +475 -475
- package/core/cli/doctor.js +287 -287
- package/core/cli/ecosystem.js +162 -162
- package/core/cli/init.js +779 -779
- package/core/cli/migrate.js +541 -541
- package/core/cli/model.js +66 -66
- package/core/cli/nginx.js +199 -199
- package/core/cli/route.js +120 -120
- package/core/cli/view.js +55 -36
- package/core/config.d.ts +3 -3
- package/core/config.js +111 -111
- package/core/csrf.d.ts +3 -3
- package/core/csrf.js +114 -114
- package/core/database.d.ts +15 -15
- package/core/database.js +636 -636
- package/core/debug.d.ts +3 -3
- package/core/debug.js +249 -249
- package/core/hash.d.ts +3 -3
- package/core/hash.js +194 -194
- package/core/html.d.ts +42 -0
- package/core/html.js +217 -0
- package/core/index.d.ts +1176 -1071
- package/core/logger.d.ts +3 -3
- package/core/logger.js +127 -124
- package/core/middleware.d.ts +3 -3
- package/core/middleware.js +28 -28
- package/core/model.d.ts +19 -19
- package/core/model.js +600 -600
- package/core/queue.d.ts +13 -13
- package/core/queue.js +172 -172
- package/core/ratelimit.d.ts +3 -3
- package/core/ratelimit.js +145 -145
- package/core/redis.d.ts +21 -21
- package/core/redis.js +230 -230
- package/core/render-cache.js +212 -0
- package/core/render.d.ts +3 -3
- package/core/render.js +199 -555
- package/core/router.d.ts +3 -3
- package/core/router.js +171 -171
- package/core/seo.d.ts +3 -3
- package/core/seo.js +106 -106
- package/core/swagger.d.ts +3 -3
- package/core/swagger.js +60 -60
- package/core/upload.d.ts +13 -13
- package/core/upload.js +102 -102
- package/core/util/colors.js +82 -82
- package/core/validate.d.ts +15 -15
- package/core/validate.js +364 -364
- package/core/view-loader.js +162 -0
- package/core/vite.d.ts +3 -3
- package/core/vite.js +145 -145
- package/core/ws.d.ts +13 -13
- package/core/ws.js +245 -245
- package/index.js +18 -18
- package/jsconfig.json +15 -15
- package/package.json +85 -86
- package/production.md +273 -273
- package/public/css/bluebird.min.css +1 -1
- package/public/js/bluebird-client.js +1780 -1662
- package/public/js/bluebird.min.js +1072 -1072
- package/app/views/about.html +0 -161
- package/app/views/dashboard.html +0 -140
- package/app/views/index.html +0 -150
- package/app/views/login.html +0 -144
|
@@ -1,1663 +1,1781 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bluebird Client Runtime.
|
|
3
|
-
* Provides client-side SPA routing with View Transitions,
|
|
4
|
-
* persistent element state, selective React Islands hydration,
|
|
5
|
-
* and a lightweight global event bus.
|
|
6
|
-
*/
|
|
7
|
-
(() => {
|
|
8
|
-
if (typeof window === "undefined" || window.Bluebird) return;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Global Island component registry.
|
|
12
|
-
* Components register themselves here via `window.__BLUEBIRD_ISLANDS__[name] = Component`.
|
|
13
|
-
* @type {Record<string, any>}
|
|
14
|
-
*/
|
|
15
|
-
window.__BLUEBIRD_ISLANDS__ = window.__BLUEBIRD_ISLANDS__ || {};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Global Island root mounter/renderer function supplied by the React bundle.
|
|
19
|
-
* @type {Function|null}
|
|
20
|
-
*/
|
|
21
|
-
window.__BLUEBIRD_MOUNT__ = window.__BLUEBIRD_MOUNT__ || null;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Map of mounted roots to DOM container elements.
|
|
25
|
-
* @type {Map<HTMLElement, {unmount: Function, persist: boolean, name: string}>}
|
|
26
|
-
*/
|
|
27
|
-
const mountedRoots = new Map();
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Map of prefetched HTML entries by URL with TTL expiration.
|
|
31
|
-
* @type {Map<string, {html: string, expiry: number}>}
|
|
32
|
-
*/
|
|
33
|
-
const prefetchCache = new Map();
|
|
34
|
-
const PREFETCH_TTL_MS = 30000;
|
|
35
|
-
const PREFETCH_MAX_ENTRIES = 50;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves a valid prefetched HTML string from cache if not expired.
|
|
39
|
-
* @param {string} url
|
|
40
|
-
* @returns {string|null}
|
|
41
|
-
*/
|
|
42
|
-
function getPrefetchedHtml(url) {
|
|
43
|
-
const entry = prefetchCache.get(url);
|
|
44
|
-
if (!entry) return null;
|
|
45
|
-
if (entry.expiry <= Date.now()) {
|
|
46
|
-
prefetchCache.delete(url);
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return entry.html;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Stores a prefetched HTML string with TTL and LRU cap.
|
|
54
|
-
* @param {string} url
|
|
55
|
-
* @param {string} html
|
|
56
|
-
*/
|
|
57
|
-
function setPrefetchedHtml(url, html) {
|
|
58
|
-
if (prefetchCache.size >= PREFETCH_MAX_ENTRIES) {
|
|
59
|
-
const oldestKey = prefetchCache.keys().next().value;
|
|
60
|
-
if (oldestKey !== undefined) prefetchCache.delete(oldestKey);
|
|
61
|
-
}
|
|
62
|
-
prefetchCache.set(url, { html, expiry: Date.now() + PREFETCH_TTL_MS });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Event listeners storage for the Bluebird Event Bus.
|
|
67
|
-
* @type {Map<string, Set<Function>>}
|
|
68
|
-
*/
|
|
69
|
-
const eventListeners = new Map();
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* In-memory key-value reactive store.
|
|
73
|
-
* @type {Map<string, any>}
|
|
74
|
-
*/
|
|
75
|
-
const storeState = new Map();
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Reactive store change listeners.
|
|
79
|
-
* @type {Map<string, Set<Function>>}
|
|
80
|
-
*/
|
|
81
|
-
const storeListeners = new Map();
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Bluebird global API object.
|
|
85
|
-
*/
|
|
86
|
-
const Bluebird = {
|
|
87
|
-
/**
|
|
88
|
-
* Emits an event through the client event bus.
|
|
89
|
-
* @param {string} event - Event identifier.
|
|
90
|
-
* @param {any} [data] - Event payload.
|
|
91
|
-
*/
|
|
92
|
-
emit(event, data) {
|
|
93
|
-
const callbacks = eventListeners.get(event);
|
|
94
|
-
if (callbacks) {
|
|
95
|
-
for (const cb of callbacks) {
|
|
96
|
-
try {
|
|
97
|
-
cb(data);
|
|
98
|
-
} catch (err) {
|
|
99
|
-
console.error(`[BLUEBIRD EVENT ERROR] Error in listener for "${event}":`, err);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Subscribes to an event on the client event bus.
|
|
107
|
-
* @param {string} event - Event identifier.
|
|
108
|
-
* @param {Function} callback - Event listener callback.
|
|
109
|
-
* @returns {Function} Unsubscribe function.
|
|
110
|
-
*/
|
|
111
|
-
on(event, callback) {
|
|
112
|
-
if (!eventListeners.has(event)) {
|
|
113
|
-
eventListeners.set(event, new Set());
|
|
114
|
-
}
|
|
115
|
-
eventListeners.get(event).add(callback);
|
|
116
|
-
return () => eventListeners.get(event)?.delete(callback);
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Unsubscribes a callback from the client event bus.
|
|
121
|
-
* @param {string} event - Event identifier.
|
|
122
|
-
* @param {Function} callback - Registered callback.
|
|
123
|
-
*/
|
|
124
|
-
off(event, callback) {
|
|
125
|
-
eventListeners.get(event)?.delete(callback);
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Gets or sets a reactive store value.
|
|
130
|
-
* @param {string} key - Store key.
|
|
131
|
-
* @param {any} [value] - Optional new value.
|
|
132
|
-
* @returns {any} Current store value.
|
|
133
|
-
*/
|
|
134
|
-
store(key, value) {
|
|
135
|
-
if (arguments.length > 1) {
|
|
136
|
-
storeState.set(key, value);
|
|
137
|
-
const listeners = storeListeners.get(key);
|
|
138
|
-
if (listeners) {
|
|
139
|
-
for (const cb of listeners) {
|
|
140
|
-
try {
|
|
141
|
-
cb(value);
|
|
142
|
-
} catch (err) {
|
|
143
|
-
console.error(`[BLUEBIRD STORE ERROR] Error in listener for "${key}":`, err);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return storeState.get(key);
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Subscribes to reactive store changes.
|
|
153
|
-
* @param {string} key - Store key.
|
|
154
|
-
* @param {Function} callback - Change handler receiving new value.
|
|
155
|
-
* @returns {Function} Unsubscribe function.
|
|
156
|
-
*/
|
|
157
|
-
subscribe(key, callback) {
|
|
158
|
-
if (!storeListeners.has(key)) {
|
|
159
|
-
storeListeners.set(key, new Set());
|
|
160
|
-
}
|
|
161
|
-
storeListeners.get(key).add(callback);
|
|
162
|
-
return () => storeListeners.get(key)?.delete(callback);
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Clears the internal link prefetch cache.
|
|
167
|
-
*/
|
|
168
|
-
clearPrefetch() {
|
|
169
|
-
prefetchCache.clear();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Registers a callback executed both on initial page load and after every SPA transition.
|
|
174
|
-
* Replaces DOMContentLoaded for Vanilla JavaScript components, sliders, and event listeners.
|
|
175
|
-
* @param {Function} callback - Function receiving { url, initial }.
|
|
176
|
-
* @returns {Function} Unsubscribe function.
|
|
177
|
-
*/
|
|
178
|
-
onPageLoad(callback) {
|
|
179
|
-
if (typeof callback !== "function") return () => {};
|
|
180
|
-
const handler = (e) => callback(e.detail || { url: window.location.href, initial: false });
|
|
181
|
-
window.addEventListener("bluebird:page-load", handler);
|
|
182
|
-
if (document.readyState !== "loading") {
|
|
183
|
-
try {
|
|
184
|
-
callback({ url: window.location.href, initial: true });
|
|
185
|
-
} catch (err) {
|
|
186
|
-
console.error("[BLUEBIRD ON_PAGE_LOAD ERROR]:", err);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return () => window.removeEventListener("bluebird:page-load", handler);
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Hydrates and mounts all [data-island] elements inside a container.
|
|
194
|
-
* @param {HTMLElement|Document} [container=document] - Target root DOM container.
|
|
195
|
-
*/
|
|
196
|
-
hydrate(container = document) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
*
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* @param {string
|
|
252
|
-
* @param {
|
|
253
|
-
* @param {
|
|
254
|
-
* @param {boolean} [options.
|
|
255
|
-
* @
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"X-Bluebird-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
targetEl
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
*
|
|
305
|
-
* @param {
|
|
306
|
-
* @param {
|
|
307
|
-
* @param {boolean} [options.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
let
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
* @param {
|
|
354
|
-
* @param {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
nextPersistElements.
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
*
|
|
435
|
-
* @param {
|
|
436
|
-
*/
|
|
437
|
-
function
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
try {
|
|
499
|
-
const url = new URL(anchor.href, window.location.href);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
(
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
Bluebird.navigate(
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
})
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
if (
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
if (
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
toastEl.
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
return
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
overlay
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
if (!
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
if (
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
function
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
let
|
|
946
|
-
if (
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
if (
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
if (
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
const
|
|
1020
|
-
const
|
|
1021
|
-
if (
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
if (
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
if (
|
|
1055
|
-
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
carousel.
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
(
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
if (
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
-
if (
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
if (
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
if (
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
const
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
if (
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
this.
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
this.
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
"
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
if (
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
);
|
|
1560
|
-
|
|
1561
|
-
const
|
|
1562
|
-
const
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
}
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
this.options.
|
|
1632
|
-
|
|
1633
|
-
.
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
this.
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
this.options.
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Bluebird Client Runtime.
|
|
3
|
+
* Provides client-side SPA routing with View Transitions,
|
|
4
|
+
* persistent element state, selective React Islands hydration,
|
|
5
|
+
* and a lightweight global event bus.
|
|
6
|
+
*/
|
|
7
|
+
(() => {
|
|
8
|
+
if (typeof window === "undefined" || window.Bluebird) return;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Global Island component registry.
|
|
12
|
+
* Components register themselves here via `window.__BLUEBIRD_ISLANDS__[name] = Component`.
|
|
13
|
+
* @type {Record<string, any>}
|
|
14
|
+
*/
|
|
15
|
+
window.__BLUEBIRD_ISLANDS__ = window.__BLUEBIRD_ISLANDS__ || {};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Global Island root mounter/renderer function supplied by the React bundle.
|
|
19
|
+
* @type {Function|null}
|
|
20
|
+
*/
|
|
21
|
+
window.__BLUEBIRD_MOUNT__ = window.__BLUEBIRD_MOUNT__ || null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Map of mounted roots to DOM container elements.
|
|
25
|
+
* @type {Map<HTMLElement, {unmount: Function, persist: boolean, name: string}>}
|
|
26
|
+
*/
|
|
27
|
+
const mountedRoots = new Map();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Map of prefetched HTML entries by URL with TTL expiration.
|
|
31
|
+
* @type {Map<string, {html: string, expiry: number}>}
|
|
32
|
+
*/
|
|
33
|
+
const prefetchCache = new Map();
|
|
34
|
+
const PREFETCH_TTL_MS = 30000;
|
|
35
|
+
const PREFETCH_MAX_ENTRIES = 50;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a valid prefetched HTML string from cache if not expired.
|
|
39
|
+
* @param {string} url
|
|
40
|
+
* @returns {string|null}
|
|
41
|
+
*/
|
|
42
|
+
function getPrefetchedHtml(url) {
|
|
43
|
+
const entry = prefetchCache.get(url);
|
|
44
|
+
if (!entry) return null;
|
|
45
|
+
if (entry.expiry <= Date.now()) {
|
|
46
|
+
prefetchCache.delete(url);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return entry.html;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Stores a prefetched HTML string with TTL and LRU cap.
|
|
54
|
+
* @param {string} url
|
|
55
|
+
* @param {string} html
|
|
56
|
+
*/
|
|
57
|
+
function setPrefetchedHtml(url, html) {
|
|
58
|
+
if (prefetchCache.size >= PREFETCH_MAX_ENTRIES) {
|
|
59
|
+
const oldestKey = prefetchCache.keys().next().value;
|
|
60
|
+
if (oldestKey !== undefined) prefetchCache.delete(oldestKey);
|
|
61
|
+
}
|
|
62
|
+
prefetchCache.set(url, { html, expiry: Date.now() + PREFETCH_TTL_MS });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Event listeners storage for the Bluebird Event Bus.
|
|
67
|
+
* @type {Map<string, Set<Function>>}
|
|
68
|
+
*/
|
|
69
|
+
const eventListeners = new Map();
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* In-memory key-value reactive store.
|
|
73
|
+
* @type {Map<string, any>}
|
|
74
|
+
*/
|
|
75
|
+
const storeState = new Map();
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reactive store change listeners.
|
|
79
|
+
* @type {Map<string, Set<Function>>}
|
|
80
|
+
*/
|
|
81
|
+
const storeListeners = new Map();
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Bluebird global API object.
|
|
85
|
+
*/
|
|
86
|
+
const Bluebird = {
|
|
87
|
+
/**
|
|
88
|
+
* Emits an event through the client event bus.
|
|
89
|
+
* @param {string} event - Event identifier.
|
|
90
|
+
* @param {any} [data] - Event payload.
|
|
91
|
+
*/
|
|
92
|
+
emit(event, data) {
|
|
93
|
+
const callbacks = eventListeners.get(event);
|
|
94
|
+
if (callbacks) {
|
|
95
|
+
for (const cb of callbacks) {
|
|
96
|
+
try {
|
|
97
|
+
cb(data);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
console.error(`[BLUEBIRD EVENT ERROR] Error in listener for "${event}":`, err);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Subscribes to an event on the client event bus.
|
|
107
|
+
* @param {string} event - Event identifier.
|
|
108
|
+
* @param {Function} callback - Event listener callback.
|
|
109
|
+
* @returns {Function} Unsubscribe function.
|
|
110
|
+
*/
|
|
111
|
+
on(event, callback) {
|
|
112
|
+
if (!eventListeners.has(event)) {
|
|
113
|
+
eventListeners.set(event, new Set());
|
|
114
|
+
}
|
|
115
|
+
eventListeners.get(event).add(callback);
|
|
116
|
+
return () => eventListeners.get(event)?.delete(callback);
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Unsubscribes a callback from the client event bus.
|
|
121
|
+
* @param {string} event - Event identifier.
|
|
122
|
+
* @param {Function} callback - Registered callback.
|
|
123
|
+
*/
|
|
124
|
+
off(event, callback) {
|
|
125
|
+
eventListeners.get(event)?.delete(callback);
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Gets or sets a reactive store value.
|
|
130
|
+
* @param {string} key - Store key.
|
|
131
|
+
* @param {any} [value] - Optional new value.
|
|
132
|
+
* @returns {any} Current store value.
|
|
133
|
+
*/
|
|
134
|
+
store(key, value) {
|
|
135
|
+
if (arguments.length > 1) {
|
|
136
|
+
storeState.set(key, value);
|
|
137
|
+
const listeners = storeListeners.get(key);
|
|
138
|
+
if (listeners) {
|
|
139
|
+
for (const cb of listeners) {
|
|
140
|
+
try {
|
|
141
|
+
cb(value);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.error(`[BLUEBIRD STORE ERROR] Error in listener for "${key}":`, err);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return storeState.get(key);
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Subscribes to reactive store changes.
|
|
153
|
+
* @param {string} key - Store key.
|
|
154
|
+
* @param {Function} callback - Change handler receiving new value.
|
|
155
|
+
* @returns {Function} Unsubscribe function.
|
|
156
|
+
*/
|
|
157
|
+
subscribe(key, callback) {
|
|
158
|
+
if (!storeListeners.has(key)) {
|
|
159
|
+
storeListeners.set(key, new Set());
|
|
160
|
+
}
|
|
161
|
+
storeListeners.get(key).add(callback);
|
|
162
|
+
return () => storeListeners.get(key)?.delete(callback);
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Clears the internal link prefetch cache.
|
|
167
|
+
*/
|
|
168
|
+
clearPrefetch() {
|
|
169
|
+
prefetchCache.clear();
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Registers a callback executed both on initial page load and after every SPA transition.
|
|
174
|
+
* Replaces DOMContentLoaded for Vanilla JavaScript components, sliders, and event listeners.
|
|
175
|
+
* @param {Function} callback - Function receiving { url, initial }.
|
|
176
|
+
* @returns {Function} Unsubscribe function.
|
|
177
|
+
*/
|
|
178
|
+
onPageLoad(callback) {
|
|
179
|
+
if (typeof callback !== "function") return () => {};
|
|
180
|
+
const handler = (e) => callback(e.detail || { url: window.location.href, initial: false });
|
|
181
|
+
window.addEventListener("bluebird:page-load", handler);
|
|
182
|
+
if (document.readyState !== "loading") {
|
|
183
|
+
try {
|
|
184
|
+
callback({ url: window.location.href, initial: true });
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.error("[BLUEBIRD ON_PAGE_LOAD ERROR]:", err);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return () => window.removeEventListener("bluebird:page-load", handler);
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Hydrates and mounts all [data-island] elements inside a container.
|
|
194
|
+
* @param {HTMLElement|Document} [container=document] - Target root DOM container.
|
|
195
|
+
*/
|
|
196
|
+
hydrate(container = document) {
|
|
197
|
+
|
|
198
|
+
const islands = container.querySelectorAll("[data-island]");
|
|
199
|
+
for (const el of islands) {
|
|
200
|
+
if (el.__bluebird_mounted__) continue;
|
|
201
|
+
|
|
202
|
+
const name = el.getAttribute("data-island");
|
|
203
|
+
const isPersist = el.getAttribute("data-persist") === "true";
|
|
204
|
+
let props = {};
|
|
205
|
+
|
|
206
|
+
try {
|
|
207
|
+
const rawProps = el.getAttribute("data-props");
|
|
208
|
+
if (rawProps) props = JSON.parse(rawProps);
|
|
209
|
+
} catch (err) {
|
|
210
|
+
console.warn(`[BLUEBIRD ISLAND] Failed to parse props for island "${name}":`, err);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const component = window.__BLUEBIRD_ISLANDS__[name];
|
|
214
|
+
if (component && typeof window.__BLUEBIRD_MOUNT__ === "function") {
|
|
215
|
+
try {
|
|
216
|
+
const unmountFn = window.__BLUEBIRD_MOUNT__(el, component, props);
|
|
217
|
+
el.__bluebird_mounted__ = true;
|
|
218
|
+
mountedRoots.set(el, {
|
|
219
|
+
unmount: unmountFn,
|
|
220
|
+
persist: isPersist,
|
|
221
|
+
name,
|
|
222
|
+
});
|
|
223
|
+
} catch (err) {
|
|
224
|
+
console.error(`[BLUEBIRD ISLAND] Error mounting island "${name}":`, err);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Cleanly unmounts non-persistent mounted islands inside a specific container (or entire document).
|
|
232
|
+
* @param {HTMLElement|Document} [container=document]
|
|
233
|
+
*/
|
|
234
|
+
unmountNonPersistent(container = document) {
|
|
235
|
+
for (const [el, item] of mountedRoots.entries()) {
|
|
236
|
+
if (item.persist) continue;
|
|
237
|
+
if (container !== document && !container.contains(el)) continue;
|
|
238
|
+
try {
|
|
239
|
+
if (typeof item.unmount === "function") {
|
|
240
|
+
item.unmount();
|
|
241
|
+
}
|
|
242
|
+
} catch {}
|
|
243
|
+
el.__bluebird_mounted__ = false;
|
|
244
|
+
mountedRoots.delete(el);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Fetches an HTML partial from the server and swaps it into a target DOM selector.
|
|
250
|
+
* Automatically handles authentication redirects by falling back to full SPA navigation.
|
|
251
|
+
* @param {string} url - Endpoint returning a rendered partial or view.
|
|
252
|
+
* @param {string|HTMLElement} target - CSS selector or DOM element to update.
|
|
253
|
+
* @param {Object} [options={}] - Swap options.
|
|
254
|
+
* @param {boolean} [options.transition=false] - Wrap swap in View Transition.
|
|
255
|
+
* @param {boolean} [options.pushUrl=false] - Push URL to browser history.
|
|
256
|
+
* @returns {Promise<boolean>}
|
|
257
|
+
*/
|
|
258
|
+
async renderPartial(url, target, options = {}) {
|
|
259
|
+
const targetEl = typeof target === "string" ? document.querySelector(target) : target;
|
|
260
|
+
if (!targetEl) return false;
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
const res = await fetch(url, {
|
|
264
|
+
headers: {
|
|
265
|
+
"X-Bluebird-Client-Router": "1",
|
|
266
|
+
"X-Bluebird-Partial": "1",
|
|
267
|
+
},
|
|
268
|
+
credentials: "include",
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
if (!res.ok) return false;
|
|
272
|
+
|
|
273
|
+
if (res.redirected && res.url && res.headers.get("X-Bluebird-Partial") !== "1") {
|
|
274
|
+
await Bluebird.navigate(res.url);
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const html = await res.text();
|
|
279
|
+
const applyPartial = () => {
|
|
280
|
+
Bluebird.unmountNonPersistent(targetEl);
|
|
281
|
+
targetEl.innerHTML = html;
|
|
282
|
+
executeScripts(targetEl);
|
|
283
|
+
Bluebird.hydrate(targetEl);
|
|
284
|
+
if (options.pushUrl) {
|
|
285
|
+
window.history.pushState({}, "", url);
|
|
286
|
+
}
|
|
287
|
+
window.dispatchEvent(
|
|
288
|
+
new CustomEvent("bluebird:partial-load", { detail: { url, target: targetEl } })
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
if (options.transition && document.startViewTransition) {
|
|
293
|
+
await document.startViewTransition(applyPartial).finished;
|
|
294
|
+
} else {
|
|
295
|
+
applyPartial();
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
} catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Performs client-side navigation to a target URL.
|
|
305
|
+
* @param {string} url - Target URL path.
|
|
306
|
+
* @param {Object} [options={}] - Navigation options.
|
|
307
|
+
* @param {boolean} [options.replace=false] - Use history.replaceState instead of pushState.
|
|
308
|
+
* @param {boolean} [options.scroll=true] - Scroll to top on navigation.
|
|
309
|
+
*/
|
|
310
|
+
async navigate(url, options = {}) {
|
|
311
|
+
try {
|
|
312
|
+
let html = getPrefetchedHtml(url);
|
|
313
|
+
let targetUrl = url;
|
|
314
|
+
if (!html) {
|
|
315
|
+
const res = await fetch(url, {
|
|
316
|
+
headers: { "X-Bluebird-Client-Router": "1" },
|
|
317
|
+
credentials: "include",
|
|
318
|
+
});
|
|
319
|
+
if (!res.ok) {
|
|
320
|
+
window.location.href = url;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (res.redirected && res.url) {
|
|
324
|
+
try {
|
|
325
|
+
const parsed = new URL(res.url);
|
|
326
|
+
targetUrl = parsed.pathname + parsed.search;
|
|
327
|
+
} catch {}
|
|
328
|
+
}
|
|
329
|
+
html = await res.text();
|
|
330
|
+
} else {
|
|
331
|
+
prefetchCache.delete(url);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const parser = new DOMParser();
|
|
335
|
+
const nextDoc = parser.parseFromString(html, "text/html");
|
|
336
|
+
|
|
337
|
+
if (document.startViewTransition) {
|
|
338
|
+
await document.startViewTransition(() => {
|
|
339
|
+
swapDocument(nextDoc, targetUrl, options);
|
|
340
|
+
}).finished;
|
|
341
|
+
} else {
|
|
342
|
+
swapDocument(nextDoc, targetUrl, options);
|
|
343
|
+
}
|
|
344
|
+
} catch {
|
|
345
|
+
window.location.href = url;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Swaps the current document DOM with the incoming parsed document.
|
|
352
|
+
* Preserves [data-persist="true"] elements and synchronizes <head> meta tags.
|
|
353
|
+
* @param {Document} nextDoc - Parsed incoming HTML document.
|
|
354
|
+
* @param {string} url - Target URL.
|
|
355
|
+
* @param {Object} options - Navigation options.
|
|
356
|
+
*/
|
|
357
|
+
function swapDocument(nextDoc, url, options) {
|
|
358
|
+
const currentPersistNodes = new Map();
|
|
359
|
+
const currentPersistElements = document.querySelectorAll('[data-persist="true"]');
|
|
360
|
+
|
|
361
|
+
currentPersistElements.forEach((el, index) => {
|
|
362
|
+
const key = el.getAttribute("data-island") || el.getAttribute("data-bb-client") || el.id || `persist-${index}`;
|
|
363
|
+
currentPersistNodes.set(key, el);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
Bluebird.unmountNonPersistent();
|
|
367
|
+
|
|
368
|
+
document.title = nextDoc.title || document.title;
|
|
369
|
+
|
|
370
|
+
updateHeadTags(nextDoc);
|
|
371
|
+
|
|
372
|
+
const nextPersistElements = nextDoc.querySelectorAll('[data-persist="true"]');
|
|
373
|
+
nextPersistElements.forEach((nextEl, index) => {
|
|
374
|
+
const key = nextEl.getAttribute("data-island") || nextEl.getAttribute("data-bb-client") || nextEl.id || `persist-${index}`;
|
|
375
|
+
const activeEl = currentPersistNodes.get(key);
|
|
376
|
+
if (activeEl && nextEl.parentNode) {
|
|
377
|
+
nextEl.parentNode.replaceChild(activeEl, nextEl);
|
|
378
|
+
currentPersistNodes.delete(key);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const currentOutlet = document.querySelector("[data-bb-outlet]");
|
|
383
|
+
const nextOutlet = nextDoc.querySelector("[data-bb-outlet]");
|
|
384
|
+
const currentLayout = document.body.getAttribute("data-layout");
|
|
385
|
+
const nextLayout = nextDoc.body.getAttribute("data-layout");
|
|
386
|
+
|
|
387
|
+
const canSwapOutletOnly =
|
|
388
|
+
currentOutlet &&
|
|
389
|
+
nextOutlet &&
|
|
390
|
+
currentLayout &&
|
|
391
|
+
nextLayout &&
|
|
392
|
+
currentLayout === nextLayout;
|
|
393
|
+
|
|
394
|
+
if (canSwapOutletOnly) {
|
|
395
|
+
currentOutlet.innerHTML = nextOutlet.innerHTML;
|
|
396
|
+
executeScripts(currentOutlet);
|
|
397
|
+
Bluebird.hydrate(currentOutlet);
|
|
398
|
+
} else {
|
|
399
|
+
document.body.innerHTML = nextDoc.body.innerHTML;
|
|
400
|
+
|
|
401
|
+
for (const [key, activeEl] of currentPersistNodes.entries()) {
|
|
402
|
+
const placeholder = document.querySelector(
|
|
403
|
+
`[data-persist="true"][data-island="${key}"], [data-persist="true"][data-bb-client="${key}"], [data-persist="true"]#${key}`
|
|
404
|
+
);
|
|
405
|
+
if (placeholder && placeholder.parentNode && placeholder !== activeEl) {
|
|
406
|
+
placeholder.parentNode.replaceChild(activeEl, placeholder);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
executeScripts(document.body);
|
|
411
|
+
Bluebird.hydrate();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (options.replace) {
|
|
415
|
+
window.history.replaceState({}, "", url);
|
|
416
|
+
} else {
|
|
417
|
+
window.history.pushState({}, "", url);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (options.scroll !== false) {
|
|
421
|
+
window.scrollTo(0, 0);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
Bluebird.hydrate();
|
|
425
|
+
|
|
426
|
+
const pageLoadDetail = { url, initial: false };
|
|
427
|
+
window.dispatchEvent(new CustomEvent("bluebird:navigate", { detail: { url } }));
|
|
428
|
+
window.dispatchEvent(new CustomEvent("bluebird:page-load", { detail: pageLoadDetail }));
|
|
429
|
+
document.dispatchEvent(new CustomEvent("bluebird:page-load", { detail: pageLoadDetail }));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Re-evaluates script elements found in the newly injected container.
|
|
434
|
+
* Skips persistent scripts and the Bluebird client runtime itself.
|
|
435
|
+
* @param {HTMLElement} container
|
|
436
|
+
*/
|
|
437
|
+
function executeScripts(container) {
|
|
438
|
+
const scripts = Array.from(container.querySelectorAll("script"));
|
|
439
|
+
for (const oldScript of scripts) {
|
|
440
|
+
if (oldScript.getAttribute("data-persist") === "true") continue;
|
|
441
|
+
const src = oldScript.getAttribute("src") || "";
|
|
442
|
+
if (src.includes("bluebird-client.js")) continue;
|
|
443
|
+
|
|
444
|
+
const newScript = document.createElement("script");
|
|
445
|
+
for (const attr of Array.from(oldScript.attributes)) {
|
|
446
|
+
newScript.setAttribute(attr.name, attr.value);
|
|
447
|
+
}
|
|
448
|
+
newScript.textContent = oldScript.textContent;
|
|
449
|
+
if (oldScript.parentNode) {
|
|
450
|
+
oldScript.parentNode.replaceChild(newScript, oldScript);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Synchronizes meta and link tags between current and incoming <head>.
|
|
457
|
+
* @param {Document} nextDoc
|
|
458
|
+
*/
|
|
459
|
+
function updateHeadTags(nextDoc) {
|
|
460
|
+
const currentMeta = document.head.querySelectorAll("meta[name], meta[property]");
|
|
461
|
+
currentMeta.forEach((el) => el.remove());
|
|
462
|
+
|
|
463
|
+
const nextMeta = nextDoc.head.querySelectorAll("meta[name], meta[property]");
|
|
464
|
+
nextMeta.forEach((el) => {
|
|
465
|
+
document.head.appendChild(document.importNode(el, true));
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
const nextCanonical = nextDoc.head.querySelector("link[rel='canonical']");
|
|
469
|
+
const currentCanonical = document.head.querySelector("link[rel='canonical']");
|
|
470
|
+
if (nextCanonical) {
|
|
471
|
+
if (currentCanonical) {
|
|
472
|
+
currentCanonical.setAttribute("href", nextCanonical.getAttribute("href") || "");
|
|
473
|
+
} else {
|
|
474
|
+
document.head.appendChild(document.importNode(nextCanonical, true));
|
|
475
|
+
}
|
|
476
|
+
} else if (currentCanonical) {
|
|
477
|
+
currentCanonical.remove();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Determines if a link element qualifies for SPA navigation.
|
|
483
|
+
* @param {HTMLAnchorElement} anchor
|
|
484
|
+
* @returns {boolean}
|
|
485
|
+
*/
|
|
486
|
+
function isInternalLink(anchor) {
|
|
487
|
+
if (!anchor || anchor.tagName !== "A") return false;
|
|
488
|
+
if (anchor.target && anchor.target !== "_self") return false;
|
|
489
|
+
if (anchor.hasAttribute("download")) return false;
|
|
490
|
+
if (anchor.getAttribute("rel") === "external") return false;
|
|
491
|
+
if (anchor.getAttribute("data-no-router") !== null) return false;
|
|
492
|
+
|
|
493
|
+
const href = anchor.getAttribute("href");
|
|
494
|
+
if (!href || href.startsWith("#") || href.startsWith("javascript:") || href.startsWith("mailto:") || href.startsWith("tel:")) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
try {
|
|
499
|
+
const url = new URL(anchor.href, window.location.href);
|
|
500
|
+
return url.origin === window.location.origin;
|
|
501
|
+
} catch {
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Determines if a link element qualifies for background prefetching on hover.
|
|
508
|
+
* Excludes links marked with data-no-prefetch, data-prefetch="false", data-no-hover,
|
|
509
|
+
* or paths typically used for session termination (such as /logout or /signout).
|
|
510
|
+
* @param {HTMLAnchorElement} anchor
|
|
511
|
+
* @returns {boolean}
|
|
512
|
+
*/
|
|
513
|
+
function canPrefetch(anchor) {
|
|
514
|
+
if (!isInternalLink(anchor)) return false;
|
|
515
|
+
if (anchor.hasAttribute("data-no-prefetch")) return false;
|
|
516
|
+
if (anchor.getAttribute("data-prefetch") === "false") return false;
|
|
517
|
+
if (anchor.hasAttribute("data-no-hover")) return false;
|
|
518
|
+
if (anchor.hasAttribute("data-partial-target")) return false;
|
|
519
|
+
|
|
520
|
+
try {
|
|
521
|
+
const url = new URL(anchor.href, window.location.href);
|
|
522
|
+
const pathname = url.pathname.toLowerCase();
|
|
523
|
+
if (
|
|
524
|
+
pathname === "/logout" ||
|
|
525
|
+
pathname.endsWith("/logout") ||
|
|
526
|
+
pathname === "/signout" ||
|
|
527
|
+
pathname.endsWith("/signout")
|
|
528
|
+
) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
} catch {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Initializes click interception on document for client-side routing and partial swaps.
|
|
540
|
+
*/
|
|
541
|
+
function initLinkInterception() {
|
|
542
|
+
document.addEventListener("click", (e) => {
|
|
543
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const anchor = e.target.closest("a");
|
|
548
|
+
if (!anchor || !isInternalLink(anchor)) return;
|
|
549
|
+
|
|
550
|
+
const partialTarget = anchor.getAttribute("data-partial-target");
|
|
551
|
+
if (partialTarget) {
|
|
552
|
+
e.preventDefault();
|
|
553
|
+
Bluebird.renderPartial(anchor.href, partialTarget, {
|
|
554
|
+
transition: anchor.getAttribute("data-transition") === "true",
|
|
555
|
+
pushUrl: anchor.getAttribute("data-push-url") === "true",
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const url = anchor.href;
|
|
561
|
+
if (url === window.location.href) {
|
|
562
|
+
e.preventDefault();
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
e.preventDefault();
|
|
567
|
+
Bluebird.navigate(url);
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
document.addEventListener(
|
|
571
|
+
"mouseover",
|
|
572
|
+
(e) => {
|
|
573
|
+
const anchor = e.target.closest("a");
|
|
574
|
+
if (!anchor || !canPrefetch(anchor)) return;
|
|
575
|
+
const url = anchor.href;
|
|
576
|
+
if (!getPrefetchedHtml(url)) {
|
|
577
|
+
fetch(url, { headers: { "X-Bluebird-Prefetch": "1" }, credentials: "include" })
|
|
578
|
+
.then((r) => (r.ok ? r.text() : null))
|
|
579
|
+
.then((html) => {
|
|
580
|
+
if (html) setPrefetchedHtml(url, html);
|
|
581
|
+
})
|
|
582
|
+
.catch(() => {});
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
{ passive: true }
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
window.addEventListener("popstate", () => {
|
|
589
|
+
Bluebird.navigate(window.location.href, { replace: true, scroll: false });
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* DOM query selector shortcut.
|
|
595
|
+
* @param {string} selector
|
|
596
|
+
* @param {HTMLElement|Document} [context=document]
|
|
597
|
+
* @returns {HTMLElement|null}
|
|
598
|
+
*/
|
|
599
|
+
const $ = (selector, context = document) => context.querySelector(selector);
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* DOM query selector all shortcut returning an Array.
|
|
603
|
+
* @param {string} selector
|
|
604
|
+
* @param {HTMLElement|Document} [context=document]
|
|
605
|
+
* @returns {HTMLElement[]}
|
|
606
|
+
*/
|
|
607
|
+
const $$ = (selector, context = document) => Array.from(context.querySelectorAll(selector));
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Delegated DOM event listener helper.
|
|
611
|
+
* Listens on document, matching selectors dynamically.
|
|
612
|
+
* Works across View Transitions without manual re-binding!
|
|
613
|
+
* @param {string} selector - CSS selector (e.g. '#btnInc', '.card-btn')
|
|
614
|
+
* @param {string} type - Event type (e.g. 'click', 'input', 'submit')
|
|
615
|
+
* @param {Function} handler - Callback receiving (event, matchedElement)
|
|
616
|
+
* @returns {Function} Unsubscribe function.
|
|
617
|
+
*/
|
|
618
|
+
function delegate(selector, type, handler) {
|
|
619
|
+
const listener = (e) => {
|
|
620
|
+
const match = e.target.closest(selector);
|
|
621
|
+
if (match) handler(e, match);
|
|
622
|
+
};
|
|
623
|
+
document.addEventListener(type, listener);
|
|
624
|
+
return () => document.removeEventListener(type, listener);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
Bluebird.$ = $;
|
|
628
|
+
Bluebird.$$ = $$;
|
|
629
|
+
Bluebird.delegate = delegate;
|
|
630
|
+
Bluebird.event = delegate;
|
|
631
|
+
|
|
632
|
+
window.$ = window.$ || $;
|
|
633
|
+
window.$$ = window.$$ || $$;
|
|
634
|
+
window.on = window.on || delegate;
|
|
635
|
+
|
|
636
|
+
window.Bluebird = Bluebird;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Initializes automatic page reload during development when the Node server restarts.
|
|
640
|
+
*/
|
|
641
|
+
function initDevReload() {
|
|
642
|
+
if (typeof window === "undefined" || !window.EventSource) return;
|
|
643
|
+
const isLocalhost =
|
|
644
|
+
window.location.hostname === "localhost" ||
|
|
645
|
+
window.location.hostname === "127.0.0.1" ||
|
|
646
|
+
window.location.hostname === "::1";
|
|
647
|
+
if (!isLocalhost) return;
|
|
648
|
+
|
|
649
|
+
let initialBootId = null;
|
|
650
|
+
let connectedOnce = false;
|
|
651
|
+
let failedAttempts = 0;
|
|
652
|
+
let es = null;
|
|
653
|
+
|
|
654
|
+
function connect() {
|
|
655
|
+
try {
|
|
656
|
+
es = new EventSource("/_bb/dev-reload");
|
|
657
|
+
|
|
658
|
+
es.onmessage = (event) => {
|
|
659
|
+
try {
|
|
660
|
+
const data = JSON.parse(event.data);
|
|
661
|
+
if (data.type === "connected" && data.bootId) {
|
|
662
|
+
connectedOnce = true;
|
|
663
|
+
failedAttempts = 0;
|
|
664
|
+
if (initialBootId === null) {
|
|
665
|
+
initialBootId = data.bootId;
|
|
666
|
+
} else if (initialBootId !== data.bootId) {
|
|
667
|
+
console.log("[Bluebird] Server restart detected, reloading page...");
|
|
668
|
+
window.location.reload();
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
} catch {}
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
es.onerror = () => {
|
|
675
|
+
try { es.close(); } catch {}
|
|
676
|
+
if (!connectedOnce) {
|
|
677
|
+
failedAttempts++;
|
|
678
|
+
if (failedAttempts > 2) return;
|
|
679
|
+
setTimeout(connect, 1000);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
setTimeout(connect, 500);
|
|
683
|
+
};
|
|
684
|
+
} catch {}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
connect();
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Initializes client router, hydrates components, and emits initial page-load event.
|
|
692
|
+
*/
|
|
693
|
+
function triggerInitialLoad() {
|
|
694
|
+
initLinkInterception();
|
|
695
|
+
Bluebird.hydrate();
|
|
696
|
+
initDevReload();
|
|
697
|
+
const detail = { url: window.location.href, initial: true };
|
|
698
|
+
window.dispatchEvent(new CustomEvent("bluebird:page-load", { detail }));
|
|
699
|
+
document.dispatchEvent(new CustomEvent("bluebird:page-load", { detail }));
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (document.readyState === "loading") {
|
|
703
|
+
document.addEventListener("DOMContentLoaded", triggerInitialLoad);
|
|
704
|
+
} else {
|
|
705
|
+
triggerInitialLoad();
|
|
706
|
+
}
|
|
707
|
+
})();
|
|
708
|
+
/* Blue Bird JS v0.2.2 | MIT License | @seip/blue-bird-css */
|
|
709
|
+
function bluebird(component, options) {
|
|
710
|
+
if (typeof component === 'object') {
|
|
711
|
+
options = component;
|
|
712
|
+
component = 'snackbar';
|
|
713
|
+
}
|
|
714
|
+
if (component === 'snackbar') {
|
|
715
|
+
let snackbarEl = document.getElementById('snackbar');
|
|
716
|
+
if (!snackbarEl) {
|
|
717
|
+
snackbarEl = document.createElement('div');
|
|
718
|
+
snackbarEl.id = 'snackbar';
|
|
719
|
+
document.body.appendChild(snackbarEl);
|
|
720
|
+
}
|
|
721
|
+
snackbarEl.className = 'show';
|
|
722
|
+
if (options && options.type) {
|
|
723
|
+
snackbarEl.classList.add(options.type);
|
|
724
|
+
} else {
|
|
725
|
+
snackbarEl.classList.add('info');
|
|
726
|
+
}
|
|
727
|
+
snackbarEl.textContent = (options && options.message) || '';
|
|
728
|
+
setTimeout(() => {
|
|
729
|
+
snackbarEl.classList.add('show');
|
|
730
|
+
}, 10);
|
|
731
|
+
const duration = (options && options.duration) || 3000;
|
|
732
|
+
if (snackbarEl.timeoutId) {
|
|
733
|
+
clearTimeout(snackbarEl.timeoutId);
|
|
734
|
+
}
|
|
735
|
+
snackbarEl.timeoutId = setTimeout(function () {
|
|
736
|
+
snackbarEl.className = '';
|
|
737
|
+
}, duration);
|
|
738
|
+
}
|
|
739
|
+
if (component === 'toast') {
|
|
740
|
+
const position = (options && options.position) || 'bottom-right';
|
|
741
|
+
let container = document.querySelector(`.toast-container.${position}`);
|
|
742
|
+
if (!container) {
|
|
743
|
+
container = document.createElement('div');
|
|
744
|
+
container.className = `toast-container ${position}`;
|
|
745
|
+
document.body.appendChild(container);
|
|
746
|
+
}
|
|
747
|
+
const toastEl = document.createElement('div');
|
|
748
|
+
const typeClass = (options && options.type) ? `toast-${options.type}` : 'toast-info';
|
|
749
|
+
toastEl.className = `toast ${typeClass}`;
|
|
750
|
+
const title = (options && options.title) ? `<div class="toast-title">${options.title}</div>` : '';
|
|
751
|
+
const desc = (options && options.description) ? `<div class="toast-description">${options.description}</div>` : '';
|
|
752
|
+
toastEl.innerHTML = `
|
|
753
|
+
<div class="toast-content">
|
|
754
|
+
${title}
|
|
755
|
+
${desc}
|
|
756
|
+
</div>
|
|
757
|
+
<button class="toast-close" aria-label="Dismiss">×</button>
|
|
758
|
+
`;
|
|
759
|
+
const closeBtn = toastEl.querySelector('.toast-close');
|
|
760
|
+
closeBtn.addEventListener('click', () => dismissToast(toastEl));
|
|
761
|
+
container.appendChild(toastEl);
|
|
762
|
+
const duration = (options && options.duration) !== undefined ? options.duration : 4000;
|
|
763
|
+
if (duration > 0) {
|
|
764
|
+
setTimeout(() => dismissToast(toastEl), duration);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (component === 'tab') {
|
|
768
|
+
const targetId = options && options.id;
|
|
769
|
+
if (!targetId) return;
|
|
770
|
+
const targetContent = document.getElementById(targetId);
|
|
771
|
+
if (!targetContent) return;
|
|
772
|
+
const tabsContainer = targetContent.closest('.tabs');
|
|
773
|
+
if (!tabsContainer) return;
|
|
774
|
+
const allTriggers = tabsContainer.querySelectorAll('.tab-trigger');
|
|
775
|
+
const allContents = tabsContainer.querySelectorAll('.tab-content');
|
|
776
|
+
allContents.forEach(c => c.classList.remove('active'));
|
|
777
|
+
allTriggers.forEach(t => t.classList.remove('active'));
|
|
778
|
+
targetContent.classList.add('active');
|
|
779
|
+
const matchingTrigger = Array.from(allTriggers).find(t =>
|
|
780
|
+
t.getAttribute('data-tab-target') === targetId || t.getAttribute('href') === `#${targetId}`
|
|
781
|
+
);
|
|
782
|
+
if (matchingTrigger) {
|
|
783
|
+
matchingTrigger.classList.add('active');
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (component === 'command') {
|
|
787
|
+
const action = (options && options.action) || 'toggle';
|
|
788
|
+
let backdrop = document.querySelector('.command-backdrop');
|
|
789
|
+
if (!backdrop) {
|
|
790
|
+
backdrop = createCommandPaletteModal();
|
|
791
|
+
}
|
|
792
|
+
const isOpen = backdrop.classList.contains('open');
|
|
793
|
+
if (action === 'open' || (action === 'toggle' && !isOpen)) {
|
|
794
|
+
backdrop.classList.add('open');
|
|
795
|
+
const input = backdrop.querySelector('.command-input');
|
|
796
|
+
if (input) {
|
|
797
|
+
input.value = '';
|
|
798
|
+
setTimeout(() => input.focus(), 50);
|
|
799
|
+
}
|
|
800
|
+
} else if (action === 'close' || (action === 'toggle' && isOpen)) {
|
|
801
|
+
backdrop.classList.remove('open');
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (component === 'popover') {
|
|
805
|
+
const id = options && options.id;
|
|
806
|
+
const action = (options && options.action) || 'toggle';
|
|
807
|
+
if (!id) return;
|
|
808
|
+
const popoverEl = document.getElementById(id) || document.querySelector(`[data-popover-id="${id}"]`);
|
|
809
|
+
if (!popoverEl) return;
|
|
810
|
+
const isOpen = popoverEl.classList.contains('open');
|
|
811
|
+
if (action === 'open' || (action === 'toggle' && !isOpen)) {
|
|
812
|
+
popoverEl.classList.add('open');
|
|
813
|
+
} else {
|
|
814
|
+
popoverEl.classList.remove('open');
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
if (component === 'drawer') {
|
|
818
|
+
cleanupOrphanedBackdrops();
|
|
819
|
+
const id = options && options.id;
|
|
820
|
+
const action = (options && options.action) || 'toggle';
|
|
821
|
+
if (!id) return;
|
|
822
|
+
const drawerEl = document.getElementById(id);
|
|
823
|
+
if (!drawerEl) return;
|
|
824
|
+
let overlay = document.querySelector(`.drawer-backdrop[data-for="${id}"]`);
|
|
825
|
+
if (!overlay) {
|
|
826
|
+
overlay = document.createElement('div');
|
|
827
|
+
overlay.className = 'drawer-backdrop';
|
|
828
|
+
overlay.setAttribute('data-for', id);
|
|
829
|
+
document.body.appendChild(overlay);
|
|
830
|
+
overlay.addEventListener('click', () => {
|
|
831
|
+
bluebird('drawer', { id, action: 'close' });
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
const isOpen = drawerEl.classList.contains('open') || drawerEl.classList.contains('active');
|
|
835
|
+
if (action === 'open' || (action === 'toggle' && !isOpen)) {
|
|
836
|
+
drawerEl.classList.add('open');
|
|
837
|
+
overlay.classList.add('open');
|
|
838
|
+
document.body.style.overflow = 'hidden';
|
|
839
|
+
} else if (action === 'close' || (action === 'toggle' && isOpen)) {
|
|
840
|
+
drawerEl.classList.remove('open');
|
|
841
|
+
overlay.classList.remove('open');
|
|
842
|
+
document.body.style.overflow = '';
|
|
843
|
+
setTimeout(() => {
|
|
844
|
+
if (overlay && overlay.parentNode && !drawerEl.classList.contains('open')) {
|
|
845
|
+
overlay.remove();
|
|
846
|
+
}
|
|
847
|
+
}, 300);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (component === 'carousel') {
|
|
851
|
+
const selector = (options && options.selector) || '.carousel';
|
|
852
|
+
const carousels = document.querySelectorAll(selector);
|
|
853
|
+
carousels.forEach(carousel => initSingleCarousel(carousel, options));
|
|
854
|
+
}
|
|
855
|
+
if (component === 'datatable' || component === 'table') {
|
|
856
|
+
const containerId = (options && (options.container || options.id)) || 'datatable';
|
|
857
|
+
return new ResponsiveDataTable(containerId, options);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function snackbar(options) {
|
|
861
|
+
bluebird('snackbar', options);
|
|
862
|
+
}
|
|
863
|
+
function toast(options) {
|
|
864
|
+
bluebird('toast', options);
|
|
865
|
+
}
|
|
866
|
+
function dismissToast(toastEl) {
|
|
867
|
+
if (!toastEl || toastEl.isDismissing) return;
|
|
868
|
+
toastEl.isDismissing = true;
|
|
869
|
+
toastEl.style.opacity = '0';
|
|
870
|
+
toastEl.style.transform = 'translateY(-10px) scale(0.95)';
|
|
871
|
+
setTimeout(() => {
|
|
872
|
+
if (toastEl.parentNode) {
|
|
873
|
+
toastEl.remove();
|
|
874
|
+
}
|
|
875
|
+
}, 200);
|
|
876
|
+
}
|
|
877
|
+
function createCommandPaletteModal() {
|
|
878
|
+
const backdrop = document.createElement('div');
|
|
879
|
+
backdrop.className = 'command-backdrop';
|
|
880
|
+
backdrop.innerHTML = `
|
|
881
|
+
<div class="command-dialog">
|
|
882
|
+
<div class="command-input-wrapper">
|
|
883
|
+
<span>🔍</span>
|
|
884
|
+
<input type="text" class="command-input" placeholder="Type a command or search documentation..." />
|
|
885
|
+
<kbd>ESC</kbd>
|
|
886
|
+
</div>
|
|
887
|
+
<div class="command-list">
|
|
888
|
+
<div class="command-group">
|
|
889
|
+
<div class="command-group-title">Navigation</div>
|
|
890
|
+
<div class="command-item" data-navigate="#/"><span>Documentation Home</span><kbd>↵</kbd></div>
|
|
891
|
+
<div class="command-item" data-navigate="#/buttons"><span>Buttons & Badges</span><kbd>↵</kbd></div>
|
|
892
|
+
<div class="command-item" data-navigate="#/forms"><span>Forms & Inputs</span><kbd>↵</kbd></div>
|
|
893
|
+
</div>
|
|
894
|
+
<div class="command-group">
|
|
895
|
+
<div class="command-group-title">Components</div>
|
|
896
|
+
<div class="command-item" data-navigate="#/carousel"><span>Touch Carousel</span><kbd>↵</kbd></div>
|
|
897
|
+
<div class="command-item" data-navigate="#/aside-drawer"><span>Aside & Drawers</span><kbd>↵</kbd></div>
|
|
898
|
+
<div class="command-item" data-navigate="#/animations"><span>CSS Animations</span><kbd>↵</kbd></div>
|
|
899
|
+
</div>
|
|
900
|
+
</div>
|
|
901
|
+
</div>
|
|
902
|
+
`;
|
|
903
|
+
document.body.appendChild(backdrop);
|
|
904
|
+
backdrop.addEventListener('click', (e) => {
|
|
905
|
+
if (e.target === backdrop) {
|
|
906
|
+
bluebird('command', { action: 'close' });
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
const input = backdrop.querySelector('.command-input');
|
|
910
|
+
input.addEventListener('input', (e) => {
|
|
911
|
+
const query = e.target.value.toLowerCase().trim();
|
|
912
|
+
const items = backdrop.querySelectorAll('.command-item');
|
|
913
|
+
items.forEach(item => {
|
|
914
|
+
const text = item.textContent.toLowerCase();
|
|
915
|
+
item.style.display = text.includes(query) ? 'flex' : 'none';
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
backdrop.addEventListener('click', (e) => {
|
|
919
|
+
const item = e.target.closest('.command-item');
|
|
920
|
+
if (item && item.getAttribute('data-navigate')) {
|
|
921
|
+
window.location.hash = item.getAttribute('data-navigate');
|
|
922
|
+
bluebird('command', { action: 'close' });
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
return backdrop;
|
|
926
|
+
}
|
|
927
|
+
function cleanupOrphanedBackdrops() {
|
|
928
|
+
document.querySelectorAll('.drawer-backdrop[data-for]').forEach(backdrop => {
|
|
929
|
+
const targetId = backdrop.getAttribute('data-for');
|
|
930
|
+
if (!document.getElementById(targetId)) {
|
|
931
|
+
backdrop.remove();
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
function initMobileDrawer() {
|
|
936
|
+
const mainEl = document.querySelector('main');
|
|
937
|
+
const aside = mainEl ? mainEl.querySelector(':scope > aside') : null;
|
|
938
|
+
if (!aside) return;
|
|
939
|
+
let overlay = document.querySelector('.bluebird-drawer-overlay');
|
|
940
|
+
if (!overlay) {
|
|
941
|
+
overlay = document.createElement('div');
|
|
942
|
+
overlay.className = 'bluebird-drawer-overlay';
|
|
943
|
+
document.body.appendChild(overlay);
|
|
944
|
+
}
|
|
945
|
+
let drawer = document.querySelector('.bluebird-drawer');
|
|
946
|
+
if (!drawer) {
|
|
947
|
+
drawer = document.createElement('div');
|
|
948
|
+
drawer.className = 'bluebird-drawer';
|
|
949
|
+
document.body.appendChild(drawer);
|
|
950
|
+
}
|
|
951
|
+
drawer.innerHTML = aside.innerHTML;
|
|
952
|
+
let toggle = document.querySelector('.bluebird-drawer-toggle');
|
|
953
|
+
if (!toggle) {
|
|
954
|
+
toggle = document.createElement('button');
|
|
955
|
+
toggle.className = 'bluebird-drawer-toggle';
|
|
956
|
+
toggle.innerHTML = '☰';
|
|
957
|
+
toggle.setAttribute('aria-label', 'Toggle navigation menu');
|
|
958
|
+
const header = document.querySelector('header');
|
|
959
|
+
if (header) {
|
|
960
|
+
const nav = header.querySelector('nav');
|
|
961
|
+
if (nav) {
|
|
962
|
+
nav.insertBefore(toggle, nav.firstChild);
|
|
963
|
+
} else {
|
|
964
|
+
header.prepend(toggle);
|
|
965
|
+
}
|
|
966
|
+
} else {
|
|
967
|
+
document.body.prepend(toggle);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (!window.__BLUEBIRD_UI_BOUND__) {
|
|
972
|
+
window.addEventListener('click', function (e) {
|
|
973
|
+
const tabTrigger = e.target.closest('[data-tab-target], .tab-trigger');
|
|
974
|
+
if (tabTrigger) {
|
|
975
|
+
const targetId = tabTrigger.getAttribute('data-tab-target') || (tabTrigger.getAttribute('href') || '').replace('#', '');
|
|
976
|
+
if (targetId) {
|
|
977
|
+
e.preventDefault();
|
|
978
|
+
bluebird('tab', { id: targetId });
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
const popoverTrigger = e.target.closest('[data-popover-target]');
|
|
982
|
+
if (popoverTrigger) {
|
|
983
|
+
const popoverId = popoverTrigger.getAttribute('data-popover-target');
|
|
984
|
+
bluebird('popover', { id: popoverId, action: 'toggle' });
|
|
985
|
+
}
|
|
986
|
+
if (!e.target.closest('.popover') && !e.target.closest('[data-popover-target]')) {
|
|
987
|
+
document.querySelectorAll('.popover.open').forEach(p => p.classList.remove('open'));
|
|
988
|
+
}
|
|
989
|
+
const mobileToggle = e.target.closest('.bluebird-drawer-toggle');
|
|
990
|
+
if (mobileToggle) {
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
e.stopPropagation();
|
|
993
|
+
initMobileDrawer();
|
|
994
|
+
const drawer = document.querySelector('.bluebird-drawer');
|
|
995
|
+
const overlay = document.querySelector('.bluebird-drawer-overlay');
|
|
996
|
+
if (drawer && overlay) {
|
|
997
|
+
const isOpen = drawer.classList.contains('open');
|
|
998
|
+
if (isOpen) {
|
|
999
|
+
drawer.classList.remove('open');
|
|
1000
|
+
overlay.classList.remove('open');
|
|
1001
|
+
document.body.style.overflow = '';
|
|
1002
|
+
} else {
|
|
1003
|
+
drawer.classList.add('open');
|
|
1004
|
+
overlay.classList.add('open');
|
|
1005
|
+
document.body.style.overflow = 'hidden';
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (e.target.closest('.bluebird-drawer-overlay')) {
|
|
1011
|
+
const drawer = document.querySelector('.bluebird-drawer');
|
|
1012
|
+
const overlay = document.querySelector('.bluebird-drawer-overlay');
|
|
1013
|
+
if (drawer) drawer.classList.remove('open');
|
|
1014
|
+
if (overlay) overlay.classList.remove('open');
|
|
1015
|
+
document.body.style.overflow = '';
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
if (e.target.closest('.bluebird-drawer a')) {
|
|
1019
|
+
const drawer = document.querySelector('.bluebird-drawer');
|
|
1020
|
+
const overlay = document.querySelector('.bluebird-drawer-overlay');
|
|
1021
|
+
if (drawer) drawer.classList.remove('open');
|
|
1022
|
+
if (overlay) overlay.classList.remove('open');
|
|
1023
|
+
document.body.style.overflow = '';
|
|
1024
|
+
}
|
|
1025
|
+
const btn = e.target.closest("button, a[role='button']");
|
|
1026
|
+
if (btn && !btn.classList.contains('fab') && !btn.classList.contains('carousel-nav') && !btn.classList.contains('bluebird-drawer-toggle')) {
|
|
1027
|
+
const rect = btn.getBoundingClientRect();
|
|
1028
|
+
const size = Math.max(rect.width, rect.height);
|
|
1029
|
+
const x = e.clientX - rect.left - size / 2;
|
|
1030
|
+
const y = e.clientY - rect.top - size / 2;
|
|
1031
|
+
const ripple = document.createElement('span');
|
|
1032
|
+
ripple.className = 'ripple';
|
|
1033
|
+
ripple.style.width = ripple.style.height = size + 'px';
|
|
1034
|
+
ripple.style.left = x + 'px';
|
|
1035
|
+
ripple.style.top = y + 'px';
|
|
1036
|
+
btn.appendChild(ripple);
|
|
1037
|
+
ripple.addEventListener('animationend', () => ripple.remove());
|
|
1038
|
+
}
|
|
1039
|
+
const drawerTrigger = e.target.closest('[data-drawer-target]');
|
|
1040
|
+
if (drawerTrigger) {
|
|
1041
|
+
const id = drawerTrigger.getAttribute('data-drawer-target');
|
|
1042
|
+
bluebird('drawer', { id, action: 'toggle' });
|
|
1043
|
+
}
|
|
1044
|
+
const drawerClose = e.target.closest('[data-drawer-close]');
|
|
1045
|
+
if (drawerClose) {
|
|
1046
|
+
const drawerEl = drawerClose.closest('.drawer');
|
|
1047
|
+
if (drawerEl && drawerEl.id) {
|
|
1048
|
+
bluebird('drawer', { id: drawerEl.id, action: 'close' });
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
function initSingleCarousel(carousel, opts = {}) {
|
|
1054
|
+
if (carousel._bb_initialized) return;
|
|
1055
|
+
carousel._bb_initialized = true;
|
|
1056
|
+
const track = carousel.querySelector('.carousel-track');
|
|
1057
|
+
if (!track) return;
|
|
1058
|
+
const items = Array.from(track.querySelectorAll('.carousel-item, .carousel-card'));
|
|
1059
|
+
if (items.length === 0) return;
|
|
1060
|
+
const prevBtn = carousel.querySelector('.carousel-prev');
|
|
1061
|
+
const nextBtn = carousel.querySelector('.carousel-next');
|
|
1062
|
+
let indicatorsContainer = carousel.querySelector('.carousel-indicators');
|
|
1063
|
+
let currentSlideIndex = 0;
|
|
1064
|
+
if (indicatorsContainer && indicatorsContainer.children.length === 0) {
|
|
1065
|
+
items.forEach((_, idx) => {
|
|
1066
|
+
const dot = document.createElement('button');
|
|
1067
|
+
dot.className = `carousel-dot ${idx === 0 ? 'active' : ''}`;
|
|
1068
|
+
dot.setAttribute('aria-label', `Go to slide ${idx + 1}`);
|
|
1069
|
+
dot.addEventListener('click', (e) => {
|
|
1070
|
+
e.preventDefault();
|
|
1071
|
+
scrollToSlide(idx);
|
|
1072
|
+
});
|
|
1073
|
+
indicatorsContainer.appendChild(dot);
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
function scrollToSlide(index) {
|
|
1077
|
+
if (index < 0) index = 0;
|
|
1078
|
+
if (index >= items.length) index = items.length - 1;
|
|
1079
|
+
currentSlideIndex = index;
|
|
1080
|
+
const targetItem = items[index];
|
|
1081
|
+
if (targetItem) {
|
|
1082
|
+
track.scrollTo({
|
|
1083
|
+
left: targetItem.offsetLeft - track.offsetLeft,
|
|
1084
|
+
behavior: 'smooth'
|
|
1085
|
+
});
|
|
1086
|
+
updateIndicators(index);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
function updateIndicators(activeIndex) {
|
|
1090
|
+
if (!indicatorsContainer) return;
|
|
1091
|
+
const dots = Array.from(indicatorsContainer.children);
|
|
1092
|
+
dots.forEach((dot, idx) => {
|
|
1093
|
+
dot.classList.toggle('active', idx === activeIndex);
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
let scrollTimeout;
|
|
1097
|
+
track.addEventListener('scroll', () => {
|
|
1098
|
+
clearTimeout(scrollTimeout);
|
|
1099
|
+
scrollTimeout = setTimeout(() => {
|
|
1100
|
+
const trackLeft = track.scrollLeft;
|
|
1101
|
+
let closestIndex = 0;
|
|
1102
|
+
let minDistance = Infinity;
|
|
1103
|
+
items.forEach((item, idx) => {
|
|
1104
|
+
const distance = Math.abs(item.offsetLeft - track.offsetLeft - trackLeft);
|
|
1105
|
+
if (distance < minDistance) {
|
|
1106
|
+
minDistance = distance;
|
|
1107
|
+
closestIndex = idx;
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
currentSlideIndex = closestIndex;
|
|
1111
|
+
updateIndicators(closestIndex);
|
|
1112
|
+
}, 40);
|
|
1113
|
+
});
|
|
1114
|
+
if (prevBtn) {
|
|
1115
|
+
prevBtn.addEventListener('click', (e) => {
|
|
1116
|
+
e.preventDefault();
|
|
1117
|
+
e.stopPropagation();
|
|
1118
|
+
scrollToSlide(currentSlideIndex - 1);
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
if (nextBtn) {
|
|
1122
|
+
nextBtn.addEventListener('click', (e) => {
|
|
1123
|
+
e.preventDefault();
|
|
1124
|
+
e.stopPropagation();
|
|
1125
|
+
scrollToSlide(currentSlideIndex + 1);
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
let startX = 0;
|
|
1129
|
+
let isDragging = false;
|
|
1130
|
+
track.addEventListener('touchstart', (e) => {
|
|
1131
|
+
startX = e.touches[0].clientX;
|
|
1132
|
+
isDragging = true;
|
|
1133
|
+
}, { passive: true });
|
|
1134
|
+
track.addEventListener('touchend', (e) => {
|
|
1135
|
+
if (!isDragging) return;
|
|
1136
|
+
isDragging = false;
|
|
1137
|
+
const endX = e.changedTouches[0].clientX;
|
|
1138
|
+
const diffX = startX - endX;
|
|
1139
|
+
if (Math.abs(diffX) > 35) {
|
|
1140
|
+
if (diffX > 0) {
|
|
1141
|
+
scrollToSlide(currentSlideIndex + 1);
|
|
1142
|
+
} else {
|
|
1143
|
+
scrollToSlide(currentSlideIndex - 1);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
track.addEventListener('mousedown', (e) => {
|
|
1148
|
+
startX = e.clientX;
|
|
1149
|
+
isDragging = true;
|
|
1150
|
+
track.style.cursor = 'grabbing';
|
|
1151
|
+
});
|
|
1152
|
+
track.addEventListener('mouseleave', () => {
|
|
1153
|
+
isDragging = false;
|
|
1154
|
+
track.style.cursor = 'grab';
|
|
1155
|
+
});
|
|
1156
|
+
track.addEventListener('mouseup', (e) => {
|
|
1157
|
+
if (!isDragging) return;
|
|
1158
|
+
isDragging = false;
|
|
1159
|
+
track.style.cursor = 'grab';
|
|
1160
|
+
const endX = e.clientX;
|
|
1161
|
+
const diffX = startX - endX;
|
|
1162
|
+
if (Math.abs(diffX) > 35) {
|
|
1163
|
+
if (diffX > 0) {
|
|
1164
|
+
scrollToSlide(currentSlideIndex + 1);
|
|
1165
|
+
} else {
|
|
1166
|
+
scrollToSlide(currentSlideIndex - 1);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
const isAutoplay = (opts && opts.autoplay) || carousel.getAttribute('data-autoplay') === 'true';
|
|
1171
|
+
const intervalTime = parseInt((opts && opts.interval) || carousel.getAttribute('data-interval') || 3500, 10);
|
|
1172
|
+
if (isAutoplay) {
|
|
1173
|
+
let autoInterval = setInterval(() => {
|
|
1174
|
+
const nextIdx = (currentSlideIndex + 1) % items.length;
|
|
1175
|
+
scrollToSlide(nextIdx);
|
|
1176
|
+
}, intervalTime);
|
|
1177
|
+
carousel.addEventListener('mouseenter', () => clearInterval(autoInterval));
|
|
1178
|
+
carousel.addEventListener('mouseleave', () => {
|
|
1179
|
+
autoInterval = setInterval(() => {
|
|
1180
|
+
const nextIdx = (currentSlideIndex + 1) % items.length;
|
|
1181
|
+
scrollToSlide(nextIdx);
|
|
1182
|
+
}, intervalTime);
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
(function setupDeclarativeListeners() {
|
|
1187
|
+
if (window.__BLUEBIRD_UI_BOUND__) return;
|
|
1188
|
+
window.__BLUEBIRD_UI_BOUND__ = true;
|
|
1189
|
+
document.addEventListener('click', (e) => {
|
|
1190
|
+
const copyTrigger = e.target.closest('[data-copy]');
|
|
1191
|
+
if (copyTrigger) {
|
|
1192
|
+
e.preventDefault();
|
|
1193
|
+
const targetAttr = copyTrigger.getAttribute('data-copy');
|
|
1194
|
+
let textToCopy = targetAttr;
|
|
1195
|
+
if (targetAttr && (targetAttr.startsWith('#') || targetAttr.startsWith('.'))) {
|
|
1196
|
+
const targetEl = document.querySelector(targetAttr);
|
|
1197
|
+
if (targetEl) {
|
|
1198
|
+
textToCopy = targetEl.value !== undefined ? targetEl.value : (targetEl.innerText || targetEl.textContent);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
if (textToCopy) {
|
|
1202
|
+
navigator.clipboard.writeText(textToCopy.trim()).then(() => {
|
|
1203
|
+
copyTrigger.classList.add('copied');
|
|
1204
|
+
if (typeof bluebird === 'function') {
|
|
1205
|
+
bluebird('toast', {
|
|
1206
|
+
title: 'Copied to clipboard',
|
|
1207
|
+
description: textToCopy.length > 50 ? textToCopy.substring(0, 50) + '...' : textToCopy,
|
|
1208
|
+
type: 'success',
|
|
1209
|
+
duration: 2500
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
setTimeout(() => copyTrigger.classList.remove('copied'), 2000);
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const confirmTrigger = e.target.closest('[data-confirm]');
|
|
1218
|
+
if (confirmTrigger) {
|
|
1219
|
+
const msg = confirmTrigger.getAttribute('data-confirm') || 'Are you sure?';
|
|
1220
|
+
if (!window.confirm(msg)) {
|
|
1221
|
+
e.preventDefault();
|
|
1222
|
+
e.stopImmediatePropagation();
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
const scrollTrigger = e.target.closest('[data-scroll-to]');
|
|
1227
|
+
if (scrollTrigger) {
|
|
1228
|
+
e.preventDefault();
|
|
1229
|
+
const targetId = scrollTrigger.getAttribute('data-scroll-to');
|
|
1230
|
+
const targetEl = document.querySelector(targetId);
|
|
1231
|
+
if (targetEl) {
|
|
1232
|
+
targetEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
1233
|
+
}
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
const passToggle = e.target.closest('[data-password-toggle]');
|
|
1237
|
+
if (passToggle) {
|
|
1238
|
+
e.preventDefault();
|
|
1239
|
+
const targetSelector = passToggle.getAttribute('data-password-toggle');
|
|
1240
|
+
const input = targetSelector
|
|
1241
|
+
? document.querySelector(targetSelector)
|
|
1242
|
+
: (passToggle.closest('.input-group, .form-input-group, div')?.querySelector('input') || passToggle.previousElementSibling);
|
|
1243
|
+
if (input && (input.type === 'password' || input.type === 'text')) {
|
|
1244
|
+
const isPassword = input.type === 'password';
|
|
1245
|
+
input.type = isPassword ? 'text' : 'password';
|
|
1246
|
+
passToggle.classList.toggle('showing', isPassword);
|
|
1247
|
+
passToggle.setAttribute('aria-pressed', isPassword ? 'true' : 'false');
|
|
1248
|
+
}
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
const stepUp = e.target.closest('[data-step-up]');
|
|
1252
|
+
if (stepUp) {
|
|
1253
|
+
e.preventDefault();
|
|
1254
|
+
const targetInput = document.querySelector(stepUp.getAttribute('data-step-up')) ||
|
|
1255
|
+
stepUp.closest('.stepper')?.querySelector('input[type="number"]');
|
|
1256
|
+
if (targetInput && typeof targetInput.stepUp === 'function') {
|
|
1257
|
+
targetInput.stepUp();
|
|
1258
|
+
targetInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1259
|
+
targetInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
1260
|
+
}
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
const stepDown = e.target.closest('[data-step-down]');
|
|
1264
|
+
if (stepDown) {
|
|
1265
|
+
e.preventDefault();
|
|
1266
|
+
const targetInput = document.querySelector(stepDown.getAttribute('data-step-down')) ||
|
|
1267
|
+
stepDown.closest('.stepper')?.querySelector('input[type="number"]');
|
|
1268
|
+
if (targetInput && typeof targetInput.stepDown === 'function') {
|
|
1269
|
+
targetInput.stepDown();
|
|
1270
|
+
targetInput.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1271
|
+
targetInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
1272
|
+
}
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
const selectItem = e.target.closest('[data-select-value]');
|
|
1276
|
+
if (selectItem) {
|
|
1277
|
+
const val = selectItem.getAttribute('data-select-value');
|
|
1278
|
+
const targetSelector = selectItem.getAttribute('data-select-target') ||
|
|
1279
|
+
selectItem.closest('[data-select-container]')?.getAttribute('data-select-target');
|
|
1280
|
+
if (targetSelector) {
|
|
1281
|
+
const targetEl = document.querySelector(targetSelector);
|
|
1282
|
+
if (targetEl) {
|
|
1283
|
+
if (targetEl.tagName === 'INPUT' || targetEl.tagName === 'SELECT') {
|
|
1284
|
+
targetEl.value = val;
|
|
1285
|
+
targetEl.dispatchEvent(new Event('input', { bubbles: true }));
|
|
1286
|
+
targetEl.dispatchEvent(new Event('change', { bubbles: true }));
|
|
1287
|
+
} else {
|
|
1288
|
+
targetEl.textContent = selectItem.textContent.trim();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
const parentDropdown = selectItem.closest('.dropdown-content, .popover-content');
|
|
1293
|
+
if (parentDropdown) {
|
|
1294
|
+
parentDropdown.classList.remove('open');
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const modalTrigger = e.target.closest('[data-toggle="modal"], [data-modal-target], [data-dialog-target]');
|
|
1298
|
+
if (modalTrigger) {
|
|
1299
|
+
e.preventDefault();
|
|
1300
|
+
const targetSelector = modalTrigger.getAttribute('data-modal-target') ||
|
|
1301
|
+
modalTrigger.getAttribute('data-dialog-target') ||
|
|
1302
|
+
modalTrigger.getAttribute('data-target') ||
|
|
1303
|
+
modalTrigger.getAttribute('href');
|
|
1304
|
+
if (targetSelector) {
|
|
1305
|
+
const dialog = document.querySelector(targetSelector);
|
|
1306
|
+
if (dialog && typeof dialog.showModal === 'function') {
|
|
1307
|
+
dialog.showModal();
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
const dismissTrigger = e.target.closest('[data-dismiss="modal"], [data-close-dialog], [data-close-modal]');
|
|
1313
|
+
if (dismissTrigger) {
|
|
1314
|
+
e.preventDefault();
|
|
1315
|
+
const dialog = dismissTrigger.closest('dialog') ||
|
|
1316
|
+
document.querySelector(dismissTrigger.getAttribute('data-target') || '');
|
|
1317
|
+
if (dialog && typeof dialog.close === 'function') {
|
|
1318
|
+
dialog.close();
|
|
1319
|
+
}
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
const themeTrigger = e.target.closest('[data-toggle="theme"]');
|
|
1323
|
+
if (themeTrigger) {
|
|
1324
|
+
e.preventDefault();
|
|
1325
|
+
const html = document.documentElement;
|
|
1326
|
+
const current = html.getAttribute('data-theme') || 'light';
|
|
1327
|
+
const next = current === 'dark' ? 'light' : 'dark';
|
|
1328
|
+
html.setAttribute('data-theme', next);
|
|
1329
|
+
try {
|
|
1330
|
+
localStorage.setItem('bluebird-theme', next);
|
|
1331
|
+
} catch (err) { }
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
const toastTrigger = e.target.closest('[data-toast]');
|
|
1335
|
+
if (toastTrigger) {
|
|
1336
|
+
e.preventDefault();
|
|
1337
|
+
const desc = toastTrigger.getAttribute('data-toast') || '';
|
|
1338
|
+
const title = toastTrigger.getAttribute('data-toast-title') || '';
|
|
1339
|
+
const type = toastTrigger.getAttribute('data-toast-type') || 'info';
|
|
1340
|
+
if (typeof bluebird === 'function') {
|
|
1341
|
+
bluebird('toast', { title, description: desc, type });
|
|
1342
|
+
}
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
const snackbarTrigger = e.target.closest('[data-snackbar]');
|
|
1346
|
+
if (snackbarTrigger) {
|
|
1347
|
+
e.preventDefault();
|
|
1348
|
+
const message = snackbarTrigger.getAttribute('data-snackbar') || '';
|
|
1349
|
+
const type = snackbarTrigger.getAttribute('data-snackbar-type') || 'info';
|
|
1350
|
+
if (typeof bluebird === 'function') {
|
|
1351
|
+
bluebird('snackbar', { message, type });
|
|
1352
|
+
}
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
if (!e.target.closest('.dropdown') && !e.target.closest('.popover')) {
|
|
1356
|
+
document.querySelectorAll('.dropdown-content.open, .popover-content.open').forEach(el => {
|
|
1357
|
+
el.classList.remove('open');
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
document.addEventListener('input', (e) => {
|
|
1362
|
+
const filterInput = e.target.closest('[data-filter-target]');
|
|
1363
|
+
if (filterInput) {
|
|
1364
|
+
const targetSelector = filterInput.getAttribute('data-filter-target');
|
|
1365
|
+
const targetContainer = document.querySelector(targetSelector);
|
|
1366
|
+
if (targetContainer) {
|
|
1367
|
+
const query = filterInput.value.toLowerCase().trim();
|
|
1368
|
+
const items = targetContainer.querySelectorAll('[data-filter-item], li, tr, .card, .dropdown-item, .item');
|
|
1369
|
+
let visibleCount = 0;
|
|
1370
|
+
items.forEach(item => {
|
|
1371
|
+
const text = item.textContent.toLowerCase();
|
|
1372
|
+
const matches = text.includes(query);
|
|
1373
|
+
item.style.display = matches ? '' : 'none';
|
|
1374
|
+
if (matches) visibleCount++;
|
|
1375
|
+
});
|
|
1376
|
+
const emptyMsg = targetContainer.querySelector('.no-filter-results');
|
|
1377
|
+
if (emptyMsg) {
|
|
1378
|
+
emptyMsg.style.display = visibleCount === 0 ? 'block' : 'none';
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
if (e.target.matches('textarea[data-auto-resize]')) {
|
|
1383
|
+
const textarea = e.target;
|
|
1384
|
+
textarea.style.height = 'auto';
|
|
1385
|
+
textarea.style.height = (textarea.scrollHeight + 2) + 'px';
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
document.addEventListener('keydown', (e) => {
|
|
1389
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
|
1390
|
+
e.preventDefault();
|
|
1391
|
+
if (typeof bluebird === 'function') {
|
|
1392
|
+
bluebird('command', { action: 'toggle' });
|
|
1393
|
+
}
|
|
1394
|
+
} else if (e.key === 'Escape') {
|
|
1395
|
+
const openCommand = document.querySelector('.command-backdrop.open');
|
|
1396
|
+
if (openCommand && typeof bluebird === 'function') {
|
|
1397
|
+
bluebird('command', { action: 'close' });
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
})();
|
|
1402
|
+
(function () {
|
|
1403
|
+
function init() {
|
|
1404
|
+
cleanupOrphanedBackdrops();
|
|
1405
|
+
initMobileDrawer();
|
|
1406
|
+
document.querySelectorAll('.carousel').forEach(c => initSingleCarousel(c));
|
|
1407
|
+
document.querySelectorAll('textarea[data-auto-resize]').forEach(t => {
|
|
1408
|
+
t.style.height = 'auto';
|
|
1409
|
+
t.style.height = (t.scrollHeight + 2) + 'px';
|
|
1410
|
+
});
|
|
1411
|
+
try {
|
|
1412
|
+
const savedTheme = localStorage.getItem('bluebird-theme');
|
|
1413
|
+
if (savedTheme) {
|
|
1414
|
+
document.documentElement.setAttribute('data-theme', savedTheme);
|
|
1415
|
+
}
|
|
1416
|
+
} catch (e) { }
|
|
1417
|
+
}
|
|
1418
|
+
if (document.readyState === 'loading') {
|
|
1419
|
+
document.addEventListener('DOMContentLoaded', () => setTimeout(init, 50));
|
|
1420
|
+
} else {
|
|
1421
|
+
setTimeout(init, 50);
|
|
1422
|
+
}
|
|
1423
|
+
if (!window.__BLUEBIRD_INIT_BOUND__) {
|
|
1424
|
+
window.__BLUEBIRD_INIT_BOUND__ = true;
|
|
1425
|
+
window.addEventListener('bluebird:page-load', () => setTimeout(init, 20));
|
|
1426
|
+
window.addEventListener('bluebird:partial-load', () => setTimeout(init, 20));
|
|
1427
|
+
}
|
|
1428
|
+
})();
|
|
1429
|
+
async function Http(
|
|
1430
|
+
url = "/",
|
|
1431
|
+
method = "GET",
|
|
1432
|
+
body = false,
|
|
1433
|
+
bodyForm = false,
|
|
1434
|
+
headers = {},
|
|
1435
|
+
) {
|
|
1436
|
+
const csrfEl = document.getElementById("csrf") || document.querySelector('input[name="_csrf"]') || document.querySelector('meta[name="csrf-token"]');
|
|
1437
|
+
const csrfToken = csrfEl ? (csrfEl.value || csrfEl.getAttribute("content")) : null;
|
|
1438
|
+
const mergedHeaders = { ...headers };
|
|
1439
|
+
if (csrfToken) {
|
|
1440
|
+
mergedHeaders["X-CSRF-Token"] = csrfToken;
|
|
1441
|
+
}
|
|
1442
|
+
const upperMethod = String(method || "GET").toUpperCase();
|
|
1443
|
+
const options = { method: upperMethod, headers: mergedHeaders, credentials: "include" };
|
|
1444
|
+
if (body) {
|
|
1445
|
+
const payload = csrfToken ? { ...body, _csrf: csrfToken, csrf: csrfToken } : body;
|
|
1446
|
+
options["body"] = JSON.stringify(payload);
|
|
1447
|
+
if (!mergedHeaders["Content-Type"]) {
|
|
1448
|
+
mergedHeaders["Content-Type"] = "application/json";
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
if (bodyForm) {
|
|
1452
|
+
if (csrfToken && bodyForm instanceof FormData) {
|
|
1453
|
+
if (!bodyForm.has("_csrf")) bodyForm.append("_csrf", csrfToken);
|
|
1454
|
+
}
|
|
1455
|
+
options["body"] = bodyForm;
|
|
1456
|
+
}
|
|
1457
|
+
if (upperMethod !== "GET" && window.Bluebird && typeof window.Bluebird.clearPrefetch === "function") {
|
|
1458
|
+
window.Bluebird.clearPrefetch();
|
|
1459
|
+
}
|
|
1460
|
+
const response = await fetch(url, options);
|
|
1461
|
+
if (!response.ok) {
|
|
1462
|
+
let errorData;
|
|
1463
|
+
try {
|
|
1464
|
+
errorData = await response.json();
|
|
1465
|
+
} catch {
|
|
1466
|
+
errorData = { message: `HTTP Error ${response.status}: ${response.statusText}` };
|
|
1467
|
+
}
|
|
1468
|
+
throw new Error(errorData.message || errorData.msg || errorData.mensaje || "Fetch request failed");
|
|
1469
|
+
}
|
|
1470
|
+
return await response.json();
|
|
1471
|
+
}
|
|
1472
|
+
function getUrlParameter(name) {
|
|
1473
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
1474
|
+
}
|
|
1475
|
+
function lang(l = "es") {
|
|
1476
|
+
const docLang = document.documentElement.lang || "es";
|
|
1477
|
+
return docLang === l || docLang.startsWith(l);
|
|
1478
|
+
}
|
|
1479
|
+
class ResponsiveDataTable {
|
|
1480
|
+
constructor(containerId, options = {}) {
|
|
1481
|
+
this.container = typeof containerId === "string" ? document.getElementById(containerId) : containerId;
|
|
1482
|
+
if (!this.container) return;
|
|
1483
|
+
this.defaults = {
|
|
1484
|
+
data: [],
|
|
1485
|
+
columns: [],
|
|
1486
|
+
rowsPerPage: 10,
|
|
1487
|
+
search: true,
|
|
1488
|
+
pagination: true,
|
|
1489
|
+
headerTitles: {},
|
|
1490
|
+
summaryFields: ["id"],
|
|
1491
|
+
edit: false,
|
|
1492
|
+
delete: false,
|
|
1493
|
+
breakpoint: 768,
|
|
1494
|
+
};
|
|
1495
|
+
this.options = { ...this.defaults, ...options };
|
|
1496
|
+
this.currentPage = 1;
|
|
1497
|
+
this.filteredData = [...this.options.data];
|
|
1498
|
+
this.isMobile = window.innerWidth < this.options.breakpoint;
|
|
1499
|
+
this.init();
|
|
1500
|
+
window.addEventListener("resize", () => this.handleResize());
|
|
1501
|
+
}
|
|
1502
|
+
init() {
|
|
1503
|
+
this.renderContainer();
|
|
1504
|
+
this.updateTable();
|
|
1505
|
+
if (this.options.search) this.setupSearch();
|
|
1506
|
+
}
|
|
1507
|
+
handleResize() {
|
|
1508
|
+
const wasMobile = this.isMobile;
|
|
1509
|
+
this.isMobile = window.innerWidth < this.options.breakpoint;
|
|
1510
|
+
if (wasMobile !== this.isMobile) this.updateTable();
|
|
1511
|
+
}
|
|
1512
|
+
renderContainer() {
|
|
1513
|
+
this.container.innerHTML = `
|
|
1514
|
+
<section class="w-full">
|
|
1515
|
+
${this.options.search
|
|
1516
|
+
? `<div class="mb-4 flex items-center justify-between"><input type="search" class="datatable-search-input outline" placeholder="${lang() ? "Buscar..." : "Search..."}" aria-label="Search"/></div>`
|
|
1517
|
+
: ""
|
|
1518
|
+
}
|
|
1519
|
+
<div class="overflow-x-auto">
|
|
1520
|
+
<table class="datatable-table hidden"></table>
|
|
1521
|
+
<div class="datatable-mobile"></div>
|
|
1522
|
+
</div>
|
|
1523
|
+
${this.options.pagination ? `<nav class="datatable-pagination mt-4 flex items-center justify-center gap-1" aria-label="Pagination"></nav>` : ""}
|
|
1524
|
+
</section>`;
|
|
1525
|
+
}
|
|
1526
|
+
renderTable() {
|
|
1527
|
+
const table = this.container.querySelector(".datatable-table");
|
|
1528
|
+
const mobileView = this.container.querySelector(".datatable-mobile");
|
|
1529
|
+
if (!table || !mobileView) return;
|
|
1530
|
+
if (this.isMobile) {
|
|
1531
|
+
table.classList.add("hidden");
|
|
1532
|
+
mobileView.classList.remove("hidden");
|
|
1533
|
+
this.renderMobileView();
|
|
1534
|
+
} else {
|
|
1535
|
+
table.classList.remove("hidden");
|
|
1536
|
+
mobileView.classList.add("hidden");
|
|
1537
|
+
this.renderDesktopTable();
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
renderDesktopTable() {
|
|
1541
|
+
const table = this.container.querySelector(".datatable-table");
|
|
1542
|
+
table.innerHTML = `
|
|
1543
|
+
<thead>
|
|
1544
|
+
<tr class="datatable-header"></tr>
|
|
1545
|
+
</thead>
|
|
1546
|
+
<tbody class="datatable-body"></tbody>`;
|
|
1547
|
+
const headerRow = table.querySelector("thead tr");
|
|
1548
|
+
this.options.columns.forEach((column) => {
|
|
1549
|
+
const th = document.createElement("th");
|
|
1550
|
+
th.scope = "col";
|
|
1551
|
+
th.textContent =
|
|
1552
|
+
this.options.headerTitles[column.key] || column.title || column.key;
|
|
1553
|
+
headerRow.appendChild(th);
|
|
1554
|
+
});
|
|
1555
|
+
if (this.options.edit || this.options.delete) {
|
|
1556
|
+
const th = document.createElement("th");
|
|
1557
|
+
th.scope = "col";
|
|
1558
|
+
th.textContent = lang() ? "Acciones" : "Actions";
|
|
1559
|
+
headerRow.appendChild(th);
|
|
1560
|
+
}
|
|
1561
|
+
const startIndex = (this.currentPage - 1) * this.options.rowsPerPage;
|
|
1562
|
+
const endIndex = startIndex + this.options.rowsPerPage;
|
|
1563
|
+
const paginatedData = this.filteredData.slice(startIndex, endIndex);
|
|
1564
|
+
const tbody = table.querySelector("tbody");
|
|
1565
|
+
paginatedData.forEach((item) => {
|
|
1566
|
+
const row = document.createElement("tr");
|
|
1567
|
+
this.options.columns.forEach((column) => {
|
|
1568
|
+
const td = document.createElement("td");
|
|
1569
|
+
const value = item[column.key];
|
|
1570
|
+
if (
|
|
1571
|
+
value &&
|
|
1572
|
+
typeof value === "string" &&
|
|
1573
|
+
/<[a-z][\s\S]*>/i.test(value)
|
|
1574
|
+
) {
|
|
1575
|
+
td.innerHTML = value;
|
|
1576
|
+
} else {
|
|
1577
|
+
td.textContent = value !== undefined && value !== null ? value : "-";
|
|
1578
|
+
}
|
|
1579
|
+
row.appendChild(td);
|
|
1580
|
+
});
|
|
1581
|
+
if (this.options.edit || this.options.delete) {
|
|
1582
|
+
const td = document.createElement("td");
|
|
1583
|
+
const actionsDiv = document.createElement("div");
|
|
1584
|
+
actionsDiv.className = "flex items-center gap-2";
|
|
1585
|
+
if (this.options.edit) {
|
|
1586
|
+
const btn = document.createElement("button");
|
|
1587
|
+
btn.className = "outline";
|
|
1588
|
+
btn.textContent = lang() ? "Editar" : "Edit";
|
|
1589
|
+
btn.onclick = (e) => this.handleAction("edit", e, item);
|
|
1590
|
+
actionsDiv.appendChild(btn);
|
|
1591
|
+
}
|
|
1592
|
+
if (this.options.delete) {
|
|
1593
|
+
const btn = document.createElement("button");
|
|
1594
|
+
btn.className = "destructive";
|
|
1595
|
+
btn.textContent = lang() ? "Eliminar" : "Delete";
|
|
1596
|
+
btn.onclick = (e) => this.handleAction("delete", e, item);
|
|
1597
|
+
actionsDiv.appendChild(btn);
|
|
1598
|
+
}
|
|
1599
|
+
td.appendChild(actionsDiv);
|
|
1600
|
+
row.appendChild(td);
|
|
1601
|
+
}
|
|
1602
|
+
tbody.appendChild(row);
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
renderMobileView() {
|
|
1606
|
+
const mobileView = this.container.querySelector(".datatable-mobile");
|
|
1607
|
+
mobileView.innerHTML = "";
|
|
1608
|
+
const startIndex = (this.currentPage - 1) * this.options.rowsPerPage;
|
|
1609
|
+
const endIndex = startIndex + this.options.rowsPerPage;
|
|
1610
|
+
const paginatedData = this.filteredData.slice(startIndex, endIndex);
|
|
1611
|
+
paginatedData.forEach((item) => {
|
|
1612
|
+
const card = document.createElement("article");
|
|
1613
|
+
card.className = "card mb-4";
|
|
1614
|
+
const summary = document.createElement("h3");
|
|
1615
|
+
summary.className =
|
|
1616
|
+
"flex items-center justify-between font-bold mb-2 pb-2";
|
|
1617
|
+
this.options.summaryFields.forEach((fieldKey) => {
|
|
1618
|
+
const value = item[fieldKey];
|
|
1619
|
+
summary.innerHTML += `<span>${value !== undefined && value !== null ? value : "-"}</span>`;
|
|
1620
|
+
});
|
|
1621
|
+
card.appendChild(summary);
|
|
1622
|
+
const details = document.createElement("dl");
|
|
1623
|
+
details.className =
|
|
1624
|
+
"grid cols-1 gap-2 mb-2 pb-2";
|
|
1625
|
+
this.options.columns.forEach((column) => {
|
|
1626
|
+
if (this.options.summaryFields.includes(column.key)) return;
|
|
1627
|
+
const dt = document.createElement("dt");
|
|
1628
|
+
dt.className =
|
|
1629
|
+
"font-bold text-muted";
|
|
1630
|
+
dt.textContent =
|
|
1631
|
+
this.options.headerTitles[column.key] || column.title || column.key;
|
|
1632
|
+
const dd = document.createElement("dd");
|
|
1633
|
+
dd.className =
|
|
1634
|
+
"text-left";
|
|
1635
|
+
const cellValue = item[column.key];
|
|
1636
|
+
if (
|
|
1637
|
+
cellValue &&
|
|
1638
|
+
typeof cellValue === "string" &&
|
|
1639
|
+
/<[a-z][\s\S]*>/i.test(cellValue)
|
|
1640
|
+
) {
|
|
1641
|
+
dd.innerHTML = cellValue;
|
|
1642
|
+
} else {
|
|
1643
|
+
dd.textContent = cellValue !== undefined && cellValue !== null ? cellValue : "-";
|
|
1644
|
+
}
|
|
1645
|
+
details.appendChild(dt);
|
|
1646
|
+
details.appendChild(dd);
|
|
1647
|
+
});
|
|
1648
|
+
card.appendChild(details);
|
|
1649
|
+
if (this.options.edit || this.options.delete) {
|
|
1650
|
+
const actions = document.createElement("div");
|
|
1651
|
+
actions.className = "flex items-center gap-2 justify-end";
|
|
1652
|
+
if (this.options.edit) {
|
|
1653
|
+
const btn = document.createElement("button");
|
|
1654
|
+
btn.className = "outline";
|
|
1655
|
+
btn.textContent = lang() ? "Editar" : "Edit";
|
|
1656
|
+
btn.onclick = (e) => this.handleAction("edit", e, item);
|
|
1657
|
+
actions.appendChild(btn);
|
|
1658
|
+
}
|
|
1659
|
+
if (this.options.delete) {
|
|
1660
|
+
const btn = document.createElement("button");
|
|
1661
|
+
btn.className = "destructive";
|
|
1662
|
+
btn.textContent = lang() ? "Eliminar" : "Delete";
|
|
1663
|
+
btn.onclick = (e) => this.handleAction("delete", e, item);
|
|
1664
|
+
actions.appendChild(btn);
|
|
1665
|
+
}
|
|
1666
|
+
card.appendChild(actions);
|
|
1667
|
+
}
|
|
1668
|
+
mobileView.appendChild(card);
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
renderPagination() {
|
|
1672
|
+
const pagination = this.container.querySelector(".datatable-pagination");
|
|
1673
|
+
if (!pagination || !this.options.pagination) return;
|
|
1674
|
+
pagination.innerHTML = "";
|
|
1675
|
+
const pageCount = Math.ceil(
|
|
1676
|
+
this.filteredData.length / this.options.rowsPerPage,
|
|
1677
|
+
);
|
|
1678
|
+
if (pageCount <= 1) return;
|
|
1679
|
+
const baseClass = "px-3 py-2 outline";
|
|
1680
|
+
const activeClass = "px-3 py-2";
|
|
1681
|
+
const prevButton = document.createElement("button");
|
|
1682
|
+
prevButton.textContent = "«";
|
|
1683
|
+
prevButton.className = baseClass;
|
|
1684
|
+
prevButton.disabled = this.currentPage === 1;
|
|
1685
|
+
prevButton.onclick = () => this.changePage(this.currentPage - 1);
|
|
1686
|
+
pagination.appendChild(prevButton);
|
|
1687
|
+
const maxVisible = 5;
|
|
1688
|
+
let start = Math.max(1, this.currentPage - Math.floor(maxVisible / 2));
|
|
1689
|
+
let end = start + maxVisible - 1;
|
|
1690
|
+
if (end > pageCount) {
|
|
1691
|
+
end = pageCount;
|
|
1692
|
+
start = Math.max(1, end - maxVisible + 1);
|
|
1693
|
+
}
|
|
1694
|
+
if (start > 1) {
|
|
1695
|
+
const firstButton = document.createElement("button");
|
|
1696
|
+
firstButton.className = baseClass;
|
|
1697
|
+
firstButton.textContent = "1";
|
|
1698
|
+
firstButton.onclick = () => this.changePage(1);
|
|
1699
|
+
pagination.appendChild(firstButton);
|
|
1700
|
+
if (start > 2) pagination.appendChild(this.createEllipsis());
|
|
1701
|
+
}
|
|
1702
|
+
for (let i = start; i <= end; i++) {
|
|
1703
|
+
const button = document.createElement("button");
|
|
1704
|
+
button.className =
|
|
1705
|
+
i === this.currentPage ? activeClass : baseClass;
|
|
1706
|
+
button.textContent = i;
|
|
1707
|
+
button.onclick = () => this.changePage(i);
|
|
1708
|
+
pagination.appendChild(button);
|
|
1709
|
+
}
|
|
1710
|
+
if (end < pageCount) {
|
|
1711
|
+
if (end < pageCount - 1) pagination.appendChild(this.createEllipsis());
|
|
1712
|
+
const lastButton = document.createElement("button");
|
|
1713
|
+
lastButton.className = baseClass;
|
|
1714
|
+
lastButton.textContent = pageCount;
|
|
1715
|
+
lastButton.onclick = () => this.changePage(pageCount);
|
|
1716
|
+
pagination.appendChild(lastButton);
|
|
1717
|
+
}
|
|
1718
|
+
const nextButton = document.createElement("button");
|
|
1719
|
+
nextButton.className = baseClass;
|
|
1720
|
+
nextButton.textContent = "»";
|
|
1721
|
+
nextButton.disabled = this.currentPage === pageCount;
|
|
1722
|
+
nextButton.onclick = () => this.changePage(this.currentPage + 1);
|
|
1723
|
+
pagination.appendChild(nextButton);
|
|
1724
|
+
}
|
|
1725
|
+
createEllipsis() {
|
|
1726
|
+
const span = document.createElement("span");
|
|
1727
|
+
span.className = "px-2 text-muted";
|
|
1728
|
+
span.textContent = "...";
|
|
1729
|
+
return span;
|
|
1730
|
+
}
|
|
1731
|
+
changePage(page) {
|
|
1732
|
+
this.currentPage = page;
|
|
1733
|
+
this.updateTable();
|
|
1734
|
+
}
|
|
1735
|
+
handleAction(type, event, item) {
|
|
1736
|
+
if (!this.options[type]) return;
|
|
1737
|
+
const callback =
|
|
1738
|
+
typeof this.options[type] === "function"
|
|
1739
|
+
? this.options[type]
|
|
1740
|
+
: window[this.options[type]];
|
|
1741
|
+
if (typeof callback === "function") callback(event, item.id || item);
|
|
1742
|
+
}
|
|
1743
|
+
setupSearch() {
|
|
1744
|
+
const searchInput = this.container.querySelector(".datatable-search-input");
|
|
1745
|
+
if (!searchInput) return;
|
|
1746
|
+
searchInput.addEventListener("input", (e) => {
|
|
1747
|
+
const term = e.target.value.toLowerCase().trim();
|
|
1748
|
+
this.filteredData = this.options.data.filter((item) =>
|
|
1749
|
+
this.options.columns.some((column) =>
|
|
1750
|
+
String(item[column.key] || "")
|
|
1751
|
+
.toLowerCase()
|
|
1752
|
+
.includes(term),
|
|
1753
|
+
),
|
|
1754
|
+
);
|
|
1755
|
+
this.currentPage = 1;
|
|
1756
|
+
this.updateTable();
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
updateTable() {
|
|
1760
|
+
this.renderTable();
|
|
1761
|
+
if (this.options.pagination) this.renderPagination();
|
|
1762
|
+
}
|
|
1763
|
+
updateData(newData) {
|
|
1764
|
+
this.options.data = newData;
|
|
1765
|
+
this.filteredData = [...newData];
|
|
1766
|
+
this.currentPage = 1;
|
|
1767
|
+
this.updateTable();
|
|
1768
|
+
}
|
|
1769
|
+
updateColumns(newColumns) {
|
|
1770
|
+
this.options.columns = newColumns;
|
|
1771
|
+
this.updateTable();
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
if (typeof window !== "undefined") {
|
|
1775
|
+
window.ResponsiveDataTable = ResponsiveDataTable;
|
|
1776
|
+
window.Http = Http;
|
|
1777
|
+
window.getUrlParameter = getUrlParameter;
|
|
1778
|
+
window.snackbar = snackbar;
|
|
1779
|
+
window.toast = toast;
|
|
1780
|
+
window.bluebird = bluebird; window.dismissToast = dismissToast; window.initMobileDrawer = initMobileDrawer; window.initSingleCarousel = initSingleCarousel; window.lang = lang;
|
|
1663
1781
|
}
|