pixijs-input-devices 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -44,6 +44,100 @@ declare class GamepadJoystick {
44
44
  /** A scalar -1.0 to 1.0 representing the Y-axis position on the stick */
45
45
  get y(): number;
46
46
  }
47
+ declare class InputDeviceManager {
48
+ static global: InputDeviceManager;
49
+ readonly keyboard: KeyboardDevice;
50
+ private readonly _emitter;
51
+ /** Whether we are a mobile device (including tablets) */
52
+ readonly isMobile: boolean;
53
+ /** Whether a touchscreen is available */
54
+ readonly isTouchCapable: boolean;
55
+ /** Add an event listener */
56
+ on<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
57
+ /** Remove an event listener (or all if none provided) */
58
+ off<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
59
+ private hasFocus;
60
+ /**
61
+ * Connected gamepads accessible by index.
62
+ *
63
+ * Keep in mind these inputs are only up-to-date from the last update().
64
+ */
65
+ get gamepads(): readonly GamepadDevice[];
66
+ /**
67
+ * Connected devices.
68
+ *
69
+ * Keep in mind these inputs may only be up-to-date from the last update().
70
+ */
71
+ get devices(): readonly Device[];
72
+ options: {
73
+ clearInputInBackground: boolean;
74
+ };
75
+ private _devices;
76
+ private _gamepadDevices;
77
+ private _gamepadDeviceMap;
78
+ private constructor();
79
+ /**
80
+ * Performs a poll of latest input from all devices
81
+ */
82
+ update(): ReadonlyArray<Device>;
83
+ /** Add a custom device. */
84
+ add(device: CustomDevice): void;
85
+ /** Remove a custom device. */
86
+ remove(device: Device): void;
87
+ /**
88
+ * @returns updates connected gamepads, performing a poll of latest input
89
+ */
90
+ pollGamepads(now: number): ReadonlyArray<GamepadDevice>;
91
+ private removeGamepad;
92
+ }
93
+ declare class NavigationManager {
94
+ static global: NavigationManager;
95
+ /**
96
+ * Set the stage root to automatically handle global
97
+ * navigation intents.
98
+ */
99
+ stage?: Container;
100
+ options: {
101
+ /**
102
+ * When set to false, navigation will be disabled globally.
103
+ */
104
+ enabled: boolean;
105
+ /**
106
+ * When enabled, if no "pointover"/"mouseover" listeners
107
+ * exist, a default alpha effect will be used instead.
108
+ */
109
+ useFallbackHoverEffect: boolean;
110
+ };
111
+ private _focused?;
112
+ private _responderStack;
113
+ private constructor();
114
+ /**
115
+ * Active global interaction target
116
+ */
117
+ get firstResponder(): NavigationResponder | undefined;
118
+ /**
119
+ * Stack of global interaction targets
120
+ */
121
+ get responders(): readonly NavigationResponder[];
122
+ /**
123
+ * Emit interaction intent to the first responder,
124
+ * or the global responder if none.
125
+ */
126
+ commit(intent: NavigationIntent, device: Device): void;
127
+ /**
128
+ * Remove the top-most global interaction target
129
+ */
130
+ popResponder(): NavigationResponder | undefined;
131
+ /**
132
+ * Set the new top-most global interaction target.
133
+ */
134
+ pushResponder(responder: NavigationResponder): void;
135
+ private _propagateIntent;
136
+ private _handleGlobalIntent;
137
+ private _emitBlur;
138
+ private _emitFocus;
139
+ private _emitTrigger;
140
+ }
47
141
  declare const ButtonCode: readonly [
48
142
  "A",
49
143
  "B",
@@ -65,11 +159,23 @@ declare const ButtonCode: readonly [
65
159
  export declare abstract class CustomDevice {
66
160
  readonly id: string;
67
161
  readonly type = "custom";
68
- assignee?: any;
162
+ /**
163
+ * Associate custom meta data with a device.
164
+ */
165
+ readonly meta: Record<string, any>;
69
166
  lastUpdated: number;
70
167
  constructor(id: string);
71
- update(now: number): void;
168
+ /**
169
+ * (Optional) Clear input.
170
+ *
171
+ * This method is triggered when the window is
172
+ * moved to background.
173
+ */
72
174
  clear(): void;
175
+ /**
176
+ * Triggered during the polling function.
177
+ */
178
+ abstract update(now: number): void;
73
179
  }
74
180
  /**
75
181
  * A gamepad (game controller).
@@ -83,7 +189,40 @@ export declare abstract class CustomDevice {
83
189
  export declare class GamepadDevice {
84
190
  source: Gamepad;
85
191
  static defaultOptions: {
86
- navigationalBinds: Partial<Record<Button, NavigationIntent>>;
192
+ /**
193
+ * When set to `"physical"` _(default)_, ABXY refer to the equivalent
194
+ * positions on a standard layout controller.
195
+ *
196
+ * When set to `"accurate"`, ABXY refer to the ABXY buttons on a Nintendo
197
+ * controller.
198
+ *
199
+ * When set to `"none"`, ABXY refer to the unmapped buttons in the 0, 1,
200
+ * 2, and 3 positions respectively.
201
+ */
202
+ remapNintendoMode: RemapNintendoMode;
203
+ /**
204
+ * Create named groups of buttons.
205
+ *
206
+ * This can be used with `groupPressed( name )`.
207
+ *
208
+ * @example
209
+ * // set by names
210
+ * Gamepad.defaultOptions.namedGroups = {
211
+ * jump: [ "A" ],
212
+ * crouch: [ "X" ],
213
+ * }
214
+ *
215
+ * // check by named presses
216
+ * if ( gamepad.groupPressed( "jump" ) )
217
+ * {
218
+ * // ...
219
+ * }
220
+ */
221
+ namedGroups: Partial<Record<string, ButtonCode[]>>;
222
+ navigation: {
223
+ enabled: boolean;
224
+ binds: Partial<Record<Button, NavigationIntent>>;
225
+ };
87
226
  intent: {
88
227
  joystickCommitSensitivity: number;
89
228
  firstCooldownMs: number;
@@ -101,24 +240,29 @@ export declare class GamepadDevice {
101
240
  readonly id: string;
102
241
  readonly type = "gamepad";
103
242
  /**
104
- * Associate custom metadata with a device.
243
+ * Associate custom meta data with a device.
105
244
  */
106
- meta: Record<string, any>;
245
+ readonly meta: Record<string, any>;
246
+ /** When the gamepad was last checked for input. */
107
247
  lastUpdated: number;
248
+ /** When the gamepad was last interacted with. */
249
+ lastActive: number;
108
250
  /**
109
251
  * Platform of this gamepad, useful for configuring standard
110
252
  * button layouts or displaying branded icons.
111
253
  * @example "playstation"
112
254
  */
113
- platform: GamepadPlatform;
255
+ layout: GamepadLayout;
114
256
  options: typeof GamepadDevice.defaultOptions;
257
+ readonly leftJoystick: GamepadJoystick;
258
+ readonly rightJoystick: GamepadJoystick;
259
+ /** Accessors for buttons */
260
+ button: Record<ButtonCode, boolean>;
115
261
  private _btnPrevState;
116
262
  private _axisIntents;
117
263
  private readonly _throttleIdLeftStickX;
118
264
  private readonly _throttleIdLeftStickY;
119
265
  private readonly _emitter;
120
- readonly leftJoystick: GamepadJoystick;
121
- readonly rightJoystick: GamepadJoystick;
122
266
  /** A scalar 0.0 to 1.0 representing the trigger pull */
123
267
  get leftTrigger(): number;
124
268
  /** A scalar 0.0 to 1.0 representing the trigger pull */
@@ -127,12 +271,16 @@ export declare class GamepadDevice {
127
271
  get leftShoulder(): number;
128
272
  /** A scalar 0.0 to 1.0 representing the trigger pull */
129
273
  get rightShoulder(): number;
274
+ /** @returns true if any button from the named group is pressed. */
275
+ groupPressed(name: string): boolean;
276
+ /** @returns true if any of the given buttons are pressed. */
277
+ anyPressed(btns: ButtonCode[]): boolean;
278
+ /** @returns true if all of the given buttons are pressed. */
279
+ allPressed(btns: ButtonCode[]): boolean;
130
280
  /** Add an event listener */
131
281
  on<K extends keyof GamepadDeviceEvent>(event: K, listener: (event: GamepadDeviceEvent[K]) => void): this;
132
- /** Remove an event listener */
133
- off<K extends keyof GamepadDeviceEvent>(event: K, listener: (event: GamepadDeviceEvent[K]) => void): this;
134
- /** Accessors for buttons */
135
- button: Record<ButtonCode, boolean>;
282
+ /** Remove an event listener (or all if none provided). */
283
+ off<K extends keyof GamepadDeviceEvent>(event: K, listener?: (event: GamepadDeviceEvent[K]) => void): this;
136
284
  /**
137
285
  * Play a vibration effect (if supported).
138
286
  *
@@ -145,60 +293,14 @@ export declare class GamepadDevice {
145
293
  constructor(source: Gamepad);
146
294
  private updatePresses;
147
295
  }
148
- export declare class InputDevice {
149
- static readonly shared: InputDevice;
150
- static keyboard: KeyboardDevice;
151
- static gamepads: readonly GamepadDevice[];
152
- static devices: readonly Device[];
153
- static update: () => ReadonlyArray<Device>;
154
- readonly keyboard: KeyboardDevice;
155
- private readonly _emitter;
156
- /** Add an event listener */
157
- on<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
158
- /** Remove an event listener */
159
- off<K extends keyof InputDeviceEvent>(event: K, listener: (event: InputDeviceEvent[K]) => void): this;
160
- private hasFocus;
161
- /**
162
- * Connected gamepads accessible by index.
163
- *
164
- * Keep in mind these inputs are only up-to-date from the last update().
165
- */
166
- get gamepads(): readonly GamepadDevice[];
167
- /**
168
- * Connected devices.
169
- *
170
- * Keep in mind these inputs may only be up-to-date from the last update().
171
- */
172
- get devices(): readonly Device[];
173
- options: {
174
- clearInputInBackground: boolean;
175
- };
176
- private _devices;
177
- private _gamepadDevices;
178
- private _gamepadDeviceMap;
179
- private constructor();
180
- /**
181
- * Performs a poll of latest input from all devices
182
- */
183
- update(): ReadonlyArray<Device>;
184
- /** Add a custom device. */
185
- add(device: CustomDevice): void;
186
- /** Remove a custom device. */
187
- remove(device: Device): void;
188
- /**
189
- * @returns updates connected gamepads, performing a poll of latest input
190
- */
191
- pollGamepads(now: number): ReadonlyArray<GamepadDevice>;
192
- private removeGamepad;
193
- }
194
296
  export declare class KeyboardDevice {
195
297
  static global: KeyboardDevice;
196
- readonly type: "keyboard";
197
- readonly id: "keyboard";
298
+ readonly type = "keyboard";
299
+ readonly id = "keyboard";
198
300
  /**
199
- * Associate custom metadata with a device.
301
+ * Associate custom meta data with a device.
200
302
  */
201
- meta: Record<string, any>;
303
+ readonly meta: Record<string, any>;
202
304
  lastUpdated: number;
203
305
  /**
204
306
  * Detect layout from keypresses.
@@ -207,18 +309,46 @@ export declare class KeyboardDevice {
207
309
  * layout can be determined.
208
310
  */
209
311
  detectLayoutOnKeypress: boolean;
312
+ /**
313
+ * Keyboard has been detected.
314
+ */
315
+ detected: boolean;
210
316
  private _layout;
211
317
  private _layoutSource;
212
318
  private _emitter;
213
- on<K extends keyof KeyboardDeviceEvent>(event: K, listener: (event: KeyboardDeviceEvent[K]) => void): this;
214
- off<K extends keyof KeyboardDeviceEvent>(event: K, listener: (event: KeyboardDeviceEvent[K]) => void): this;
215
319
  options: {
216
320
  /**
217
321
  * Keys to prevent default event propagation for.
218
322
  */
219
323
  preventDefaultKeys: Set<KeyCode>;
220
- navigationBinds: Partial<Record<KeyCode, NavigationIntent>>;
324
+ /**
325
+ * Create named groups of buttons.
326
+ *
327
+ * This can be used with `groupPressed( name )`.
328
+ *
329
+ * @example
330
+ * // set by names
331
+ * Keyboard.options.namedGroups = {
332
+ * jump: [ "ArrowUp", "KeyW" ],
333
+ * left: [ "ArrowLeft", "KeyA" ],
334
+ * crouch: [ "ArrowDown", "KeyS" ],
335
+ * right: [ "ArrowRight", "KeyD" ],
336
+ * }
337
+ *
338
+ * // check by named presses
339
+ * if ( keyboard.groupPressed( "jump" ) )
340
+ * {
341
+ * // ...
342
+ * }
343
+ */
344
+ namedGroups: Partial<Record<string, KeyCode[]>>;
345
+ navigation: {
346
+ enabled: boolean;
347
+ binds: NavigationBinds;
348
+ };
221
349
  };
350
+ /** Accessors for keys */
351
+ key: Record<KeyCode, boolean>;
222
352
  private constructor();
223
353
  /**
224
354
  * Keyboard Layout
@@ -242,9 +372,16 @@ export declare class KeyboardDevice {
242
372
  set layout(value: KeyboardLayout);
243
373
  /** How the keyboard layout was determined. */
244
374
  get layoutSource(): KeyboardLayoutSource;
245
- private configureEventListeners;
246
- /** Accessors for keys */
247
- key: Record<KeyCode, boolean>;
375
+ /** @returns true if any key from the named group is pressed. */
376
+ groupPressed(name: string): boolean;
377
+ /** @returns true if any of the given keys are pressed. */
378
+ anyPressed(keys: KeyCode[]): boolean;
379
+ /** @returns true if all of the given keys are pressed. */
380
+ allPressed(keys: KeyCode[]): boolean;
381
+ /** Add an event listener. */
382
+ on<K extends keyof KeyboardDeviceEvent>(event: K, listener: (event: KeyboardDeviceEvent[K]) => void): this;
383
+ /** Remove an event listener (or all if none provided). */
384
+ off<K extends keyof KeyboardDeviceEvent>(event: K, listener: (event: KeyboardDeviceEvent[K]) => void): this;
248
385
  /**
249
386
  * Get the label for the given key code in the current keyboard layout.
250
387
  *
@@ -260,53 +397,7 @@ export declare class KeyboardDevice {
260
397
  * Clear all keyboard keys.
261
398
  */
262
399
  clear(): void;
263
- }
264
- /**
265
- * Responsible for global navigation interactions.
266
- *
267
- * Set stageRoot to enable the global responder behaviors.
268
- */
269
- export declare class Navigation {
270
- static shared: Navigation;
271
- /**
272
- * Set the stage root to automatically handle global
273
- * navigation intents.
274
- */
275
- stageRoot?: Container;
276
- /**
277
- * When enabled, if no pointover/mouseover listeners
278
- * exist, a default effect will be used instead.
279
- */
280
- fallbackEffects: boolean;
281
- private _focused?;
282
- private _responderStack;
283
- private constructor();
284
- /**
285
- * Active global interaction target
286
- */
287
- get firstResponder(): NavigationResponder | undefined;
288
- /**
289
- * Stack of global interaction targets
290
- */
291
- get responders(): readonly NavigationResponder[];
292
- /**
293
- * Emit interaction intent to the first responder,
294
- * or the global responder if none.
295
- */
296
- commit(intent: NavigationIntent, device: Device): void;
297
- /**
298
- * Remove the top-most global interaction target
299
- */
300
- popResponder(): NavigationResponder | undefined;
301
- /**
302
- * Set the new top-most global interaction target.
303
- */
304
- pushResponder(responder: NavigationResponder): void;
305
- private _propagateIntent;
306
- private _handleGlobalIntent;
307
- private _emitBlur;
308
- private _emitFocus;
309
- private _emitTrigger;
400
+ private _configureEventListeners;
310
401
  }
311
402
  export declare const Button: {
312
403
  /** A Button (Xbox / Nintendo: "A", PlayStation: "Cross") */
@@ -325,9 +416,9 @@ export declare const Button: {
325
416
  readonly LeftTrigger: 6;
326
417
  /** Right Trigger (Xbox: "RT", PlayStation: "R2", Nintendo: "ZR") */
327
418
  readonly RightTrigger: 7;
328
- /** Bak Button (Xbox: "Share", PlayStation: "Options", Nintendo: "-") */
419
+ /** Back Button (Xbox: "Back", PlayStation: "Share", Nintendo: "Minus") */
329
420
  readonly Back: 8;
330
- /** Start Button (Xbox: "Start", PlayStation: "Select", Nintendo: "+") */
421
+ /** Start Button (Xbox: "Start", PlayStation: "Options", Nintendo: "Plus") */
331
422
  readonly Start: 9;
332
423
  /** Left Stick Press (Xbox / PlayStation: "LS", Nintendo: "L3") */
333
424
  readonly LeftStick: 10;
@@ -342,6 +433,7 @@ export declare const Button: {
342
433
  /** D-Pad Right */
343
434
  readonly DPadRight: 15;
344
435
  };
436
+ export declare const InputDevice: InputDeviceManager;
345
437
  export declare const KeyCode: {
346
438
  readonly AltLeft: "AltLeft";
347
439
  readonly AltRight: "AltRight";
@@ -476,6 +568,12 @@ export declare const KeyCode: {
476
568
  readonly VolumeUp: "VolumeUp";
477
569
  readonly WakeUp: "WakeUp";
478
570
  };
571
+ /**
572
+ * Responsible for global navigation interactions.
573
+ *
574
+ * Set stage to enable the global responder behaviors.
575
+ */
576
+ export declare const Navigation: NavigationManager;
479
577
  /**
480
578
  * @returns all navigatable containers in some container
481
579
  */
@@ -506,16 +604,16 @@ export interface InputDeviceEvent {
506
604
  };
507
605
  }
508
606
  export interface KeyboardDeviceKeydownEvent {
607
+ event: KeyboardEvent;
509
608
  device: KeyboardDevice;
510
609
  keyCode: KeyCode;
511
610
  /** Layout-specific label for key. @example "Ц" // JCUKEN for "KeyW" */
512
- label: string;
513
- event: KeyboardEvent;
611
+ keyLabel: string;
514
612
  }
515
613
  export interface KeyboardDeviceLayoutUpdatedEvent {
516
614
  device: KeyboardDevice;
517
615
  layout: KeyboardLayout;
518
- source: KeyboardLayoutSource;
616
+ layoutSource: KeyboardLayoutSource;
519
617
  }
520
618
  /**
521
619
  * A target that responds to navigation on the stack.
@@ -555,12 +653,6 @@ export type GamepadDeviceEvent = {} & {
555
653
  export type GamepadDeviceSource = {
556
654
  source: Gamepad;
557
655
  };
558
- /**
559
- * Common gamepad platforms, which may indicate button layout.
560
- *
561
- * Note: Non-comprehensive list, covers the most brands only.
562
- */
563
- export type GamepadPlatform = "logitech" | "nintendo" | "playstation" | "steam" | "xbox" | "other";
564
656
  export type GamepadVibration = GamepadEffectParameters & {
565
657
  vibrationType?: GamepadHapticEffectType;
566
658
  };
@@ -573,8 +665,20 @@ export type KeyboardDeviceEvent = {
573
665
  export type KeyboardLayout = "QWERTY" | "AZERTY" | "JCUKEN" | "QWERTZ";
574
666
  export type KeyboardLayoutSource = "browser" | "lang" | "keypress" | "manual";
575
667
  export type NavigatableContainer = Container;
668
+ export type NavigationBinds = Partial<Record<KeyCode, NavigationIntent>>;
576
669
  export type NavigationDirection = "navigateLeft" | "navigateRight" | "navigateUp" | "navigateDown";
577
670
  export type NavigationIntent = "navigateBack" | "navigateDown" | "navigateLeft" | "navigateRight" | "navigateUp" | "trigger";
578
671
  export type NavigationTargetEvent = "focus" | "blur";
672
+ export type RemapNintendoMode = "none" | "accurate" | "physical";
673
+ /**
674
+ * Common gamepad platform layouts, which may indicate button layout.
675
+ *
676
+ * Note: Non-comprehensive list, covers the most brands only.
677
+ */
678
+ type GamepadLayout = "logitech" | "nintendo" | "playstation" | "steam" | "xbox" | "generic";
679
+
680
+ export {
681
+ GamepadLayout as GamepadPlatform,
682
+ };
579
683
 
580
684
  export {};
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- class CustomDevice{constructor(e){this.id=e,this.type="custom",this.lastUpdated=performance.now()}update(e){}clear(){}}const e=0,t=1,i=2,a=3,s={A:0,B:1,X:2,Y:3,LeftShoulder:4,RightShoulder:5,LeftTrigger:6,RightTrigger:7,Back:8,Start:9,LeftStick:10,RightStick:11,DPadUp:12,DPadDown:13,DPadLeft:14,DPadRight:15},o=["A","B","X","Y","LeftShoulder","RightShoulder","LeftTrigger","RightTrigger","Back","Start","LeftStick","RightStick","DPadUp","DPadDown","DPadLeft","DPadRight"];function getAllNavigatables(e,t=[]){for(const i of e.children)i.isNavigatable?t.push(i):getAllNavigatables(i,t);return t}function getFirstNavigatable(e,t,i,{minimumDistance:a=3}={}){return function chooseFirstNavigatableInDirection(e,t,i,{minimumDistance:a=3}={}){var s,o,n,r,d,u,c,l,h;const g=e.filter((e=>e.isNavigatable&&null!=e.parent&&function isVisible(e){for(;null!=e;){if(!e.visible)return!1;e=e.parent}return!0}(e))),p=g.find((e=>e===t));if(void 0===p)return g.sort(((e,t)=>e.navigationPriority-t.navigationPriority)),g[0];if(void 0===i&&p)return p;const m=null!=p?p:g[Math.floor(Math.random()*g.length)];if(void 0===p)return null!==(s=e[0])&&void 0!==s?s:m;const v=p.getBounds(),y={x:v.left+v.width/2,y:v.top+v.height/2},f=g.filter((e=>e!==p)).map((e=>{const t=e.getBounds(),i={x:t.left+t.width/2,y:t.top+t.height/2};return{element:e,bounds:t,center:i,distSqrd:squaredDist(i,y)}}));switch(i){case"navigateUp":return null!==(n=null===(o=f.filter((e=>e.center.y<y.y-a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===o?void 0:o.element)&&void 0!==n?n:m;case"navigateLeft":return null!==(d=null===(r=f.filter((e=>e.center.x<y.x-a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===r?void 0:r.element)&&void 0!==d?d:m;case"navigateRight":return null!==(c=null===(u=f.filter((e=>e.center.x>y.x+a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===u?void 0:u.element)&&void 0!==c?c:m;case"navigateDown":return null!==(h=null===(l=f.filter((e=>e.center.y>y.y+a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===l?void 0:l.element)&&void 0!==h?h:m;default:return p}}(getAllNavigatables(e),t,i,{minimumDistance:a})}function squaredDist(e,t){const i=t.x-e.x,a=t.y-e.y;return i*i+a*a}class Navigation{constructor(){this.fallbackEffects=!0,this._responderStack=[]}get firstResponder(){return this._responderStack[0]}get responders(){return this._responderStack}commit(e,t){this._propagateIntent(e,t)}popResponder(){var e,t,i;const a=this._responderStack.shift();return null===(t=null===(e=this.firstResponder)||void 0===e?void 0:e.becameFirstResponder)||void 0===t||t.call(e),null===(i=null==a?void 0:a.resignedAsFirstResponder)||void 0===i||i.call(a),a}pushResponder(e){var t,i;if(this._responderStack.includes(e))throw new Error("Responder already in stack.");const a=this.firstResponder;this._responderStack.unshift(e),null===(t=e.becameFirstResponder)||void 0===t||t.call(e),null===(i=null==a?void 0:a.resignedAsFirstResponder)||void 0===i||i.call(a)}_propagateIntent(e,t){var i;for(const a of this._responderStack)if(null===(i=a.handledNavigationIntent)||void 0===i?void 0:i.call(a,e,t))return;void 0===this.stageRoot?console.warn("navigation: no stageRoot set"):this._handleGlobalIntent(this.stageRoot,e)}_handleGlobalIntent(e,t){var i;if(void 0===this._focused){const i=getFirstNavigatable(e);return void 0===i?void console.debug("navigation: no navigatable views found",t):(this._emitFocus(i),void(this._focused=i))}if("navigateBack"===t)return this._emitBlur(this._focused),void(this._focused=void 0);if("trigger"===t)return void this._emitTrigger(this._focused);const a=null!==(i=getFirstNavigatable(this.stageRoot,this._focused,t))&&void 0!==i?i:this._focused;a!==this._focused&&(this._emitBlur(this._focused),this._emitFocus(a),this._focused=a)}_emitBlur(e){const t=e.eventNames();t.includes("pointerout")?e.emit("pointerout"):t.includes("mouseout")?e.emit("mouseout"):"auto"===e.navigationMode&&this.fallbackEffects&&(e.alpha=1),e.emit("blur")}_emitFocus(e){const t=e.eventNames();t.includes("pointerover")?e.emit("pointerover"):t.includes("mouseover")?e.emit("mouseover"):"auto"===e.navigationMode&&this.fallbackEffects&&(e.alpha=.5),e.emit("focus")}_emitTrigger(e){const t=e.eventNames();t.includes("pointerdown")?e.emit("pointerdown"):t.includes("mousedown")?e.emit("mousedown"):"auto"===e.navigationMode&&this.fallbackEffects&&(e.alpha=.75),e.emit("trigger")}}Navigation.shared=new Navigation;let n=new Map;function throttle(e,t){var i;const a=Date.now();return(null!==(i=n.get(e))&&void 0!==i?i:0)>a||(n.set(e,a+t),!1)}class EventEmitter{constructor(){this.l={}}hasListener(e){return void 0!==this.l[e]}emit(e,t){var i;null===(i=this.l[e])||void 0===i||i.forEach((e=>e(t)))}on(e,t){var i;this.l[e]||(this.l[e]=[]),null===(i=this.l[e])||void 0===i||i.push(t)}off(e,t){var i;this.l[e]=null===(i=this.l[e])||void 0===i?void 0:i.filter((e=>e!==t)),0===this.l[e].length&&(this.l[e]=void 0)}}class GamepadDevice{get leftTrigger(){return this.source.buttons[s.LeftTrigger].value}get rightTrigger(){return this.source.buttons[s.LeftTrigger].value}get leftShoulder(){return this.source.buttons[s.LeftShoulder].value}get rightShoulder(){return this.source.buttons[s.RightShoulder].value}on(e,t){const i="number"==typeof e?o[e]:e;return this._emitter.on(i,t),this}off(e,t){const i="number"==typeof e?o[e]:e;return this._emitter.off(i,t),this}playVibration({duration:e=200,weakMagnitude:t=.5,strongMagnitude:i=.5,vibrationType:a="dual-rumble",rightTrigger:s=0,leftTrigger:o=0,startDelay:n=0}={}){if(this.options.vibration.enabled&&this.source.vibrationActuator)try{this.source.vibrationActuator.playEffect(a,{duration:e,startDelay:n,weakMagnitude:t,strongMagnitude:i,leftTrigger:o,rightTrigger:s})}catch(e){console.warn("gamepad vibrationActuator failed with error:",e)}}update(e,t){this.lastUpdated=t,this.updatePresses(e),this.source=e}clear(){this._axisIntents=this._axisIntents.map((()=>!1)),this._btnPrevState=this._btnPrevState.map((()=>!1))}constructor(o){this.source=o,this.type="gamepad",this.meta={},this.lastUpdated=performance.now(),this.options=structuredClone(GamepadDevice.defaultOptions),this._btnPrevState=new Array(16),this._axisIntents=new Array(2),this._emitter=new EventEmitter,this.button=Object.keys(s).reduce(((e,t)=>(e[t]=!1,e)),{}),this.id="gamepad"+o.index,this.platform=function detectPlatform(e){const t=(e.id||"").toLowerCase();return/(logitech|046d)/.test(t)?"logitech":/(steam|28de)/.test(t)?"steam":/(dualshock|dualsense|sony|054c|0ce6|0810)/.test(t)?"playstation":/(nintendo|switch|joycon|057e)/.test(t)?"nintendo":/(xbox|xinput|045e|028e|0291|02a0|02a1|02ea|02ff)/.test(t)?"xbox":"other"}(o),this.leftJoystick=new GamepadJoystick(this,e,t),this.rightJoystick=new GamepadJoystick(this,i,a),this._throttleIdLeftStickX=this.id+"-lsx",this._throttleIdLeftStickY=this.id+"-lsy"}updatePresses(i){var a,s,n,r,d,u;const c=this._btnPrevState.length;for(let e=0;e<c;e++){if(this._btnPrevState[e]===(null===(a=i.buttons[e])||void 0===a?void 0:a.pressed))continue;const t=null!==(n=null===(s=i.buttons[e])||void 0===s?void 0:s.pressed)&&void 0!==n&&n,d=o[e];if(this._btnPrevState[e]=t,this.button[d]=t,t)if(this._emitter.hasListener(d))this._emitter.emit(d,{device:this,button:e,buttonCode:d});else{const t=null!==(r=this.options.navigationalBinds[e])&&void 0!==r?r:void 0;void 0!==t&&Navigation.shared.commit(t,this)}}const l=null!==(d=i.axes[e])&&void 0!==d?d:0,h=null!==(u=i.axes[t])&&void 0!==u?u:0;if(Math.abs(l)>=this.options.intent.joystickCommitSensitivity){const t=l<0?"navigateLeft":"navigateRight",i=this._axisIntents[e]?this.options.intent.defaultCooldownMs:this.options.intent.firstCooldownMs;this._axisIntents[e]=!0,throttle(this._throttleIdLeftStickX,i)||Navigation.shared.commit(t,this)}else this._axisIntents[e]=!1;if(Math.abs(h)>=this.options.intent.joystickCommitSensitivity){const e=h<0?"navigateUp":"navigateDown",i=this._axisIntents[t]?this.options.intent.defaultCooldownMs:this.options.intent.firstCooldownMs;this._axisIntents[t]=!0,throttle(this._throttleIdLeftStickY,i)||Navigation.shared.commit(e,this)}else this._axisIntents[t]=!1}}GamepadDevice.defaultOptions={navigationalBinds:{[s.A]:"trigger",[s.B]:"navigateBack",[s.Back]:"navigateBack",[s.DPadDown]:"navigateDown",[s.DPadLeft]:"navigateLeft",[s.DPadRight]:"navigateRight",[s.DPadUp]:"navigateUp"},intent:{joystickCommitSensitivity:.5,firstCooldownMs:400,defaultCooldownMs:80},vibration:{enabled:!0,intensity:1}};class GamepadJoystick{constructor(e,t,i){this._owner=e,this.ix=t,this.iy=i}get x(){return this._owner.source.axes[this.ix]}get y(){return this._owner.source.axes[this.iy]}}const r={AltLeft:"AltLeft",AltRight:"AltRight",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",Backquote:"Backquote",Backslash:"Backslash",Backspace:"Backspace",BracketLeft:"BracketLeft",BracketRight:"BracketRight",CapsLock:"CapsLock",Comma:"Comma",ContextMenu:"ContextMenu",ControlLeft:"ControlLeft",ControlRight:"ControlRight",Delete:"Delete",Digit0:"Digit0",Digit1:"Digit1",Digit2:"Digit2",Digit3:"Digit3",Digit4:"Digit4",Digit5:"Digit5",Digit6:"Digit6",Digit7:"Digit7",Digit8:"Digit8",Digit9:"Digit9",End:"End",Enter:"Enter",Equal:"Equal",Escape:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F2:"F2",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F3:"F3",F30:"F30",F31:"F31",F32:"F32",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Home:"Home",IntlBackslash:"IntlBackslash",IntlRo:"IntlRo",IntlYen:"IntlYen",KeyA:"KeyA",KeyB:"KeyB",KeyC:"KeyC",KeyD:"KeyD",KeyE:"KeyE",KeyF:"KeyF",KeyG:"KeyG",KeyH:"KeyH",KeyI:"KeyI",KeyJ:"KeyJ",KeyK:"KeyK",KeyL:"KeyL",KeyM:"KeyM",KeyN:"KeyN",KeyO:"KeyO",KeyP:"KeyP",KeyQ:"KeyQ",KeyR:"KeyR",KeyS:"KeyS",KeyT:"KeyT",KeyU:"KeyU",KeyV:"KeyV",KeyW:"KeyW",KeyX:"KeyX",KeyY:"KeyY",KeyZ:"KeyZ",Lang1:"Lang1",Lang2:"Lang2",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",MetaLeft:"MetaLeft",MetaRight:"MetaRight",Minus:"Minus",NumLock:"NumLock",Numpad0:"Numpad0",Numpad1:"Numpad1",Numpad2:"Numpad2",Numpad3:"Numpad3",Numpad4:"Numpad4",Numpad5:"Numpad5",Numpad6:"Numpad6",Numpad7:"Numpad7",Numpad8:"Numpad8",Numpad9:"Numpad9",NumpadAdd:"NumpadAdd",NumpadComma:"NumpadComma",NumpadDecimal:"NumpadDecimal",NumpadDivide:"NumpadDivide",NumpadMultiply:"NumpadMultiply",NumpadSubtract:"NumpadSubtract",OSLeft:"OSLeft",Pause:"Pause",Period:"Period",Quote:"Quote",ScrollLock:"ScrollLock",Semicolon:"Semicolon",ShiftLeft:"ShiftLeft",ShiftRight:"ShiftRight",Slash:"Slash",Space:"Space",Tab:"Tab",VolumeDown:"VolumeDown",VolumeMute:"VolumeMute",VolumeUp:"VolumeUp",WakeUp:"WakeUp"};function __awaiter(e,t,i,a){return new(i||(i=Promise))((function(s,o){function fulfilled(e){try{step(a.next(e))}catch(e){o(e)}}function rejected(e){try{step(a.throw(e))}catch(e){o(e)}}function step(e){e.done?s(e.value):function adopt(e){return e instanceof i?e:new i((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const d=["fr","mg","lu"],u=["ab","ba","be","bg","ch","kk","ky","mk","mn","ru","sr","tg","tt","uk","uz"],c=["de","cs","sk","sl","hu","hr","bs","ro","sq","me","lt","lv","et"],l=/ф|и|с|в|у|а|п|р|ш|о|л|д|ь|т|щ|з|й|к|ы|е|г|м|ц|ч|н|я|ё|х|ъ|б|ю|э|ж|и/i,h=/[a-z]/i;function inferKeyboardLayoutFromLang(e=function getLang(){var e;const t=navigator;return null!=(null===(e=t.languages)||void 0===e?void 0:e.length)?t.languages[0]:t.userLanguage||t.language||t.browserLanguage}()){const t=(e||"").toLowerCase(),i=t.split("-")[0];return d.includes(i)||t.startsWith("nl-be")?"AZERTY":u.includes(i)?"JCUKEN":c.includes(i)||t.startsWith("sr-latn")?"QWERTZ":"QWERTY"}const g=new Set(["AZERTY","JCUKEN","QWERTY","QWERTZ"]);let p;function getMetaKeyLabel(){var e,t,i,a;const s=navigator,o=null!==(t=null===(e=s.platform)||void 0===e?void 0:e.toLowerCase())&&void 0!==t?t:"",n=null!==(a=null===(i=s.userAgent)||void 0===i?void 0:i.toLowerCase())&&void 0!==a?a:"";return o.includes("mac")?"⌘":o.includes("win")||o.includes("linux")?"⊞":n.includes("android")?"Search":n.includes("iphone")||n.includes("ipad")?"⌘":"⊞"}class KeyboardDevice{on(e,t){return this._emitter.on(e,t),this}off(e,t){return this._emitter.off(e,t),this}constructor(){this.meta={},this.lastUpdated=performance.now(),this.detectLayoutOnKeypress=!0,this._emitter=new EventEmitter,this.options={preventDefaultKeys:new Set([]),navigationBinds:{Space:"trigger",Enter:"trigger",Escape:"navigateBack",Backspace:"navigateBack",ArrowDown:"navigateDown",ArrowLeft:"navigateLeft",ArrowRight:"navigateRight",ArrowUp:"navigateUp",KeyA:"navigateLeft",KeyD:"navigateRight",KeyS:"navigateDown",KeyW:"navigateUp"}},this.key=Object.keys(r).reduce(((e,t)=>(e[t]=!1,e)),{}),this._layoutSource="lang",this._layout=inferKeyboardLayoutFromLang(),function requestKeyboardLayout(){return __awaiter(this,void 0,void 0,(function*(){const e=navigator;if(e.keyboard&&e.keyboard.getLayoutMap)try{const t=yield e.keyboard.getLayoutMap(),i=t.get("KeyQ"),a=t.get("KeyA"),s=t.get("KeyZ");if("a"===i&&"w"===s&&"q"===a)return"AZERTY";if("q"===i&&"y"===s&&"a"===a)return"QWERTZ";if("q"===i&&"z"===s&&"a"===a)return"QWERTY";if("й"===i&&"я"===s&&"ф"===a)return"JCUKEN"}catch(e){console.error("Error detecting keyboard layout:",e)}}))}().then((e=>{this._layoutSource="browser",this._layout=e,this._emitter.emit("layoutdetected",{source:"browser",layout:e,device:this})})),this.configureEventListeners()}get layout(){return this._layout}set layout(e){this._layoutSource="manual",this._layout=e}get layoutSource(){return this._layoutSource}configureEventListeners(){document.addEventListener("keydown",(e=>{const t=e.code;if(this.key[t]=!0,this.options.preventDefaultKeys.has(t)&&e.preventDefault(),this.detectLayoutOnKeypress&&"lang"===this._layoutSource){const t=function detectKeyboardLayoutFromKeydown(e){const t=e.key.toLowerCase(),i=e.code;return l.test(t)?(g.delete("AZERTY"),g.delete("QWERTY"),g.delete("QWERTZ")):"Backquote"===i&&"²"===t||"BracketLeft"===i&&"«"===t||"BracketRight"===i&&"»"===t||"KeyA"===i&&"q"===t||"KeyQ"===i&&"a"===t||"KeyW"===i&&"z"===t||"KeyZ"===i&&"w"===t?(g.delete("JCUKEN"),g.delete("QWERTY"),g.delete("QWERTZ")):"BracketLeft"===i&&"ü"===t||"BracketRight"===i&&"ö"===t||"KeyY"===i&&"z"===t||"KeyZ"===i&&"y"===t||"Slash"===i&&"-"===t?(g.delete("AZERTY"),g.delete("JCUKEN"),g.delete("QWERTY")):"BracketLeft"===i&&"["===t||"BracketRight"===i&&"]"===t||"KeyZ"===i&&"z"===t?(g.delete("AZERTY"),g.delete("JCUKEN"),g.delete("QWERTZ")):"KeyQ"===i&&"q"===t||"KeyW"===i&&"w"===t?(g.delete("AZERTY"),g.delete("JCUKEN")):"KeyY"===i&&"Y"===t?(g.delete("QWERTZ"),g.delete("JCUKEN")):h.test(t)&&g.delete("JCUKEN"),1===g.size?[...g][0]:void 0}(e);void 0!==t&&(this._layout=t,this._layoutSource="keypress",this.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{source:"keypress",layout:t,device:this}))}this._emitter.hasListener(t)?setTimeout((()=>this._emitter.emit(t,{device:this,keyCode:t,label:this.keyLabel(t),event:e}))):void 0!==this.options.navigationBinds[t]&&(e.preventDefault(),setTimeout((()=>Navigation.shared.commit(this.options.navigationBinds[t],this))))})),document.addEventListener("keyup",(e=>{this.key[e.code]=!1,this.options.preventDefaultKeys.has(e.code)&&e.preventDefault()}))}keyLabel(e,t=this._layout){return function getLayoutLabel(e,t){if(void 0===p){const e={ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓",AltLeft:"Left Alt",AltRight:"Right Alt",Backquote:"`",Backslash:"\\",Backspace:"Backspace",BracketLeft:"[",BracketRight:"]",CapsLock:"Caps Lock",Comma:",",ContextMenu:"Context Menu",ControlLeft:"Left Ctrl",ControlRight:"Right Ctrl",Delete:"Delete",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",End:"End",Enter:"Enter",Equal:"=",Escape:"Esc",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",Home:"Home",IntlBackslash:"\\",IntlRo:"Ro",IntlYen:"¥",KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Lang1:"Language 1",Lang2:"Language 2",MediaTrackNext:"Next Track",MediaTrackPrevious:"Previous Track",MetaLeft:"Left "+getMetaKeyLabel(),MetaRight:"Right "+getMetaKeyLabel(),Minus:"-",NumLock:"Num Lock",Numpad0:"Num0",Numpad1:"Num1",Numpad2:"Num2",Numpad3:"Num3",Numpad4:"Num4",Numpad5:"Num5",Numpad6:"Num6",Numpad7:"Num7",Numpad8:"Num8",Numpad9:"Num9",NumpadAdd:"+",NumpadComma:",",NumpadDecimal:".",NumpadDivide:"/",NumpadMultiply:"*",NumpadSubtract:"-",OSLeft:"OS Left",Pause:"Pause",Period:".",Quote:"'",ScrollLock:"Scroll Lock",Semicolon:";",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",Slash:"/",Space:"Space",Tab:"Tab",VolumeDown:"Volume Down",VolumeMute:"Mute",VolumeUp:"Volume Up",WakeUp:"Wake Up"},t=Object.assign(Object.assign({},e),{KeyA:"Q",KeyQ:"A",KeyW:"Z",KeyZ:"W",Backquote:"²",BracketLeft:"«",BracketRight:"»"}),i=Object.assign(Object.assign({},e),{KeyA:"Ф",KeyB:"И",KeyC:"С",KeyD:"В",KeyE:"У",KeyF:"А",KeyG:"П",KeyH:"Р",KeyI:"Ш",KeyJ:"О",KeyK:"Л",KeyL:"Д",KeyM:"Ь",KeyN:"Т",KeyO:"Щ",KeyP:"З",KeyQ:"Й",KeyR:"К",KeyS:"Ы",KeyT:"Е",KeyU:"Г",KeyV:"М",KeyW:"Ц",KeyX:"Ч",KeyY:"Н",KeyZ:"Я",Backquote:"Ё",BracketLeft:"х",BracketRight:"ъ",Comma:"Б",Period:"Ю",Quote:"Э",Semicolon:"Ж",Slash:"И"}),a=Object.assign(Object.assign({},e),{KeyY:"Z",KeyZ:"Y",BracketLeft:"ü",BracketRight:"ö",Slash:"-"});p={AZERTY:t,JCUKEN:i,QWERTY:e,QWERTZ:a}}return p[t][e]}(e,t)}clear(){for(const e of Object.keys(r))this.key[e]=!1}}var m;KeyboardDevice.global=new KeyboardDevice;class InputDevice{on(e,t){return this._emitter.on(e,t),this}off(e,t){return this._emitter.off(e,t),this}get gamepads(){return this._gamepadDevices}get devices(){return this._devices}constructor(){this._emitter=new EventEmitter,this.hasFocus=!1,this.options={clearInputInBackground:!0},this._gamepadDevices=[],this._gamepadDeviceMap=new Map,this.keyboard=KeyboardDevice.global,window.addEventListener("gamepadconnected",(()=>this.pollGamepads(performance.now()))),window.addEventListener("gamepaddisconnected",(e=>this.removeGamepad(e.gamepad.index))),this._devices=[this.keyboard]}update(){if(!document.hasFocus())return this.hasFocus&&this.options.clearInputInBackground&&this.devices.forEach((e=>e.clear())),this.hasFocus=!1,this._devices;this.hasFocus=!0;const e=performance.now();return this.keyboard.lastUpdated=e,this.pollGamepads(e),this._devices}add(e){this._devices.push(e)}remove(e){const t=this._devices.indexOf(e);-1!==t&&(this._devices.splice(t,1),this._emitter.emit("deviceremoved",{device:e}))}pollGamepads(e){if(!document.hasFocus())return this._gamepadDevices;if(void 0===navigator.getGamepads)return this._gamepadDevices;for(const t of navigator.getGamepads())if(null!=t)if(this._gamepadDeviceMap.has(t.index)){this._gamepadDeviceMap.get(t.index).update(t,e)}else{const e=new GamepadDevice(t);this._gamepadDeviceMap.set(t.index,e),this._gamepadDevices.push(e),this._devices.push(e),this._emitter.emit("deviceadded",{device:e})}return this._gamepadDevices}removeGamepad(e){const t=this._gamepadDeviceMap.get(e);if(!t)return;const i=this._gamepadDevices.indexOf(t);-1!==i&&this._gamepadDevices.splice(i,1),this.remove(t),this._gamepadDeviceMap.delete(e)}}function registerPixiJSInputDeviceMixin(e){const t=e.prototype;t.navigationPriority=0,t.navigationMode="auto",Object.defineProperty(t,"isNavigatable",{get:function(){if("auto"===this.navigationMode){if(!this.isInteractive)return!1;const e=this.eventNames();return e.includes("pointerdown")||e.includes("mousedown")}return"target"===this.navigationMode},configurable:!0,enumerable:!1})}m=InputDevice,InputDevice.shared=new InputDevice,InputDevice.keyboard=m.shared.keyboard,InputDevice.gamepads=m.shared.gamepads,InputDevice.devices=m.shared.devices,InputDevice.update=m.shared.update;export{s as Button,CustomDevice,GamepadDevice,InputDevice,r as KeyCode,KeyboardDevice,Navigation,getAllNavigatables,getFirstNavigatable,registerPixiJSInputDeviceMixin};
1
+ class CustomDevice{constructor(e){this.type="custom",this.meta={},this.lastUpdated=performance.now(),this.id=e}clear(){}}const e=0,t=1,i=2,a=3,o={A:0,B:1,X:2,Y:3,LeftShoulder:4,RightShoulder:5,LeftTrigger:6,RightTrigger:7,Back:8,Start:9,LeftStick:10,RightStick:11,DPadUp:12,DPadDown:13,DPadLeft:14,DPadRight:15},n=["A","B","X","Y","LeftShoulder","RightShoulder","LeftTrigger","RightTrigger","Back","Start","LeftStick","RightStick","DPadUp","DPadDown","DPadLeft","DPadRight"];function getAllNavigatables(e,t=[]){for(const i of e.children)i.isNavigatable?t.push(i):getAllNavigatables(i,t);return t}function getFirstNavigatable(e,t,i,{minimumDistance:a=3}={}){return function chooseFirstNavigatableInDirection(e,t,i,{minimumDistance:a=3}={}){var o,n,s,r,d,u,l,c,h;const g=e.filter((e=>e.isNavigatable&&null!=e.parent&&function isVisible(e){for(;null!=e;){if(!e.visible)return!1;e=e.parent}return!0}(e))),p=g.find((e=>e===t));if(void 0===p)return g.sort(((e,t)=>e.navigationPriority-t.navigationPriority)),g[0];if(void 0===i&&p)return p;const m=null!=p?p:g[Math.floor(Math.random()*g.length)];if(void 0===p)return null!==(o=e[0])&&void 0!==o?o:m;const v=p.getBounds(),y={x:v.left+v.width/2,y:v.top+v.height/2},f=g.filter((e=>e!==p)).map((e=>{const t=e.getBounds(),i={x:t.left+t.width/2,y:t.top+t.height/2};return{element:e,bounds:t,center:i,distSqrd:squaredDist(i,y)}}));switch(i){case"navigateUp":return null!==(s=null===(n=f.filter((e=>e.center.y<y.y-a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===n?void 0:n.element)&&void 0!==s?s:m;case"navigateLeft":return null!==(d=null===(r=f.filter((e=>e.center.x<y.x-a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===r?void 0:r.element)&&void 0!==d?d:m;case"navigateRight":return null!==(l=null===(u=f.filter((e=>e.center.x>y.x+a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===u?void 0:u.element)&&void 0!==l?l:m;case"navigateDown":return null!==(h=null===(c=f.filter((e=>e.center.y>y.y+a)).sort(((e,t)=>e.distSqrd-t.distSqrd))[0])||void 0===c?void 0:c.element)&&void 0!==h?h:m;default:return p}}(getAllNavigatables(e),t,i,{minimumDistance:a})}function squaredDist(e,t){const i=t.x-e.x,a=t.y-e.y;return i*i+a*a}class NavigationManager{constructor(){this.options={enabled:!0,useFallbackHoverEffect:!0},this._responderStack=[]}get firstResponder(){return this._responderStack[0]}get responders(){return this._responderStack}commit(e,t){this.options.enabled&&this._propagateIntent(e,t)}popResponder(){var e,t,i;const a=this._responderStack.shift();return null===(t=null===(e=this.firstResponder)||void 0===e?void 0:e.becameFirstResponder)||void 0===t||t.call(e),null===(i=null==a?void 0:a.resignedAsFirstResponder)||void 0===i||i.call(a),a}pushResponder(e){var t,i;if(this._responderStack.includes(e))throw new Error("Responder already in stack.");const a=this.firstResponder;this._responderStack.unshift(e),null===(t=e.becameFirstResponder)||void 0===t||t.call(e),null===(i=null==a?void 0:a.resignedAsFirstResponder)||void 0===i||i.call(a)}_propagateIntent(e,t){var i;for(const a of this._responderStack)if(null===(i=a.handledNavigationIntent)||void 0===i?void 0:i.call(a,e,t))return;void 0===this.stage?console.warn("navigation: no stage root set"):this._handleGlobalIntent(this.stage,e)}_handleGlobalIntent(e,t){var i;if(void 0===this._focused){const i=getFirstNavigatable(e);return void 0===i?void console.debug("navigation: no navigatable views found",t):(this._emitFocus(i),void(this._focused=i))}if("navigateBack"===t)return this._emitBlur(this._focused),void(this._focused=void 0);if("trigger"===t)return void this._emitTrigger(this._focused);const a=null!==(i=getFirstNavigatable(this.stage,this._focused,t))&&void 0!==i?i:this._focused;a!==this._focused&&(this._emitBlur(this._focused),this._emitFocus(a),this._focused=a)}_emitBlur(e){const t=e.eventNames();t.includes("pointerout")?e.emit("pointerout"):t.includes("mouseout")?e.emit("mouseout"):"auto"===e.navigationMode&&this.options.useFallbackHoverEffect&&(e.alpha=1),e.emit("blur")}_emitFocus(e){const t=e.eventNames();t.includes("pointerover")?e.emit("pointerover"):t.includes("mouseover")?e.emit("mouseover"):"auto"===e.navigationMode&&this.options.useFallbackHoverEffect&&(e.alpha=.5),e.emit("focus")}_emitTrigger(e){const t=e.eventNames();t.includes("pointerdown")?e.emit("pointerdown"):t.includes("mousedown")?e.emit("mousedown"):"auto"===e.navigationMode&&this.options.useFallbackHoverEffect&&(e.alpha=.75),e.emit("trigger")}}NavigationManager.global=new NavigationManager;const s=NavigationManager.global;let r=new Map;function throttle(e,t){var i;const a=Date.now();return(null!==(i=r.get(e))&&void 0!==i?i:0)>a||(r.set(e,a+t),!1)}class EventEmitter{constructor(){this.l={}}hasListener(e){return void 0!==this.l[e]}emit(e,t){var i;null===(i=this.l[e])||void 0===i||i.forEach((e=>e(t)))}on(e,t){var i;this.l[e]||(this.l[e]=[]),null===(i=this.l[e])||void 0===i||i.push(t)}off(e,t){var i,a;this.l[e]=void 0===t||null===(i=this.l[e])||void 0===i?void 0:i.filter((e=>e!==t)),0===(null===(a=this.l[e])||void 0===a?void 0:a.length)&&(this.l[e]=void 0)}}class GamepadDevice{get leftTrigger(){return this.source.buttons[o.LeftTrigger].value}get rightTrigger(){return this.source.buttons[o.RightTrigger].value}get leftShoulder(){return this.source.buttons[o.LeftShoulder].value}get rightShoulder(){return this.source.buttons[o.RightShoulder].value}groupPressed(e){return void 0!==this.options.namedGroups[e]&&this.anyPressed(this.options.namedGroups[e])}anyPressed(e){for(let t=0;t<e.length;t++)if(this.button[e[t]])return!0;return!1}allPressed(e){for(let t=0;t<e.length;t++)if(!this.button[e[t]])return!1;return!0}on(e,t){const i="number"==typeof e?n[e]:e;return this._emitter.on(i,t),this}off(e,t){const i="number"==typeof e?n[e]:e;return this._emitter.off(i,t),this}playVibration({duration:e=200,weakMagnitude:t=.5,strongMagnitude:i=.5,vibrationType:a="dual-rumble",rightTrigger:o=0,leftTrigger:n=0,startDelay:s=0}={}){if(this.options.vibration.enabled&&this.source.vibrationActuator)try{this.source.vibrationActuator.playEffect(a,{duration:e,startDelay:s,weakMagnitude:t,strongMagnitude:i,leftTrigger:n,rightTrigger:o})}catch(e){console.warn("gamepad vibrationActuator failed with error:",e)}}update(e,t){this.lastUpdated=t,this.updatePresses(e,t),this.source=e}clear(){this._axisIntents=this._axisIntents.map((()=>!1)),this._btnPrevState=this._btnPrevState.map((()=>!1))}constructor(n){this.source=n,this.type="gamepad",this.meta={},this.lastUpdated=performance.now(),this.lastActive=performance.now(),this.options=JSON.parse(JSON.stringify(GamepadDevice.defaultOptions)),this.button=Object.keys(o).reduce(((e,t)=>(e[t]=!1,e)),{}),this._btnPrevState=new Array(16),this._axisIntents=new Array(2),this._emitter=new EventEmitter,this.id="gamepad"+n.index,this.layout=function detectLayout(e){const t=(e.id||"").toLowerCase();return/(steam|28de)/.test(t)?"steam":/(logitech|046d|c216)/.test(t)?"logitech":/(nintendo|switch|joycon|057e)/.test(t)?"nintendo":/(dualshock|dualsense|sony|054c|0ce6|0810)/.test(t)?"playstation":/(xbox|xinput|045e|028e|0291|02a0|02a1|02ea|02ff)/.test(t)?"xbox":"generic"}(n),this.leftJoystick=new GamepadJoystick(this,e,t),this.rightJoystick=new GamepadJoystick(this,i,a),this._throttleIdLeftStickX=this.id+"-lsx",this._throttleIdLeftStickY=this.id+"-lsy"}updatePresses(i,a){var r,d,u,l,c;const h=this._btnPrevState.length;for(let e=0;e<h;e++){let t=e;if("nintendo"===this.layout&&"none"!==this.options.remapNintendoMode&&("physical"===this.options.remapNintendoMode?t===o.B?t=o.A:t===o.A?t=o.B:t===o.X?t=o.Y:t===o.Y&&(t=o.X):t===o.B?t=o.X:t===o.X&&(t=o.B)),this._btnPrevState[t]===(null===(r=i.buttons[e])||void 0===r?void 0:r.pressed))continue;this.lastActive=a;const l=null!==(u=null===(d=i.buttons[e])||void 0===d?void 0:d.pressed)&&void 0!==u&&u,c=n[t];this._btnPrevState[t]=l,this.button[c]=l,l&&(this._emitter.hasListener(c)?setTimeout((()=>this._emitter.emit(c,{device:this,button:t,buttonCode:c}))):this.options.navigation.enabled&&void 0!==this.options.navigation.binds[t]&&setTimeout((()=>s.commit(this.options.navigation.binds[t],this))))}const g=null!==(l=i.axes[e])&&void 0!==l?l:0,p=null!==(c=i.axes[t])&&void 0!==c?c:0;if(Math.abs(g)>=this.options.intent.joystickCommitSensitivity){const t=g<0?"navigateLeft":"navigateRight",i=this._axisIntents[e]?this.options.intent.defaultCooldownMs:this.options.intent.firstCooldownMs;this._axisIntents[e]=!0,this.options.navigation.enabled&&!throttle(this._throttleIdLeftStickX,i)&&setTimeout((()=>s.commit(t,this)))}else this._axisIntents[e]=!1;if(Math.abs(p)>=this.options.intent.joystickCommitSensitivity){const e=p<0?"navigateUp":"navigateDown",i=this._axisIntents[t]?this.options.intent.defaultCooldownMs:this.options.intent.firstCooldownMs;this._axisIntents[t]=!0,this.options.navigation.enabled&&!throttle(this._throttleIdLeftStickY,i)&&setTimeout((()=>s.commit(e,this)))}else this._axisIntents[t]=!1}}GamepadDevice.defaultOptions={remapNintendoMode:"physical",namedGroups:{},navigation:{enabled:!0,binds:{[o.A]:"trigger",[o.B]:"navigateBack",[o.Back]:"navigateBack",[o.DPadDown]:"navigateDown",[o.DPadLeft]:"navigateLeft",[o.DPadRight]:"navigateRight",[o.DPadUp]:"navigateUp"}},intent:{joystickCommitSensitivity:.5,firstCooldownMs:400,defaultCooldownMs:80},vibration:{enabled:!0,intensity:1}};class GamepadJoystick{constructor(e,t,i){this._owner=e,this.ix=t,this.iy=i}get x(){return this._owner.source.axes[this.ix]}get y(){return this._owner.source.axes[this.iy]}}const d={AltLeft:"AltLeft",AltRight:"AltRight",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",Backquote:"Backquote",Backslash:"Backslash",Backspace:"Backspace",BracketLeft:"BracketLeft",BracketRight:"BracketRight",CapsLock:"CapsLock",Comma:"Comma",ContextMenu:"ContextMenu",ControlLeft:"ControlLeft",ControlRight:"ControlRight",Delete:"Delete",Digit0:"Digit0",Digit1:"Digit1",Digit2:"Digit2",Digit3:"Digit3",Digit4:"Digit4",Digit5:"Digit5",Digit6:"Digit6",Digit7:"Digit7",Digit8:"Digit8",Digit9:"Digit9",End:"End",Enter:"Enter",Equal:"Equal",Escape:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F2:"F2",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F3:"F3",F30:"F30",F31:"F31",F32:"F32",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Home:"Home",IntlBackslash:"IntlBackslash",IntlRo:"IntlRo",IntlYen:"IntlYen",KeyA:"KeyA",KeyB:"KeyB",KeyC:"KeyC",KeyD:"KeyD",KeyE:"KeyE",KeyF:"KeyF",KeyG:"KeyG",KeyH:"KeyH",KeyI:"KeyI",KeyJ:"KeyJ",KeyK:"KeyK",KeyL:"KeyL",KeyM:"KeyM",KeyN:"KeyN",KeyO:"KeyO",KeyP:"KeyP",KeyQ:"KeyQ",KeyR:"KeyR",KeyS:"KeyS",KeyT:"KeyT",KeyU:"KeyU",KeyV:"KeyV",KeyW:"KeyW",KeyX:"KeyX",KeyY:"KeyY",KeyZ:"KeyZ",Lang1:"Lang1",Lang2:"Lang2",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",MetaLeft:"MetaLeft",MetaRight:"MetaRight",Minus:"Minus",NumLock:"NumLock",Numpad0:"Numpad0",Numpad1:"Numpad1",Numpad2:"Numpad2",Numpad3:"Numpad3",Numpad4:"Numpad4",Numpad5:"Numpad5",Numpad6:"Numpad6",Numpad7:"Numpad7",Numpad8:"Numpad8",Numpad9:"Numpad9",NumpadAdd:"NumpadAdd",NumpadComma:"NumpadComma",NumpadDecimal:"NumpadDecimal",NumpadDivide:"NumpadDivide",NumpadMultiply:"NumpadMultiply",NumpadSubtract:"NumpadSubtract",OSLeft:"OSLeft",Pause:"Pause",Period:"Period",Quote:"Quote",ScrollLock:"ScrollLock",Semicolon:"Semicolon",ShiftLeft:"ShiftLeft",ShiftRight:"ShiftRight",Slash:"Slash",Space:"Space",Tab:"Tab",VolumeDown:"VolumeDown",VolumeMute:"VolumeMute",VolumeUp:"VolumeUp",WakeUp:"WakeUp"};function __awaiter(e,t,i,a){return new(i||(i=Promise))((function(o,n){function fulfilled(e){try{step(a.next(e))}catch(e){n(e)}}function rejected(e){try{step(a.throw(e))}catch(e){n(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof i?e:new i((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const u=["fr","mg","lu"],l=["ab","ba","be","bg","ch","kk","ky","mk","mn","ru","sr","tg","tt","uk","uz"],c=["de","cs","sk","sl","hu","hr","bs","ro","sq","me","lt","lv","et"],h=/ф|и|с|в|у|а|п|р|ш|о|л|д|ь|т|щ|з|й|к|ы|е|г|м|ц|ч|н|я|ё|х|ъ|б|ю|э|ж|и/i,g=/[a-z]/i;function inferKeyboardLayoutFromLang(e=function getLang(){var e;const t=navigator;return null!=(null===(e=t.languages)||void 0===e?void 0:e.length)?t.languages[0]:t.userLanguage||t.language||t.browserLanguage}()){const t=(e||"").toLowerCase(),i=t.split("-")[0];return u.includes(i)||t.startsWith("nl-be")?"AZERTY":l.includes(i)?"JCUKEN":c.includes(i)||t.startsWith("sr-latn")?"QWERTZ":"QWERTY"}const p=new Set(["AZERTY","JCUKEN","QWERTY","QWERTZ"]);let m;function getMetaKeyLabel(){var e,t,i,a;const o=navigator,n=null!==(t=null===(e=o.platform)||void 0===e?void 0:e.toLowerCase())&&void 0!==t?t:"",s=null!==(a=null===(i=o.userAgent)||void 0===i?void 0:i.toLowerCase())&&void 0!==a?a:"";return n.includes("mac")?"⌘":n.includes("win")||n.includes("linux")?"⊞":s.includes("android")?"Search":s.includes("iphone")||s.includes("ipad")?"⌘":"⊞"}class KeyboardDevice{constructor(){this.type="keyboard",this.id="keyboard",this.meta={},this.lastUpdated=performance.now(),this.detectLayoutOnKeypress=!0,this.detected=!1,this._emitter=new EventEmitter,this.options={preventDefaultKeys:new Set([]),namedGroups:{},navigation:{enabled:!0,binds:{Space:"trigger",Enter:"trigger",Escape:"navigateBack",Backspace:"navigateBack",ArrowDown:"navigateDown",ArrowLeft:"navigateLeft",ArrowRight:"navigateRight",ArrowUp:"navigateUp",KeyA:"navigateLeft",KeyD:"navigateRight",KeyS:"navigateDown",KeyW:"navigateUp"}}},this.key=Object.keys(d).reduce(((e,t)=>(e[t]=!1,e)),{}),this._layout=inferKeyboardLayoutFromLang(),this._layoutSource="lang",function requestKeyboardLayout(){return __awaiter(this,void 0,void 0,(function*(){const e=navigator;if(e.keyboard&&e.keyboard.getLayoutMap)try{const t=yield e.keyboard.getLayoutMap(),i=t.get("KeyQ"),a=t.get("KeyA"),o=t.get("KeyZ");if("a"===i&&"w"===o&&"q"===a)return"AZERTY";if("q"===i&&"y"===o&&"a"===a)return"QWERTZ";if("q"===i&&"z"===o&&"a"===a)return"QWERTY";if("й"===i&&"я"===o&&"ф"===a)return"JCUKEN"}catch(e){console.error("Error detecting keyboard layout:",e)}}))}().then((e=>{void 0!==e&&(this._layoutSource="browser",this._layout=e,this._emitter.emit("layoutdetected",{layoutSource:"browser",layout:e,device:this}))})),this._configureEventListeners()}get layout(){return this._layout}set layout(e){this._layoutSource="manual",this._layout=e}get layoutSource(){return this._layoutSource}groupPressed(e){return void 0!==this.options.namedGroups[e]&&this.anyPressed(this.options.namedGroups[e])}anyPressed(e){for(let t=0;t<e.length;t++)if(this.key[e[t]])return!0;return!1}allPressed(e){for(let t=0;t<e.length;t++)if(!this.key[e[t]])return!1;return!0}on(e,t){return this._emitter.on(e,t),this}off(e,t){return this._emitter.off(e,t),this}keyLabel(e,t=this._layout){return function getLayoutLabel(e,t){if(void 0===m){const e={ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓",AltLeft:"Left Alt",AltRight:"Right Alt",Backquote:"`",Backslash:"\\",Backspace:"Backspace",BracketLeft:"[",BracketRight:"]",CapsLock:"Caps Lock",Comma:",",ContextMenu:"Context Menu",ControlLeft:"Left Ctrl",ControlRight:"Right Ctrl",Delete:"Delete",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",End:"End",Enter:"Enter",Equal:"=",Escape:"Esc",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",Home:"Home",IntlBackslash:"\\",IntlRo:"Ro",IntlYen:"¥",KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Lang1:"Language 1",Lang2:"Language 2",MediaTrackNext:"Next Track",MediaTrackPrevious:"Previous Track",MetaLeft:"Left "+getMetaKeyLabel(),MetaRight:"Right "+getMetaKeyLabel(),Minus:"-",NumLock:"Num Lock",Numpad0:"Num0",Numpad1:"Num1",Numpad2:"Num2",Numpad3:"Num3",Numpad4:"Num4",Numpad5:"Num5",Numpad6:"Num6",Numpad7:"Num7",Numpad8:"Num8",Numpad9:"Num9",NumpadAdd:"+",NumpadComma:",",NumpadDecimal:".",NumpadDivide:"/",NumpadMultiply:"*",NumpadSubtract:"-",OSLeft:"OS Left",Pause:"Pause",Period:".",Quote:"'",ScrollLock:"Scroll Lock",Semicolon:";",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",Slash:"/",Space:"Space",Tab:"Tab",VolumeDown:"Volume Down",VolumeMute:"Mute",VolumeUp:"Volume Up",WakeUp:"Wake Up"},t=Object.assign(Object.assign({},e),{KeyA:"Q",KeyQ:"A",KeyW:"Z",KeyZ:"W",Backquote:"²",BracketLeft:"«",BracketRight:"»"}),i=Object.assign(Object.assign({},e),{KeyA:"Ф",KeyB:"И",KeyC:"С",KeyD:"В",KeyE:"У",KeyF:"А",KeyG:"П",KeyH:"Р",KeyI:"Ш",KeyJ:"О",KeyK:"Л",KeyL:"Д",KeyM:"Ь",KeyN:"Т",KeyO:"Щ",KeyP:"З",KeyQ:"Й",KeyR:"К",KeyS:"Ы",KeyT:"Е",KeyU:"Г",KeyV:"М",KeyW:"Ц",KeyX:"Ч",KeyY:"Н",KeyZ:"Я",Backquote:"Ё",BracketLeft:"х",BracketRight:"ъ",Comma:"Б",Period:"Ю",Quote:"Э",Semicolon:"Ж",Slash:"И"}),a=Object.assign(Object.assign({},e),{KeyY:"Z",KeyZ:"Y",BracketLeft:"ü",BracketRight:"ö",Slash:"-"});m={AZERTY:t,JCUKEN:i,QWERTY:e,QWERTZ:a}}return m[t][e]}(e,t)}clear(){for(const e of Object.keys(d))this.key[e]=!1}_configureEventListeners(){document.addEventListener("keydown",(e=>{const t=e.code;if(this.key[t]=!0,this.options.preventDefaultKeys.has(t)&&e.preventDefault(),this.detectLayoutOnKeypress&&"lang"===this._layoutSource){const t=function detectKeyboardLayoutFromKeydown(e){const t=e.key.toLowerCase(),i=e.code;return h.test(t)?(p.delete("AZERTY"),p.delete("QWERTY"),p.delete("QWERTZ")):"Backquote"===i&&"²"===t||"BracketLeft"===i&&"«"===t||"BracketRight"===i&&"»"===t||"KeyA"===i&&"q"===t||"KeyQ"===i&&"a"===t||"KeyW"===i&&"z"===t||"KeyZ"===i&&"w"===t?(p.delete("JCUKEN"),p.delete("QWERTY"),p.delete("QWERTZ")):"BracketLeft"===i&&"ü"===t||"BracketRight"===i&&"ö"===t||"KeyY"===i&&"z"===t||"KeyZ"===i&&"y"===t||"Slash"===i&&"-"===t?(p.delete("AZERTY"),p.delete("JCUKEN"),p.delete("QWERTY")):"BracketLeft"===i&&"["===t||"BracketRight"===i&&"]"===t||"KeyZ"===i&&"z"===t?(p.delete("AZERTY"),p.delete("JCUKEN"),p.delete("QWERTZ")):"KeyQ"===i&&"q"===t||"KeyW"===i&&"w"===t?(p.delete("AZERTY"),p.delete("JCUKEN")):"KeyY"===i&&"Y"===t?(p.delete("QWERTZ"),p.delete("JCUKEN")):g.test(t)&&p.delete("JCUKEN"),1===p.size?[...p][0]:void 0}(e);void 0!==t&&(this._layout=t,this._layoutSource="keypress",this.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{layout:t,layoutSource:"keypress",device:this}))}this._emitter.hasListener(t)?setTimeout((()=>this._emitter.emit(t,{device:this,keyCode:t,keyLabel:this.keyLabel(t),event:e}))):this.options.navigation.enabled&&void 0!==this.options.navigation.binds[t]&&(e.preventDefault(),setTimeout((()=>s.commit(this.options.navigation.binds[t],this))))})),document.addEventListener("keyup",(e=>{this.key[e.code]=!1,this.options.preventDefaultKeys.has(e.code)&&e.preventDefault()}))}}KeyboardDevice.global=new KeyboardDevice;class InputDeviceManager{on(e,t){return this._emitter.on(e,t),this}off(e,t){return this._emitter.off(e,t),this}get gamepads(){return this._gamepadDevices}get devices(){return this._devices}constructor(){this._emitter=new EventEmitter,this.isMobile=(()=>{let e=!1;var t;return t=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0),e})(),this.isTouchCapable=function isTouchCapable(){return"ontouchstart"in window||navigator.maxTouchPoints>0}(),this.hasFocus=!1,this.options={clearInputInBackground:!0},this._gamepadDevices=[],this._gamepadDeviceMap=new Map,this._devices=[];const registerKeyboard=()=>{window.removeEventListener("keydown",registerKeyboard),this._devices.push(this.keyboard),this._emitter.emit("deviceadded",{device:this.keyboard}),this.keyboard.detected=!0};this.keyboard=KeyboardDevice.global,this.isTouchCapable||this.isMobile?window.addEventListener("keydown",registerKeyboard):registerKeyboard(),window.addEventListener("gamepadconnected",(()=>this.pollGamepads(performance.now()))),window.addEventListener("gamepaddisconnected",(e=>this.removeGamepad(e.gamepad.index)))}update(){if(!document.hasFocus())return this.hasFocus&&this.options.clearInputInBackground&&this.devices.forEach((e=>e.clear())),this.hasFocus=!1,this._devices;this.hasFocus=!0;const e=performance.now();return this.keyboard.lastUpdated=e,this.pollGamepads(e),this._devices}add(e){this._devices.push(e)}remove(e){const t=this._devices.indexOf(e);-1!==t&&(this._devices.splice(t,1),this._emitter.emit("deviceremoved",{device:e}))}pollGamepads(e){if(!document.hasFocus())return this._gamepadDevices;if(void 0===navigator.getGamepads)return this._gamepadDevices;for(const t of navigator.getGamepads())if(null!=t)if(this._gamepadDeviceMap.has(t.index)){this._gamepadDeviceMap.get(t.index).update(t,e)}else{const e=new GamepadDevice(t);this._gamepadDeviceMap.set(t.index,e),this._gamepadDevices.push(e),this._devices.push(e),this._emitter.emit("deviceadded",{device:e})}return this._gamepadDevices}removeGamepad(e){const t=this._gamepadDeviceMap.get(e);if(!t)return;const i=this._gamepadDevices.indexOf(t);-1!==i&&this._gamepadDevices.splice(i,1),this.remove(t),this._gamepadDeviceMap.delete(e)}}InputDeviceManager.global=new InputDeviceManager;const v=InputDeviceManager.global;function registerPixiJSInputDeviceMixin(e){const t=e.prototype;t.navigationPriority=0,t.navigationMode="auto",Object.defineProperty(t,"isNavigatable",{get:function(){if("auto"===this.navigationMode){if(!this.isInteractive)return!1;const e=this.eventNames();return e.includes("pointerdown")||e.includes("mousedown")}return"target"===this.navigationMode},configurable:!0,enumerable:!1})}export{o as Button,CustomDevice,GamepadDevice,v as InputDevice,d as KeyCode,KeyboardDevice,s as Navigation,getAllNavigatables,getFirstNavigatable,registerPixiJSInputDeviceMixin};
2
2
  //# sourceMappingURL=index.mjs.map