preact-missing-hooks 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -29,7 +29,7 @@ A lightweight, extendable collection of React-like hooks for Preact, including u
29
29
  - **`useNetworkState`** — Tracks online/offline status and connection details (type, downlink, RTT, save-data).
30
30
  - **`usePrefetch`** — Preload URLs (documents or data) so they are cached before navigation or use. Ideal for link hover or route preloading. Returns `prefetch(url, options?)` and `isPrefetched(url)`.
31
31
  - **`usePoll`** — Polls an async function at a fixed interval until it returns `{ done: true, data? }`. Stops on error. Returns `data`, `done`, `error`, `pollCount`, `start`, `stop`. Good for readiness checks or waiting on a backend job.
32
- - **`useDeviceData`** — Extracts device and browser data from native Navigator, Screen, `window`, and `matchMedia` APIs (language, platform, CPUs, memory, screen/viewport size, touch, color scheme, reduced motion, Client Hints). Optionally polls the Battery Status API. Updates on resize, orientation, and preference changes.
32
+ - **`useDeviceData`** — Extracts device and browser data from native Navigator, Screen, `window`, and `matchMedia` APIs (browser name/version, OS name/version, language, platform, CPUs, memory, screen/viewport size, touch, color scheme, reduced motion, Client Hints). Uses Client Hints high-entropy values when available. Optionally polls the Battery Status API. Updates on resize, orientation, and preference changes.
33
33
  - **`useClipboard`** — Copy and paste text with the Clipboard API, with copied/error state.
34
34
  - **`useRageClick`** — Detects rage clicks (repeated rapid clicks in the same spot). Use with Sentry or similar to detect and fix rage-click issues and lower rage-click-related support.
35
35
  - **`useThreadedWorker`** — Run async work in a queue with **sequential** (single worker, priority-ordered) or **parallel** (worker pool) mode. Optional priority (1 = highest); FIFO within same priority.
