UNPKG

react-force-graph

Version:

React component for 2D, 3D, VR and AR force directed graphs

2 lines 2.15 MB
// Version 1.47.7 react-force-graph - https://github.com/vasturiano/react-force-graph !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ForceGraph={},t.React)}(this,(function(e,n){"use strict";function r(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(t){u=!0,i=t}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(t,e)||o(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,s,o,a=[],l=!0,u=!1;try{if(s=(n=n.call(t)).next,0===e);else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(t){u=!0,i=t}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return a}}(t,e)||c(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){if(t){if("string"==typeof t)return l(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.useEffect,r=n.useRef(),i=n.useRef(!1),s=n.useRef(!1),o=u(n.useState(0),2);o[0];var a=o[1];i.current&&(s.current=!0),e((function(){return i.current||(r.current=t(),i.current=!0),a((function(t){return t+1})),function(){s.current&&r.current&&r.current()}}),[])}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function f(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var m,g,y,v,_,b,x,w={};function M(){return y?g:(y=1,g=Object.assign((function(){}),{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16}))}function S(){if(x)return b;x=1;const t=M(),e=(_||(_=1,v=function(t,e,n){this.type=t,this.index=e,this.pressed=n.pressed,this.value=n.value}),v),n=.2,r="left",i="right",s=1,o=2;return b=AFRAME.registerComponent("gamepad-controls",{GamepadButton:t,schema:{enabled:{default:!0},rotationSensitivity:{default:2}},init:function(){const t=this.el.sceneEl;this.system=t.systems["tracked-controls"]||t.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};const e=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=e.x,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=e.y,this.yaw.add(this.pitch),this._lookVector=new THREE.Vector2,this._moveVector=new THREE.Vector2,this._dpadVector=new THREE.Vector2,t.addBehavior(this)},update:function(){this.tick()},tick:function(t,e){this.updateButtonState(),this.updateRotation(e)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const t=this._dpadVector,e=this._moveVector;this.getDpad(t),this.getJoystick(s,e);const r=t.x||e.x,i=t.y||e.y;return Math.abs(r)>n||Math.abs(i)>n},getVelocityDelta:function(){const t=this._dpadVector,e=this._moveVector;this.getDpad(t),this.getJoystick(s,e);const r=t.x||e.x,i=t.y||e.y,o=new THREE.Vector3;return Math.abs(r)>n&&(o.x+=r),Math.abs(i)>n&&(o.z+=i),o},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const t=this._lookVector;return this.getJoystick(o,t),Math.abs(t.x)>n||Math.abs(t.y)>n},updateRotation:function(t){if(!this.isRotationActive())return;const e=this.data,r=this.yaw,i=this.pitch;r.rotation.y=this.el.object3D.rotation.y,i.rotation.x=this.el.object3D.rotation.x;const s=this._lookVector;this.getJoystick(o,s),Math.abs(s.x)<=n&&(s.x=0),Math.abs(s.y)<=n&&(s.y=0),s.multiplyScalar(e.rotationSensitivity*t/1e3),r.rotation.y-=s.x,i.rotation.x-=s.y,i.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,i.rotation.x)),this.el.object3D.rotation.set(i.rotation.x,r.rotation.y,0)},updateButtonState:function(){const t=this.getGamepad(i);if(this.data.enabled&&t)for(var n=0;n<t.buttons.length;n++)t.buttons[n].pressed&&!this.buttons[n]?this.emit(new e("gamepadbuttondown",n,t.buttons[n])):!t.buttons[n].pressed&&this.buttons[n]&&this.emit(new e("gamepadbuttonup",n,t.buttons[n])),this.buttons[n]=t.buttons[n].pressed;else for(const t in this.buttons)this.buttons[t]=!1},emit:function(t){this.el.emit(t.type,t),this.el.emit(t.type+":"+t.index,new e(t.type,t.index,t))},getGamepad:function(){const t=[],e=[];return function(n){const r=this.el.sceneEl.components["proxy-controls"],i=r&&r.isConnected()&&r.getGamepad(0);if(i)return i;t.length=0;for(let e=0;e<this.system.controllers.length;e++){const r=this.system.controllers[e],i=r?r.gamepad:null;if(t.push(i),i&&r.handedness===n)return i}const s=navigator.getGamepads?navigator.getGamepads():e;for(let t=0;t<s.length;t++){const e=s[t];if(e&&e.hand===n)return e}return t[0]||s[0]}}(),getButton:function(t){return this.getGamepad(i).buttons[t]},getAxis:function(t){return this.getGamepad(t>1?i:r).axes[t]},getJoystick:function(t,e){const n=this.getGamepad(t===s?r:i);if(!n)return e.set(0,0);if("xr-standard"===n.mapping)switch(t){case s:return e.set(n.axes[2],n.axes[3]);case o:return e.set(n.axes[2],0)}else switch(t){case s:return e.set(n.axes[0],n.axes[1]);case o:return e.set(n.axes[2],n.axes[3])}throw new Error('Unexpected joystick index "%d".',t)},getDpad:function(e){const n=this.getGamepad(r);return n&&n.buttons[t.DPAD_RIGHT]?e.set((n.buttons[t.DPAD_RIGHT].pressed?1:0)+(n.buttons[t.DPAD_LEFT].pressed?-1:0),(n.buttons[t.DPAD_UP].pressed?-1:0)+(n.buttons[t.DPAD_DOWN].pressed?1:0)):e.set(0,0)},isConnected:function(){const t=this.getGamepad(r);return!(!t||!t.connected)},getID:function(){return this.getGamepad(r).id}}),b}var T,E,A,C,R,N,P,k={};function O(){return T||(T=1,function(t){var e="KeyboardEvent"in t;e||(t.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in t.KeyboardEvent||(t.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var n=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,r=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,i=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,s=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function o(t,e){return-1!==String(t).indexOf(e)}var a=o(navigator.platform,"Win")?"win":o(navigator.platform,"Mac")?"mac":o(navigator.platform,"CrOS")?"cros":o(navigator.platform,"Linux")?"linux":o(navigator.userAgent,"iPad")||o(navigator.platform,"iPod")||o(navigator.platform,"iPhone")?"ios":"",l=o(navigator.userAgent,"Chrome/")?"chrome":o(navigator.vendor,"Apple")?"safari":o(navigator.userAgent,"MSIE")?"ie":o(navigator.userAgent,"Gecko/")?"moz":o(navigator.userAgent,"Opera/")?"opera":"",u=l+"-"+a;function h(t,e,n){u!==e&&l!==e&&a!==e||Object.keys(n).forEach((function(e){t[e]=n[e]}))}var c={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:r},92:{code:"OSRight",location:i},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:s},97:{code:"Numpad1",keyCap:"1",location:s},98:{code:"Numpad2",keyCap:"2",location:s},99:{code:"Numpad3",keyCap:"3",location:s},100:{code:"Numpad4",keyCap:"4",location:s},101:{code:"Numpad5",keyCap:"5",location:s},102:{code:"Numpad6",keyCap:"6",location:s},103:{code:"Numpad7",keyCap:"7",location:s},104:{code:"Numpad8",keyCap:"8",location:s},105:{code:"Numpad9",keyCap:"9",location:s},106:{code:"NumpadMultiply",keyCap:"*",location:s},107:{code:"NumpadAdd",keyCap:"+",location:s},108:{code:"NumpadComma",keyCap:",",location:s},109:{code:"NumpadSubtract",keyCap:"-",location:s},110:{code:"NumpadDecimal",keyCap:".",location:s},111:{code:"NumpadDivide",keyCap:"/",location:s},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:s},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:r},161:{code:"ShiftRight",location:i},162:{code:"ControlLeft",location:r},163:{code:"ControlRight",location:i},164:{code:"AltLeft",location:r},165:{code:"AltRight",location:i},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};h(c,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:s},189:{code:"NumpadSubtract",keyCap:"-",location:s}}),h(c,"moz-mac",{12:{code:"NumLock",location:s},173:{code:"Minus",keyCap:"-"}}),h(c,"moz-win",{173:{code:"Minus",keyCap:"-"}}),h(c,"chrome-mac",{93:{code:"OSRight",location:i}}),h(c,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),h(c,"ios",{10:{code:"Enter",location:n}}),h(c,"safari-mac",{91:{code:"OSLeft",location:r},93:{code:"OSRight",location:i},229:{code:"KeyQ",keyCap:"Q"}});var d={};"cros"===a&&(d["U+00A0"]={code:"ShiftLeft",location:r},d["U+00A1"]={code:"ShiftRight",location:i},d["U+00A2"]={code:"ControlLeft",location:r},d["U+00A3"]={code:"ControlRight",location:i},d["U+00A4"]={code:"AltLeft",location:r},d["U+00A5"]={code:"AltRight",location:i}),"chrome-mac"===u&&(d["U+0010"]={code:"ContextMenu"}),"safari-mac"===u&&(d["U+0010"]={code:"ContextMenu"}),"ios"===a&&(d["U+0010"]={code:"Function"},d["U+001C"]={code:"ArrowLeft"},d["U+001D"]={code:"ArrowRight"},d["U+001E"]={code:"ArrowUp"},d["U+001F"]={code:"ArrowDown"},d["U+0001"]={code:"Home"},d["U+0004"]={code:"End"},d["U+000B"]={code:"PageUp"},d["U+000C"]={code:"PageDown"});var p=[];p[r]={16:{code:"ShiftLeft",location:r},17:{code:"ControlLeft",location:r},18:{code:"AltLeft",location:r}},p[i]={16:{code:"ShiftRight",location:i},17:{code:"ControlRight",location:i},18:{code:"AltRight",location:i}},p[s]={13:{code:"NumpadEnter",location:s}},h(p[s],"moz",{109:{code:"NumpadSubtract",location:s},107:{code:"NumpadAdd",location:s}}),h(p[r],"moz-mac",{224:{code:"OSLeft",location:r}}),h(p[i],"moz-mac",{224:{code:"OSRight",location:i}}),h(p[i],"moz-win",{91:{code:"OSRight",location:i}}),h(p[i],"mac",{93:{code:"OSRight",location:i}}),h(p[s],"chrome-mac",{12:{code:"NumLock",location:s}}),h(p[s],"safari-mac",{12:{code:"NumLock",location:s},187:{code:"NumpadAdd",location:s},189:{code:"NumpadSubtract",location:s},190:{code:"NumpadDecimal",location:s},191:{code:"NumpadDivide",location:s}});var f={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};h(f,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var m={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},g=function(t,e){var n={};return Object.keys(t).forEach((function(r){var i=t[r];e in i&&(n[i[e]]=i)})),n}(c,"code");try{var y=e&&"location"in new KeyboardEvent("")}catch(t){}function v(t){var e="keyCode"in t?t.keyCode:"which"in t?t.which:0,n=function(){if(y||"keyLocation"in t){var n=y?t.location:t.keyLocation;if(n&&e in p[n])return p[n][e]}return"keyIdentifier"in t&&t.keyIdentifier in d?d[t.keyIdentifier]:e in c?c[e]:null}();if(!n)return null;var r,i=(r=f[n.code])?t.shiftKey&&"shiftKey"in r?r.shiftKey:r.key:n.code;return{code:n.code,key:i,location:n.location,keyCap:n.keyCap}}"KeyboardEvent"in t&&"defineProperty"in Object&&function(){function t(t,e,n){e in t||Object.defineProperty(t,e,n)}if(t(KeyboardEvent.prototype,"code",{get:function(){var t=v(this);return t?t.code:""}}),"key"in KeyboardEvent.prototype){var e=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var t=e.get.call(this);return m.hasOwnProperty(t)?m[t]:t}})}t(KeyboardEvent.prototype,"key",{get:function(){var t=v(this);return t&&"key"in t?t.key:"Unidentified"}}),t(KeyboardEvent.prototype,"location",{get:function(){var t=v(this);return t&&"location"in t?t.location:n}}),t(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in t.KeyboardEvent||(t.KeyboardEvent.queryKeyCap=function(t,e){if(t=String(t),!g.hasOwnProperty(t))return"Undefined";if(e&&"en-us"!==String(e).toLowerCase())throw Error("Unsupported locale");var n=g[t];return n.keyCap||n.code||"Undefined"}),t.identifyKey=function(t){if(!("code"in t)){var e=v(t);t.code=e?e.code:"",t.key=e&&"key"in e?e.key:"Unidentified",t.location="location"in t?t.location:"keyLocation"in t?t.keyLocation:e&&"location"in e?e.location:n,t.locale=""}}}(window)),k}const I=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)},D=t=>t*(Math.PI/180),L=t=>t*(180/Math.PI),U=new Map,F=t=>{U.has(t)&&clearTimeout(U.get(t)),U.set(t,setTimeout(t,100))},z=(t,e,n)=>{const r=e.split(/[ ,]+/g);let i;for(let e=0;e<r.length;e+=1)i=r[e],t.addEventListener?t.addEventListener(i,n,!1):t.attachEvent&&t.attachEvent(i,n)},B=(t,e,n)=>{const r=e.split(/[ ,]+/g);let i;for(let e=0;e<r.length;e+=1)i=r[e],t.removeEventListener?t.removeEventListener(i,n):t.detachEvent&&t.detachEvent(i,n)},j=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),V=()=>({x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}),G=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},H=(t,e,n)=>{const r=W(t);for(let t in r)if(r.hasOwnProperty(t))if("string"==typeof e)r[t]=e+" "+n;else{let i="";for(let t=0,r=e.length;t<r;t+=1)i+=e[t]+" "+n+", ";r[t]=i.slice(0,-2)}return r},W=t=>{const e={};e[t]="";return["webkit","Moz","o"].forEach((function(n){e[n+t.charAt(0).toUpperCase()+t.slice(1)]=""})),e},q=(t,e)=>{for(let n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},$=(t,e)=>{if(t.length)for(let n=0,r=t.length;n<r;n+=1)e(t[n]);else e(t)};var X,Y=!!("ontouchstart"in window),K=!!window.PointerEvent,Z=!!window.MSPointerEvent,J={start:"mousedown",move:"mousemove",end:"mouseup"},Q={};function tt(){}function et(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=et.id,et.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}function nt(t,e){var n=this;n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.pressureIntervals={},n.manager=t,n.id=nt.id,nt.id+=1,n.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},n.config(e),"static"!==n.options.mode&&"semi"!==n.options.mode||(n.options.multitouch=!1),n.options.multitouch||(n.options.maxNumberOfNipples=1);const r=getComputedStyle(n.options.zone.parentElement);return r&&"flex"===r.display&&(n.parentIsFlex=!0),n.updateBox(),n.prepareNipples(),n.bindings(),n.begin(),n.nipples}function rt(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=V(),e.config(t),e.prepareCollections();var n=function(){var t;e.collections.forEach((function(n){n.forEach((function(n){t=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+t.left,y:e.scroll.y+t.top}}))}))};z(window,"resize",(function(){F(n)}));var r=function(){e.scroll=V()};return z(window,"scroll",(function(){F(r)})),e.collections}K?X={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:Z?X={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Y?(X={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Q=J):X=J,tt.prototype.on=function(t,e){var n,r=this,i=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<i.length;s+=1)n=i[s],r._handlers_[n]=r._handlers_[n]||[],r._handlers_[n].push(e);return r},tt.prototype.off=function(t,e){var n=this;return n._handlers_=n._handlers_||{},void 0===t?n._handlers_={}:void 0===e?n._handlers_[t]=null:n._handlers_[t]&&n._handlers_[t].indexOf(e)>=0&&n._handlers_[t].splice(n._handlers_[t].indexOf(e),1),n},tt.prototype.trigger=function(t,e){var n,r=this,i=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var s=0;s<i.length;s+=1)n=i[s],r._handlers_[n]&&r._handlers_[n].length&&r._handlers_[n].forEach((function(t){t.call(r,{type:n,target:r},e)}))},tt.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((t,e)=>{const n={};for(let r in t)t.hasOwnProperty(r)&&e.hasOwnProperty(r)?n[r]=e[r]:t.hasOwnProperty(r)&&(n[r]=t[r]);return n})(e.options,t))},tt.prototype.bindEvt=function(t,e){var n=this;return n._domHandlers_=n._domHandlers_||{},n._domHandlers_[e]=function(){"function"==typeof n["on"+e]?n["on"+e].apply(n,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},z(t,X[e],n._domHandlers_[e]),Q[e]&&z(t,Q[e],n._domHandlers_[e]),n},tt.prototype.unbindEvt=function(t,e){var n=this;return n._domHandlers_=n._domHandlers_||{},B(t,X[e],n._domHandlers_[e]),Q[e]&&B(t,Q[e],n._domHandlers_[e]),delete n._domHandlers_[e],this},et.prototype=new tt,et.constructor=et,et.id=0,et.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},et.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=((t,e)=>{const n=W(t);for(let t in n)n.hasOwnProperty(t)&&(n[t]=e);return n})("borderRadius","50%"),n=H("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},q(r.el,n),"circle"===this.options.shape&&q(r.back,e),q(r.front,e),this.applyStyles(r),this},et.prototype.applyStyles=function(t){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var n in t[e])this.ui[e].style[n]=t[e][n];return this},et.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},et.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},et.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},et.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout((function(){e.ui.el.style.opacity=1}),0),e.showTimeout=setTimeout((function(){e.trigger("shown",e.instance),"function"==typeof t&&t.call(this)}),e.options.fadeTime)),e},et.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout((function(){var n="dynamic"===e.options.mode?"none":"block";e.ui.el.style.display=n,"function"==typeof t&&t.call(e),e.trigger("hidden",e.instance)}),e.options.fadeTime),e.options.restJoystick){const n=e.options.restJoystick,r={};r.x=!0===n||!1!==n.x?0:e.instance.frontPosition.x,r.y=!0===n||!1!==n.y?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},et.prototype.setPosition=function(t,e){var n=this;n.frontPosition={x:e.x,y:e.y};var r=n.options.fadeTime+"ms",i={};i.front=H("transition",["transform"],r);var s={front:{}};s.front={transform:"translate("+n.frontPosition.x+"px,"+n.frontPosition.y+"px)"},n.applyStyles(i),n.applyStyles(s),n.restTimeout=setTimeout((function(){"function"==typeof t&&t.call(n),n.restCallback()}),n.options.fadeTime)},et.prototype.restCallback=function(){var t=this,e={};e.front=H("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},et.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},et.prototype.computeDirection=function(t){var e,n,r,i=t.angle.radian,s=Math.PI/4,o=Math.PI/2;if(i>s&&i<3*s&&!t.lockX?e="up":i>-s&&i<=s&&!t.lockY?e="left":i>3*-s&&i<=-s&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(n=i>-o&&i<o?"left":"right"),t.lockX||(r=i>0?"up":"down"),t.force>this.options.threshold){var a,l={};for(a in this.direction)this.direction.hasOwnProperty(a)&&(l[a]=this.direction[a]);var u={};for(a in this.direction={x:n,y:r,angle:e},t.direction=this.direction,l)l[a]===this.direction[a]&&(u[a]=!0);if(u.x&&u.y&&u.angle)return t;u.x&&u.y||this.trigger("plain",t),u.x||this.trigger("plain:"+n,t),u.y||this.trigger("plain:"+r,t),u.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t},nt.prototype=new tt,nt.constructor=nt,nt.id=0,nt.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(t){if(void 0===t)return e[0];for(var n=0,r=e.length;n<r;n+=1)if(e[n].identifier===t)return e[n];return!1}},nt.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},nt.prototype.begin=function(){var t=this,e=t.options;if("static"===e.mode){var n=t.createNipple(e.position,t.manager.getIdentifier());n.add(),t.idles.push(n)}},nt.prototype.createNipple=function(t,e){var n=this,r=n.manager.scroll,i={},s=n.options,o=n.parentIsFlex?r.x:r.x+n.box.left,a=n.parentIsFlex?r.y:r.y+n.box.top;if(t.x&&t.y)i={x:t.x-o,y:t.y-a};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",s.zone.appendChild(l);var u=l.getBoundingClientRect();s.zone.removeChild(l),i=t,t={x:u.left+r.x,y:u.top+r.y}}var h=new et(n,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:e,position:t,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(G(h.ui.el,i),G(h.ui.front,h.frontPosition)),n.nipples.push(h),n.trigger("added "+h.identifier+":added",h),n.manager.trigger("added "+h.identifier+":added",h),n.bindNipple(h),h},nt.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},nt.prototype.bindNipple=function(t){var e,n=this,r=function(t,r){e=t.type+" "+r.id+":"+t.type,n.trigger(e,r)};t.on("destroyed",n.onDestroyed.bind(n)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},nt.prototype.pressureFn=function(t,e,n){var r=this,i=0;clearInterval(r.pressureIntervals[n]),r.pressureIntervals[n]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==i&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),i=n)}.bind(r),100)},nt.prototype.onstart=function(t){var e=this,n=e.options,r=t;t=j(t),e.updateBox();return $(t,(function(i){e.actives.length<n.maxNumberOfNipples?e.processOnStart(i):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach((function(n){if(Object.values(r.touches).findIndex((function(t){return t.identifier===n}))<0){var i=[t[0]];i.identifier=n,e.processOnEnd(i)}})),e.actives.length<n.maxNumberOfNipples&&e.processOnStart(i))})),e.manager.bindDocument(),!1},nt.prototype.processOnStart=function(t){var e,n=this,r=n.options,i=n.manager.getIdentifier(t),s=t.force||t.pressure||t.webkitForce||0,o={x:t.pageX,y:t.pageY},a=n.getOrCreate(i,o);a.identifier!==i&&n.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(e){e.trigger("start",e),n.trigger("start "+e.id+":start",e),e.show(),s>0&&n.pressureFn(t,e,e.identifier),n.processOnMove(t)};if((e=n.idles.indexOf(a))>=0&&n.idles.splice(e,1),n.actives.push(a),n.ids.push(a.identifier),"semi"!==r.mode)l(a);else{if(!(I(o,a.position)<=r.catchDistance))return a.destroy(),void n.processOnStart(t);l(a)}return a},nt.prototype.getOrCreate=function(t,e){var n,r=this,i=r.options;return/(semi|static)/.test(i.mode)?(n=r.idles[0])?(r.idles.splice(0,1),n):"semi"===i.mode?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):n=r.createNipple(e,t)},nt.prototype.processOnMove=function(t){var e=this,n=e.options,r=e.manager.getIdentifier(t),i=e.nipples.get(r),s=e.manager.scroll;if((t=>isNaN(t.buttons)?0!==t.pressure:0!==t.buttons)(t)){if(!i)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(n.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=r;var a=i.options.size/2,l={x:t.pageX,y:t.pageY};n.lockX&&(l.y=i.position.y),n.lockY&&(l.x=i.position.x);var u,h,c=I(l,i.position),d=((t,e)=>{const n=e.x-t.x,r=e.y-t.y;return L(Math.atan2(r,n))})(l,i.position),p=D(d),f=c/a,m={distance:c,position:l};if("circle"===i.options.shape?(u=Math.min(c,a),h=((t,e,n)=>{const r={x:0,y:0};return n=D(n),r.x=t.x-e*Math.cos(n),r.y=t.y-e*Math.sin(n),r})(i.position,u,d)):(h=((t,e,n)=>({x:Math.min(Math.max(t.x,e.x-n),e.x+n),y:Math.min(Math.max(t.y,e.y-n),e.y+n)}))(l,i.position,a),u=I(h,i.position)),n.follow){if(c>a){let t=l.x-h.x,n=l.y-h.y;i.position.x+=t,i.position.y+=n,i.el.style.top=i.position.y-(e.box.top+s.y)+"px",i.el.style.left=i.position.x-(e.box.left+s.x)+"px",c=I(l,i.position)}}else l=h,c=u;var g=l.x-i.position.x,y=l.y-i.position.y;i.frontPosition={x:g,y:y},n.dataOnly||(i.ui.front.style.transform="translate("+g+"px,"+y+"px)");var v={identifier:i.identifier,position:l,force:f,pressure:t.force||t.pressure||t.webkitForce||0,distance:c,angle:{radian:p,degree:d},vector:{x:g/a,y:-y/a},raw:m,instance:i,lockX:n.lockX,lockY:n.lockY};(v=i.computeDirection(v)).angle={radian:D(180-d),degree:180-d},i.trigger("move",v),e.trigger("move "+i.id+":move",v)}else this.processOnEnd(t)},nt.prototype.processOnEnd=function(t){var e=this,n=e.options,r=e.manager.getIdentifier(t),i=e.nipples.get(r),s=e.manager.removeIdentifier(i.identifier);i&&(n.dataOnly||i.hide((function(){"dynamic"===n.mode&&(i.trigger("removed",i),e.trigger("removed "+i.id+":removed",i),e.manager.trigger("removed "+i.id+":removed",i),i.destroy())})),clearInterval(e.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),e.trigger("end "+i.id+":end",i),e.ids.indexOf(i.identifier)>=0&&e.ids.splice(e.ids.indexOf(i.identifier),1),e.actives.indexOf(i)>=0&&e.actives.splice(e.actives.indexOf(i),1),/(semi|static)/.test(n.mode)?e.idles.push(i):e.nipples.indexOf(i)>=0&&e.nipples.splice(e.nipples.indexOf(i),1),e.manager.unbindDocument(),/(semi|static)/.test(n.mode)&&(e.manager.ids[s.id]=s.identifier))},nt.prototype.onDestroyed=function(t,e){var n=this;n.nipples.indexOf(e)>=0&&n.nipples.splice(n.nipples.indexOf(e),1),n.actives.indexOf(e)>=0&&n.actives.splice(n.actives.indexOf(e),1),n.idles.indexOf(e)>=0&&n.idles.splice(n.idles.indexOf(e),1),n.ids.indexOf(e.identifier)>=0&&n.ids.splice(n.ids.indexOf(e.identifier),1),n.manager.removeIdentifier(e.identifier),n.manager.unbindDocument()},nt.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach((function(t){t.destroy()})),t.pressureIntervals)t.pressureIntervals.hasOwnProperty(e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off()},rt.prototype=new tt,rt.constructor=rt,rt.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var n;return t.collections.every((function(t){return!(n=t.get(e))})),n}},rt.prototype.create=function(t){return this.createCollection(t)},rt.prototype.createCollection=function(t){var e=this,n=new nt(e,t);return e.bindCollection(n),e.collections.push(n),n},rt.prototype.bindCollection=function(t){var e,n=this,r=function(t,r){e=t.type+" "+r.id+":"+t.type,n.trigger(e,r)};t.on("destroyed",n.onDestroyed.bind(n)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},rt.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},rt.prototype.unbindDocument=function(t){var e=this;Object.keys(e.ids).length&&!0!==t||(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},rt.prototype.getIdentifier=function(t){var e;return t?void 0===(e=void 0===t.identifier?t.pointerId:t.identifier)&&(e=this.latest||0):e=this.index,void 0===this.ids[e]&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},rt.prototype.removeIdentifier=function(t){var e={};for(var n in this.ids)if(this.ids[n]===t){e.id=n,e.identifier=this.ids[n],delete this.ids[n];break}return e},rt.prototype.onmove=function(t){return this.onAny("move",t),!1},rt.prototype.onend=function(t){return this.onAny("end",t),!1},rt.prototype.oncancel=function(t){return this.onAny("end",t),!1},rt.prototype.onAny=function(t,e){var n,r=this,i="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=j(e);var s=function(t,e,n){n.ids.indexOf(e)>=0&&(n[i](t),t._found_=!0)};return $(e,(function(t){n=r.getIdentifier(t),$(r.collections,s.bind(null,t,n)),t._found_||r.removeIdentifier(n)})),!1},rt.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.ids={},t.index=0,t.collections.forEach((function(t){t.destroy()})),t.off()},rt.prototype.onDestroyed=function(t,e){var n=this;if(n.collections.indexOf(e)<0)return!1;n.collections.splice(n.collections.indexOf(e),1)};const it=new rt;var st,ot=function(t){return it.create(t)};function at(){return st||(st=1,m||(m=1,AFRAME.registerComponent("checkpoint-controls",{schema:{enabled:{default:!0},mode:{default:"teleport",oneOf:["teleport","animate"]},animateSpeed:{default:3}},init:function(){this.active=!0,this.checkpoint=null,this.isNavMeshConstrained=!1,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(t){const e=this.el;this.active&&this.checkpoint!==t&&(this.checkpoint&&e.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=t,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(e.emit("navigation-start",{checkpoint:t}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,e.emit("navigation-end",{checkpoint:t}),e.components["movement-controls"].updateNavLocation())))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(!this.active)return;const t=this.data,e=this.offset,n=this.position,r=this.targetPosition,i=this.checkpoint;return this.sync(),n.distanceTo(r)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:i}),e.set(0,0,0)):(e.setLength(t.animateSpeed),e)},sync:function(){const t=this.offset,e=this.position,n=this.targetPosition;e.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(n),n.add(this.checkpoint.components.checkpoint.getOffset()),t.copy(n).sub(e)}})),S(),function(){if(A)return E;A=1,O();const t=window.KeyboardEvent;E=AFRAME.registerComponent("keyboard-controls",{schema:{enabled:{default:!0},debug:{default:!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this),onContextMenu:this.onContextMenu.bind(this)}},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){const t=this.data,e=this.getKeys();return this.dVelocity.set(0,0,0),t.enabled&&((e.KeyW||e.ArrowUp)&&(this.dVelocity.z-=1),(e.KeyA||e.ArrowLeft)&&(this.dVelocity.x-=1),(e.KeyS||e.ArrowDown)&&(this.dVelocity.z+=1),(e.KeyD||e.ArrowRight)&&(this.dVelocity.x+=1),e.ShiftLeft&&(this.dVelocity=this.dVelocity.multiplyScalar(2))),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},attachEventListeners:function(){window.addEventListener("contextmenu",this.listeners.onContextMenu,!1),window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},onContextMenu:function(){for(const t in this.localKeys)this.localKeys.hasOwnProperty(t)&&delete this.localKeys[t]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(t){AFRAME.utils.shouldCaptureKeyEvent(t)&&(this.localKeys[t.code]=!0,this.emit(t))},onKeyUp:function(t){AFRAME.utils.shouldCaptureKeyEvent(t)&&(delete this.localKeys[t.code],this.emit(t))},onBlur:function(){for(const t in this.localKeys)this.localKeys.hasOwnProperty(t)&&delete this.localKeys[t]},emit:function(e){"__keyboard-controls-proxy"in e&&this.el.emit(e.type,e),this.el.emit(e.type+":"+e.code,new t(e.type,e)),this.data.debug&&console.log(e.type+":"+e.code)},isPressed:function(t){return t in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const t=this.el.sceneEl.components["proxy-controls"];return t&&t.isConnected()}})}(),C||(C=1,AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0},reverseEnabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods(),this.direction=0},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const t=this.el.sceneEl,e=t.canvas;if(!e)return void t.addEventListener("render-target-loaded",this.addEventListeners.bind(this));e.addEventListener("touchstart",this.onTouchStart,{passive:!0}),e.addEventListener("touchend",this.onTouchEnd,{passive:!0});const n=t.getAttribute("vr-mode-ui");n&&n.cardboardModeEnabled&&t.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const t=this.el.sceneEl&&this.el.sceneEl.canvas;t&&(t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchend",this.onTouchEnd),this.el.sceneEl.removeEventListener("enter-vr",this.onEnterVR))},isVelocityActive:function(){return this.data.enabled&&!!this.direction},getVelocityDelta:function(){return this.dVelocity.z=this.direction,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onEnterVR=this.onEnterVR.bind(this)},onTouchStart:function(t){this.direction=-1,this.data.reverseEnabled&&t.touches&&2===t.touches.length&&(this.direction=1),t.preventDefault()},onTouchEnd:function(t){this.direction=0,t.preventDefault()},onEnterVR:function(){const t=this.el.sceneEl.xrSession;t&&(t.addEventListener("selectstart",this.onTouchStart),t.addEventListener("selectend",this.onTouchEnd))}})),function(){if(N)return R;N=1;const t="-controls";R=AFRAME.registerComponent("movement-controls",{dependencies:["rotation"],schema:{enabled:{default:!0},controls:{default:["gamepad","trackpad","keyboard","touch"]},speed:{default:.3,min:0},fly:{default:!1},constrainToNavMesh:{default:!1},camera:{default:"[movement-controls] [camera]",type:"selector"}},init:function(){const t=this.el;this.data.camera||(this.data.camera=t.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,t.sceneEl.hasLoaded?this.injectControls():t.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(e){const n=this.el,r=this.data,i=n.sceneEl.systems.nav;if(n.sceneEl.hasLoaded&&this.injectControls(),i&&r.constrainToNavMesh!==e.constrainToNavMesh&&(r.constrainToNavMesh?i.addAgent(this):i.removeAgent(this)),r.enabled!==e.enabled)for(let e=0;e<r.controls.length;e++){const n=r.controls[e]+t;this.el.setAttribute(n,{enabled:this.data.enabled})}},injectControls:function(){const e=this.data;for(let n=0;n<e.controls.length;n++){const r=e.controls[n]+t;this.el.setAttribute(r,{enabled:this.data.enabled})}},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){const t=new THREE.Vector3,e=new THREE.Vector3,n=new THREE.Vector3;return function(r,i){if(!i)return;const s=this.el,o=this.data;if(!o.enabled)return;this.updateVelocityCtrl();const a=this.velocityCtrl,l=this.velocity;if(a)if(i/1e3>.2?l.set(0,0,0):this.updateVelocity(i),o.constrainToNavMesh&&!1!==a.isNavMeshConstrained){if(l.lengthSq()<1e-5)return;t.copy(s.object3D.position),e.copy(l).multiplyScalar(i/1e3).add(t);const r=s.sceneEl.systems.nav;this.navGroup=null===this.navGroup?r.getGroup(t):this.navGroup,this.navNode=this.navNode||r.getNode(t,this.navGroup),this.navNode=r.clampStep(t,e,this.navGroup,this.navNode,n),s.object3D.position.copy(n)}else s.hasAttribute("velocity")?s.setAttribute("velocity",l):(s.object3D.position.x+=l.x*i/1e3,s.object3D.position.y+=l.y*i/1e3,s.object3D.position.z+=l.z*i/1e3)}}(),updateVelocityCtrl:function(){const e=this.data;if(e.enabled){for(let n=0,r=e.controls.length;n<r;n++){const r=this.el.components[e.controls[n]+t];if(r&&r.isVelocityActive())return void(this.velocityCtrl=r)}this.velocityCtrl=null}},updateVelocity:function(){const t=new THREE.Vector2,e=new THREE.Quaternion;return function(n){let r;const i=this.el,s=this.velocityCtrl,o=this.velocity,a=this.data;if(s){if(!s.getVelocityDelta){if(s.getVelocity)return void o.copy(s.getVelocity());if(s.getPositionDelta)return void o.copy(s.getPositionDelta(n).multiplyScalar(1e3/n));throw new Error("Incompatible movement controls: ",s)}r=s.getVelocityDelta(n)}if(i.hasAttribute("velocity")&&!a.constrainToNavMesh&&o.copy(this.el.getAttribute("velocity")),r&&a.enabled){const n=a.camera;e.copy(n.object3D.quaternion),e.premultiply(i.object3D.quaternion),r.applyQuaternion(e);const s=r.length();a.fly?(o.copy(r),o.multiplyScalar(16.66667*this.data.speed)):(t.set(r.x,r.z),t.setLength(s*this.data.speed*16.66667),o.x=t.x,o.y=0,o.z=t.y),0===o.x&&0===o.y&&0===o.z||(this.eventDetail.velocity=o,this.el.emit("moved",this.eventDetail))}}}()})}(),P||(P=1,AFRAME.registerComponent("trackpad-controls",{schema:{enabled:{default:!0},enableNegX:{default:!0},enablePosX:{default:!0},enableNegZ:{default:!0},enablePosZ:{default:!0},mode:{default:"touch",oneOf:["swipe","touch","press"]}},init:function(){this.dVelocity=new THREE.Vector3,this.zVel=0,this.xVel=0,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const t=this.data,e=this.el.sceneEl;switch(e.addEventListener("axismove",this.onAxisMove),t.mode){case"swipe":case"touch":e.addEventListener("trackpadtouchstart",this.onTouchStart),e.addEventListener("trackpadtouchend",this.onTouchEnd);break;case"press":e.addEventListener("trackpaddown",this.onTouchStart),e.addEventListener("trackpadup",this.onTouchEnd)}},removeEventListeners:function(){const t=this.el.sceneEl;t.removeEventListener("axismove",this.onAxisMove),t.removeEventListener("trackpadtouchstart",this.onTouchStart),t.removeEventListener("trackpadtouchend",this.onTouchEnd),t.removeEventListener("trackpaddown",this.onTouchStart),t.removeEventListener("trackpadup",this.onTouchEnd)},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-this.zVel:1,this.dVelocity.x=this.isMoving?this.xVel:1,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onAxisMove=this.onAxisMove.bind(this)},onTouchStart:function(t){switch(this.data.mode){case"swipe":this.canRecordAxis=!0,this.startingAxisData=[];break;case"touch":case"press":this.isMoving=!0}t.preventDefault()},onTouchEnd:function(t){"swipe"==this.data.mode&&(this.startingAxisData=[]),this.isMoving=!1,t.preventDefault()},onAxisMove:function(t){switch(this.data.mode){case"swipe":return this.handleSwipeAxis(t);case"touch":case"press":return this.handleTouchAxis(t)}},handleSwipeAxis:function(t){const e=this.data,n=t.detail.axis;if(0===this.starting