@peekling/runtime 0.1.2 → 0.1.3
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 +10 -8
- package/dist/canvas.d.ts +1 -1
- package/dist/canvas.d.ts.map +1 -1
- package/dist/configuration-validation.d.ts.map +1 -1
- package/dist/configuration-validation.js +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/peekling.js +23 -12
- package/dist/peekling.js.sri +1 -1
- package/dist/peekling.min.js +1 -1
- package/dist/peekling.min.js.sri +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +14 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ data cannot contain code, callbacks, DOM nodes, or raw HTML.
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npm install @peekling/runtime@0.1.
|
|
13
|
+
npm install @peekling/runtime@0.1.3
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The runtime supports modern ESM applications and the complete browser bundle.
|
|
@@ -197,14 +197,14 @@ free. The element is a lifecycle facade over hatch, not a second engine.
|
|
|
197
197
|
```html
|
|
198
198
|
<script
|
|
199
199
|
defer
|
|
200
|
-
src="https://cdn.jsdelivr.net/npm/@peekling/runtime@0.1.
|
|
200
|
+
src="https://cdn.jsdelivr.net/npm/@peekling/runtime@0.1.3/dist/peekling.min.js"
|
|
201
201
|
integrity="sha384-<runtime-release-hash>"
|
|
202
202
|
crossorigin="anonymous"
|
|
203
203
|
></script>
|
|
204
204
|
|
|
205
205
|
<peekling-character
|
|
206
206
|
character="peek"
|
|
207
|
-
styles-url="https://cdn.jsdelivr.net/npm/@peekling/runtime@0.1.
|
|
207
|
+
styles-url="https://cdn.jsdelivr.net/npm/@peekling/runtime@0.1.3/dist/peekling.css"
|
|
208
208
|
styles-integrity="sha256-<stylesheet-release-hash>"
|
|
209
209
|
></peekling-character>
|
|
210
210
|
```
|
|
@@ -254,7 +254,9 @@ expiry, or teardown.
|
|
|
254
254
|
|
|
255
255
|
Reduced motion is a rendering policy, not another Plan. It shows a validated
|
|
256
256
|
static tableau and suppresses incompatible motion while preserving host-page
|
|
257
|
-
interaction.
|
|
257
|
+
interaction. `motionPreference` defaults to `"system"`. Choose `"full"` when
|
|
258
|
+
direct manipulation and physics are essential, or `"reduce"` for an explicitly
|
|
259
|
+
static instance.
|
|
258
260
|
|
|
259
261
|
Direct hatch integrations in single-page applications must call `destroy()` when
|
|
260
262
|
the owning view unmounts. `pushState`, hash changes, and client-side route
|
|
@@ -320,15 +322,15 @@ host surfaces, blocked stylesheets, suspension, dismissal recovery, remount
|
|
|
320
322
|
cleanup, hostile host layout, root repair, and contained failures in Chromium,
|
|
321
323
|
Firefox, and WebKit.
|
|
322
324
|
|
|
323
|
-
The 0.1.
|
|
325
|
+
The 0.1.3 record below measures the interaction and renderer release with the
|
|
324
326
|
exact release toolchain and required reserve.
|
|
325
327
|
|
|
326
328
|
<!-- peekling-size-evidence:start -->
|
|
327
329
|
|
|
328
|
-
The recorded canonical delivery measurement is 38,
|
|
330
|
+
The recorded canonical delivery measurement is 38,200 bytes gzip and 33,541
|
|
329
331
|
bytes Brotli. Against the 40 KiB gzip and 40 KiB Brotli caps, that recorded
|
|
330
|
-
build leaves 2,
|
|
331
|
-
After the required 256-byte reserve, 2,
|
|
332
|
+
build leaves 2,760 bytes of gzip headroom and 7,419 bytes of Brotli headroom.
|
|
333
|
+
After the required 256-byte reserve, 2,504 gzip bytes and 7,163 Brotli bytes
|
|
332
334
|
remain for that build.
|
|
333
335
|
<!-- peekling-size-evidence:end -->
|
|
334
336
|
|
package/dist/canvas.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PeeklingHatchInput, type PeeklingInstance, type PeeklingOptions } from "./runtime.js";
|
|
2
2
|
/** Hatch with Canvas 2D character pixels and accessible DOM content surfaces. */
|
|
3
3
|
export declare function hatchCanvas(input: PeeklingHatchInput | PeeklingOptions): PeeklingInstance;
|
|
4
|
-
export type { PeeklingHatchInput, PeeklingInstance, PeeklingOptions, } from "./runtime.js";
|
|
4
|
+
export type { PeeklingHatchInput, PeeklingInstance, PeeklingMotionPreference, PeeklingOptions, } from "./runtime.js";
|
|
5
5
|
//# sourceMappingURL=canvas.d.ts.map
|
package/dist/canvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACrB,MAAM,cAAc,CAAC;AAEtB,iFAAiF;AACjF,wBAAgB,WAAW,CACzB,KAAK,EAAE,kBAAkB,GAAG,eAAe,GAC1C,gBAAgB,CAElB;AAED,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-validation.d.ts","sourceRoot":"","sources":["../src/configuration-validation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration-validation.d.ts","sourceRoot":"","sources":["../src/configuration-validation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAiC/D,MAAM,MAAM,sBAAsB,GAAG,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,sBAAuB,SAAQ,SAAS;IACnD,QAAQ,CAAC,MAAM,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAEtD,YAAY,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAItD;CACF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,sBAAsB,GAC5B,WAAW,CAuKb;AAkQD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CAExE"}
|
|
@@ -27,6 +27,7 @@ const CONFIGURATION_FIELDS = [
|
|
|
27
27
|
"position",
|
|
28
28
|
"density",
|
|
29
29
|
"maxDensity",
|
|
30
|
+
"motionPreference",
|
|
30
31
|
"onDiagnostic",
|
|
31
32
|
"logger",
|
|
32
33
|
"document",
|
|
@@ -87,6 +88,10 @@ export function validateConfiguration(options, baseUrl, fault) {
|
|
|
87
88
|
options.density > options.maxDensity) {
|
|
88
89
|
reportConfigurationFault("incompatible-density", "$.density", fault);
|
|
89
90
|
}
|
|
91
|
+
if (options.motionPreference !== undefined &&
|
|
92
|
+
!["system", "full", "reduce"].includes(options.motionPreference)) {
|
|
93
|
+
reportConfigurationFault("invalid-motion-preference", "$.motionPreference", fault);
|
|
94
|
+
}
|
|
90
95
|
if (!validRuntimeName(options.name)) {
|
|
91
96
|
reportConfigurationFault("invalid-name", "$.name", fault);
|
|
92
97
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { hatch, type PeeklingFinishReason, type PeeklingFinishResult, type PeeklingHatchInput, type PeeklingIndicator, type PeeklingInteractionOptions, type PeeklingInstance, type PeeklingOptions, type PeeklingPackSelection, type PeeklingPosition, type PeeklingPressAction, } from "./runtime.js";
|
|
1
|
+
export { hatch, type PeeklingFinishReason, type PeeklingFinishResult, type PeeklingHatchInput, type PeeklingIndicator, type PeeklingInteractionOptions, type PeeklingInstance, type PeeklingMotionPreference, type PeeklingOptions, type PeeklingPackSelection, type PeeklingPosition, type PeeklingPressAction, } from "./runtime.js";
|
|
2
2
|
export { hidePeekling, isPeeklingHidden, showPeekling, type PeeklingHideDuration, } from "./visibility.js";
|
|
3
3
|
export type { RuntimeStyleAsset } from "./styles.js";
|
|
4
4
|
export { definePeeklingElement, PEEKLING_ELEMENT_TAG, type PeeklingElement, } from "./web-component.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/peekling.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @peekling/runtime 0.1.
|
|
1
|
+
/*! @peekling/runtime 0.1.3 | Copyright 2026 Prajwal S. Venkateshmurthy | Apache-2.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/runtime/src/runtime-diagnostics.ts
|
|
@@ -5189,6 +5189,7 @@
|
|
|
5189
5189
|
"position",
|
|
5190
5190
|
"density",
|
|
5191
5191
|
"maxDensity",
|
|
5192
|
+
"motionPreference",
|
|
5192
5193
|
"onDiagnostic",
|
|
5193
5194
|
"logger",
|
|
5194
5195
|
"document",
|
|
@@ -5242,6 +5243,13 @@
|
|
|
5242
5243
|
if (options.density !== void 0 && options.maxDensity !== void 0 && options.density > options.maxDensity) {
|
|
5243
5244
|
reportConfigurationFault("incompatible-density", "$.density", fault);
|
|
5244
5245
|
}
|
|
5246
|
+
if (options.motionPreference !== void 0 && !["system", "full", "reduce"].includes(options.motionPreference)) {
|
|
5247
|
+
reportConfigurationFault(
|
|
5248
|
+
"invalid-motion-preference",
|
|
5249
|
+
"$.motionPreference",
|
|
5250
|
+
fault
|
|
5251
|
+
);
|
|
5252
|
+
}
|
|
5245
5253
|
if (!validRuntimeName(options.name)) {
|
|
5246
5254
|
reportConfigurationFault("invalid-name", "$.name", fault);
|
|
5247
5255
|
}
|
|
@@ -7585,18 +7593,21 @@ ${styles.integrity ?? ""}` === this.#styleKey) return;
|
|
|
7585
7593
|
if (this.#displayName === "") {
|
|
7586
7594
|
this.#displayName = loaded.content.displayName;
|
|
7587
7595
|
}
|
|
7596
|
+
const motionPreference = this.#options.motionPreference ?? "system";
|
|
7588
7597
|
this.#media = this.#window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
7589
|
-
this.#reducedMotion = this.#media.matches;
|
|
7590
|
-
|
|
7591
|
-
this.#
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7598
|
+
this.#reducedMotion = motionPreference === "reduce" || motionPreference === "system" && this.#media.matches;
|
|
7599
|
+
if (motionPreference === "system") {
|
|
7600
|
+
this.#mediaListener = (event) => {
|
|
7601
|
+
this.#reducedMotion = event.matches;
|
|
7602
|
+
this.#notice(
|
|
7603
|
+
event.matches ? "lifecycle.reduced-motion-enabled" : "lifecycle.reduced-motion-disabled",
|
|
7604
|
+
"info",
|
|
7605
|
+
"lifecycle"
|
|
7606
|
+
);
|
|
7607
|
+
this.#wake();
|
|
7608
|
+
};
|
|
7609
|
+
this.#media.addEventListener("change", this.#mediaListener);
|
|
7610
|
+
}
|
|
7600
7611
|
this.#watchDpr();
|
|
7601
7612
|
this.#position = resolveInitialPosition(
|
|
7602
7613
|
this.#options.position ?? DEFAULT_POSITION,
|
package/dist/peekling.js.sri
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
sha384-
|
|
1
|
+
sha384-xPa08dz9kqhhRv3iuJpcAJh0gGCN7tvI1xPbFz8X5SWtosCbVCA9u/x8BzIsca1R
|
package/dist/peekling.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*!Apache-2.0*/
|
|
2
|
-
(()=>{function t(t,e,i){if(t.ownerDocument!==e)throw Error("root.document");let s=e.documentElement;if(!s)throw Error("root.missing");t.parentNode!==s&&s.append(t),t.hasAttribute(i)||t.setAttribute(i,"")}function e(t){return void 0===t||"string"==typeof t&&/^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(t)}function i(t,i){let s=t??Rt??(t=>({url:new URL("./peekling.css",t).href}))(i),r=new URL(s.url,i);if("https:"!==r.protocol&&"http:"!==r.protocol)throw new TypeError("styles.url");if(!e(s.integrity))throw new TypeError("styles.integrity");return Object.freeze({url:r.href,...s.integrity?{integrity:s.integrity}:{}})}function s(t){return"string"==typeof t&&Yt.test(t)}function r(t,e){if("string"!=typeof t||t.length<1||t.length>2048||/[\s\u0000-\u001f\u007f-\u009f\\]/u.test(t)||/%(?![0-9A-Fa-f]{2})/.test(t))return!1;let i=/^https:\/\//i.test(t);if(!i&&/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)||t.startsWith("//")||i&&!(t=>{let e=t.slice(8),i=e.search(/[/?#]/),s=i<0?e:e.slice(0,i);if(!s||s.includes("@")||s.includes("%"))return!1;if(s.startsWith("[")){let t=s.indexOf("]");return!(t<2||s.indexOf("[",1)>=0||s.indexOf("]",t+1)>=0||!n(s.slice(t+1)))}let r=s.indexOf(":");if(r!==s.lastIndexOf(":"))return!1;let h=r<0?s:s.slice(0,r),a=r<0?"":s.slice(r);return o(h)&&n(a)})(t))return!1;try{if(i){let e=new URL(t);return"https:"===e.protocol&&!e.username&&!e.password&&((t,e)=>{let i=t.slice(8),s=i.search(/[/?#]/),r=s<0?i:i.slice(0,s);if(r.startsWith("["))return!0;let n=r.indexOf(":");return(n<0?r:r.slice(0,n)).toLowerCase()===e.toLowerCase()})(t,e.hostname)}let s=new URL(e);if("https:"!==s.protocol&&"http:"!==s.protocol||s.username||s.password||!(t=>t.startsWith("[")?t.endsWith("]"):o(t))(s.hostname))return!1;let r=new URL(t,s);return!(r.username||r.password||"https:"!==r.protocol&&"http:"!==r.protocol||r.origin!==s.origin)}catch{return!1}}function n(t){return""===t||!!/^:[0-9]{1,5}$/.test(t)&&+t.slice(1)<=65535}function o(t){if(!t||t.length>253||t.endsWith("."))return!1;let e=t.split(".");return e.every(t=>/^[0-9]+$/.test(t))?4===e.length&&e.every(t=>/^(?:0|[1-9][0-9]{0,2})$/.test(t)&&+t<=255):e.every(t=>/^(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])$/.test(t))}function h(t,e,i){e&&ie.add(t),i&&se.add(t)}function a(t,e,i){if(!i&&((t,e)=>"object"==typeof t&&null!==t&&("configuration"===e?ee.has(t)||ie.has(t):"pack"===e?se.has(t):ie.has(t)))(t,e))return t;let s=0,r=0,n=new WeakSet,o=new WeakMap,a=(t,e,i)=>{throw new te(t,e,e)},l=(t,c,d)=>{if(void 0!==i?.maxDepth&&d>i.maxDepth)return a(c,"data.depth");if(r+=1,void 0!==i?.maxValues&&r>i.maxValues)return a(c,"data.nodes");if(null===t||"boolean"==typeof t)return{value:t,ownSafe:!0,packSafe:!0};if("string"==typeof t)return void 0!==i?.maxStringLength&&t.length>i.maxStringLength?a(c,"data.string"):{value:t,ownSafe:!0,packSafe:!0};if("number"==typeof t)return i?.json&&!Number.isFinite(t)?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!0};if(typeof t>"u")return i?.json?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!0};if("function"==typeof t)return"pack"===e||i?.json?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!1};if("object"!=typeof t)return a(c,"data.type");if("configuration"===e&&("$.document"===c||"$.window"===c))return{value:t,ownSafe:!1,packSafe:!1};if(d>32)return a(c,"data.depth");if(s+=1,s>2e4)return a(c,"data.nodes");let f,u,p=o.get(t);if(p){if(n.has(t))return a(c,"data.cycle");if(!i)return{value:p.value,ownSafe:p.ownSafe,packSafe:p.packSafe}}try{f=Reflect.ownKeys(t)}catch{return a(c,"data.reflect")}if(f.some(t=>"string"!=typeof t))return a(c,"data.symbol");if(Array.isArray(t)){if(t.length>Math.min(4096,i?.maxArrayLength??4096))return a(c,"data.array");if(f.length!==t.length+1||f.some(e=>"length"!==e&&(!/^\d+$/.test(e)||+e>=t.length)))return a(c,"data.array-own");let e=[],s={value:e};o.set(t,s),n.add(t);let r=!0,u=!0;for(let i=0;i<t.length;i+=1){let s=Object.getOwnPropertyDescriptor(t,i+"");if(!s||s.get||s.set)return a(`${c}[${i}]`,"data.descriptor");let n=l(s.value,`${c}[${i}]`,d+1);e.push(n.value),r&&=n.ownSafe,u&&=n.packSafe}n.delete(t);let p=Object.freeze(e);return s.ownSafe=r,s.packSafe=u,h(p,r,u),{value:p,ownSafe:r,packSafe:u}}try{u=(t=>{let e=Object.getPrototypeOf(t);return null===e||e===Object.prototype})(t)}catch{return a(c,"data.reflect")}if(!u)return a(c,"data.plain");if(f.length>Math.min(1024,i?.maxObjectKeys??1024))return a(c,"data.keys");let v=Object.create(null),y={value:v};o.set(t,y),n.add(t);let w=!0,b=!0;for(let e of f){i?.key&&!i.key(e)&&a(`${c}.${e}`,"data.key");let s=Object.getOwnPropertyDescriptor(t,e);if(!s||s.get||s.set)return a(`${c}.${e}`,"data.descriptor");let r=l(s.value,`${c}.${e}`,d+1);v[e]=r.value,w&&=r.ownSafe,b&&=r.packSafe}n.delete(t);let g=Object.freeze(v);return y.ownSafe=w,y.packSafe=b,h(g,w,b),{value:g,ownSafe:w,packSafe:b}};try{let i=l(t,"$",0);return"configuration"===e&&"object"==typeof i.value&&null!==i.value&&ee.add(i.value),i.value}catch(t){if(t instanceof te)throw t;return a("$","data.reflect")}}function l(t,e){return a(t,"own",e)}function c(t){return a(t,"pack")}function d(t){return a(t,"configuration")}function f(t){switch(t){case"pointer.click":case"document.visibility":case"window.focus":case"window.scroll":case"page.lifecycle":return t;default:return}}function u(t){return"pointer.move"===t||"section.visibility"===t}function p(t){if(void 0===t)return;let e;try{e=l(t,ne)}catch(t){if(t instanceof te)switch(t.issueCode){case"data.array":throw new TypeError("event.array-limit");case"data.cycle":case"data.depth":case"data.nodes":throw new TypeError("event.complexity");case"data.key":throw new TypeError("event.key");case"data.keys":throw new TypeError("event.key-limit");case"data.string":throw new TypeError("event.string-limit")}throw new TypeError("event.payload")}if((Ct??=new TextEncoder).encode(JSON.stringify(e)).byteLength>8192)throw new TypeError("event.size");return e}function v(t,e,i){if("string"==typeof t)return w(t,500);if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("content.surface");y(t,["title","text","link","mountId","announce"]);let s,n=w(t.title,120),o=w(t.text,500);if(void 0!==t.announce&&"boolean"!=typeof t.announce)throw new TypeError("content.announce");if(void 0!==t.mountId&&("string"!=typeof t.mountId||!Jt.test(t.mountId)))throw new TypeError("content.binding");if(void 0!==t.link){if(t.link&&"object"==typeof t.link&&y(t.link,["label","href"]),!t.link||"string"!=typeof t.link.label||"string"!=typeof t.link.href||!r(t.link.href,e))throw new TypeError("content.link");let i=new URL(t.link.href,e);s={label:w(t.link.label,120),href:i.href}}if(!(n||o||s||t.mountId))throw new TypeError("content.empty");return{...n?{title:n}:{},...o?{text:o}:{},...s?{link:s}:{},...t.mountId?{mountId:t.mountId}:{},...!0===t.announce?{announce:!0}:{}}}function y(t,e,i){for(let i of Object.keys(t))if(!e.includes(i))throw new TypeError(Lt("content.field"))}function w(t,e,i){if(void 0!==t){if("string"!=typeof t||t.length<1||t.length>e||/[\u0000-\u001f\u007f]/.test(t))throw new TypeError("content.text");return t}}function b(t,e,i,s,r){let n=e.y-s.height/2-12-r.height,o=e.y+s.height/2+12,h="bottom"===t,a=h?o:n,l=h?n:o;return{x:g("top-left"===t?e.x-s.width/2-12-r.width:"top-right"===t?e.x+s.width/2+12:e.x-r.width/2,8,i.width-r.width-8),y:g(a>=8&&a+r.height<=i.height-8?a:l,8,i.height-r.height-8)}}function g(t,e,i){return Math.max(e,Math.min(t,Math.max(e,i)))}function m(t){return t.replace(/https?:\/\/[^\s]+/gi,"[redacted-url]").replace(/\b(token|secret|password|authorization)=\S+/gi,"$1=[redacted]").slice(0,500)}function k(t){return t.durations?t.durations.reduce((t,e)=>t+e,0):t.frames.length/(t.fps??1)*1e3}function $(t,e){let i=(e%1+1)%1;if(!t?.length)return{advance:i,lift:0};let s=t.findIndex(t=>t.at>=i),r=t[s<0?t.length-1:s],n=t[Math.max(0,(s<0?t.length-1:s)-1)];if(r.at===n.at)return{advance:r.advance,lift:r.lift};let o=(i-n.at)/(r.at-n.at);return{advance:n.advance+(r.advance-n.advance)*o,lift:n.lift+(r.lift-n.lift)*o}}function j(t,e){return t}function x(t,e,i){t.push(j(e))}function E(t,e){throw new ue([j(t)])}function M(t,e,i){return!("string"!=typeof t||!pe.test(t))||(x(i,e),!1)}function O(t,e,i){let s=[];if(!Array.isArray(t)||t.length<1||t.length>3)return x(i,e.path+".limit"),s;let r=new Set;for(let[n,o]of t.entries()){let t=`${e.path}.${n}`;if(!A(o)){x(i,t);continue}z(o,e.native?["src","density","sourceCellSize","sha256"]:["src","density","cellWidth","cellHeight","sha256"],t,i);let h=o.density,a=(1===h||2===h||4===h)&&!r.has(h),l=o.src,c="string"==typeof l&&Gt.test(l)&&(e.native?/\.png$/i:/\.(?:png|webp)$/i).test(l),d=o.sha256,f=M(d,t+".sha256",i),u=e.native?+e.logicalWidth*+h:o.cellWidth,p=e.native?+e.logicalHeight*+h:o.cellHeight;(e.native?o.sourceCellSize===u&&u===p:Number.isInteger(u)&&u>=1&&u<=1024&&Number.isInteger(p)&&p>=1&&p<=1024)?a&&c?f&&(r.add(h),s.push({src:l,density:h,cellWidth:u,cellHeight:p,sha256:d})):x(i,t+".density"):x(i,t+".dimensions")}return s.sort((t,e)=>t.density-e.density)}function S(t,e,i){let s=Object.create(null);if(!A(t))return x(i,"states"),s;let r=Object.entries(t);(0===r.length||r.length>64)&&x(i,"states.limit");for(let[t,n]of r){let r="states."+t;if(!Qt.test(t)||["constructor","prototype","__proto__"].includes(t)||!A(n)){x(i,r);continue}z(n,["frames","fps","loop","durations"],r,i);let o=n.frames,h=n.durations;if(!Array.isArray(o)||0===o.length||o.length>64||o.some(t=>!Number.isInteger(t)||t<0||t>=e)){x(i,r+".frames");continue}let a=void 0!==n.fps,l=void 0!==h,c="number"==typeof n.fps&&Number.isFinite(n.fps)&&n.fps>=.1&&n.fps<=60,d=Array.isArray(h)&&h.length===o.length&&h.every(t=>"number"==typeof t&&Number.isFinite(t)&&t>=16&&t<=1e4)&&h.reduce((t,e)=>t+e,0)<=6e4;a===l||"boolean"!=typeof n.loop||a&&!c||l&&!d?x(i,r+".timing"):s[t]=a?{frames:[...o],loop:n.loop,fps:n.fps}:{frames:[...o],loop:n.loop,durations:[...h]}}return s.idle||x(i,"states.idle"),s}function N(t,e,i){let s=[];if(!Array.isArray(t)||t.length<2||t.length>8)return x(i,e+".limit"),s;for(let[r,n]of t.entries()){let t=`${e}.${r}`,o=s.at(-1);A(n)&&z(n,["at","advance","lift"],t,i),!A(n)||!Number.isFinite(n.at)||!Number.isFinite(n.advance)||!Number.isFinite(n.lift)||n.at<0||n.at>1||n.advance<0||n.advance>1||n.lift<0||n.lift>.5||void 0!==o&&(n.at<=o.at||n.advance<o.advance)?x(i,t):s.push({at:n.at,advance:n.advance,lift:n.lift})}return s.length===t.length&&(0!==s[0].at||0!==s[0].advance||0!==s[0].lift||1!==s.at(-1).at||1!==s.at(-1).advance||0!==s.at(-1).lift)&&x(i,e+".endpoints"),s}function A(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function z(t,e,i,s){for(let r of Object.keys(t))e.includes(r)||x(s,`${i}.${r}`)}function T(t){return ye.every((e,i)=>t[i]===e)}function P(t){return t.byteLength>=12&&"RIFF"===I(t,0)&&"WEBP"===I(t,8)}function I(t,e){return String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])}function D(t,e){return t[e]|t[e+1]<<8|t[e+2]<<16}function R(t,e,i){return(t<1||e<1||t>ve||e>ve)&&E("webp.dimensions"),{width:t,height:e,hasAlpha:i,mimeType:"image/webp"}}function C(t,e,i,s=256){if("string"!=typeof t||0===t.length||t.length>s)x(i,e);else{if(!/[\u0000-\u001f\u007f]/.test(t))return t;x(i,e)}}function U(t,e,i=1){let s=[];try{t=c(t)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}if(!A(t))throw new ue([j("manifest")]);z(t,["format","name","version","license","metadata","assets","states","capabilities","defaults"],"manifest",s),1!==t.format&&x(s,"format");let r=C(t.name,"name",s,64);r&&!Jt.test(r)&&x(s,"name");let n=C(t.version,"version",s,64),o=C(t.license,"license",s,128);n&&!Xt.test(n)&&x(s,"version"),o&&!Bt.test(o)&&x(s,"license");let h,a,l,d,f=0,u=1,p=32,v=32;if(A(t.assets))if(A(t.assets.atlas)){z(t.assets,["atlas"],"assets",s);let e=t.assets.atlas;z(e,["src","columns","rows","density","logicalCellSize","sourceCellSize","sha256"],"assets.atlas",s),h=C(e.src,"assets.atlas.src",s),M(e.sha256,"assets.atlas.sha256",s)&&(a=e.sha256),h&&(!Gt.test(h)||!/\.png$/i.test(h))&&x(s,"assets.atlas.src"),e.columns!==Zt&&x(s,"assets.atlas.columns");let i=[e.density,e.logicalCellSize,e.sourceCellSize],r=i.some(t=>void 0!==t),n=i.every(t=>void 0!==t);r&&!n&&x(s,"assets.atlas.density"),n&&(Ft.includes(e.density)?u=e.density:x(s,"assets.atlas.density"),Ht.includes(e.logicalCellSize)?p=e.logicalCellSize:x(s,"assets.atlas.logicalCellSize"),Number.isInteger(e.sourceCellSize)&&e.sourceCellSize===p*u?v=e.sourceCellSize:x(s,"assets.atlas.sourceCellSize")),!Number.isInteger(e.rows)||e.rows<2||e.rows>we/v?x(s,"assets.atlas.rows"):f=e.rows}else if(A(t.assets.atlases)){z(t.assets,["atlases"],"assets",s);let e=t.assets.atlases;z(e,["columns","rows","logicalCellSize","lineage","variants"],"assets.atlases",s),e.columns!==Zt&&x(s,"assets.atlases.columns"),Ht.includes(e.logicalCellSize)?p=e.logicalCellSize:x(s,"assets.atlases.logicalCellSize"),l=C(e.lineage,"assets.atlases.lineage",s,128),(!l||!/^[a-z0-9][a-z0-9._-]{2,127}$/.test(l))&&x(s,"assets.atlases.lineage"),d=O(e.variants,{path:"assets.atlases.variants",logicalWidth:p,logicalHeight:p,native:!0},s);let r=d.length?L(d.map(t=>t.density),i):void 0,n=d.find(t=>t.density===r);n&&(h=n.src,a=n.sha256,u=n.density,v=n.cellWidth),!Number.isInteger(e.rows)||e.rows<2||e.rows>we/v?x(s,"assets.atlases.rows"):f=e.rows}else x(s,"assets");else x(s,"assets");let y,w=S(t.states,f*Zt,s),b=Object.create(null);if(void 0!==t.capabilities){A(t.capabilities)&&z(t.capabilities,["locomotion"],"capabilities",s);let e=A(t.capabilities)?t.capabilities.locomotion:void 0;if(A(e)&&A(e.directions)){z(e,["directions","motion"],"capabilities.locomotion",s),z(e.directions,_t,"capabilities.locomotion.directions",s);for(let t of _t){let i=e.directions[t];"string"==typeof i&&w[i]?b[t]=i:x(s,"capabilities.locomotion.directions."+t)}if(void 0!==e.motion){let t=A(e.motion)?e.motion.keyframes:void 0;A(e.motion)&&z(e.motion,["keyframes"],"capabilities.locomotion.motion",s);let i=N(t,"capabilities.locomotion.motion.keyframes",s);Array.isArray(t)&&i.length===t.length&&(y=i)}}else x(s,"capabilities.locomotion.directions")}let g=2;if(void 0!==t.defaults&&(A(t.defaults)?(z(t.defaults,["scale"],"defaults",s),void 0!==t.defaults.scale&&(!Number.isInteger(t.defaults.scale)||t.defaults.scale<1||t.defaults.scale>4?x(s,"defaults.scale"):g=t.defaults.scale)):x(s,"defaults")),A(t.metadata)){z(t.metadata,["title","author","description","tags"],"metadata",s),C(t.metadata.description,"metadata.description",s,500),"string"==typeof t.metadata.description&&/:\/\//.test(t.metadata.description)&&x(s,"metadata.description");for(let e of["title","author"])void 0!==t.metadata[e]&&(C(t.metadata[e],"metadata."+e,s,120),"string"==typeof t.metadata[e]&&/:\/\//.test(t.metadata[e])&&x(s,"metadata."+e));void 0!==t.metadata.tags&&(!Array.isArray(t.metadata.tags)||t.metadata.tags.length>16||t.metadata.tags.some(t=>"string"!=typeof t||!be.test(t)))&&x(s,"metadata.tags")}else x(s,"metadata");e&&((e.width!==Zt*v||e.height!==f*v)&&x(s,"atlas.dimensions"),(e.width>we||e.height>we||void 0!==e.byteLength&&e.byteLength>4194304)&&x(s,"atlas.size"));if(s.length||!r||!n||!o||!h||!a)throw new ue(s.length?s:[j("manifest.incomplete")]);let m=t;return{name:r,displayName:m.metadata.title??r,version:n,license:o,atlas:{src:h,sha256:a,columns:Zt,rows:f,cellWidth:v,cellHeight:v,logicalWidth:p,logicalHeight:p,density:u,...l?{lineage:l}:{},...d?{variants:d}:{}},states:w,defaultScale:g,...Object.keys(b).length?{directionalStates:b}:{},...y?{locomotionMotion:y}:{},...m.metadata?{source:{metadata:m.metadata}}:{}}}function L(t,e){let i=[...new Set(t)].sort((t,e)=>t-e);if(!i.length)throw new ue([j("atlas.variants")]);return i.find(t=>t>=e)??i.at(-1)}function W(t){return"string"==typeof t&&t.length>0&&t.length<=512&&!/[\u0000-\u001f\u007f]/.test(t)}function H(t,e,i){let s=[];try{t=c(t)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}if(!A(t)||!A(t.atlas)||!A(t.states))throw new ue([j("normalized.structure")]);z(t,["name","displayName","version","license","atlas","states","defaultScale","directionalStates","locomotionMotion","reactionStates","source"],"normalizedPack",s);for(let e of["name","version","license"])W(t[e])||x(s,"normalized."+e);(!W(t.displayName)||t.displayName.length>120||/:\/\//.test(t.displayName))&&x(s,"normalized.displayName"),"string"==typeof t.version&&t.version.length>64&&x(s,"normalized.version"),W(t.name)&&!Jt.test(t.name)&&x(s,"normalized.name"),W(t.version)&&!Xt.test(t.version)&&x(s,"normalized.version"),W(t.license)&&!Bt.test(t.license)&&x(s,"normalized.license");let r=t.atlas;z(r,["src","columns","rows","cellWidth","cellHeight","logicalWidth","logicalHeight","density","lineage","sha256","variants"],"atlas",s);let n=[["columns",256],["rows",4096],["cellWidth",1024],["cellHeight",1024]];for(let[t,e]of n)(!Number.isInteger(r[t])||r[t]<1||r[t]>e)&&x(s,"atlas."+t);(!W(r.src)||!Gt.test(r.src)||!/\.(?:png|webp)$/i.test(r.src))&&x(s,"atlas.src");let o=+r.columns,h=+r.rows,a=+r.cellWidth,l=+r.cellHeight;for(let t of["logicalWidth","logicalHeight"])void 0!==r[t]&&(!Number.isInteger(r[t])||r[t]<1||r[t]>256)&&x(s,"atlas."+t);void 0!==r.density&&![1,2,4].includes(r.density)&&x(s,"atlas.density"),void 0!==r.lineage&&(!W(r.lineage)||!/^[a-z0-9][a-z0-9._-]{2,127}$/.test(r.lineage))&&x(s,"atlas.lineage");let d=void 0===r.variants?[]:O(r.variants,{path:"atlas.variants"},s),f=void 0===r.sha256?void 0:M(r.sha256,"atlas.sha256",s)?r.sha256:void 0;void 0===r.variants&&void 0===r.sha256&&M(void 0,"atlas.sha256",s);let u=[1,2,4].includes(r.density)?r.density:1,v=Number.isInteger(r.logicalWidth)?r.logicalWidth:a/u,y=Number.isInteger(r.logicalHeight)?r.logicalHeight:l/u,w=d.length?L(d.map(t=>t.density),i??u):u,b=d.find(t=>t.density===w),g=b?.sha256??f,m=b?.src??r.src,k=b?.cellWidth??a,$=b?.cellHeight??l;(!Number.isInteger(v)||!Number.isInteger(y)||k!==v*w||$!==y*w)&&x(s,"atlas.logical-cell");let E=o*h;(o*k>4096||h*$>4096)&&x(s,"atlas.size");let T=S(t.states,E,s);(!Number.isInteger(t.defaultScale)||t.defaultScale<1||t.defaultScale>4)&&x(s,"normalized.defaultScale");let P={};if(void 0!==t.directionalStates)if(A(t.directionalStates)){z(t.directionalStates,_t,"directionalStates",s);for(let e of _t){let i=t.directionalStates[e];void 0!==i&&("string"==typeof i&&T[i]?P[e]=i:x(s,"directionalStates."+e))}}else x(s,"directionalStates");let I={};if(void 0!==t.reactionStates)if(!A(t.reactionStates)||Object.keys(t.reactionStates).length>32)x(s,"reactionStates.limit");else for(let[e,i]of Object.entries(t.reactionStates))/^[a-z][a-z0-9-]{0,63}$/.test(e)&&"string"==typeof i&&T[i]?I[e]=i:x(s,"reactionStates."+e);let D,R=[];void 0!==t.locomotionMotion&&(R=N(t.locomotionMotion,"locomotionMotion",s)),e&&(e.width!==o*k||e.height!==h*$)&&x(s,"atlas.pixels"),void 0!==e?.byteLength&&(!Number.isSafeInteger(e.byteLength)||e.byteLength<1||e.byteLength>33554432)&&x(s,"atlas.size");if(void 0!==t.source)try{let e=p(t.source);if(!A(e))throw new TypeError("normalized.source");D=Object.freeze({...e})}catch(t){x(s,"normalized.source")}if(s.length||!g)throw new ue(s.length?s:[j("atlas.sha256")]);return{name:t.name,displayName:W(t.displayName)?t.displayName:t.name,version:t.version,license:t.license,atlas:{src:m,sha256:g,columns:o,rows:h,cellWidth:k,cellHeight:$,logicalWidth:v,logicalHeight:y,density:w,..."string"==typeof r.lineage?{lineage:r.lineage}:{},...d.length?{variants:d}:{}},states:T,defaultScale:t.defaultScale,...Object.keys(P).length?{directionalStates:P}:{},...R.length?{locomotionMotion:R}:{},...Object.keys(I).length?{reactionStates:I}:{},...D?{source:D}:{}}}function Z(t){return Object.hasOwn(ge,t)}function F(t,e){let i=t.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return(!i||!e.includes(i))&&E("mime.invalid"),i}function _(t){if(t instanceof DOMException&&"AbortError"===t.name)return"abort";if(t instanceof fe)return t.category;if(t instanceof ue)for(let e of t.issueCodes){let t=e.slice(e.indexOf(".")+1);if("hash"===t)return"hash";if("mime.invalid"===e||"mime"===t)return"mime";if(e.startsWith("png.")||e.startsWith("webp.")||e.startsWith("atlas.")&&["dimensions","pixels","alpha","size"].includes(t))return"image";if("size"===t)return"size";if(t.startsWith("integrity-"))return"integrity"}return"validation"}function V(t,e){return e.aborted||t instanceof DOMException&&"AbortError"===t.name}async function q(t,e,i,s){let r=((t,e,i)=>{let s=new AbortController,r=!1,n=()=>s.abort(t.reason);t.aborted?n():t.addEventListener("abort",n,{once:!0});let o=globalThis.setTimeout(()=>{s.signal.aborted||(r=!0,s.abort(new DOMException(i,"TimeoutError")))},e);return{signal:s.signal,get timedOut(){return r},close(){globalThis.clearTimeout(o),t.removeEventListener("abort",n)}}})(t,e,i);try{return await s(r.signal)}catch(t){throw r.timedOut&&(t===r.signal.reason||t instanceof DOMException&&("AbortError"===t.name||"TimeoutError"===t.name))?new fe(i,"timeout",i,t):t}finally{r.close()}}async function J(t,e,i,s){try{return await t(e,{signal:i})}catch(t){throw V(t,i)?t:new fe(s,"network",s,t)}}async function K(t,e,i,s){try{return await(async(t,e,i)=>{let s=+t.headers.get("content-length");if(Number.isFinite(s)&&s>e&&E("resource.size"),!t.body){let i=new Uint8Array(await t.arrayBuffer());return i.byteLength>e&&E("resource.size"),i}let r=t.body.getReader(),n=[],o=0;try{for(;;){i.throwIfAborted();let{done:t,value:s}=await r.read();if(t)break;o+=s.byteLength,o>e&&(await r.cancel(),E("resource.size")),n.push(s)}}catch(t){try{await r.cancel(t)}catch{}throw t}finally{r.releaseLock()}let h=new Uint8Array(o),a=0;for(let t of n)h.set(t,a),a+=t.byteLength;return h})(t,e,i)}catch(t){throw V(t,i)||t instanceof fe||t instanceof ue?t:new fe(s,"network",s,t)}}async function Q(t,e,i=!1){let s,r=i?"manifest":"atlas";pe.test(e)||E(r+".integrity-declaration");try{let t=globalThis.crypto?.subtle;s=t?.digest.bind(t)}catch{}s||E(r+".integrity-unavailable");try{return!new Uint8Array(await s("SHA-256",t)).some((t,i)=>t!==Number.parseInt(e.slice(2*i,2*i+2),16))}catch{E(r+".integrity-failed")}}function X(t,e,i=4){let s=Number.isFinite(t)&&t>0?t:1;return Math.min(s*e,i)}function B(t,e={}){let i=l(t);ht(i),at(i,["baseline","rules"]),i.baseline||ut("missing-baseline");let s=G(i.baseline,0,e,!1);s.until&&ut("invalid-baseline-interrupt"),s.channels.includes("state")||ut("missing-baseline-state"),s.state||ut("missing-baseline-state");for(let[t,e]of Y(s).entries())e.ordering&&ut("invalid-ordering-source");let r=void 0===i.rules?[]:i.rules;(!Array.isArray(r)||r.length>64)&&ut("rule-limit");let n=new Set,o=r.map((t,i)=>{ht(t),at(t,["id","when","effect"]),lt(t.id),n.has(t.id)&&ut("duplicate-rule"),n.add(t.id);let s=((t,e,i)=>(ht(t),"application"===t.source?(at(t,["source","event","coalesce"]),("string"!=typeof t.event||!Kt.test(t.event))&&ut("invalid-condition"),it(t.coalesce),ft({source:"application",event:t.event,...t.coalesce?{coalesce:t.coalesce}:{}})):("browser"!==t.source&&ut("invalid-condition"),Vt.includes(t.event)||ut("invalid-condition"),"section.visibility"!==t.event?(at(t,["source","event","coalesce"]),it(t.coalesce),"window.scroll"===t.event?ft({source:"browser",event:"window.scroll",...t.coalesce?{coalesce:t.coalesce}:{}}):(t.coalesce&&ut("unsafe-coalescing"),ft({source:"browser",event:t.event}))):(at(t,["source","event","selector","phase","threshold"]),((t,e,i)=>{if(("string"!=typeof t||t.length<1||t.length>256||/[\0\r\n]/.test(t))&&ut("invalid-selector"),!i)return;let s=!1;try{s=i(t)}catch{s=!1}s||ut("invalid-selector")})(t.selector,0,i.validateSelector),["enter","while-visible","leave"].includes(t.phase)||ut("invalid-condition"),void 0!==t.threshold&&("number"!=typeof t.threshold||!Number.isFinite(t.threshold)||t.threshold<=0||t.threshold>1)&&ut("invalid-threshold"),ft({source:"browser",event:"section.visibility",selector:t.selector,phase:t.phase,...void 0===t.threshold?{}:{threshold:t.threshold}})))))(t.when,0,e),r=G(t.effect,0,e,!0);"browser"===s.source&&("pointer.move"===s.event||"section.visibility"===s.event&&"while-visible"===s.phase)&&(void 0!==t.effect.surfaces||r.until)&&ut("invalid-continuous-effect");for(let t of Y(r))"event-payload"===et(t)&&"application"!==s.source&&ut("invalid-payload-source"),t.ordering&&"application"!==s.source&&ut("invalid-ordering-source");return ft({id:t.id,when:s,effect:r})});return((t,e)=>{let i=new Set(Y(t).map(tt)),s=new Map,r=new Map;for(let t of e)for(let e of Y(t.effect)){let n=tt(e);i.has(n)&&!e.disposition&&ut("ambiguous-channel");let o=s.get(n)??[];o.push(t),s.set(n,o);let h=e.ordering;if(!h)continue;let a=r.get(n);a?(a.sessionField!==h.sessionField&&ut("ambiguous-ordering"),h.revisionField&&a.revisionField&&a.revisionField!==h.revisionField&&ut("ambiguous-ordering"),h.revisionField&&!a.revisionField&&(a.revisionField=h.revisionField)):r.set(n,{sessionField:h.sessionField,...h.revisionField?{revisionField:h.revisionField}:{}})}for(let[t,e]of s)e.length<2||e.filter(e=>Y(e.effect).some(e=>tt(e)===t&&!e.disposition)).length&&ut("ambiguous-channel")})(s,o),(t=>{let e=new Map;for(let i of t){let t=`${i.when.source}:${i.when.event}`,s=e.get(t)??[];s.push(i),e.set(t,s)}for(let[t,i]of e)new Set(i.map(t=>t.when.coalesce??"fifo")).size>1&&ut("ambiguous-coalescing"),"latest"===i[0]?.when.coalesce&&"application"===i[0].when.source&&(i.every(t=>t.effect.channels.every(t=>t.startsWith("surface:"))&&Y(t.effect).length>0&&Y(t.effect).every(t=>t.ordering?.revisionField))||ut("unsafe-coalescing"),1!==new Set(i.flatMap(t=>Y(t.effect).map(t=>`${t.ordering.sessionField}\0${t.ordering.revisionField}`))).size&&ut("ambiguous-coalescing"))})(o),ft({baseline:s,rules:ft(o)})}function G(t,e,i,s){ht(t),at(t,["channels","state","motion","surfaces","until"]),(!Array.isArray(t.channels)||!t.channels.length||t.channels.length>16)&&ut("invalid-channels");let r=t.channels.map((t,e)=>(("string"!=typeof t||!me.test(t))&&ut("invalid-channel"),t));new Set(r).size!==r.length&&ut("duplicate-channel");let n=void 0===t.state?void 0:((t,e,i)=>(ht(t),"state"in t?(at(t,["state"]),("string"!=typeof t.state||!Qt.test(t.state))&&ut("invalid-state"),i.states&&!i.states.has(t.state)&&ut("unknown-state"),ft({kind:"state",name:t.state})):(at(t,["capability"]),"locomotion"!==t.capability&&ut("invalid-capability"),i.capabilities&&!i.capabilities.has(t.capability)&&ut("unknown-capability"),ft({kind:"capability",name:t.capability}))))(t.state,0,i),o=void 0===t.motion?void 0:((t,e,i)=>{switch(ht(t),t.type){case"follow-pointer":at(t,["type","speed","arrivalRadius"]),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"horizontal-patrol":at(t,["type","speed","edgeInset"]),dt(t.speed,0,1,1e3),dt(t.edgeInset,0,0,1e3);break;case"viewport-traverse":at(t,["type","speed","edgeInset","clockwise"]),dt(t.speed,0,1,1e3),dt(t.edgeInset,0,0,1e3),void 0!==t.clockwise&&"boolean"!=typeof t.clockwise&&ut("invalid-motion");break;case"move-to":at(t,["type","x","y","speed","arrivalRadius"]),dt(t.x,0,-1e5,1e5),dt(t.y,0,-1e5,1e5),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"move-to-target":at(t,["type","target","anchor","speed","arrivalRadius"]),lt(t.target),i.targets&&!i.targets.has(t.target)&&ut("unknown-target"),void 0!==t.anchor&&!["center","top","right","bottom","left"].includes(t.anchor)&&ut("invalid-motion"),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"jump-to":at(t,["type","x","y","duration","height"]),dt(t.x,0,-1e5,1e5),dt(t.y,0,-1e5,1e5),dt(t.duration,0,100,1e4),dt(t.height,0,0,2e3);break;case"svg-path":at(t,["type","path","duration","loop","relative"]),("string"!=typeof t.path||t.path.length<1||t.path.length>4096||/[\0\r\n]/.test(t.path))&&ut("invalid-path"),i.validatePath&&!i.validatePath(t.path)&&ut("invalid-path"),dt(t.duration,0,100,6e4);for(let e of["loop","relative"])void 0!==t[e]&&"boolean"!=typeof t[e]&&ut("invalid-motion");break;default:ut("invalid-motion")}return ft({...t})})(t.motion,0,i),h=void 0===t.surfaces?[]:t.surfaces;(!Array.isArray(h)||h.length>8)&&ut("surface-limit");let a=h.map((t,e)=>((t,e,i,s)=>{ht(t),at(t,["id","contentId","data","disposition","ordering"]),lt(t.id),lt(t.contentId),i.contentIds&&!i.contentIds.has(t.contentId)&&ut("unknown-content"),"event-payload"===t.data&&!s&&ut("invalid-surface-data"),void 0!==t.disposition&&!["update","replace","ignore","interrupt"].includes(t.disposition)&&ut("invalid-disposition");let r,n=void 0===t.ordering?void 0:(t=>(ht(t),at(t,["sessionField","revisionField","terminal"]),ct(t.sessionField),void 0!==t.revisionField&&ct(t.revisionField),void 0!==t.terminal&&"boolean"!=typeof t.terminal&&ut("invalid-ordering"),!t.terminal&&!t.revisionField&&ut("invalid-ordering"),ft({sessionField:t.sessionField,...t.revisionField?{revisionField:t.revisionField}:{},...t.terminal?{terminal:!0}:{}})))(t.ordering);if(void 0!==t.data&&"event-payload"!==t.data)try{r=p(t.data)}catch{ut("invalid-surface-data")}return ft({id:t.id,channel:"surface:"+t.id,contentId:t.contentId,..."event-payload"===t.data?{dataSource:"event-payload"}:{},...void 0===r?{}:{data:r},...t.disposition?{disposition:t.disposition}:{},...n?{ordering:n}:{}})})(t,0,i,s)),l=new Set;for(let t of a){let e=tt(t);l.has(e)&&ut("duplicate-surface"),l.add(e)}let c=void 0===t.until?void 0:(t=>(ht(t),"duration"===t.type?(at(t,["type","ms"]),void 0===t.ms&&ut("missing-interrupt-duration"),dt(t.ms,0,1,36e5),ft({type:"duration",ms:t.ms})):("event"!==t.type&&ut("invalid-interrupt-lifetime"),at(t,["type","name","timeout"]),("string"!=typeof t.name||!Kt.test(t.name))&&ut("invalid-interrupt-lifetime"),u(t.name)&&ut("invalid-interrupt-lifetime"),dt(t.timeout,0,1,36e5),ft({type:"event",name:t.name,...void 0===t.timeout?{}:{timeout:t.timeout}}))))(t.until);a.filter(t=>"interrupt"===t.disposition).length&&!c&&ut("missing-interrupt-lifetime"),c&&a.some(t=>"interrupt"!==t.disposition)&&ut("mixed-interrupt-effect"),n&&!r.includes("state")&&ut("undeclared-channel"),!n&&r.includes("state")&&ut("missing-channel-output"),o&&!r.includes("motion")&&ut("undeclared-channel"),!o&&r.includes("motion")&&ut("missing-channel-output");let d=a.map(tt);for(let t of r)t.startsWith("surface:")&&!d.includes(t)&&ut("missing-channel-output");for(let t of d)r.includes(t)||ut("undeclared-channel");return ft({channels:ft(r),...n?{state:n}:{},...o?{motion:o}:{},surfaces:ft(a),...c?{until:c}:{}})}function Y(t){return t.surfaces??[]}function tt(t){return"channel"in t?t.channel:"surface:"+t.id}function et(t){return"dataSource"in t?t.dataSource:"event-payload"===t.data?"event-payload":void 0}function it(t,e){void 0!==t&&"latest"!==t&&ut("invalid-coalescing")}function st(t,e){let i=Y(t).map(t=>ft({...t,..."event-payload"===et(t)?{data:e}:{}}));return ft({...t,surfaces:ft(i)})}function rt(t,e,i,s){for(let r of t){let t=r.ordering;if(!t)continue;if(!s||"object"!=typeof s||Array.isArray(s))return"invalid";let n=s,o=n[t.sessionField];if("string"!=typeof o&&"number"!=typeof o)return"invalid";let h=`${tt(r)}\0${typeof o}\0${o+""}`,a=e.ordering.get(h);if(!0===a)return"closed";let l=i.ordering.get(h),c="number"==typeof l?l:a;if(t.revisionField){let e=n[t.revisionField];if(!Number.isSafeInteger(e)||e<0)return"invalid";if("number"==typeof a&&e<=a||"number"==typeof l&&e<l)return"stale";c=e}i.ordering.set(h,!(!t.terminal&&!0!==l)||c)}return"matched"}function nt(t,e){if(!e.length)return;if(e.length===t.channels.length)return t;let i=new Set(e);return ft({channels:ft(e),...i.has("state")&&t.state?{state:t.state}:{},...i.has("motion")&&t.motion?{motion:t.motion}:{},surfaces:ft(Y(t).filter(t=>i.has(tt(t)))),...t.until?{until:t.until}:{}})}function ot(t,e,i){for(let[i,s]of e.ordering)t.ordering.set(i,s);for(let s of e.ordering.keys()){let e=t.sessions.get(i)??[],r=e.indexOf(s);for(r>=0&&e.splice(r,1),e.push(s),t.sessions.set(i,e);e.length>64;)t.ordering.delete(e.shift())}}function ht(t,e){(!t||"object"!=typeof t||Array.isArray(t))&&ut("invalid-object")}function at(t,e,i){for(let i of Object.keys(t))e.includes(i)||ut("unknown-field")}function lt(t,e,i){("string"!=typeof t||!/^[a-z][a-z0-9:-]{0,63}$/.test(t))&&ut("invalid-id")}function ct(t,e){("string"!=typeof t||!ke.test(t))&&ut("invalid-ordering")}function dt(t,e,i,s){void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<i||t>s)&&ut("out-of-range")}function ft(t){return Object.freeze(t)}function ut(t,e,i){throw new $e(t,"",t)}function pt(t,e,i){let s=Math.min(e.viewport.width/2,e.t.width/2+(t.edgeInset??0)),r=e.viewport.width-s,n=e.t.height/2,o=Math.max(n,e.viewport.height-n),h=wt(t,e.position,i?r:s,o);return h||(h=wt(t,e.position,(i=!i)?r:s,o)),[i,h]}function vt(t,e){let i=e.t;return i?{x:Math.max(i.width/2,Math.min(e.viewport.width-i.width/2,t.x)),y:Math.max(i.height/2,Math.min(e.viewport.height-i.height/2,t.y))}:{x:t.x,y:t.y}}function yt(t,e,i=0){let s=e.x-t.x,r=e.y-t.y,n=Math.hypot(s,r);return{x:n?s/n:0,y:n?r/n:0,speed:0,maxDistance:n,lift:i,direct:!0}}function wt(t,e,i,s,r=0,n){let o=n?.t,h=n?.viewport;if(o&&h){let t=i,e=s;i=Math.max(o.width/2,Math.min(h.width-o.width/2,i)),s=Math.max(o.height/2,Math.min(h.height-o.height/2,s)),(i!==t||s!==e)&&(r=0)}let a=i-e.x,l=s-e.y,c=Math.hypot(a,l),d=c-r;if(!(d<=4))return{x:a/c,y:l/c,speed:t.speed??160,maxDistance:d}}function bt(t){return void 0===t||"boolean"==typeof t||kt(t,80)}function gt(t,e,i,s,r){if(!(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(t)&&($t(e,i),xe))return;let n=t;return s&&mt(n,s,i),n}function mt(t,e,i,s){for(let s of Object.keys(t))e.includes(s)||$t("unknown-field",`${i}.${s}`)}function kt(t,e){return"string"==typeof t&&t.length>0&&t.length<=e&&!/[\u0000-\u001f\u007f]/.test(t)}function $t(t,e,i,s){throw new Me(t,e,t)}function jt(t,e,i){throw new Me(t,e,t)}function xt(t){return f(t)?"browser":"application"}function Et(t){let e=t.until;return"duration"===e?.type?e.ms:"event"===e?.type&&void 0!==e.timeout?e.timeout:"manual"===e?.type&&void 0!==e.maxMs?e.maxMs:Oe}function Mt(t,e){if("number"!=typeof t||!Number.isFinite(t)||t<1||t>Oe)throw new TypeError("override.lifetime")}function Ot(t,e,i){for(let i of Object.keys(t))if(!e.includes(i))throw new TypeError(Lt("override.unknown-field"))}function St(t,e=1){let i=Number.isFinite(e)&&e>0?e:1;return Math.round(t*i)/i}function Nt(t){let e=t.target,i="function"==typeof e.closest?e:e.parentElement;try{return!!i?.closest?.("[data-peekling-host],[data-peekling-content],[data-peekling-controls]")}catch{return!1}}function At(t,e=Date.now()){try{if("1"===t.sessionStorage.getItem(Re))return[!0];let i=JSON.parse(t.localStorage.getItem(De)??"null");if("hidden"!==i?.visibility)return[!1];if(null===i.until)return[!0];if(Number.isFinite(i.until)&&i.until>e)return[!0,i.until];t.localStorage.removeItem(De)}catch{}return[!1]}function zt(t,e){let i=Ce.findIndex(t=>t[1]===e);if(i<0)throw new TypeError("visibility.duration");let s=new Date,r=i>2?void 0:i<2?s.getTime()+6e4*(i?60:10):new Date(s.getFullYear(),s.getMonth(),s.getDate()+1).getTime();try{if(t.sessionStorage.removeItem(Re),3===i)return t.localStorage.removeItem(De),t.sessionStorage.setItem(Re,"1"),r;t.localStorage.setItem(De,JSON.stringify({visibility:"hidden",until:4===i?null:r}))}catch{}return r}function Tt(t){try{t.localStorage.removeItem(De),t.sessionStorage.removeItem(Re)}catch{}}function Pt(t,e,i,s){return{x:Math.max(i/2,Math.min(e.width-i/2,t.x)),y:Math.max(s/2,Math.min(e.height-s/2,t.y))}}function It(t){try{globalThis.dispatchEvent(new CustomEvent("peekling:collision",{detail:t}))}catch{}}function Dt(){let t,e,i=new Promise((i,s)=>{t=i,e=s});return i.catch(()=>{}),[i,t,e]}var Rt,Ct,Ut,Lt=t=>t,Wt=class{ready;#t;#e;#i=!1;#s=()=>{};constructor(t,e,i){let s=t.createElement("link");this.#t=s,s.rel="stylesheet",s.href=i.url,s.crossOrigin="anonymous",s.referrerPolicy="no-referrer",i.integrity&&(s.integrity=i.integrity),this.ready=new Promise((t,e)=>{this.#s=e;let i=(t,i)=>{this.#i||(this.#i=!0,e(Error(t)))};s.addEventListener("load",()=>{if(this.#i)return;let e=s.sheet;e&&"function"==typeof e.insertRule?(this.#e=e,this.#i=!0,t()):i("styles.cssom")},{once:!0}),s.addEventListener("error",()=>i("styles.load"),{once:!0})}),this.ready.catch(()=>{}),e.append(s)}addRule(t){if(!this.#e)throw Error("styles.pending");let e=this.#e.cssRules.length;this.#e.insertRule(t+"{}",e);let i=this.#e.cssRules[e];if(!i?.style)throw Error("styles.rule");return i.style}removeRule(t){let e=this.#e;if(e)for(let i=e.cssRules.length-1;i>=0;i--)if(e.cssRules[i]?.style===t){e.deleteRule(i);return}}destroy(){this.#i||(this.#i=!0,this.#s(new DOMException("styles.cancelled","AbortError"))),this.#t.remove(),this.#e=void 0}},Ht=[32,64],Zt=16,Ft=[1,2,4],_t=["N","NE","E","SE","S","SW","W","NW"],Vt=["pointer.click","pointer.move","document.visibility","window.focus","window.scroll","section.visibility","page.lifecycle"],qt=["top-left","top-center","top-right","bottom"],Jt=/^(?!peekling:)[a-z][a-z0-9:-]{0,63}$/,Kt=/^(?=.{1,64}$)[a-z][a-z0-9]*(?:[.:-][a-z][a-z0-9-]*)*$/,Qt=/^(?=.{1,64}$)[a-z][a-z0-9-]*(?::[A-Za-z0-9.-]+)?$/,Xt=/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,Bt=/^(?:[A-Za-z0-9][A-Za-z0-9.-]{0,63}|DocumentRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31}:LicenseRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31})$/,Gt=/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*\/\/)[A-Za-z0-9._/-]{1,256}$/,Yt=/^(?:transparent|#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8}))(?![\s\S])/,te=class extends TypeError{issueCode;constructor(t,e,i){super(`${t} ${e}`),this.name="OwnDataError",this.issueCode=i}},ee=new WeakSet,ie=new WeakSet,se=new WeakSet,re=/^[A-Za-z0-9_.:-]{1,64}$/,ne=Object.freeze({json:!0,key(t){return re.test(t)},maxArrayLength:64,maxDepth:6,maxObjectKeys:64,maxStringLength:2048,maxValues:256}),oe=class{ready;#t;#e;#i;#s=new Map;#r;#n;#o;#h;#a;#l;#c;#d;#f=0;#u=0;#p=!0;#v=NaN;#y=NaN;#w=NaN;#b=NaN;#g=NaN;#m=NaN;#k;#$;#j;#x=!1;#E=!1;#M=!1;constructor(t,e={}){this.#t=t,this.#r=new URL(t.baseURI??globalThis.location?.href??"https://peekling.invalid/").origin,this.#n=e.i??(()=>{}),this.#o=e.bindings??{},this.#h=!0===e.announce,this.#a=e.emit??(()=>({accepted:!1,reason:"not-ready"})),this.#l=e.wake??(()=>{}),this.#e=t.createElement("aside"),this.#e.hidden=!0,this.#e.dataset.peeklingContent="",this.#d=e.label??"Peekling content",this.#e.setAttribute("aria-label",this.#d),this.#i=this.#e.attachShadow({mode:"closed"}),this.#c=new Wt(t,this.#i,e.styles??i(void 0,t.baseURI??"https://peekling.invalid/")),this.ready=this.#c.ready.then(()=>{this.#M||((t,e)=>{if(!e)return;let i=[["--peekling-surface-background",e.background,""],["--peekling-surface-color",e.color,""],["--peekling-surface-link",e.linkColor,""],["--peekling-surface-border",e.borderColor,""],["--peekling-surface-radius",e.radius,"px"],["--peekling-surface-width",e.width,"px"],["--peekling-surface-padding",e.padding,"px"]];for(let[e,s,r]of i)void 0!==s&&t.setProperty(e,`${s}${r}`)})(this.#c.addRule(":host"),e.theme)}),this.ready.catch(()=>{}),this.#O()}o(t,e,i,s,r,n){if(this.#M||(this.#O(),this.#M))return;if(this.#u+=1,this.#u>=Number.MAX_SAFE_INTEGER){this.#u=1;for(let t of this.#s.values())t.seen=0}let o=this.#u;for(let i of t)if(Object.hasOwn(e,i.contentId)&&(this.#S(i,e[i.contentId],o),this.#M))return;if(n){if(n!==this.#k&&(this.#k=n,this.#$={id:"peekling:name",contentId:"peekling:name",key:"peekling:name:"+n},this.#j={bottom:n}),this.#S(this.#$,this.#j,o),this.#M)return}else this.#k=void 0,this.#$=void 0,this.#j=void 0;for(let t of this.#s.values())if(t.seen!==o&&this.#N(t),this.#M)return;let h=!1;for(let t of this.#s.values())if(!t.host.hidden){h=!0;break}this.#E=h;let a=this.#x||!h;this.#e.hidden!==a&&(this.#e.hidden=a);let l=s.width!==this.#w||s.height!==this.#b,c=l||i.x!==this.#v||i.y!==this.#y||r.width!==this.#g||r.height!==this.#m;if(this.#v=i.x,this.#y=i.y,this.#w=s.width,this.#b=s.height,this.#g=r.width,this.#m=r.height,l)for(let t of this.#s.values())t.host.hidden||(t.measureDirty=!0);c&&(this.#p=!0);for(let t of this.#s.values()){if(t.host.hidden||!t.measureDirty)continue;let e=t.host.getBoundingClientRect();if(this.#M)return;t.measuredWidth=e.width,t.measuredHeight=e.height,t.measureDirty=!1,this.#p=!0}if(this.#p){let t=0,e=0,n=0,o=0,h=[...this.#s.values()].sort((t,e)=>t.key<e.key?-1:t.key>e.key?1:0);for(let a of h){if(a.host.hidden)continue;let h;switch(a.region){case"top-left":h=t,t+=a.measuredHeight+8;break;case"top-center":h=e,e+=a.measuredHeight+8;break;case"top-right":h=n,n+=a.measuredHeight+8;break;case"bottom":h=o,o+=a.measuredHeight+8}let l=b(a.region,i,s,r,{width:a.measuredWidth,height:a.measuredHeight}),c=l.x+"px",d=g(l.y+h,8,s.height-a.measuredHeight-8)+"px";if(a.left!==c){if(a.h.left=c,this.#M)return;a.left=c}if(a.top!==d){if(a.h.top=d,this.#M)return;a.top=d}}this.#p=!1}}setUserHidden(t){if(this.#M)return!1;let e=this.#x;if(this.#x=t,this.#e.hidden=t||!this.#E,e&&!t&&!this.#e.hidden){for(let t of this.#s.values())t.host.hidden||(t.measureDirty=!0);this.#p=!0,this.#l()}return!this.#x}toggleUserHidden(){return this.setUserHidden(!this.#x)}get userHidden(){return this.#x}#S(t,e,i){for(let s of qt){let r=e[s];if(void 0===r)continue;let n=`${t.id}\0${s}`,o=this.#s.get(n)??this.#A(n,t.id,t.contentId,s);if(o.seen=i,o.contentId!==t.contentId&&(o.contentId=t.contentId,this.#z(o)),this.#T(o,r,t),this.#M)return}}#z(t,e=!1){t.measureDirty=!0,this.#p=!0,e&&!this.#M&&this.#l()}#P(t,e){t.host.hidden!==e&&(t.host.hidden=e,this.#p=!0,e||(t.measureDirty=!0))}#A(t,e,i,s){let r=this.#t.createElement("section"),n="peekling-position-"+ ++this.#f;r.className=`surface ${s} ${n}`,r.hidden=!0,r.setAttribute("part","surface "+s),r.dataset.peeklingSurface=e;let o=this.#t.createElement("strong");o.className="title";let h=this.#t.createElement("p"),a=this.#t.createElement("a"),l=this.#t.createElement("div");l.dataset.peeklingMount="",r.append(o,h,a,l),this.#i.append(r);let c={key:t,surfaceId:e,contentId:i,region:s,host:r,title:o,text:h,link:a,l,u:void 0,p:"",v:"",seen:0,measureDirty:!0,measuredWidth:0,measuredHeight:0,left:"",top:"",h:this.#c.addRule("."+n)};return this.#s.set(t,c),this.#p=!0,c}#T(t,e,i){if(this.#M)return;if(t.primitive!==e){t.primitive=e,t.item="string"==typeof e?{text:e}:e;let i=t.item;this.#z(t),t.title.textContent=i.title??"",t.title.hidden=!!i.mountId||!i.title,t.text.textContent=i.text??"",t.text.hidden=!!i.mountId||!i.text,t.link.hidden=!!i.mountId||!i.link,!i.mountId&&i.link?(t.link.textContent=i.link.label,t.link.href=i.link.href,new URL(i.link.href).origin!==this.#r?(t.link.target="_blank",t.link.rel="noopener noreferrer"):(t.link.removeAttribute("target"),t.link.removeAttribute("rel"))):(t.link.textContent="",t.link.removeAttribute("href"),t.link.removeAttribute("target"),t.link.removeAttribute("rel")),i.announce||this.#h?(t.host.setAttribute("aria-live","polite"),t.host.setAttribute("aria-atomic","true")):(t.host.removeAttribute("aria-live"),t.host.removeAttribute("aria-atomic"))}let s=t.item;if(s.mountId){if(t.v===`${s.mountId}\0${i.key}`){this.#P(t,!0);return}t.v&&(t.v=""),this.#I(t,s.mountId,i)}else t.v="",this.#D(t);this.#M||this.#P(t,!1)}#I(t,e,i){if(this.#M)return;let s,r=`${e}\0${i.key}`;if(t.u?.mountId===e&&t.p===r)return;try{s=p(i.data)}catch{this.#R(t,"data-failed",r);return}if(t.u?.mountId===e){if(t.p=r,t.u.data=s,t.u.result?.update){this.#C(t,t.u,s);return}if(!t.u.result){t.u.m=!0,t.u.key=i.key;return}this.#D(t)}else this.#D(t);if(this.#M)return;let n=this.#o.mounts,o=n&&Object.hasOwn(n,e)?n[e]:void 0;if(!o){this.#R(t,"mount-binding-is-missing",r);return}let h,a=new AbortController,l=this.#t.createElement("div"),c={mountId:e,abort:a,root:l,result:void 0,data:s,m:!1,updating:!1,key:i.key};t.u=c,t.p=r,t.l.replaceChildren(l),this.#z(t);try{h=o(Object.freeze({surfaceId:t.surfaceId,contentId:t.contentId,region:t.region,root:l,...void 0===s?{}:{data:s},signal:a.signal,emit:this.#a}))}catch{this.#R(t,"mount-failed",r);return}Promise.resolve(h).then(i=>{let s=(t=>{if(!t||"object"!=typeof t)return;let e;try{e=Object.getOwnPropertyDescriptors(t)}catch{return}let i=e.cleanup,s=e.update;return i&&"value"in i&&"function"==typeof i.value&&(!s||"value"in s&&"function"==typeof s.value)?Object.freeze({cleanup:i.value,...s?{update:s.value}:{}}):void 0})(i);if(this.#M||t.u!==c||a.signal.aborted)s&&this.#U(s,t);else if(s){if(c.result=s,this.#z(t,!0),c.m)if(c.m=!1,s.update)this.#C(t,c,c.data);else{let i={id:t.surfaceId,contentId:t.contentId,...void 0===c.data?{}:{data:c.data},key:c.key};this.#D(t),this.#I(t,e,i)}}else this.#R(t,"mount-failed",r)},()=>{!this.#M&&t.u===c&&!a.signal.aborted&&this.#R(t,"mount-failed",r)})}#C(t,e,i){if(this.#M)return;let s=e.result?.update;if(s){if(e.updating){e.m=!0;return}e.updating=!0,this.#z(t);try{let r=s(i);Promise.resolve(r).then(()=>{this.#M||t.u!==e||(e.updating=!1,this.#z(t,!0),e.m&&(e.m=!1,this.#C(t,e,e.data)))},()=>{!this.#M&&t.u===e&&this.#R(t,"update-failed",t.p)})}catch{!this.#M&&t.u===e&&this.#R(t,"update-failed",t.p)}}}#R(t,e,i=t.p){this.#M||(this.#n("content."+e),!this.#M&&(this.#D(t),!this.#M&&(t.v=i,this.#P(t,!0))))}#D(t){let e=t.u;t.u=void 0,t.p="",e&&(e.abort.abort(),e.result&&this.#U(e.result,t),e.root.remove(),t.l.replaceChildren(),this.#z(t))}#U(t,e){try{let e=t.cleanup();Promise.resolve(e).catch(()=>this.#n("content.cleanup-failed"))}catch{this.#n("content.cleanup-failed")}}#N(t){this.#D(t),!this.#M&&this.#L(t)}#L(t){t.u&&this.#D(t),this.#c.removeRule(t.h),t.host.remove(),this.#s.delete(t.key),this.#p=!0}destroy(){if(!this.#M){this.#M=!0;for(let t of[...this.#s.values()])this.#L(t);this.#c.destroy(),this.#e.remove()}}#O(){if(this.#M)return;let e=this.#e.parentNode!==this.#t.documentElement||!this.#e.hasAttribute("data-peekling-content");if(t(this.#e,this.#t,"data-peekling-content"),!this.#M){if(this.#i.host!==this.#e)throw Error("content.root");this.#e.getAttribute("aria-label")!==this.#d&&this.#e.setAttribute("aria-label",this.#d);for(let t of this.#s.values()){if(e&&this.#z(t),t.host.ownerDocument!==this.#t)throw Error(Lt("content.document"));t.host.parentNode!==this.#i&&(this.#i.append(t.host),this.#z(t)),(t.title.parentNode!==t.host||t.text.parentNode!==t.host||t.link.parentNode!==t.host||t.l.parentNode!==t.host)&&(t.host.replaceChildren(t.title,t.text,t.link,t.l),this.#z(t));let i=t.u;if(i){if(i.root.ownerDocument!==this.#t){if(this.#R(t,"root-adopted"),this.#M)return;continue}i.root.parentNode!==t.l&&(t.l.replaceChildren(i.root),this.#z(t))}}}}},he=class{pointer;k=[];$;#t=1;#e=[];#i=new Map;#s;#r;#n;#o;#h;#a;#l=!1;constructor(t,e,i){this.#s=t,this.#r=e,this.#n=i.now,this.#o=i.wake,this.#h=i.i??(()=>{}),this.$=i.now(),this.#v(e,"resize",()=>this.#o());for(let t of i.events)this.#c(t);this.#a=i.coalesce??new Map}get reaction(){return this.k[0]}j(t,e,i="application"){let s=this.#n(),r=this.k.at(-1),n=this.#a.get(`${i}:${t}`),o=!(r?.name!==t||r.source!==i||!(!0===n||void 0!==n&&((t,e,i)=>{if(!t||!e||"object"!=typeof t||"object"!=typeof e||Array.isArray(t)||Array.isArray(e))return!1;let s=t,r=e;return r[i.sessionField]===s[i.sessionField]&&Number.isSafeInteger(r[i.revisionField])&&Number.isSafeInteger(s[i.revisionField])&&r[i.revisionField]>s[i.revisionField]})(r.payload,e,n)));if(!o&&this.k.length>=32)return this.#h("event.queue-full"),{accepted:!1,reason:"queue-full"};let h={id:o?r.id:this.#t++,source:i,name:t,at:s,...void 0===e?{}:{payload:e}};return o?this.k[this.k.length-1]=h:this.k.push(h),this.$=s,this.#o(),{accepted:!0,id:h.id,coalesced:o}}M(t){this.k[0]?.id===t&&this.k.shift()}retainEvent(t){this.#c(t);let e=!0;return()=>{e&&(e=!1,this.#d(t))}}O(t){if(t!==this.#l){this.#l=t;for(let e of this.#e)t&&e[3]&&!e[4]?(e[0].removeEventListener(e[1],e[2]),e[3]=!1):!t&&!e[3]&&(e[0].addEventListener(e[1],e[2],{passive:!0}),e[3]=!0);t&&(this.pointer=void 0)}}destroy(){for(let t of this.#e.splice(0))t[3]&&t[0].removeEventListener(t[1],t[2]);this.pointer=void 0,this.k.length=0,this.#i.clear()}#c(t){let e=this.#i.get(t);if(e){e[0]+=1;return}let i=[];this.#i.set(t,[1,i]);let s=(t,e,s,r=!1)=>i.push(this.#v(t,e,s,r));if("pointer.move"===t){s(this.#s,"pointerdown",t=>{("touch"===t.pointerType||"pen"===t.pointerType)&&this.#u(t)}),s(this.#s,"pointermove",t=>this.#u(t));let t=t=>{let e=t.pointerType;("touch"===e||"pen"===e)&&this.#f()};s(this.#s,"pointerup",t),s(this.#s,"pointercancel",t),s(this.#s,"pointerout",t=>{null===t.relatedTarget&&this.#f()}),s(this.#r,"blur",()=>this.#f())}else"pointer.click"===t?s(this.#s,"click",t=>this.#p("pointer.click",t)):"document.visibility"===t?s(this.#s,"visibilitychange",()=>this.j("document.visibility",{visible:!this.#s.hidden},"browser"),!0):"window.scroll"===t?s(this.#r,"scroll",t=>{this.#f(),this.#p("window.scroll",t)}):"window.focus"===t&&(s(this.#r,"focus",()=>this.j("window.focus",{focused:!0},"browser")),s(this.#r,"blur",()=>this.j("window.focus",{focused:!1},"browser")))}#d(t){let e=this.#i.get(t);if(e){if(e[0]>1){e[0]-=1;return}this.#i.delete(t);for(let t of e[1]){t[3]&&t[0].removeEventListener(t[1],t[2]);let e=this.#e.indexOf(t);e>=0&&this.#e.splice(e,1)}}}#f(){this.#l||this.pointer&&(this.pointer=void 0,this.$=this.#n(),this.#o())}#u(t){this.#l||(this.pointer={x:t.clientX,y:t.clientY},this.$=this.#n(),this.#o())}#p(t,e){if(this.#l||e.composedPath().some(t=>"hasAttribute"in t&&"function"==typeof t.hasAttribute&&t.hasAttribute("data-peekling-controls")))return;let i=e,s=Number.isFinite(i.clientX)&&Number.isFinite(i.clientY)?{x:i.clientX,y:i.clientY}:void 0;this.j(t,s,"browser")}#v(t,e,i,s=!1){t.addEventListener(e,i,{passive:!0});let r=[t,e,i,!0,s];return this.#e.push(r),r}},ae=class{ready;#t;#e;#i;#s;#r;#n;#o;#h;#a;#l;#c;#d={x:0,y:0};#f;#u={x:0,y:0};#p={x:0,y:0};#v={x:0,y:0};#y={x:0,y:0};#w=0;#b=!1;#g=!1;#m=!1;constructor(t){this.#o=t,this.#t=t.document,this.#c=t.label,this.#e=t.document.createElement("div"),this.#e.setAttribute("data-peekling-interaction",""),this.#i=this.#e.attachShadow({mode:"closed"}),this.#n=new Wt(t.document,this.#i,t.styles),this.#s=t.document.createElement("button"),this.#s.type="button",this.#s.className="peekling-character-hit",this.#s.setAttribute("aria-label",t.label),void 0!==t.expanded&&this.#s.setAttribute("aria-expanded",t.expanded+""),this.#s.toggleAttribute("data-peekling-draggable",t.draggable),this.#r=t.document.createElement("span"),this.#r.className="peekling-character-indicator",this.#r.setAttribute("aria-hidden","true"),this.#s.append(this.#r),this.#i.append(this.#s),this.ready=this.#n.ready.then(()=>{this.#m||(this.#h=this.#n.addRule(".peekling-character-hit"),this.#a=this.#n.addRule(".peekling-character-indicator"),this.#k())}),this.ready.catch(()=>{}),this.#s.addEventListener("click",this.#$),t.draggable&&(this.#s.addEventListener("pointerdown",this.#j),this.#s.addEventListener("pointermove",this.#x),this.#s.addEventListener("pointerup",this.#E),this.#s.addEventListener("pointercancel",this.#M)),this.updateIndicator(t.indicator),this.#z()}S(t,e,i=0){if(this.#m)return;this.#z(),this.#d={x:t.x,y:t.y-i};let s=this.#h;if(!s)return;let r=t.x-e.width/2,n=t.y-e.height/2-i;s.width=e.width+"px",s.height=e.height+"px",s.transform=`translate3d(${r}px,${n}px,0)`}N(t){this.#m||this.#e.toggleAttribute("hidden",t)}setExpanded(t){!this.#m&&this.#s.hasAttribute("aria-expanded")&&this.#s.setAttribute("aria-expanded",t+"")}updateIndicator(t){if(this.#m)return;this.#l=t??void 0,this.#k();let e=!(!t||!1===t.visible||!("count"!==t.kind||(t.count??0)>0));if(this.#r.hidden=!e,!e||!t){this.#r.textContent="",this.#s.setAttribute("aria-label",this.#c);return}let i=t.kind??"dot";this.#r.dataset.kind=i,this.#r.textContent="count"===i?Math.min(99,t.count??0)+"":"",this.#s.setAttribute("aria-label",`${this.#c}. ${t.label}`)}#k(){this.#a&&(this.#a.backgroundColor=this.#l?.color??"")}destroy(){this.#m||(this.#m=!0,this.#n.destroy(),this.#e.remove())}#$=()=>{this.#g?this.#g=!1:this.#o.onPress()};#j=t=>{if(!(this.#m||void 0!==this.#f||!t.isPrimary&&"mouse"!==t.pointerType||"mouse"===t.pointerType&&0!==t.button)){this.#f=t.pointerId,this.#u={x:t.clientX,y:t.clientY},this.#p={...this.#u},this.#v={...this.#d},this.#y={x:0,y:0},this.#w=t.timeStamp,this.#b=!1;try{this.#s.setPointerCapture(t.pointerId)}catch{}this.#o.onDragStart()}};#x=t=>{if(t.pointerId!==this.#f)return;let e=t.clientX-this.#u.x,i=t.clientY-this.#u.y;!this.#b&&Math.hypot(e,i)>=4&&(this.#b=!0);let s=Math.max(8,Math.min(100,t.timeStamp-this.#w)),r=1e3*(t.clientX-this.#p.x)/s,n=1e3*(t.clientY-this.#p.y)/s;this.#y={x:.65*r+.35*this.#y.x,y:.65*n+.35*this.#y.y},this.#p={x:t.clientX,y:t.clientY},this.#w=t.timeStamp,this.#o.onDragMove({x:this.#v.x+e,y:this.#v.y+i},this.#y)};#E=t=>{t.pointerId===this.#f&&this.#S(t,this.#b,this.#y)};#M=t=>{t.pointerId===this.#f&&this.#S(t,this.#b,{x:0,y:0},this.#p)};#S(t,e,i,s={x:t.clientX,y:t.clientY}){let r=this.#f;if(this.#f=void 0,void 0!==r)try{this.#s.releasePointerCapture(r)}catch{}this.#g=e,this.#o.onDragEnd(i,e,s)}#z(){if(!this.#m&&(t(this.#e,this.#t,"data-peekling-interaction"),this.#i.host!==this.#e||this.#s.getRootNode()!==this.#i))throw Error("interaction.root")}},le=["E","SE","S","SW","W","NW","N","NE"],ce=6e4,de=class{#t;#e;#i;#s;#r;#n;#o;#h=0;#a=[];#l=[];#c;#d=!1;constructor(t){this.#t=t.instanceId,this.#e=t.now,this.#i=t.logger,this.#s=t.messageSink,this.#r=t.context,this.#n=!0===t.debug,this.#o=t.console}emit(t){let e=this.#e();if(this.#a=this.#a.filter(t=>e-t<ce),this.#l=this.#l.filter(t=>e-t<ce),void 0!==this.#c&&e-this.#c>=ce&&(this.#c=void 0),!this.#d)return this.#a.length>=64?(void 0===this.#c&&(this.#c=e,this.#f({code:"diagnostics.rate-limited",severity:"warning",message:"Diagnostic output was rate limited",phase:"internal",metadata:{windowMs:ce,recordLimit:64,errorReserve:8}})),"error"!==t.severity||this.#l.length>=8?void 0:(this.#l.push(e),this.#f(t))):(this.#a.push(e),this.#f(t))}#f(t){let e={code:t.code,severity:t.severity,message:m(t.message),phase:t.phase,sequence:++this.#h,timestamp:Date.now(),instanceId:this.#t};t.overrideId&&(e.overrideId=t.overrideId),void 0!==t.eventId&&(e.eventId=t.eventId),t.metadata&&(e.metadata=t.metadata),this.#r&&(e.context=this.#r),this.#n&&t.cause&&(e.cause=(t=>t instanceof Error?{name:t.name.slice(0,80),message:t.message.slice(0,500),...t.stack?{stack:t.stack.slice(0,4e3)}:{}}:{name:"Error",message:(t+"").slice(0,500)})(t.cause)),this.#d=!0;try{try{this.#s?.(e.message)}catch{}try{this.#i?.(e)}catch{}}finally{this.#d=!1}return!this.#s&&!this.#i&&(!0===this.#o||void 0===this.#o&&"error"===e.severity)&&console.warn(`[Peekling] ${e.message}${"error"===e.severity?" (use peekling.js for details)":""}`),e}},fe=class extends Error{code;category;constructor(t,e,i,s){super(i,{cause:s}),this.name="PackLoadError",this.code=t,this.category=e}},ue=class extends Error{issues;issueCodes;constructor(t,e=[]){let i=t,s=t;super("pack:"+i.join(",")),this.name="PackValidationError",this.issues=i,this.issueCodes=e.length?e:s}},pe=/^[a-f0-9]{64}$/,ve=4096,ye=[137,80,78,71,13,10,26,10],we=4096,be=/^[a-z][a-z0-9._-]{0,63}$/,ge={peek:Object.freeze({url:"https://cdn.jsdelivr.net/npm/@peekling/pack-peek@0.1.1/character.json",sha256:"9a2e2a41e85f7c4b8d3487a3655db40872675bd9c0780e139a946eabdf71d75f"})},me=/^(?:motion|state|surface:[a-z][a-z0-9:-]{0,63})$/,ke=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/,$e=class extends TypeError{code;path;constructor(t,e,i){super(t),this.name="PlanCompileError",this.code=t,this.path=""}},je=class{#t;#e=(()=>({ordering:new Map,sessions:new Map}))();#i=new Map;#s=new Map;#r=new WeakMap;#n=new WeakMap;#o;#h;#a;#l;#c=[];#d=0;#f;#u=[];constructor(t){this.#t=t}get plan(){return this.#t}get lastEventStatus(){return this.#f}get lastEventRejections(){return this.#u}evaluate(t){this.#f=void 0,this.#u=[];let e=t.reaction;if(this.#m(t.now),e){let i=((t,e,i)=>{function s(t,e=[],i=[],s=[]){return{status:t,rules:e,effects:i,rejectedSurfaces:ft([...s])}}let r;try{r=p(i.payload)}catch{return s("invalid")}let n="browser"===i.source&&"section.visibility"===i.name?(t=>{if(!t||"object"!=typeof t||Array.isArray(t))return;let e=t;return 3!==Object.keys(e).length||"string"!=typeof e.selector||"number"!=typeof e.A||"number"!=typeof e.ratio||e.A<0||e.A>1||e.ratio<0||e.ratio>1?void 0:e})(r):void 0;if("browser"===i.source&&"section.visibility"===i.name&&!n)return s("invalid");let o=t.rules.filter(t=>t.when.source===i.source&&t.when.event===i.name&&(!n||((t,e)=>{if("browser"!==t.source||"section.visibility"!==t.event||t.selector!==e.selector||"while-visible"===t.phase)return!1;let i=t.threshold??.25;return"enter"===t.phase?e.A<i&&e.ratio>=i:e.A>=i&&e.ratio<i})(t.when,n)));if(!o.length)return s("unmatched");if(!o.some(t=>Y(t.effect).some(t=>t.ordering)))return s("matched",o,o.map(t=>st(t.effect,r)));let h=new Map;for(let t of o)for(let e of Y(t.effect)){if(!e.ordering)continue;let t=tt(e),i=h.get(t)??[];i.push(e),h.set(t,i)}let a=[],l=new Set;for(let[t,i]of h){let s={ordering:new Map},n=rt(i,e,s,r);"matched"!==n?(l.add(t),a.push({channel:t,status:n})):ot(e,s,t)}let c=[],d=[];for(let[t,e]of o.entries()){let t=st(e.effect,r),i=nt(t,t.channels.filter(t=>!l.has(t)));i&&(c.push(e),d.push(i))}return s(d.length?"matched":a[0]?.status??"matched",c,d,a)})(this.#t,this.#e,{source:e.source,name:e.name,...void 0===e.payload?{}:{payload:e.payload}});if(this.#f=i.status,this.#u=i.rejectedSurfaces,"invalid"!==i.status&&"stale"!==i.status&&"closed"!==i.status&&this.#m(t.now,e.source,e.name),"matched"===i.status){let e=new Set;i.effects.forEach((s,r)=>{let n=s.channels.filter(t=>!e.has(t));if(n.length){for(let t of n)e.add(t);if(s.until)this.#g(nt(s,n),t.now);else{for(let t of n)("motion"===t||"state"===t)&&this.#i.set(t,[i.rules[r].effect,s]);for(let t of s.surfaces)n.includes(t.channel)&&this.#b(t)}}})}}let i=new Map;for(let t of this.#c)for(let e of t.effect.channels)i.set(e,t.effect);for(let e of this.#t.rules){let s=this.#w(e,t);for(let t of["motion","state"]){if(i.has(t))continue;let r=this.#i.get(t),n=s&&e.effect.channels.includes(t)?e.effect:r?.[0]===e.effect?r[1]:void 0;n&&i.set(t,n)}}for(let t of this.#t.baseline.channels)i.has(t)||i.set(t,this.#t.baseline);let s={},r=i.get("state")?.state;"state"===r?.kind&&(s.state=r.name),"capability"===r?.kind&&(s.capability=r.name);let n=i.get("motion"),o=n?.motion,h=()=>{if("locomotion"!==s.capability)return;delete s.capability;let t=this.#p();!s.state&&t&&(s.state=t)};if("jump-to"!==o?.type&&(this.#o=void 0,this.#h=void 0),"svg-path"!==o?.type&&(this.#a=void 0,this.#l=void 0),"horizontal-patrol"===o?.type&&t.t){let[e,i]=pt(o,t,this.#r.get(n)??!0);this.#r.set(n,e),i&&(s.motion=i)}else if("viewport-traverse"===o?.type&&t.t){let[e,i]=((t,e,i)=>{let s=t.edgeInset??0,r=e.t.height/2,n=Math.min(e.viewport.width/2,e.t.width/2+s),o=Math.max(n,e.viewport.width-n),h=Math.min(e.viewport.height/2,r+s),a=Math.max(h,e.viewport.height-r-s),l=[{x:n,y:a},{x:o,y:a},{x:o,y:h},{x:n,y:h}];void 0===i&&(i=l.reduce((t,i,s)=>Math.hypot(i.x-e.position.x,i.y-e.position.y)<Math.hypot(l[t].x-e.position.x,l[t].y-e.position.y)?s:t,0));let c=l[i],d=wt(t,e.position,c.x,c.y);d||(c=l[i=(i+(!1===t.clockwise?-1:1)+l.length)%l.length],d=wt(t,e.position,c.x,c.y));return[i,d]})(o,t,this.#n.get(n));this.#n.set(n,e),i&&(s.motion=i)}else if("follow-pointer"===o?.type){let e=t.pointer?wt(o,t.position,t.pointer.x,t.pointer.y,o.arrivalRadius,t):void 0;e?s.motion=e:h()}else if("move-to"===o?.type){let e=wt(o,t.position,o.x,o.y,o.arrivalRadius,t);e?s.motion=e:h()}else if("move-to-target"===o?.type){let e=t.targets?.[o.target],i=e&&t.t?((t,e="center",i)=>{let s={x:t.left+t.width/2,y:t.top+t.height/2};switch(e){case"top":return{x:s.x,y:t.top-i.height/2};case"right":return{x:t.right+i.width/2,y:s.y};case"bottom":return{x:s.x,y:t.bottom+i.height/2};case"left":return{x:t.left-i.width/2,y:s.y};default:return s}})(e,o.anchor,t.t):void 0,r=i?wt(o,t.position,i.x,i.y,o.arrivalRadius,t):void 0;r?s.motion={...r,trackTarget:!0}:h()}else if("jump-to"===o?.type){let e=this.#v(n,o,t);e?s.motion=e:h()}else if("svg-path"===o?.type){let e=this.#y(n,o,t);e?s.motion=e:h()}let a=new Map;for(let t of this.#t.baseline.surfaces)a.set(t.channel,{surface:t,version:0});for(let t of this.#s.values())a.set(t.surface.channel,t);for(let t of this.#c)for(let e of t.effect.surfaces)a.set(e.channel,{surface:e,version:t.version});return a.size&&(s.surfaces=Object.freeze([...a.values()].map(({surface:t,version:e})=>Object.freeze({id:t.id,channel:t.channel,contentId:t.contentId,...void 0===t.data?{}:{data:t.data},key:`${t.channel}:${e}`})))),e&&"matched"===this.#f&&(s.T=e.id),s}reset(){this.#i.clear(),this.#s.clear(),this.#c=[],this.#r=new WeakMap,this.#n=new WeakMap,this.#o=void 0,this.#h=void 0,this.#a=void 0,this.#l=void 0,this.#e.ordering.clear(),this.#e.sessions.clear(),this.#f=void 0,this.#u=[]}P(){return this.#c.reduce((t,e)=>Number.isFinite(e.I)?void 0===t?e.I:Math.min(t,e.I):t,void 0)}D(t){t&&(this.#c=this.#c.map(e=>({...e,I:e.I+t})))}#p(){let t=this.#t.baseline.state;return"state"===t?.kind?t.name:void 0}#v(t,e,i){(this.#o!==t||!this.#h)&&(this.#o=t,this.#h={R:i.now,from:{...i.position}});let s=Math.max(0,Math.min(1,(i.now-this.#h.R)/(e.duration??800))),r=vt(e,i),n={x:this.#h.from.x+(r.x-this.#h.from.x)*s,y:this.#h.from.y+(r.y-this.#h.from.y)*s},o=yt(i.position,n,0===s||1===s?0:Math.sin(Math.PI*s)*(e.height??i.t?.height??32));if(s<1||o.maxDistance)return o}#y(t,e,i){let s=i.samplePath;if(!s)return;let r=s(e.path,0);if(!r)return;(this.#a!==t||!this.#l)&&(this.#a=t,this.#l={R:i.now,offset:!1===e.relative?{x:0,y:0}:{x:i.position.x-r.x,y:i.position.y-r.y}});let n=e.duration??4e3,o=Math.max(0,i.now-this.#l.R),h=!0!==e.loop&&o>=n,a=s(e.path,e.loop?o%n/n:Math.min(1,o/n));if(!a)return;let l={x:a.x+this.#l.offset.x,y:a.y+this.#l.offset.y},c=yt(i.position,vt(l,i));return!h||c.maxDistance?c:void 0}#w(t,e){let i=t.when;if("browser"!==i.source)return!1;if("pointer.move"===i.event){if(!e.pointer)return!1;let i=t.effect.motion;return!i||"follow-pointer"!==i.type||!!wt(i,e.position,e.pointer.x,e.pointer.y,i.arrivalRadius,e)}if("section.visibility"!==i.event)return!1;let s=e.sections?.[i.selector],r=i.threshold??.25;return"while-visible"===i.phase&&(s?.ratio??0)>=r}#b(t){let e=this.#s.get(t.channel);if("ignore"===t.disposition)return;let i="update"===t.disposition&&e?{...t,contentId:e.surface.contentId}:t;this.#s.set(t.channel,{surface:Object.freeze(i),version:++this.#d})}#g(t,e){let i=t.until,s=e+("duration"===i.type?i.ms:i.timeout??36e5);Number.isFinite(s)&&(this.#c=this.#c.filter(e=>!e.effect.channels.some(e=>t.channels.includes(e))),this.#c.push({effect:t,I:s,version:++this.#d}))}#m(t,e,i){this.#c=this.#c.filter(s=>{if(t>=s.I)return!1;let r=s.effect.until;return!(void 0!==e&&void 0!==i&&"event"===r.type&&(t=>f(t)?"browser":"application")(r.name)===e&&r.name===i)})}},xe=!1,Ee=["format","character","pack","packUrl","atlasUrl","styles","plan","preset","targets","interaction","indicator","content","bindings","theme","accessibility","diagnostics","name","scale","position","density","maxDensity","onDiagnostic","logger","document","window"],Me=class extends TypeError{issues;constructor(t,e,i){super(`${e}: ${i}`),this.name="PeeklingPreflightError",this.issues=[{code:t,path:e,message:i}]}},Oe=36e5,Se=class{#t;#e;#i;#s=[];#r=1;constructor(t,e,i=()=>{}){this.#t=t,this.#e=e,this.#i=i}add(t){let e,i,s=this.#n();try{e=(t=>{let e=l(t);if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("override.object");if(Ot(e,["effect","until","mode"]),!e.effect)throw new TypeError("override.effect");if(void 0!==e.mode&&"reject"!==e.mode&&"replace"!==e.mode)throw new TypeError("override.mode");let i=void 0===e.until?Object.freeze({type:"manual"}):e.until;if(!i||"object"!=typeof i||Array.isArray(i))throw new TypeError("override.until");if("duration"===i.type)Ot(i,["type","ms"]),Mt(i.ms);else if("event"===i.type){if(Ot(i,["type","name","timeout"]),"string"!=typeof i.name||!Kt.test(i.name))throw new TypeError("override.until.name");if(u(i.name))throw new TypeError("override.until.name");void 0!==i.timeout&&Mt(i.timeout)}else{if("manual"!==i.type)throw new TypeError("override.until.type");Ot(i,["type","maxMs"]),void 0!==i.maxMs&&Mt(i.maxMs)}return Object.freeze({effect:e.effect,until:i,...void 0===e.mode?{}:{mode:e.mode}})})(t),i=((t,e={})=>{let i=l(t),s=G(i,0,e,!1);s.until&&ut("invalid-override-lifetime");for(let[t,e]of Y(i).entries())void 0!==e.disposition&&ut("invalid-override-disposition"),void 0!==e.ordering&&ut("invalid-override-ordering");return s})(e.effect,this.#t)}catch(t){return this.#i("override.invalid"),s.finish("rejected"),s.handle}let r=this.#s.filter(t=>t.effect.channels.some(t=>i.channels.includes(t)));if(r.length&&"replace"!==e.mode)return this.#i("override.conflict"),s.finish("conflict"),s.handle;for(let t of r)this.#o(t,"replaced");if(this.#s.length>=8)return this.#i("override.limit"),s.finish("overflow"),s.handle;let n=this.#e();return Object.assign(s,{input:e,effect:i,R:n,I:n+Et(e),status:"active"}),this.#s.push(s),s.handle}reject(t="rejected"){let e=this.#n();return e.finish(t),e.handle}browserCompletionFor(t){let e=this.#s.find(e=>e.id===t)?.input.until;return"event"===e?.type?f(e.name):void 0}C(t,e="application"){for(let i of[...this.#s])"event"===i.input.until?.type&&i.input.until.name===t&&xt(i.input.until.name)===e&&this.#o(i,"event");return!1}compose(t,e){let i=this.#e();for(let t of[...this.#s])i>=t.I&&this.#o(t,"timeout");let s={...t},r=new Map;for(let e of t.surfaces??[])r.set(e.channel,e);for(let t of this.#s){let i=t.effect.state;"state"===i?.kind?(s.state=i.name,delete s.capability):"capability"===i?.kind&&(s.capability=i.name,delete s.state);let n=t.effect.motion;if("horizontal-patrol"===n?.type){let[i,r]=pt(n,e,t.U);t.U=i,r?s.motion=r:delete s.motion}else if("follow-pointer"===n?.type&&e.pointer&&e.position){let t=wt(n,e.position,e.pointer.x,e.pointer.y,n.arrivalRadius,e);t?s.motion=t:delete s.motion}for(let e of t.effect.surfaces)r.set(e.channel,Object.freeze({id:e.id,channel:e.channel,contentId:e.contentId,...void 0===e.data?{}:{data:e.data},key:t.id}))}return s.surfaces=Object.freeze([...r.values()]),s}P(){return this.#s.reduce((t,e)=>void 0===t?e.I:Math.min(t,e.I),void 0)}D(t){for(let e of this.#s)e.R+=t,e.I+=t}clear(t){for(let e of[...this.#s])this.#o(e,t)}#n(){let t,e="override:"+this.#r++,i=!1,s=new Promise(e=>{t=e}),r={},n=Object.freeze({id:e,get status(){return r.status},finished:s,cancel:()=>{"active"===r.status&&this.#o(r,"cancelled")}});return Object.assign(r,{id:e,effect:Object.freeze({channels:[],surfaces:[]}),input:Object.freeze({effect:Object.freeze({channels:[]}),until:Object.freeze({type:"manual"})}),R:0,I:0,status:"rejected",U:!0,handle:n,finish(s){i||(i=!0,r.status=(t=>"rejected"===t||"conflict"===t||"overflow"===t)(s)?"rejected":"finished",t({id:e,reason:s}))}}),r}#o(t,e){let i=this.#s.indexOf(t);i>=0&&this.#s.splice(i,1),t.finish(e)}},Ne=class{host;ready;#t;#e;#i;#s;#r;#n;#o;#h=0;#a=0;#l="";#c=0;#d=-1;#f=!1;constructor(t,e,i,s,r){this.#t=t,this.#n=e,this.#o=s,this.host=t.createElement("div"),this.host.setAttribute("aria-hidden","true"),this.host.setAttribute("data-peekling-host",""),this.#e=this.host.attachShadow({mode:"closed"}),this.#s=new Wt(t,this.#e,r),this.#i=t.createElement("i"),this.#i.className="sprite",this.#e.append(this.#i),this.ready=this.#s.ready.then(()=>{this.#f||(this.#r=this.#s.addRule(".sprite"),this.#u(e,i))}),this.ready.catch(()=>{}),this.#p()}L(t,e){this.#f||this.#u(t,e)}#u(t,e){this.#n=t;let i=this.#r;if(!i)throw Error("renderer.styles");this.#h=t.atlas.logicalWidth??t.atlas.cellWidth,this.#a=t.atlas.logicalHeight??t.atlas.cellHeight,i.width=this.#h+"px",i.height=this.#a+"px",i.backgroundSize=`${t.atlas.columns*this.#h}px ${t.atlas.rows*this.#a}px`,i.backgroundImage=`url(${JSON.stringify(e)})`,i.imageRendering=1===(t.atlas.density??1)?"pixelated":"auto",this.#d=-1}N(t){this.#f||this.host.toggleAttribute("hidden",t)}W(t){if(this.#f)return;let e=this.#n.states[this.#l];if(!e||e.frames.length<2)return;let i=Math.max(0,t-this.#c);if(e.durations?.length===e.frames.length){let t=k(e);if(!e.loop&&i>=t-e.durations.at(-1))return;let s=e.loop?i%t:i,r=0;for(let t of e.durations)if(r+=t,r>s)return r-s;return e.loop?e.durations[0]:void 0}let s=1e3/(e.fps??1);return!e.loop&&i>=s*(e.frames.length-1)?void 0:s-(i%s||0)}S(t,e,i,s=1,r=0){if(this.#f||(this.#p(),this.#f))return;let n=this.#n.states[t];if(!n)throw Error("renderer.state");t!==this.#l&&(this.#l=t,this.#c=e,this.#d=-1,this.host.setAttribute("data-peekling-state",t));let o=((t,e)=>{if(1===t.frames.length)return t.frames[0];if(t.durations?.length===t.frames.length){let i=k(t),s=t.loop?e%i:Math.min(e,i-1),r=0;for(let e=0;e<t.frames.length;e++)if(r+=t.durations[e],s<r)return t.frames[e];return t.frames.at(-1)}let i=Math.floor(e*(t.fps??1)/1e3);return t.frames[t.loop?i%t.frames.length:Math.min(i,t.frames.length-1)]})(n,e-this.#c);if(o!==this.#d){let t=o%this.#n.atlas.columns,e=Math.floor(o/this.#n.atlas.columns);if(!this.#r)throw Error("renderer.styles");this.#r.backgroundPosition=`${-t*this.#h}px ${-e*this.#a}px`,this.#d=o,this.host.setAttribute("data-peekling-frame",o+"")}let h=this.#h*this.#o,a=this.#a*this.#o,l=St(i.x-h/2,s),c=St(i.y-a/2-r,s),d=l+"",f=c+"";if(this.host.getAttribute("data-peekling-x")!==d&&this.host.setAttribute("data-peekling-x",d),this.host.getAttribute("data-peekling-y")!==f&&this.host.setAttribute("data-peekling-y",f),!this.#r)throw Error("renderer.styles");let u=`translate3d(${l}px,${c}px,0) scale(${this.#o})`;this.#r.transform!==u&&(this.#r.transform=u)}destroy(){this.#f||(this.#f=!0,this.#s.destroy(),this.host.remove())}#p(){if(!this.#f){if(t(this.host,this.#t,"data-peekling-host"),this.#e.host!==this.host||this.#i.getRootNode()!==this.#e)throw Error("renderer.root");"true"!==this.host.getAttribute("aria-hidden")&&this.host.setAttribute("aria-hidden","true")}}},Ae=t=>new Ne(t.document,t.pack,t.atlasUrl,t.scale,t.styles),ze={click:["waving","happy","alert"],"double-click":["jumping","happy","waving"],"context-click":["alert","waving","idle"],scroll:["alert","waving","idle"],success:["success","happy","jumping","waving"],happy:["happy","success","waving"],error:["error","failed","alert"],sleep:["sleep","idle"]},Te=class{#t;#e;#i=new Map;#s=new Map;#r;#n;#o;#h;#a=!1;#l=!1;#c=!1;#d;#f=0;constructor(t,e,i,s,r,n){this.#t=t,this.#e=e,this.#o=r,this.#h=n;let o=i.map(t=>[t,this.#p(t)]),h=e.IntersectionObserver;h&&(this.#r=new h(t=>{let e=!1;for(let i of t)for(let t of this.#s.get(i.target)??[]){let s=this.#i.get(t);s&&(e=this.#y(t,s,i.isIntersecting?i.intersectionRatio:0)||e)}e&&r()},{threshold:[...s]}));let a=e.MutationObserver;a&&(this.#n=new a(t=>{if(this.#a||this.#l||this.#f||this.#c||t.length>0&&t.every(Nt))return;let e=!1;for(let t of this.#i.values())if(!t[0]?.isConnected){e=!0;break}e&&this.#b()}),this.#n.observe(t.documentElement,{childList:!0,subtree:!0}));for(let[t,e]of o)this.#i.set(t,[void 0,0,0]),this.#u(t,e)}H(){if(this.#d)throw this.#d;if(this.#c&&(this.#c=!1,this.#m(),this.#d))throw this.#d;let t=Object.create(null);for(let[e,i]of this.#i)t[e]={ratio:i[2],A:i[1]};return t}O(t){if(!this.#l&&t!==this.#a){if(this.#a=t,t){this.#g(),this.#c=!1,this.#r?.disconnect(),this.#n?.disconnect();return}if(this.#n?.observe(this.#t.documentElement,{childList:!0,subtree:!0}),this.#c=!1,this.#m())for(let t of this.#s.keys())this.#r?.observe(t)}}destroy(){this.#l||(this.#l=!0,this.#g(),this.#c=!1,this.#r?.disconnect(),this.#n?.disconnect(),this.#s.clear(),this.#i.clear())}#u(t,e=this.#p(t)){let i=this.#i.get(t);if(!e){this.#v(t,i),this.#y(t,i,0);return}if(e===i[0]&&e.isConnected)return;this.#v(t,i),i[0]=e;let s=this.#s.get(e)??new Set;s.size||this.#r?.observe(e),s.add(t),this.#s.set(e,s)}#p(t){try{return this.#t.querySelector(t)}catch{throw new TypeError("section.selector")}}#v(t,e){let i=e[0];if(e[0]=void 0,!i)return;let s=this.#s.get(i);s?.delete(t),s?.size||(this.#r?.unobserve(i),this.#s.delete(i))}#y(t,e,i){let s=e[2];return i!==s&&(e[1]=s,e[2]=i,this.#h?.({selector:t,A:s,ratio:i}),!0)}#w(){for(let[t,e]of this.#i)e[0]?.isConnected||this.#u(t)}#b(){this.#f||this.#a||this.#l||(this.#f=this.#e.setTimeout(()=>{this.#f=0,!(this.#a||this.#l||this.#d||this.#c)&&(this.#c=!0,this.#o())},250))}#g(){this.#f&&this.#e.clearTimeout(this.#f),this.#f=0}#m(){if(this.#d)return!1;try{return this.#w(),!0}catch(t){return this.#d=t instanceof Error?t:Error("section.refresh"),this.#r?.disconnect(),this.#n?.disconnect(),this.#o(),!1}}},Pe=class{#t;#e=new Map;constructor(t){this.#t=t}validate(t){return void 0!==this.#i(t)}sample(t,e){let i=this.#i(t);if(!i)return;let s=Math.max(0,Math.min(1,e));try{let t=i.element.getPointAtLength(i.length*s);return Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:t.x,y:t.y}:void 0}catch{return}}#i(t){let e=this.#e.get(t);if(e)return e;if(this.#e.size>=16)return;let i=this.#t.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",t);try{let e=i.getTotalLength();if(!Number.isFinite(e)||e<=0)return;let s=Object.freeze({element:i,length:e});return this.#e.set(t,s),s}catch{return}}},Ie=class{#t;#e;#i;#s=new Map;#r;#n;#o;#h=Object.freeze({});#a=!0;#l=!1;constructor(t,e,i,s){this.#t=t,this.#e=e,this.#i=i,this.#r=s;let r=e;this.#n=r.ResizeObserver?new r.ResizeObserver(()=>this.refresh()):void 0,this.#o=r.MutationObserver?new r.MutationObserver(()=>this.refresh()):void 0,this.#o?.observe(t.documentElement,{attributes:!0,attributeFilter:["class","id"],childList:!0,subtree:!0}),e.addEventListener("resize",this.#c,{passive:!0}),e.addEventListener("scroll",this.#c,{capture:!0,passive:!0})}H(t=!1){if(this.#l)return Object.freeze({});if(t&&(this.#a=!0),!this.#a)return this.#h;let e=Object.create(null);for(let[t,i]of Object.entries(this.#i)){let s=this.#s.get(t);if(s?.isConnected||(s&&this.#n?.unobserve(s),s=this.#t.querySelector(i),s?(this.#s.set(t,s),this.#n?.observe(s)):this.#s.delete(t)),!s)continue;let r=s.getBoundingClientRect();!Number.isFinite(r.left)||!Number.isFinite(r.top)||!Number.isFinite(r.width)||!Number.isFinite(r.height)||(e[t]=Object.freeze({left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height}))}return this.#h=Object.freeze(e),this.#a=!1,this.#h}contains(t,e,i=0){let s=this.H(!0)[t];return!!(s&&e.x>=s.left-i&&e.x<=s.right+i&&e.y>=s.top-i&&e.y<=s.bottom+i)}refresh=()=>{this.#l||(this.#a=!0,this.#r())};destroy(){this.#l||(this.#l=!0,this.#n?.disconnect(),this.#o?.disconnect(),this.#e.removeEventListener("resize",this.#c),this.#e.removeEventListener("scroll",this.#c,!0),this.#s.clear())}#c=()=>this.refresh()},De="peekling:site-preference",Re="peekling:hidden-session",Ce=[["10 minutes","10-minutes"],["1 hour","1-hour"],["Until tomorrow","until-tomorrow"],["Until I return","session"],["Forever on this site","forever"]],Ue=new WeakMap,Le=class{ready;#t;#e;#i=new Set;#s=[];#r=[];#n;#o;#h;#a;#l;#c;#d;#f;#u=0;#p=0;#v=!1;#y=!1;constructor(t,e,i){this.#t=t,this.#e=e;let s=At(e);this.#f=s[0],this.#n=t.createElement("div"),this.#n.dataset.peeklingControls="",this.#o=this.#n.attachShadow({mode:"closed"}),this.#c=`${i.url}\n${i.integrity??""}`,this.#d=i.integrity,this.#l=new Wt(t,this.#o,i),this.ready=this.#l.ready,this.ready.catch(()=>{}),this.#a=t.createElement("button"),this.#a.className="peekling-visibility-trigger",this.#a.type="button",this.#a.setAttribute("aria-label","Open Peekling visibility controls"),this.#a.textContent="🐾",this.#h=t.createElement("section"),this.#h.className="peekling-visibility-panel",this.#h.hidden=!0,this.#h.setAttribute("role","dialog"),this.#h.setAttribute("aria-label","Let Peekling rest");let r=t.createElement("h2");r.textContent="Let Peekling rest?",this.#h.append(r);for(let[e,i]of Ce){let s=t.createElement("button");s.className="peekling-visibility-option",s.type="button",s.textContent=e,s.addEventListener("click",()=>this.hide(i)),this.#h.append(s)}this.#o.append(this.#a,this.#h),this.#M(),this.#x(e,"storage",()=>this.refresh(),this.#s),this.#j(s[0],!1),this.#k(s[1])}#w(){if(!this.#r.length){this.#x(this.#t,"pointermove",t=>{"touch"===t.pointerType||"pen"===t.pointerType||this.#g(t.clientX,t.clientY)},this.#r),this.#x(this.#t,"pointerdown",t=>{let e=t;this.#v&&!this.#n.contains(t.target)&&this.close(),("touch"===e.pointerType||"pen"===e.pointerType)&&this.#g(e.clientX,e.clientY)},this.#r);for(let t of["pointerup","pointercancel","pointerout"])this.#x(this.#t,t,e=>{("pointerout"!==t||null===e.relatedTarget)&&this.#m()},this.#r);this.#x(this.#t,"keydown",t=>{"Escape"===t.key&&this.close(!0)},this.#r);this.#x(this.#a,"click",()=>this.open(!0),this.#r)}}#b(){this.#m(),this.#E(this.#r)}register(t){return this.#i.add(t),t(this.#f),()=>{this.#i.delete(t),this.#i.size||this.destroy()}}assertStyles(t){if(`${t.url}\n${t.integrity??""}`!==this.#c&&(!t.integrity||t.integrity!==this.#d))throw new TypeError("visibility.styles-conflict")}isHidden(){return this.#f}hide(t){let e=zt(this.#e,t);this.#$(!0),this.#k(e),this.close()}show(){Tt(this.#e),this.refresh()}refresh(){try{this.#M()}catch{let t=[...this.#i];this.destroy();for(let e of t)e(null);return}let t=At(this.#e);this.#$(t[0]),this.#k(t[1])}open(t=!1){this.#f||(this.#m(),this.#v=!0,this.#n.setAttribute("data-open",""),this.#h.hidden=!1,t&&this.#h.querySelector("button")?.focus())}close(t=!1){this.#v&&(this.#v=!1,this.#n.removeAttribute("data-open"),this.#h.hidden=!0,t&&this.#a.focus())}destroy(){this.#y||(this.#y=!0,this.#b(),this.#k(),this.#E(this.#s),this.#l.destroy(),this.#n.remove(),this.#i.clear(),Ue.delete(this.#t))}#g(t,e){this.#f||this.#v||t<this.#e.innerWidth-64||e<this.#e.innerHeight-64?this.#m():this.#u||(this.#u=this.#e.setTimeout(()=>this.open(),1e3))}#m(){this.#u&&this.#e.clearTimeout(this.#u),this.#u=0}#k(t){(this.#p&&this.#e.clearTimeout(this.#p),this.#p=0,void 0===t||this.#y)||(this.#p=this.#e.setTimeout(()=>{this.#p=0,this.refresh()},Math.max(0,Math.min(t-Date.now(),2147e6))))}#$(t){t!==this.#f&&this.#j(t,!0)}#j(t,e){if(this.#f=t,this.#n.toggleAttribute("data-hidden",t),this.#a.hidden=t,t?this.#b():this.#w(),e)for(let e of this.#i)e(t)}#x(t,e,i,s){t.addEventListener(e,i,{passive:!0}),s.push([t,e,i])}#E(t){for(let[e,i,s]of t.splice(0))e.removeEventListener(i,s)}#M(){if(t(this.#n,this.#t,"data-peekling-controls"),this.#o.host!==this.#n||this.#a.getRootNode()!==this.#o||this.#h.getRootNode()!==this.#o)throw Error("visibility.root")}},We=Object.freeze([]),He=class t{static hatch(e,i=Ae){return new t((t=>{if(void 0===t)return{};if("string"==typeof t)return{character:t};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("options.input");return t})(e),i)}Z(t){return!this.#e&&(bt(t)?(this.#C="string"==typeof t?t:!0===t?this.#s?.content.displayName??"":void 0,this.#s&&this.#C&&!this.#n?this.#W().ready.then(()=>this.#H(),()=>{this.#e||(this.#Z(),this.#F("failed"))}):this.#H(),!0):(this.#_("config.invalid-name","warning","config"),!0))}ready;finished;#t;#e=!1;#i=new AbortController;#s;#r;#n;#o;#h;#a;#l;#c=0;#d=0;#f=0;#u=0;#p=0;#v=0;#y="";#w={x:0,y:0};#b=0;#g=!1;#m;#k;#$;#j;#x;#E=!1;#M=0;#S;#z;#P;#A;#T;#I=4;#C;#R;#D;#U;#N;#L;#O;#V;#q;#J;#K;#Q;#X=0;#B=!1;#G=!1;#Y=!1;#tt;#et;#it=!1;#st=!1;#rt={x:0,y:0};#nt=0;constructor(t={},n=Ae){let o=(t=d(t)).document??globalThis.document,h=t.window??globalThis.window;if(!o||!h)throw Error("browser.context");this.#R=o,this.#D=h,this.#tt=new Pe(o),this.#L=t,this.#et=t.indicator,this.#Q=n,this.#O=h.performance?.now?.bind(h.performance)??Date.now,this.#q=`instance:${Math.floor(this.#O())}:${Math.random().toString(36).slice(2,8)}`,this.#J=new de({instanceId:this.#q,now:this.#O,...t.logger?{logger:t.logger}:{},...t.onDiagnostic?{messageSink:t.onDiagnostic}:{},...t.diagnostics?.context?{context:t.diagnostics.context}:{},...t.diagnostics?.debug?{debug:!0}:{},...void 0===t.diagnostics?.console?{}:{console:t.diagnostics.console}});let[a,l]=((t,n)=>{let o,h=((t,i)=>{mt(t,Ee,"$"),void 0===t.character&&void 0===t.pack&&void 0===t.packUrl&&$t("manifest.selection","$"),void 0!==t.format&&1!==t.format&&$t("unsupported-format","$.format"),void 0!==t.plan&&void 0!==t.preset&&$t("incompatible-behavior","$.preset"),void 0!==t.preset&&!["companion","still","bottom-patrol","viewport-roam"].includes(t.preset)&&$t("invalid-preset","$.preset"),void 0!==t.character&&("string"==typeof t.character&&Jt.test(t.character)?void 0===t.pack&&void 0===t.packUrl&&!Z(t.character)&&$t("character.unknown","$.character"):$t("invalid-character","$.character")),void 0!==t.scale&&(!Number.isInteger(t.scale)||t.scale<1||t.scale>4)&&$t("out-of-range","$.scale");for(let e of["density","maxDensity"]){let i=t[e];void 0!==i&&1!==i&&2!==i&&4!==i&&$t("invalid-density","$."+e)}void 0!==t.density&&void 0!==t.maxDensity&&t.density>t.maxDensity&&$t("incompatible-density","$.density"),bt(t.name)||$t("invalid-name","$.name");for(let e of["packUrl","atlasUrl"]){let s=t[e];void 0!==s&&!r(s,i)&&$t("invalid-url","$."+e)}let n=t.position;if(void 0!==n&&"bottom-left"!==n&&"bottom-right"!==n&&"center"!==n){let t=gt(n,"invalid-position","$.position",["x","y"]);("number"!=typeof t.x||!Number.isFinite(t.x)||Math.abs(t.x)>1e5||"number"!=typeof t.y||!Number.isFinite(t.y)||Math.abs(t.y)>1e5)&&$t("invalid-position","$.position")}let o,h=t.styles;if(void 0!==h){let t=gt(h,"invalid-styles","$.styles",["url","integrity"]);("string"!=typeof t.url||!r(t.url,i))&&$t("invalid-styles-url","$.styles.url"),e(t.integrity)||$t("invalid-styles-integrity","$.styles.integrity")}try{o=((t,e)=>{if(void 0===t)return{};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("content.object");let i=Object.entries(t);if(i.length>32)throw new TypeError("content.limit");let s={};for(let[t,r]of i){if(!Jt.test(t))throw new TypeError(Lt("content.id"));if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError(Lt("content.item"));y(r,qt);let i={};for(let t of qt){let s=r[t];void 0!==s&&(i[t]=v(s,e))}if(!Object.keys(i).length)throw new TypeError(Lt("content.empty"));s[t]=i}return s})(t.content,i)}catch(t){$t("invalid-content","$.content")}((t,e)=>{let i;if(void 0!==t){let e=gt(t,"invalid-bindings","$.bindings",["mounts"]);if(void 0!==e.mounts){let t=gt(e.mounts,"invalid-bindings","$.bindings.mounts",void 0);{i=t;let e=Object.entries(t);e.length>64&&$t("binding-limit","$.bindings.mounts");for(let[t,i]of e)(!Jt.test(t)||"function"!=typeof i)&&$t("invalid-binding","$.bindings.mounts."+t)}}}for(let[t,s]of Object.entries(e))for(let e of qt){let r=s[e];r&&"string"!=typeof r&&r.mountId&&!Object.hasOwn(i??{},r.mountId)&&$t("missing-binding",`$.content.${t}.${e}.mountId`)}})(t.bindings,o),(t=>{if(void 0===t)return;let e=gt(t,"invalid-targets","$.targets",void 0),i=Object.entries(e);i.length>16&&$t("target-limit","$.targets");for(let[t,e]of i)Jt.test(t)||$t("invalid-target","$.targets."+t),("string"!=typeof e||e.length<1||e.length>256||/[\0\r\n]/.test(e))&&$t("invalid-target-selector","$.targets."+t)})(t.targets),((t,e)=>{if(void 0===t||!1===t)return;let i=gt(t,"invalid-interaction","$.interaction",["press","pressEvent","drag","throw","dragState","riseState","fallState","landState","gravity","maxThrowSpeed","bounce","floorInset","label","contentInitiallyHidden","clearIndicatorOnPress","catchTarget","catchAnchor","catchMargin","catchEvent"]);void 0!==i.press&&!["toggle-content","show-content","hide-content","emit","none"].includes(i.press)&&$t("invalid-interaction","$.interaction.press"),void 0!==i.pressEvent&&("string"!=typeof i.pressEvent||!Kt.test(i.pressEvent))&&$t("invalid-interaction-event","$.interaction.pressEvent"),"emit"===i.press&&void 0===i.pressEvent&&$t("missing-interaction-event","$.interaction.pressEvent"),void 0!==i.pressEvent&&void 0!==i.press&&"emit"!==i.press&&$t("incompatible-interaction-event","$.interaction.pressEvent");for(let t of["drag","throw","contentInitiallyHidden","clearIndicatorOnPress"])void 0!==i[t]&&"boolean"!=typeof i[t]&&$t("invalid-interaction","$.interaction."+t);for(let t of["dragState","riseState","fallState","landState"])void 0!==i[t]&&("string"!=typeof i[t]||!Qt.test(i[t]))&&$t("invalid-interaction-state","$.interaction."+t);for(let[t,e,s]of[["gravity",0,1e4],["maxThrowSpeed",0,1e4],["bounce",0,1],["floorInset",0,1e3],["catchMargin",0,1e3]]){let r=i[t];void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<e||r>s)&&$t("invalid-interaction-range","$.interaction."+t)}void 0!==i.label&&!kt(i.label,120)&&$t("invalid-interaction-label","$.interaction.label"),void 0!==i.catchTarget&&("string"!=typeof i.catchTarget||!Jt.test(i.catchTarget)||!Object.hasOwn(e??{},i.catchTarget))&&$t("invalid-catch-target","$.interaction.catchTarget"),void 0!==i.catchAnchor&&!["center","top","right","bottom","left"].includes(i.catchAnchor)&&$t("invalid-catch-anchor","$.interaction.catchAnchor"),void 0!==i.catchEvent&&("string"!=typeof i.catchEvent||!Kt.test(i.catchEvent))&&$t("invalid-interaction-event","$.interaction.catchEvent")})(t.interaction,t.targets),(t=>{if(void 0===t)return;let e=gt(t,"invalid-indicator","$.indicator",["kind","count","label","color","visible"]);void 0!==e.kind&&"dot"!==e.kind&&"count"!==e.kind&&$t("invalid-indicator","$.indicator.kind"),kt(e.label,120)||$t("invalid-indicator","$.indicator.label"),void 0!==e.count&&("number"!=typeof e.count||!Number.isInteger(e.count)||e.count<0||e.count>999)&&$t("invalid-indicator","$.indicator.count"),void 0!==e.color&&!s(e.color)&&$t("invalid-indicator","$.indicator.color"),void 0!==e.visible&&"boolean"!=typeof e.visible&&$t("invalid-indicator","$.indicator.visible")})(t.indicator),!1===t.interaction&&void 0!==t.indicator&&$t("incompatible-indicator","$.indicator"),(t=>{if(void 0===t)return;let e=gt(t,"invalid-theme","$.theme",["background","color","linkColor","borderColor","radius","width","padding"]);for(let[t,i,s]of[["radius",0,64],["width",120,640],["padding",0,48]]){let r=e[t];void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<i||r>s)&&$t("invalid-theme","$.theme."+t)}for(let t of["background","color","linkColor","borderColor"]){let i=e[t];void 0!==i&&!s(i)&&$t("invalid-theme","$.theme."+t)}})(t.theme),(t=>{if(void 0===t)return;let e=gt(t,"invalid-diagnostics","$.diagnostics",["console","debug","context"]);for(let t of["console","debug"])void 0!==e[t]&&"boolean"!=typeof e[t]&&$t("invalid-diagnostics","$.diagnostics."+t);let i=e.context;if(void 0===i)return;let s=gt(i,"invalid-diagnostic-context","$.diagnostics.context",void 0),r=Object.entries(s);r.length>16&&$t("diagnostic-context-limit","$.diagnostics.context");for(let[t,e]of r)(!/^[a-z][a-z0-9_.-]{0,31}$/.test(t)||!["string","number","boolean"].includes(typeof e)||"string"==typeof e&&e.length>64||"number"==typeof e&&!Number.isFinite(e))&&$t("invalid-diagnostic-context","$.diagnostics.context."+t)})(t.diagnostics),(t=>{if(void 0===t)return;let e=gt(t,"invalid-accessibility","$.accessibility",["announceContent","contentLabel"]);void 0!==e.announceContent&&"boolean"!=typeof e.announceContent&&$t("invalid-accessibility","$.accessibility.announceContent"),void 0!==e.contentLabel&&!kt(e.contentLabel,120)&&$t("invalid-accessibility","$.accessibility.contentLabel")})(t.accessibility);for(let e of["onDiagnostic","logger"])void 0!==t[e]&&"function"!=typeof t[e]&&$t("invalid-callback","$."+e);return o})(t,n);try{o=i(t.styles,n)}catch(t){jt("invalid-styles","$.styles")}if(void 0!==t.plan)try{B(t.plan,{contentIds:new Set(Object.keys(h)),targets:new Set(Object.keys(t.targets??{}))})}catch(t){jt("invalid-plan","$.plan")}return[h,o]})(t,h.location?.href??o.baseURI);this.#K=l,this.finished=new Promise(t=>{this.#t=t}),this.#C="string"==typeof t.name?t.name:!0===t.name?"":void 0,this.#N=a;let c=((t,e,i,s)=>{let r=Ue.get(t);return r?r.assertStyles(s):(r=new Le(t,e,s),Ue.set(t,r)),{unregister:r.register(i),ready:r.ready}})(o,h,t=>{null===t?(this.#ot("visibility.root-failed","internal.frame-failed","error","internal"),this.#F("failed")):this.#ht(t)},this.#K);this.#z=c.unregister,this.#P=c.ready,this.#A=()=>{o.hidden?(this.#at(2,!0),this.#_("lifecycle.hidden","info","lifecycle")):(this.#at(2,!1),this.#_("lifecycle.visible","info","lifecycle"))},o.addEventListener("visibilitychange",this.#A,{passive:!0}),this.#T=()=>this.#lt(),h.addEventListener("pagehide",this.#T,{passive:!0}),o.hidden&&this.#at(2,!0),this.ready=this.#ct(),this.ready.catch(()=>{})}emit(t,e){if(this.#e)return this.#dt("destroyed");if(this.#E)return this.#dt("hidden");if("string"!=typeof t||!Kt.test(t))return this.#dt("invalid-name");if(!this.#l)return this.#dt("not-ready");let i;try{i=p(e)}catch{return this.#dt("invalid-payload")}let s=this.#l.j(t,i,"application");return s.accepted?(this.#_(s.coalesced?"event.coalesced":"event.accepted","info","event",s.id),s):this.#dt(s.reason)}override(t){let e=t=>((t,e)=>Object.freeze({id:t,status:"rejected",finished:Promise.resolve({id:t,reason:e}),cancel(){}}))("override:rejected:"+ ++this.#X,t);if(this.#e)return e("destroyed");if(this.#E)return e("dismissed");if(!this.#V)return this.#G||(this.#G=!0,this.#_("override.not-ready","warning","override")),e("rejected");let i=this.#V.add(t),s=this.#V.browserCompletionFor(i.id),r=s?this.#l?.retainEvent(s):void 0;return i.finished.then(()=>{r?.(),this.#H()}),this.#H(),i}pause(){this.#e||1&this.#M||(this.#at(1,!0),this.#_("lifecycle.paused","info","lifecycle"))}resume(){this.#e||!(1&this.#M)||(this.#at(1,!1),this.#_("lifecycle.resumed","info","lifecycle"))}refreshTargets(){this.#a?.refresh()}setIndicator(t){this.#e||(this.#et=(t=>{if(null===t)return;let e=d(t);if(!e||"object"!=typeof e||Array.isArray(e)||void 0!==e.kind&&"dot"!==e.kind&&"count"!==e.kind||"string"!=typeof e.label||e.label.length<1||e.label.length>120||/[\u0000-\u001f\u007f]/.test(e.label)||void 0!==e.count&&(!Number.isInteger(e.count)||e.count<0||e.count>999)||void 0!==e.color&&!s(e.color)||void 0!==e.visible&&"boolean"!=typeof e.visible)throw new TypeError("indicator.invalid");return e})(t),this.#o?.updateIndicator(this.#et))}setContentVisible(t){if(this.#e||!this.#n)return!1;let e=this.#n.setUserHidden(!t);return this.#o?.setExpanded(e),this.#H(),e}toggleContent(){if(this.#e||!this.#n)return!1;let t=this.#n.toggleUserHidden();return this.#o?.setExpanded(t),this.#H(),t}destroy(){this.#F("destroyed")}#F(t){if(this.#e)return;this.#e=!0,this.#f+=1,this.#V?.clear("destroyed"),this.#i.abort(),this.#ft(),this.#l?.destroy(),this.#U?.reset(),this.#h?.destroy(),this.#a?.destroy(),this.#n?.destroy(),this.#o?.destroy(),this.#r?.destroy(),this.#z?.(),this.#z=void 0,this.#A&&(this.#R.removeEventListener("visibilitychange",this.#A),this.#A=void 0),this.#T&&(this.#D.removeEventListener("pagehide",this.#T),this.#T=void 0),this.#s?.release(),this.#m&&this.#k&&this.#m.removeEventListener("change",this.#k),this.#$&&this.#j&&this.#$.removeEventListener("change",this.#j),this.#_("lifecycle.destroyed","info","lifecycle");let e=this.#t;this.#t=void 0,e?.({reason:t})}async#ct(){try{let t=t=>((t,e)=>{try{return t.createDocumentFragment().querySelector(e),!0}catch{return!1}})(this.#R,t),e=new Set(Object.keys(this.#L.targets??{}));for(let e of Object.values(this.#L.targets??{}))if(!t(e))throw new TypeError(Lt("target.selector"));void 0!==this.#L.plan&&B(this.#L.plan,{contentIds:new Set(Object.keys(this.#N)),targets:e,validateSelector:t,validatePath:t=>this.#tt.validate(t)});let i,s=this.#D,n=s.navigator.connection;this.#I=this.#L.maxDensity??(n?.saveData?2:4);try{i=await(async t=>{let e=t.resourceTimeoutMs??3e4;void 0===t.pack&&void 0===t.packUrl&&void 0===t.character&&E("manifest.selection");let i,s,n=t.packUrl;if(void 0!==t.pack)i=t.pack;else{if(void 0===n){let e=(t=>{if(!Z(t))throw Error("character.unknown");return ge[t]})(t.character);n=e.url,s=e.sha256}let o=((t,e)=>{r(t,e)||E("url.protocol");try{return new URL(t,e).href}catch{E("url.invalid")}})(n,t.baseUrl);n=o;let h=await q(t.signal,e,"manifest.timeout",async e=>{let i=await J(t.fetch,o,e,"manifest.network");if(!i.ok)throw new fe("manifest.http","http","manifest.http");return F(i,["application/json"]),K(i,65536,e,"manifest.network")});s&&!await Q(h,s,!0)&&E("manifest.hash");try{i=(t=>((t,e,i=65536)=>{if((new TextEncoder).encode(t).byteLength>i)throw new ue([j(e+".size")]);let s,r;try{s=JSON.parse(t)}catch{throw new ue([j(e+".json")])}try{r=(t=>{let e,i=0,s=()=>{for(;/\s/.test(t[i]??"");)i++},r=()=>{let e=i++;for(;i<t.length;)if("\\"===t[i])i+=2;else if('"'===t[i++])break;return JSON.parse(t.slice(e,i))},n=(o=0)=>{if(s(),"{"===t[i]){if(o>=64)throw 0;i++;let h=new Set;for(s();"}"!==t[i];){let a=r();if(h.has(a)&&void 0===e&&(e=a),h.add(a),s(),i++,n(o+1),s(),","!==t[i])break;i++,s()}i++;return}if("["!==t[i])if('"'!==t[i])for(;i<t.length&&!/[\s,}\]]/.test(t[i]);)i++;else r();else{if(o>=64)throw 0;for(i++,s();"]"!==t[i]&&(n(o+1),s(),","===t[i]);)i++,s();i++}};return n(),e})(t)}catch(t){throw 0!==t?t:new ue([j(e+".depth")])}if(void 0!==r)throw new ue([j(e+".duplicate-key",JSON.stringify(r))]);return s})(t,"character.json"))(new TextDecoder("utf-8",{fatal:!0}).decode(h))}catch(t){if(t instanceof ue)throw t;E("manifest.utf8")}}try{i=c(i)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}let o=(t=>{if(!A(t))return!1;let e=Object.getOwnPropertyDescriptor(t,"atlas")?.value,i=Object.getOwnPropertyDescriptor(t,"assets")?.value;return A(e)&&!A(i)})(i),h=o?H:U,a=h(i),l=t.F??X(t.devicePixelRatio??1,t._??a.defaultScale,t.maxDensity),d=h(i,void 0,l),f=!1,u="",p=async s=>{let r=(e=>t.atlasUrl??(n?new URL(e,new URL(n,t.baseUrl)).href:void 0))(s.src);r||E("atlas.url");let[a,l]=await q(t.signal,e,"atlas.timeout",async e=>{let i=await J(t.fetch,r,e,"atlas.network");if(!i.ok)throw new fe("atlas.http","http","atlas.http");return[F(i,o?["image/png","image/webp"]:["image/png"]),await K(i,o?33554432:4194304,e,"atlas.network")]});await Q(l,s.sha256)||E("atlas.hash");let c=h(i,void 0,s.density);((t,e,i,s)=>{let r=((t,e)=>{t.byteLength>33554432&&E("resource.size");let i=T(t),s=P(t);return("image/png"===e&&s||"image/webp"===e&&i)&&E("atlas.mime"),"image/png"===e?(t=>{T(t)||E("png.signature");let e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=ye.length,s=0,r=0,n=-1,o=0,h=!1,a=!1,l=!1,c=!1;for(;i<t.byteLength;){t.byteLength-i<12&&E("png.truncated");let d=e.getUint32(i),f=i+8,u=f+d+4;(u>t.byteLength||u<f)&&E("png.chunk");let p=I(t,i+4);if(/^[A-Za-z]{4}$/.test(p)||E("png.chunk-type"),o+=1,o>4096&&E("png.chunks"),!h&&("IHDR"!==p||13!==d)&&E("png.ihdr-first"),"IHDR"===p){(h||13!==d)&&E("png.ihdr"),h=!0,s=e.getUint32(f),r=e.getUint32(f+4);let i=t[f+8];n=t[f+9];let o={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};(s<1||r<1||s>ve||r>ve)&&E("png.dimensions"),(!o[n]?.includes(i)||0!==t[f+10]||0!==t[f+11]||0!==t[f+12]&&1!==t[f+12])&&E("png.fields")}else if("PLTE"===p)c&&E("png.palette-order"),a=!0;else if("tRNS"===p)c&&E("png.alpha-order"),l=!0;else if("IDAT"===p)3===n&&!a&&E("png.palette"),c=!0;else{if("IEND"===p)return(0!==d||!c)&&E("png.iend"),u!==t.byteLength&&E("png.trailing"),{width:s,height:r,hasAlpha:4===n||6===n||3===n&&l,mimeType:"image/png"};p.charCodeAt(0)<=90&&E("png.critical")}i=u}E("png.truncated")})(t):(t=>{(t.byteLength<20||!P(t))&&E("webp.header");let e=new DataView(t.buffer,t.byteOffset,t.byteLength);e.getUint32(4,!0)+8!==t.byteLength&&E("webp.size");let i,s,r=12,n=0,o=!1;for(;r<t.byteLength;){t.byteLength-r<8&&E("webp.chunk");let h=I(t,r),a=e.getUint32(r+4,!0),l=r+8,c=l+a+(1&a);if((c<l||c>t.byteLength)&&E("webp.chunk"),n+=1,n>4096&&E("webp.chunks"),"ALPH"===h)o=!0;else if("VP8X"===h)a<10&&E("webp.vp8x"),i=R(1+D(t,l+4),1+D(t,l+7),!!(16&t[l])||o);else if("VP8L"===h){(a<5||47!==t[l])&&E("webp.vp8l");let r=e.getUint32(l+1,!0),n=R(1+(16383&r),1+(r>>>14&16383),!0);s??=i??n}else if("VP8 "===h){(a<10||157!==t[l+3]||1!==t[l+4]||42!==t[l+5])&&E("webp.vp8");let r=R(16383&e.getUint16(l+6,!0),16383&e.getUint16(l+8,!0),o);s??=i??r}else!i&&!s&&"ICCP"!==h&&"EXIF"!==h&&"XMP "!==h&&E("webp.chunk-type");r=c}if(s)return s;E("webp.image")})(t)})(t,e);(r.width!==s.width||r.height!==s.height)&&E("atlas.dimensions"),!i&&!r.hasAlpha&&E("atlas.alpha")})(l,a,o,{width:c.atlas.columns*c.atlas.cellWidth,height:c.atlas.rows*c.atlas.cellHeight});let d=t.createObjectURL(new Blob([l]));try{let e=await(async(t,e,i)=>(await new Promise((s,r)=>{let n=()=>{t.removeEventListener("load",o),t.removeEventListener("error",h),i.removeEventListener("abort",a)},o=()=>{n(),s()},h=()=>{n(),r(new fe("atlas.decode","decode","atlas.decode"))},a=()=>{n(),t.removeAttribute("src"),r(i.reason)};if(t.addEventListener("load",o,{once:!0}),t.addEventListener("error",h,{once:!0}),i.addEventListener("abort",a,{once:!0}),i.aborted)return a();t.src=e}),{width:t.naturalWidth,height:t.naturalHeight}))(t.image(),d,t.signal);return{pack:h(i,{...e,byteLength:l.byteLength},s.density),V:d}}catch(e){throw t.revokeObjectURL(d),e}},v=async(e,i)=>{let s,r=(e=>{let i=a.atlas.variants;if(!i?.length){let e=d.atlas.density??1;return void 0!==t.F&&t.F!==e&&E("atlas.override-density"),e>(t.maxDensity??4)&&E("atlas.max-density"),d.atlas.sha256||E("atlas.integrity-declaration"),[{src:d.atlas.src,density:e,sha256:d.atlas.sha256}]}let s=i.filter(e=>e.density<=(t.maxDensity??4));if(s.length||E("atlas.max-density"),void 0!==t.atlasUrl){void 0===t.F&&E("atlas.override-density");let e=s.find(e=>e.density===t.F);return e||E("atlas.override-density"),[e]}let r=L(s.map(t=>t.density),e);return s.filter(t=>t.density<=r).sort((t,e)=>e.density-t.density)})(e);for(let[e,n]of r.entries()){if(i&&n.density<=(d.atlas.density??1))return;try{return await p(n)}catch(i){if(t.signal.aborted)throw t.i?.(Lt("atlas.abort"),"abort"),i;s=i;let n=_(i),o=e<r.length-1;t.i?.(Lt(`atlas.${n}.${o?"fallback":"exhausted"}`),n)}}if(!i)throw s??new fe("atlas.unusable","validation","atlas.unusable")},y=await v(l,!1);if(!y)throw new fe("atlas.unusable","validation","atlas.unusable");d=y.pack,u=y.V;let w=d.atlas.density??1,b=0,g={get content(){return d},get q(){return u},get J(){return d.atlas.density??1},async upgrade(e){if(f||void 0!==t.atlasUrl||e<=g.J)return!1;w=Math.max(w,e);let i=++b,s=await v(w,!0),r=s?.pack.atlas.density??1;if(!s||f||r<=g.J||i!==b&&r<w)return s&&t.revokeObjectURL(s.V),!1;let n=u;return d=s.pack,u=s.V,t.revokeObjectURL(n),!0},release(){f||(f=!0,u&&t.revokeObjectURL(u),u="")}};return g})({...void 0===this.#L.character?{}:{character:this.#L.character},baseUrl:this.#D.location.href,...void 0===this.#L.pack?{}:{pack:this.#L.pack},...void 0===this.#L.packUrl?{}:{packUrl:this.#L.packUrl},...void 0===this.#L.atlasUrl?{}:{atlasUrl:this.#L.atlasUrl},...void 0===this.#L.scale?{}:{_:this.#L.scale},devicePixelRatio:this.#D.devicePixelRatio,...void 0===this.#L.density?{}:{F:this.#L.density},maxDensity:this.#I,fetch:this.#D.fetch.bind(this.#D),image(){return new s.Image},signal:this.#i.signal,createObjectURL:s.URL.createObjectURL.bind(s.URL),revokeObjectURL:s.URL.revokeObjectURL.bind(s.URL),i:(t,e)=>{this.#ot(t,e?"config.pack-load-"+e:"config.pack-load","warning","config")}})}catch(t){throw this.#e&&this.#i.signal.aborted||this.#_("config.pack-load-failed","error","config",void 0,void 0,t),t}if(this.#e)throw i.release(),new DOMException("lifecycle.destroyed","AbortError");let o=this.#L.scale??i.content.defaultScale;if(!Number.isInteger(o)||o<1||o>4)throw i.release(),new TypeError("scale.value");this.#s=i;let h=(t=>_t.every(e=>Object.hasOwn(t.directionalStates??{},e)))(i.content),a=new Set(h?["locomotion"]:[]),l=B(this.#L.plan??((t,e)=>"still"===t?{baseline:{channels:["state"],state:{state:"idle"}}}:"bottom-patrol"===t||"viewport-roam"===t?{baseline:{channels:["motion","state"],state:e?{capability:"locomotion"}:{state:"idle"},motion:"bottom-patrol"===t?{type:"horizontal-patrol",speed:160}:{type:"viewport-traverse",speed:160}}}:{baseline:{channels:["state"],state:{state:"idle"}},...e?{rules:[{id:"follow-pointer",when:{source:"browser",event:"pointer.move"},effect:{channels:["motion","state"],motion:{type:"follow-pointer",speed:160},state:{capability:"locomotion"}}}]}:{}})(this.#L.preset??"companion",h),{states:new Set(Object.keys(i.content.states)),capabilities:a,contentIds:new Set(Object.keys(this.#N)),targets:e,validateSelector:t,validatePath:t=>this.#tt.validate(t)});if(this.#U=new je(l),this.#V=new Se({states:new Set(Object.keys(i.content.states)),capabilities:a,contentIds:new Set(Object.keys(this.#N)),targets:e,validatePath:t=>this.#tt.validate(t)},this.#O,t=>this.#ot(t,"override.rejected","warning","override")),""===this.#C&&(this.#C=i.content.displayName),this.#m=this.#D.matchMedia("(prefers-reduced-motion: reduce)"),this.#g=this.#m.matches,this.#k=t=>{this.#g=t.matches,this.#_(t.matches?"lifecycle.reduced-motion-enabled":"lifecycle.reduced-motion-disabled","info","lifecycle"),this.#H()},this.#m.addEventListener("change",this.#k),this.#ut(),this.#w=((t,e,i,s,r)=>{let n;if("center"===t)n={x:e/2,y:i/2};else if("bottom-right"===t||"bottom-left"===t)n={x:"bottom-right"===t?e-s/2-16:s/2+16,y:i-r/2-16};else{if("object"!=typeof t)throw new TypeError("position.value");if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new TypeError("position.coordinates");n=t}return Pt(n,{width:e,height:i},s,r)})(this.#L.position??"bottom-right",this.#D.innerWidth,this.#D.innerHeight,(i.content.atlas.logicalWidth??i.content.atlas.cellWidth)*o,(i.content.atlas.logicalHeight??i.content.atlas.cellHeight)*o),this.#r=this.#Q({document:this.#R,pack:i.content,atlasUrl:i.q,scale:o,styles:this.#K}),(Object.keys(this.#N).length||void 0!==this.#C)&&this.#W(),!1!==this.#L.interaction){let t=this.#L.interaction??{},e=t.press??(t.pressEvent?"emit":"toggle-content"),s=!!this.#n&&("toggle-content"===e||"show-content"===e||"hide-content"===e);t.contentInitiallyHidden&&this.#n?.setUserHidden(!0),this.#o=new ae({document:this.#R,styles:this.#K,label:t.label??"Interact with "+(i.content.displayName||"Peekling"),draggable:!1!==t.drag,...s?{expanded:!t.contentInitiallyHidden}:{},...this.#et?{indicator:this.#et}:{},onPress:()=>this.#pt(),onDragStart:()=>this.#vt(),onDragMove:(t,e)=>this.#yt(t,e),onDragEnd:(t,e,i)=>this.#wt(t,e,i)}),t.contentInitiallyHidden&&this.#o.setExpanded(!1)}try{await Promise.all([this.#P,this.#r.ready,this.#n?.ready,this.#o?.ready])}catch(t){throw this.#Z(t),t}let d=(t=>{let e=new Set,i=new Set([0,1]);for(let s of t.rules)"browser"===s.when.source&&"section.visibility"===s.when.event&&(e.add(s.when.selector),i.add(s.when.threshold??.25));return{selectors:[...e],thresholds:[...i].sort((t,e)=>t-e)}})(l);return this.#bt(),e.size&&(this.#a=new Ie(this.#R,this.#D,this.#L.targets,()=>this.#H())),d.selectors.length&&(this.#h=new Te(this.#R,this.#D,d.selectors,d.thresholds,()=>this.#H(),t=>this.#l?.j("section.visibility",t,"browser"))),this.#r.N(this.#E),this.#o?.N(this.#E),this.#M&&(this.#l?.O(!0),this.#h?.O(!0)),this.#u=this.#O(),this.#gt(this.#u,!0),this}catch(t){throw this.#F("failed"),t}}#bt(){if(this.#e||this.#l||!this.#U)return;let t=new Set,e=new Map;for(let i of this.#U.plan.rules){let s="browser"===i.when.source;if(s&&t.add(i.when.event),"event"===i.effect.until?.type){let e=f(i.effect.until.name);e&&t.add(e)}if("latest"!==i.when.coalesce)continue;let r=`${i.when.source}:${i.when.event}`;if(s)e.set(r,!0);else{let t=i.effect.surfaces[0].ordering;e.set(r,{sessionField:t.sessionField,revisionField:t.revisionField})}}this.#l=new he(this.#R,this.#D,{events:t,coalesce:e,i:t=>this.#ot(t,"event.queue-overflow","warning","event"),now:this.#O,wake:()=>this.#H()}),t.has("page.lifecycle")&&this.#l.j("page.lifecycle",{phase:"show"},"browser")}#W(){return this.#n||this.#e||(this.#n=new oe(this.#R,{i:t=>this.#ot(t,"render.host-failed","error","render"),...this.#L.bindings?{bindings:this.#L.bindings}:{},...this.#L.theme?{theme:this.#L.theme}:{},...this.#L.accessibility?.announceContent?{announce:!0}:{},...this.#L.accessibility?.contentLabel?{label:this.#L.accessibility.contentLabel}:{},emit:(t,e)=>this.emit(t,e),wake:()=>this.#H(),styles:this.#K})),this.#n}#pt(){if(this.#e)return;let t=this.#L.interaction||{};!0===t.clearIndicatorOnPress&&this.#et&&this.setIndicator(null);let e=t.press??(t.pressEvent?"emit":"toggle-content");"emit"!==e?"none"!==e&&("show-content"===e?this.setContentVisible(!0):"hide-content"===e?this.setContentVisible(!1):this.toggleContent()):t.pressEvent&&this.emit(t.pressEvent)}#vt(){this.#e||this.#E||(this.#it=!0,this.#st=!1,this.#nt=0,this.#rt={x:0,y:0},this.#H())}#yt(t,e){if(!this.#it||this.#e)return;let i=this.#mt();this.#w=i?Pt(t,{width:this.#D.innerWidth,height:this.#D.innerHeight},i.width,i.height):{...t},this.#rt={...e},this.#H()}#wt(t,e,i){if(!this.#it||this.#e)return;if(this.#it=!1,!e){this.#rt={x:0,y:0},this.#H();return}let s=this.#L.interaction||{};if(s.catchTarget&&this.#a?.contains(s.catchTarget,i,s.catchMargin??24)&&this.#kt(s.catchTarget))return;if(this.#g){this.#$t();return}if(!1===s.throw){this.#rt={x:0,y:0},this.#H();return}let r=s.maxThrowSpeed??1800,n=Math.hypot(t.x,t.y),o=n>r&&n?r/n:1;this.#rt={x:t.x*o,y:t.y*o},this.#st=!0,this.#H()}#mt(){let t=this.#s?.content;if(!t)return;let e=this.#L.scale??t.defaultScale;return{width:(t.atlas.logicalWidth??t.atlas.cellWidth)*e,height:(t.atlas.logicalHeight??t.atlas.cellHeight)*e}}#$t(){let t=this.#mt();if(t){let e=(this.#L.interaction||{}).floorInset??8;this.#w=Pt({x:this.#w.x,y:this.#D.innerHeight-t.height/2-e},{width:this.#D.innerWidth,height:this.#D.innerHeight},t.width,t.height)}this.#it=!1,this.#st=!1,this.#rt={x:0,y:0},this.#nt=this.#O()+360,this.#H()}#kt(t){let e=this.#a?.H(!0)[t],i=this.#mt();if(!e||!i)return!1;let s=this.#L.interaction||{},r=((t,e,i)=>{let s={x:t.left+t.width/2,y:t.top+t.height/2};switch(e){case"top":return{x:s.x,y:t.top-i.height/2};case"right":return{x:t.right+i.width/2,y:s.y};case"bottom":return{x:s.x,y:t.bottom+i.height/2};case"left":return{x:t.left-i.width/2,y:s.y};default:return s}})(e,s.catchAnchor??"center",i);return this.#w=Pt(r,{width:this.#D.innerWidth,height:this.#D.innerHeight},i.width,i.height),this.#st=!1,this.#rt={x:0,y:0},this.#nt=this.#O()+360,s.catchEvent&&this.emit(s.catchEvent),this.#H(),!0}#ot(t,e="runtime.notice",i="warning",s="internal",r,n,o){this.#J.emit({code:e,severity:i,message:t,phase:s,...void 0===r?{}:{eventId:r},...n?{metadata:n}:{},...o?{cause:o}:{}})}#_(t,e="warning",i="internal",s,r,n){this.#ot(t,t,e,i,s,r,n)}#Z(t){this.#_("config.styles-load-failed","error","config",void 0,void 0,t)}#dt(t){if("not-ready"===t){if(this.#B)return{accepted:!1,reason:t};this.#B=!0}return this.#ot("event.rejected","event.rejected."+t,"warning","event",void 0,{reason:t}),{accepted:!1,reason:t}}#jt(){void 0===this.#S&&(this.#S=this.#O(),this.#ft(),this.#l?.O(!0),this.#h?.O(!0))}#ft(){this.#c&&this.#D.cancelAnimationFrame(this.#c),this.#c=0,this.#d&&this.#D.clearTimeout(this.#d),this.#d=0}#xt(){if(void 0===this.#S||this.#M||this.#e)return;let t=this.#O(),e=Math.max(0,t-this.#S);this.#S=void 0,this.#V?.D(e),this.#U?.D(e),this.#l?.O(!1),this.#h?.O(!1),this.#u=t,this.#H()}#at(t,e){let i=this.#M;e?this.#M|=t:this.#M&=~t,i!==this.#M&&(this.#f+=1,!i&&this.#M&&this.#jt(),i&&!this.#M&&this.#xt())}#ht(t){if(t!==this.#E&&(this.#E=t,this.#r?.N(t),this.#o?.N(t),!(this.#e||t&&this.#n&&(this.#n.o([],{},this.#w,{width:this.#D.innerWidth,height:this.#D.innerHeight},{width:0,height:0}),this.#e)))){if(t){this.#it=!1,this.#st=!1,this.#rt={x:0,y:0},this.#V?.clear("dismissed"),this.#at(4,!0),this.#_("lifecycle.dismissed","info","lifecycle");return}this.#at(4,!1),this.#r&&this.#s&&!this.#e&&(this.#_("lifecycle.shown","info","lifecycle"),this.#e||this.#H())}}#H(){if(this.#e||this.#M||!this.#r||this.#c)return;this.#d&&this.#D.clearTimeout(this.#d),this.#d=0;let t=this.#f,e=this.#D.requestAnimationFrame(()=>{if(this.#c=0,!this.#e&&!this.#M&&t===this.#f)try{this.#gt(this.#O())}catch(t){this.#_("internal.frame-failed","error","internal",void 0,void 0,t),this.#F("failed")}});this.#e||this.#M||t!==this.#f?this.#D.cancelAnimationFrame(e):this.#c=e}#Et(t){if(!this.#Mt(t))return;this.#d&&this.#D.clearTimeout(this.#d),this.#d=0;let e=t.overrides.P(),i=Number.isFinite(e)?e:void 0,s=t.plan.P(),r=Number.isFinite(s)?s:void 0,n=this.#g?void 0:t.renderer.W(this.#p),o=Number.isFinite(n)?n:void 0,h=void 0===o?void 0:t.now+o,a=void 0===i?r:void 0===r?i:Math.min(i,r),l=void 0===a?h:void 0===h?a:Math.min(a,h);if(void 0===l||!Number.isFinite(l)||!this.#Mt(t))return;let c=this.#D.setTimeout(()=>{this.#Mt(t)&&(this.#d=0,this.#H())},Math.min(2147483647,Math.max(0,l-t.now)));this.#Mt(t)?this.#d=c:this.#D.clearTimeout(c)}#ut(){this.#$&&this.#j&&this.#$.removeEventListener("change",this.#j),this.#$=this.#D.matchMedia(`(resolution: ${this.#D.devicePixelRatio}dppx)`),this.#j=()=>{this.#ut(),this.#Ot(),this.#H()},this.#$.addEventListener("change",this.#j)}#Ot(){if(this.#e||!this.#s||!this.#r||this.#x||void 0!==this.#L.density)return;let t=this.#L.scale??this.#s.content.defaultScale,e=X(this.#D.devicePixelRatio,t,this.#I);if(e<=this.#s.J)return;let i=this.#s;this.#x=i.upgrade(e).then(t=>{if(t&&!this.#e&&this.#s===i){let t=this.#r;return t?Promise.resolve(t.L(i.content,i.q)).then(()=>{!this.#e&&this.#s===i&&this.#H()}):void 0}}).catch(t=>{this.#e||this.#_("render.atlas-upgrade-failed","warning","render",void 0,void 0,t)}).finally(()=>{this.#x=void 0})}#Mt(t){return!this.#e&&!this.#M&&t.K===this.#f&&t.renderer===this.#r&&t.loaded===this.#s&&t.input===this.#l&&t.plan===this.#U&&t.overrides===this.#V}#St(t,e){let i=this.#r,s=this.#s,r=this.#l,n=this.#U,o=this.#V;if(this.#e||this.#M||!i||!s||!r||!n||!o)return;let h=t-this.#u;if(e||!(h<1e3/30))return{K:this.#f,now:t,elapsed:h,stepMs:Math.min(Math.max(0,h)||1e3/30,100),renderer:i,loaded:s,input:r,plan:n,overrides:o};this.#H()}#Nt(t){let e=t.loaded.content,i=t.input,s=this.#L.scale??e.defaultScale,r={width:this.#D.innerWidth,height:this.#D.innerHeight},n={width:(e.atlas.logicalWidth??e.atlas.cellWidth)*s,height:(e.atlas.logicalHeight??e.atlas.cellHeight)*s},o=this.#D.devicePixelRatio;this.#Ot(),this.#w=Pt(this.#w,r,n.width,n.height);let h=this.#h?.H(),a=i.reaction,l=a&&a.id>this.#b?a:void 0;return{frame:t,devicePixelRatio:o,t:n,world:{now:t.now,pointer:i.pointer,position:this.#w,viewport:r,t:n,$:i.$,reducedMotion:this.#g,pageVisible:!this.#R.hidden,sections:h,targets:this.#a?.H(this.#Y),samplePath:(t,e)=>this.#tt.sample(t,e),reaction:l},reaction:l}}#At(t){let{frame:e,world:i,reaction:s}=t,{plan:r,overrides:n}=e,o=r.evaluate(i),h=s?r.lastEventStatus:void 0,a=s?r.lastEventRejections:[];s&&"invalid"!==h&&"stale"!==h&&"closed"!==h&&n.C(s.name,s.source);let l=n.compose(o,i);this.#Y=!0===l.motion?.trackTarget,this.#g&&(delete l.motion,"locomotion"===l.capability&&delete l.capability,l.state||(l.state="idle"));let c=this.#L.interaction||{};this.#it?(delete l.motion,delete l.capability,l.state=c.dragState??"scroll:fly"):this.#st?(delete l.motion,delete l.capability,l.state=this.#rt.y<0?c.riseState??"scroll:fly":c.fallState??"scroll:fall"):this.#nt>i.now&&(delete l.motion,delete l.capability,l.state=c.landState??"success");let d=[];if(s)if(this.#b=s.id,e.input.M(s.id),a.length)for(let t of a)d.push(Object.freeze({message:Lt("event."+t.status),code:"event."+t.status,severity:"invalid"===t.status?"warning":"info",eventId:s.id,metadata:Object.freeze({channel:t.channel})}));else"stale"===h||"closed"===h||"invalid"===h?d.push(Object.freeze({message:"event."+h,code:"event."+h,severity:"invalid"===h?"warning":"info",eventId:s.id})):"matched"!==h&&d.push(Object.freeze({message:"event.unmatched",code:"event.unmatched",severity:"info",eventId:s.id}));return{request:l,diagnostics:d}}#zt(t,e){for(let i of e){if(!this.#Mt(t))return!1;this.#ot(i.message,i.code,i.severity,"event",i.eventId,i.metadata)}return this.#Mt(t)}#Tt(t){if(!this.#st)return;let e=this.#L.interaction||{},i=t.frame.stepMs/1e3,s=e.bounce??.35,r=t.t.width/2,n=t.t.height/2,o=t.world.viewport.height-n-(e.floorInset??8),h=this.#rt.x,a=this.#rt.y+(e.gravity??1800)*i,l=this.#w.x+h*i,c=this.#w.y+a*i,d=t.world.viewport.width-r;l<r?(l=r,h=Math.abs(h)*s):l>d&&(l=d,h=-Math.abs(h)*s),c<n&&(c=n,a=Math.abs(a)*s);let f={x:l,y:c};if(!(e.catchTarget&&this.#a?.contains(e.catchTarget,f,e.catchMargin??24)&&this.#kt(e.catchTarget))){if(c>=o){this.#w={x:l,y:o},this.#$t();return}this.#w=f,this.#rt={x:.995*h,y:a}}}#Pt(t,e){let{frame:i,t:s,world:r}=t,{request:n}=e,o=i.loaded.content;this.#g||(this.#p+=Math.max(0,i.elapsed)),this.#Tt(t);let h="locomotion"===n.capability&&n.motion?o.directionalStates?.[((t,e)=>le[(Math.round(Math.atan2(e.y-0,e.x-0)/(Math.PI/4))+8)%8])(0,{x:n.motion.x,y:n.motion.y})]:((t,e)=>{if(t)return e.reactionStates&&Object.hasOwn(e.reactionStates,t)?e.reactionStates[t]:t})(n.state,o),a=((t,e)=>{let i=Object.keys(e);if(0===i.length)throw Error("state.empty");let s=t=>Object.hasOwn(e,t);if(t&&s(t))return{name:t};if(t)for(let e of Object.hasOwn(ze,t)?ze[t]:[])if(s(e))return{name:e};return s("idle")?{name:"idle"}:{name:i.sort()[0]}})(h,o.states),l=0;if(n.motion?.direct){let t=n.motion.maxDistance??0;this.#w=Pt({x:this.#w.x+n.motion.x*t,y:this.#w.y+n.motion.y*t},r.viewport,s.width,s.height),l=n.motion.lift??0,this.#y="",this.#v=0}else if(n.motion){this.#y!==a.name&&(this.#y=a.name,this.#v=0);let t=k(o.states[a.name]),e=this.#v/t;this.#v+=i.stepMs;let h=this.#v/t,c=h-e,d=((t,e,i)=>(Math.floor(i)-Math.floor(e))*(t?.length?t.at(-1).advance-t[0].advance:1)+$(t,i).advance-$(t,e).advance)(o.locomotionMotion,e,h),f=n.motion.speed*(i.stepMs/1e3)*(c>0?d/c:1),u=Math.min(f,n.motion.maxDistance??f);this.#w=Pt({x:this.#w.x+n.motion.x*u,y:this.#w.y+n.motion.y*u},r.viewport,s.width,s.height),l=n.motion.lift??$(o.locomotionMotion,h).lift*s.height}else this.#y="",this.#v=0;return{state:a.name,lift:l}}#gt(t,e=!1){let i=this.#St(t,e);if(!i||!this.#Mt(i))return;let s=this.#Nt(i);if(!this.#Mt(i))return;let r=this.#At(s);if(!this.#Mt(i)||!this.#zt(i,r.diagnostics))return;let n=this.#Pt(s,r);this.#Mt(i)&&(this.#n?.o(r.request.surfaces??We,this.#N,this.#w,s.world.viewport,s.t,this.#C),this.#Mt(i)&&(i.renderer.S(n.state,this.#p,this.#w,s.devicePixelRatio,n.lift),this.#Mt(i)&&(this.#o?.S(this.#w,s.t,n.lift),this.#Mt(i)&&(this.#u=i.now,this.#Et(i),this.#Mt(i)&&(r.request.motion||i.input.reaction||this.#st||this.#it)&&this.#H()))))}#lt(){if(!this.#e)try{this.#l&&this.#U&&(this.#It(this.#O()),this.#l.j("page.lifecycle",{phase:"hide"},"browser"),this.#It(this.#O())),this.#_("lifecycle.pagehide","info","lifecycle")}finally{this.#F("pagehide")}}#It(t){if(!this.#l||!this.#U)return;let e=this.#l.reaction;for(;e;)this.#U.evaluate({now:t,position:this.#w,viewport:{width:this.#D.innerWidth,height:this.#D.innerHeight},$:this.#l.$,reducedMotion:this.#g,pageVisible:!1,reaction:e}),this.#b=e.id,this.#l.M(e.id),e=this.#l.reaction}},Ze="peekling-character",Fe=0,_e="sha256-r4PIKebZlQTb2JaHfQibQqQxHaKciwlXtTMDEvDTUPY=",Ve=globalThis.document?.currentScript;Ve?.src&&(t=>{Rt=Object.freeze({...t})})({url:new URL("./peekling.css",Ve.src).href,..._e?{integrity:_e}:{}});var qe=Object.freeze({hatch(t){return He.hatch(t)},visibility:Object.freeze({hide(t,e=globalThis.document,i=globalThis.window){if(!e||!i)throw Error("browser.context");let s=Ue.get(e);s?s.hide(t):zt(i,t)},show(t=globalThis.document,e=globalThis.window){if(!t||!e)throw Error("browser.context");let i=Ue.get(t);i?i.show():Tt(e)},isHidden(t=globalThis.window){return!!((t=globalThis.window)=>{if(!t)throw Error("browser.window");return Ue.get(t.document)?.isHidden()??((t,e=Date.now())=>At(t,e)[0])(t)})(t)}})});try{Reflect.has(globalThis,"Peekling")?It("Peekling"):Object.defineProperty(globalThis,"Peekling",{configurable:!0,value:qe,writable:!1})}catch{It("Peekling")}(function(){try{let t=globalThis.customElements,e=globalThis.HTMLElement;if(!t||!e)return;let i=t.get(Ze);if(i){i!==Ut&&It(Ze);return}class s extends e{static observedAttributes=["character","pack-url","name","styles-url","styles-integrity"];static{for(let t of["plan","content","bindings","theme","styles","accessibility","diagnostics","logger"])Object.defineProperty(this.prototype,t,{configurable:!0,get(){return this.#s[t]},set(e){this.#l(t,e)}})}#t;#e=Object.create(null);#i;#s=Object.create(null);#r=!1;#n=!1;#o=0;#h=Dt();#a=t=>{t.persisted&&this.#c()};get options(){return this.#e}set options(t){try{this.#e=d(t),this.#i=void 0}catch(t){this.#e=Object.create(null),this.#i=t}this.#c()}get instance(){return this.#t}get ready(){return this.#h[0]}emit(t,e){return this.#t?.emit(t,e)??{accepted:!1,reason:"not-ready"}}override(t){if(!this.#t){let t="override:disconnected:"+ ++Fe;return{id:t,status:"rejected",finished:Promise.resolve({id:t,reason:"rejected"}),cancel(){}}}return this.#t.override(t)}pause(){this.#t?.pause()}resume(){this.#t?.resume()}connectedCallback(){globalThis.addEventListener?.("pageshow",this.#a),this.#c()}attributeChangedCallback(t){let e=this.getAttribute("name");"name"===t&&this.#t&&this.#t.Z(null===e?this.#e.name:e||!0)||this.#c()}disconnectedCallback(){globalThis.removeEventListener?.("pageshow",this.#a),this.#o+=1,this.#r=!1,this.#h[2](new DOMException("element.disconnected","AbortError")),this.#t?.destroy(),this.#t=void 0}#l(t,e){void 0===e?delete this.#s[t]:this.#s[t]=e,this.#c()}#c(){if(!this.isConnected||this.#r)return;this.#r=!0;let t=++this.#o;this.#n?(this.#h[2](new DOMException("element.remounted","AbortError")),this.#h=Dt()):this.#n=!0,queueMicrotask(()=>{t===this.#o&&(this.#r=!1,this.isConnected&&(this.#t?.destroy(),this.#t=void 0,this.#d(t)))})}async#d(t){try{if(this.#i)throw this.#i;if(!this.#e||"object"!=typeof this.#e||Array.isArray(this.#e))throw new te("$","data.plain");let e=Object.create(null);for(let t of[this.#e,this.#s])for(let i in t)e[i]=t[i];let i=this.getAttribute("character");null!==i&&(e.character=i);let s=this.getAttribute("pack-url");null!==s&&(e.packUrl=s);let r=this.getAttribute("name");null!==r&&(e.name=r||!0);let n=this.getAttribute("styles-url");if(null!==n){let t=this.getAttribute("styles-integrity");e.styles=t?{url:n,integrity:t}:{url:n}}let o=He.hatch(e);if(this.#t=o,await o.ready,t!==this.#o||!this.isConnected){o.destroy();return}this.#h[1](o)}catch(e){if(t!==this.#o)return;this.#t?.destroy(),this.#t=void 0,this.#h[2](e)}}}t.define(Ze,s),Ut=s}catch{It(Ze)}})()})();
|
|
2
|
+
(()=>{function t(t,e,i){if(t.ownerDocument!==e)throw Error("root.document");let s=e.documentElement;if(!s)throw Error("root.missing");t.parentNode!==s&&s.append(t),t.hasAttribute(i)||t.setAttribute(i,"")}function e(t){return void 0===t||"string"==typeof t&&/^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(t)}function i(t,i){let s=t??Rt??(t=>({url:new URL("./peekling.css",t).href}))(i),r=new URL(s.url,i);if("https:"!==r.protocol&&"http:"!==r.protocol)throw new TypeError("styles.url");if(!e(s.integrity))throw new TypeError("styles.integrity");return Object.freeze({url:r.href,...s.integrity?{integrity:s.integrity}:{}})}function s(t){return"string"==typeof t&&Yt.test(t)}function r(t,e){if("string"!=typeof t||t.length<1||t.length>2048||/[\s\u0000-\u001f\u007f-\u009f\\]/u.test(t)||/%(?![0-9A-Fa-f]{2})/.test(t))return!1;let i=/^https:\/\//i.test(t);if(!i&&/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)||t.startsWith("//")||i&&!(t=>{let e=t.slice(8),i=e.search(/[/?#]/),s=i<0?e:e.slice(0,i);if(!s||s.includes("@")||s.includes("%"))return!1;if(s.startsWith("[")){let t=s.indexOf("]");return!(t<2||s.indexOf("[",1)>=0||s.indexOf("]",t+1)>=0||!n(s.slice(t+1)))}let r=s.indexOf(":");if(r!==s.lastIndexOf(":"))return!1;let h=r<0?s:s.slice(0,r),a=r<0?"":s.slice(r);return o(h)&&n(a)})(t))return!1;try{if(i){let e=new URL(t);return"https:"===e.protocol&&!e.username&&!e.password&&((t,e)=>{let i=t.slice(8),s=i.search(/[/?#]/),r=s<0?i:i.slice(0,s);if(r.startsWith("["))return!0;let n=r.indexOf(":");return(n<0?r:r.slice(0,n)).toLowerCase()===e.toLowerCase()})(t,e.hostname)}let s=new URL(e);if("https:"!==s.protocol&&"http:"!==s.protocol||s.username||s.password||!(t=>t.startsWith("[")?t.endsWith("]"):o(t))(s.hostname))return!1;let r=new URL(t,s);return!(r.username||r.password||"https:"!==r.protocol&&"http:"!==r.protocol||r.origin!==s.origin)}catch{return!1}}function n(t){return""===t||!!/^:[0-9]{1,5}$/.test(t)&&+t.slice(1)<=65535}function o(t){if(!t||t.length>253||t.endsWith("."))return!1;let e=t.split(".");return e.every(t=>/^[0-9]+$/.test(t))?4===e.length&&e.every(t=>/^(?:0|[1-9][0-9]{0,2})$/.test(t)&&+t<=255):e.every(t=>/^(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])$/.test(t))}function h(t,e,i){e&&ie.add(t),i&&se.add(t)}function a(t,e,i){if(!i&&((t,e)=>"object"==typeof t&&null!==t&&("configuration"===e?ee.has(t)||ie.has(t):"pack"===e?se.has(t):ie.has(t)))(t,e))return t;let s=0,r=0,n=new WeakSet,o=new WeakMap,a=(t,e,i)=>{throw new te(t,e,e)},l=(t,c,d)=>{if(void 0!==i?.maxDepth&&d>i.maxDepth)return a(c,"data.depth");if(r+=1,void 0!==i?.maxValues&&r>i.maxValues)return a(c,"data.nodes");if(null===t||"boolean"==typeof t)return{value:t,ownSafe:!0,packSafe:!0};if("string"==typeof t)return void 0!==i?.maxStringLength&&t.length>i.maxStringLength?a(c,"data.string"):{value:t,ownSafe:!0,packSafe:!0};if("number"==typeof t)return i?.json&&!Number.isFinite(t)?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!0};if(typeof t>"u")return i?.json?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!0};if("function"==typeof t)return"pack"===e||i?.json?a(c,"data.type"):{value:t,ownSafe:!0,packSafe:!1};if("object"!=typeof t)return a(c,"data.type");if("configuration"===e&&("$.document"===c||"$.window"===c))return{value:t,ownSafe:!1,packSafe:!1};if(d>32)return a(c,"data.depth");if(s+=1,s>2e4)return a(c,"data.nodes");let f,u,p=o.get(t);if(p){if(n.has(t))return a(c,"data.cycle");if(!i)return{value:p.value,ownSafe:p.ownSafe,packSafe:p.packSafe}}try{f=Reflect.ownKeys(t)}catch{return a(c,"data.reflect")}if(f.some(t=>"string"!=typeof t))return a(c,"data.symbol");if(Array.isArray(t)){if(t.length>Math.min(4096,i?.maxArrayLength??4096))return a(c,"data.array");if(f.length!==t.length+1||f.some(e=>"length"!==e&&(!/^\d+$/.test(e)||+e>=t.length)))return a(c,"data.array-own");let e=[],s={value:e};o.set(t,s),n.add(t);let r=!0,u=!0;for(let i=0;i<t.length;i+=1){let s=Object.getOwnPropertyDescriptor(t,i+"");if(!s||s.get||s.set)return a(`${c}[${i}]`,"data.descriptor");let n=l(s.value,`${c}[${i}]`,d+1);e.push(n.value),r&&=n.ownSafe,u&&=n.packSafe}n.delete(t);let p=Object.freeze(e);return s.ownSafe=r,s.packSafe=u,h(p,r,u),{value:p,ownSafe:r,packSafe:u}}try{u=(t=>{let e=Object.getPrototypeOf(t);return null===e||e===Object.prototype})(t)}catch{return a(c,"data.reflect")}if(!u)return a(c,"data.plain");if(f.length>Math.min(1024,i?.maxObjectKeys??1024))return a(c,"data.keys");let v=Object.create(null),y={value:v};o.set(t,y),n.add(t);let w=!0,b=!0;for(let e of f){i?.key&&!i.key(e)&&a(`${c}.${e}`,"data.key");let s=Object.getOwnPropertyDescriptor(t,e);if(!s||s.get||s.set)return a(`${c}.${e}`,"data.descriptor");let r=l(s.value,`${c}.${e}`,d+1);v[e]=r.value,w&&=r.ownSafe,b&&=r.packSafe}n.delete(t);let g=Object.freeze(v);return y.ownSafe=w,y.packSafe=b,h(g,w,b),{value:g,ownSafe:w,packSafe:b}};try{let i=l(t,"$",0);return"configuration"===e&&"object"==typeof i.value&&null!==i.value&&ee.add(i.value),i.value}catch(t){if(t instanceof te)throw t;return a("$","data.reflect")}}function l(t,e){return a(t,"own",e)}function c(t){return a(t,"pack")}function d(t){return a(t,"configuration")}function f(t){switch(t){case"pointer.click":case"document.visibility":case"window.focus":case"window.scroll":case"page.lifecycle":return t;default:return}}function u(t){return"pointer.move"===t||"section.visibility"===t}function p(t){if(void 0===t)return;let e;try{e=l(t,ne)}catch(t){if(t instanceof te)switch(t.issueCode){case"data.array":throw new TypeError("event.array-limit");case"data.cycle":case"data.depth":case"data.nodes":throw new TypeError("event.complexity");case"data.key":throw new TypeError("event.key");case"data.keys":throw new TypeError("event.key-limit");case"data.string":throw new TypeError("event.string-limit")}throw new TypeError("event.payload")}if((Ct??=new TextEncoder).encode(JSON.stringify(e)).byteLength>8192)throw new TypeError("event.size");return e}function v(t,e,i){if("string"==typeof t)return w(t,500);if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("content.surface");y(t,["title","text","link","mountId","announce"]);let s,n=w(t.title,120),o=w(t.text,500);if(void 0!==t.announce&&"boolean"!=typeof t.announce)throw new TypeError("content.announce");if(void 0!==t.mountId&&("string"!=typeof t.mountId||!Jt.test(t.mountId)))throw new TypeError("content.binding");if(void 0!==t.link){if(t.link&&"object"==typeof t.link&&y(t.link,["label","href"]),!t.link||"string"!=typeof t.link.label||"string"!=typeof t.link.href||!r(t.link.href,e))throw new TypeError("content.link");let i=new URL(t.link.href,e);s={label:w(t.link.label,120),href:i.href}}if(!(n||o||s||t.mountId))throw new TypeError("content.empty");return{...n?{title:n}:{},...o?{text:o}:{},...s?{link:s}:{},...t.mountId?{mountId:t.mountId}:{},...!0===t.announce?{announce:!0}:{}}}function y(t,e,i){for(let i of Object.keys(t))if(!e.includes(i))throw new TypeError(Lt("content.field"))}function w(t,e,i){if(void 0!==t){if("string"!=typeof t||t.length<1||t.length>e||/[\u0000-\u001f\u007f]/.test(t))throw new TypeError("content.text");return t}}function b(t,e,i,s,r){let n=e.y-s.height/2-12-r.height,o=e.y+s.height/2+12,h="bottom"===t,a=h?o:n,l=h?n:o;return{x:g("top-left"===t?e.x-s.width/2-12-r.width:"top-right"===t?e.x+s.width/2+12:e.x-r.width/2,8,i.width-r.width-8),y:g(a>=8&&a+r.height<=i.height-8?a:l,8,i.height-r.height-8)}}function g(t,e,i){return Math.max(e,Math.min(t,Math.max(e,i)))}function m(t){return t.replace(/https?:\/\/[^\s]+/gi,"[redacted-url]").replace(/\b(token|secret|password|authorization)=\S+/gi,"$1=[redacted]").slice(0,500)}function k(t){return t.durations?t.durations.reduce((t,e)=>t+e,0):t.frames.length/(t.fps??1)*1e3}function $(t,e){let i=(e%1+1)%1;if(!t?.length)return{advance:i,lift:0};let s=t.findIndex(t=>t.at>=i),r=t[s<0?t.length-1:s],n=t[Math.max(0,(s<0?t.length-1:s)-1)];if(r.at===n.at)return{advance:r.advance,lift:r.lift};let o=(i-n.at)/(r.at-n.at);return{advance:n.advance+(r.advance-n.advance)*o,lift:n.lift+(r.lift-n.lift)*o}}function j(t,e){return t}function x(t,e,i){t.push(j(e))}function E(t,e){throw new ue([j(t)])}function M(t,e,i){return!("string"!=typeof t||!pe.test(t))||(x(i,e),!1)}function O(t,e,i){let s=[];if(!Array.isArray(t)||t.length<1||t.length>3)return x(i,e.path+".limit"),s;let r=new Set;for(let[n,o]of t.entries()){let t=`${e.path}.${n}`;if(!A(o)){x(i,t);continue}z(o,e.native?["src","density","sourceCellSize","sha256"]:["src","density","cellWidth","cellHeight","sha256"],t,i);let h=o.density,a=(1===h||2===h||4===h)&&!r.has(h),l=o.src,c="string"==typeof l&&Gt.test(l)&&(e.native?/\.png$/i:/\.(?:png|webp)$/i).test(l),d=o.sha256,f=M(d,t+".sha256",i),u=e.native?+e.logicalWidth*+h:o.cellWidth,p=e.native?+e.logicalHeight*+h:o.cellHeight;(e.native?o.sourceCellSize===u&&u===p:Number.isInteger(u)&&u>=1&&u<=1024&&Number.isInteger(p)&&p>=1&&p<=1024)?a&&c?f&&(r.add(h),s.push({src:l,density:h,cellWidth:u,cellHeight:p,sha256:d})):x(i,t+".density"):x(i,t+".dimensions")}return s.sort((t,e)=>t.density-e.density)}function S(t,e,i){let s=Object.create(null);if(!A(t))return x(i,"states"),s;let r=Object.entries(t);(0===r.length||r.length>64)&&x(i,"states.limit");for(let[t,n]of r){let r="states."+t;if(!Qt.test(t)||["constructor","prototype","__proto__"].includes(t)||!A(n)){x(i,r);continue}z(n,["frames","fps","loop","durations"],r,i);let o=n.frames,h=n.durations;if(!Array.isArray(o)||0===o.length||o.length>64||o.some(t=>!Number.isInteger(t)||t<0||t>=e)){x(i,r+".frames");continue}let a=void 0!==n.fps,l=void 0!==h,c="number"==typeof n.fps&&Number.isFinite(n.fps)&&n.fps>=.1&&n.fps<=60,d=Array.isArray(h)&&h.length===o.length&&h.every(t=>"number"==typeof t&&Number.isFinite(t)&&t>=16&&t<=1e4)&&h.reduce((t,e)=>t+e,0)<=6e4;a===l||"boolean"!=typeof n.loop||a&&!c||l&&!d?x(i,r+".timing"):s[t]=a?{frames:[...o],loop:n.loop,fps:n.fps}:{frames:[...o],loop:n.loop,durations:[...h]}}return s.idle||x(i,"states.idle"),s}function N(t,e,i){let s=[];if(!Array.isArray(t)||t.length<2||t.length>8)return x(i,e+".limit"),s;for(let[r,n]of t.entries()){let t=`${e}.${r}`,o=s.at(-1);A(n)&&z(n,["at","advance","lift"],t,i),!A(n)||!Number.isFinite(n.at)||!Number.isFinite(n.advance)||!Number.isFinite(n.lift)||n.at<0||n.at>1||n.advance<0||n.advance>1||n.lift<0||n.lift>.5||void 0!==o&&(n.at<=o.at||n.advance<o.advance)?x(i,t):s.push({at:n.at,advance:n.advance,lift:n.lift})}return s.length===t.length&&(0!==s[0].at||0!==s[0].advance||0!==s[0].lift||1!==s.at(-1).at||1!==s.at(-1).advance||0!==s.at(-1).lift)&&x(i,e+".endpoints"),s}function A(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function z(t,e,i,s){for(let r of Object.keys(t))e.includes(r)||x(s,`${i}.${r}`)}function T(t){return ye.every((e,i)=>t[i]===e)}function P(t){return t.byteLength>=12&&"RIFF"===I(t,0)&&"WEBP"===I(t,8)}function I(t,e){return String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])}function D(t,e){return t[e]|t[e+1]<<8|t[e+2]<<16}function R(t,e,i){return(t<1||e<1||t>ve||e>ve)&&E("webp.dimensions"),{width:t,height:e,hasAlpha:i,mimeType:"image/webp"}}function C(t,e,i,s=256){if("string"!=typeof t||0===t.length||t.length>s)x(i,e);else{if(!/[\u0000-\u001f\u007f]/.test(t))return t;x(i,e)}}function U(t,e,i=1){let s=[];try{t=c(t)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}if(!A(t))throw new ue([j("manifest")]);z(t,["format","name","version","license","metadata","assets","states","capabilities","defaults"],"manifest",s),1!==t.format&&x(s,"format");let r=C(t.name,"name",s,64);r&&!Jt.test(r)&&x(s,"name");let n=C(t.version,"version",s,64),o=C(t.license,"license",s,128);n&&!Xt.test(n)&&x(s,"version"),o&&!Bt.test(o)&&x(s,"license");let h,a,l,d,f=0,u=1,p=32,v=32;if(A(t.assets))if(A(t.assets.atlas)){z(t.assets,["atlas"],"assets",s);let e=t.assets.atlas;z(e,["src","columns","rows","density","logicalCellSize","sourceCellSize","sha256"],"assets.atlas",s),h=C(e.src,"assets.atlas.src",s),M(e.sha256,"assets.atlas.sha256",s)&&(a=e.sha256),h&&(!Gt.test(h)||!/\.png$/i.test(h))&&x(s,"assets.atlas.src"),e.columns!==Zt&&x(s,"assets.atlas.columns");let i=[e.density,e.logicalCellSize,e.sourceCellSize],r=i.some(t=>void 0!==t),n=i.every(t=>void 0!==t);r&&!n&&x(s,"assets.atlas.density"),n&&(Ft.includes(e.density)?u=e.density:x(s,"assets.atlas.density"),Ht.includes(e.logicalCellSize)?p=e.logicalCellSize:x(s,"assets.atlas.logicalCellSize"),Number.isInteger(e.sourceCellSize)&&e.sourceCellSize===p*u?v=e.sourceCellSize:x(s,"assets.atlas.sourceCellSize")),!Number.isInteger(e.rows)||e.rows<2||e.rows>we/v?x(s,"assets.atlas.rows"):f=e.rows}else if(A(t.assets.atlases)){z(t.assets,["atlases"],"assets",s);let e=t.assets.atlases;z(e,["columns","rows","logicalCellSize","lineage","variants"],"assets.atlases",s),e.columns!==Zt&&x(s,"assets.atlases.columns"),Ht.includes(e.logicalCellSize)?p=e.logicalCellSize:x(s,"assets.atlases.logicalCellSize"),l=C(e.lineage,"assets.atlases.lineage",s,128),(!l||!/^[a-z0-9][a-z0-9._-]{2,127}$/.test(l))&&x(s,"assets.atlases.lineage"),d=O(e.variants,{path:"assets.atlases.variants",logicalWidth:p,logicalHeight:p,native:!0},s);let r=d.length?L(d.map(t=>t.density),i):void 0,n=d.find(t=>t.density===r);n&&(h=n.src,a=n.sha256,u=n.density,v=n.cellWidth),!Number.isInteger(e.rows)||e.rows<2||e.rows>we/v?x(s,"assets.atlases.rows"):f=e.rows}else x(s,"assets");else x(s,"assets");let y,w=S(t.states,f*Zt,s),b=Object.create(null);if(void 0!==t.capabilities){A(t.capabilities)&&z(t.capabilities,["locomotion"],"capabilities",s);let e=A(t.capabilities)?t.capabilities.locomotion:void 0;if(A(e)&&A(e.directions)){z(e,["directions","motion"],"capabilities.locomotion",s),z(e.directions,_t,"capabilities.locomotion.directions",s);for(let t of _t){let i=e.directions[t];"string"==typeof i&&w[i]?b[t]=i:x(s,"capabilities.locomotion.directions."+t)}if(void 0!==e.motion){let t=A(e.motion)?e.motion.keyframes:void 0;A(e.motion)&&z(e.motion,["keyframes"],"capabilities.locomotion.motion",s);let i=N(t,"capabilities.locomotion.motion.keyframes",s);Array.isArray(t)&&i.length===t.length&&(y=i)}}else x(s,"capabilities.locomotion.directions")}let g=2;if(void 0!==t.defaults&&(A(t.defaults)?(z(t.defaults,["scale"],"defaults",s),void 0!==t.defaults.scale&&(!Number.isInteger(t.defaults.scale)||t.defaults.scale<1||t.defaults.scale>4?x(s,"defaults.scale"):g=t.defaults.scale)):x(s,"defaults")),A(t.metadata)){z(t.metadata,["title","author","description","tags"],"metadata",s),C(t.metadata.description,"metadata.description",s,500),"string"==typeof t.metadata.description&&/:\/\//.test(t.metadata.description)&&x(s,"metadata.description");for(let e of["title","author"])void 0!==t.metadata[e]&&(C(t.metadata[e],"metadata."+e,s,120),"string"==typeof t.metadata[e]&&/:\/\//.test(t.metadata[e])&&x(s,"metadata."+e));void 0!==t.metadata.tags&&(!Array.isArray(t.metadata.tags)||t.metadata.tags.length>16||t.metadata.tags.some(t=>"string"!=typeof t||!be.test(t)))&&x(s,"metadata.tags")}else x(s,"metadata");e&&((e.width!==Zt*v||e.height!==f*v)&&x(s,"atlas.dimensions"),(e.width>we||e.height>we||void 0!==e.byteLength&&e.byteLength>4194304)&&x(s,"atlas.size"));if(s.length||!r||!n||!o||!h||!a)throw new ue(s.length?s:[j("manifest.incomplete")]);let m=t;return{name:r,displayName:m.metadata.title??r,version:n,license:o,atlas:{src:h,sha256:a,columns:Zt,rows:f,cellWidth:v,cellHeight:v,logicalWidth:p,logicalHeight:p,density:u,...l?{lineage:l}:{},...d?{variants:d}:{}},states:w,defaultScale:g,...Object.keys(b).length?{directionalStates:b}:{},...y?{locomotionMotion:y}:{},...m.metadata?{source:{metadata:m.metadata}}:{}}}function L(t,e){let i=[...new Set(t)].sort((t,e)=>t-e);if(!i.length)throw new ue([j("atlas.variants")]);return i.find(t=>t>=e)??i.at(-1)}function W(t){return"string"==typeof t&&t.length>0&&t.length<=512&&!/[\u0000-\u001f\u007f]/.test(t)}function H(t,e,i){let s=[];try{t=c(t)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}if(!A(t)||!A(t.atlas)||!A(t.states))throw new ue([j("normalized.structure")]);z(t,["name","displayName","version","license","atlas","states","defaultScale","directionalStates","locomotionMotion","reactionStates","source"],"normalizedPack",s);for(let e of["name","version","license"])W(t[e])||x(s,"normalized."+e);(!W(t.displayName)||t.displayName.length>120||/:\/\//.test(t.displayName))&&x(s,"normalized.displayName"),"string"==typeof t.version&&t.version.length>64&&x(s,"normalized.version"),W(t.name)&&!Jt.test(t.name)&&x(s,"normalized.name"),W(t.version)&&!Xt.test(t.version)&&x(s,"normalized.version"),W(t.license)&&!Bt.test(t.license)&&x(s,"normalized.license");let r=t.atlas;z(r,["src","columns","rows","cellWidth","cellHeight","logicalWidth","logicalHeight","density","lineage","sha256","variants"],"atlas",s);let n=[["columns",256],["rows",4096],["cellWidth",1024],["cellHeight",1024]];for(let[t,e]of n)(!Number.isInteger(r[t])||r[t]<1||r[t]>e)&&x(s,"atlas."+t);(!W(r.src)||!Gt.test(r.src)||!/\.(?:png|webp)$/i.test(r.src))&&x(s,"atlas.src");let o=+r.columns,h=+r.rows,a=+r.cellWidth,l=+r.cellHeight;for(let t of["logicalWidth","logicalHeight"])void 0!==r[t]&&(!Number.isInteger(r[t])||r[t]<1||r[t]>256)&&x(s,"atlas."+t);void 0!==r.density&&![1,2,4].includes(r.density)&&x(s,"atlas.density"),void 0!==r.lineage&&(!W(r.lineage)||!/^[a-z0-9][a-z0-9._-]{2,127}$/.test(r.lineage))&&x(s,"atlas.lineage");let d=void 0===r.variants?[]:O(r.variants,{path:"atlas.variants"},s),f=void 0===r.sha256?void 0:M(r.sha256,"atlas.sha256",s)?r.sha256:void 0;void 0===r.variants&&void 0===r.sha256&&M(void 0,"atlas.sha256",s);let u=[1,2,4].includes(r.density)?r.density:1,v=Number.isInteger(r.logicalWidth)?r.logicalWidth:a/u,y=Number.isInteger(r.logicalHeight)?r.logicalHeight:l/u,w=d.length?L(d.map(t=>t.density),i??u):u,b=d.find(t=>t.density===w),g=b?.sha256??f,m=b?.src??r.src,k=b?.cellWidth??a,$=b?.cellHeight??l;(!Number.isInteger(v)||!Number.isInteger(y)||k!==v*w||$!==y*w)&&x(s,"atlas.logical-cell");let E=o*h;(o*k>4096||h*$>4096)&&x(s,"atlas.size");let T=S(t.states,E,s);(!Number.isInteger(t.defaultScale)||t.defaultScale<1||t.defaultScale>4)&&x(s,"normalized.defaultScale");let P={};if(void 0!==t.directionalStates)if(A(t.directionalStates)){z(t.directionalStates,_t,"directionalStates",s);for(let e of _t){let i=t.directionalStates[e];void 0!==i&&("string"==typeof i&&T[i]?P[e]=i:x(s,"directionalStates."+e))}}else x(s,"directionalStates");let I={};if(void 0!==t.reactionStates)if(!A(t.reactionStates)||Object.keys(t.reactionStates).length>32)x(s,"reactionStates.limit");else for(let[e,i]of Object.entries(t.reactionStates))/^[a-z][a-z0-9-]{0,63}$/.test(e)&&"string"==typeof i&&T[i]?I[e]=i:x(s,"reactionStates."+e);let D,R=[];void 0!==t.locomotionMotion&&(R=N(t.locomotionMotion,"locomotionMotion",s)),e&&(e.width!==o*k||e.height!==h*$)&&x(s,"atlas.pixels"),void 0!==e?.byteLength&&(!Number.isSafeInteger(e.byteLength)||e.byteLength<1||e.byteLength>33554432)&&x(s,"atlas.size");if(void 0!==t.source)try{let e=p(t.source);if(!A(e))throw new TypeError("normalized.source");D=Object.freeze({...e})}catch(t){x(s,"normalized.source")}if(s.length||!g)throw new ue(s.length?s:[j("atlas.sha256")]);return{name:t.name,displayName:W(t.displayName)?t.displayName:t.name,version:t.version,license:t.license,atlas:{src:m,sha256:g,columns:o,rows:h,cellWidth:k,cellHeight:$,logicalWidth:v,logicalHeight:y,density:w,..."string"==typeof r.lineage?{lineage:r.lineage}:{},...d.length?{variants:d}:{}},states:T,defaultScale:t.defaultScale,...Object.keys(P).length?{directionalStates:P}:{},...R.length?{locomotionMotion:R}:{},...Object.keys(I).length?{reactionStates:I}:{},...D?{source:D}:{}}}function Z(t){return Object.hasOwn(ge,t)}function F(t,e){let i=t.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return(!i||!e.includes(i))&&E("mime.invalid"),i}function _(t){if(t instanceof DOMException&&"AbortError"===t.name)return"abort";if(t instanceof fe)return t.category;if(t instanceof ue)for(let e of t.issueCodes){let t=e.slice(e.indexOf(".")+1);if("hash"===t)return"hash";if("mime.invalid"===e||"mime"===t)return"mime";if(e.startsWith("png.")||e.startsWith("webp.")||e.startsWith("atlas.")&&["dimensions","pixels","alpha","size"].includes(t))return"image";if("size"===t)return"size";if(t.startsWith("integrity-"))return"integrity"}return"validation"}function V(t,e){return e.aborted||t instanceof DOMException&&"AbortError"===t.name}async function q(t,e,i,s){let r=((t,e,i)=>{let s=new AbortController,r=!1,n=()=>s.abort(t.reason);t.aborted?n():t.addEventListener("abort",n,{once:!0});let o=globalThis.setTimeout(()=>{s.signal.aborted||(r=!0,s.abort(new DOMException(i,"TimeoutError")))},e);return{signal:s.signal,get timedOut(){return r},close(){globalThis.clearTimeout(o),t.removeEventListener("abort",n)}}})(t,e,i);try{return await s(r.signal)}catch(t){throw r.timedOut&&(t===r.signal.reason||t instanceof DOMException&&("AbortError"===t.name||"TimeoutError"===t.name))?new fe(i,"timeout",i,t):t}finally{r.close()}}async function J(t,e,i,s){try{return await t(e,{signal:i})}catch(t){throw V(t,i)?t:new fe(s,"network",s,t)}}async function K(t,e,i,s){try{return await(async(t,e,i)=>{let s=+t.headers.get("content-length");if(Number.isFinite(s)&&s>e&&E("resource.size"),!t.body){let i=new Uint8Array(await t.arrayBuffer());return i.byteLength>e&&E("resource.size"),i}let r=t.body.getReader(),n=[],o=0;try{for(;;){i.throwIfAborted();let{done:t,value:s}=await r.read();if(t)break;o+=s.byteLength,o>e&&(await r.cancel(),E("resource.size")),n.push(s)}}catch(t){try{await r.cancel(t)}catch{}throw t}finally{r.releaseLock()}let h=new Uint8Array(o),a=0;for(let t of n)h.set(t,a),a+=t.byteLength;return h})(t,e,i)}catch(t){throw V(t,i)||t instanceof fe||t instanceof ue?t:new fe(s,"network",s,t)}}async function Q(t,e,i=!1){let s,r=i?"manifest":"atlas";pe.test(e)||E(r+".integrity-declaration");try{let t=globalThis.crypto?.subtle;s=t?.digest.bind(t)}catch{}s||E(r+".integrity-unavailable");try{return!new Uint8Array(await s("SHA-256",t)).some((t,i)=>t!==Number.parseInt(e.slice(2*i,2*i+2),16))}catch{E(r+".integrity-failed")}}function X(t,e,i=4){let s=Number.isFinite(t)&&t>0?t:1;return Math.min(s*e,i)}function B(t,e={}){let i=l(t);ht(i),at(i,["baseline","rules"]),i.baseline||ut("missing-baseline");let s=G(i.baseline,0,e,!1);s.until&&ut("invalid-baseline-interrupt"),s.channels.includes("state")||ut("missing-baseline-state"),s.state||ut("missing-baseline-state");for(let[t,e]of Y(s).entries())e.ordering&&ut("invalid-ordering-source");let r=void 0===i.rules?[]:i.rules;(!Array.isArray(r)||r.length>64)&&ut("rule-limit");let n=new Set,o=r.map((t,i)=>{ht(t),at(t,["id","when","effect"]),lt(t.id),n.has(t.id)&&ut("duplicate-rule"),n.add(t.id);let s=((t,e,i)=>(ht(t),"application"===t.source?(at(t,["source","event","coalesce"]),("string"!=typeof t.event||!Kt.test(t.event))&&ut("invalid-condition"),it(t.coalesce),ft({source:"application",event:t.event,...t.coalesce?{coalesce:t.coalesce}:{}})):("browser"!==t.source&&ut("invalid-condition"),Vt.includes(t.event)||ut("invalid-condition"),"section.visibility"!==t.event?(at(t,["source","event","coalesce"]),it(t.coalesce),"window.scroll"===t.event?ft({source:"browser",event:"window.scroll",...t.coalesce?{coalesce:t.coalesce}:{}}):(t.coalesce&&ut("unsafe-coalescing"),ft({source:"browser",event:t.event}))):(at(t,["source","event","selector","phase","threshold"]),((t,e,i)=>{if(("string"!=typeof t||t.length<1||t.length>256||/[\0\r\n]/.test(t))&&ut("invalid-selector"),!i)return;let s=!1;try{s=i(t)}catch{s=!1}s||ut("invalid-selector")})(t.selector,0,i.validateSelector),["enter","while-visible","leave"].includes(t.phase)||ut("invalid-condition"),void 0!==t.threshold&&("number"!=typeof t.threshold||!Number.isFinite(t.threshold)||t.threshold<=0||t.threshold>1)&&ut("invalid-threshold"),ft({source:"browser",event:"section.visibility",selector:t.selector,phase:t.phase,...void 0===t.threshold?{}:{threshold:t.threshold}})))))(t.when,0,e),r=G(t.effect,0,e,!0);"browser"===s.source&&("pointer.move"===s.event||"section.visibility"===s.event&&"while-visible"===s.phase)&&(void 0!==t.effect.surfaces||r.until)&&ut("invalid-continuous-effect");for(let t of Y(r))"event-payload"===et(t)&&"application"!==s.source&&ut("invalid-payload-source"),t.ordering&&"application"!==s.source&&ut("invalid-ordering-source");return ft({id:t.id,when:s,effect:r})});return((t,e)=>{let i=new Set(Y(t).map(tt)),s=new Map,r=new Map;for(let t of e)for(let e of Y(t.effect)){let n=tt(e);i.has(n)&&!e.disposition&&ut("ambiguous-channel");let o=s.get(n)??[];o.push(t),s.set(n,o);let h=e.ordering;if(!h)continue;let a=r.get(n);a?(a.sessionField!==h.sessionField&&ut("ambiguous-ordering"),h.revisionField&&a.revisionField&&a.revisionField!==h.revisionField&&ut("ambiguous-ordering"),h.revisionField&&!a.revisionField&&(a.revisionField=h.revisionField)):r.set(n,{sessionField:h.sessionField,...h.revisionField?{revisionField:h.revisionField}:{}})}for(let[t,e]of s)e.length<2||e.filter(e=>Y(e.effect).some(e=>tt(e)===t&&!e.disposition)).length&&ut("ambiguous-channel")})(s,o),(t=>{let e=new Map;for(let i of t){let t=`${i.when.source}:${i.when.event}`,s=e.get(t)??[];s.push(i),e.set(t,s)}for(let[t,i]of e)new Set(i.map(t=>t.when.coalesce??"fifo")).size>1&&ut("ambiguous-coalescing"),"latest"===i[0]?.when.coalesce&&"application"===i[0].when.source&&(i.every(t=>t.effect.channels.every(t=>t.startsWith("surface:"))&&Y(t.effect).length>0&&Y(t.effect).every(t=>t.ordering?.revisionField))||ut("unsafe-coalescing"),1!==new Set(i.flatMap(t=>Y(t.effect).map(t=>`${t.ordering.sessionField}\0${t.ordering.revisionField}`))).size&&ut("ambiguous-coalescing"))})(o),ft({baseline:s,rules:ft(o)})}function G(t,e,i,s){ht(t),at(t,["channels","state","motion","surfaces","until"]),(!Array.isArray(t.channels)||!t.channels.length||t.channels.length>16)&&ut("invalid-channels");let r=t.channels.map((t,e)=>(("string"!=typeof t||!me.test(t))&&ut("invalid-channel"),t));new Set(r).size!==r.length&&ut("duplicate-channel");let n=void 0===t.state?void 0:((t,e,i)=>(ht(t),"state"in t?(at(t,["state"]),("string"!=typeof t.state||!Qt.test(t.state))&&ut("invalid-state"),i.states&&!i.states.has(t.state)&&ut("unknown-state"),ft({kind:"state",name:t.state})):(at(t,["capability"]),"locomotion"!==t.capability&&ut("invalid-capability"),i.capabilities&&!i.capabilities.has(t.capability)&&ut("unknown-capability"),ft({kind:"capability",name:t.capability}))))(t.state,0,i),o=void 0===t.motion?void 0:((t,e,i)=>{switch(ht(t),t.type){case"follow-pointer":at(t,["type","speed","arrivalRadius"]),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"horizontal-patrol":at(t,["type","speed","edgeInset"]),dt(t.speed,0,1,1e3),dt(t.edgeInset,0,0,1e3);break;case"viewport-traverse":at(t,["type","speed","edgeInset","clockwise"]),dt(t.speed,0,1,1e3),dt(t.edgeInset,0,0,1e3),void 0!==t.clockwise&&"boolean"!=typeof t.clockwise&&ut("invalid-motion");break;case"move-to":at(t,["type","x","y","speed","arrivalRadius"]),dt(t.x,0,-1e5,1e5),dt(t.y,0,-1e5,1e5),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"move-to-target":at(t,["type","target","anchor","speed","arrivalRadius"]),lt(t.target),i.targets&&!i.targets.has(t.target)&&ut("unknown-target"),void 0!==t.anchor&&!["center","top","right","bottom","left"].includes(t.anchor)&&ut("invalid-motion"),dt(t.speed,0,1,1e3),dt(t.arrivalRadius,0,0,1e3);break;case"jump-to":at(t,["type","x","y","duration","height"]),dt(t.x,0,-1e5,1e5),dt(t.y,0,-1e5,1e5),dt(t.duration,0,100,1e4),dt(t.height,0,0,2e3);break;case"svg-path":at(t,["type","path","duration","loop","relative"]),("string"!=typeof t.path||t.path.length<1||t.path.length>4096||/[\0\r\n]/.test(t.path))&&ut("invalid-path"),i.validatePath&&!i.validatePath(t.path)&&ut("invalid-path"),dt(t.duration,0,100,6e4);for(let e of["loop","relative"])void 0!==t[e]&&"boolean"!=typeof t[e]&&ut("invalid-motion");break;default:ut("invalid-motion")}return ft({...t})})(t.motion,0,i),h=void 0===t.surfaces?[]:t.surfaces;(!Array.isArray(h)||h.length>8)&&ut("surface-limit");let a=h.map((t,e)=>((t,e,i,s)=>{ht(t),at(t,["id","contentId","data","disposition","ordering"]),lt(t.id),lt(t.contentId),i.contentIds&&!i.contentIds.has(t.contentId)&&ut("unknown-content"),"event-payload"===t.data&&!s&&ut("invalid-surface-data"),void 0!==t.disposition&&!["update","replace","ignore","interrupt"].includes(t.disposition)&&ut("invalid-disposition");let r,n=void 0===t.ordering?void 0:(t=>(ht(t),at(t,["sessionField","revisionField","terminal"]),ct(t.sessionField),void 0!==t.revisionField&&ct(t.revisionField),void 0!==t.terminal&&"boolean"!=typeof t.terminal&&ut("invalid-ordering"),!t.terminal&&!t.revisionField&&ut("invalid-ordering"),ft({sessionField:t.sessionField,...t.revisionField?{revisionField:t.revisionField}:{},...t.terminal?{terminal:!0}:{}})))(t.ordering);if(void 0!==t.data&&"event-payload"!==t.data)try{r=p(t.data)}catch{ut("invalid-surface-data")}return ft({id:t.id,channel:"surface:"+t.id,contentId:t.contentId,..."event-payload"===t.data?{dataSource:"event-payload"}:{},...void 0===r?{}:{data:r},...t.disposition?{disposition:t.disposition}:{},...n?{ordering:n}:{}})})(t,0,i,s)),l=new Set;for(let t of a){let e=tt(t);l.has(e)&&ut("duplicate-surface"),l.add(e)}let c=void 0===t.until?void 0:(t=>(ht(t),"duration"===t.type?(at(t,["type","ms"]),void 0===t.ms&&ut("missing-interrupt-duration"),dt(t.ms,0,1,36e5),ft({type:"duration",ms:t.ms})):("event"!==t.type&&ut("invalid-interrupt-lifetime"),at(t,["type","name","timeout"]),("string"!=typeof t.name||!Kt.test(t.name))&&ut("invalid-interrupt-lifetime"),u(t.name)&&ut("invalid-interrupt-lifetime"),dt(t.timeout,0,1,36e5),ft({type:"event",name:t.name,...void 0===t.timeout?{}:{timeout:t.timeout}}))))(t.until);a.filter(t=>"interrupt"===t.disposition).length&&!c&&ut("missing-interrupt-lifetime"),c&&a.some(t=>"interrupt"!==t.disposition)&&ut("mixed-interrupt-effect"),n&&!r.includes("state")&&ut("undeclared-channel"),!n&&r.includes("state")&&ut("missing-channel-output"),o&&!r.includes("motion")&&ut("undeclared-channel"),!o&&r.includes("motion")&&ut("missing-channel-output");let d=a.map(tt);for(let t of r)t.startsWith("surface:")&&!d.includes(t)&&ut("missing-channel-output");for(let t of d)r.includes(t)||ut("undeclared-channel");return ft({channels:ft(r),...n?{state:n}:{},...o?{motion:o}:{},surfaces:ft(a),...c?{until:c}:{}})}function Y(t){return t.surfaces??[]}function tt(t){return"channel"in t?t.channel:"surface:"+t.id}function et(t){return"dataSource"in t?t.dataSource:"event-payload"===t.data?"event-payload":void 0}function it(t,e){void 0!==t&&"latest"!==t&&ut("invalid-coalescing")}function st(t,e){let i=Y(t).map(t=>ft({...t,..."event-payload"===et(t)?{data:e}:{}}));return ft({...t,surfaces:ft(i)})}function rt(t,e,i,s){for(let r of t){let t=r.ordering;if(!t)continue;if(!s||"object"!=typeof s||Array.isArray(s))return"invalid";let n=s,o=n[t.sessionField];if("string"!=typeof o&&"number"!=typeof o)return"invalid";let h=`${tt(r)}\0${typeof o}\0${o+""}`,a=e.ordering.get(h);if(!0===a)return"closed";let l=i.ordering.get(h),c="number"==typeof l?l:a;if(t.revisionField){let e=n[t.revisionField];if(!Number.isSafeInteger(e)||e<0)return"invalid";if("number"==typeof a&&e<=a||"number"==typeof l&&e<l)return"stale";c=e}i.ordering.set(h,!(!t.terminal&&!0!==l)||c)}return"matched"}function nt(t,e){if(!e.length)return;if(e.length===t.channels.length)return t;let i=new Set(e);return ft({channels:ft(e),...i.has("state")&&t.state?{state:t.state}:{},...i.has("motion")&&t.motion?{motion:t.motion}:{},surfaces:ft(Y(t).filter(t=>i.has(tt(t)))),...t.until?{until:t.until}:{}})}function ot(t,e,i){for(let[i,s]of e.ordering)t.ordering.set(i,s);for(let s of e.ordering.keys()){let e=t.sessions.get(i)??[],r=e.indexOf(s);for(r>=0&&e.splice(r,1),e.push(s),t.sessions.set(i,e);e.length>64;)t.ordering.delete(e.shift())}}function ht(t,e){(!t||"object"!=typeof t||Array.isArray(t))&&ut("invalid-object")}function at(t,e,i){for(let i of Object.keys(t))e.includes(i)||ut("unknown-field")}function lt(t,e,i){("string"!=typeof t||!/^[a-z][a-z0-9:-]{0,63}$/.test(t))&&ut("invalid-id")}function ct(t,e){("string"!=typeof t||!ke.test(t))&&ut("invalid-ordering")}function dt(t,e,i,s){void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<i||t>s)&&ut("out-of-range")}function ft(t){return Object.freeze(t)}function ut(t,e,i){throw new $e(t,"",t)}function pt(t,e,i){let s=Math.min(e.viewport.width/2,e.t.width/2+(t.edgeInset??0)),r=e.viewport.width-s,n=e.t.height/2,o=Math.max(n,e.viewport.height-n),h=wt(t,e.position,i?r:s,o);return h||(h=wt(t,e.position,(i=!i)?r:s,o)),[i,h]}function vt(t,e){let i=e.t;return i?{x:Math.max(i.width/2,Math.min(e.viewport.width-i.width/2,t.x)),y:Math.max(i.height/2,Math.min(e.viewport.height-i.height/2,t.y))}:{x:t.x,y:t.y}}function yt(t,e,i=0){let s=e.x-t.x,r=e.y-t.y,n=Math.hypot(s,r);return{x:n?s/n:0,y:n?r/n:0,speed:0,maxDistance:n,lift:i,direct:!0}}function wt(t,e,i,s,r=0,n){let o=n?.t,h=n?.viewport;if(o&&h){let t=i,e=s;i=Math.max(o.width/2,Math.min(h.width-o.width/2,i)),s=Math.max(o.height/2,Math.min(h.height-o.height/2,s)),(i!==t||s!==e)&&(r=0)}let a=i-e.x,l=s-e.y,c=Math.hypot(a,l),d=c-r;if(!(d<=4))return{x:a/c,y:l/c,speed:t.speed??160,maxDistance:d}}function bt(t){return void 0===t||"boolean"==typeof t||kt(t,80)}function gt(t,e,i,s,r){if(!(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(t)&&($t(e,i),xe))return;let n=t;return s&&mt(n,s,i),n}function mt(t,e,i,s){for(let s of Object.keys(t))e.includes(s)||$t("unknown-field",`${i}.${s}`)}function kt(t,e){return"string"==typeof t&&t.length>0&&t.length<=e&&!/[\u0000-\u001f\u007f]/.test(t)}function $t(t,e,i,s){throw new Me(t,e,t)}function jt(t,e,i){throw new Me(t,e,t)}function xt(t){return f(t)?"browser":"application"}function Et(t){let e=t.until;return"duration"===e?.type?e.ms:"event"===e?.type&&void 0!==e.timeout?e.timeout:"manual"===e?.type&&void 0!==e.maxMs?e.maxMs:Oe}function Mt(t,e){if("number"!=typeof t||!Number.isFinite(t)||t<1||t>Oe)throw new TypeError("override.lifetime")}function Ot(t,e,i){for(let i of Object.keys(t))if(!e.includes(i))throw new TypeError(Lt("override.unknown-field"))}function St(t,e=1){let i=Number.isFinite(e)&&e>0?e:1;return Math.round(t*i)/i}function Nt(t){let e=t.target,i="function"==typeof e.closest?e:e.parentElement;try{return!!i?.closest?.("[data-peekling-host],[data-peekling-content],[data-peekling-controls]")}catch{return!1}}function At(t,e=Date.now()){try{if("1"===t.sessionStorage.getItem(Re))return[!0];let i=JSON.parse(t.localStorage.getItem(De)??"null");if("hidden"!==i?.visibility)return[!1];if(null===i.until)return[!0];if(Number.isFinite(i.until)&&i.until>e)return[!0,i.until];t.localStorage.removeItem(De)}catch{}return[!1]}function zt(t,e){let i=Ce.findIndex(t=>t[1]===e);if(i<0)throw new TypeError("visibility.duration");let s=new Date,r=i>2?void 0:i<2?s.getTime()+6e4*(i?60:10):new Date(s.getFullYear(),s.getMonth(),s.getDate()+1).getTime();try{if(t.sessionStorage.removeItem(Re),3===i)return t.localStorage.removeItem(De),t.sessionStorage.setItem(Re,"1"),r;t.localStorage.setItem(De,JSON.stringify({visibility:"hidden",until:4===i?null:r}))}catch{}return r}function Tt(t){try{t.localStorage.removeItem(De),t.sessionStorage.removeItem(Re)}catch{}}function Pt(t,e,i,s){return{x:Math.max(i/2,Math.min(e.width-i/2,t.x)),y:Math.max(s/2,Math.min(e.height-s/2,t.y))}}function It(t){try{globalThis.dispatchEvent(new CustomEvent("peekling:collision",{detail:t}))}catch{}}function Dt(){let t,e,i=new Promise((i,s)=>{t=i,e=s});return i.catch(()=>{}),[i,t,e]}var Rt,Ct,Ut,Lt=t=>t,Wt=class{ready;#t;#e;#i=!1;#s=()=>{};constructor(t,e,i){let s=t.createElement("link");this.#t=s,s.rel="stylesheet",s.href=i.url,s.crossOrigin="anonymous",s.referrerPolicy="no-referrer",i.integrity&&(s.integrity=i.integrity),this.ready=new Promise((t,e)=>{this.#s=e;let i=(t,i)=>{this.#i||(this.#i=!0,e(Error(t)))};s.addEventListener("load",()=>{if(this.#i)return;let e=s.sheet;e&&"function"==typeof e.insertRule?(this.#e=e,this.#i=!0,t()):i("styles.cssom")},{once:!0}),s.addEventListener("error",()=>i("styles.load"),{once:!0})}),this.ready.catch(()=>{}),e.append(s)}addRule(t){if(!this.#e)throw Error("styles.pending");let e=this.#e.cssRules.length;this.#e.insertRule(t+"{}",e);let i=this.#e.cssRules[e];if(!i?.style)throw Error("styles.rule");return i.style}removeRule(t){let e=this.#e;if(e)for(let i=e.cssRules.length-1;i>=0;i--)if(e.cssRules[i]?.style===t){e.deleteRule(i);return}}destroy(){this.#i||(this.#i=!0,this.#s(new DOMException("styles.cancelled","AbortError"))),this.#t.remove(),this.#e=void 0}},Ht=[32,64],Zt=16,Ft=[1,2,4],_t=["N","NE","E","SE","S","SW","W","NW"],Vt=["pointer.click","pointer.move","document.visibility","window.focus","window.scroll","section.visibility","page.lifecycle"],qt=["top-left","top-center","top-right","bottom"],Jt=/^(?!peekling:)[a-z][a-z0-9:-]{0,63}$/,Kt=/^(?=.{1,64}$)[a-z][a-z0-9]*(?:[.:-][a-z][a-z0-9-]*)*$/,Qt=/^(?=.{1,64}$)[a-z][a-z0-9-]*(?::[A-Za-z0-9.-]+)?$/,Xt=/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,Bt=/^(?:[A-Za-z0-9][A-Za-z0-9.-]{0,63}|DocumentRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31}:LicenseRef-[A-Za-z0-9][A-Za-z0-9.-]{0,31})$/,Gt=/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*\/\/)[A-Za-z0-9._/-]{1,256}$/,Yt=/^(?:transparent|#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8}))(?![\s\S])/,te=class extends TypeError{issueCode;constructor(t,e,i){super(`${t} ${e}`),this.name="OwnDataError",this.issueCode=i}},ee=new WeakSet,ie=new WeakSet,se=new WeakSet,re=/^[A-Za-z0-9_.:-]{1,64}$/,ne=Object.freeze({json:!0,key(t){return re.test(t)},maxArrayLength:64,maxDepth:6,maxObjectKeys:64,maxStringLength:2048,maxValues:256}),oe=class{ready;#t;#e;#i;#s=new Map;#r;#n;#o;#h;#a;#l;#c;#d;#f=0;#u=0;#p=!0;#v=NaN;#y=NaN;#w=NaN;#b=NaN;#g=NaN;#m=NaN;#k;#$;#j;#x=!1;#E=!1;#M=!1;constructor(t,e={}){this.#t=t,this.#r=new URL(t.baseURI??globalThis.location?.href??"https://peekling.invalid/").origin,this.#n=e.i??(()=>{}),this.#o=e.bindings??{},this.#h=!0===e.announce,this.#a=e.emit??(()=>({accepted:!1,reason:"not-ready"})),this.#l=e.wake??(()=>{}),this.#e=t.createElement("aside"),this.#e.hidden=!0,this.#e.dataset.peeklingContent="",this.#d=e.label??"Peekling content",this.#e.setAttribute("aria-label",this.#d),this.#i=this.#e.attachShadow({mode:"closed"}),this.#c=new Wt(t,this.#i,e.styles??i(void 0,t.baseURI??"https://peekling.invalid/")),this.ready=this.#c.ready.then(()=>{this.#M||((t,e)=>{if(!e)return;let i=[["--peekling-surface-background",e.background,""],["--peekling-surface-color",e.color,""],["--peekling-surface-link",e.linkColor,""],["--peekling-surface-border",e.borderColor,""],["--peekling-surface-radius",e.radius,"px"],["--peekling-surface-width",e.width,"px"],["--peekling-surface-padding",e.padding,"px"]];for(let[e,s,r]of i)void 0!==s&&t.setProperty(e,`${s}${r}`)})(this.#c.addRule(":host"),e.theme)}),this.ready.catch(()=>{}),this.#O()}o(t,e,i,s,r,n){if(this.#M||(this.#O(),this.#M))return;if(this.#u+=1,this.#u>=Number.MAX_SAFE_INTEGER){this.#u=1;for(let t of this.#s.values())t.seen=0}let o=this.#u;for(let i of t)if(Object.hasOwn(e,i.contentId)&&(this.#S(i,e[i.contentId],o),this.#M))return;if(n){if(n!==this.#k&&(this.#k=n,this.#$={id:"peekling:name",contentId:"peekling:name",key:"peekling:name:"+n},this.#j={bottom:n}),this.#S(this.#$,this.#j,o),this.#M)return}else this.#k=void 0,this.#$=void 0,this.#j=void 0;for(let t of this.#s.values())if(t.seen!==o&&this.#N(t),this.#M)return;let h=!1;for(let t of this.#s.values())if(!t.host.hidden){h=!0;break}this.#E=h;let a=this.#x||!h;this.#e.hidden!==a&&(this.#e.hidden=a);let l=s.width!==this.#w||s.height!==this.#b,c=l||i.x!==this.#v||i.y!==this.#y||r.width!==this.#g||r.height!==this.#m;if(this.#v=i.x,this.#y=i.y,this.#w=s.width,this.#b=s.height,this.#g=r.width,this.#m=r.height,l)for(let t of this.#s.values())t.host.hidden||(t.measureDirty=!0);c&&(this.#p=!0);for(let t of this.#s.values()){if(t.host.hidden||!t.measureDirty)continue;let e=t.host.getBoundingClientRect();if(this.#M)return;t.measuredWidth=e.width,t.measuredHeight=e.height,t.measureDirty=!1,this.#p=!0}if(this.#p){let t=0,e=0,n=0,o=0,h=[...this.#s.values()].sort((t,e)=>t.key<e.key?-1:t.key>e.key?1:0);for(let a of h){if(a.host.hidden)continue;let h;switch(a.region){case"top-left":h=t,t+=a.measuredHeight+8;break;case"top-center":h=e,e+=a.measuredHeight+8;break;case"top-right":h=n,n+=a.measuredHeight+8;break;case"bottom":h=o,o+=a.measuredHeight+8}let l=b(a.region,i,s,r,{width:a.measuredWidth,height:a.measuredHeight}),c=l.x+"px",d=g(l.y+h,8,s.height-a.measuredHeight-8)+"px";if(a.left!==c){if(a.h.left=c,this.#M)return;a.left=c}if(a.top!==d){if(a.h.top=d,this.#M)return;a.top=d}}this.#p=!1}}setUserHidden(t){if(this.#M)return!1;let e=this.#x;if(this.#x=t,this.#e.hidden=t||!this.#E,e&&!t&&!this.#e.hidden){for(let t of this.#s.values())t.host.hidden||(t.measureDirty=!0);this.#p=!0,this.#l()}return!this.#x}toggleUserHidden(){return this.setUserHidden(!this.#x)}get userHidden(){return this.#x}#S(t,e,i){for(let s of qt){let r=e[s];if(void 0===r)continue;let n=`${t.id}\0${s}`,o=this.#s.get(n)??this.#A(n,t.id,t.contentId,s);if(o.seen=i,o.contentId!==t.contentId&&(o.contentId=t.contentId,this.#z(o)),this.#T(o,r,t),this.#M)return}}#z(t,e=!1){t.measureDirty=!0,this.#p=!0,e&&!this.#M&&this.#l()}#P(t,e){t.host.hidden!==e&&(t.host.hidden=e,this.#p=!0,e||(t.measureDirty=!0))}#A(t,e,i,s){let r=this.#t.createElement("section"),n="peekling-position-"+ ++this.#f;r.className=`surface ${s} ${n}`,r.hidden=!0,r.setAttribute("part","surface "+s),r.dataset.peeklingSurface=e;let o=this.#t.createElement("strong");o.className="title";let h=this.#t.createElement("p"),a=this.#t.createElement("a"),l=this.#t.createElement("div");l.dataset.peeklingMount="",r.append(o,h,a,l),this.#i.append(r);let c={key:t,surfaceId:e,contentId:i,region:s,host:r,title:o,text:h,link:a,l,u:void 0,p:"",v:"",seen:0,measureDirty:!0,measuredWidth:0,measuredHeight:0,left:"",top:"",h:this.#c.addRule("."+n)};return this.#s.set(t,c),this.#p=!0,c}#T(t,e,i){if(this.#M)return;if(t.primitive!==e){t.primitive=e,t.item="string"==typeof e?{text:e}:e;let i=t.item;this.#z(t),t.title.textContent=i.title??"",t.title.hidden=!!i.mountId||!i.title,t.text.textContent=i.text??"",t.text.hidden=!!i.mountId||!i.text,t.link.hidden=!!i.mountId||!i.link,!i.mountId&&i.link?(t.link.textContent=i.link.label,t.link.href=i.link.href,new URL(i.link.href).origin!==this.#r?(t.link.target="_blank",t.link.rel="noopener noreferrer"):(t.link.removeAttribute("target"),t.link.removeAttribute("rel"))):(t.link.textContent="",t.link.removeAttribute("href"),t.link.removeAttribute("target"),t.link.removeAttribute("rel")),i.announce||this.#h?(t.host.setAttribute("aria-live","polite"),t.host.setAttribute("aria-atomic","true")):(t.host.removeAttribute("aria-live"),t.host.removeAttribute("aria-atomic"))}let s=t.item;if(s.mountId){if(t.v===`${s.mountId}\0${i.key}`){this.#P(t,!0);return}t.v&&(t.v=""),this.#I(t,s.mountId,i)}else t.v="",this.#D(t);this.#M||this.#P(t,!1)}#I(t,e,i){if(this.#M)return;let s,r=`${e}\0${i.key}`;if(t.u?.mountId===e&&t.p===r)return;try{s=p(i.data)}catch{this.#R(t,"data-failed",r);return}if(t.u?.mountId===e){if(t.p=r,t.u.data=s,t.u.result?.update){this.#C(t,t.u,s);return}if(!t.u.result){t.u.m=!0,t.u.key=i.key;return}this.#D(t)}else this.#D(t);if(this.#M)return;let n=this.#o.mounts,o=n&&Object.hasOwn(n,e)?n[e]:void 0;if(!o){this.#R(t,"mount-binding-is-missing",r);return}let h,a=new AbortController,l=this.#t.createElement("div"),c={mountId:e,abort:a,root:l,result:void 0,data:s,m:!1,updating:!1,key:i.key};t.u=c,t.p=r,t.l.replaceChildren(l),this.#z(t);try{h=o(Object.freeze({surfaceId:t.surfaceId,contentId:t.contentId,region:t.region,root:l,...void 0===s?{}:{data:s},signal:a.signal,emit:this.#a}))}catch{this.#R(t,"mount-failed",r);return}Promise.resolve(h).then(i=>{let s=(t=>{if(!t||"object"!=typeof t)return;let e;try{e=Object.getOwnPropertyDescriptors(t)}catch{return}let i=e.cleanup,s=e.update;return i&&"value"in i&&"function"==typeof i.value&&(!s||"value"in s&&"function"==typeof s.value)?Object.freeze({cleanup:i.value,...s?{update:s.value}:{}}):void 0})(i);if(this.#M||t.u!==c||a.signal.aborted)s&&this.#U(s,t);else if(s){if(c.result=s,this.#z(t,!0),c.m)if(c.m=!1,s.update)this.#C(t,c,c.data);else{let i={id:t.surfaceId,contentId:t.contentId,...void 0===c.data?{}:{data:c.data},key:c.key};this.#D(t),this.#I(t,e,i)}}else this.#R(t,"mount-failed",r)},()=>{!this.#M&&t.u===c&&!a.signal.aborted&&this.#R(t,"mount-failed",r)})}#C(t,e,i){if(this.#M)return;let s=e.result?.update;if(s){if(e.updating){e.m=!0;return}e.updating=!0,this.#z(t);try{let r=s(i);Promise.resolve(r).then(()=>{this.#M||t.u!==e||(e.updating=!1,this.#z(t,!0),e.m&&(e.m=!1,this.#C(t,e,e.data)))},()=>{!this.#M&&t.u===e&&this.#R(t,"update-failed",t.p)})}catch{!this.#M&&t.u===e&&this.#R(t,"update-failed",t.p)}}}#R(t,e,i=t.p){this.#M||(this.#n("content."+e),!this.#M&&(this.#D(t),!this.#M&&(t.v=i,this.#P(t,!0))))}#D(t){let e=t.u;t.u=void 0,t.p="",e&&(e.abort.abort(),e.result&&this.#U(e.result,t),e.root.remove(),t.l.replaceChildren(),this.#z(t))}#U(t,e){try{let e=t.cleanup();Promise.resolve(e).catch(()=>this.#n("content.cleanup-failed"))}catch{this.#n("content.cleanup-failed")}}#N(t){this.#D(t),!this.#M&&this.#L(t)}#L(t){t.u&&this.#D(t),this.#c.removeRule(t.h),t.host.remove(),this.#s.delete(t.key),this.#p=!0}destroy(){if(!this.#M){this.#M=!0;for(let t of[...this.#s.values()])this.#L(t);this.#c.destroy(),this.#e.remove()}}#O(){if(this.#M)return;let e=this.#e.parentNode!==this.#t.documentElement||!this.#e.hasAttribute("data-peekling-content");if(t(this.#e,this.#t,"data-peekling-content"),!this.#M){if(this.#i.host!==this.#e)throw Error("content.root");this.#e.getAttribute("aria-label")!==this.#d&&this.#e.setAttribute("aria-label",this.#d);for(let t of this.#s.values()){if(e&&this.#z(t),t.host.ownerDocument!==this.#t)throw Error(Lt("content.document"));t.host.parentNode!==this.#i&&(this.#i.append(t.host),this.#z(t)),(t.title.parentNode!==t.host||t.text.parentNode!==t.host||t.link.parentNode!==t.host||t.l.parentNode!==t.host)&&(t.host.replaceChildren(t.title,t.text,t.link,t.l),this.#z(t));let i=t.u;if(i){if(i.root.ownerDocument!==this.#t){if(this.#R(t,"root-adopted"),this.#M)return;continue}i.root.parentNode!==t.l&&(t.l.replaceChildren(i.root),this.#z(t))}}}}},he=class{pointer;k=[];$;#t=1;#e=[];#i=new Map;#s;#r;#n;#o;#h;#a;#l=!1;constructor(t,e,i){this.#s=t,this.#r=e,this.#n=i.now,this.#o=i.wake,this.#h=i.i??(()=>{}),this.$=i.now(),this.#v(e,"resize",()=>this.#o());for(let t of i.events)this.#c(t);this.#a=i.coalesce??new Map}get reaction(){return this.k[0]}j(t,e,i="application"){let s=this.#n(),r=this.k.at(-1),n=this.#a.get(`${i}:${t}`),o=!(r?.name!==t||r.source!==i||!(!0===n||void 0!==n&&((t,e,i)=>{if(!t||!e||"object"!=typeof t||"object"!=typeof e||Array.isArray(t)||Array.isArray(e))return!1;let s=t,r=e;return r[i.sessionField]===s[i.sessionField]&&Number.isSafeInteger(r[i.revisionField])&&Number.isSafeInteger(s[i.revisionField])&&r[i.revisionField]>s[i.revisionField]})(r.payload,e,n)));if(!o&&this.k.length>=32)return this.#h("event.queue-full"),{accepted:!1,reason:"queue-full"};let h={id:o?r.id:this.#t++,source:i,name:t,at:s,...void 0===e?{}:{payload:e}};return o?this.k[this.k.length-1]=h:this.k.push(h),this.$=s,this.#o(),{accepted:!0,id:h.id,coalesced:o}}M(t){this.k[0]?.id===t&&this.k.shift()}retainEvent(t){this.#c(t);let e=!0;return()=>{e&&(e=!1,this.#d(t))}}O(t){if(t!==this.#l){this.#l=t;for(let e of this.#e)t&&e[3]&&!e[4]?(e[0].removeEventListener(e[1],e[2]),e[3]=!1):!t&&!e[3]&&(e[0].addEventListener(e[1],e[2],{passive:!0}),e[3]=!0);t&&(this.pointer=void 0)}}destroy(){for(let t of this.#e.splice(0))t[3]&&t[0].removeEventListener(t[1],t[2]);this.pointer=void 0,this.k.length=0,this.#i.clear()}#c(t){let e=this.#i.get(t);if(e){e[0]+=1;return}let i=[];this.#i.set(t,[1,i]);let s=(t,e,s,r=!1)=>i.push(this.#v(t,e,s,r));if("pointer.move"===t){s(this.#s,"pointerdown",t=>{("touch"===t.pointerType||"pen"===t.pointerType)&&this.#u(t)}),s(this.#s,"pointermove",t=>this.#u(t));let t=t=>{let e=t.pointerType;("touch"===e||"pen"===e)&&this.#f()};s(this.#s,"pointerup",t),s(this.#s,"pointercancel",t),s(this.#s,"pointerout",t=>{null===t.relatedTarget&&this.#f()}),s(this.#r,"blur",()=>this.#f())}else"pointer.click"===t?s(this.#s,"click",t=>this.#p("pointer.click",t)):"document.visibility"===t?s(this.#s,"visibilitychange",()=>this.j("document.visibility",{visible:!this.#s.hidden},"browser"),!0):"window.scroll"===t?s(this.#r,"scroll",t=>{this.#f(),this.#p("window.scroll",t)}):"window.focus"===t&&(s(this.#r,"focus",()=>this.j("window.focus",{focused:!0},"browser")),s(this.#r,"blur",()=>this.j("window.focus",{focused:!1},"browser")))}#d(t){let e=this.#i.get(t);if(e){if(e[0]>1){e[0]-=1;return}this.#i.delete(t);for(let t of e[1]){t[3]&&t[0].removeEventListener(t[1],t[2]);let e=this.#e.indexOf(t);e>=0&&this.#e.splice(e,1)}}}#f(){this.#l||this.pointer&&(this.pointer=void 0,this.$=this.#n(),this.#o())}#u(t){this.#l||(this.pointer={x:t.clientX,y:t.clientY},this.$=this.#n(),this.#o())}#p(t,e){if(this.#l||e.composedPath().some(t=>"hasAttribute"in t&&"function"==typeof t.hasAttribute&&t.hasAttribute("data-peekling-controls")))return;let i=e,s=Number.isFinite(i.clientX)&&Number.isFinite(i.clientY)?{x:i.clientX,y:i.clientY}:void 0;this.j(t,s,"browser")}#v(t,e,i,s=!1){t.addEventListener(e,i,{passive:!0});let r=[t,e,i,!0,s];return this.#e.push(r),r}},ae=class{ready;#t;#e;#i;#s;#r;#n;#o;#h;#a;#l;#c;#d={x:0,y:0};#f;#u={x:0,y:0};#p={x:0,y:0};#v={x:0,y:0};#y={x:0,y:0};#w=0;#b=!1;#g=!1;#m=!1;constructor(t){this.#o=t,this.#t=t.document,this.#c=t.label,this.#e=t.document.createElement("div"),this.#e.setAttribute("data-peekling-interaction",""),this.#i=this.#e.attachShadow({mode:"closed"}),this.#n=new Wt(t.document,this.#i,t.styles),this.#s=t.document.createElement("button"),this.#s.type="button",this.#s.className="peekling-character-hit",this.#s.setAttribute("aria-label",t.label),void 0!==t.expanded&&this.#s.setAttribute("aria-expanded",t.expanded+""),this.#s.toggleAttribute("data-peekling-draggable",t.draggable),this.#r=t.document.createElement("span"),this.#r.className="peekling-character-indicator",this.#r.setAttribute("aria-hidden","true"),this.#s.append(this.#r),this.#i.append(this.#s),this.ready=this.#n.ready.then(()=>{this.#m||(this.#h=this.#n.addRule(".peekling-character-hit"),this.#a=this.#n.addRule(".peekling-character-indicator"),this.#k())}),this.ready.catch(()=>{}),this.#s.addEventListener("click",this.#$),t.draggable&&(this.#s.addEventListener("pointerdown",this.#j),this.#s.addEventListener("pointermove",this.#x),this.#s.addEventListener("pointerup",this.#E),this.#s.addEventListener("pointercancel",this.#M)),this.updateIndicator(t.indicator),this.#z()}S(t,e,i=0){if(this.#m)return;this.#z(),this.#d={x:t.x,y:t.y-i};let s=this.#h;if(!s)return;let r=t.x-e.width/2,n=t.y-e.height/2-i;s.width=e.width+"px",s.height=e.height+"px",s.transform=`translate3d(${r}px,${n}px,0)`}N(t){this.#m||this.#e.toggleAttribute("hidden",t)}setExpanded(t){!this.#m&&this.#s.hasAttribute("aria-expanded")&&this.#s.setAttribute("aria-expanded",t+"")}updateIndicator(t){if(this.#m)return;this.#l=t??void 0,this.#k();let e=!(!t||!1===t.visible||!("count"!==t.kind||(t.count??0)>0));if(this.#r.hidden=!e,!e||!t){this.#r.textContent="",this.#s.setAttribute("aria-label",this.#c);return}let i=t.kind??"dot";this.#r.dataset.kind=i,this.#r.textContent="count"===i?Math.min(99,t.count??0)+"":"",this.#s.setAttribute("aria-label",`${this.#c}. ${t.label}`)}#k(){this.#a&&(this.#a.backgroundColor=this.#l?.color??"")}destroy(){this.#m||(this.#m=!0,this.#n.destroy(),this.#e.remove())}#$=()=>{this.#g?this.#g=!1:this.#o.onPress()};#j=t=>{if(!(this.#m||void 0!==this.#f||!t.isPrimary&&"mouse"!==t.pointerType||"mouse"===t.pointerType&&0!==t.button)){this.#f=t.pointerId,this.#u={x:t.clientX,y:t.clientY},this.#p={...this.#u},this.#v={...this.#d},this.#y={x:0,y:0},this.#w=t.timeStamp,this.#b=!1;try{this.#s.setPointerCapture(t.pointerId)}catch{}this.#o.onDragStart()}};#x=t=>{if(t.pointerId!==this.#f)return;let e=t.clientX-this.#u.x,i=t.clientY-this.#u.y;!this.#b&&Math.hypot(e,i)>=4&&(this.#b=!0);let s=Math.max(8,Math.min(100,t.timeStamp-this.#w)),r=1e3*(t.clientX-this.#p.x)/s,n=1e3*(t.clientY-this.#p.y)/s;this.#y={x:.65*r+.35*this.#y.x,y:.65*n+.35*this.#y.y},this.#p={x:t.clientX,y:t.clientY},this.#w=t.timeStamp,this.#o.onDragMove({x:this.#v.x+e,y:this.#v.y+i},this.#y)};#E=t=>{t.pointerId===this.#f&&this.#S(t,this.#b,this.#y)};#M=t=>{t.pointerId===this.#f&&this.#S(t,this.#b,{x:0,y:0},this.#p)};#S(t,e,i,s={x:t.clientX,y:t.clientY}){let r=this.#f;if(this.#f=void 0,void 0!==r)try{this.#s.releasePointerCapture(r)}catch{}this.#g=e,this.#o.onDragEnd(i,e,s)}#z(){if(!this.#m&&(t(this.#e,this.#t,"data-peekling-interaction"),this.#i.host!==this.#e||this.#s.getRootNode()!==this.#i))throw Error("interaction.root")}},le=["E","SE","S","SW","W","NW","N","NE"],ce=6e4,de=class{#t;#e;#i;#s;#r;#n;#o;#h=0;#a=[];#l=[];#c;#d=!1;constructor(t){this.#t=t.instanceId,this.#e=t.now,this.#i=t.logger,this.#s=t.messageSink,this.#r=t.context,this.#n=!0===t.debug,this.#o=t.console}emit(t){let e=this.#e();if(this.#a=this.#a.filter(t=>e-t<ce),this.#l=this.#l.filter(t=>e-t<ce),void 0!==this.#c&&e-this.#c>=ce&&(this.#c=void 0),!this.#d)return this.#a.length>=64?(void 0===this.#c&&(this.#c=e,this.#f({code:"diagnostics.rate-limited",severity:"warning",message:"Diagnostic output was rate limited",phase:"internal",metadata:{windowMs:ce,recordLimit:64,errorReserve:8}})),"error"!==t.severity||this.#l.length>=8?void 0:(this.#l.push(e),this.#f(t))):(this.#a.push(e),this.#f(t))}#f(t){let e={code:t.code,severity:t.severity,message:m(t.message),phase:t.phase,sequence:++this.#h,timestamp:Date.now(),instanceId:this.#t};t.overrideId&&(e.overrideId=t.overrideId),void 0!==t.eventId&&(e.eventId=t.eventId),t.metadata&&(e.metadata=t.metadata),this.#r&&(e.context=this.#r),this.#n&&t.cause&&(e.cause=(t=>t instanceof Error?{name:t.name.slice(0,80),message:t.message.slice(0,500),...t.stack?{stack:t.stack.slice(0,4e3)}:{}}:{name:"Error",message:(t+"").slice(0,500)})(t.cause)),this.#d=!0;try{try{this.#s?.(e.message)}catch{}try{this.#i?.(e)}catch{}}finally{this.#d=!1}return!this.#s&&!this.#i&&(!0===this.#o||void 0===this.#o&&"error"===e.severity)&&console.warn(`[Peekling] ${e.message}${"error"===e.severity?" (use peekling.js for details)":""}`),e}},fe=class extends Error{code;category;constructor(t,e,i,s){super(i,{cause:s}),this.name="PackLoadError",this.code=t,this.category=e}},ue=class extends Error{issues;issueCodes;constructor(t,e=[]){let i=t,s=t;super("pack:"+i.join(",")),this.name="PackValidationError",this.issues=i,this.issueCodes=e.length?e:s}},pe=/^[a-f0-9]{64}$/,ve=4096,ye=[137,80,78,71,13,10,26,10],we=4096,be=/^[a-z][a-z0-9._-]{0,63}$/,ge={peek:Object.freeze({url:"https://cdn.jsdelivr.net/npm/@peekling/pack-peek@0.1.1/character.json",sha256:"9a2e2a41e85f7c4b8d3487a3655db40872675bd9c0780e139a946eabdf71d75f"})},me=/^(?:motion|state|surface:[a-z][a-z0-9:-]{0,63})$/,ke=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/,$e=class extends TypeError{code;path;constructor(t,e,i){super(t),this.name="PlanCompileError",this.code=t,this.path=""}},je=class{#t;#e=(()=>({ordering:new Map,sessions:new Map}))();#i=new Map;#s=new Map;#r=new WeakMap;#n=new WeakMap;#o;#h;#a;#l;#c=[];#d=0;#f;#u=[];constructor(t){this.#t=t}get plan(){return this.#t}get lastEventStatus(){return this.#f}get lastEventRejections(){return this.#u}evaluate(t){this.#f=void 0,this.#u=[];let e=t.reaction;if(this.#m(t.now),e){let i=((t,e,i)=>{function s(t,e=[],i=[],s=[]){return{status:t,rules:e,effects:i,rejectedSurfaces:ft([...s])}}let r;try{r=p(i.payload)}catch{return s("invalid")}let n="browser"===i.source&&"section.visibility"===i.name?(t=>{if(!t||"object"!=typeof t||Array.isArray(t))return;let e=t;return 3!==Object.keys(e).length||"string"!=typeof e.selector||"number"!=typeof e.A||"number"!=typeof e.ratio||e.A<0||e.A>1||e.ratio<0||e.ratio>1?void 0:e})(r):void 0;if("browser"===i.source&&"section.visibility"===i.name&&!n)return s("invalid");let o=t.rules.filter(t=>t.when.source===i.source&&t.when.event===i.name&&(!n||((t,e)=>{if("browser"!==t.source||"section.visibility"!==t.event||t.selector!==e.selector||"while-visible"===t.phase)return!1;let i=t.threshold??.25;return"enter"===t.phase?e.A<i&&e.ratio>=i:e.A>=i&&e.ratio<i})(t.when,n)));if(!o.length)return s("unmatched");if(!o.some(t=>Y(t.effect).some(t=>t.ordering)))return s("matched",o,o.map(t=>st(t.effect,r)));let h=new Map;for(let t of o)for(let e of Y(t.effect)){if(!e.ordering)continue;let t=tt(e),i=h.get(t)??[];i.push(e),h.set(t,i)}let a=[],l=new Set;for(let[t,i]of h){let s={ordering:new Map},n=rt(i,e,s,r);"matched"!==n?(l.add(t),a.push({channel:t,status:n})):ot(e,s,t)}let c=[],d=[];for(let[t,e]of o.entries()){let t=st(e.effect,r),i=nt(t,t.channels.filter(t=>!l.has(t)));i&&(c.push(e),d.push(i))}return s(d.length?"matched":a[0]?.status??"matched",c,d,a)})(this.#t,this.#e,{source:e.source,name:e.name,...void 0===e.payload?{}:{payload:e.payload}});if(this.#f=i.status,this.#u=i.rejectedSurfaces,"invalid"!==i.status&&"stale"!==i.status&&"closed"!==i.status&&this.#m(t.now,e.source,e.name),"matched"===i.status){let e=new Set;i.effects.forEach((s,r)=>{let n=s.channels.filter(t=>!e.has(t));if(n.length){for(let t of n)e.add(t);if(s.until)this.#g(nt(s,n),t.now);else{for(let t of n)("motion"===t||"state"===t)&&this.#i.set(t,[i.rules[r].effect,s]);for(let t of s.surfaces)n.includes(t.channel)&&this.#b(t)}}})}}let i=new Map;for(let t of this.#c)for(let e of t.effect.channels)i.set(e,t.effect);for(let e of this.#t.rules){let s=this.#w(e,t);for(let t of["motion","state"]){if(i.has(t))continue;let r=this.#i.get(t),n=s&&e.effect.channels.includes(t)?e.effect:r?.[0]===e.effect?r[1]:void 0;n&&i.set(t,n)}}for(let t of this.#t.baseline.channels)i.has(t)||i.set(t,this.#t.baseline);let s={},r=i.get("state")?.state;"state"===r?.kind&&(s.state=r.name),"capability"===r?.kind&&(s.capability=r.name);let n=i.get("motion"),o=n?.motion,h=()=>{if("locomotion"!==s.capability)return;delete s.capability;let t=this.#p();!s.state&&t&&(s.state=t)};if("jump-to"!==o?.type&&(this.#o=void 0,this.#h=void 0),"svg-path"!==o?.type&&(this.#a=void 0,this.#l=void 0),"horizontal-patrol"===o?.type&&t.t){let[e,i]=pt(o,t,this.#r.get(n)??!0);this.#r.set(n,e),i&&(s.motion=i)}else if("viewport-traverse"===o?.type&&t.t){let[e,i]=((t,e,i)=>{let s=t.edgeInset??0,r=e.t.height/2,n=Math.min(e.viewport.width/2,e.t.width/2+s),o=Math.max(n,e.viewport.width-n),h=Math.min(e.viewport.height/2,r+s),a=Math.max(h,e.viewport.height-r-s),l=[{x:n,y:a},{x:o,y:a},{x:o,y:h},{x:n,y:h}];void 0===i&&(i=l.reduce((t,i,s)=>Math.hypot(i.x-e.position.x,i.y-e.position.y)<Math.hypot(l[t].x-e.position.x,l[t].y-e.position.y)?s:t,0));let c=l[i],d=wt(t,e.position,c.x,c.y);d||(c=l[i=(i+(!1===t.clockwise?-1:1)+l.length)%l.length],d=wt(t,e.position,c.x,c.y));return[i,d]})(o,t,this.#n.get(n));this.#n.set(n,e),i&&(s.motion=i)}else if("follow-pointer"===o?.type){let e=t.pointer?wt(o,t.position,t.pointer.x,t.pointer.y,o.arrivalRadius,t):void 0;e?s.motion=e:h()}else if("move-to"===o?.type){let e=wt(o,t.position,o.x,o.y,o.arrivalRadius,t);e?s.motion=e:h()}else if("move-to-target"===o?.type){let e=t.targets?.[o.target],i=e&&t.t?((t,e="center",i)=>{let s={x:t.left+t.width/2,y:t.top+t.height/2};switch(e){case"top":return{x:s.x,y:t.top-i.height/2};case"right":return{x:t.right+i.width/2,y:s.y};case"bottom":return{x:s.x,y:t.bottom+i.height/2};case"left":return{x:t.left-i.width/2,y:s.y};default:return s}})(e,o.anchor,t.t):void 0,r=i?wt(o,t.position,i.x,i.y,o.arrivalRadius,t):void 0;r?s.motion={...r,trackTarget:!0}:h()}else if("jump-to"===o?.type){let e=this.#v(n,o,t);e?s.motion=e:h()}else if("svg-path"===o?.type){let e=this.#y(n,o,t);e?s.motion=e:h()}let a=new Map;for(let t of this.#t.baseline.surfaces)a.set(t.channel,{surface:t,version:0});for(let t of this.#s.values())a.set(t.surface.channel,t);for(let t of this.#c)for(let e of t.effect.surfaces)a.set(e.channel,{surface:e,version:t.version});return a.size&&(s.surfaces=Object.freeze([...a.values()].map(({surface:t,version:e})=>Object.freeze({id:t.id,channel:t.channel,contentId:t.contentId,...void 0===t.data?{}:{data:t.data},key:`${t.channel}:${e}`})))),e&&"matched"===this.#f&&(s.T=e.id),s}reset(){this.#i.clear(),this.#s.clear(),this.#c=[],this.#r=new WeakMap,this.#n=new WeakMap,this.#o=void 0,this.#h=void 0,this.#a=void 0,this.#l=void 0,this.#e.ordering.clear(),this.#e.sessions.clear(),this.#f=void 0,this.#u=[]}P(){return this.#c.reduce((t,e)=>Number.isFinite(e.I)?void 0===t?e.I:Math.min(t,e.I):t,void 0)}D(t){t&&(this.#c=this.#c.map(e=>({...e,I:e.I+t})))}#p(){let t=this.#t.baseline.state;return"state"===t?.kind?t.name:void 0}#v(t,e,i){(this.#o!==t||!this.#h)&&(this.#o=t,this.#h={R:i.now,from:{...i.position}});let s=Math.max(0,Math.min(1,(i.now-this.#h.R)/(e.duration??800))),r=vt(e,i),n={x:this.#h.from.x+(r.x-this.#h.from.x)*s,y:this.#h.from.y+(r.y-this.#h.from.y)*s},o=yt(i.position,n,0===s||1===s?0:Math.sin(Math.PI*s)*(e.height??i.t?.height??32));if(s<1||o.maxDistance)return o}#y(t,e,i){let s=i.samplePath;if(!s)return;let r=s(e.path,0);if(!r)return;(this.#a!==t||!this.#l)&&(this.#a=t,this.#l={R:i.now,offset:!1===e.relative?{x:0,y:0}:{x:i.position.x-r.x,y:i.position.y-r.y}});let n=e.duration??4e3,o=Math.max(0,i.now-this.#l.R),h=!0!==e.loop&&o>=n,a=s(e.path,e.loop?o%n/n:Math.min(1,o/n));if(!a)return;let l={x:a.x+this.#l.offset.x,y:a.y+this.#l.offset.y},c=yt(i.position,vt(l,i));return!h||c.maxDistance?c:void 0}#w(t,e){let i=t.when;if("browser"!==i.source)return!1;if("pointer.move"===i.event){if(!e.pointer)return!1;let i=t.effect.motion;return!i||"follow-pointer"!==i.type||!!wt(i,e.position,e.pointer.x,e.pointer.y,i.arrivalRadius,e)}if("section.visibility"!==i.event)return!1;let s=e.sections?.[i.selector],r=i.threshold??.25;return"while-visible"===i.phase&&(s?.ratio??0)>=r}#b(t){let e=this.#s.get(t.channel);if("ignore"===t.disposition)return;let i="update"===t.disposition&&e?{...t,contentId:e.surface.contentId}:t;this.#s.set(t.channel,{surface:Object.freeze(i),version:++this.#d})}#g(t,e){let i=t.until,s=e+("duration"===i.type?i.ms:i.timeout??36e5);Number.isFinite(s)&&(this.#c=this.#c.filter(e=>!e.effect.channels.some(e=>t.channels.includes(e))),this.#c.push({effect:t,I:s,version:++this.#d}))}#m(t,e,i){this.#c=this.#c.filter(s=>{if(t>=s.I)return!1;let r=s.effect.until;return!(void 0!==e&&void 0!==i&&"event"===r.type&&(t=>f(t)?"browser":"application")(r.name)===e&&r.name===i)})}},xe=!1,Ee=["format","character","pack","packUrl","atlasUrl","styles","plan","preset","targets","interaction","indicator","content","bindings","theme","accessibility","diagnostics","name","scale","position","density","maxDensity","motionPreference","onDiagnostic","logger","document","window"],Me=class extends TypeError{issues;constructor(t,e,i){super(`${e}: ${i}`),this.name="PeeklingPreflightError",this.issues=[{code:t,path:e,message:i}]}},Oe=36e5,Se=class{#t;#e;#i;#s=[];#r=1;constructor(t,e,i=()=>{}){this.#t=t,this.#e=e,this.#i=i}add(t){let e,i,s=this.#n();try{e=(t=>{let e=l(t);if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("override.object");if(Ot(e,["effect","until","mode"]),!e.effect)throw new TypeError("override.effect");if(void 0!==e.mode&&"reject"!==e.mode&&"replace"!==e.mode)throw new TypeError("override.mode");let i=void 0===e.until?Object.freeze({type:"manual"}):e.until;if(!i||"object"!=typeof i||Array.isArray(i))throw new TypeError("override.until");if("duration"===i.type)Ot(i,["type","ms"]),Mt(i.ms);else if("event"===i.type){if(Ot(i,["type","name","timeout"]),"string"!=typeof i.name||!Kt.test(i.name))throw new TypeError("override.until.name");if(u(i.name))throw new TypeError("override.until.name");void 0!==i.timeout&&Mt(i.timeout)}else{if("manual"!==i.type)throw new TypeError("override.until.type");Ot(i,["type","maxMs"]),void 0!==i.maxMs&&Mt(i.maxMs)}return Object.freeze({effect:e.effect,until:i,...void 0===e.mode?{}:{mode:e.mode}})})(t),i=((t,e={})=>{let i=l(t),s=G(i,0,e,!1);s.until&&ut("invalid-override-lifetime");for(let[t,e]of Y(i).entries())void 0!==e.disposition&&ut("invalid-override-disposition"),void 0!==e.ordering&&ut("invalid-override-ordering");return s})(e.effect,this.#t)}catch(t){return this.#i("override.invalid"),s.finish("rejected"),s.handle}let r=this.#s.filter(t=>t.effect.channels.some(t=>i.channels.includes(t)));if(r.length&&"replace"!==e.mode)return this.#i("override.conflict"),s.finish("conflict"),s.handle;for(let t of r)this.#o(t,"replaced");if(this.#s.length>=8)return this.#i("override.limit"),s.finish("overflow"),s.handle;let n=this.#e();return Object.assign(s,{input:e,effect:i,R:n,I:n+Et(e),status:"active"}),this.#s.push(s),s.handle}reject(t="rejected"){let e=this.#n();return e.finish(t),e.handle}browserCompletionFor(t){let e=this.#s.find(e=>e.id===t)?.input.until;return"event"===e?.type?f(e.name):void 0}C(t,e="application"){for(let i of[...this.#s])"event"===i.input.until?.type&&i.input.until.name===t&&xt(i.input.until.name)===e&&this.#o(i,"event");return!1}compose(t,e){let i=this.#e();for(let t of[...this.#s])i>=t.I&&this.#o(t,"timeout");let s={...t},r=new Map;for(let e of t.surfaces??[])r.set(e.channel,e);for(let t of this.#s){let i=t.effect.state;"state"===i?.kind?(s.state=i.name,delete s.capability):"capability"===i?.kind&&(s.capability=i.name,delete s.state);let n=t.effect.motion;if("horizontal-patrol"===n?.type){let[i,r]=pt(n,e,t.U);t.U=i,r?s.motion=r:delete s.motion}else if("follow-pointer"===n?.type&&e.pointer&&e.position){let t=wt(n,e.position,e.pointer.x,e.pointer.y,n.arrivalRadius,e);t?s.motion=t:delete s.motion}for(let e of t.effect.surfaces)r.set(e.channel,Object.freeze({id:e.id,channel:e.channel,contentId:e.contentId,...void 0===e.data?{}:{data:e.data},key:t.id}))}return s.surfaces=Object.freeze([...r.values()]),s}P(){return this.#s.reduce((t,e)=>void 0===t?e.I:Math.min(t,e.I),void 0)}D(t){for(let e of this.#s)e.R+=t,e.I+=t}clear(t){for(let e of[...this.#s])this.#o(e,t)}#n(){let t,e="override:"+this.#r++,i=!1,s=new Promise(e=>{t=e}),r={},n=Object.freeze({id:e,get status(){return r.status},finished:s,cancel:()=>{"active"===r.status&&this.#o(r,"cancelled")}});return Object.assign(r,{id:e,effect:Object.freeze({channels:[],surfaces:[]}),input:Object.freeze({effect:Object.freeze({channels:[]}),until:Object.freeze({type:"manual"})}),R:0,I:0,status:"rejected",U:!0,handle:n,finish(s){i||(i=!0,r.status=(t=>"rejected"===t||"conflict"===t||"overflow"===t)(s)?"rejected":"finished",t({id:e,reason:s}))}}),r}#o(t,e){let i=this.#s.indexOf(t);i>=0&&this.#s.splice(i,1),t.finish(e)}},Ne=class{host;ready;#t;#e;#i;#s;#r;#n;#o;#h=0;#a=0;#l="";#c=0;#d=-1;#f=!1;constructor(t,e,i,s,r){this.#t=t,this.#n=e,this.#o=s,this.host=t.createElement("div"),this.host.setAttribute("aria-hidden","true"),this.host.setAttribute("data-peekling-host",""),this.#e=this.host.attachShadow({mode:"closed"}),this.#s=new Wt(t,this.#e,r),this.#i=t.createElement("i"),this.#i.className="sprite",this.#e.append(this.#i),this.ready=this.#s.ready.then(()=>{this.#f||(this.#r=this.#s.addRule(".sprite"),this.#u(e,i))}),this.ready.catch(()=>{}),this.#p()}L(t,e){this.#f||this.#u(t,e)}#u(t,e){this.#n=t;let i=this.#r;if(!i)throw Error("renderer.styles");this.#h=t.atlas.logicalWidth??t.atlas.cellWidth,this.#a=t.atlas.logicalHeight??t.atlas.cellHeight,i.width=this.#h+"px",i.height=this.#a+"px",i.backgroundSize=`${t.atlas.columns*this.#h}px ${t.atlas.rows*this.#a}px`,i.backgroundImage=`url(${JSON.stringify(e)})`,i.imageRendering=1===(t.atlas.density??1)?"pixelated":"auto",this.#d=-1}N(t){this.#f||this.host.toggleAttribute("hidden",t)}W(t){if(this.#f)return;let e=this.#n.states[this.#l];if(!e||e.frames.length<2)return;let i=Math.max(0,t-this.#c);if(e.durations?.length===e.frames.length){let t=k(e);if(!e.loop&&i>=t-e.durations.at(-1))return;let s=e.loop?i%t:i,r=0;for(let t of e.durations)if(r+=t,r>s)return r-s;return e.loop?e.durations[0]:void 0}let s=1e3/(e.fps??1);return!e.loop&&i>=s*(e.frames.length-1)?void 0:s-(i%s||0)}S(t,e,i,s=1,r=0){if(this.#f||(this.#p(),this.#f))return;let n=this.#n.states[t];if(!n)throw Error("renderer.state");t!==this.#l&&(this.#l=t,this.#c=e,this.#d=-1,this.host.setAttribute("data-peekling-state",t));let o=((t,e)=>{if(1===t.frames.length)return t.frames[0];if(t.durations?.length===t.frames.length){let i=k(t),s=t.loop?e%i:Math.min(e,i-1),r=0;for(let e=0;e<t.frames.length;e++)if(r+=t.durations[e],s<r)return t.frames[e];return t.frames.at(-1)}let i=Math.floor(e*(t.fps??1)/1e3);return t.frames[t.loop?i%t.frames.length:Math.min(i,t.frames.length-1)]})(n,e-this.#c);if(o!==this.#d){let t=o%this.#n.atlas.columns,e=Math.floor(o/this.#n.atlas.columns);if(!this.#r)throw Error("renderer.styles");this.#r.backgroundPosition=`${-t*this.#h}px ${-e*this.#a}px`,this.#d=o,this.host.setAttribute("data-peekling-frame",o+"")}let h=this.#h*this.#o,a=this.#a*this.#o,l=St(i.x-h/2,s),c=St(i.y-a/2-r,s),d=l+"",f=c+"";if(this.host.getAttribute("data-peekling-x")!==d&&this.host.setAttribute("data-peekling-x",d),this.host.getAttribute("data-peekling-y")!==f&&this.host.setAttribute("data-peekling-y",f),!this.#r)throw Error("renderer.styles");let u=`translate3d(${l}px,${c}px,0) scale(${this.#o})`;this.#r.transform!==u&&(this.#r.transform=u)}destroy(){this.#f||(this.#f=!0,this.#s.destroy(),this.host.remove())}#p(){if(!this.#f){if(t(this.host,this.#t,"data-peekling-host"),this.#e.host!==this.host||this.#i.getRootNode()!==this.#e)throw Error("renderer.root");"true"!==this.host.getAttribute("aria-hidden")&&this.host.setAttribute("aria-hidden","true")}}},Ae=t=>new Ne(t.document,t.pack,t.atlasUrl,t.scale,t.styles),ze={click:["waving","happy","alert"],"double-click":["jumping","happy","waving"],"context-click":["alert","waving","idle"],scroll:["alert","waving","idle"],success:["success","happy","jumping","waving"],happy:["happy","success","waving"],error:["error","failed","alert"],sleep:["sleep","idle"]},Te=class{#t;#e;#i=new Map;#s=new Map;#r;#n;#o;#h;#a=!1;#l=!1;#c=!1;#d;#f=0;constructor(t,e,i,s,r,n){this.#t=t,this.#e=e,this.#o=r,this.#h=n;let o=i.map(t=>[t,this.#p(t)]),h=e.IntersectionObserver;h&&(this.#r=new h(t=>{let e=!1;for(let i of t)for(let t of this.#s.get(i.target)??[]){let s=this.#i.get(t);s&&(e=this.#y(t,s,i.isIntersecting?i.intersectionRatio:0)||e)}e&&r()},{threshold:[...s]}));let a=e.MutationObserver;a&&(this.#n=new a(t=>{if(this.#a||this.#l||this.#f||this.#c||t.length>0&&t.every(Nt))return;let e=!1;for(let t of this.#i.values())if(!t[0]?.isConnected){e=!0;break}e&&this.#b()}),this.#n.observe(t.documentElement,{childList:!0,subtree:!0}));for(let[t,e]of o)this.#i.set(t,[void 0,0,0]),this.#u(t,e)}H(){if(this.#d)throw this.#d;if(this.#c&&(this.#c=!1,this.#m(),this.#d))throw this.#d;let t=Object.create(null);for(let[e,i]of this.#i)t[e]={ratio:i[2],A:i[1]};return t}O(t){if(!this.#l&&t!==this.#a){if(this.#a=t,t){this.#g(),this.#c=!1,this.#r?.disconnect(),this.#n?.disconnect();return}if(this.#n?.observe(this.#t.documentElement,{childList:!0,subtree:!0}),this.#c=!1,this.#m())for(let t of this.#s.keys())this.#r?.observe(t)}}destroy(){this.#l||(this.#l=!0,this.#g(),this.#c=!1,this.#r?.disconnect(),this.#n?.disconnect(),this.#s.clear(),this.#i.clear())}#u(t,e=this.#p(t)){let i=this.#i.get(t);if(!e){this.#v(t,i),this.#y(t,i,0);return}if(e===i[0]&&e.isConnected)return;this.#v(t,i),i[0]=e;let s=this.#s.get(e)??new Set;s.size||this.#r?.observe(e),s.add(t),this.#s.set(e,s)}#p(t){try{return this.#t.querySelector(t)}catch{throw new TypeError("section.selector")}}#v(t,e){let i=e[0];if(e[0]=void 0,!i)return;let s=this.#s.get(i);s?.delete(t),s?.size||(this.#r?.unobserve(i),this.#s.delete(i))}#y(t,e,i){let s=e[2];return i!==s&&(e[1]=s,e[2]=i,this.#h?.({selector:t,A:s,ratio:i}),!0)}#w(){for(let[t,e]of this.#i)e[0]?.isConnected||this.#u(t)}#b(){this.#f||this.#a||this.#l||(this.#f=this.#e.setTimeout(()=>{this.#f=0,!(this.#a||this.#l||this.#d||this.#c)&&(this.#c=!0,this.#o())},250))}#g(){this.#f&&this.#e.clearTimeout(this.#f),this.#f=0}#m(){if(this.#d)return!1;try{return this.#w(),!0}catch(t){return this.#d=t instanceof Error?t:Error("section.refresh"),this.#r?.disconnect(),this.#n?.disconnect(),this.#o(),!1}}},Pe=class{#t;#e=new Map;constructor(t){this.#t=t}validate(t){return void 0!==this.#i(t)}sample(t,e){let i=this.#i(t);if(!i)return;let s=Math.max(0,Math.min(1,e));try{let t=i.element.getPointAtLength(i.length*s);return Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:t.x,y:t.y}:void 0}catch{return}}#i(t){let e=this.#e.get(t);if(e)return e;if(this.#e.size>=16)return;let i=this.#t.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",t);try{let e=i.getTotalLength();if(!Number.isFinite(e)||e<=0)return;let s=Object.freeze({element:i,length:e});return this.#e.set(t,s),s}catch{return}}},Ie=class{#t;#e;#i;#s=new Map;#r;#n;#o;#h=Object.freeze({});#a=!0;#l=!1;constructor(t,e,i,s){this.#t=t,this.#e=e,this.#i=i,this.#r=s;let r=e;this.#n=r.ResizeObserver?new r.ResizeObserver(()=>this.refresh()):void 0,this.#o=r.MutationObserver?new r.MutationObserver(()=>this.refresh()):void 0,this.#o?.observe(t.documentElement,{attributes:!0,attributeFilter:["class","id"],childList:!0,subtree:!0}),e.addEventListener("resize",this.#c,{passive:!0}),e.addEventListener("scroll",this.#c,{capture:!0,passive:!0})}H(t=!1){if(this.#l)return Object.freeze({});if(t&&(this.#a=!0),!this.#a)return this.#h;let e=Object.create(null);for(let[t,i]of Object.entries(this.#i)){let s=this.#s.get(t);if(s?.isConnected||(s&&this.#n?.unobserve(s),s=this.#t.querySelector(i),s?(this.#s.set(t,s),this.#n?.observe(s)):this.#s.delete(t)),!s)continue;let r=s.getBoundingClientRect();!Number.isFinite(r.left)||!Number.isFinite(r.top)||!Number.isFinite(r.width)||!Number.isFinite(r.height)||(e[t]=Object.freeze({left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height}))}return this.#h=Object.freeze(e),this.#a=!1,this.#h}contains(t,e,i=0){let s=this.H(!0)[t];return!!(s&&e.x>=s.left-i&&e.x<=s.right+i&&e.y>=s.top-i&&e.y<=s.bottom+i)}refresh=()=>{this.#l||(this.#a=!0,this.#r())};destroy(){this.#l||(this.#l=!0,this.#n?.disconnect(),this.#o?.disconnect(),this.#e.removeEventListener("resize",this.#c),this.#e.removeEventListener("scroll",this.#c,!0),this.#s.clear())}#c=()=>this.refresh()},De="peekling:site-preference",Re="peekling:hidden-session",Ce=[["10 minutes","10-minutes"],["1 hour","1-hour"],["Until tomorrow","until-tomorrow"],["Until I return","session"],["Forever on this site","forever"]],Ue=new WeakMap,Le=class{ready;#t;#e;#i=new Set;#s=[];#r=[];#n;#o;#h;#a;#l;#c;#d;#f;#u=0;#p=0;#v=!1;#y=!1;constructor(t,e,i){this.#t=t,this.#e=e;let s=At(e);this.#f=s[0],this.#n=t.createElement("div"),this.#n.dataset.peeklingControls="",this.#o=this.#n.attachShadow({mode:"closed"}),this.#c=`${i.url}\n${i.integrity??""}`,this.#d=i.integrity,this.#l=new Wt(t,this.#o,i),this.ready=this.#l.ready,this.ready.catch(()=>{}),this.#a=t.createElement("button"),this.#a.className="peekling-visibility-trigger",this.#a.type="button",this.#a.setAttribute("aria-label","Open Peekling visibility controls"),this.#a.textContent="🐾",this.#h=t.createElement("section"),this.#h.className="peekling-visibility-panel",this.#h.hidden=!0,this.#h.setAttribute("role","dialog"),this.#h.setAttribute("aria-label","Let Peekling rest");let r=t.createElement("h2");r.textContent="Let Peekling rest?",this.#h.append(r);for(let[e,i]of Ce){let s=t.createElement("button");s.className="peekling-visibility-option",s.type="button",s.textContent=e,s.addEventListener("click",()=>this.hide(i)),this.#h.append(s)}this.#o.append(this.#a,this.#h),this.#M(),this.#x(e,"storage",()=>this.refresh(),this.#s),this.#j(s[0],!1),this.#k(s[1])}#w(){if(!this.#r.length){this.#x(this.#t,"pointermove",t=>{"touch"===t.pointerType||"pen"===t.pointerType||this.#g(t.clientX,t.clientY)},this.#r),this.#x(this.#t,"pointerdown",t=>{let e=t;this.#v&&!this.#n.contains(t.target)&&this.close(),("touch"===e.pointerType||"pen"===e.pointerType)&&this.#g(e.clientX,e.clientY)},this.#r);for(let t of["pointerup","pointercancel","pointerout"])this.#x(this.#t,t,e=>{("pointerout"!==t||null===e.relatedTarget)&&this.#m()},this.#r);this.#x(this.#t,"keydown",t=>{"Escape"===t.key&&this.close(!0)},this.#r);this.#x(this.#a,"click",()=>this.open(!0),this.#r)}}#b(){this.#m(),this.#E(this.#r)}register(t){return this.#i.add(t),t(this.#f),()=>{this.#i.delete(t),this.#i.size||this.destroy()}}assertStyles(t){if(`${t.url}\n${t.integrity??""}`!==this.#c&&(!t.integrity||t.integrity!==this.#d))throw new TypeError("visibility.styles-conflict")}isHidden(){return this.#f}hide(t){let e=zt(this.#e,t);this.#$(!0),this.#k(e),this.close()}show(){Tt(this.#e),this.refresh()}refresh(){try{this.#M()}catch{let t=[...this.#i];this.destroy();for(let e of t)e(null);return}let t=At(this.#e);this.#$(t[0]),this.#k(t[1])}open(t=!1){this.#f||(this.#m(),this.#v=!0,this.#n.setAttribute("data-open",""),this.#h.hidden=!1,t&&this.#h.querySelector("button")?.focus())}close(t=!1){this.#v&&(this.#v=!1,this.#n.removeAttribute("data-open"),this.#h.hidden=!0,t&&this.#a.focus())}destroy(){this.#y||(this.#y=!0,this.#b(),this.#k(),this.#E(this.#s),this.#l.destroy(),this.#n.remove(),this.#i.clear(),Ue.delete(this.#t))}#g(t,e){this.#f||this.#v||t<this.#e.innerWidth-64||e<this.#e.innerHeight-64?this.#m():this.#u||(this.#u=this.#e.setTimeout(()=>this.open(),1e3))}#m(){this.#u&&this.#e.clearTimeout(this.#u),this.#u=0}#k(t){(this.#p&&this.#e.clearTimeout(this.#p),this.#p=0,void 0===t||this.#y)||(this.#p=this.#e.setTimeout(()=>{this.#p=0,this.refresh()},Math.max(0,Math.min(t-Date.now(),2147e6))))}#$(t){t!==this.#f&&this.#j(t,!0)}#j(t,e){if(this.#f=t,this.#n.toggleAttribute("data-hidden",t),this.#a.hidden=t,t?this.#b():this.#w(),e)for(let e of this.#i)e(t)}#x(t,e,i,s){t.addEventListener(e,i,{passive:!0}),s.push([t,e,i])}#E(t){for(let[e,i,s]of t.splice(0))e.removeEventListener(i,s)}#M(){if(t(this.#n,this.#t,"data-peekling-controls"),this.#o.host!==this.#n||this.#a.getRootNode()!==this.#o||this.#h.getRootNode()!==this.#o)throw Error("visibility.root")}},We=Object.freeze([]),He=class t{static hatch(e,i=Ae){return new t((t=>{if(void 0===t)return{};if("string"==typeof t)return{character:t};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("options.input");return t})(e),i)}Z(t){return!this.#e&&(bt(t)?(this.#C="string"==typeof t?t:!0===t?this.#s?.content.displayName??"":void 0,this.#s&&this.#C&&!this.#n?this.#W().ready.then(()=>this.#H(),()=>{this.#e||(this.#Z(),this.#F("failed"))}):this.#H(),!0):(this.#_("config.invalid-name","warning","config"),!0))}ready;finished;#t;#e=!1;#i=new AbortController;#s;#r;#n;#o;#h;#a;#l;#c=0;#d=0;#f=0;#u=0;#p=0;#v=0;#y="";#w={x:0,y:0};#b=0;#g=!1;#m;#k;#$;#j;#x;#E=!1;#M=0;#S;#z;#P;#A;#T;#I=4;#C;#R;#D;#U;#N;#L;#O;#V;#q;#J;#K;#Q;#X=0;#B=!1;#G=!1;#Y=!1;#tt;#et;#it=!1;#st=!1;#rt={x:0,y:0};#nt=0;constructor(t={},n=Ae){let o=(t=d(t)).document??globalThis.document,h=t.window??globalThis.window;if(!o||!h)throw Error("browser.context");this.#R=o,this.#D=h,this.#tt=new Pe(o),this.#L=t,this.#et=t.indicator,this.#Q=n,this.#O=h.performance?.now?.bind(h.performance)??Date.now,this.#q=`instance:${Math.floor(this.#O())}:${Math.random().toString(36).slice(2,8)}`,this.#J=new de({instanceId:this.#q,now:this.#O,...t.logger?{logger:t.logger}:{},...t.onDiagnostic?{messageSink:t.onDiagnostic}:{},...t.diagnostics?.context?{context:t.diagnostics.context}:{},...t.diagnostics?.debug?{debug:!0}:{},...void 0===t.diagnostics?.console?{}:{console:t.diagnostics.console}});let[a,l]=((t,n)=>{let o,h=((t,i)=>{mt(t,Ee,"$"),void 0===t.character&&void 0===t.pack&&void 0===t.packUrl&&$t("manifest.selection","$"),void 0!==t.format&&1!==t.format&&$t("unsupported-format","$.format"),void 0!==t.plan&&void 0!==t.preset&&$t("incompatible-behavior","$.preset"),void 0!==t.preset&&!["companion","still","bottom-patrol","viewport-roam"].includes(t.preset)&&$t("invalid-preset","$.preset"),void 0!==t.character&&("string"==typeof t.character&&Jt.test(t.character)?void 0===t.pack&&void 0===t.packUrl&&!Z(t.character)&&$t("character.unknown","$.character"):$t("invalid-character","$.character")),void 0!==t.scale&&(!Number.isInteger(t.scale)||t.scale<1||t.scale>4)&&$t("out-of-range","$.scale");for(let e of["density","maxDensity"]){let i=t[e];void 0!==i&&1!==i&&2!==i&&4!==i&&$t("invalid-density","$."+e)}void 0!==t.density&&void 0!==t.maxDensity&&t.density>t.maxDensity&&$t("incompatible-density","$.density"),void 0!==t.motionPreference&&!["system","full","reduce"].includes(t.motionPreference)&&$t("invalid-motion-preference","$.motionPreference"),bt(t.name)||$t("invalid-name","$.name");for(let e of["packUrl","atlasUrl"]){let s=t[e];void 0!==s&&!r(s,i)&&$t("invalid-url","$."+e)}let n=t.position;if(void 0!==n&&"bottom-left"!==n&&"bottom-right"!==n&&"center"!==n){let t=gt(n,"invalid-position","$.position",["x","y"]);("number"!=typeof t.x||!Number.isFinite(t.x)||Math.abs(t.x)>1e5||"number"!=typeof t.y||!Number.isFinite(t.y)||Math.abs(t.y)>1e5)&&$t("invalid-position","$.position")}let o,h=t.styles;if(void 0!==h){let t=gt(h,"invalid-styles","$.styles",["url","integrity"]);("string"!=typeof t.url||!r(t.url,i))&&$t("invalid-styles-url","$.styles.url"),e(t.integrity)||$t("invalid-styles-integrity","$.styles.integrity")}try{o=((t,e)=>{if(void 0===t)return{};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("content.object");let i=Object.entries(t);if(i.length>32)throw new TypeError("content.limit");let s={};for(let[t,r]of i){if(!Jt.test(t))throw new TypeError(Lt("content.id"));if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError(Lt("content.item"));y(r,qt);let i={};for(let t of qt){let s=r[t];void 0!==s&&(i[t]=v(s,e))}if(!Object.keys(i).length)throw new TypeError(Lt("content.empty"));s[t]=i}return s})(t.content,i)}catch(t){$t("invalid-content","$.content")}((t,e)=>{let i;if(void 0!==t){let e=gt(t,"invalid-bindings","$.bindings",["mounts"]);if(void 0!==e.mounts){let t=gt(e.mounts,"invalid-bindings","$.bindings.mounts",void 0);{i=t;let e=Object.entries(t);e.length>64&&$t("binding-limit","$.bindings.mounts");for(let[t,i]of e)(!Jt.test(t)||"function"!=typeof i)&&$t("invalid-binding","$.bindings.mounts."+t)}}}for(let[t,s]of Object.entries(e))for(let e of qt){let r=s[e];r&&"string"!=typeof r&&r.mountId&&!Object.hasOwn(i??{},r.mountId)&&$t("missing-binding",`$.content.${t}.${e}.mountId`)}})(t.bindings,o),(t=>{if(void 0===t)return;let e=gt(t,"invalid-targets","$.targets",void 0),i=Object.entries(e);i.length>16&&$t("target-limit","$.targets");for(let[t,e]of i)Jt.test(t)||$t("invalid-target","$.targets."+t),("string"!=typeof e||e.length<1||e.length>256||/[\0\r\n]/.test(e))&&$t("invalid-target-selector","$.targets."+t)})(t.targets),((t,e)=>{if(void 0===t||!1===t)return;let i=gt(t,"invalid-interaction","$.interaction",["press","pressEvent","drag","throw","dragState","riseState","fallState","landState","gravity","maxThrowSpeed","bounce","floorInset","label","contentInitiallyHidden","clearIndicatorOnPress","catchTarget","catchAnchor","catchMargin","catchEvent"]);void 0!==i.press&&!["toggle-content","show-content","hide-content","emit","none"].includes(i.press)&&$t("invalid-interaction","$.interaction.press"),void 0!==i.pressEvent&&("string"!=typeof i.pressEvent||!Kt.test(i.pressEvent))&&$t("invalid-interaction-event","$.interaction.pressEvent"),"emit"===i.press&&void 0===i.pressEvent&&$t("missing-interaction-event","$.interaction.pressEvent"),void 0!==i.pressEvent&&void 0!==i.press&&"emit"!==i.press&&$t("incompatible-interaction-event","$.interaction.pressEvent");for(let t of["drag","throw","contentInitiallyHidden","clearIndicatorOnPress"])void 0!==i[t]&&"boolean"!=typeof i[t]&&$t("invalid-interaction","$.interaction."+t);for(let t of["dragState","riseState","fallState","landState"])void 0!==i[t]&&("string"!=typeof i[t]||!Qt.test(i[t]))&&$t("invalid-interaction-state","$.interaction."+t);for(let[t,e,s]of[["gravity",0,1e4],["maxThrowSpeed",0,1e4],["bounce",0,1],["floorInset",0,1e3],["catchMargin",0,1e3]]){let r=i[t];void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<e||r>s)&&$t("invalid-interaction-range","$.interaction."+t)}void 0!==i.label&&!kt(i.label,120)&&$t("invalid-interaction-label","$.interaction.label"),void 0!==i.catchTarget&&("string"!=typeof i.catchTarget||!Jt.test(i.catchTarget)||!Object.hasOwn(e??{},i.catchTarget))&&$t("invalid-catch-target","$.interaction.catchTarget"),void 0!==i.catchAnchor&&!["center","top","right","bottom","left"].includes(i.catchAnchor)&&$t("invalid-catch-anchor","$.interaction.catchAnchor"),void 0!==i.catchEvent&&("string"!=typeof i.catchEvent||!Kt.test(i.catchEvent))&&$t("invalid-interaction-event","$.interaction.catchEvent")})(t.interaction,t.targets),(t=>{if(void 0===t)return;let e=gt(t,"invalid-indicator","$.indicator",["kind","count","label","color","visible"]);void 0!==e.kind&&"dot"!==e.kind&&"count"!==e.kind&&$t("invalid-indicator","$.indicator.kind"),kt(e.label,120)||$t("invalid-indicator","$.indicator.label"),void 0!==e.count&&("number"!=typeof e.count||!Number.isInteger(e.count)||e.count<0||e.count>999)&&$t("invalid-indicator","$.indicator.count"),void 0!==e.color&&!s(e.color)&&$t("invalid-indicator","$.indicator.color"),void 0!==e.visible&&"boolean"!=typeof e.visible&&$t("invalid-indicator","$.indicator.visible")})(t.indicator),!1===t.interaction&&void 0!==t.indicator&&$t("incompatible-indicator","$.indicator"),(t=>{if(void 0===t)return;let e=gt(t,"invalid-theme","$.theme",["background","color","linkColor","borderColor","radius","width","padding"]);for(let[t,i,s]of[["radius",0,64],["width",120,640],["padding",0,48]]){let r=e[t];void 0!==r&&("number"!=typeof r||!Number.isFinite(r)||r<i||r>s)&&$t("invalid-theme","$.theme."+t)}for(let t of["background","color","linkColor","borderColor"]){let i=e[t];void 0!==i&&!s(i)&&$t("invalid-theme","$.theme."+t)}})(t.theme),(t=>{if(void 0===t)return;let e=gt(t,"invalid-diagnostics","$.diagnostics",["console","debug","context"]);for(let t of["console","debug"])void 0!==e[t]&&"boolean"!=typeof e[t]&&$t("invalid-diagnostics","$.diagnostics."+t);let i=e.context;if(void 0===i)return;let s=gt(i,"invalid-diagnostic-context","$.diagnostics.context",void 0),r=Object.entries(s);r.length>16&&$t("diagnostic-context-limit","$.diagnostics.context");for(let[t,e]of r)(!/^[a-z][a-z0-9_.-]{0,31}$/.test(t)||!["string","number","boolean"].includes(typeof e)||"string"==typeof e&&e.length>64||"number"==typeof e&&!Number.isFinite(e))&&$t("invalid-diagnostic-context","$.diagnostics.context."+t)})(t.diagnostics),(t=>{if(void 0===t)return;let e=gt(t,"invalid-accessibility","$.accessibility",["announceContent","contentLabel"]);void 0!==e.announceContent&&"boolean"!=typeof e.announceContent&&$t("invalid-accessibility","$.accessibility.announceContent"),void 0!==e.contentLabel&&!kt(e.contentLabel,120)&&$t("invalid-accessibility","$.accessibility.contentLabel")})(t.accessibility);for(let e of["onDiagnostic","logger"])void 0!==t[e]&&"function"!=typeof t[e]&&$t("invalid-callback","$."+e);return o})(t,n);try{o=i(t.styles,n)}catch(t){jt("invalid-styles","$.styles")}if(void 0!==t.plan)try{B(t.plan,{contentIds:new Set(Object.keys(h)),targets:new Set(Object.keys(t.targets??{}))})}catch(t){jt("invalid-plan","$.plan")}return[h,o]})(t,h.location?.href??o.baseURI);this.#K=l,this.finished=new Promise(t=>{this.#t=t}),this.#C="string"==typeof t.name?t.name:!0===t.name?"":void 0,this.#N=a;let c=((t,e,i,s)=>{let r=Ue.get(t);return r?r.assertStyles(s):(r=new Le(t,e,s),Ue.set(t,r)),{unregister:r.register(i),ready:r.ready}})(o,h,t=>{null===t?(this.#ot("visibility.root-failed","internal.frame-failed","error","internal"),this.#F("failed")):this.#ht(t)},this.#K);this.#z=c.unregister,this.#P=c.ready,this.#A=()=>{o.hidden?(this.#at(2,!0),this.#_("lifecycle.hidden","info","lifecycle")):(this.#at(2,!1),this.#_("lifecycle.visible","info","lifecycle"))},o.addEventListener("visibilitychange",this.#A,{passive:!0}),this.#T=()=>this.#lt(),h.addEventListener("pagehide",this.#T,{passive:!0}),o.hidden&&this.#at(2,!0),this.ready=this.#ct(),this.ready.catch(()=>{})}emit(t,e){if(this.#e)return this.#dt("destroyed");if(this.#E)return this.#dt("hidden");if("string"!=typeof t||!Kt.test(t))return this.#dt("invalid-name");if(!this.#l)return this.#dt("not-ready");let i;try{i=p(e)}catch{return this.#dt("invalid-payload")}let s=this.#l.j(t,i,"application");return s.accepted?(this.#_(s.coalesced?"event.coalesced":"event.accepted","info","event",s.id),s):this.#dt(s.reason)}override(t){let e=t=>((t,e)=>Object.freeze({id:t,status:"rejected",finished:Promise.resolve({id:t,reason:e}),cancel(){}}))("override:rejected:"+ ++this.#X,t);if(this.#e)return e("destroyed");if(this.#E)return e("dismissed");if(!this.#V)return this.#G||(this.#G=!0,this.#_("override.not-ready","warning","override")),e("rejected");let i=this.#V.add(t),s=this.#V.browserCompletionFor(i.id),r=s?this.#l?.retainEvent(s):void 0;return i.finished.then(()=>{r?.(),this.#H()}),this.#H(),i}pause(){this.#e||1&this.#M||(this.#at(1,!0),this.#_("lifecycle.paused","info","lifecycle"))}resume(){this.#e||!(1&this.#M)||(this.#at(1,!1),this.#_("lifecycle.resumed","info","lifecycle"))}refreshTargets(){this.#a?.refresh()}setIndicator(t){this.#e||(this.#et=(t=>{if(null===t)return;let e=d(t);if(!e||"object"!=typeof e||Array.isArray(e)||void 0!==e.kind&&"dot"!==e.kind&&"count"!==e.kind||"string"!=typeof e.label||e.label.length<1||e.label.length>120||/[\u0000-\u001f\u007f]/.test(e.label)||void 0!==e.count&&(!Number.isInteger(e.count)||e.count<0||e.count>999)||void 0!==e.color&&!s(e.color)||void 0!==e.visible&&"boolean"!=typeof e.visible)throw new TypeError("indicator.invalid");return e})(t),this.#o?.updateIndicator(this.#et))}setContentVisible(t){if(this.#e||!this.#n)return!1;let e=this.#n.setUserHidden(!t);return this.#o?.setExpanded(e),this.#H(),e}toggleContent(){if(this.#e||!this.#n)return!1;let t=this.#n.toggleUserHidden();return this.#o?.setExpanded(t),this.#H(),t}destroy(){this.#F("destroyed")}#F(t){if(this.#e)return;this.#e=!0,this.#f+=1,this.#V?.clear("destroyed"),this.#i.abort(),this.#ft(),this.#l?.destroy(),this.#U?.reset(),this.#h?.destroy(),this.#a?.destroy(),this.#n?.destroy(),this.#o?.destroy(),this.#r?.destroy(),this.#z?.(),this.#z=void 0,this.#A&&(this.#R.removeEventListener("visibilitychange",this.#A),this.#A=void 0),this.#T&&(this.#D.removeEventListener("pagehide",this.#T),this.#T=void 0),this.#s?.release(),this.#m&&this.#k&&this.#m.removeEventListener("change",this.#k),this.#$&&this.#j&&this.#$.removeEventListener("change",this.#j),this.#_("lifecycle.destroyed","info","lifecycle");let e=this.#t;this.#t=void 0,e?.({reason:t})}async#ct(){try{let t=t=>((t,e)=>{try{return t.createDocumentFragment().querySelector(e),!0}catch{return!1}})(this.#R,t),e=new Set(Object.keys(this.#L.targets??{}));for(let e of Object.values(this.#L.targets??{}))if(!t(e))throw new TypeError(Lt("target.selector"));void 0!==this.#L.plan&&B(this.#L.plan,{contentIds:new Set(Object.keys(this.#N)),targets:e,validateSelector:t,validatePath:t=>this.#tt.validate(t)});let i,s=this.#D,n=s.navigator.connection;this.#I=this.#L.maxDensity??(n?.saveData?2:4);try{i=await(async t=>{let e=t.resourceTimeoutMs??3e4;void 0===t.pack&&void 0===t.packUrl&&void 0===t.character&&E("manifest.selection");let i,s,n=t.packUrl;if(void 0!==t.pack)i=t.pack;else{if(void 0===n){let e=(t=>{if(!Z(t))throw Error("character.unknown");return ge[t]})(t.character);n=e.url,s=e.sha256}let o=((t,e)=>{r(t,e)||E("url.protocol");try{return new URL(t,e).href}catch{E("url.invalid")}})(n,t.baseUrl);n=o;let h=await q(t.signal,e,"manifest.timeout",async e=>{let i=await J(t.fetch,o,e,"manifest.network");if(!i.ok)throw new fe("manifest.http","http","manifest.http");return F(i,["application/json"]),K(i,65536,e,"manifest.network")});s&&!await Q(h,s,!0)&&E("manifest.hash");try{i=(t=>((t,e,i=65536)=>{if((new TextEncoder).encode(t).byteLength>i)throw new ue([j(e+".size")]);let s,r;try{s=JSON.parse(t)}catch{throw new ue([j(e+".json")])}try{r=(t=>{let e,i=0,s=()=>{for(;/\s/.test(t[i]??"");)i++},r=()=>{let e=i++;for(;i<t.length;)if("\\"===t[i])i+=2;else if('"'===t[i++])break;return JSON.parse(t.slice(e,i))},n=(o=0)=>{if(s(),"{"===t[i]){if(o>=64)throw 0;i++;let h=new Set;for(s();"}"!==t[i];){let a=r();if(h.has(a)&&void 0===e&&(e=a),h.add(a),s(),i++,n(o+1),s(),","!==t[i])break;i++,s()}i++;return}if("["!==t[i])if('"'!==t[i])for(;i<t.length&&!/[\s,}\]]/.test(t[i]);)i++;else r();else{if(o>=64)throw 0;for(i++,s();"]"!==t[i]&&(n(o+1),s(),","===t[i]);)i++,s();i++}};return n(),e})(t)}catch(t){throw 0!==t?t:new ue([j(e+".depth")])}if(void 0!==r)throw new ue([j(e+".duplicate-key",JSON.stringify(r))]);return s})(t,"character.json"))(new TextDecoder("utf-8",{fatal:!0}).decode(h))}catch(t){if(t instanceof ue)throw t;E("manifest.utf8")}}try{i=c(i)}catch(t){throw t instanceof te?new ue([t.message],t.issueCode?[t.issueCode]:[]):t}let o=(t=>{if(!A(t))return!1;let e=Object.getOwnPropertyDescriptor(t,"atlas")?.value,i=Object.getOwnPropertyDescriptor(t,"assets")?.value;return A(e)&&!A(i)})(i),h=o?H:U,a=h(i),l=t.F??X(t.devicePixelRatio??1,t._??a.defaultScale,t.maxDensity),d=h(i,void 0,l),f=!1,u="",p=async s=>{let r=(e=>t.atlasUrl??(n?new URL(e,new URL(n,t.baseUrl)).href:void 0))(s.src);r||E("atlas.url");let[a,l]=await q(t.signal,e,"atlas.timeout",async e=>{let i=await J(t.fetch,r,e,"atlas.network");if(!i.ok)throw new fe("atlas.http","http","atlas.http");return[F(i,o?["image/png","image/webp"]:["image/png"]),await K(i,o?33554432:4194304,e,"atlas.network")]});await Q(l,s.sha256)||E("atlas.hash");let c=h(i,void 0,s.density);((t,e,i,s)=>{let r=((t,e)=>{t.byteLength>33554432&&E("resource.size");let i=T(t),s=P(t);return("image/png"===e&&s||"image/webp"===e&&i)&&E("atlas.mime"),"image/png"===e?(t=>{T(t)||E("png.signature");let e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=ye.length,s=0,r=0,n=-1,o=0,h=!1,a=!1,l=!1,c=!1;for(;i<t.byteLength;){t.byteLength-i<12&&E("png.truncated");let d=e.getUint32(i),f=i+8,u=f+d+4;(u>t.byteLength||u<f)&&E("png.chunk");let p=I(t,i+4);if(/^[A-Za-z]{4}$/.test(p)||E("png.chunk-type"),o+=1,o>4096&&E("png.chunks"),!h&&("IHDR"!==p||13!==d)&&E("png.ihdr-first"),"IHDR"===p){(h||13!==d)&&E("png.ihdr"),h=!0,s=e.getUint32(f),r=e.getUint32(f+4);let i=t[f+8];n=t[f+9];let o={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};(s<1||r<1||s>ve||r>ve)&&E("png.dimensions"),(!o[n]?.includes(i)||0!==t[f+10]||0!==t[f+11]||0!==t[f+12]&&1!==t[f+12])&&E("png.fields")}else if("PLTE"===p)c&&E("png.palette-order"),a=!0;else if("tRNS"===p)c&&E("png.alpha-order"),l=!0;else if("IDAT"===p)3===n&&!a&&E("png.palette"),c=!0;else{if("IEND"===p)return(0!==d||!c)&&E("png.iend"),u!==t.byteLength&&E("png.trailing"),{width:s,height:r,hasAlpha:4===n||6===n||3===n&&l,mimeType:"image/png"};p.charCodeAt(0)<=90&&E("png.critical")}i=u}E("png.truncated")})(t):(t=>{(t.byteLength<20||!P(t))&&E("webp.header");let e=new DataView(t.buffer,t.byteOffset,t.byteLength);e.getUint32(4,!0)+8!==t.byteLength&&E("webp.size");let i,s,r=12,n=0,o=!1;for(;r<t.byteLength;){t.byteLength-r<8&&E("webp.chunk");let h=I(t,r),a=e.getUint32(r+4,!0),l=r+8,c=l+a+(1&a);if((c<l||c>t.byteLength)&&E("webp.chunk"),n+=1,n>4096&&E("webp.chunks"),"ALPH"===h)o=!0;else if("VP8X"===h)a<10&&E("webp.vp8x"),i=R(1+D(t,l+4),1+D(t,l+7),!!(16&t[l])||o);else if("VP8L"===h){(a<5||47!==t[l])&&E("webp.vp8l");let r=e.getUint32(l+1,!0),n=R(1+(16383&r),1+(r>>>14&16383),!0);s??=i??n}else if("VP8 "===h){(a<10||157!==t[l+3]||1!==t[l+4]||42!==t[l+5])&&E("webp.vp8");let r=R(16383&e.getUint16(l+6,!0),16383&e.getUint16(l+8,!0),o);s??=i??r}else!i&&!s&&"ICCP"!==h&&"EXIF"!==h&&"XMP "!==h&&E("webp.chunk-type");r=c}if(s)return s;E("webp.image")})(t)})(t,e);(r.width!==s.width||r.height!==s.height)&&E("atlas.dimensions"),!i&&!r.hasAlpha&&E("atlas.alpha")})(l,a,o,{width:c.atlas.columns*c.atlas.cellWidth,height:c.atlas.rows*c.atlas.cellHeight});let d=t.createObjectURL(new Blob([l]));try{let e=await(async(t,e,i)=>(await new Promise((s,r)=>{let n=()=>{t.removeEventListener("load",o),t.removeEventListener("error",h),i.removeEventListener("abort",a)},o=()=>{n(),s()},h=()=>{n(),r(new fe("atlas.decode","decode","atlas.decode"))},a=()=>{n(),t.removeAttribute("src"),r(i.reason)};if(t.addEventListener("load",o,{once:!0}),t.addEventListener("error",h,{once:!0}),i.addEventListener("abort",a,{once:!0}),i.aborted)return a();t.src=e}),{width:t.naturalWidth,height:t.naturalHeight}))(t.image(),d,t.signal);return{pack:h(i,{...e,byteLength:l.byteLength},s.density),V:d}}catch(e){throw t.revokeObjectURL(d),e}},v=async(e,i)=>{let s,r=(e=>{let i=a.atlas.variants;if(!i?.length){let e=d.atlas.density??1;return void 0!==t.F&&t.F!==e&&E("atlas.override-density"),e>(t.maxDensity??4)&&E("atlas.max-density"),d.atlas.sha256||E("atlas.integrity-declaration"),[{src:d.atlas.src,density:e,sha256:d.atlas.sha256}]}let s=i.filter(e=>e.density<=(t.maxDensity??4));if(s.length||E("atlas.max-density"),void 0!==t.atlasUrl){void 0===t.F&&E("atlas.override-density");let e=s.find(e=>e.density===t.F);return e||E("atlas.override-density"),[e]}let r=L(s.map(t=>t.density),e);return s.filter(t=>t.density<=r).sort((t,e)=>e.density-t.density)})(e);for(let[e,n]of r.entries()){if(i&&n.density<=(d.atlas.density??1))return;try{return await p(n)}catch(i){if(t.signal.aborted)throw t.i?.(Lt("atlas.abort"),"abort"),i;s=i;let n=_(i),o=e<r.length-1;t.i?.(Lt(`atlas.${n}.${o?"fallback":"exhausted"}`),n)}}if(!i)throw s??new fe("atlas.unusable","validation","atlas.unusable")},y=await v(l,!1);if(!y)throw new fe("atlas.unusable","validation","atlas.unusable");d=y.pack,u=y.V;let w=d.atlas.density??1,b=0,g={get content(){return d},get q(){return u},get J(){return d.atlas.density??1},async upgrade(e){if(f||void 0!==t.atlasUrl||e<=g.J)return!1;w=Math.max(w,e);let i=++b,s=await v(w,!0),r=s?.pack.atlas.density??1;if(!s||f||r<=g.J||i!==b&&r<w)return s&&t.revokeObjectURL(s.V),!1;let n=u;return d=s.pack,u=s.V,t.revokeObjectURL(n),!0},release(){f||(f=!0,u&&t.revokeObjectURL(u),u="")}};return g})({...void 0===this.#L.character?{}:{character:this.#L.character},baseUrl:this.#D.location.href,...void 0===this.#L.pack?{}:{pack:this.#L.pack},...void 0===this.#L.packUrl?{}:{packUrl:this.#L.packUrl},...void 0===this.#L.atlasUrl?{}:{atlasUrl:this.#L.atlasUrl},...void 0===this.#L.scale?{}:{_:this.#L.scale},devicePixelRatio:this.#D.devicePixelRatio,...void 0===this.#L.density?{}:{F:this.#L.density},maxDensity:this.#I,fetch:this.#D.fetch.bind(this.#D),image(){return new s.Image},signal:this.#i.signal,createObjectURL:s.URL.createObjectURL.bind(s.URL),revokeObjectURL:s.URL.revokeObjectURL.bind(s.URL),i:(t,e)=>{this.#ot(t,e?"config.pack-load-"+e:"config.pack-load","warning","config")}})}catch(t){throw this.#e&&this.#i.signal.aborted||this.#_("config.pack-load-failed","error","config",void 0,void 0,t),t}if(this.#e)throw i.release(),new DOMException("lifecycle.destroyed","AbortError");let o=this.#L.scale??i.content.defaultScale;if(!Number.isInteger(o)||o<1||o>4)throw i.release(),new TypeError("scale.value");this.#s=i;let h=(t=>_t.every(e=>Object.hasOwn(t.directionalStates??{},e)))(i.content),a=new Set(h?["locomotion"]:[]),l=B(this.#L.plan??((t,e)=>"still"===t?{baseline:{channels:["state"],state:{state:"idle"}}}:"bottom-patrol"===t||"viewport-roam"===t?{baseline:{channels:["motion","state"],state:e?{capability:"locomotion"}:{state:"idle"},motion:"bottom-patrol"===t?{type:"horizontal-patrol",speed:160}:{type:"viewport-traverse",speed:160}}}:{baseline:{channels:["state"],state:{state:"idle"}},...e?{rules:[{id:"follow-pointer",when:{source:"browser",event:"pointer.move"},effect:{channels:["motion","state"],motion:{type:"follow-pointer",speed:160},state:{capability:"locomotion"}}}]}:{}})(this.#L.preset??"companion",h),{states:new Set(Object.keys(i.content.states)),capabilities:a,contentIds:new Set(Object.keys(this.#N)),targets:e,validateSelector:t,validatePath:t=>this.#tt.validate(t)});this.#U=new je(l),this.#V=new Se({states:new Set(Object.keys(i.content.states)),capabilities:a,contentIds:new Set(Object.keys(this.#N)),targets:e,validatePath:t=>this.#tt.validate(t)},this.#O,t=>this.#ot(t,"override.rejected","warning","override")),""===this.#C&&(this.#C=i.content.displayName);let d=this.#L.motionPreference??"system";if(this.#m=this.#D.matchMedia("(prefers-reduced-motion: reduce)"),this.#g="reduce"===d||"system"===d&&this.#m.matches,"system"===d&&(this.#k=t=>{this.#g=t.matches,this.#_(t.matches?"lifecycle.reduced-motion-enabled":"lifecycle.reduced-motion-disabled","info","lifecycle"),this.#H()},this.#m.addEventListener("change",this.#k)),this.#ut(),this.#w=((t,e,i,s,r)=>{let n;if("center"===t)n={x:e/2,y:i/2};else if("bottom-right"===t||"bottom-left"===t)n={x:"bottom-right"===t?e-s/2-16:s/2+16,y:i-r/2-16};else{if("object"!=typeof t)throw new TypeError("position.value");if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new TypeError("position.coordinates");n=t}return Pt(n,{width:e,height:i},s,r)})(this.#L.position??"bottom-right",this.#D.innerWidth,this.#D.innerHeight,(i.content.atlas.logicalWidth??i.content.atlas.cellWidth)*o,(i.content.atlas.logicalHeight??i.content.atlas.cellHeight)*o),this.#r=this.#Q({document:this.#R,pack:i.content,atlasUrl:i.q,scale:o,styles:this.#K}),(Object.keys(this.#N).length||void 0!==this.#C)&&this.#W(),!1!==this.#L.interaction){let t=this.#L.interaction??{},e=t.press??(t.pressEvent?"emit":"toggle-content"),s=!!this.#n&&("toggle-content"===e||"show-content"===e||"hide-content"===e);t.contentInitiallyHidden&&this.#n?.setUserHidden(!0),this.#o=new ae({document:this.#R,styles:this.#K,label:t.label??"Interact with "+(i.content.displayName||"Peekling"),draggable:!1!==t.drag,...s?{expanded:!t.contentInitiallyHidden}:{},...this.#et?{indicator:this.#et}:{},onPress:()=>this.#pt(),onDragStart:()=>this.#vt(),onDragMove:(t,e)=>this.#yt(t,e),onDragEnd:(t,e,i)=>this.#wt(t,e,i)}),t.contentInitiallyHidden&&this.#o.setExpanded(!1)}try{await Promise.all([this.#P,this.#r.ready,this.#n?.ready,this.#o?.ready])}catch(t){throw this.#Z(t),t}let f=(t=>{let e=new Set,i=new Set([0,1]);for(let s of t.rules)"browser"===s.when.source&&"section.visibility"===s.when.event&&(e.add(s.when.selector),i.add(s.when.threshold??.25));return{selectors:[...e],thresholds:[...i].sort((t,e)=>t-e)}})(l);return this.#bt(),e.size&&(this.#a=new Ie(this.#R,this.#D,this.#L.targets,()=>this.#H())),f.selectors.length&&(this.#h=new Te(this.#R,this.#D,f.selectors,f.thresholds,()=>this.#H(),t=>this.#l?.j("section.visibility",t,"browser"))),this.#r.N(this.#E),this.#o?.N(this.#E),this.#M&&(this.#l?.O(!0),this.#h?.O(!0)),this.#u=this.#O(),this.#gt(this.#u,!0),this}catch(t){throw this.#F("failed"),t}}#bt(){if(this.#e||this.#l||!this.#U)return;let t=new Set,e=new Map;for(let i of this.#U.plan.rules){let s="browser"===i.when.source;if(s&&t.add(i.when.event),"event"===i.effect.until?.type){let e=f(i.effect.until.name);e&&t.add(e)}if("latest"!==i.when.coalesce)continue;let r=`${i.when.source}:${i.when.event}`;if(s)e.set(r,!0);else{let t=i.effect.surfaces[0].ordering;e.set(r,{sessionField:t.sessionField,revisionField:t.revisionField})}}this.#l=new he(this.#R,this.#D,{events:t,coalesce:e,i:t=>this.#ot(t,"event.queue-overflow","warning","event"),now:this.#O,wake:()=>this.#H()}),t.has("page.lifecycle")&&this.#l.j("page.lifecycle",{phase:"show"},"browser")}#W(){return this.#n||this.#e||(this.#n=new oe(this.#R,{i:t=>this.#ot(t,"render.host-failed","error","render"),...this.#L.bindings?{bindings:this.#L.bindings}:{},...this.#L.theme?{theme:this.#L.theme}:{},...this.#L.accessibility?.announceContent?{announce:!0}:{},...this.#L.accessibility?.contentLabel?{label:this.#L.accessibility.contentLabel}:{},emit:(t,e)=>this.emit(t,e),wake:()=>this.#H(),styles:this.#K})),this.#n}#pt(){if(this.#e)return;let t=this.#L.interaction||{};!0===t.clearIndicatorOnPress&&this.#et&&this.setIndicator(null);let e=t.press??(t.pressEvent?"emit":"toggle-content");"emit"!==e?"none"!==e&&("show-content"===e?this.setContentVisible(!0):"hide-content"===e?this.setContentVisible(!1):this.toggleContent()):t.pressEvent&&this.emit(t.pressEvent)}#vt(){this.#e||this.#E||(this.#it=!0,this.#st=!1,this.#nt=0,this.#rt={x:0,y:0},this.#H())}#yt(t,e){if(!this.#it||this.#e)return;let i=this.#mt();this.#w=i?Pt(t,{width:this.#D.innerWidth,height:this.#D.innerHeight},i.width,i.height):{...t},this.#rt={...e},this.#H()}#wt(t,e,i){if(!this.#it||this.#e)return;if(this.#it=!1,!e){this.#rt={x:0,y:0},this.#H();return}let s=this.#L.interaction||{};if(s.catchTarget&&this.#a?.contains(s.catchTarget,i,s.catchMargin??24)&&this.#kt(s.catchTarget))return;if(this.#g){this.#$t();return}if(!1===s.throw){this.#rt={x:0,y:0},this.#H();return}let r=s.maxThrowSpeed??1800,n=Math.hypot(t.x,t.y),o=n>r&&n?r/n:1;this.#rt={x:t.x*o,y:t.y*o},this.#st=!0,this.#H()}#mt(){let t=this.#s?.content;if(!t)return;let e=this.#L.scale??t.defaultScale;return{width:(t.atlas.logicalWidth??t.atlas.cellWidth)*e,height:(t.atlas.logicalHeight??t.atlas.cellHeight)*e}}#$t(){let t=this.#mt();if(t){let e=(this.#L.interaction||{}).floorInset??8;this.#w=Pt({x:this.#w.x,y:this.#D.innerHeight-t.height/2-e},{width:this.#D.innerWidth,height:this.#D.innerHeight},t.width,t.height)}this.#it=!1,this.#st=!1,this.#rt={x:0,y:0},this.#nt=this.#O()+360,this.#H()}#kt(t){let e=this.#a?.H(!0)[t],i=this.#mt();if(!e||!i)return!1;let s=this.#L.interaction||{},r=((t,e,i)=>{let s={x:t.left+t.width/2,y:t.top+t.height/2};switch(e){case"top":return{x:s.x,y:t.top-i.height/2};case"right":return{x:t.right+i.width/2,y:s.y};case"bottom":return{x:s.x,y:t.bottom+i.height/2};case"left":return{x:t.left-i.width/2,y:s.y};default:return s}})(e,s.catchAnchor??"center",i);return this.#w=Pt(r,{width:this.#D.innerWidth,height:this.#D.innerHeight},i.width,i.height),this.#st=!1,this.#rt={x:0,y:0},this.#nt=this.#O()+360,s.catchEvent&&this.emit(s.catchEvent),this.#H(),!0}#ot(t,e="runtime.notice",i="warning",s="internal",r,n,o){this.#J.emit({code:e,severity:i,message:t,phase:s,...void 0===r?{}:{eventId:r},...n?{metadata:n}:{},...o?{cause:o}:{}})}#_(t,e="warning",i="internal",s,r,n){this.#ot(t,t,e,i,s,r,n)}#Z(t){this.#_("config.styles-load-failed","error","config",void 0,void 0,t)}#dt(t){if("not-ready"===t){if(this.#B)return{accepted:!1,reason:t};this.#B=!0}return this.#ot("event.rejected","event.rejected."+t,"warning","event",void 0,{reason:t}),{accepted:!1,reason:t}}#jt(){void 0===this.#S&&(this.#S=this.#O(),this.#ft(),this.#l?.O(!0),this.#h?.O(!0))}#ft(){this.#c&&this.#D.cancelAnimationFrame(this.#c),this.#c=0,this.#d&&this.#D.clearTimeout(this.#d),this.#d=0}#xt(){if(void 0===this.#S||this.#M||this.#e)return;let t=this.#O(),e=Math.max(0,t-this.#S);this.#S=void 0,this.#V?.D(e),this.#U?.D(e),this.#l?.O(!1),this.#h?.O(!1),this.#u=t,this.#H()}#at(t,e){let i=this.#M;e?this.#M|=t:this.#M&=~t,i!==this.#M&&(this.#f+=1,!i&&this.#M&&this.#jt(),i&&!this.#M&&this.#xt())}#ht(t){if(t!==this.#E&&(this.#E=t,this.#r?.N(t),this.#o?.N(t),!(this.#e||t&&this.#n&&(this.#n.o([],{},this.#w,{width:this.#D.innerWidth,height:this.#D.innerHeight},{width:0,height:0}),this.#e)))){if(t){this.#it=!1,this.#st=!1,this.#rt={x:0,y:0},this.#V?.clear("dismissed"),this.#at(4,!0),this.#_("lifecycle.dismissed","info","lifecycle");return}this.#at(4,!1),this.#r&&this.#s&&!this.#e&&(this.#_("lifecycle.shown","info","lifecycle"),this.#e||this.#H())}}#H(){if(this.#e||this.#M||!this.#r||this.#c)return;this.#d&&this.#D.clearTimeout(this.#d),this.#d=0;let t=this.#f,e=this.#D.requestAnimationFrame(()=>{if(this.#c=0,!this.#e&&!this.#M&&t===this.#f)try{this.#gt(this.#O())}catch(t){this.#_("internal.frame-failed","error","internal",void 0,void 0,t),this.#F("failed")}});this.#e||this.#M||t!==this.#f?this.#D.cancelAnimationFrame(e):this.#c=e}#Et(t){if(!this.#Mt(t))return;this.#d&&this.#D.clearTimeout(this.#d),this.#d=0;let e=t.overrides.P(),i=Number.isFinite(e)?e:void 0,s=t.plan.P(),r=Number.isFinite(s)?s:void 0,n=this.#g?void 0:t.renderer.W(this.#p),o=Number.isFinite(n)?n:void 0,h=void 0===o?void 0:t.now+o,a=void 0===i?r:void 0===r?i:Math.min(i,r),l=void 0===a?h:void 0===h?a:Math.min(a,h);if(void 0===l||!Number.isFinite(l)||!this.#Mt(t))return;let c=this.#D.setTimeout(()=>{this.#Mt(t)&&(this.#d=0,this.#H())},Math.min(2147483647,Math.max(0,l-t.now)));this.#Mt(t)?this.#d=c:this.#D.clearTimeout(c)}#ut(){this.#$&&this.#j&&this.#$.removeEventListener("change",this.#j),this.#$=this.#D.matchMedia(`(resolution: ${this.#D.devicePixelRatio}dppx)`),this.#j=()=>{this.#ut(),this.#Ot(),this.#H()},this.#$.addEventListener("change",this.#j)}#Ot(){if(this.#e||!this.#s||!this.#r||this.#x||void 0!==this.#L.density)return;let t=this.#L.scale??this.#s.content.defaultScale,e=X(this.#D.devicePixelRatio,t,this.#I);if(e<=this.#s.J)return;let i=this.#s;this.#x=i.upgrade(e).then(t=>{if(t&&!this.#e&&this.#s===i){let t=this.#r;return t?Promise.resolve(t.L(i.content,i.q)).then(()=>{!this.#e&&this.#s===i&&this.#H()}):void 0}}).catch(t=>{this.#e||this.#_("render.atlas-upgrade-failed","warning","render",void 0,void 0,t)}).finally(()=>{this.#x=void 0})}#Mt(t){return!this.#e&&!this.#M&&t.K===this.#f&&t.renderer===this.#r&&t.loaded===this.#s&&t.input===this.#l&&t.plan===this.#U&&t.overrides===this.#V}#St(t,e){let i=this.#r,s=this.#s,r=this.#l,n=this.#U,o=this.#V;if(this.#e||this.#M||!i||!s||!r||!n||!o)return;let h=t-this.#u;if(e||!(h<1e3/30))return{K:this.#f,now:t,elapsed:h,stepMs:Math.min(Math.max(0,h)||1e3/30,100),renderer:i,loaded:s,input:r,plan:n,overrides:o};this.#H()}#Nt(t){let e=t.loaded.content,i=t.input,s=this.#L.scale??e.defaultScale,r={width:this.#D.innerWidth,height:this.#D.innerHeight},n={width:(e.atlas.logicalWidth??e.atlas.cellWidth)*s,height:(e.atlas.logicalHeight??e.atlas.cellHeight)*s},o=this.#D.devicePixelRatio;this.#Ot(),this.#w=Pt(this.#w,r,n.width,n.height);let h=this.#h?.H(),a=i.reaction,l=a&&a.id>this.#b?a:void 0;return{frame:t,devicePixelRatio:o,t:n,world:{now:t.now,pointer:i.pointer,position:this.#w,viewport:r,t:n,$:i.$,reducedMotion:this.#g,pageVisible:!this.#R.hidden,sections:h,targets:this.#a?.H(this.#Y),samplePath:(t,e)=>this.#tt.sample(t,e),reaction:l},reaction:l}}#At(t){let{frame:e,world:i,reaction:s}=t,{plan:r,overrides:n}=e,o=r.evaluate(i),h=s?r.lastEventStatus:void 0,a=s?r.lastEventRejections:[];s&&"invalid"!==h&&"stale"!==h&&"closed"!==h&&n.C(s.name,s.source);let l=n.compose(o,i);this.#Y=!0===l.motion?.trackTarget,this.#g&&(delete l.motion,"locomotion"===l.capability&&delete l.capability,l.state||(l.state="idle"));let c=this.#L.interaction||{};this.#it?(delete l.motion,delete l.capability,l.state=c.dragState??"scroll:fly"):this.#st?(delete l.motion,delete l.capability,l.state=this.#rt.y<0?c.riseState??"scroll:fly":c.fallState??"scroll:fall"):this.#nt>i.now&&(delete l.motion,delete l.capability,l.state=c.landState??"success");let d=[];if(s)if(this.#b=s.id,e.input.M(s.id),a.length)for(let t of a)d.push(Object.freeze({message:Lt("event."+t.status),code:"event."+t.status,severity:"invalid"===t.status?"warning":"info",eventId:s.id,metadata:Object.freeze({channel:t.channel})}));else"stale"===h||"closed"===h||"invalid"===h?d.push(Object.freeze({message:"event."+h,code:"event."+h,severity:"invalid"===h?"warning":"info",eventId:s.id})):"matched"!==h&&d.push(Object.freeze({message:"event.unmatched",code:"event.unmatched",severity:"info",eventId:s.id}));return{request:l,diagnostics:d}}#zt(t,e){for(let i of e){if(!this.#Mt(t))return!1;this.#ot(i.message,i.code,i.severity,"event",i.eventId,i.metadata)}return this.#Mt(t)}#Tt(t){if(!this.#st)return;let e=this.#L.interaction||{},i=t.frame.stepMs/1e3,s=e.bounce??.35,r=t.t.width/2,n=t.t.height/2,o=t.world.viewport.height-n-(e.floorInset??8),h=this.#rt.x,a=this.#rt.y+(e.gravity??1800)*i,l=this.#w.x+h*i,c=this.#w.y+a*i,d=t.world.viewport.width-r;l<r?(l=r,h=Math.abs(h)*s):l>d&&(l=d,h=-Math.abs(h)*s),c<n&&(c=n,a=Math.abs(a)*s);let f={x:l,y:c};if(!(e.catchTarget&&this.#a?.contains(e.catchTarget,f,e.catchMargin??24)&&this.#kt(e.catchTarget))){if(c>=o){this.#w={x:l,y:o},this.#$t();return}this.#w=f,this.#rt={x:.995*h,y:a}}}#Pt(t,e){let{frame:i,t:s,world:r}=t,{request:n}=e,o=i.loaded.content;this.#g||(this.#p+=Math.max(0,i.elapsed)),this.#Tt(t);let h="locomotion"===n.capability&&n.motion?o.directionalStates?.[((t,e)=>le[(Math.round(Math.atan2(e.y-0,e.x-0)/(Math.PI/4))+8)%8])(0,{x:n.motion.x,y:n.motion.y})]:((t,e)=>{if(t)return e.reactionStates&&Object.hasOwn(e.reactionStates,t)?e.reactionStates[t]:t})(n.state,o),a=((t,e)=>{let i=Object.keys(e);if(0===i.length)throw Error("state.empty");let s=t=>Object.hasOwn(e,t);if(t&&s(t))return{name:t};if(t)for(let e of Object.hasOwn(ze,t)?ze[t]:[])if(s(e))return{name:e};return s("idle")?{name:"idle"}:{name:i.sort()[0]}})(h,o.states),l=0;if(n.motion?.direct){let t=n.motion.maxDistance??0;this.#w=Pt({x:this.#w.x+n.motion.x*t,y:this.#w.y+n.motion.y*t},r.viewport,s.width,s.height),l=n.motion.lift??0,this.#y="",this.#v=0}else if(n.motion){this.#y!==a.name&&(this.#y=a.name,this.#v=0);let t=k(o.states[a.name]),e=this.#v/t;this.#v+=i.stepMs;let h=this.#v/t,c=h-e,d=((t,e,i)=>(Math.floor(i)-Math.floor(e))*(t?.length?t.at(-1).advance-t[0].advance:1)+$(t,i).advance-$(t,e).advance)(o.locomotionMotion,e,h),f=n.motion.speed*(i.stepMs/1e3)*(c>0?d/c:1),u=Math.min(f,n.motion.maxDistance??f);this.#w=Pt({x:this.#w.x+n.motion.x*u,y:this.#w.y+n.motion.y*u},r.viewport,s.width,s.height),l=n.motion.lift??$(o.locomotionMotion,h).lift*s.height}else this.#y="",this.#v=0;return{state:a.name,lift:l}}#gt(t,e=!1){let i=this.#St(t,e);if(!i||!this.#Mt(i))return;let s=this.#Nt(i);if(!this.#Mt(i))return;let r=this.#At(s);if(!this.#Mt(i)||!this.#zt(i,r.diagnostics))return;let n=this.#Pt(s,r);this.#Mt(i)&&(this.#n?.o(r.request.surfaces??We,this.#N,this.#w,s.world.viewport,s.t,this.#C),this.#Mt(i)&&(i.renderer.S(n.state,this.#p,this.#w,s.devicePixelRatio,n.lift),this.#Mt(i)&&(this.#o?.S(this.#w,s.t,n.lift),this.#Mt(i)&&(this.#u=i.now,this.#Et(i),this.#Mt(i)&&(r.request.motion||i.input.reaction||this.#st||this.#it)&&this.#H()))))}#lt(){if(!this.#e)try{this.#l&&this.#U&&(this.#It(this.#O()),this.#l.j("page.lifecycle",{phase:"hide"},"browser"),this.#It(this.#O())),this.#_("lifecycle.pagehide","info","lifecycle")}finally{this.#F("pagehide")}}#It(t){if(!this.#l||!this.#U)return;let e=this.#l.reaction;for(;e;)this.#U.evaluate({now:t,position:this.#w,viewport:{width:this.#D.innerWidth,height:this.#D.innerHeight},$:this.#l.$,reducedMotion:this.#g,pageVisible:!1,reaction:e}),this.#b=e.id,this.#l.M(e.id),e=this.#l.reaction}},Ze="peekling-character",Fe=0,_e="sha256-r4PIKebZlQTb2JaHfQibQqQxHaKciwlXtTMDEvDTUPY=",Ve=globalThis.document?.currentScript;Ve?.src&&(t=>{Rt=Object.freeze({...t})})({url:new URL("./peekling.css",Ve.src).href,..._e?{integrity:_e}:{}});var qe=Object.freeze({hatch(t){return He.hatch(t)},visibility:Object.freeze({hide(t,e=globalThis.document,i=globalThis.window){if(!e||!i)throw Error("browser.context");let s=Ue.get(e);s?s.hide(t):zt(i,t)},show(t=globalThis.document,e=globalThis.window){if(!t||!e)throw Error("browser.context");let i=Ue.get(t);i?i.show():Tt(e)},isHidden(t=globalThis.window){return!!((t=globalThis.window)=>{if(!t)throw Error("browser.window");return Ue.get(t.document)?.isHidden()??((t,e=Date.now())=>At(t,e)[0])(t)})(t)}})});try{Reflect.has(globalThis,"Peekling")?It("Peekling"):Object.defineProperty(globalThis,"Peekling",{configurable:!0,value:qe,writable:!1})}catch{It("Peekling")}(function(){try{let t=globalThis.customElements,e=globalThis.HTMLElement;if(!t||!e)return;let i=t.get(Ze);if(i){i!==Ut&&It(Ze);return}class s extends e{static observedAttributes=["character","pack-url","name","styles-url","styles-integrity"];static{for(let t of["plan","content","bindings","theme","styles","accessibility","diagnostics","logger"])Object.defineProperty(this.prototype,t,{configurable:!0,get(){return this.#s[t]},set(e){this.#l(t,e)}})}#t;#e=Object.create(null);#i;#s=Object.create(null);#r=!1;#n=!1;#o=0;#h=Dt();#a=t=>{t.persisted&&this.#c()};get options(){return this.#e}set options(t){try{this.#e=d(t),this.#i=void 0}catch(t){this.#e=Object.create(null),this.#i=t}this.#c()}get instance(){return this.#t}get ready(){return this.#h[0]}emit(t,e){return this.#t?.emit(t,e)??{accepted:!1,reason:"not-ready"}}override(t){if(!this.#t){let t="override:disconnected:"+ ++Fe;return{id:t,status:"rejected",finished:Promise.resolve({id:t,reason:"rejected"}),cancel(){}}}return this.#t.override(t)}pause(){this.#t?.pause()}resume(){this.#t?.resume()}connectedCallback(){globalThis.addEventListener?.("pageshow",this.#a),this.#c()}attributeChangedCallback(t){let e=this.getAttribute("name");"name"===t&&this.#t&&this.#t.Z(null===e?this.#e.name:e||!0)||this.#c()}disconnectedCallback(){globalThis.removeEventListener?.("pageshow",this.#a),this.#o+=1,this.#r=!1,this.#h[2](new DOMException("element.disconnected","AbortError")),this.#t?.destroy(),this.#t=void 0}#l(t,e){void 0===e?delete this.#s[t]:this.#s[t]=e,this.#c()}#c(){if(!this.isConnected||this.#r)return;this.#r=!0;let t=++this.#o;this.#n?(this.#h[2](new DOMException("element.remounted","AbortError")),this.#h=Dt()):this.#n=!0,queueMicrotask(()=>{t===this.#o&&(this.#r=!1,this.isConnected&&(this.#t?.destroy(),this.#t=void 0,this.#d(t)))})}async#d(t){try{if(this.#i)throw this.#i;if(!this.#e||"object"!=typeof this.#e||Array.isArray(this.#e))throw new te("$","data.plain");let e=Object.create(null);for(let t of[this.#e,this.#s])for(let i in t)e[i]=t[i];let i=this.getAttribute("character");null!==i&&(e.character=i);let s=this.getAttribute("pack-url");null!==s&&(e.packUrl=s);let r=this.getAttribute("name");null!==r&&(e.name=r||!0);let n=this.getAttribute("styles-url");if(null!==n){let t=this.getAttribute("styles-integrity");e.styles=t?{url:n,integrity:t}:{url:n}}let o=He.hatch(e);if(this.#t=o,await o.ready,t!==this.#o||!this.isConnected){o.destroy();return}this.#h[1](o)}catch(e){if(t!==this.#o)return;this.#t?.destroy(),this.#t=void 0,this.#h[2](e)}}}t.define(Ze,s),Ut=s}catch{It(Ze)}})()})();
|
package/dist/peekling.min.js.sri
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
sha384-
|
|
1
|
+
sha384-iWLrycCEm5UEMtb8i9CshYh8AkU1w+crgNFLXLQSKPWIncrWcWzx+ma5uLswMLzQ
|
package/dist/runtime.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { RuntimeStyleAsset } from "./styles.js";
|
|
|
4
4
|
import { type DiagnosticRecord, type EmitResult, type HostContent, type HostBindings, type NativeManifest, type NormalizedPack, type Point, type PeeklingPreset, type Plan, type OverrideHandle, type OverrideInput, type SurfaceTheme, type TargetAnchor } from "./types.js";
|
|
5
5
|
export type PeeklingPosition = "bottom-left" | "bottom-right" | "center" | Readonly<Point>;
|
|
6
6
|
export type PeeklingPressAction = "toggle-content" | "show-content" | "hide-content" | "emit" | "none";
|
|
7
|
+
export type PeeklingMotionPreference = "system" | "full" | "reduce";
|
|
7
8
|
export interface PeeklingInteractionOptions {
|
|
8
9
|
/** Defaults to toggle-content. Setting pressEvent defaults this to emit. */
|
|
9
10
|
press?: PeeklingPressAction;
|
|
@@ -74,6 +75,8 @@ export interface PeeklingOptions {
|
|
|
74
75
|
position?: PeeklingPosition;
|
|
75
76
|
density?: 1 | 2 | 4;
|
|
76
77
|
maxDensity?: 1 | 2 | 4;
|
|
78
|
+
/** Defaults to system. Hosts may explicitly request full or reduced motion. */
|
|
79
|
+
motionPreference?: PeeklingMotionPreference;
|
|
77
80
|
onDiagnostic?: (message: string) => void;
|
|
78
81
|
document?: Document;
|
|
79
82
|
window?: Window;
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AA6B1B,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,IAAI,EAET,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAC;AAsGpB,MAAM,MAAM,gBAAgB,GAC1B,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAC7B,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvE,MAAM,WAAW,0BAA0B;IACzC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;IACvC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,yDAAyD;IACzD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,mEAAmE;IACnE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,uEAAuE;IACvE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,qFAAqF;IACrF,WAAW,CAAC,EAAE,KAAK,GAAG,0BAA0B,CAAC;IACjD,8EAA8E;IAC9E,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,gFAAgF;IAChF,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,aAAa,CAAC,EAAE;QACd,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,mFAAmF;QACnF,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;KAC/D,CAAC;IACF,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD,iEAAiE;IACjE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAAA;CAAE,GACzC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAC5B,MAAM,GAAG,CAAC,eAAe,GAAG,qBAAqB,CAAC,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;CACvC;AA6CD,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1C,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAAC;IAC/C,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,wEAAwE;IACxE,cAAc,IAAI,IAAI,CAAC;IACvB,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAC;IACxD,kEAAkE;IAClE,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7C,4DAA4D;IAC5D,aAAa,IAAI,OAAO,CAAC;IACzB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,qEAAqE;AACrE,qBAAa,eAAgB,YAAW,gBAAgB;;IACtD,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,kBAAkB,GAAG,eAAe,EAC3C,eAAe,GAAE,wBAA8C,GAC9D,eAAe,CAKjB;IAED,2EAA2E;IAC3E,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CA4B3D;IAED,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAyDjD,YACE,OAAO,GAAE,eAAoB,EAC7B,eAAe,GAAE,wBAA8C,EAyFhE;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAsBhD;IAED,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CA0B7C;IAED,KAAK,IAAI,IAAI,CAIZ;IAED,MAAM,IAAI,IAAI,CAIb;IAED,cAAc,IAAI,IAAI,CAErB;IAED,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAItD;IAED,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAM3C;IAED,aAAa,IAAI,OAAO,CAMvB;IAED,OAAO,IAAI,IAAI,CAEd;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AA6B1B,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,IAAI,EAET,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAC;AAsGpB,MAAM,MAAM,gBAAgB,GAC1B,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAC7B,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvE,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpE,MAAM,WAAW,0BAA0B;IACzC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;IACvC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,yDAAyD;IACzD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,mEAAmE;IACnE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,uEAAuE;IACvE,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,qFAAqF;IACrF,WAAW,CAAC,EAAE,KAAK,GAAG,0BAA0B,CAAC;IACjD,8EAA8E;IAC9E,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,gFAAgF;IAChF,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,aAAa,CAAC,EAAE;QACd,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,mFAAmF;QACnF,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;KAC/D,CAAC;IACF,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD,iEAAiE;IACjE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAAA;CAAE,GACzC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAC5B,MAAM,GAAG,CAAC,eAAe,GAAG,qBAAqB,CAAC,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;CACvC;AA6CD,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1C,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAAC;IAC/C,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,wEAAwE;IACxE,cAAc,IAAI,IAAI,CAAC;IACvB,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAC;IACxD,kEAAkE;IAClE,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7C,4DAA4D;IAC5D,aAAa,IAAI,OAAO,CAAC;IACzB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,qEAAqE;AACrE,qBAAa,eAAgB,YAAW,gBAAgB;;IACtD,MAAM,CAAC,KAAK,CACV,KAAK,EAAE,kBAAkB,GAAG,eAAe,EAC3C,eAAe,GAAE,wBAA8C,GAC9D,eAAe,CAKjB;IAED,2EAA2E;IAC3E,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CA4B3D;IAED,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAyDjD,YACE,OAAO,GAAE,eAAoB,EAC7B,eAAe,GAAE,wBAA8C,EAyFhE;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAsBhD;IAED,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CA0B7C;IAED,KAAK,IAAI,IAAI,CAIZ;IAED,MAAM,IAAI,IAAI,CAIb;IAED,cAAc,IAAI,IAAI,CAErB;IAED,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAItD;IAED,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAM3C;IAED,aAAa,IAAI,OAAO,CAMvB;IAED,OAAO,IAAI,IAAI,CAEd;CAsrCF;AAED,yDAAyD;AACzD,wBAAgB,KAAK,CAAC,KAAK,EAAE,kBAAkB,GAAG,gBAAgB,CAEjE;AAQD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,EAClD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,KAAK,CA6BP"}
|
package/dist/runtime.js
CHANGED
|
@@ -495,16 +495,21 @@ export class PeeklingRuntime {
|
|
|
495
495
|
if (this.#displayName === "") {
|
|
496
496
|
this.#displayName = loaded.content.displayName;
|
|
497
497
|
}
|
|
498
|
+
const motionPreference = this.#options.motionPreference ?? "system";
|
|
498
499
|
this.#media = this.#window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
499
|
-
this.#reducedMotion =
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
500
|
+
this.#reducedMotion =
|
|
501
|
+
motionPreference === "reduce" ||
|
|
502
|
+
(motionPreference === "system" && this.#media.matches);
|
|
503
|
+
if (motionPreference === "system") {
|
|
504
|
+
this.#mediaListener = (event) => {
|
|
505
|
+
this.#reducedMotion = event.matches;
|
|
506
|
+
this.#notice(event.matches
|
|
507
|
+
? "lifecycle.reduced-motion-enabled"
|
|
508
|
+
: "lifecycle.reduced-motion-disabled", "info", "lifecycle");
|
|
509
|
+
this.#wake();
|
|
510
|
+
};
|
|
511
|
+
this.#media.addEventListener("change", this.#mediaListener);
|
|
512
|
+
}
|
|
508
513
|
this.#watchDpr();
|
|
509
514
|
this.#position = resolveInitialPosition(this.#options.position ?? DEFAULT_POSITION, this.#window.innerWidth, this.#window.innerHeight, (loaded.content.atlas.logicalWidth ?? loaded.content.atlas.cellWidth) *
|
|
510
515
|
scale, (loaded.content.atlas.logicalHeight ??
|