@@ -149,7 +149,7 @@ Or open `docs/index.html` after building (see [docs/README.md](docs/README.md) f
149
149
  | [useNetworkState](#usenetworkstate) | `const { online, effectiveType } = useNetworkState();` |
150
150
  | [usePrefetch](#useprefetch) | `const { prefetch, isPrefetched } = usePrefetch();` |
151
151
  | [usePoll](#usepoll) | `const { data, done, pollCount, stop } = usePoll(pollFn, { intervalMs });` |
152
- | [useDeviceData](#usedevicedata) | `const device = useDeviceData();` |
152
+ | [useDeviceData](#usedevicedata) | `const { browser, os } = useDeviceData();` — `browser.name`, `os.version`, viewport, etc. |
153
153
  | [useClipboard](#useclipboard) | `const { copy, paste, copied } = useClipboard();` |
154
154
  | [useRageClick](#userageclick) | `useRageClick(ref, { onRageClick, threshold: 5 });` |
155
155
  | [useThreadedWorker](#usethreadedworker) | `const { run, loading, result } = useThreadedWorker(fn, { mode: 'sequential' });` |
@@ -326,6 +326,30 @@ function NetworkStatus() {
326
326
 
327
327
  ---
328
328
 
329
+ ### `useDeviceData`
330
+
331
+ ```tsx
332
+ import { useDeviceData } from "preact-missing-hooks";
333
+
334
+ function EnvironmentBadge() {
335
+ const { browser, os, viewport } = useDeviceData({
336
+ includeBattery: false,
337
+ includeHighEntropy: true,
338
+ });
339
+
340
+ return (
341
+ <span>
342
+ {browser.name} {browser.version} · {os.name} {os.version} ·{" "}
343
+ {viewport.width}×{viewport.height}
344
+ </span>
345
+ );
346
+ }
347
+ ```
348
+
349
+ See [full `useDeviceData` docs](#usedevicedata) for all fields, `getDeviceData()`, and `parseUserAgent()`.
350
+
351
+ ---
352
+
329
353
  ### `useClipboard`
330
354
 
331
355
  ```tsx
@@ -420,49 +444,79 @@ function StatusPoller() {
420
444
 
421
445
  ### `useDeviceData`
422
446
 
423
- Reads device and browser information from native APIs (`navigator`, `screen`, `window`, `matchMedia`). No permissions required for the base snapshot; battery uses the [Battery Status API](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API) when available.
447
+ Reads device and browser information from native APIs (`navigator`, `screen`, `window`, `matchMedia`). Detects **browser** and **OS** name/version via [Client Hints](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData) when supported, with user-agent parsing as fallback. High-entropy hints (`platformVersion`, `fullVersionList`) refine versions when the browser allows it.
424
448
 
425
- Options: `includeBattery` (default `true`), `batteryPollIntervalMs` (default `60000`). Returns a `DeviceData` object that updates on resize, orientation, online/offline, and `prefers-color-scheme` / `prefers-reduced-motion` changes.
449
+ No permissions required for the base snapshot; battery uses the [Battery Status API](https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API) when available.
450
+
451
+ **Options**
452
+
453
+ | Option | Default | Description |
454
+ | --- | --- | --- |
455
+ | `includeBattery` | `true` | Poll `navigator.getBattery()` when available |
456
+ | `batteryPollIntervalMs` | `60000` | Battery refresh interval (ms) |
457
+ | `includeHighEntropy` | `true` | Request `platformVersion` / `fullVersionList` from Client Hints |
458
+
459
+ **Key return fields**
460
+
461
+ | Field | Description |
462
+ | --- | --- |
463
+ | `browser.name`, `browser.version` | Detected browser (e.g. Chrome, 120.0.0.0) |
464
+ | `os.name`, `os.version` | Detected OS (e.g. Windows, 10.0) |
465
+ | `language`, `languages` | Locale from `navigator` |
466
+ | `screen`, `viewport` | Display and window size |
467
+ | `hardwareConcurrency`, `deviceMemory` | CPU count, RAM hint (GB) |
468
+ | `colorScheme`, `reducedMotion` | `prefers-color-scheme` / `prefers-reduced-motion` |
469
+ | `userAgentData` | Raw Client Hints snapshot when available |
470
+ | `battery` | Charging state and level (0–1) when enabled |
471
+
472
+ Updates on resize, orientation, online/offline, and media preference changes.
426
473
 
427
474
  ```tsx
428
- import { useDeviceData } from "preact-missing-hooks";
475
+ import { useDeviceData, getDeviceData, parseUserAgent } from "preact-missing-hooks";
429
476
 
430
477
  function DeviceInfo() {
431
- const device = useDeviceData({ includeBattery: true });
478
+ const device = useDeviceData({
479
+ includeBattery: true,
480
+ includeHighEntropy: true,
481
+ });
432
482
 
433
483
  return (
434
- <dl>
435
- <dt>Language</dt>
436
- <dd>{device.language}</dd>
437
- <dt>CPUs</dt>
438
- <dd>{device.hardwareConcurrency ?? "—"}</dd>
439
- <dt>Viewport</dt>
440
- <dd>
441
- {device.viewport.width}×{device.viewport.height}
442
- </dd>
443
- <dt>Color scheme</dt>
444
- <dd>{device.colorScheme}</dd>
445
- {device.userAgentData && (
446
- <>
447
- <dt>Platform (Client Hints)</dt>
448
- <dd>{device.userAgentData.platform}</dd>
449
- </>
450
- )}
451
- {device.battery && (
452
- <>
453
- <dt>Battery</dt>
454
- <dd>
455
- {Math.round(device.battery.level * 100)}%
484
+ <section>
485
+ <h2>Environment</h2>
486
+ <p>
487
+ {device.browser.name} {device.browser.version} on {device.os.name}{" "}
488
+ {device.os.version}
489
+ </p>
490
+ <ul>
491
+ <li>Language: {device.language}</li>
492
+ <li>
493
+ Viewport: {device.viewport.width}×{device.viewport.height}
494
+ </li>
495
+ <li>CPUs: {device.hardwareConcurrency ?? "—"}</li>
496
+ <li>Theme: {device.colorScheme}</li>
497
+ {device.battery && (
498
+ <li>
499
+ Battery: {Math.round(device.battery.level * 100)}%
456
500
  {device.battery.charging ? " (charging)" : ""}
457
- </dd>
458
- </>
459
- )}
460
- </dl>
501
+ </li>
502
+ )}
503
+ </ul>
504
+ </section>
461
505
  );
462
506
  }
463
- ```
464
507
 
465
- You can also call `getDeviceData()` outside React for a one-off snapshot (e.g. analytics on load).
508
+ // One-off snapshot (e.g. analytics on page load)
509
+ const snapshot = getDeviceData();
510
+ sendAnalytics({
511
+ browser: snapshot.browser.name,
512
+ browserVersion: snapshot.browser.version,
513
+ os: snapshot.os.name,
514
+ osVersion: snapshot.os.version,
515
+ });
516
+
517
+ // Parse a custom UA string without the hook
518
+ const { browser, os } = parseUserAgent(customUserAgent);
519
+ ```
466
520
 
467
521
  ---
468
522
 
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("preact/hooks"),n=require("preact"),t=require("preact/compat"),r=new Map;function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function i(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return o(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u.apply(null,arguments)}function a(){if("undefined"==typeof navigator)return{online:!0};var e={online:navigator.onLine},n=navigator.connection;return n&&(void 0!==n.effectiveType&&(e.effectiveType=n.effectiveType),void 0!==n.downlink&&(e.downlink=n.downlink),void 0!==n.rtt&&(e.rtt=n.rtt),void 0!==n.saveData&&(e.saveData=n.saveData),void 0!==n.type&&(e.connectionType=n.type)),e}function c(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var l=new Map;function s(e){return new Promise(function(n,t){e.onsuccess=function(){return n(e.result)},e.onerror=function(){var n;return t(null!=(n=e.error)?n:new DOMException("Unknown IndexedDB error"))}})}function f(e,n){return n?e.then(function(e){return null==n.onSuccess||n.onSuccess(e),e}).catch(function(e){throw null==n.onError||n.onError(e),e}):e}var d=/\b(?:25[0-5]|2[0-4]\d|1?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|1?\d{1,2})){3}\b/g,v=["stun:stun.l.google.com:19302"];function p(e,n){if(null==e)return"";var t=("string"==typeof e?e:String(e)).trim();return t.length>n?t.slice(0,n):t}function m(e){if(!Array.isArray(e))return[];for(var n=[],t=0;t<e.length&&n.length<50;t++){var r=p(e[t],100);r&&n.push(r)}return n}function h(e){var n=p(e,2048);if(!n)return"";try{var t=new URL(n);if("http:"===t.protocol||"https:"===t.protocol)return n}catch(e){}return""}function g(e){try{if("undefined"==typeof window)return!1;var n=window.getComputedStyle(e);return"none"!==n.display&&"hidden"!==n.visibility&&"0"!==n.opacity}catch(e){return!1}}function y(e){var n={};try{for(var t,r=i(Object.keys(e).slice(0,20));!(t=r()).done;){var o=t.value,u=p(o,50);if(u){var a=e[o];"string"==typeof a?n[u]=a.slice(0,500):"number"==typeof a&&Number.isFinite(a)||"boolean"==typeof a?n[u]=a:Array.isArray(a)&&(n[u]=a.map(function(e){return p(e,200)}).filter(Boolean).slice(0,20))}}}catch(e){}return n}function w(){try{if("undefined"==typeof document||!document.querySelectorAll)return;document.querySelectorAll('script[data-llm="true"]').forEach(function(e){return e.remove()})}catch(e){}}var b="use-ref-print-target",S="use-ref-print-styles",E="\n@media print {\n body * {\n visibility: hidden;\n }\n ."+b+",\n ."+b+" * {\n visibility: visible;\n }\n ."+b+" {\n position: absolute !important;\n left: 0 !important;\n top: 0 !important;\n width: 100% !important;\n }\n}\n";function k(e,n){if("undefined"==typeof window)return null;var t="localStorage"===e?window.localStorage:window.sessionStorage;try{var r=t.getItem(n);if(null==r)return null;var o=JSON.parse(r);return o&&"object"==typeof o?o:null}catch(e){return null}}function x(e,n){if("undefined"==typeof window)return[];var t="localStorage"===e?window.localStorage:window.sessionStorage;try{var r=t.getItem(n);if(null==r)return[];var o=JSON.parse(r);return Array.isArray(o)?o.filter(function(e){return"string"==typeof e}):[]}catch(e){return[]}}function C(e,n){return n.filter(function(n){return n.condition(e)}).map(function(e){return e.role})}function P(e,n){for(var t,r=new Set,o=i(e);!(t=o()).done;){var u=n[t.value];if(Array.isArray(u))for(var a,c=i(u);!(a=c()).done;)r.add(a.value)}return Array.from(r)}var I={userAgent:"",language:"en",languages:["en"],platform:"",cookieEnabled:!1,online:!0,maxTouchPoints:0,vendor:"",touch:!1,screen:{width:0,height:0,availWidth:0,availHeight:0,colorDepth:24,pixelRatio:1},viewport:{width:0,height:0},reducedMotion:!1,colorScheme:"no-preference"};function M(){var e,n,t,r,o,i,u,a,c,l,s,f,d,v;if("undefined"==typeof navigator)return I;var p=navigator,m=void 0!==globalThis.screen?globalThis.screen:null,h=void 0!==globalThis.window?globalThis.window:null,g={userAgent:null!=(e=p.userAgent)?e:"",language:null!=(n=p.language)?n:"",languages:p.languages?[].concat(p.languages):[],platform:null!=(t=p.platform)?t:"",cookieEnabled:Boolean(p.cookieEnabled),online:Boolean(p.onLine),maxTouchPoints:null!=(r=p.maxTouchPoints)?r:0,vendor:null!=(o=p.vendor)?o:"",touch:(null!=(i=p.maxTouchPoints)?i:0)>0,screen:{width:null!=(u=null==m?void 0:m.width)?u:0,height:null!=(a=null==m?void 0:m.height)?a:0,availWidth:null!=(c=null==m?void 0:m.availWidth)?c:0,availHeight:null!=(l=null==m?void 0:m.availHeight)?l:0,colorDepth:null!=(s=null==m?void 0:m.colorDepth)?s:24,pixelRatio:null!=(f=null==h?void 0:h.devicePixelRatio)?f:1},viewport:{width:null!=(d=null==h?void 0:h.innerWidth)?d:0,height:null!=(v=null==h?void 0:h.innerHeight)?v:0},reducedMotion:!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,colorScheme:"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"no-preference":"no-preference"};"number"==typeof p.hardwareConcurrency&&(g.hardwareConcurrency=p.hardwareConcurrency),"number"==typeof p.deviceMemory&&(g.deviceMemory=p.deviceMemory);var y,w=p.userAgentData;return w&&(g.userAgentData={mobile:Boolean(w.mobile),platform:null!=(y=w.platform)?y:"",brands:w.brands?[].concat(w.brands):[]}),g}exports.getDeviceData=M,exports.useClipboard=function(n){void 0===n&&(n={});var t=n.resetDelay,r=void 0===t?2e3:t,o=e.useState(!1),i=o[0],u=o[1],a=e.useState(null),l=a[0],s=a[1],f=e.useCallback(function(){u(!1),s(null)},[]);return{copy:e.useCallback(function(e){try{if(s(null),"undefined"==typeof navigator||!navigator.clipboard){var n=new Error("Clipboard API is not available");return s(n),Promise.resolve(!1)}return Promise.resolve(c(function(){return Promise.resolve(navigator.clipboard.writeText(e)).then(function(){return u(!0),r>0&&setTimeout(function(){return u(!1)},r),!0})},function(e){var n=e instanceof Error?e:new Error(String(e));return s(n),!1}))}catch(e){return Promise.reject(e)}},[r]),paste:e.useCallback(function(){try{if(s(null),"undefined"==typeof navigator||!navigator.clipboard){var e=new Error("Clipboard API is not available");return s(e),Promise.resolve("")}return Promise.resolve(c(function(){return Promise.resolve(navigator.clipboard.readText())},function(e){var n=e instanceof Error?e:new Error(String(e));return s(n),""}))}catch(e){return Promise.reject(e)}},[]),copied:i,error:l,reset:f}},exports.useDeviceData=function(n){void 0===n&&(n={});var t=n.includeBattery,r=void 0===t||t,o=n.batteryPollIntervalMs,i=void 0===o?6e4:o,a=e.useState(function(){return M()}),c=a[0],l=a[1],s=e.useCallback(function(){l(function(e){var n=M();return e.battery?u({},n,{battery:e.battery}):n})},[]);return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){return s()};window.addEventListener("resize",e),window.addEventListener("orientationchange",e),window.addEventListener("online",s),window.addEventListener("offline",s);var n=null==window.matchMedia?void 0:window.matchMedia("(prefers-reduced-motion: reduce)"),t=null==window.matchMedia?void 0:window.matchMedia("(prefers-color-scheme: dark)"),r=null==window.matchMedia?void 0:window.matchMedia("(prefers-color-scheme: light)"),o=function(){return s()};return null==n||null==n.addEventListener||n.addEventListener("change",o),null==t||null==t.addEventListener||t.addEventListener("change",o),null==r||null==r.addEventListener||r.addEventListener("change",o),function(){window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e),window.removeEventListener("online",s),window.removeEventListener("offline",s),null==n||null==n.removeEventListener||n.removeEventListener("change",o),null==t||null==t.removeEventListener||t.removeEventListener("change",o),null==r||null==r.removeEventListener||r.removeEventListener("change",o)}}},[s]),e.useEffect(function(){if(r&&"undefined"!=typeof navigator){var e,n=!1,t=function(){return Promise.resolve(function(){try{if("undefined"==typeof navigator)return Promise.resolve(void 0);var e=navigator.getBattery;return Promise.resolve(e?function(){try{var n=Promise.resolve(e.call(navigator)).then(function(e){return{charging:e.charging,level:e.level}})}catch(e){return}return n&&n.then?n.then(void 0,function(){}):n}():void 0)}catch(e){return Promise.reject(e)}}()).then(function(e){n||void 0===e||l(function(n){return u({},n,{battery:e})})})};return t(),i>0&&(e=setInterval(function(){t()},i)),function(){n=!0,void 0!==e&&clearInterval(e)}}},[r,i]),c},exports.useEventBus=function(){return{emit:e.useCallback(function(e){var n=arguments,t=r.get(e);t&&t.forEach(function(e){return e.apply(void 0,[].slice.call(n,1))})},[]),on:e.useCallback(function(e,n){var t=r.get(e);return t||(t=new Set,r.set(e,t)),t.add(n),function(){t.delete(n),0===t.size&&r.delete(e)}},[])}},exports.useIndexedDB=function(n){var t=e.useState(null),r=t[0],o=t[1],a=e.useState(null),c=a[0],d=a[1],v=e.useState(!1),p=v[0],m=v[1],h=e.useRef(n);return h.current=n,e.useEffect(function(){var e=!1;d(null),m(!1),o(null);var n=h.current;return function(e){var n=e.name+"_v"+e.version,t=l.get(n);return t||(t=function(e){return new Promise(function(n,t){var r=indexedDB.open(e.name,e.version);r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Failed to open database"))},r.onsuccess=function(){return n(r.result)},r.onupgradeneeded=function(n){for(var t=n.target.result,r=e.tables,o=0,u=Object.keys(r);o<u.length;o++){var a=u[o],c=r[a];if(!t.objectStoreNames.contains(a)){var l,s=t.createObjectStore(a,{keyPath:c.keyPath,autoIncrement:null!=(l=c.autoIncrement)&&l});if(c.indexes)for(var f,d=i(c.indexes);!(f=d()).done;){var v=f.value;s.createIndex(v,v,{unique:!1})}}}}})}(e),l.set(n,t),t)}({name:n.name,version:n.version,tables:n.tables}).then(function(n){if(e)n.close();else{var t=function(e){return{get db(){return e},hasTable:function(n){return e.objectStoreNames.contains(n)},table:function(n){return function(e,n){return function(e,n){function t(t){return e.transaction([n],t).objectStore(n)}return{insert:function(e,n){return f(s(t("readwrite").add(e)),n)},update:function(e,n,r){var o=t("readwrite");return f(s(o.get(e)).then(function(e){if(void 0===e)throw new DOMException("Key not found","NotFoundError");var t=u({},e,n);return s(o.put(t))}).then(function(){}),r)},delete:function(e,n){return f(s(t("readwrite").delete(e)).then(function(){}),n)},exists:function(e){return s(t("readonly").getKey(e)).then(function(e){return void 0!==e})},query:function(e,n){var r=t("readonly").openCursor(),o=[];return f(new Promise(function(n,t){r.onsuccess=function(){var t=r.result;t?(e(t.value)&&o.push(t.value),t.continue()):n(o)},r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Unknown error"))}}),n)},upsert:function(e,n){return f(s(t("readwrite").put(e)),n)},bulkInsert:function(e,n){var r=t("readwrite"),o=[];if(0===e.length)return f(Promise.resolve(o),n);var i=0;return f(new Promise(function(n,t){e.forEach(function(u,a){var c=r.add(u);c.onsuccess=function(){o[a]=c.result,++i===e.length&&n(o)},c.onerror=function(){var e;return t(null!=(e=c.error)?e:new DOMException("Unknown error"))}})}),n)},clear:function(e){return f(s(t("readwrite").clear()).then(function(){}),e)},count:function(e){return f(s(t("readonly").count()),null!=e?e:{})}}}(e,n)}(e,n)},transaction:function(n,t,r,o){var i=e.transaction(n,t),a={table:function(e){return function(e,n){return function(e,n){function t(){return e.objectStore(n)}return{insert:function(e,n){return f(s(t().add(e)),n)},update:function(e,n,r){var o=t();return f(s(o.get(e)).then(function(e){if(void 0===e)throw new DOMException("Key not found","NotFoundError");var t=u({},e,n);return s(o.put(t))}).then(function(){}),r)},delete:function(e,n){return f(s(t().delete(e)).then(function(){}),n)},exists:function(e){return s(t().getKey(e)).then(function(e){return void 0!==e})},query:function(e,n){var r=t().openCursor(),o=[];return f(new Promise(function(n,t){r.onsuccess=function(){var t=r.result;t?(e(t.value)&&o.push(t.value),t.continue()):n(o)},r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Unknown error"))}}),n)},upsert:function(e,n){return f(s(t().put(e)),n)},bulkInsert:function(e,n){var r=t(),o=[];if(0===e.length)return f(Promise.resolve(o),n);var i=0;return f(new Promise(function(n,t){e.forEach(function(u,a){var c=r.add(u);c.onsuccess=function(){o[a]=c.result,++i===e.length&&n(o)},c.onerror=function(){var e;return t(null!=(e=c.error)?e:new DOMException("Unknown error"))}})}),n)},clear:function(e){return f(s(t().clear()).then(function(){}),e)},count:function(e){return f(s(t().count()),null!=e?e:{})}}}(e,n)}(i,e)}},c=new Promise(function(e,n){i.oncomplete=function(){return e()},i.onerror=function(){var e;return n(null!=(e=i.error)?e:new DOMException("Transaction failed"))}}),l=r(a);return function(e,n){return n?e.then(function(){return null==n.onSuccess?void 0:n.onSuccess()}).catch(function(e){throw null==n.onError||n.onError(e),e}):e}(Promise.resolve(l).then(function(){return c}),o)}}}(n);o(t),m(!0)}}).catch(function(n){e||d(n)}),function(){e=!0}},[n.name,n.version]),{db:r,isReady:p,error:c}},exports.useLLMMetadata=function(e){var n=t.useRef(null);t.useEffect(function(){try{if("undefined"==typeof window)return;var t=function(e){return null==e||"object"!=typeof e?{route:"/"}:{route:p(e.route,2048)||"/",mode:"auto-extract"===e.mode?"auto-extract":"manual",title:void 0!==e.title?p(e.title,200):void 0,description:void 0!==e.description?p(e.description,2e3):void 0,tags:void 0!==e.tags?m(e.tags):void 0,canonicalUrl:void 0!==e.canonicalUrl?h(e.canonicalUrl):void 0,language:void 0!==e.language?p(e.language,20):void 0,ogType:void 0!==e.ogType?p(e.ogType,50):void 0,ogImage:void 0!==e.ogImage?h(e.ogImage):void 0,ogImageAlt:void 0!==e.ogImageAlt?p(e.ogImageAlt,200):void 0,siteName:void 0!==e.siteName?p(e.siteName,100):void 0,author:void 0!==e.author?p(e.author,200):void 0,publishedTime:void 0!==e.publishedTime?p(e.publishedTime,50):void 0,modifiedTime:void 0!==e.modifiedTime?p(e.modifiedTime,50):void 0,robots:void 0!==e.robots?p(e.robots,100):void 0,extra:void 0===e.extra||"object"!=typeof e.extra||Array.isArray(e.extra)?void 0:y(e.extra)}}(e),r=function(e){try{var n=(new Date).toISOString(),t={route:e.route,generatedAt:n};if("auto-extract"===e.mode){var r,o,u=function(){var e={title:"",outline:[],description:""};try{if("undefined"==typeof document)return e;var n=p(document.title,200),t=[],r="";try{for(var o,u=document.querySelectorAll("nav, footer, [role='navigation'], [role='contentinfo'], script, style, noscript"),a=function(e){for(var n,t=i(u);!(n=t()).done;)if(n.value.contains(e))return!0;return!1},c=i(document.querySelectorAll("h1, h2"));!(o=c()).done;){var l=o.value;if(t.length>=50)break;if(g(l)&&!a(l)){var s=p(l.textContent,300);s&&t.push(s)}}for(var f,d=document.querySelectorAll("p"),v=[],m=i(d);!(f=m()).done;){var h=f.value;if(v.length>=3)break;if(g(h)&&!a(h)){var y=p(h.textContent,1e3);y&&v.push(y)}}r=v.join(" ").trim().slice(0,2e3)||""}catch(e){}return{title:n,outline:t,description:r}}catch(n){return e}}();t.title=(null!=(r=e.title)?r:u.title)||void 0,t.description=(null!=(o=e.description)?o:u.description)||void 0,u.outline.length>0&&(t.outline=u.outline)}else void 0!==e.title&&""!==e.title&&(t.title=e.title),void 0!==e.description&&""!==e.description&&(t.description=e.description);return e.tags&&e.tags.length>0&&(t.tags=e.tags),e.canonicalUrl&&(t.canonicalUrl=e.canonicalUrl),e.language&&(t.language=e.language),e.ogType&&(t.ogType=e.ogType),e.ogImage&&(t.ogImage=e.ogImage),e.ogImageAlt&&(t.ogImageAlt=e.ogImageAlt),e.siteName&&(t.siteName=e.siteName),e.author&&(t.author=e.author),e.publishedTime&&(t.publishedTime=e.publishedTime),e.modifiedTime&&(t.modifiedTime=e.modifiedTime),e.robots&&(t.robots=e.robots),e.extra&&Object.keys(e.extra).length>0&&(t.extra=e.extra),t}catch(n){var a;return{route:null!=(a=null==e?void 0:e.route)?a:"/",generatedAt:(new Date).toISOString()}}}(t),o=JSON.stringify(r);if(n.current===o)return;return n.current=o,w(),function(e){try{if("undefined"==typeof document||!document.head)return;var n=document.createElement("script");n.type="application/llm+json",n.setAttribute("data-llm","true"),n.textContent=JSON.stringify(e),document.head.appendChild(n)}catch(e){}}(r),function(){w(),n.current=null}}catch(e){}},[null==e?void 0:e.route,null==e?void 0:e.mode,null==e?void 0:e.title,null==e?void 0:e.description,null==e?void 0:e.tags,null==e?void 0:e.canonicalUrl,null==e?void 0:e.language,null==e?void 0:e.ogType,null==e?void 0:e.ogImage,null==e?void 0:e.ogImageAlt,null==e?void 0:e.siteName,null==e?void 0:e.author,null==e?void 0:e.publishedTime,null==e?void 0:e.modifiedTime,null==e?void 0:e.robots])},exports.useMutationObserver=function(n,t,r){e.useEffect(function(){var e=n.current;if(e){var o=new MutationObserver(t);return o.observe(e,r),function(){return o.disconnect()}}},[n,t,r])},exports.useNetworkState=function(){var n=e.useState(a),t=n[0],r=n[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){return r(a())};window.addEventListener("online",e),window.addEventListener("offline",e);var n=navigator.connection;return null!=n&&n.addEventListener&&n.addEventListener("change",e),function(){window.removeEventListener("online",e),window.removeEventListener("offline",e),null!=n&&n.removeEventListener&&n.removeEventListener("change",e)}}},[]),t},exports.usePoll=function(n,t){void 0===t&&(t={});var r=t.intervalMs,o=void 0===r?1e3:r,i=t.immediate,u=void 0===i||i,a=t.enabled,c=void 0===a||a,l=e.useState(null),s=l[0],f=l[1],d=e.useState(!1),v=d[0],p=d[1],m=e.useState(null),h=m[0],g=m[1],y=e.useState(0),w=y[0],b=y[1],S=e.useState(!1),E=S[0],k=S[1],x=e.useRef(null),C=e.useRef(n);C.current=n;var P=e.useCallback(function(){null!=x.current&&(clearInterval(x.current),x.current=null),k(!1)},[]),I=e.useCallback(function(){try{var e=function(e,n){try{var t=(g(null),Promise.resolve(C.current()).then(function(e){b(function(e){return e+1}),e.done&&(P(),p(!0),void 0!==e.data&&f(e.data))}))}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(0,function(e){var n=e instanceof Error?e:new Error(String(e));g(n),P()});return Promise.resolve(e&&e.then?e.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[P]),M=e.useCallback(function(){c&&!E&&(k(!0),u&&I(),x.current=setInterval(I,o))},[c,u,o,E,I]);return e.useEffect(function(){return c&&M(),function(){P()}},[c]),{data:s,done:v,error:h,pollCount:w,start:M,stop:P}},exports.usePreferredTheme=function(){var n=e.useState(function(){if("undefined"==typeof window)return"no-preference";var e=window.matchMedia("(prefers-color-scheme: dark)"),n=window.matchMedia("(prefers-color-scheme: light)");return e.matches?"dark":n.matches?"light":"no-preference"}),t=n[0],r=n[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=window.matchMedia("(prefers-color-scheme: dark)"),n=function(e){r(e.matches?"dark":"light")},t=function(){var e=window.matchMedia("(prefers-color-scheme: dark)"),n=window.matchMedia("(prefers-color-scheme: light)");r(e.matches?"dark":n.matches?"light":"no-preference")};e.addEventListener("change",n);var o=window.matchMedia("(prefers-color-scheme: light)");return o.addEventListener("change",t),function(){e.removeEventListener("change",n),o.removeEventListener("change",t)}}},[]),t},exports.usePrefetch=function(){var n=e.useRef(new Set),t=e.useState(0)[1];return{prefetch:e.useCallback(function(e,r){var o,i=null==e?void 0:e.trim();i&&(n.current.has(i)||("document"===(null!=(o=null==r?void 0:r.as)?o:"document")?function(e){if("undefined"!=typeof document){for(var n=document.querySelectorAll('link[rel="prefetch"]'),t=0;t<n.length;t++)if(n[t].href===e)return;var r=document.createElement("link");r.rel="prefetch",r.href=e,document.head.appendChild(r)}}(i):function(e){"undefined"!=typeof fetch&&fetch(e,{method:"GET",mode:"cors"}).catch(function(){})}(i),n.current.add(i),t(function(e){return e+1})))},[]),isPrefetched:e.useCallback(function(e){var t;return n.current.has(null!=(t=null==e?void 0:e.trim())?t:"")},[])}},exports.useRBAC=function(n){var t=n.userSource,r=e.useRef(n);r.current=n;var o=e.useState(null),i=o[0],u=o[1],a=e.useState([]),c=a[0],l=a[1],s=e.useState([]),f=s[0],d=s[1],v=e.useState(!1),p=v[0],m=v[1],h=e.useState(null),g=h[0],y=h[1],w=e.useCallback(function(){try{var e=r.current,n=e.userSource,t=e.roleDefinitions,o=e.roleCapabilities,i=e.capabilitiesOverride;y(null);var a=null,c=[],s=[],f=function(e,r){try{var f=function(e,r){try{var f=function(){function e(){function e(){u(a),l(c),d(s)}var n=function(){if(i){var e=function(){if("localStorage"===i.type){var e=x("localStorage",i.key);e.length>0&&(s=e)}else{var n=function(){if("sessionStorage"===i.type){var e=x("sessionStorage",i.key);e.length>0&&(s=e)}else{var n=function(){if("api"===i.type)return Promise.resolve(i.fetch()).then(function(e){s=e})}();if(n&&n.then)return n.then(function(){})}}();if(n&&n.then)return n.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();return n&&n.then?n.then(e):e()}var r=function(){if("localStorage"===n.type)a=k("localStorage",n.key),c=C(a,t),s=P(c,o);else{var e=function(){if("sessionStorage"===n.type)a=k("sessionStorage",n.key),c=C(a,t),s=P(c,o);else{var e=function(){if("api"===n.type)return Promise.resolve(n.fetch()).then(function(e){c=C(a=e,t),s=P(c,o)});var e=function(){if("memory"===n.type)a=n.getUser(),c=C(a,t),s=P(c,o);else{var e=function(){if("custom"===n.type)return Promise.resolve(Promise.resolve(n.getAuth())).then(function(e){var n,r,i;a=null!=(n=e.user)?n:null,c=null!=(r=e.roles)?r:C(a,t),s=null!=(i=e.capabilities)?i:P(c,o)})}();if(e&&e.then)return e.then(function(){})}}();return e&&e.then?e.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();return r&&r.then?r.then(e):e()}()}catch(e){return r(e)}return f&&f.then?f.then(void 0,r):f}(0,function(e){y(e instanceof Error?e:new Error(String(e))),u(null),l([]),d([])})}catch(e){return r(!0,e)}return f&&f.then?f.then(r.bind(null,!1),r.bind(null,!0)):r(!1,f)}(0,function(e,n){if(m(!0),e)throw n;return n});return Promise.resolve(f&&f.then?f.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[]);e.useEffect(function(){w()},[w]),e.useEffect(function(){if("undefined"!=typeof window){var e="localStorage"===t.type||"sessionStorage"===t.type?t.key:null;if(e){var n=function(n){n.key===e&&w()};return window.addEventListener("storage",n),function(){return window.removeEventListener("storage",n)}}}},[t.type,"localStorage"===t.type||"sessionStorage"===t.type?t.key:"",w]);var b=e.useCallback(function(e){return c.includes(e)},[c]),S=e.useCallback(function(e){return function(e,n){return!!e.includes("*")||e.includes(n)}(f,e)},[f]),E=S,I=e.useCallback(function(){return w()},[w]),M=e.useCallback(function(e,n,r){if("undefined"!=typeof window){var o="localStorage"===n?window.localStorage:window.sessionStorage;null==e?o.removeItem(r):o.setItem(r,JSON.stringify(e)),("localStorage"===t.type&&"localStorage"===n&&t.key===r||"sessionStorage"===t.type&&"sessionStorage"===n&&t.key===r)&&w()}},[t,w]),T=e.useCallback(function(e,n,t){"undefined"!=typeof window&&("localStorage"===n?window.localStorage:window.sessionStorage).setItem(t,JSON.stringify(e))},[]),L=e.useCallback(function(e,n,t){"undefined"!=typeof window&&("localStorage"===n?window.localStorage:window.sessionStorage).setItem(t,JSON.stringify(e))},[]);return{user:i,roles:c,capabilities:f,isReady:p,error:g,hasRole:b,hasCapability:S,can:E,refetch:I,setUserInStorage:M,setRolesInStorage:T,setCapabilitiesInStorage:L}},exports.useRageClick=function(n,t){var r=t.onRageClick,o=t.threshold,i=void 0===o?5:o,u=t.timeWindow,a=void 0===u?1e3:u,c=t.distanceThreshold,l=void 0===c?30:c,s=e.useRef(r);s.current=r;var f=e.useRef([]);e.useEffect(function(){var e=n.current;if(e){var t=function(e){var n=Date.now(),t={time:n,x:e.clientX,y:e.clientY},r=n-a,o=f.current.filter(function(e){return e.time>=r});if(o.push(t),Infinity!==l){var u=o.filter(function(e){return n=e,r=t,Math.hypot(r.x-n.x,r.y-n.y)<=l;var n,r});if(u.length>=i)return s.current({count:u.length,event:e}),void(f.current=[])}else if(o.length>=i)return s.current({count:o.length,event:e}),void(f.current=[]);f.current=o};return e.addEventListener("click",t),function(){return e.removeEventListener("click",t)}}},[n,i,a,l])},exports.useRefPrint=function(n,t){void 0===t&&(t={});var r=t.documentTitle,o=e.useRef("");return{print:e.useCallback(function(){var e=n.current;if(e&&"undefined"!=typeof window&&window.print){var t=document.getElementById(S);t||((t=document.createElement("style")).id=S,t.textContent=E,document.head.appendChild(t)),e.classList.add(b),r&&(o.current=document.title,document.title=r);var i=function(){e.classList.remove(b),r&&void 0!==o.current&&(document.title=o.current)};if("onafterprint"in window){var u=function(){i(),window.removeEventListener("afterprint",u)};window.addEventListener("afterprint",u)}window.print(),setTimeout(i,1e3)}},[n,r])}},exports.useThreadedWorker=function(n,t){var r=t.concurrency,o="sequential"===t.mode?1:Math.max(1,void 0===r?4:r),i=e.useState(!1),u=i[0],a=i[1],c=e.useState(void 0),l=c[0],s=c[1],f=e.useState(void 0),d=f[0],v=f[1],p=e.useState(0),m=p[0],h=p[1],g=e.useRef([]),y=e.useRef(0),w=e.useRef(0),b=e.useRef(!1),S=e.useRef(n);S.current=n;var E=e.useCallback(function(){h(g.current.length+w.current)},[]),k=e.useCallback(function(){if(!(b.current||w.current>=o)){if(0===g.current.length)return 0===w.current&&a(!1),void E();g.current.sort(function(e,n){return e.priority!==n.priority?e.priority-n.priority:e.sequence-n.sequence});var e=g.current.shift();w.current+=1,a(!0),E(),(0,S.current)(e.data).then(function(n){s(n),v(void 0),e.resolve(n)}).catch(function(n){v(n),e.reject(n)}).finally(function(){w.current-=1,E(),k()}),g.current.length>0&&w.current<o&&k()}},[o,E]),x=e.useCallback(function(e,n){var t;if(b.current)return Promise.reject(new Error("Worker is terminated"));var r=null!=(t=null==n?void 0:n.priority)?t:1,o=++y.current,i=new Promise(function(n,t){g.current.push({data:e,priority:r,sequence:o,resolve:n,reject:t})});return E(),a(!0),queueMicrotask(k),i},[k,E]),C=e.useCallback(function(){var e=g.current;g.current=[],e.forEach(function(e){return e.reject(new Error("Task cleared from queue"))}),E(),0===w.current&&a(!1)},[E]),P=e.useCallback(function(){b.current=!0,C()},[C]);return e.useEffect(function(){return function(){b.current=!0}},[]),{run:x,loading:u,result:l,error:d,queueSize:m,clearQueue:C,terminate:P}},exports.useTransition=function(){var n=e.useState(!1),t=n[0],r=n[1];return[e.useCallback(function(e){r(!0),Promise.resolve().then(function(){e(),r(!1)})},[]),t]},exports.useWasmCompute=function(n){var t=n.wasmUrl,r=n.exportName,o=void 0===r?"compute":r,i=n.workerUrl,u=n.importObject,a=e.useState(void 0),c=a[0],l=a[1],s=e.useState(!0),f=s[0],d=s[1],v=e.useState(null),p=v[0],m=v[1],h=e.useState(!1),g=h[0],y=h[1],w=e.useRef(null),b=e.useRef(null),S=e.useRef(null);return e.useEffect(function(){if("undefined"==typeof window)return m("useWasmCompute is not available during SSR"),void d(!1);if("undefined"==typeof Worker)return m("Worker is not supported in this environment"),void d(!1);if("undefined"==typeof WebAssembly||"function"!=typeof WebAssembly.instantiate)return m("WebAssembly is not supported in this environment"),void d(!1);m(null),y(!1);var e=function(e){if(e)return new Worker(e);var n=new Blob(["\nself.onmessage = async (e) => {\n const d = e.data;\n if (d.type === 'init') {\n try {\n const res = await fetch(d.wasmUrl);\n const buf = await res.arrayBuffer();\n const mod = await WebAssembly.instantiate(buf, d.importObject || {});\n self.wasmInstance = mod.instance;\n self.exportName = d.exportName || 'compute';\n self.postMessage({ type: 'ready' });\n } catch (err) {\n self.postMessage({ type: 'error', error: (err && err.message) || String(err) });\n }\n return;\n }\n if (d.type === 'compute') {\n try {\n const fn = self.wasmInstance.exports[self.exportName];\n if (typeof fn !== 'function') {\n self.postMessage({ type: 'error', error: 'Export \"' + self.exportName + '\" is not a function' });\n return;\n }\n const result = fn(d.input);\n self.postMessage({ type: 'result', result: result });\n } catch (err) {\n self.postMessage({ type: 'error', error: (err && err.message) || String(err) });\n }\n }\n};\n"],{type:"application/javascript"}),t=URL.createObjectURL(n),r=new Worker(t);return URL.revokeObjectURL(t),r}(i);w.current=e;var n=function(e){var n,t=null!=(n=e.data)?n:{},r=t.type,o=t.result,i=t.error;return"ready"===r?(y(!0),void d(!1)):"error"===r?(m(null!=i?i:"Unknown error"),d(!1),void(S.current&&(S.current(new Error(i)),b.current=null,S.current=null))):void("result"===r&&(l(o),d(!1),b.current&&(b.current(o),b.current=null,S.current=null)))};return e.addEventListener("message",n),e.postMessage({type:"init",wasmUrl:t,exportName:o,importObject:null!=u?u:{}}),function(){e.removeEventListener("message",n),e.terminate(),w.current=null,S.current&&(S.current(new Error("Worker terminated")),b.current=null,S.current=null)}},[t,o,i,u]),{compute:e.useCallback(function(e){return new Promise(function(n,t){w.current&&g?p?t(new Error(p)):(b.current=n,S.current=t,d(!0),w.current.postMessage({type:"compute",input:e})):t(new Error("WASM not ready"))})},[g,p]),result:c,loading:f,error:p,ready:g}},exports.useWebRTCIP=function(n){void 0===n&&(n={});var t=n.stunServers,r=void 0===t?v:t,o=n.timeout,i=void 0===o?3e3:o,u=n.onDetect,a=e.useState([]),c=a[0],l=a[1],s=e.useState(!0),f=s[0],p=s[1],m=e.useState(null),h=m[0],g=m[1],y=e.useRef(null),w=e.useRef(null),b=e.useRef(new Set),S=e.useRef(u);return S.current=u,e.useEffect(function(){if("undefined"==typeof window)return p(!1),void g("WebRTC IP detection is not available during SSR");if("undefined"==typeof RTCPeerConnection)return p(!1),void g("RTCPeerConnection is not available");var e=new Set;b.current=e;var n=function(){w.current&&(clearTimeout(w.current),w.current=null),y.current&&(y.current.close(),y.current=null),p(!1)},t=function(n){e.has(n)||(e.add(n),l(function(e){return[].concat(e,[n])}),null==S.current||S.current(n))};try{var o=new RTCPeerConnection({iceServers:[{urls:r}]});y.current=o,o.onicecandidate=function(e){var n,r=e.candidate;r&&r.candidate&&((n=r.candidate.match(d))?[].concat(n):[]).forEach(t)},o.createDataChannel(""),o.createOffer().then(function(e){return o.setLocalDescription(e)}).catch(function(e){g(e instanceof Error?e.message:"Failed to create offer"),n()}),w.current=setTimeout(function(){return n()},i)}catch(e){g(e instanceof Error?e.message:"WebRTC setup failed"),n()}return function(){n()}},[r.join(","),i]),{ips:c,loading:f,error:h}},exports.useWorkerNotifications=function(n,t){void 0===t&&(t={});var r=t.maxHistory,o=void 0===r?100:r,i=t.throughputWindowMs,u=void 0===i?1e3:i,a=e.useState([]),c=a[0],l=a[1],s=e.useState(0),f=s[0],d=s[1],v=e.useState(0),p=v[0],m=v[1],h=e.useState([]),g=h[0],y=h[1],w=e.useState(0),b=w[0],S=w[1],E=e.useRef([]),k=e.useRef(0),x=e.useRef(0);e.useEffect(function(){if(n){var e=function(e){var n=function(e){if(null==e||"object"!=typeof e)return null;var n=e.type;return"task_start"!==n&&"task_end"!==n&&"task_fail"!==n&&"queue_size"!==n?null:{type:n,taskId:"string"==typeof e.taskId?e.taskId:void 0,duration:"number"==typeof e.duration?e.duration:void 0,error:"string"==typeof e.error?e.error:void 0,size:"number"==typeof e.size?e.size:void 0,timestamp:Date.now()}}(e.data);if(n)if(y(function(e){return[].concat(e,[n]).slice(-o)}),"task_start"===n.type&&n.taskId)l(function(e){return e.includes(n.taskId)?e:[].concat(e,[n.taskId])});else if("task_end"===n.type){n.taskId&&l(function(e){return e.filter(function(e){return e!==n.taskId})}),d(function(e){return e+1});var t=Date.now()-u;E.current=[].concat(E.current.filter(function(e){return e>=t}),[n.timestamp]),"number"==typeof n.duration&&(k.current+=n.duration,x.current+=1)}else"task_fail"===n.type?(n.taskId&&l(function(e){return e.filter(function(e){return e!==n.taskId})}),m(function(e){return e+1})):"queue_size"===n.type&&"number"==typeof n.size&&S(n.size)};return n.addEventListener("message",e),function(){return n.removeEventListener("message",e)}}},[n,o]);var C=e.useMemo(function(){var e=x.current;return e>0?k.current/e:0},[g]),P=e.useMemo(function(){var e=Date.now()-u;return E.current.filter(function(n){return n>=e}).length/(u/1e3)},[g,u]),I=e.useMemo(function(){return{runningTasks:c,completedCount:f,failedCount:p,averageDurationMs:C,throughputPerSecond:P,currentQueueSize:b,totalProcessed:f+p,recentEventCount:g.length}},[c,f,p,C,P,b,g.length]);return{runningTasks:c,completedCount:f,failedCount:p,eventHistory:g,averageDurationMs:C,throughputPerSecond:P,currentQueueSize:b,progress:I}},exports.useWrappedChildren=function(t,r,o){return void 0===o&&(o="preserve"),e.useMemo(function(){if(!t)return t;var e=function(e){if(!n.isValidElement(e))return e;var t,i=e.props||{};t="override"===o?u({},i,r):u({},r,i);var a=null==i?void 0:i.style,c=null==r?void 0:r.style;return a&&c&&"object"==typeof a&&"object"==typeof c&&(t.style="override"===o?u({},a,c):u({},c,a)),n.cloneElement(e,t)};return Array.isArray(t)?t.map(e):e(t)},[t,r,o])};
1
+ var e=require("preact/hooks"),n=require("preact"),t=require("preact/compat"),r=new Map;function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function i(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return o(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u.apply(null,arguments)}function a(){if("undefined"==typeof navigator)return{online:!0};var e={online:navigator.onLine},n=navigator.connection;return n&&(void 0!==n.effectiveType&&(e.effectiveType=n.effectiveType),void 0!==n.downlink&&(e.downlink=n.downlink),void 0!==n.rtt&&(e.rtt=n.rtt),void 0!==n.saveData&&(e.saveData=n.saveData),void 0!==n.type&&(e.connectionType=n.type)),e}function c(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var l=new Map;function s(e){return new Promise(function(n,t){e.onsuccess=function(){return n(e.result)},e.onerror=function(){var n;return t(null!=(n=e.error)?n:new DOMException("Unknown IndexedDB error"))}})}function f(e,n){return n?e.then(function(e){return null==n.onSuccess||n.onSuccess(e),e}).catch(function(e){throw null==n.onError||n.onError(e),e}):e}var d=/\b(?:25[0-5]|2[0-4]\d|1?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|1?\d{1,2})){3}\b/g,v=["stun:stun.l.google.com:19302"];function m(e,n){if(null==e)return"";var t=("string"==typeof e?e:String(e)).trim();return t.length>n?t.slice(0,n):t}function p(e){if(!Array.isArray(e))return[];for(var n=[],t=0;t<e.length&&n.length<50;t++){var r=m(e[t],100);r&&n.push(r)}return n}function h(e){var n=m(e,2048);if(!n)return"";try{var t=new URL(n);if("http:"===t.protocol||"https:"===t.protocol)return n}catch(e){}return""}function g(e){try{if("undefined"==typeof window)return!1;var n=window.getComputedStyle(e);return"none"!==n.display&&"hidden"!==n.visibility&&"0"!==n.opacity}catch(e){return!1}}function y(e){var n={};try{for(var t,r=i(Object.keys(e).slice(0,20));!(t=r()).done;){var o=t.value,u=m(o,50);if(u){var a=e[o];"string"==typeof a?n[u]=a.slice(0,500):"number"==typeof a&&Number.isFinite(a)||"boolean"==typeof a?n[u]=a:Array.isArray(a)&&(n[u]=a.map(function(e){return m(e,200)}).filter(Boolean).slice(0,20))}}}catch(e){}return n}function w(){try{if("undefined"==typeof document||!document.querySelectorAll)return;document.querySelectorAll('script[data-llm="true"]').forEach(function(e){return e.remove()})}catch(e){}}var b="use-ref-print-target",S="use-ref-print-styles",E="\n@media print {\n body * {\n visibility: hidden;\n }\n ."+b+",\n ."+b+" * {\n visibility: visible;\n }\n ."+b+" {\n position: absolute !important;\n left: 0 !important;\n top: 0 !important;\n width: 100% !important;\n }\n}\n";function k(e,n){if("undefined"==typeof window)return null;var t="localStorage"===e?window.localStorage:window.sessionStorage;try{var r=t.getItem(n);if(null==r)return null;var o=JSON.parse(r);return o&&"object"==typeof o?o:null}catch(e){return null}}function x(e,n){if("undefined"==typeof window)return[];var t="localStorage"===e?window.localStorage:window.sessionStorage;try{var r=t.getItem(n);if(null==r)return[];var o=JSON.parse(r);return Array.isArray(o)?o.filter(function(e){return"string"==typeof e}):[]}catch(e){return[]}}function C(e,n){return n.filter(function(n){return n.condition(e)}).map(function(e){return e.role})}function P(e,n){for(var t,r=new Set,o=i(e);!(t=o()).done;){var u=n[t.value];if(Array.isArray(u))for(var a,c=i(u);!(a=c()).done;)r.add(a.value)}return Array.from(r)}function L(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var M={name:"Unknown",version:""},I={name:"Unknown",version:""},T={userAgent:"",language:"en",languages:["en"],platform:"",browser:M,os:I,cookieEnabled:!1,online:!0,maxTouchPoints:0,vendor:"",touch:!1,screen:{width:0,height:0,availWidth:0,availHeight:0,colorDepth:24,pixelRatio:1},viewport:{width:0,height:0},reducedMotion:!1,colorScheme:"no-preference"},A=/not.?a.?brand/i;function R(e){var n=u({},M),t=u({},I);if(!e)return{browser:n,os:t};var r=e.match(/Windows NT ([\d.]+)/);if(r)t.name="Windows",t.version=r[1];else{var o=e.match(/Mac OS X ([\d._]+)/);if(o)t.name="macOS",t.version=o[1].replace(/_/g,".");else{var i=e.match(/Android ([\d.]+)/);if(i)t.name="Android",t.version=i[1];else{var a=e.match(/(?:iPhone OS|CPU OS) ([\d_]+)/);if(a)t.name="iOS",t.version=a[1].replace(/_/g,".");else if(/Linux/.test(e)){var c;t.name="Linux";var l=e.match(/Linux ([\d.]+)/);t.version=null!=(c=null==l?void 0:l[1])?c:""}}}}var s=e.match(/Edg(?:A|iOS)?\/([\d.]+)/),f=e.match(/OPR\/([\d.]+)/),d=e.match(/Firefox\/([\d.]+)/),v=/Version\/([\d.]+)/.test(e)&&/Safari/.test(e)&&!/Chrome|Chromium|Edg|OPR/.test(e)?e.match(/Version\/([\d.]+)/):null,m=e.match(/Chrome\/([\d.]+)/);return s?(n.name="Edge",n.version=s[1]):f?(n.name="Opera",n.version=f[1]):d?(n.name="Firefox",n.version=d[1]):v?(n.name="Safari",n.version=v[1]):m&&(n.name="Chrome",n.version=m[1]),{browser:n,os:t}}function O(e){var n=e.find(function(e){return!A.test(e.brand)}),t=null!=n?n:e[0];return t?{name:t.brand,version:t.version}:u({},M)}function j(){var e,n,t,r,o,i,a,c,l,s,f,d,v,m;if("undefined"==typeof navigator)return T;var p,h=navigator,g=void 0!==globalThis.screen?globalThis.screen:null,y=void 0!==globalThis.window?globalThis.window:null,w=null!=(e=h.userAgent)?e:"",b=R(w),S=h.userAgentData,E=S?function(e,n){var t,r;return{browser:null!=(t=e.brands)&&t.length?O(e.brands):u({},n.browser),os:{name:(null==(r=e.platform)?void 0:r.trim())||n.os.name,version:n.os.version}}}(S,b):b,k=E.browser,x=E.os,C={userAgent:w,language:null!=(n=h.language)?n:"",languages:h.languages?[].concat(h.languages):[],platform:null!=(t=h.platform)?t:"",browser:k,os:x,cookieEnabled:Boolean(h.cookieEnabled),online:Boolean(h.onLine),maxTouchPoints:null!=(r=h.maxTouchPoints)?r:0,vendor:null!=(o=h.vendor)?o:"",touch:(null!=(i=h.maxTouchPoints)?i:0)>0,screen:{width:null!=(a=null==g?void 0:g.width)?a:0,height:null!=(c=null==g?void 0:g.height)?c:0,availWidth:null!=(l=null==g?void 0:g.availWidth)?l:0,availHeight:null!=(s=null==g?void 0:g.availHeight)?s:0,colorDepth:null!=(f=null==g?void 0:g.colorDepth)?f:24,pixelRatio:null!=(d=null==y?void 0:y.devicePixelRatio)?d:1},viewport:{width:null!=(v=null==y?void 0:y.innerWidth)?v:0,height:null!=(m=null==y?void 0:y.innerHeight)?m:0},reducedMotion:!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,colorScheme:"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"no-preference":"no-preference"};return"number"==typeof h.hardwareConcurrency&&(C.hardwareConcurrency=h.hardwareConcurrency),"number"==typeof h.deviceMemory&&(C.deviceMemory=h.deviceMemory),S&&(C.userAgentData={mobile:Boolean(S.mobile),platform:null!=(p=S.platform)?p:"",brands:S.brands?[].concat(S.brands):[]}),C}exports.getDeviceData=j,exports.parseUserAgent=R,exports.useClipboard=function(n){void 0===n&&(n={});var t=n.resetDelay,r=void 0===t?2e3:t,o=e.useState(!1),i=o[0],u=o[1],a=e.useState(null),l=a[0],s=a[1],f=e.useCallback(function(){u(!1),s(null)},[]);return{copy:e.useCallback(function(e){try{if(s(null),"undefined"==typeof navigator||!navigator.clipboard){var n=new Error("Clipboard API is not available");return s(n),Promise.resolve(!1)}return Promise.resolve(c(function(){return Promise.resolve(navigator.clipboard.writeText(e)).then(function(){return u(!0),r>0&&setTimeout(function(){return u(!1)},r),!0})},function(e){var n=e instanceof Error?e:new Error(String(e));return s(n),!1}))}catch(e){return Promise.reject(e)}},[r]),paste:e.useCallback(function(){try{if(s(null),"undefined"==typeof navigator||!navigator.clipboard){var e=new Error("Clipboard API is not available");return s(e),Promise.resolve("")}return Promise.resolve(c(function(){return Promise.resolve(navigator.clipboard.readText())},function(e){var n=e instanceof Error?e:new Error(String(e));return s(n),""}))}catch(e){return Promise.reject(e)}},[]),copied:i,error:l,reset:f}},exports.useDeviceData=function(n){void 0===n&&(n={});var t=n.includeBattery,r=void 0===t||t,o=n.batteryPollIntervalMs,i=void 0===o?6e4:o,a=n.includeHighEntropy,c=void 0===a||a,l=e.useState(function(){return j()}),s=l[0],f=l[1],d=e.useCallback(function(){f(function(e){return u({},j(),e.battery?{battery:e.battery}:{})})},[]);return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){return d()};window.addEventListener("resize",e),window.addEventListener("orientationchange",e),window.addEventListener("online",d),window.addEventListener("offline",d);var n=null==window.matchMedia?void 0:window.matchMedia("(prefers-reduced-motion: reduce)"),t=null==window.matchMedia?void 0:window.matchMedia("(prefers-color-scheme: dark)"),r=null==window.matchMedia?void 0:window.matchMedia("(prefers-color-scheme: light)"),o=function(){return d()};return null==n||null==n.addEventListener||n.addEventListener("change",o),null==t||null==t.addEventListener||t.addEventListener("change",o),null==r||null==r.addEventListener||r.addEventListener("change",o),function(){window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e),window.removeEventListener("online",d),window.removeEventListener("offline",d),null==n||null==n.removeEventListener||n.removeEventListener("change",o),null==t||null==t.removeEventListener||t.removeEventListener("change",o),null==r||null==r.removeEventListener||r.removeEventListener("change",o)}}},[d]),e.useEffect(function(){if(c&&"undefined"!=typeof navigator){var e=navigator.userAgentData;if(null!=e&&e.getHighEntropyValues){var n=!1;return function(){try{var t=j();return Promise.resolve(function(e,n){try{return Promise.resolve(e.getHighEntropyValues?L(function(){return Promise.resolve(e.getHighEntropyValues(["platformVersion","fullVersionList"])).then(function(e){var t,r;return{browser:null!=(t=e.fullVersionList)&&t.length?O(e.fullVersionList):u({},n.browser),os:{name:n.os.name,version:(null==(r=e.platformVersion)?void 0:r.trim())||n.os.version}}})},function(){}):void 0)}catch(e){return Promise.reject(e)}}(e,{browser:t.browser,os:t.os})).then(function(e){!n&&e&&f(function(n){return u({},n,{browser:e.browser,os:e.os})})})}catch(e){return Promise.reject(e)}}(),function(){n=!0}}}},[c]),e.useEffect(function(){if(r&&"undefined"!=typeof navigator){var e,n=!1,t=function(){return Promise.resolve(function(){try{if("undefined"==typeof navigator)return Promise.resolve(void 0);var e=navigator.getBattery;return Promise.resolve(e?L(function(){return Promise.resolve(e.call(navigator)).then(function(e){return{charging:e.charging,level:e.level}})},function(){}):void 0)}catch(e){return Promise.reject(e)}}()).then(function(e){n||void 0===e||f(function(n){return u({},n,{battery:e})})})};return t(),i>0&&(e=setInterval(function(){t()},i)),function(){n=!0,void 0!==e&&clearInterval(e)}}},[r,i]),s},exports.useEventBus=function(){return{emit:e.useCallback(function(e){var n=arguments,t=r.get(e);t&&t.forEach(function(e){return e.apply(void 0,[].slice.call(n,1))})},[]),on:e.useCallback(function(e,n){var t=r.get(e);return t||(t=new Set,r.set(e,t)),t.add(n),function(){t.delete(n),0===t.size&&r.delete(e)}},[])}},exports.useIndexedDB=function(n){var t=e.useState(null),r=t[0],o=t[1],a=e.useState(null),c=a[0],d=a[1],v=e.useState(!1),m=v[0],p=v[1],h=e.useRef(n);return h.current=n,e.useEffect(function(){var e=!1;d(null),p(!1),o(null);var n=h.current;return function(e){var n=e.name+"_v"+e.version,t=l.get(n);return t||(t=function(e){return new Promise(function(n,t){var r=indexedDB.open(e.name,e.version);r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Failed to open database"))},r.onsuccess=function(){return n(r.result)},r.onupgradeneeded=function(n){for(var t=n.target.result,r=e.tables,o=0,u=Object.keys(r);o<u.length;o++){var a=u[o],c=r[a];if(!t.objectStoreNames.contains(a)){var l,s=t.createObjectStore(a,{keyPath:c.keyPath,autoIncrement:null!=(l=c.autoIncrement)&&l});if(c.indexes)for(var f,d=i(c.indexes);!(f=d()).done;){var v=f.value;s.createIndex(v,v,{unique:!1})}}}}})}(e),l.set(n,t),t)}({name:n.name,version:n.version,tables:n.tables}).then(function(n){if(e)n.close();else{var t=function(e){return{get db(){return e},hasTable:function(n){return e.objectStoreNames.contains(n)},table:function(n){return function(e,n){return function(e,n){function t(t){return e.transaction([n],t).objectStore(n)}return{insert:function(e,n){return f(s(t("readwrite").add(e)),n)},update:function(e,n,r){var o=t("readwrite");return f(s(o.get(e)).then(function(e){if(void 0===e)throw new DOMException("Key not found","NotFoundError");var t=u({},e,n);return s(o.put(t))}).then(function(){}),r)},delete:function(e,n){return f(s(t("readwrite").delete(e)).then(function(){}),n)},exists:function(e){return s(t("readonly").getKey(e)).then(function(e){return void 0!==e})},query:function(e,n){var r=t("readonly").openCursor(),o=[];return f(new Promise(function(n,t){r.onsuccess=function(){var t=r.result;t?(e(t.value)&&o.push(t.value),t.continue()):n(o)},r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Unknown error"))}}),n)},upsert:function(e,n){return f(s(t("readwrite").put(e)),n)},bulkInsert:function(e,n){var r=t("readwrite"),o=[];if(0===e.length)return f(Promise.resolve(o),n);var i=0;return f(new Promise(function(n,t){e.forEach(function(u,a){var c=r.add(u);c.onsuccess=function(){o[a]=c.result,++i===e.length&&n(o)},c.onerror=function(){var e;return t(null!=(e=c.error)?e:new DOMException("Unknown error"))}})}),n)},clear:function(e){return f(s(t("readwrite").clear()).then(function(){}),e)},count:function(e){return f(s(t("readonly").count()),null!=e?e:{})}}}(e,n)}(e,n)},transaction:function(n,t,r,o){var i=e.transaction(n,t),a={table:function(e){return function(e,n){return function(e,n){function t(){return e.objectStore(n)}return{insert:function(e,n){return f(s(t().add(e)),n)},update:function(e,n,r){var o=t();return f(s(o.get(e)).then(function(e){if(void 0===e)throw new DOMException("Key not found","NotFoundError");var t=u({},e,n);return s(o.put(t))}).then(function(){}),r)},delete:function(e,n){return f(s(t().delete(e)).then(function(){}),n)},exists:function(e){return s(t().getKey(e)).then(function(e){return void 0!==e})},query:function(e,n){var r=t().openCursor(),o=[];return f(new Promise(function(n,t){r.onsuccess=function(){var t=r.result;t?(e(t.value)&&o.push(t.value),t.continue()):n(o)},r.onerror=function(){var e;return t(null!=(e=r.error)?e:new DOMException("Unknown error"))}}),n)},upsert:function(e,n){return f(s(t().put(e)),n)},bulkInsert:function(e,n){var r=t(),o=[];if(0===e.length)return f(Promise.resolve(o),n);var i=0;return f(new Promise(function(n,t){e.forEach(function(u,a){var c=r.add(u);c.onsuccess=function(){o[a]=c.result,++i===e.length&&n(o)},c.onerror=function(){var e;return t(null!=(e=c.error)?e:new DOMException("Unknown error"))}})}),n)},clear:function(e){return f(s(t().clear()).then(function(){}),e)},count:function(e){return f(s(t().count()),null!=e?e:{})}}}(e,n)}(i,e)}},c=new Promise(function(e,n){i.oncomplete=function(){return e()},i.onerror=function(){var e;return n(null!=(e=i.error)?e:new DOMException("Transaction failed"))}}),l=r(a);return function(e,n){return n?e.then(function(){return null==n.onSuccess?void 0:n.onSuccess()}).catch(function(e){throw null==n.onError||n.onError(e),e}):e}(Promise.resolve(l).then(function(){return c}),o)}}}(n);o(t),p(!0)}}).catch(function(n){e||d(n)}),function(){e=!0}},[n.name,n.version]),{db:r,isReady:m,error:c}},exports.useLLMMetadata=function(e){var n=t.useRef(null);t.useEffect(function(){try{if("undefined"==typeof window)return;var t=function(e){return null==e||"object"!=typeof e?{route:"/"}:{route:m(e.route,2048)||"/",mode:"auto-extract"===e.mode?"auto-extract":"manual",title:void 0!==e.title?m(e.title,200):void 0,description:void 0!==e.description?m(e.description,2e3):void 0,tags:void 0!==e.tags?p(e.tags):void 0,canonicalUrl:void 0!==e.canonicalUrl?h(e.canonicalUrl):void 0,language:void 0!==e.language?m(e.language,20):void 0,ogType:void 0!==e.ogType?m(e.ogType,50):void 0,ogImage:void 0!==e.ogImage?h(e.ogImage):void 0,ogImageAlt:void 0!==e.ogImageAlt?m(e.ogImageAlt,200):void 0,siteName:void 0!==e.siteName?m(e.siteName,100):void 0,author:void 0!==e.author?m(e.author,200):void 0,publishedTime:void 0!==e.publishedTime?m(e.publishedTime,50):void 0,modifiedTime:void 0!==e.modifiedTime?m(e.modifiedTime,50):void 0,robots:void 0!==e.robots?m(e.robots,100):void 0,extra:void 0===e.extra||"object"!=typeof e.extra||Array.isArray(e.extra)?void 0:y(e.extra)}}(e),r=function(e){try{var n=(new Date).toISOString(),t={route:e.route,generatedAt:n};if("auto-extract"===e.mode){var r,o,u=function(){var e={title:"",outline:[],description:""};try{if("undefined"==typeof document)return e;var n=m(document.title,200),t=[],r="";try{for(var o,u=document.querySelectorAll("nav, footer, [role='navigation'], [role='contentinfo'], script, style, noscript"),a=function(e){for(var n,t=i(u);!(n=t()).done;)if(n.value.contains(e))return!0;return!1},c=i(document.querySelectorAll("h1, h2"));!(o=c()).done;){var l=o.value;if(t.length>=50)break;if(g(l)&&!a(l)){var s=m(l.textContent,300);s&&t.push(s)}}for(var f,d=document.querySelectorAll("p"),v=[],p=i(d);!(f=p()).done;){var h=f.value;if(v.length>=3)break;if(g(h)&&!a(h)){var y=m(h.textContent,1e3);y&&v.push(y)}}r=v.join(" ").trim().slice(0,2e3)||""}catch(e){}return{title:n,outline:t,description:r}}catch(n){return e}}();t.title=(null!=(r=e.title)?r:u.title)||void 0,t.description=(null!=(o=e.description)?o:u.description)||void 0,u.outline.length>0&&(t.outline=u.outline)}else void 0!==e.title&&""!==e.title&&(t.title=e.title),void 0!==e.description&&""!==e.description&&(t.description=e.description);return e.tags&&e.tags.length>0&&(t.tags=e.tags),e.canonicalUrl&&(t.canonicalUrl=e.canonicalUrl),e.language&&(t.language=e.language),e.ogType&&(t.ogType=e.ogType),e.ogImage&&(t.ogImage=e.ogImage),e.ogImageAlt&&(t.ogImageAlt=e.ogImageAlt),e.siteName&&(t.siteName=e.siteName),e.author&&(t.author=e.author),e.publishedTime&&(t.publishedTime=e.publishedTime),e.modifiedTime&&(t.modifiedTime=e.modifiedTime),e.robots&&(t.robots=e.robots),e.extra&&Object.keys(e.extra).length>0&&(t.extra=e.extra),t}catch(n){var a;return{route:null!=(a=null==e?void 0:e.route)?a:"/",generatedAt:(new Date).toISOString()}}}(t),o=JSON.stringify(r);if(n.current===o)return;return n.current=o,w(),function(e){try{if("undefined"==typeof document||!document.head)return;var n=document.createElement("script");n.type="application/llm+json",n.setAttribute("data-llm","true"),n.textContent=JSON.stringify(e),document.head.appendChild(n)}catch(e){}}(r),function(){w(),n.current=null}}catch(e){}},[null==e?void 0:e.route,null==e?void 0:e.mode,null==e?void 0:e.title,null==e?void 0:e.description,null==e?void 0:e.tags,null==e?void 0:e.canonicalUrl,null==e?void 0:e.language,null==e?void 0:e.ogType,null==e?void 0:e.ogImage,null==e?void 0:e.ogImageAlt,null==e?void 0:e.siteName,null==e?void 0:e.author,null==e?void 0:e.publishedTime,null==e?void 0:e.modifiedTime,null==e?void 0:e.robots])},exports.useMutationObserver=function(n,t,r){e.useEffect(function(){var e=n.current;if(e){var o=new MutationObserver(t);return o.observe(e,r),function(){return o.disconnect()}}},[n,t,r])},exports.useNetworkState=function(){var n=e.useState(a),t=n[0],r=n[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=function(){return r(a())};window.addEventListener("online",e),window.addEventListener("offline",e);var n=navigator.connection;return null!=n&&n.addEventListener&&n.addEventListener("change",e),function(){window.removeEventListener("online",e),window.removeEventListener("offline",e),null!=n&&n.removeEventListener&&n.removeEventListener("change",e)}}},[]),t},exports.usePoll=function(n,t){void 0===t&&(t={});var r=t.intervalMs,o=void 0===r?1e3:r,i=t.immediate,u=void 0===i||i,a=t.enabled,c=void 0===a||a,l=e.useState(null),s=l[0],f=l[1],d=e.useState(!1),v=d[0],m=d[1],p=e.useState(null),h=p[0],g=p[1],y=e.useState(0),w=y[0],b=y[1],S=e.useState(!1),E=S[0],k=S[1],x=e.useRef(null),C=e.useRef(n);C.current=n;var P=e.useCallback(function(){null!=x.current&&(clearInterval(x.current),x.current=null),k(!1)},[]),L=e.useCallback(function(){try{var e=function(e,n){try{var t=(g(null),Promise.resolve(C.current()).then(function(e){b(function(e){return e+1}),e.done&&(P(),m(!0),void 0!==e.data&&f(e.data))}))}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(0,function(e){var n=e instanceof Error?e:new Error(String(e));g(n),P()});return Promise.resolve(e&&e.then?e.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[P]),M=e.useCallback(function(){c&&!E&&(k(!0),u&&L(),x.current=setInterval(L,o))},[c,u,o,E,L]);return e.useEffect(function(){return c&&M(),function(){P()}},[c]),{data:s,done:v,error:h,pollCount:w,start:M,stop:P}},exports.usePreferredTheme=function(){var n=e.useState(function(){if("undefined"==typeof window)return"no-preference";var e=window.matchMedia("(prefers-color-scheme: dark)"),n=window.matchMedia("(prefers-color-scheme: light)");return e.matches?"dark":n.matches?"light":"no-preference"}),t=n[0],r=n[1];return e.useEffect(function(){if("undefined"!=typeof window){var e=window.matchMedia("(prefers-color-scheme: dark)"),n=function(e){r(e.matches?"dark":"light")},t=function(){var e=window.matchMedia("(prefers-color-scheme: dark)"),n=window.matchMedia("(prefers-color-scheme: light)");r(e.matches?"dark":n.matches?"light":"no-preference")};e.addEventListener("change",n);var o=window.matchMedia("(prefers-color-scheme: light)");return o.addEventListener("change",t),function(){e.removeEventListener("change",n),o.removeEventListener("change",t)}}},[]),t},exports.usePrefetch=function(){var n=e.useRef(new Set),t=e.useState(0)[1];return{prefetch:e.useCallback(function(e,r){var o,i=null==e?void 0:e.trim();i&&(n.current.has(i)||("document"===(null!=(o=null==r?void 0:r.as)?o:"document")?function(e){if("undefined"!=typeof document){for(var n=document.querySelectorAll('link[rel="prefetch"]'),t=0;t<n.length;t++)if(n[t].href===e)return;var r=document.createElement("link");r.rel="prefetch",r.href=e,document.head.appendChild(r)}}(i):function(e){"undefined"!=typeof fetch&&fetch(e,{method:"GET",mode:"cors"}).catch(function(){})}(i),n.current.add(i),t(function(e){return e+1})))},[]),isPrefetched:e.useCallback(function(e){var t;return n.current.has(null!=(t=null==e?void 0:e.trim())?t:"")},[])}},exports.useRBAC=function(n){var t=n.userSource,r=e.useRef(n);r.current=n;var o=e.useState(null),i=o[0],u=o[1],a=e.useState([]),c=a[0],l=a[1],s=e.useState([]),f=s[0],d=s[1],v=e.useState(!1),m=v[0],p=v[1],h=e.useState(null),g=h[0],y=h[1],w=e.useCallback(function(){try{var e=r.current,n=e.userSource,t=e.roleDefinitions,o=e.roleCapabilities,i=e.capabilitiesOverride;y(null);var a=null,c=[],s=[],f=function(e,r){try{var f=function(e,r){try{var f=function(){function e(){function e(){u(a),l(c),d(s)}var n=function(){if(i){var e=function(){if("localStorage"===i.type){var e=x("localStorage",i.key);e.length>0&&(s=e)}else{var n=function(){if("sessionStorage"===i.type){var e=x("sessionStorage",i.key);e.length>0&&(s=e)}else{var n=function(){if("api"===i.type)return Promise.resolve(i.fetch()).then(function(e){s=e})}();if(n&&n.then)return n.then(function(){})}}();if(n&&n.then)return n.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();return n&&n.then?n.then(e):e()}var r=function(){if("localStorage"===n.type)a=k("localStorage",n.key),c=C(a,t),s=P(c,o);else{var e=function(){if("sessionStorage"===n.type)a=k("sessionStorage",n.key),c=C(a,t),s=P(c,o);else{var e=function(){if("api"===n.type)return Promise.resolve(n.fetch()).then(function(e){c=C(a=e,t),s=P(c,o)});var e=function(){if("memory"===n.type)a=n.getUser(),c=C(a,t),s=P(c,o);else{var e=function(){if("custom"===n.type)return Promise.resolve(Promise.resolve(n.getAuth())).then(function(e){var n,r,i;a=null!=(n=e.user)?n:null,c=null!=(r=e.roles)?r:C(a,t),s=null!=(i=e.capabilities)?i:P(c,o)})}();if(e&&e.then)return e.then(function(){})}}();return e&&e.then?e.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();return r&&r.then?r.then(e):e()}()}catch(e){return r(e)}return f&&f.then?f.then(void 0,r):f}(0,function(e){y(e instanceof Error?e:new Error(String(e))),u(null),l([]),d([])})}catch(e){return r(!0,e)}return f&&f.then?f.then(r.bind(null,!1),r.bind(null,!0)):r(!1,f)}(0,function(e,n){if(p(!0),e)throw n;return n});return Promise.resolve(f&&f.then?f.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[]);e.useEffect(function(){w()},[w]),e.useEffect(function(){if("undefined"!=typeof window){var e="localStorage"===t.type||"sessionStorage"===t.type?t.key:null;if(e){var n=function(n){n.key===e&&w()};return window.addEventListener("storage",n),function(){return window.removeEventListener("storage",n)}}}},[t.type,"localStorage"===t.type||"sessionStorage"===t.type?t.key:"",w]);var b=e.useCallback(function(e){return c.includes(e)},[c]),S=e.useCallback(function(e){return function(e,n){return!!e.includes("*")||e.includes(n)}(f,e)},[f]),E=S,L=e.useCallback(function(){return w()},[w]),M=e.useCallback(function(e,n,r){if("undefined"!=typeof window){var o="localStorage"===n?window.localStorage:window.sessionStorage;null==e?o.removeItem(r):o.setItem(r,JSON.stringify(e)),("localStorage"===t.type&&"localStorage"===n&&t.key===r||"sessionStorage"===t.type&&"sessionStorage"===n&&t.key===r)&&w()}},[t,w]),I=e.useCallback(function(e,n,t){"undefined"!=typeof window&&("localStorage"===n?window.localStorage:window.sessionStorage).setItem(t,JSON.stringify(e))},[]),T=e.useCallback(function(e,n,t){"undefined"!=typeof window&&("localStorage"===n?window.localStorage:window.sessionStorage).setItem(t,JSON.stringify(e))},[]);return{user:i,roles:c,capabilities:f,isReady:m,error:g,hasRole:b,hasCapability:S,can:E,refetch:L,setUserInStorage:M,setRolesInStorage:I,setCapabilitiesInStorage:T}},exports.useRageClick=function(n,t){var r=t.onRageClick,o=t.threshold,i=void 0===o?5:o,u=t.timeWindow,a=void 0===u?1e3:u,c=t.distanceThreshold,l=void 0===c?30:c,s=e.useRef(r);s.current=r;var f=e.useRef([]);e.useEffect(function(){var e=n.current;if(e){var t=function(e){var n=Date.now(),t={time:n,x:e.clientX,y:e.clientY},r=n-a,o=f.current.filter(function(e){return e.time>=r});if(o.push(t),Infinity!==l){var u=o.filter(function(e){return n=e,r=t,Math.hypot(r.x-n.x,r.y-n.y)<=l;var n,r});if(u.length>=i)return s.current({count:u.length,event:e}),void(f.current=[])}else if(o.length>=i)return s.current({count:o.length,event:e}),void(f.current=[]);f.current=o};return e.addEventListener("click",t),function(){return e.removeEventListener("click",t)}}},[n,i,a,l])},exports.useRefPrint=function(n,t){void 0===t&&(t={});var r=t.documentTitle,o=e.useRef("");return{print:e.useCallback(function(){var e=n.current;if(e&&"undefined"!=typeof window&&window.print){var t=document.getElementById(S);t||((t=document.createElement("style")).id=S,t.textContent=E,document.head.appendChild(t)),e.classList.add(b),r&&(o.current=document.title,document.title=r);var i=function(){e.classList.remove(b),r&&void 0!==o.current&&(document.title=o.current)};if("onafterprint"in window){var u=function(){i(),window.removeEventListener("afterprint",u)};window.addEventListener("afterprint",u)}window.print(),setTimeout(i,1e3)}},[n,r])}},exports.useThreadedWorker=function(n,t){var r=t.concurrency,o="sequential"===t.mode?1:Math.max(1,void 0===r?4:r),i=e.useState(!1),u=i[0],a=i[1],c=e.useState(void 0),l=c[0],s=c[1],f=e.useState(void 0),d=f[0],v=f[1],m=e.useState(0),p=m[0],h=m[1],g=e.useRef([]),y=e.useRef(0),w=e.useRef(0),b=e.useRef(!1),S=e.useRef(n);S.current=n;var E=e.useCallback(function(){h(g.current.length+w.current)},[]),k=e.useCallback(function(){if(!(b.current||w.current>=o)){if(0===g.current.length)return 0===w.current&&a(!1),void E();g.current.sort(function(e,n){return e.priority!==n.priority?e.priority-n.priority:e.sequence-n.sequence});var e=g.current.shift();w.current+=1,a(!0),E(),(0,S.current)(e.data).then(function(n){s(n),v(void 0),e.resolve(n)}).catch(function(n){v(n),e.reject(n)}).finally(function(){w.current-=1,E(),k()}),g.current.length>0&&w.current<o&&k()}},[o,E]),x=e.useCallback(function(e,n){var t;if(b.current)return Promise.reject(new Error("Worker is terminated"));var r=null!=(t=null==n?void 0:n.priority)?t:1,o=++y.current,i=new Promise(function(n,t){g.current.push({data:e,priority:r,sequence:o,resolve:n,reject:t})});return E(),a(!0),queueMicrotask(k),i},[k,E]),C=e.useCallback(function(){var e=g.current;g.current=[],e.forEach(function(e){return e.reject(new Error("Task cleared from queue"))}),E(),0===w.current&&a(!1)},[E]),P=e.useCallback(function(){b.current=!0,C()},[C]);return e.useEffect(function(){return function(){b.current=!0}},[]),{run:x,loading:u,result:l,error:d,queueSize:p,clearQueue:C,terminate:P}},exports.useTransition=function(){var n=e.useState(!1),t=n[0],r=n[1];return[e.useCallback(function(e){r(!0),Promise.resolve().then(function(){e(),r(!1)})},[]),t]},exports.useWasmCompute=function(n){var t=n.wasmUrl,r=n.exportName,o=void 0===r?"compute":r,i=n.workerUrl,u=n.importObject,a=e.useState(void 0),c=a[0],l=a[1],s=e.useState(!0),f=s[0],d=s[1],v=e.useState(null),m=v[0],p=v[1],h=e.useState(!1),g=h[0],y=h[1],w=e.useRef(null),b=e.useRef(null),S=e.useRef(null);return e.useEffect(function(){if("undefined"==typeof window)return p("useWasmCompute is not available during SSR"),void d(!1);if("undefined"==typeof Worker)return p("Worker is not supported in this environment"),void d(!1);if("undefined"==typeof WebAssembly||"function"!=typeof WebAssembly.instantiate)return p("WebAssembly is not supported in this environment"),void d(!1);p(null),y(!1);var e=function(e){if(e)return new Worker(e);var n=new Blob(["\nself.onmessage = async (e) => {\n const d = e.data;\n if (d.type === 'init') {\n try {\n const res = await fetch(d.wasmUrl);\n const buf = await res.arrayBuffer();\n const mod = await WebAssembly.instantiate(buf, d.importObject || {});\n self.wasmInstance = mod.instance;\n self.exportName = d.exportName || 'compute';\n self.postMessage({ type: 'ready' });\n } catch (err) {\n self.postMessage({ type: 'error', error: (err && err.message) || String(err) });\n }\n return;\n }\n if (d.type === 'compute') {\n try {\n const fn = self.wasmInstance.exports[self.exportName];\n if (typeof fn !== 'function') {\n self.postMessage({ type: 'error', error: 'Export \"' + self.exportName + '\" is not a function' });\n return;\n }\n const result = fn(d.input);\n self.postMessage({ type: 'result', result: result });\n } catch (err) {\n self.postMessage({ type: 'error', error: (err && err.message) || String(err) });\n }\n }\n};\n"],{type:"application/javascript"}),t=URL.createObjectURL(n),r=new Worker(t);return URL.revokeObjectURL(t),r}(i);w.current=e;var n=function(e){var n,t=null!=(n=e.data)?n:{},r=t.type,o=t.result,i=t.error;return"ready"===r?(y(!0),void d(!1)):"error"===r?(p(null!=i?i:"Unknown error"),d(!1),void(S.current&&(S.current(new Error(i)),b.current=null,S.current=null))):void("result"===r&&(l(o),d(!1),b.current&&(b.current(o),b.current=null,S.current=null)))};return e.addEventListener("message",n),e.postMessage({type:"init",wasmUrl:t,exportName:o,importObject:null!=u?u:{}}),function(){e.removeEventListener("message",n),e.terminate(),w.current=null,S.current&&(S.current(new Error("Worker terminated")),b.current=null,S.current=null)}},[t,o,i,u]),{compute:e.useCallback(function(e){return new Promise(function(n,t){w.current&&g?m?t(new Error(m)):(b.current=n,S.current=t,d(!0),w.current.postMessage({type:"compute",input:e})):t(new Error("WASM not ready"))})},[g,m]),result:c,loading:f,error:m,ready:g}},exports.useWebRTCIP=function(n){void 0===n&&(n={});var t=n.stunServers,r=void 0===t?v:t,o=n.timeout,i=void 0===o?3e3:o,u=n.onDetect,a=e.useState([]),c=a[0],l=a[1],s=e.useState(!0),f=s[0],m=s[1],p=e.useState(null),h=p[0],g=p[1],y=e.useRef(null),w=e.useRef(null),b=e.useRef(new Set),S=e.useRef(u);return S.current=u,e.useEffect(function(){if("undefined"==typeof window)return m(!1),void g("WebRTC IP detection is not available during SSR");if("undefined"==typeof RTCPeerConnection)return m(!1),void g("RTCPeerConnection is not available");var e=new Set;b.current=e;var n=function(){w.current&&(clearTimeout(w.current),w.current=null),y.current&&(y.current.close(),y.current=null),m(!1)},t=function(n){e.has(n)||(e.add(n),l(function(e){return[].concat(e,[n])}),null==S.current||S.current(n))};try{var o=new RTCPeerConnection({iceServers:[{urls:r}]});y.current=o,o.onicecandidate=function(e){var n,r=e.candidate;r&&r.candidate&&((n=r.candidate.match(d))?[].concat(n):[]).forEach(t)},o.createDataChannel(""),o.createOffer().then(function(e){return o.setLocalDescription(e)}).catch(function(e){g(e instanceof Error?e.message:"Failed to create offer"),n()}),w.current=setTimeout(function(){return n()},i)}catch(e){g(e instanceof Error?e.message:"WebRTC setup failed"),n()}return function(){n()}},[r.join(","),i]),{ips:c,loading:f,error:h}},exports.useWorkerNotifications=function(n,t){void 0===t&&(t={});var r=t.maxHistory,o=void 0===r?100:r,i=t.throughputWindowMs,u=void 0===i?1e3:i,a=e.useState([]),c=a[0],l=a[1],s=e.useState(0),f=s[0],d=s[1],v=e.useState(0),m=v[0],p=v[1],h=e.useState([]),g=h[0],y=h[1],w=e.useState(0),b=w[0],S=w[1],E=e.useRef([]),k=e.useRef(0),x=e.useRef(0);e.useEffect(function(){if(n){var e=function(e){var n=function(e){if(null==e||"object"!=typeof e)return null;var n=e.type;return"task_start"!==n&&"task_end"!==n&&"task_fail"!==n&&"queue_size"!==n?null:{type:n,taskId:"string"==typeof e.taskId?e.taskId:void 0,duration:"number"==typeof e.duration?e.duration:void 0,error:"string"==typeof e.error?e.error:void 0,size:"number"==typeof e.size?e.size:void 0,timestamp:Date.now()}}(e.data);if(n)if(y(function(e){return[].concat(e,[n]).slice(-o)}),"task_start"===n.type&&n.taskId)l(function(e){return e.includes(n.taskId)?e:[].concat(e,[n.taskId])});else if("task_end"===n.type){n.taskId&&l(function(e){return e.filter(function(e){return e!==n.taskId})}),d(function(e){return e+1});var t=Date.now()-u;E.current=[].concat(E.current.filter(function(e){return e>=t}),[n.timestamp]),"number"==typeof n.duration&&(k.current+=n.duration,x.current+=1)}else"task_fail"===n.type?(n.taskId&&l(function(e){return e.filter(function(e){return e!==n.taskId})}),p(function(e){return e+1})):"queue_size"===n.type&&"number"==typeof n.size&&S(n.size)};return n.addEventListener("message",e),function(){return n.removeEventListener("message",e)}}},[n,o]);var C=e.useMemo(function(){var e=x.current;return e>0?k.current/e:0},[g]),P=e.useMemo(function(){var e=Date.now()-u;return E.current.filter(function(n){return n>=e}).length/(u/1e3)},[g,u]),L=e.useMemo(function(){return{runningTasks:c,completedCount:f,failedCount:m,averageDurationMs:C,throughputPerSecond:P,currentQueueSize:b,totalProcessed:f+m,recentEventCount:g.length}},[c,f,m,C,P,b,g.length]);return{runningTasks:c,completedCount:f,failedCount:m,eventHistory:g,averageDurationMs:C,throughputPerSecond:P,currentQueueSize:b,progress:L}},exports.useWrappedChildren=function(t,r,o){return void 0===o&&(o="preserve"),e.useMemo(function(){if(!t)return t;var e=function(e){if(!n.isValidElement(e))return e;var t,i=e.props||{};t="override"===o?u({},i,r):u({},r,i);var a=null==i?void 0:i.style,c=null==r?void 0:r.style;return a&&c&&"object"==typeof a&&"object"==typeof c&&(t.style="override"===o?u({},a,c):u({},c,a)),n.cloneElement(e,t)};return Array.isArray(t)?t.map(e):e(t)},[t,r,o])};
2
2
  //# sourceMappingURL=index.js.map